Title: [211653] trunk
Revision
211653
Author
cdu...@apple.com
Date
2017-02-03 14:18:19 -0800 (Fri, 03 Feb 2017)

Log Message

Dismiss HTML form validation popover when pressing Escape key
https://bugs.webkit.org/show_bug.cgi?id=167716
<rdar://problem/29872943>

Reviewed by Simon Fraser.

Source/WebCore:

Dismiss any visible HTML form validation popover when pressing
the Escape key.

Test: fast/forms/validation-bubble-escape-key-dismiss.html

* page/EventHandler.cpp:
(WebCore::EventHandler::keyEvent):
* page/ValidationMessageClient.h:

Source/WebKit/mac:

Override ValidationMessageClient::hideAnyValidationMessage().

* WebCoreSupport/WebValidationMessageClient.h:
* WebCoreSupport/WebValidationMessageClient.mm:
(WebValidationMessageClient::hideAnyValidationMessage):

Source/WebKit2:

Override ValidationMessageClient::hideAnyValidationMessage().

* WebProcess/WebCoreSupport/WebValidationMessageClient.cpp:
(WebKit::WebValidationMessageClient::hideAnyValidationMessage):
* WebProcess/WebCoreSupport/WebValidationMessageClient.h:

LayoutTests:

Add layout test coverage.

* fast/forms/validation-bubble-escape-key-dismiss-expected.txt: Added.
* fast/forms/validation-bubble-escape-key-dismiss.html: Added.
* platform/ios-simulator/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211652 => 211653)


--- trunk/LayoutTests/ChangeLog	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/LayoutTests/ChangeLog	2017-02-03 22:18:19 UTC (rev 211653)
@@ -1,3 +1,17 @@
+2017-02-03  Chris Dumez  <cdu...@apple.com>
+
+        Dismiss HTML form validation popover when pressing Escape key
+        https://bugs.webkit.org/show_bug.cgi?id=167716
+        <rdar://problem/29872943>
+
+        Reviewed by Simon Fraser.
+
+        Add layout test coverage.
+
+        * fast/forms/validation-bubble-escape-key-dismiss-expected.txt: Added.
+        * fast/forms/validation-bubble-escape-key-dismiss.html: Added.
+        * platform/ios-simulator/TestExpectations:
+
 2017-02-03  Jeremy Jones  <jere...@apple.com>
 
         Pointer lock events should be delivered directly to the target element

Added: trunk/LayoutTests/fast/forms/validation-bubble-escape-key-dismiss-expected.txt (0 => 211653)


--- trunk/LayoutTests/fast/forms/validation-bubble-escape-key-dismiss-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/validation-bubble-escape-key-dismiss-expected.txt	2017-02-03 22:18:19 UTC (rev 211653)
@@ -0,0 +1,11 @@
+Required text input: 
+Tests that the HTML form validation bubble gets dismissed when pressing the Escape key.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS validationBubbleContents.message is "Fill out this field"
+PASS validationBubbleContents.message is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/validation-bubble-escape-key-dismiss.html (0 => 211653)


--- trunk/LayoutTests/fast/forms/validation-bubble-escape-key-dismiss.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/validation-bubble-escape-key-dismiss.html	2017-02-03 22:18:19 UTC (rev 211653)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<form>
+  Required text input: <input type="text" id="required_text_input" required><input id="required_text_input_submit" type="submit">
+</form>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Tests that the HTML form validation bubble gets dismissed when pressing the Escape key.");
+jsTestIsAsync = true;
+
+function getValidationBubbleContents()
+{
+    return `
+    (function() {
+        return JSON.stringify(uiController.contentsOfUserInterfaceItem('validationBubble'));
+    })();`
+}
+
+_onload_ = function() {
+    input = document.getElementById("required_text_input");
+    submit = document.getElementById("required_text_input_submit");
+    submit.click();
+
+    testRunner.runUIScript(getValidationBubbleContents(), function(result) {
+        validationBubbleContents = JSON.parse(result).validationBubble;
+        shouldBeEqualToString("validationBubbleContents.message", "Fill out this field");
+
+        // Press Escape key.
+        eventSender.keyDown("escape");
+
+        testRunner.runUIScript(getValidationBubbleContents(), function(result) {
+            validationBubbleContents = JSON.parse(result).validationBubble;
+            shouldBeEqualToString("validationBubbleContents.message", ""); // No longer visible.
+            finishJSTest();
+        });
+    });
+}
+</script>
+<script src=""
+</body>
+<html>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (211652 => 211653)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-02-03 22:18:19 UTC (rev 211653)
@@ -354,6 +354,7 @@
 # This test relies on EventSender.keydown(), which is not supported on iOS
 editing/caret/emoji.html [ Skip ]
 webkit.org/b/155233 fast/events/max-tabindex-focus.html [ Skip ]
