Commit e1971903 authored by Anupam Snigdha's avatar Anupam Snigdha Committed by Commit Bot

[VirtualKeyboard] Address TAG review feedback on VirtualKeyboard APIs.

Below were some feedbacks from TAG
(https://github.com/w3ctag/design-reviews/issues/507):
1. Changed overlaygeometrychange event to geometrychange as it is fired
on the virtualKeyboard object.
2. Added boundingRect to virtualkeyboard object so web authors can query
whenever they want to know the last VK geometry values that was reported.

Bug: 856269

Change-Id: I7408133aa907fbf11d375c89417364059f2b3fc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2240458Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Anupam Snigdha <snianu@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#777563}
parent 24c5e485
......@@ -113,13 +113,14 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest,
const char kVirtualKeyboardDataURL[] =
"data:text/html,<!DOCTYPE html>"
"<script>"
" let x, y, width, height, numEvents = 0;"
" let VKRect, x, y, width, height, numEvents = 0;"
" navigator.virtualKeyboard.overlaysContent = true;"
" navigator.virtualKeyboard.addEventListener('overlaygeometrychange',"
" navigator.virtualKeyboard.addEventListener('geometrychange',"
" evt => {"
" numEvents++;"
" let r = evt.boundingRect;"
" x = r.x; y = r.y; width = r.width; height = r.height;"
" VKRect = navigator.virtualKeyboard.boundingRect"
" }, false);"
"</script>";
EXPECT_TRUE(NavigateToURL(shell(), GURL(kVirtualKeyboardDataURL)));
......@@ -172,6 +173,10 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest,
EXPECT_EQ(expected_y, EvalJs(shell(), "y"));
EXPECT_EQ(expected_width, EvalJs(shell(), "width"));
EXPECT_EQ(kKeyboardHeight, EvalJs(shell(), "height"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.x"));
EXPECT_EQ(expected_y, EvalJs(shell(), "VKRect.y"));
EXPECT_EQ(expected_width, EvalJs(shell(), "VKRect.width"));
EXPECT_EQ(kKeyboardHeight, EvalJs(shell(), "VKRect.height"));
input_method_->GetMockKeyboardController()->NotifyObserversOnKeyboardHidden();
EXPECT_EQ(2, EvalJs(shell(), "numEvents"));
......@@ -179,6 +184,10 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest,
EXPECT_EQ(0, EvalJs(shell(), "height"));
EXPECT_EQ(0, EvalJs(shell(), "x"));
EXPECT_EQ(0, EvalJs(shell(), "y"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.x"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.y"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.width"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.height"));
// Flip the policy back to non-overlay, verify the event doesn't fire
ignore_result(
......
......@@ -656,8 +656,8 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/video_rvfc/video_frame_request_callback.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/navigator_virtual_keyboard.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_overlay_geometry_change_event.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_overlay_geometry_change_event_init.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_geometry_change_event.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_geometry_change_event_init.idl",
"//third_party/blink/renderer/modules/wake_lock/navigator_wake_lock.idl",
"//third_party/blink/renderer/modules/wake_lock/wake_lock.idl",
"//third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.idl",
......
......@@ -136,6 +136,7 @@
"gattserverdisconnected",
"geofenceenter",
"geofenceleave",
"geometrychange",
"gesturelongpress",
"gesturescrollend",
"gesturescrollstart",
......@@ -199,7 +200,6 @@
"open",
"orientationchange",
"overscroll",
"overlaygeometrychange",
"pagehide",
"pageshow",
"paste",
......
......@@ -10,7 +10,7 @@ blink_modules_sources("virtualkeyboard") {
"navigator_virtual_keyboard.h",
"virtual_keyboard.cc",
"virtual_keyboard.h",
"virtual_keyboard_overlay_geometry_change_event.cc",
"virtual_keyboard_overlay_geometry_change_event.h",
"virtual_keyboard_geometry_change_event.cc",
"virtual_keyboard_geometry_change_event.h",
]
}
......@@ -4,10 +4,10 @@
modules_idl_files = [
"virtual_keyboard.idl",
"virtual_keyboard_overlay_geometry_change_event.idl",
"virtual_keyboard_geometry_change_event.idl",
]
modules_dictionary_idl_files =
[ "virtual_keyboard_overlay_geometry_change_event_init.idl" ]
[ "virtual_keyboard_geometry_change_event_init.idl" ]
modules_dependency_idl_files = [ "navigator_virtual_keyboard.idl" ]
......@@ -10,7 +10,7 @@
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_overlay_geometry_change_event.h"
#include "third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_geometry_change_event.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
......@@ -35,6 +35,10 @@ bool VirtualKeyboard::overlaysContent() const {
return overlays_content_;
}
DOMRect* VirtualKeyboard::boundingRect() const {
return bounding_rect_;
}
void VirtualKeyboard::setOverlaysContent(bool overlays_content) {
LocalFrame* frame = GetFrame();
if (frame && frame->IsMainFrame()) {
......@@ -55,10 +59,9 @@ void VirtualKeyboard::setOverlaysContent(bool overlays_content) {
void VirtualKeyboard::VirtualKeyboardOverlayChanged(
const gfx::Rect& keyboard_rect) {
DispatchEvent(
*(MakeGarbageCollected<VirtualKeyboardOverlayGeometryChangeEvent>(
event_type_names::kOverlaygeometrychange,
DOMRect::FromFloatRect(FloatRect(gfx::RectF(keyboard_rect))))));
bounding_rect_ = DOMRect::FromFloatRect(FloatRect(gfx::RectF(keyboard_rect)));
DispatchEvent(*(MakeGarbageCollected<VirtualKeyboardGeometryChangeEvent>(
event_type_names::kGeometrychange, bounding_rect_)));
}
void VirtualKeyboard::show() {
......@@ -85,6 +88,7 @@ void VirtualKeyboard::hide() {
}
void VirtualKeyboard::Trace(Visitor* visitor) const {
visitor->Trace(bounding_rect_);
EventTargetWithInlineData::Trace(visitor);
ExecutionContextClient::Trace(visitor);
}
......
......@@ -17,6 +17,7 @@ class Rect;
namespace blink {
class DOMRect;
class ExecutionContext;
// The VirtualKeyboard API provides control of the on-screen keyboard
......@@ -38,10 +39,11 @@ class VirtualKeyboard final : public EventTargetWithInlineData,
ExecutionContext* GetExecutionContext() const override;
const AtomicString& InterfaceName() const override;
DEFINE_ATTRIBUTE_EVENT_LISTENER(overlaygeometrychange, kOverlaygeometrychange)
DEFINE_ATTRIBUTE_EVENT_LISTENER(geometrychange, kGeometrychange)
bool overlaysContent() const;
void setOverlaysContent(bool overlays_content);
DOMRect* boundingRect() const;
void VirtualKeyboardOverlayChanged(const gfx::Rect&) final;
......@@ -53,6 +55,7 @@ class VirtualKeyboard final : public EventTargetWithInlineData,
private:
bool overlays_content_ = false;
Member<DOMRect> bounding_rect_;
};
} // namespace blink
......
......@@ -12,6 +12,7 @@
] interface VirtualKeyboard : EventTarget {
void show();
void hide();
attribute EventHandler onoverlaygeometrychange;
readonly attribute DOMRect boundingRect;
attribute boolean overlaysContent;
attribute EventHandler ongeometrychange;
};
......@@ -2,33 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_overlay_geometry_change_event.h"
#include "third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_geometry_change_event.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_virtual_keyboard_overlay_geometry_change_event_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_virtual_keyboard_geometry_change_event_init.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
namespace blink {
VirtualKeyboardOverlayGeometryChangeEvent*
VirtualKeyboardOverlayGeometryChangeEvent::Create(
VirtualKeyboardGeometryChangeEvent* VirtualKeyboardGeometryChangeEvent::Create(
const AtomicString& type,
const VirtualKeyboardOverlayGeometryChangeEventInit* initializer) {
return MakeGarbageCollected<VirtualKeyboardOverlayGeometryChangeEvent>(
type, initializer);
const VirtualKeyboardGeometryChangeEventInit* initializer) {
return MakeGarbageCollected<VirtualKeyboardGeometryChangeEvent>(type,
initializer);
}
VirtualKeyboardOverlayGeometryChangeEvent::
VirtualKeyboardOverlayGeometryChangeEvent(
const AtomicString& type,
const VirtualKeyboardOverlayGeometryChangeEventInit* initializer)
VirtualKeyboardGeometryChangeEvent::VirtualKeyboardGeometryChangeEvent(
const AtomicString& type,
const VirtualKeyboardGeometryChangeEventInit* initializer)
: Event(type, initializer) {}
VirtualKeyboardOverlayGeometryChangeEvent::
VirtualKeyboardOverlayGeometryChangeEvent(const AtomicString& type,
DOMRect* rect)
VirtualKeyboardGeometryChangeEvent::VirtualKeyboardGeometryChangeEvent(
const AtomicString& type,
DOMRect* rect)
: Event(type, Bubbles::kNo, Cancelable::kNo), bounding_rect_(rect) {}
void VirtualKeyboardOverlayGeometryChangeEvent::Trace(Visitor* visitor) const {
void VirtualKeyboardGeometryChangeEvent::Trace(Visitor* visitor) const {
visitor->Trace(bounding_rect_);
Event::Trace(visitor);
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_VIRTUALKEYBOARD_VIRTUAL_KEYBOARD_OVERLAY_GEOMETRY_CHANGE_EVENT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_VIRTUALKEYBOARD_VIRTUAL_KEYBOARD_OVERLAY_GEOMETRY_CHANGE_EVENT_H_
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_VIRTUALKEYBOARD_VIRTUAL_KEYBOARD_GEOMETRY_CHANGE_EVENT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_VIRTUALKEYBOARD_VIRTUAL_KEYBOARD_GEOMETRY_CHANGE_EVENT_H_
#include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
......@@ -11,20 +11,20 @@
namespace blink {
class DOMRect;
class VirtualKeyboardOverlayGeometryChangeEventInit;
class VirtualKeyboardGeometryChangeEventInit;
class VirtualKeyboardOverlayGeometryChangeEvent final : public Event {
class VirtualKeyboardGeometryChangeEvent final : public Event {
DEFINE_WRAPPERTYPEINFO();
public:
static VirtualKeyboardOverlayGeometryChangeEvent* Create(
static VirtualKeyboardGeometryChangeEvent* Create(
const AtomicString& type,
const VirtualKeyboardOverlayGeometryChangeEventInit*);
const VirtualKeyboardGeometryChangeEventInit*);
VirtualKeyboardOverlayGeometryChangeEvent(
VirtualKeyboardGeometryChangeEvent(
const AtomicString& type,
const VirtualKeyboardOverlayGeometryChangeEventInit*);
VirtualKeyboardOverlayGeometryChangeEvent(const AtomicString& type, DOMRect*);
const VirtualKeyboardGeometryChangeEventInit*);
VirtualKeyboardGeometryChangeEvent(const AtomicString& type, DOMRect*);
DOMRect* boundingRect() const { return bounding_rect_; }
......@@ -36,4 +36,4 @@ class VirtualKeyboardOverlayGeometryChangeEvent final : public Event {
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_VIRTUALKEYBOARD_VIRTUAL_KEYBOARD_OVERLAY_GEOMETRY_CHANGE_EVENT_H_
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_VIRTUALKEYBOARD_VIRTUAL_KEYBOARD_GEOMETRY_CHANGE_EVENT_H_
......@@ -9,8 +9,8 @@
[
Exposed=Window,
RuntimeEnabled=VirtualKeyboard
] interface VirtualKeyboardOverlayGeometryChangeEvent : Event {
constructor(DOMString type, VirtualKeyboardOverlayGeometryChangeEventInit eventInitDict);
] interface VirtualKeyboardGeometryChangeEvent : Event {
constructor(DOMString type, VirtualKeyboardGeometryChangeEventInit eventInitDict);
[SameObject] readonly attribute DOMRect boundingRect;
};
......@@ -2,6 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
dictionary VirtualKeyboardOverlayGeometryChangeEventInit : EventInit {
dictionary VirtualKeyboardGeometryChangeEventInit : EventInit {
required DOMRect boundingRect;
};
......@@ -56,7 +56,8 @@ PASS window.cached_navigator_userActivation.isActive is false
PASS window.cached_navigator_userAgentData.brands[0].brand is ''
PASS window.cached_navigator_userAgentData.brands[0].version is ''
PASS window.cached_navigator_userAgentData.mobile is false
PASS window.cached_navigator_virtualKeyboard.onoverlaygeometrychange is null
PASS window.cached_navigator_virtualKeyboard.boundingRect is null
PASS window.cached_navigator_virtualKeyboard.ongeometrychange is null
PASS window.cached_navigator_virtualKeyboard.overlaysContent is false
PASS window.cached_navigator_xr.ondevicechange is null
PASS window.cached_performance.onresourcetimingbufferfull is null
......
......@@ -56,7 +56,8 @@ PASS window.cached_navigator_userActivation.isActive is false
PASS window.cached_navigator_userAgentData.brands[0].brand is ''
PASS window.cached_navigator_userAgentData.brands[0].version is ''
PASS window.cached_navigator_userAgentData.mobile is false
PASS window.cached_navigator_virtualKeyboard.onoverlaygeometrychange is null
PASS window.cached_navigator_virtualKeyboard.boundingRect is null
PASS window.cached_navigator_virtualKeyboard.ongeometrychange is null
PASS window.cached_navigator_virtualKeyboard.overlaysContent is false
PASS window.cached_navigator_xr.ondevicechange is null
PASS window.cached_performance.onresourcetimingbufferfull is null
......
......@@ -56,7 +56,8 @@ PASS window.cached_navigator_userActivation.isActive is false
PASS window.cached_navigator_userAgentData.brands[0].brand is ''
PASS window.cached_navigator_userAgentData.brands[0].version is ''
PASS window.cached_navigator_userAgentData.mobile is false
PASS window.cached_navigator_virtualKeyboard.onoverlaygeometrychange is null
PASS window.cached_navigator_virtualKeyboard.boundingRect is null
PASS window.cached_navigator_virtualKeyboard.ongeometrychange is null
PASS window.cached_navigator_virtualKeyboard.overlaysContent is false
PASS window.cached_navigator_xr.ondevicechange is null
PASS window.cached_performance.onresourcetimingbufferfull is null
......
......@@ -65,7 +65,8 @@ PASS oldChildWindow.navigator.userAgentData.brands[0].version is newChildWindow.
PASS oldChildWindow.navigator.userAgentData.mobile is newChildWindow.navigator.userAgentData.mobile
PASS oldChildWindow.navigator.vendor is newChildWindow.navigator.vendor
PASS oldChildWindow.navigator.vendorSub is newChildWindow.navigator.vendorSub
PASS oldChildWindow.navigator.virtualKeyboard.onoverlaygeometrychange is newChildWindow.navigator.virtualKeyboard.onoverlaygeometrychange
PASS oldChildWindow.navigator.virtualKeyboard.boundingRect is newChildWindow.navigator.virtualKeyboard.boundingRect
PASS oldChildWindow.navigator.virtualKeyboard.ongeometrychange is newChildWindow.navigator.virtualKeyboard.ongeometrychange
PASS oldChildWindow.navigator.virtualKeyboard.overlaysContent is newChildWindow.navigator.virtualKeyboard.overlaysContent
PASS oldChildWindow.navigator.xr.ondevicechange is newChildWindow.navigator.xr.ondevicechange
PASS oldChildWindow.onabort is newChildWindow.onabort
......
......@@ -33,7 +33,8 @@ PASS childWindow.navigator.userActivation.isActive is false
PASS childWindow.navigator.userAgent is ''
PASS childWindow.navigator.vendor is window.navigator.vendor
PASS childWindow.navigator.vendorSub is ''
PASS childWindow.navigator.virtualKeyboard.onoverlaygeometrychange is null
PASS childWindow.navigator.virtualKeyboard.boundingRect is null
PASS childWindow.navigator.virtualKeyboard.ongeometrychange is null
PASS childWindow.navigator.virtualKeyboard.overlaysContent is false
PASS childWindow.onabort is null
PASS childWindow.onafterprint is null
......
......@@ -33,7 +33,8 @@ PASS childWindow.navigator.userActivation.isActive is false
PASS childWindow.navigator.userAgent is ''
PASS childWindow.navigator.vendor is window.navigator.vendor
PASS childWindow.navigator.vendorSub is ''
PASS childWindow.navigator.virtualKeyboard.onoverlaygeometrychange is null
PASS childWindow.navigator.virtualKeyboard.boundingRect is null
PASS childWindow.navigator.virtualKeyboard.ongeometrychange is null
PASS childWindow.navigator.virtualKeyboard.overlaysContent is false
PASS childWindow.onabort is null
PASS childWindow.onafterprint is null
......
......@@ -8790,14 +8790,15 @@ interface VideoTrackWriter
method constructor
interface VirtualKeyboard : EventTarget
attribute @@toStringTag
getter onoverlaygeometrychange
getter boundingRect
getter ongeometrychange
getter overlaysContent
method constructor
method hide
method show
setter onoverlaygeometrychange
setter ongeometrychange
setter overlaysContent
interface VirtualKeyboardOverlayGeometryChangeEvent : Event
interface VirtualKeyboardGeometryChangeEvent : Event
attribute @@toStringTag
getter boundingRect
method constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment