- Revision
- 235696
- Author
- [email protected]
- Date
- 2018-09-05 14:52:17 -0700 (Wed, 05 Sep 2018)
Log Message
Cherry-pick r234718. rdar://problem/44144071
REGRESSION (r228260): Events handled by input method invoke default event handler
https://bugs.webkit.org/show_bug.cgi?id=188370
Reviewed by Wenson Hsieh.
Source/WebCore:
The bug was caused by the default event handler being invoked for the "virtual" keydown events
generated for input methods. Namely, when Japanese or Chinese input methods swallows TAB key,
WebKit should not invoke the default event handler and move the focus during input composition.
Fixed the bug by adding a new boolean on Event indicating whether the default event handler
should be invoked, and restoring the behavior prior to r228260 for these virtual keydown events.
Test: editing/input/press-tab-during-ime-composition.html
* dom/Event.h:
(WebCore::Event::isDefaultEventHandlerIgnored const): Added.
(WebCore::Event::setIsDefaultEventHandlerIgnored): Added.
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent): Don't invoke the default event handler if
isDefaultEventHandlerIgnored is set.
* page/EventHandler.cpp:
(WebCore::EventHandler::internalKeyEvent): Set isDefaultEventHandlerIgnored. This restores WebKit's
behavior prior to r228260.
LayoutTests:
Added a regression test. Due to the lack of adequate support of textInputController in WebKitTestRunner,
the test is only enabled in WebKit1. The WTR fix is tracked by https://webkit.org/b/188428.
* editing/input/press-tab-during-ime-composition-expected.txt: Added.
* editing/input/press-tab-during-ime-composition.html: Added.
* platform/ios/TestExpectations:
* platform/wk2/TestExpectations:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Added Paths
Diff
Modified: branches/safari-606-branch/LayoutTests/ChangeLog (235695 => 235696)
--- branches/safari-606-branch/LayoutTests/ChangeLog 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/LayoutTests/ChangeLog 2018-09-05 21:52:17 UTC (rev 235696)
@@ -1,3 +1,61 @@
+2018-09-05 Babak Shafiei <[email protected]>
+
+ Cherry-pick r234718. rdar://problem/44144071
+
+ REGRESSION (r228260): Events handled by input method invoke default event handler
+ https://bugs.webkit.org/show_bug.cgi?id=188370
+
+ Reviewed by Wenson Hsieh.
+
+ Source/WebCore:
+
+ The bug was caused by the default event handler being invoked for the "virtual" keydown events
+ generated for input methods. Namely, when Japanese or Chinese input methods swallows TAB key,
+ WebKit should not invoke the default event handler and move the focus during input composition.
+
+ Fixed the bug by adding a new boolean on Event indicating whether the default event handler
+ should be invoked, and restoring the behavior prior to r228260 for these virtual keydown events.
+
+ Test: editing/input/press-tab-during-ime-composition.html
+
+ * dom/Event.h:
+ (WebCore::Event::isDefaultEventHandlerIgnored const): Added.
+ (WebCore::Event::setIsDefaultEventHandlerIgnored): Added.
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::dispatchEvent): Don't invoke the default event handler if
+ isDefaultEventHandlerIgnored is set.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::internalKeyEvent): Set isDefaultEventHandlerIgnored. This restores WebKit's
+ behavior prior to r228260.
+
+ LayoutTests:
+
+ Added a regression test. Due to the lack of adequate support of textInputController in WebKitTestRunner,
+ the test is only enabled in WebKit1. The WTR fix is tracked by https://webkit.org/b/188428.
+
+ * editing/input/press-tab-during-ime-composition-expected.txt: Added.
+ * editing/input/press-tab-during-ime-composition.html: Added.
+ * platform/ios/TestExpectations:
+ * platform/wk2/TestExpectations:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2018-08-08 Ryosuke Niwa <[email protected]>
+
+ REGRESSION (r228260): Events handled by input method invoke default event handler
+ https://bugs.webkit.org/show_bug.cgi?id=188370
+
+ Reviewed by Wenson Hsieh.
+
+ Added a regression test. Due to the lack of adequate support of textInputController in WebKitTestRunner,
+ the test is only enabled in WebKit1. The WTR fix is tracked by https://webkit.org/b/188428.
+
+ * editing/input/press-tab-during-ime-composition-expected.txt: Added.
+ * editing/input/press-tab-during-ime-composition.html: Added.
+ * platform/ios/TestExpectations:
+ * platform/wk2/TestExpectations:
+
2018-08-14 Ryan Haddad <[email protected]>
Cherry-pick r234869. rdar://problem/42387347
Added: branches/safari-606-branch/LayoutTests/editing/input/press-tab-during-ime-composition-expected.txt (0 => 235696)
--- branches/safari-606-branch/LayoutTests/editing/input/press-tab-during-ime-composition-expected.txt (rev 0)
+++ branches/safari-606-branch/LayoutTests/editing/input/press-tab-during-ime-composition-expected.txt 2018-09-05 21:52:17 UTC (rev 235696)
@@ -0,0 +1,6 @@
+This test ensures WebKit does not execute the default event handler of keydown when the user presses TAB key while IME composition is taking place.
+To test manually, type "kyo" using Japanese hiragana keyboard in the first text field, and press TAB key.
+WebKit should not move the focus to the second text field.
+
+PASS
+
Added: branches/safari-606-branch/LayoutTests/editing/input/press-tab-during-ime-composition.html (0 => 235696)
--- branches/safari-606-branch/LayoutTests/editing/input/press-tab-during-ime-composition.html (rev 0)
+++ branches/safari-606-branch/LayoutTests/editing/input/press-tab-during-ime-composition.html 2018-09-05 21:52:17 UTC (rev 235696)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test ensures WebKit does not execute the default event handler of keydown when the user presses TAB key while IME composition is taking place.<br>
+To test manually, type "kyo" using Japanese hiragana keyboard in the first text field, and press TAB key.<br>
+WebKit should not move the focus to the second text field.</p>
+<div id="container">
+<label>First text field:<input id="first" type="text"></label><br>
+<label>Second text field:<input id="second" type="text" _onfocus_="log('FAIL: the second text field got focused')"></label><br>
+</div>
+<pre id="result"></pre>
+<script>
+
+const first = document.getElementById('first');
+function runTest() {
+ first.focus();
+ first.selectionStart = 0;
+ first.selectionEnd = 0;
+ textInputController.setInputMethodHandler(function (event) {
+ if (event.characters[0] == '\t') {
+ textInputController.setMarkedText("\u4eca\u65e5", 0, 2);
+ return true;
+ }
+ return false;
+ })
+ textInputController.setMarkedText("kyo", 0, 3);
+ eventSender.keyDown('\t');
+
+ if (document.activeElement != first)
+ return log('FAIL: the focus did not remain in the fisrt text field');
+
+ log('PASS');
+
+ document.getElementById('container').style.display = 'none';
+}
+
+function log(text) {
+ document.getElementById('result').textContent += text + '\n';
+}
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ runTest();
+}
+
+</script>
+</body>
+</html>
Modified: branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations (235695 => 235696)
--- branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations 2018-09-05 21:52:17 UTC (rev 235696)
@@ -810,6 +810,7 @@
editing/input/password-echo-passnode.html [ Skip ]
editing/input/password-echo-passnode2.html [ Skip ]
editing/input/password-echo-passnode3.html [ Skip ]
+editing/input/press-tab-during-ime-composition.html [ Skip ]
editing/input/reveal-caret-of-transformed-multiline-input.html [ Skip ]
editing/input/reveal-edit-on-input-vertically.html [ Skip ]
editing/input/reveal-contenteditable-on-input-vertically.html [ Skip ]
Modified: branches/safari-606-branch/LayoutTests/platform/wk2/TestExpectations (235695 => 235696)
--- branches/safari-606-branch/LayoutTests/platform/wk2/TestExpectations 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/LayoutTests/platform/wk2/TestExpectations 2018-09-05 21:52:17 UTC (rev 235696)
@@ -88,6 +88,9 @@
platform/mac/fast/text/attributed-substring-from-range.html
platform/mac/fast/text/justified-text-rect.html
+# [WebKit2] WebKitTestRunner doesn't support emulating pressing a tab key during IME composition
+webkit.org/b/188428 editing/input/press-tab-during-ime-composition.html
+
# WebKitTestRunner needs testRunner.setMainFrameIsFirstResponder
# <https://bugs.webkit.org/show_bug.cgi?id=42685>
editing/selection/caret-and-focus-ring.html
Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (235695 => 235696)
--- branches/safari-606-branch/Source/WebCore/ChangeLog 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog 2018-09-05 21:52:17 UTC (rev 235696)
@@ -1,3 +1,72 @@
+2018-09-05 Babak Shafiei <[email protected]>
+
+ Cherry-pick r234718. rdar://problem/44144071
+
+ REGRESSION (r228260): Events handled by input method invoke default event handler
+ https://bugs.webkit.org/show_bug.cgi?id=188370
+
+ Reviewed by Wenson Hsieh.
+
+ Source/WebCore:
+
+ The bug was caused by the default event handler being invoked for the "virtual" keydown events
+ generated for input methods. Namely, when Japanese or Chinese input methods swallows TAB key,
+ WebKit should not invoke the default event handler and move the focus during input composition.
+
+ Fixed the bug by adding a new boolean on Event indicating whether the default event handler
+ should be invoked, and restoring the behavior prior to r228260 for these virtual keydown events.
+
+ Test: editing/input/press-tab-during-ime-composition.html
+
+ * dom/Event.h:
+ (WebCore::Event::isDefaultEventHandlerIgnored const): Added.
+ (WebCore::Event::setIsDefaultEventHandlerIgnored): Added.
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::dispatchEvent): Don't invoke the default event handler if
+ isDefaultEventHandlerIgnored is set.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::internalKeyEvent): Set isDefaultEventHandlerIgnored. This restores WebKit's
+ behavior prior to r228260.
+
+ LayoutTests:
+
+ Added a regression test. Due to the lack of adequate support of textInputController in WebKitTestRunner,
+ the test is only enabled in WebKit1. The WTR fix is tracked by https://webkit.org/b/188428.
+
+ * editing/input/press-tab-during-ime-composition-expected.txt: Added.
+ * editing/input/press-tab-during-ime-composition.html: Added.
+ * platform/ios/TestExpectations:
+ * platform/wk2/TestExpectations:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2018-08-08 Ryosuke Niwa <[email protected]>
+
+ REGRESSION (r228260): Events handled by input method invoke default event handler
+ https://bugs.webkit.org/show_bug.cgi?id=188370
+
+ Reviewed by Wenson Hsieh.
+
+ The bug was caused by the default event handler being invoked for the "virtual" keydown events
+ generated for input methods. Namely, when Japanese or Chinese input methods swallows TAB key,
+ WebKit should not invoke the default event handler and move the focus during input composition.
+
+ Fixed the bug by adding a new boolean on Event indicating whether the default event handler
+ should be invoked, and restoring the behavior prior to r228260 for these virtual keydown events.
+
+ Test: editing/input/press-tab-during-ime-composition.html
+
+ * dom/Event.h:
+ (WebCore::Event::isDefaultEventHandlerIgnored const): Added.
+ (WebCore::Event::setIsDefaultEventHandlerIgnored): Added.
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::dispatchEvent): Don't invoke the default event handler if
+ isDefaultEventHandlerIgnored is set.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::internalKeyEvent): Set isDefaultEventHandlerIgnored. This restores WebKit's
+ behavior prior to r228260.
+
2018-08-03 Babak Shafiei <[email protected]>
Cherry-pick r234534. rdar://problem/42902608
Modified: branches/safari-606-branch/Source/WebCore/dom/Event.h (235695 => 235696)
--- branches/safari-606-branch/Source/WebCore/dom/Event.h 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/Source/WebCore/dom/Event.h 2018-09-05 21:52:17 UTC (rev 235696)
@@ -119,6 +119,9 @@
bool defaultHandled() const { return m_defaultHandled; }
void setDefaultHandled() { m_defaultHandled = true; }
+ bool isDefaultEventHandlerIgnored() const { return m_isDefaultEventHandlerIgnored; }
+ void setIsDefaultEventHandlerIgnored() { m_isDefaultEventHandlerIgnored = true; }
+
void setInPassiveListener(bool value) { m_isExecutingPassiveEventListener = value; }
bool cancelBubble() const { return propagationStopped(); }
@@ -156,6 +159,7 @@
bool m_immediatePropagationStopped { false };
bool m_wasCanceled { false };
bool m_defaultHandled { false };
+ bool m_isDefaultEventHandlerIgnored { false };
bool m_isTrusted { false };
bool m_isExecutingPassiveEventListener { false };
Modified: branches/safari-606-branch/Source/WebCore/dom/EventDispatcher.cpp (235695 => 235696)
--- branches/safari-606-branch/Source/WebCore/dom/EventDispatcher.cpp 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/Source/WebCore/dom/EventDispatcher.cpp 2018-09-05 21:52:17 UTC (rev 235696)
@@ -167,7 +167,7 @@
// Call default event handlers. While the DOM does have a concept of preventing
// default handling, the detail of which handlers are called is an internal
// implementation detail and not part of the DOM.
- if (!event.defaultPrevented() && !event.defaultHandled()) {
+ if (!event.defaultPrevented() && !event.defaultHandled() && !event.isDefaultEventHandlerIgnored()) {
// FIXME: Not clear why we need to reset the target for the default event handlers.
// We should research this, and remove this code if possible.
auto* finalTarget = event.target();
Modified: branches/safari-606-branch/Source/WebCore/page/EventHandler.cpp (235695 => 235696)
--- branches/safari-606-branch/Source/WebCore/page/EventHandler.cpp 2018-09-05 21:52:13 UTC (rev 235695)
+++ branches/safari-606-branch/Source/WebCore/page/EventHandler.cpp 2018-09-05 21:52:17 UTC (rev 235696)
@@ -3279,7 +3279,7 @@
keyDownEvent.setWindowsVirtualKeyCode(CompositionEventKeyCode);
keydown = KeyboardEvent::create(keyDownEvent, &m_frame.windowProxy());
keydown->setTarget(element);
- keydown->setDefaultHandled();
+ keydown->setIsDefaultEventHandlerIgnored();
}
if (accessibilityPreventsEventPropagation(keydown))