+fast/forms/validation-bubble-escape-key-dismiss.html [ Skip ]
 fast/forms/validation-message-maxLength.html [ Skip ]
 fast/shadow-dom/shadow-host-removal-crash.html [ Skip ]
 fast/shadow-dom/input-element-in-shadow.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (211652 => 211653)


--- trunk/Source/WebCore/ChangeLog	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebCore/ChangeLog	2017-02-03 22:18:19 UTC (rev 211653)
@@ -1,3 +1,20 @@
+2017-02-03  Chris Dumez  <cdu...@apple.com>
+
+        Dismiss HTML form validation popover when pressing Escape key
+        https://bugs.webkit.org/show_bug.cgi?id=167716
+        <rdar://problem/29872943>
+
+        Reviewed by Simon Fraser.
+
+        Dismiss any visible HTML form validation popover when pressing
+        the Escape key.
+
+        Test: fast/forms/validation-bubble-escape-key-dismiss.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::keyEvent):
+        * page/ValidationMessageClient.h:
+
 2017-02-03  Jeremy Jones  <jere...@apple.com>
 
         Pointer lock events should be delivered directly to the target element

Modified: trunk/Source/WebCore/page/EventHandler.cpp (211652 => 211653)


--- trunk/Source/WebCore/page/EventHandler.cpp	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2017-02-03 22:18:19 UTC (rev 211653)
@@ -88,6 +88,7 @@
 #include "TextIterator.h"
 #include "UserGestureIndicator.h"
 #include "UserTypingGestureIndicator.h"
+#include "ValidationMessageClient.h"
 #include "VisibleUnits.h"
 #include "WheelEvent.h"
 #include "WheelEventDeltaFilter.h"
@@ -3100,6 +3101,13 @@
     }
 #endif
 
+    if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE) {
+        if (auto* page = m_frame.page()) {
+            if (auto* validationMessageClient = page->validationMessageClient())
+                validationMessageClient->hideAnyValidationMessage();
+        }
+    }
+
 #if ENABLE(FULLSCREEN_API)
     if (m_frame.document()->webkitIsFullScreen()) {
         if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE) {

Modified: trunk/Source/WebCore/page/ValidationMessageClient.h (211652 => 211653)


--- trunk/Source/WebCore/page/ValidationMessageClient.h	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebCore/page/ValidationMessageClient.h	2017-02-03 22:18:19 UTC (rev 211653)
@@ -45,6 +45,9 @@
     // anchor is already visible.
     virtual void hideValidationMessage(const Element& anchor) = 0;
 
+    // Hide any validation message currently displayed.
+    virtual void hideAnyValidationMessage() = 0;
+
     // Returns true if the validation message for the specified anchor element
     // is visible.
     virtual bool isValidationMessageVisible(const Element& anchor) = 0;

Modified: trunk/Source/WebKit/mac/ChangeLog (211652 => 211653)


--- trunk/Source/WebKit/mac/ChangeLog	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-02-03 22:18:19 UTC (rev 211653)
@@ -1,3 +1,17 @@
+2017-02-03  Chris Dumez  <cdu...@apple.com>
+
+        Dismiss HTML form validation popover when pressing Escape key
+        https://bugs.webkit.org/show_bug.cgi?id=167716
+        <rdar://problem/29872943>
+
+        Reviewed by Simon Fraser.
+
+        Override ValidationMessageClient::hideAnyValidationMessage().
+
+        * WebCoreSupport/WebValidationMessageClient.h:
+        * WebCoreSupport/WebValidationMessageClient.mm:
+        (WebValidationMessageClient::hideAnyValidationMessage):
+
 2017-02-02  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Drag images should be anchored to the mouse location

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.h (211652 => 211653)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.h	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.h	2017-02-03 22:18:19 UTC (rev 211653)
@@ -43,6 +43,7 @@
     void documentDetached(WebCore::Document&) final;
     void showValidationMessage(const WebCore::Element& anchor, const String& message) final;
     void hideValidationMessage(const WebCore::Element& anchor) final;
+    void hideAnyValidationMessage() final;
     bool isValidationMessageVisible(const WebCore::Element& anchor) final;
     void updateValidationBubbleStateIfNeeded() final;
 

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.mm (211652 => 211653)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.mm	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.mm	2017-02-03 22:18:19 UTC (rev 211653)
@@ -70,6 +70,16 @@
     [m_view hideFormValidationMessage];
 }
 
