Title: [242518] trunk
Revision
242518
Author
dba...@webkit.org
Date
2019-03-05 15:40:08 -0800 (Tue, 05 Mar 2019)

Log Message

[iOS] Should not scroll when checkbox, radio, submit, reset, or button is spacebar activated
https://bugs.webkit.org/show_bug.cgi?id=195281
<rdar://problem/48564347>

Reviewed by Simon Fraser.

Source/WebCore:

Do not call the base class's default event handler (HTMLTextFormControlElement::defaultEventHandler())
when WebCore sees a keydown of the spacebar as we consider such an event as handled.
Otherwise, calling the base class's default event handler ultimately gives the embedding
client a chance to wrongly handle the event. In the case of iOS, keydown of the spacebar
causes the page to scroll.

WebCore implements spacebar activation on keydown for form controls. For IE compatibility
WebCore does not mark such keydown events as handled so that a DOM keypress event will
be subsequently dispatched. The current logic only skips calling the base class's default
event handler if the DOM event was not marked handled. This is insufficient. We need to
know whether WebCore handled the event. If asking the input type to handle the key down
marks the DOM event as handled then, clearly, WebCore handled the event. However, if the
event is not marked as handled, but WebCore actually accounted for this event then we need
to know this so that we do not call the base class's default event handler and ultimately
the embedding client asking for an interpretation of the key event. Towards this, have
InputType::handleKeydownEvent() return a bit whether or not the base class's default
event handler should be invoked.

Tests: fast/events/ios/activating-button-should-not-scroll-page.html
       fast/events/ios/activating-checkbox-should-not-scroll-page.html
       fast/events/ios/activating-radio-button-should-not-scroll-page.html
       fast/events/ios/activating-reset-button-should-not-scroll-page.html
       fast/events/ios/activating-submit-button-should-not-scroll-page.html

* html/BaseCheckableInputType.cpp:
(WebCore::BaseCheckableInputType::handleKeydownEvent): Return ShouldCallBaseEventHandler::No
if WebCore handled the spacebar activation. Otherewise, return ShouldCallBaseEventHandler::Yes.
* html/BaseCheckableInputType.h:
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent): Ditto.
* html/BaseChooserOnlyDateAndTimeInputType.h:
* html/BaseClickableWithKeyInputType.cpp:
(WebCore::BaseClickableWithKeyInputType::handleKeydownEvent): Keep our current behavior by returning ShouldCallBaseEventHandler::Yes.
* html/BaseClickableWithKeyInputType.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler): Do not fallthrough and call the base class's default
event handler if the input type told us it handled the event regardless of whether the event was handled
from the perspective of the DOM.
* html/InputType.cpp:
(WebCore::InputType::handleKeydownEvent): Keep our current behavior by returning ShouldCallBaseEventHandler::Yes.
* html/InputType.h:

* html/NumberInputType.cpp:
(WebCore::NumberInputType::handleKeydownEvent):
* html/NumberInputType.h:
* html/RadioInputType.cpp:
(WebCore::RadioInputType::handleKeydownEvent):
* html/RadioInputType.h:
* html/RangeInputType.cpp:
(WebCore::RangeInputType::handleKeydownEvent):
* html/RangeInputType.h:
* html/SearchInputType.cpp:
(WebCore::SearchInputType::handleKeydownEvent):
* html/SearchInputType.h:
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleKeydownEvent):
* html/TextFieldInputType.h:
Keep our current behavior by returning ShouldCallBaseEventHandler::Yes.

LayoutTests:

Add some tests to ensure that we do not scroll when a checkbox, radio, submit, reset, or button
is spacebar activated.

