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

[VirtualKeyboard] Remove bounding rect from geometrychange event.

Removed the keyboard bounding rectangle from geometrychange event.
The keyboard rectangle is now a property of virtualKeyboard object.
It gets updated when the geometrychange event is fired. The keyboard
rectangle can also be captured from CSS env variables:
https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/VirtualKeyboardAPI/explainer.md#virtual-keyboard-visibility-change-css-environment-variables
This was also a feedback from TAG: https://github.com/w3ctag/design-reviews/issues/507#issuecomment-665473068

Bug: 1127749

Change-Id: Id7f19b0e091b820fa45ba4181d482559846d40ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466402
Commit-Queue: Anupam Snigdha <snianu@microsoft.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816395}
parent f6c02a26
...@@ -277,13 +277,11 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest, ...@@ -277,13 +277,11 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest,
const char kVirtualKeyboardDataURL[] = const char kVirtualKeyboardDataURL[] =
"data:text/html,<!DOCTYPE html>" "data:text/html,<!DOCTYPE html>"
"<script>" "<script>"
" let VKRect, x, y, width, height, numEvents = 0;" " let VKRect, numEvents = 0;"
" navigator.virtualKeyboard.overlaysContent = true;" " navigator.virtualKeyboard.overlaysContent = true;"
" navigator.virtualKeyboard.addEventListener('geometrychange'," " navigator.virtualKeyboard.addEventListener('geometrychange',"
" evt => {" " evt => {"
" numEvents++;" " numEvents++;"
" let r = evt.boundingRect;"
" x = r.x; y = r.y; width = r.width; height = r.height;"
" VKRect = navigator.virtualKeyboard.boundingRect" " VKRect = navigator.virtualKeyboard.boundingRect"
" }, false);" " }, false);"
"</script>"; "</script>";
...@@ -332,10 +330,6 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest, ...@@ -332,10 +330,6 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest,
const int expected_y = kKeyboardY - root_widget_origin.y(); const int expected_y = kKeyboardY - root_widget_origin.y();
EXPECT_EQ(1, EvalJs(shell(), "numEvents")); EXPECT_EQ(1, EvalJs(shell(), "numEvents"));
EXPECT_EQ(0, EvalJs(shell(), "x"));
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(0, EvalJs(shell(), "VKRect.x"));
EXPECT_EQ(expected_y, EvalJs(shell(), "VKRect.y")); EXPECT_EQ(expected_y, EvalJs(shell(), "VKRect.y"));
EXPECT_EQ(expected_width, EvalJs(shell(), "VKRect.width")); EXPECT_EQ(expected_width, EvalJs(shell(), "VKRect.width"));
...@@ -343,10 +337,6 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest, ...@@ -343,10 +337,6 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewAuraBrowserMockIMETest,
input_method_->GetMockKeyboardController()->NotifyObserversOnKeyboardHidden(); input_method_->GetMockKeyboardController()->NotifyObserversOnKeyboardHidden();
EXPECT_EQ(2, EvalJs(shell(), "numEvents")); EXPECT_EQ(2, EvalJs(shell(), "numEvents"));
EXPECT_EQ(0, EvalJs(shell(), "width"));
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.x"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.y")); EXPECT_EQ(0, EvalJs(shell(), "VKRect.y"));
EXPECT_EQ(0, EvalJs(shell(), "VKRect.width")); EXPECT_EQ(0, EvalJs(shell(), "VKRect.width"));
......
...@@ -661,7 +661,6 @@ static_idl_files_in_modules = get_path_info( ...@@ -661,7 +661,6 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/virtualkeyboard/navigator_virtual_keyboard.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.idl",
"//third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_geometry_change_event.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/navigator_wake_lock.idl",
"//third_party/blink/renderer/modules/wake_lock/wake_lock.idl", "//third_party/blink/renderer/modules/wake_lock/wake_lock.idl",
"//third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.idl", "//third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.idl",
......
...@@ -7,7 +7,4 @@ modules_idl_files = [ ...@@ -7,7 +7,4 @@ modules_idl_files = [
"virtual_keyboard_geometry_change_event.idl", "virtual_keyboard_geometry_change_event.idl",
] ]
modules_dictionary_idl_files =
[ "virtual_keyboard_geometry_change_event_init.idl" ]
modules_dependency_idl_files = [ "navigator_virtual_keyboard.idl" ] modules_dependency_idl_files = [ "navigator_virtual_keyboard.idl" ]
...@@ -85,7 +85,7 @@ void VirtualKeyboard::VirtualKeyboardOverlayChanged( ...@@ -85,7 +85,7 @@ void VirtualKeyboard::VirtualKeyboardOverlayChanged(
StyleEnvironmentVariables::FormatPx(keyboard_rect.height())); StyleEnvironmentVariables::FormatPx(keyboard_rect.height()));
} }
DispatchEvent(*(MakeGarbageCollected<VirtualKeyboardGeometryChangeEvent>( DispatchEvent(*(MakeGarbageCollected<VirtualKeyboardGeometryChangeEvent>(
event_type_names::kGeometrychange, bounding_rect_))); event_type_names::kGeometrychange)));
} }
void VirtualKeyboard::show() { void VirtualKeyboard::show() {
......
...@@ -4,31 +4,15 @@ ...@@ -4,31 +4,15 @@
#include "third_party/blink/renderer/modules/virtualkeyboard/virtual_keyboard_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_geometry_change_event_init.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
namespace blink { namespace blink {
VirtualKeyboardGeometryChangeEvent* VirtualKeyboardGeometryChangeEvent::Create( VirtualKeyboardGeometryChangeEvent* VirtualKeyboardGeometryChangeEvent::Create(
const AtomicString& type, const AtomicString& type) {
const VirtualKeyboardGeometryChangeEventInit* initializer) { return MakeGarbageCollected<VirtualKeyboardGeometryChangeEvent>(type);
return MakeGarbageCollected<VirtualKeyboardGeometryChangeEvent>(type,
initializer);
} }
VirtualKeyboardGeometryChangeEvent::VirtualKeyboardGeometryChangeEvent( VirtualKeyboardGeometryChangeEvent::VirtualKeyboardGeometryChangeEvent(
const AtomicString& type, const AtomicString& type)
const VirtualKeyboardGeometryChangeEventInit* initializer) : Event(type, Bubbles::kNo, Cancelable::kNo) {}
: Event(type, initializer) {}
VirtualKeyboardGeometryChangeEvent::VirtualKeyboardGeometryChangeEvent(
const AtomicString& type,
DOMRect* rect)
: Event(type, Bubbles::kNo, Cancelable::kNo), bounding_rect_(rect) {}
void VirtualKeyboardGeometryChangeEvent::Trace(Visitor* visitor) const {
visitor->Trace(bounding_rect_);
Event::Trace(visitor);
}
} // namespace blink } // namespace blink
...@@ -10,28 +10,13 @@ ...@@ -10,28 +10,13 @@
namespace blink { namespace blink {
class DOMRect;
class VirtualKeyboardGeometryChangeEventInit;
class VirtualKeyboardGeometryChangeEvent final : public Event { class VirtualKeyboardGeometryChangeEvent final : public Event {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
static VirtualKeyboardGeometryChangeEvent* Create( static VirtualKeyboardGeometryChangeEvent* Create(const AtomicString& type);
const AtomicString& type,
const VirtualKeyboardGeometryChangeEventInit*);
VirtualKeyboardGeometryChangeEvent(
const AtomicString& type,
const VirtualKeyboardGeometryChangeEventInit*);
VirtualKeyboardGeometryChangeEvent(const AtomicString& type, DOMRect*);
DOMRect* boundingRect() const { return bounding_rect_; }
void Trace(Visitor*) const override;
private: explicit VirtualKeyboardGeometryChangeEvent(const AtomicString& type);
Member<DOMRect> bounding_rect_;
}; };
} // namespace blink } // namespace blink
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
Exposed=Window, Exposed=Window,
RuntimeEnabled=VirtualKeyboard RuntimeEnabled=VirtualKeyboard
] interface VirtualKeyboardGeometryChangeEvent : Event { ] interface VirtualKeyboardGeometryChangeEvent : Event {
constructor(DOMString type, VirtualKeyboardGeometryChangeEventInit eventInitDict); constructor(DOMString type);
[SameObject] readonly attribute DOMRect boundingRect;
}; };
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
dictionary VirtualKeyboardGeometryChangeEventInit : EventInit {
required DOMRect boundingRect;
};
...@@ -8816,7 +8816,6 @@ interface VirtualKeyboard : EventTarget ...@@ -8816,7 +8816,6 @@ interface VirtualKeyboard : EventTarget
setter overlaysContent setter overlaysContent
interface VirtualKeyboardGeometryChangeEvent : Event interface VirtualKeyboardGeometryChangeEvent : Event
attribute @@toStringTag attribute @@toStringTag
getter boundingRect
method constructor method constructor
interface VisibilityStateEntry : PerformanceEntry interface VisibilityStateEntry : PerformanceEntry
attribute @@toStringTag attribute @@toStringTag
......
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