+void WebValidationMessageClient::hideAnyValidationMessage()
+{
+    if (!m_currentAnchor)
+        return;
+
+    m_currentAnchor = nullptr;
+    m_currentAnchorRect = { };
+    [m_view hideFormValidationMessage];
+}
+
 bool WebValidationMessageClient::isValidationMessageVisible(const Element& anchor)
 {
     return m_currentAnchor == &anchor;

Modified: trunk/Source/WebKit2/ChangeLog (211652 => 211653)


--- trunk/Source/WebKit2/ChangeLog	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-03 22:18:19 UTC (rev 211653)
@@ -1,3 +1,17 @@
+2017-02-03  Chris Dumez  <cdu...@apple.com>
+
+        Dismiss HTML form validation popover when pressing Escape key
+        https://bugs.webkit.org/show_bug.cgi?id=167716
+        <rdar://problem/29872943>
+
+        Reviewed by Simon Fraser.
+
+        Override ValidationMessageClient::hideAnyValidationMessage().
+
+        * WebProcess/WebCoreSupport/WebValidationMessageClient.cpp:
+        (WebKit::WebValidationMessageClient::hideAnyValidationMessage):
+        * WebProcess/WebCoreSupport/WebValidationMessageClient.h:
+
 2017-02-03  Jeremy Jones  <jere...@apple.com>
 
         Require keyboard focus for pointer lock.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebValidationMessageClient.cpp (211652 => 211653)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebValidationMessageClient.cpp	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebValidationMessageClient.cpp	2017-02-03 22:18:19 UTC (rev 211653)
@@ -74,6 +74,16 @@
     m_page.send(Messages::WebPageProxy::HideValidationMessage());
 }
 
+void WebValidationMessageClient::hideAnyValidationMessage()
+{
+    if (!m_currentAnchor)
+        return;
+
+    m_currentAnchor = nullptr;
+    m_currentAnchorRect = { };
+    m_page.send(Messages::WebPageProxy::HideValidationMessage());
+}
+
 bool WebValidationMessageClient::isValidationMessageVisible(const Element& anchor)
 {
     return m_currentAnchor == &anchor;

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebValidationMessageClient.h (211652 => 211653)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebValidationMessageClient.h	2017-02-03 22:01:19 UTC (rev 211652)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebValidationMessageClient.h	2017-02-03 22:18:19 UTC (rev 211653)
@@ -41,6 +41,7 @@
     void documentDetached(WebCore::Document&) final;
     void showValidationMessage(const WebCore::Element& anchor, const String& message) final;
     void hideValidationMessage(const WebCore::Element& anchor) final;
+    void hideAnyValidationMessage() final;
     bool isValidationMessageVisible(const WebCore::Element& anchor) final;
     void updateValidationBubbleStateIfNeeded() final;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to