* fast/events/ios/activating-button-should-not-scroll-page-expected.txt: Added.
* fast/events/ios/activating-button-should-not-scroll-page.html: Added.
* fast/events/ios/activating-checkbox-should-not-scroll-page-expected.txt: Added.
* fast/events/ios/activating-checkbox-should-not-scroll-page.html: Added.
* fast/events/ios/activating-radio-button-should-not-scroll-page-expected.txt: Added.
* fast/events/ios/activating-radio-button-should-not-scroll-page.html: Added.
* fast/events/ios/activating-reset-button-should-not-scroll-page-expected.txt: Added.
* fast/events/ios/activating-reset-button-should-not-scroll-page.html: Added.
* fast/events/ios/activating-submit-button-should-not-scroll-page-expected.txt: Added.
* fast/events/ios/activating-submit-button-should-not-scroll-page.html: Added.
* fast/events/ios/resources/press-spacebar-at-element-and-check-for-page-scroll.js: Added.
(done):
(handleInteraction.checkForScrollAndDone):
(handleInteraction):
(handleScroll):
(handleFocus):
(checkActivatingElementUsingSpacebarDoesNotScrollPage):
* platform/ios/TestExpectations: Skip the tests for now until ENABLE(FULL_KEYBOARD_ACCESS) is enabled
by default on iOS.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242517 => 242518)


--- trunk/LayoutTests/ChangeLog	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/LayoutTests/ChangeLog	2019-03-05 23:40:08 UTC (rev 242518)
@@ -1,3 +1,34 @@
+2019-03-05  Daniel Bates  <daba...@apple.com>
+
+        [iOS] Should not scroll when checkbox, radio, submit, reset, or button is spacebar activated
+        https://bugs.webkit.org/show_bug.cgi?id=195281
+        <rdar://problem/48564347>
+
+        Reviewed by Simon Fraser.
+
+        Add some tests to ensure that we do not scroll when a checkbox, radio, submit, reset, or button
+        is spacebar activated.
+
+        * fast/events/ios/activating-button-should-not-scroll-page-expected.txt: Added.
+        * fast/events/ios/activating-button-should-not-scroll-page.html: Added.
+        * fast/events/ios/activating-checkbox-should-not-scroll-page-expected.txt: Added.
+        * fast/events/ios/activating-checkbox-should-not-scroll-page.html: Added.
+        * fast/events/ios/activating-radio-button-should-not-scroll-page-expected.txt: Added.
+        * fast/events/ios/activating-radio-button-should-not-scroll-page.html: Added.
+        * fast/events/ios/activating-reset-button-should-not-scroll-page-expected.txt: Added.
+        * fast/events/ios/activating-reset-button-should-not-scroll-page.html: Added.
+        * fast/events/ios/activating-submit-button-should-not-scroll-page-expected.txt: Added.
+        * fast/events/ios/activating-submit-button-should-not-scroll-page.html: Added.
+        * fast/events/ios/resources/press-spacebar-at-element-and-check-for-page-scroll.js: Added.
+        (done):
+        (handleInteraction.checkForScrollAndDone):
+        (handleInteraction):
+        (handleScroll):
+        (handleFocus):
+        (checkActivatingElementUsingSpacebarDoesNotScrollPage):
+        * platform/ios/TestExpectations: Skip the tests for now until ENABLE(FULL_KEYBOARD_ACCESS) is enabled
+        by default on iOS.
+
 2019-03-05  Takashi Komori  <takashi.kom...@sony.com>
 
         [Curl] Implement Cookie Accept Policy.

Added: trunk/LayoutTests/fast/events/ios/activating-button-should-not-scroll-page-expected.txt (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-button-should-not-scroll-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-button-should-not-scroll-page-expected.txt	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,10 @@
+Tests that activating a button (focusing it and pressing the spacebar) does not cause the page to scroll.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/activating-button-should-not-scroll-page.html (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-button-should-not-scroll-page.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-button-should-not-scroll-page.html	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body style="height: 4096px"> <!-- Make the page really long to force vertical scrollbars. -->
+<p id="description"></p>
+<p id="test-container"><button id="test">Tap me</button></p>
+<div id="console"></div>
+<script>
+description("Tests that activating a button (focusing it and pressing the spacebar) does not cause the page to scroll.");
+checkActivatingElementUsingSpacebarDoesNotScrollPage(document.getElementById("test-container"), document.getElementById("test"), "click");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/ios/activating-checkbox-should-not-scroll-page-expected.txt (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-checkbox-should-not-scroll-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-checkbox-should-not-scroll-page-expected.txt	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,10 @@
+Tests that activating a checkbox (focusing it and pressing the spacebar) does not cause the page to scroll.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/activating-checkbox-should-not-scroll-page.html (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-checkbox-should-not-scroll-page.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-checkbox-should-not-scroll-page.html	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body style="height: 4096px"> <!-- Make the page really long to force vertical scrollbars. -->
+<p id="description"></p>
+<p id="test-container"><input id="test" type="checkbox"></p>
+<div id="console"></div>
+<script>
+description("Tests that activating a checkbox (focusing it and pressing the spacebar) does not cause the page to scroll.");
+checkActivatingElementUsingSpacebarDoesNotScrollPage(document.getElementById("test-container"), document.getElementById("test"), "change");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/ios/activating-radio-button-should-not-scroll-page-expected.txt (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-radio-button-should-not-scroll-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-radio-button-should-not-scroll-page-expected.txt	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,10 @@
+Tests that activating a radio button (focusing it and pressing the spacebar) does not cause the page to scroll.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/activating-radio-button-should-not-scroll-page.html (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-radio-button-should-not-scroll-page.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-radio-button-should-not-scroll-page.html	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body style="height: 4096px"> <!-- Make the page really long to force vertical scrollbars. -->
+<p id="description"></p>
+<p id="test-container"><input id="test" type="radio"></p>
+<div id="console"></div>
+<script>
+description("Tests that activating a radio button (focusing it and pressing the spacebar) does not cause the page to scroll.");
+checkActivatingElementUsingSpacebarDoesNotScrollPage(document.getElementById("test-container"), document.getElementById("test"), "change");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/ios/activating-reset-button-should-not-scroll-page-expected.txt (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-reset-button-should-not-scroll-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-reset-button-should-not-scroll-page-expected.txt	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,10 @@
+Tests that activating a Reset button (focusing it and pressing the spacebar) does not cause the page to scroll.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/activating-reset-button-should-not-scroll-page.html (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-reset-button-should-not-scroll-page.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-reset-button-should-not-scroll-page.html	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body style="height: 4096px"> <!-- Make the page really long to force vertical scrollbars. -->
+<p id="description"></p>
+<p id="test-container"><input type="reset" id="test"></p>
+<div id="console"></div>
+<script>
+description("Tests that activating a Reset button (focusing it and pressing the spacebar) does not cause the page to scroll.");
+checkActivatingElementUsingSpacebarDoesNotScrollPage(document.getElementById("test-container"), document.getElementById("test"), "click");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/ios/activating-submit-button-should-not-scroll-page-expected.txt (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-submit-button-should-not-scroll-page-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-submit-button-should-not-scroll-page-expected.txt	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,10 @@
+Tests that activating a Submit button (focusing it and pressing the spacebar) does not cause the page to scroll.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/activating-submit-button-should-not-scroll-page.html (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/activating-submit-button-should-not-scroll-page.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/activating-submit-button-should-not-scroll-page.html	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body style="height: 4096px"> <!-- Make the page really long to force vertical scrollbars. -->
+<p id="description"></p>
+<p id="test-container"><input type="submit" id="test"></p>
+<div id="console"></div>
+<script>
+description("Tests that activating a Submit button (focusing it and pressing the spacebar) does not cause the page to scroll.");
+checkActivatingElementUsingSpacebarDoesNotScrollPage(document.getElementById("test-container"), document.getElementById("test"), "click");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/ios/resources/press-spacebar-at-element-and-check-for-page-scroll.js (0 => 242518)


--- trunk/LayoutTests/fast/events/ios/resources/press-spacebar-at-element-and-check-for-page-scroll.js	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/resources/press-spacebar-at-element-and-check-for-page-scroll.js	2019-03-05 23:40:08 UTC (rev 242518)
@@ -0,0 +1,51 @@
+window.jsTestIsAsync = true;
+
+let g_testElement;
+let g_testContainer;
+let g_activationEventName;
+let checkForScrollTimerId;
+
+function done()
+{
+    document.body.removeChild(g_testContainer);
+    finishJSTest();
+}
+
+function handleInteraction(event)
+{
+    function checkForScrollAndDone() {
+        window.removeEventListener("scroll", handleScroll);
+        shouldBeZero("window.scrollY");
+        done();
+    }
+    // FIXME: Wait up to 100ms for a possible scroll to happen. Note that we will
+    // end the test as soon as a scroll happens.
+    checkForScrollTimerId = window.setTimeout(checkForScrollAndDone, 100);
+}
+
+function handleScroll()
+{
+    testFailed("Page should not have scrolled.");
+
+    window.clearTimeout(checkForScrollTimerId);
+    g_testElement.removeEventListener(g_activationEventName, handleInteraction);
+    done();
+}
+
+function checkActivatingElementUsingSpacebarDoesNotScrollPage(testContainer, testElement, activationEventName)
+{
+    g_testContainer = testContainer;
+    g_testElement = testElement;
+    g_activationEventName = activationEventName;
+
+    function handleFocus(event) {
+        console.assert(event.target == g_testElement);
+        window.addEventListener("scroll", handleScroll, { once: true });
+        g_testElement.addEventListener(g_activationEventName, handleInteraction, { once: true });
+        if (window.testRunner)
+            UIHelper.keyDown(" ");
+    }
+    g_testElement.addEventListener("focus", handleFocus, { once: true });
+    if (window.testRunner)
+        UIHelper.keyDown("\t", ["altKey"]);
+}

Modified: trunk/LayoutTests/platform/ios/TestExpectations (242517 => 242518)


--- trunk/LayoutTests/platform/ios/TestExpectations	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2019-03-05 23:40:08 UTC (rev 242518)
@@ -3228,3 +3228,8 @@
 fast/forms/ios/focus-submit-button.html [ Skip ]
 fast/forms/ios/focus-text-field.html [ Skip ]
 fast/forms/ios/focus-textarea.html [ Skip ]
+fast/events/ios/activating-button-should-not-scroll-page.html [ Skip ]
+fast/events/ios/activating-checkbox-should-not-scroll-page.html [ Skip ]
+fast/events/ios/activating-radio-button-should-not-scroll-page.html [ Skip ]
+fast/events/ios/activating-reset-button-should-not-scroll-page.html [ Skip ]
+fast/events/ios/activating-submit-button-should-not-scroll-page.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (242517 => 242518)


--- trunk/Source/WebCore/ChangeLog	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/ChangeLog	2019-03-05 23:40:08 UTC (rev 242518)
@@ -1,3 +1,70 @@
+2019-03-05  Daniel Bates  <daba...@apple.com>
+
+        [iOS] Should not scroll when checkbox, radio, submit, reset, or button is spacebar activated
+        https://bugs.webkit.org/show_bug.cgi?id=195281
+        <rdar://problem/48564347>
+
+        Reviewed by Simon Fraser.
+
+        Do not call the base class's default event handler (HTMLTextFormControlElement::defaultEventHandler())
+        when WebCore sees a keydown of the spacebar as we consider such an event as handled.
+        Otherwise, calling the base class's default event handler ultimately gives the embedding
+        client a chance to wrongly handle the event. In the case of iOS, keydown of the spacebar
+        causes the page to scroll.
+
+        WebCore implements spacebar activation on keydown for form controls. For IE compatibility
+        WebCore does not mark such keydown events as handled so that a DOM keypress event will
+        be subsequently dispatched. The current logic only skips calling the base class's default
+        event handler if the DOM event was not marked handled. This is insufficient. We need to
+        know whether WebCore handled the event. If asking the input type to handle the key down
+        marks the DOM event as handled then, clearly, WebCore handled the event. However, if the
+        event is not marked as handled, but WebCore actually accounted for this event then we need
+        to know this so that we do not call the base class's default event handler and ultimately
+        the embedding client asking for an interpretation of the key event. Towards this, have
+        InputType::handleKeydownEvent() return a bit whether or not the base class's default
+        event handler should be invoked.
+
+        Tests: fast/events/ios/activating-button-should-not-scroll-page.html
+               fast/events/ios/activating-checkbox-should-not-scroll-page.html
+               fast/events/ios/activating-radio-button-should-not-scroll-page.html
+               fast/events/ios/activating-reset-button-should-not-scroll-page.html
+               fast/events/ios/activating-submit-button-should-not-scroll-page.html
+
+        * html/BaseCheckableInputType.cpp:
+        (WebCore::BaseCheckableInputType::handleKeydownEvent): Return ShouldCallBaseEventHandler::No
+        if WebCore handled the spacebar activation. Otherewise, return ShouldCallBaseEventHandler::Yes.
+        * html/BaseCheckableInputType.h:
+        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
+        (WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent): Ditto.
+        * html/BaseChooserOnlyDateAndTimeInputType.h:
+        * html/BaseClickableWithKeyInputType.cpp:
+        (WebCore::BaseClickableWithKeyInputType::handleKeydownEvent): Keep our current behavior by returning ShouldCallBaseEventHandler::Yes.
+        * html/BaseClickableWithKeyInputType.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::defaultEventHandler): Do not fallthrough and call the base class's default
+        event handler if the input type told us it handled the event regardless of whether the event was handled
+        from the perspective of the DOM.
+        * html/InputType.cpp:
+        (WebCore::InputType::handleKeydownEvent): Keep our current behavior by returning ShouldCallBaseEventHandler::Yes.
+        * html/InputType.h:
+
+        * html/NumberInputType.cpp:
+        (WebCore::NumberInputType::handleKeydownEvent):
+        * html/NumberInputType.h:
+        * html/RadioInputType.cpp:
+        (WebCore::RadioInputType::handleKeydownEvent):
+        * html/RadioInputType.h:
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::handleKeydownEvent):
+        * html/RangeInputType.h:
+        * html/SearchInputType.cpp:
+        (WebCore::SearchInputType::handleKeydownEvent):
+        * html/SearchInputType.h:
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::handleKeydownEvent):
+        * html/TextFieldInputType.h:
+        Keep our current behavior by returning ShouldCallBaseEventHandler::Yes.
+
 2019-03-05  Takashi Komori  <takashi.kom...@sony.com>
 
         [Curl] Implement Cookie Accept Policy.

Modified: trunk/Source/WebCore/html/BaseCheckableInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/BaseCheckableInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/BaseCheckableInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -64,7 +64,7 @@
     return true;
 }
 
-void BaseCheckableInputType::handleKeydownEvent(KeyboardEvent& event)
+auto BaseCheckableInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     const String& key = event.keyIdentifier();
     if (key == "U+0020") {
@@ -72,7 +72,9 @@
         element()->setActive(true, true);
         // No setDefaultHandled(), because IE dispatches a keypress in this case
         // and the caller will only dispatch a keypress if we don't call setDefaultHandled().
+        return ShouldCallBaseEventHandler::No;
     }
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 void BaseCheckableInputType::handleKeypressEvent(KeyboardEvent& event)

Modified: trunk/Source/WebCore/html/BaseCheckableInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/BaseCheckableInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/BaseCheckableInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -38,7 +38,7 @@
 class BaseCheckableInputType : public InputType {
 protected:
     explicit BaseCheckableInputType(HTMLInputElement& element) : InputType(element) { }
-    void handleKeydownEvent(KeyboardEvent&) override;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override;
     void fireInputAndChangeEvents();
 
 private:

Modified: trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -113,10 +113,10 @@
         m_dateTimeChooser->endChooser();
 }
 
-void BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent(KeyboardEvent& event)
+auto BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     ASSERT(element());
-    BaseClickableWithKeyInputType::handleKeydownEvent(*element(), event);
+    return BaseClickableWithKeyInputType::handleKeydownEvent(*element(), event);
 }
 
 void BaseChooserOnlyDateAndTimeInputType::handleKeypressEvent(KeyboardEvent& event)

Modified: trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -49,7 +49,7 @@
     void detach() override;
     void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
     void handleDOMActivateEvent(Event&) override;
-    void handleKeydownEvent(KeyboardEvent&) override;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override;
     void handleKeypressEvent(KeyboardEvent&) override;
     void handleKeyupEvent(KeyboardEvent&) override;
     void accessKeyAction(bool sendMouseEvents) override;

Modified: trunk/Source/WebCore/html/BaseClickableWithKeyInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/BaseClickableWithKeyInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/BaseClickableWithKeyInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -39,7 +39,7 @@
 
 using namespace HTMLNames;
 
-void BaseClickableWithKeyInputType::handleKeydownEvent(HTMLInputElement& element, KeyboardEvent& event)
+auto BaseClickableWithKeyInputType::handleKeydownEvent(HTMLInputElement& element, KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     const String& key = event.keyIdentifier();
     if (key == "U+0020") {
@@ -46,7 +46,9 @@
         element.setActive(true, true);
         // No setDefaultHandled(), because IE dispatches a keypress in this case
         // and the caller will only dispatch a keypress if we don't call setDefaultHandled().
+        return ShouldCallBaseEventHandler::No;
     }
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 void BaseClickableWithKeyInputType::handleKeypressEvent(HTMLInputElement& element, KeyboardEvent& event)
@@ -78,10 +80,10 @@
     element.dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
 }
 
-void BaseClickableWithKeyInputType::handleKeydownEvent(KeyboardEvent& event)
+auto BaseClickableWithKeyInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     ASSERT(element());
-    handleKeydownEvent(*element(), event);
+    return handleKeydownEvent(*element(), event);
 }
 
 void BaseClickableWithKeyInputType::handleKeypressEvent(KeyboardEvent& event)

Modified: trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -37,7 +37,7 @@
 // Base of input types that dispatches a simulated click on space/return key.
 class BaseClickableWithKeyInputType : public InputType {
 public:
-    static void handleKeydownEvent(HTMLInputElement&, KeyboardEvent&);
+    static ShouldCallBaseEventHandler handleKeydownEvent(HTMLInputElement&, KeyboardEvent&);
     static void handleKeypressEvent(HTMLInputElement&, KeyboardEvent&);
     static void handleKeyupEvent(InputType&, KeyboardEvent&);
     static void accessKeyAction(HTMLInputElement&, bool sendMouseEvents);
@@ -46,7 +46,7 @@
     explicit BaseClickableWithKeyInputType(HTMLInputElement& element) : InputType(element) { }
 
 private:
-    void handleKeydownEvent(KeyboardEvent&) override;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override;
     void handleKeypressEvent(KeyboardEvent&) override;
     void handleKeyupEvent(KeyboardEvent&) override;
     void accessKeyAction(bool sendMouseEvents) override;

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -1169,8 +1169,8 @@
 #endif
 
     if (is<KeyboardEvent>(event) && event.type() == eventNames().keydownEvent) {
-        m_inputType->handleKeydownEvent(downcast<KeyboardEvent>(event));
-        if (event.defaultHandled())
+        auto shouldCallBaseEventHandler = m_inputType->handleKeydownEvent(downcast<KeyboardEvent>(event));
+        if (event.defaultHandled() || shouldCallBaseEventHandler == InputType::ShouldCallBaseEventHandler::No)
             return;
     }
 

Modified: trunk/Source/WebCore/html/InputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/InputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/InputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -453,8 +453,9 @@
 {
 }
 
-void InputType::handleKeydownEvent(KeyboardEvent&)
+auto InputType::handleKeydownEvent(KeyboardEvent&) -> ShouldCallBaseEventHandler
 {
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 void InputType::handleKeypressEvent(KeyboardEvent&)

Modified: trunk/Source/WebCore/html/InputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/InputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/InputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -182,7 +182,10 @@
     virtual void willDispatchClick(InputElementClickState&);
     virtual void didDispatchClick(Event&, const InputElementClickState&);
     virtual void handleDOMActivateEvent(Event&);
-    virtual void handleKeydownEvent(KeyboardEvent&);
+
+    enum ShouldCallBaseEventHandler { No, Yes };
+    virtual ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&);
+
     virtual void handleKeypressEvent(KeyboardEvent&);
     virtual void handleKeyupEvent(KeyboardEvent&);
     virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent&);

Modified: trunk/Source/WebCore/html/NumberInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/NumberInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/NumberInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -213,11 +213,12 @@
     return true;
 }
 
-void NumberInputType::handleKeydownEvent(KeyboardEvent& event)
+auto NumberInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     handleKeydownEventForSpinButton(event);
     if (!event.defaultHandled())
-        TextFieldInputType::handleKeydownEvent(event);
+        return TextFieldInputType::handleKeydownEvent(event);
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 Decimal NumberInputType::parseToNumber(const String& src, const Decimal& defaultValue) const

Modified: trunk/Source/WebCore/html/NumberInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/NumberInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/NumberInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -51,7 +51,7 @@
     float decorationWidth() const final;
     bool isSteppable() const final;
     StepRange createStepRange(AnyStepHandling) const final;
-    void handleKeydownEvent(KeyboardEvent&) final;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final;
     Decimal parseToNumber(const String&, const Decimal&) const final;
     String serialize(const Decimal&) const final;
     String localizeValue(const String&) const final;

Modified: trunk/Source/WebCore/html/RadioInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/RadioInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/RadioInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -58,14 +58,15 @@
     event.setDefaultHandled();
 }
 
-void RadioInputType::handleKeydownEvent(KeyboardEvent& event)
+auto RadioInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
-    BaseCheckableInputType::handleKeydownEvent(event);
+    if (BaseCheckableInputType::handleKeydownEvent(event) == ShouldCallBaseEventHandler::No)
+        return ShouldCallBaseEventHandler::No;
     if (event.defaultHandled())
-        return;
+        return ShouldCallBaseEventHandler::Yes;
     const String& key = event.keyIdentifier();
     if (key != "Up" && key != "Down" && key != "Left" && key != "Right")
-        return;
+        return ShouldCallBaseEventHandler::Yes;
 
     ASSERT(element());
     // Left and up mean "previous radio button".
@@ -74,7 +75,7 @@
     // to the right).  Seems strange, but we'll match it.
     // However, when using Spatial Navigation, we need to be able to navigate without changing the selection.
     if (isSpatialNavigationEnabled(element()->document().frame()))
-        return;
+        return ShouldCallBaseEventHandler::Yes;
     bool forward = (key == "Down" || key == "Right");
 
     // We can only stay within the form's children if the form hasn't been demoted to a leaf because
@@ -94,9 +95,10 @@
             element()->document().setFocusedElement(inputElement.get());
             inputElement->dispatchSimulatedClick(&event, SendNoEvents, DoNotShowPressedLook);
             event.setDefaultHandled();
-            return;
+            return ShouldCallBaseEventHandler::Yes;
         }
     }
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 void RadioInputType::handleKeyupEvent(KeyboardEvent& event)

Modified: trunk/Source/WebCore/html/RadioInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/RadioInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/RadioInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -44,7 +44,7 @@
     bool valueMissing(const String&) const final;
     String valueMissingText() const final;
     void handleClickEvent(MouseEvent&) final;
-    void handleKeydownEvent(KeyboardEvent&) final;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final;
     void handleKeyupEvent(KeyboardEvent&) final;
     bool isKeyboardFocusable(KeyboardEvent*) const final;
     bool shouldSendChangeEventAfterCheckedChanged() final;

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -195,11 +195,11 @@
     typedSliderThumbElement().hostDisabledStateChanged();
 }
 
-void RangeInputType::handleKeydownEvent(KeyboardEvent& event)
+auto RangeInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     ASSERT(element());
     if (element()->isDisabledFormControl())
-        return;
+        return ShouldCallBaseEventHandler::Yes;
 
     const String& key = event.keyIdentifier();
 
@@ -208,7 +208,6 @@
 
     StepRange stepRange(createStepRange(RejectAny));
 
-
     // FIXME: We can't use stepUp() for the step value "any". So, we increase
     // or decrease the value by 1/100 of the value range. Is it reasonable?
     const Decimal step = equalLettersIgnoringASCIICase(element()->attributeWithoutSynchronization(stepAttr), "any") ? (stepRange.maximum() - stepRange.minimum()) / 100 : stepRange.step();
@@ -238,7 +237,7 @@
     else if (key == "End")
         newValue = isVertical ? stepRange.minimum() : stepRange.maximum();
     else
-        return; // Did not match any key binding.
+        return ShouldCallBaseEventHandler::Yes; // Did not match any key binding.
 
     newValue = stepRange.clampValue(newValue);
 
@@ -251,6 +250,7 @@
     }
 
     event.setDefaultHandled();
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 void RangeInputType::createShadowSubtree()

Modified: trunk/Source/WebCore/html/RangeInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/RangeInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/RangeInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -53,7 +53,7 @@
 #if !PLATFORM(IOS_FAMILY)
     void handleMouseDownEvent(MouseEvent&) final;
 #endif
-    void handleKeydownEvent(KeyboardEvent&) final;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final;
     RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final;
     void createShadowSubtree() final;
     Decimal parseToNumber(const String&, const Decimal&) const final;

Modified: trunk/Source/WebCore/html/SearchInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/SearchInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/SearchInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -134,13 +134,11 @@
     return m_cancelButton.get();
 }
 
-void SearchInputType::handleKeydownEvent(KeyboardEvent& event)
+auto SearchInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     ASSERT(element());
-    if (element()->isDisabledOrReadOnly()) {
-        TextFieldInputType::handleKeydownEvent(event);
-        return;
-    }
+    if (element()->isDisabledOrReadOnly())
+        return TextFieldInputType::handleKeydownEvent(event);
 
     const String& key = event.keyIdentifier();
     if (key == "U+001B") {
@@ -148,9 +146,9 @@
         protectedInputElement->setValueForUser(emptyString());
         protectedInputElement->onSearch();
         event.setDefaultHandled();
-        return;
+        return ShouldCallBaseEventHandler::Yes;
     }
-    TextFieldInputType::handleKeydownEvent(event);
+    return TextFieldInputType::handleKeydownEvent(event);
 }
 
 void SearchInputType::destroyShadowSubtree()

Modified: trunk/Source/WebCore/html/SearchInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/SearchInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/SearchInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -55,7 +55,7 @@
     void destroyShadowSubtree() final;
     HTMLElement* resultsButtonElement() const final;
     HTMLElement* cancelButtonElement() const final;
-    void handleKeydownEvent(KeyboardEvent&) final;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final;
     void didSetValueByUserEdit() final;
     bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const final;
     float decorationWidth() const final;

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (242517 => 242518)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2019-03-05 23:40:08 UTC (rev 242518)
@@ -182,11 +182,11 @@
 }
 #endif
 
-void TextFieldInputType::handleKeydownEvent(KeyboardEvent& event)
+auto TextFieldInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     ASSERT(element());
     if (!element()->focused())
-        return;
+        return ShouldCallBaseEventHandler::Yes;
 #if ENABLE(DATALIST_ELEMENT)
     const String& key = event.keyIdentifier();
     if (m_suggestionPicker && (key == "Enter" || key == "Up" || key == "Down")) {
@@ -195,9 +195,9 @@
     }
 #endif
     RefPtr<Frame> frame = element()->document().frame();
-    if (!frame || !frame->editor().doTextFieldCommandFromEvent(element(), &event))
-        return;
-    event.setDefaultHandled();
+    if (frame && frame->editor().doTextFieldCommandFromEvent(element(), &event))
+        event.setDefaultHandled();
+    return ShouldCallBaseEventHandler::Yes;
 }
 
 void TextFieldInputType::handleKeydownEventForSpinButton(KeyboardEvent& event)

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (242517 => 242518)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2019-03-05 23:36:56 UTC (rev 242517)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2019-03-05 23:40:08 UTC (rev 242518)
@@ -53,7 +53,7 @@
 protected:
     explicit TextFieldInputType(HTMLInputElement&);
     virtual ~TextFieldInputType();
-    void handleKeydownEvent(KeyboardEvent&) override;
+    ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override;
     void handleKeydownEventForSpinButton(KeyboardEvent&);
 #if ENABLE(DATALIST_ELEMENT)
     void handleClickEvent(MouseEvent&) final;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to