Title: [188405] trunk
Revision
188405
Author
wenson_hs...@apple.com
Date
2015-08-13 14:48:50 -0700 (Thu, 13 Aug 2015)

Log Message

A focused node should not be assisted when handling touch events synchronously
https://bugs.webkit.org/show_bug.cgi?id=147836
.:

Reviewed by Enrica Casucci.

Added manual tests for keyboard assistance behavior due to receiving touch events on iOS.

* ManualTests/ios/focused-input-should-assist-on-touch.html: Checks that a currently focused
        input can still be assisted due to a touch event.
* ManualTests/ios/keyboard-should-not-show-on-touch-event.html: Checks that handling a touch
        event does not automatically cause us to assist the currently focused node.

Source/WebCore:

<rdar://problem/22204108>

Reviewed by Enrica Casucci.

Makes interaction with touch handlers no longer assist the currently focused element in the
general case. Added plumbing to reassist a currently focused node when dispatching touch events,
so that an input that programmatically focuses itself and prevents default on a touch event will
be properly assisted when it has been programmatically focused (either through _javascript_ or the
autofocus attribute) prior to receiving the touch event. This patch also removes the now
unnecessary special-casing of the Gmail settings app that currently makes the keyboard deploy
upon autofocus.

* dom/Element.cpp:
(WebCore::Element::focus): Notifies the chrome client that the element has refocused before
    returning early.
* page/ChromeClient.h: Refocusing an element does nothing by default.
* platform/RuntimeApplicationChecksIOS.h: Removed special casing for Gmail Add Account.
* platform/RuntimeApplicationChecksIOS.mm: See above.
(WebCore::applicationIsGmailAddAccountOnIOS): See above.

Source/WebKit2:

<rdar://problem/22204108>

Reviewed by Enrica Casucci.

Makes interaction with touch handlers no longer assist the currently focused element in the
general case. Added plumbing to reassist a currently focused node when dispatching touch events,
so that an input that programmatically focuses itself and prevents default on a touch event will
be properly assisted when it has been programmatically focused (either through _javascript_ or the
autofocus attribute) prior to receiving the touch event. This patch also removes the now
unnecessary special-casing of the Gmail settings app that currently makes the keyboard deploy
upon autofocus.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]): Removed
    special case to avoid the early return for Gmail Add Account.
* WebProcess/WebCoreSupport/WebChromeClient.h: Added a handler for refocusing an element.
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
(WebKit::WebChromeClient::elementDidRefocus): Makes refocusing an element trigger input
    assistance on iOS.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dispatchTouchEvent): Removes logic to focus the currently focused element upon
    receiving a touch event.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (188404 => 188405)


--- trunk/ChangeLog	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/ChangeLog	2015-08-13 21:48:50 UTC (rev 188405)
@@ -1,3 +1,17 @@
+2015-08-13  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        A focused node should not be assisted when handling touch events synchronously
+        https://bugs.webkit.org/show_bug.cgi?id=147836
+
+        Reviewed by Enrica Casucci.
+
+        Added manual tests for keyboard assistance behavior due to receiving touch events on iOS.
+
+        * ManualTests/ios/focused-input-should-assist-on-touch.html: Checks that a currently focused
+                input can still be assisted due to a touch event.
+        * ManualTests/ios/keyboard-should-not-show-on-touch-event.html: Checks that handling a touch
+                event does not automatically cause us to assist the currently focused node.
+
 2015-08-12  Alex Christensen  <achristen...@webkit.org>
 
         Fix Debug CMake builds on Windows

Added: trunk/ManualTests/ios/focused-input-should-assist-on-touch.html (0 => 188405)


--- trunk/ManualTests/ios/focused-input-should-assist-on-touch.html	                        (rev 0)
+++ trunk/ManualTests/ios/focused-input-should-assist-on-touch.html	2015-08-13 21:48:50 UTC (rev 188405)
@@ -0,0 +1,25 @@
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <script>
+        function handleTouchEvent(event) {
+            event.target.focus();
+            event.preventDefault();
+        }
+    </script>
+
+    <style>
+        input:focus {
+            outline: none;
+            border: 1px solid #4D90FE;
+        }
+    </style>
+
+</head>
+
+<body style="margin: 0;">
+    <p>This tests checks that a node can be assisted when focused due to a touch event, even when the focus does not change.</p>
+    <p>Tapping the below input should show the keyboard.</p>
+    <input autofocus _ontouchstart_="handleTouchEvent(event);"></input>
+</body>
+</html>

Added: trunk/ManualTests/ios/keyboard-should-not-show-on-touch-event.html (0 => 188405)


--- trunk/ManualTests/ios/keyboard-should-not-show-on-touch-event.html	                        (rev 0)
+++ trunk/ManualTests/ios/keyboard-should-not-show-on-touch-event.html	2015-08-13 21:48:50 UTC (rev 188405)
@@ -0,0 +1,34 @@
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <script>
+        function touchTest(event) { }
+    </script>
+
+    <style>
+        button {
+            top: 300px;
+            left: 100px;
+            width: 200px;
+            height: 200px;
+            background-color: #FFAAAA;
+            position: absolute;
+            padding: 10px;
+        }
+
+        input:focus {
+            outline: none;
+            border: 1px solid #4D90FE;
+        }
+    </style>
+
+</head>
+
+<body style="margin: 0;">
+    <button _ontouchstart_="touchTest(event);">
+        <p>This test checks that any interaction that fires touch events will not assist the currently focused node.</p>
+        <p>Thus, tapping in this touch-handling region should not deploy the keyboard for the autofocused input above.</p>
+    </button>
+    <input autofocus></input>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (188404 => 188405)


--- trunk/Source/WebCore/ChangeLog	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebCore/ChangeLog	2015-08-13 21:48:50 UTC (rev 188405)
@@ -1,3 +1,27 @@
+2015-08-13  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        A focused node should not be assisted when handling touch events synchronously
+        https://bugs.webkit.org/show_bug.cgi?id=147836
+        <rdar://problem/22204108>
+
+        Reviewed by Enrica Casucci.
+
+        Makes interaction with touch handlers no longer assist the currently focused element in the
+        general case. Added plumbing to reassist a currently focused node when dispatching touch events,
+        so that an input that programmatically focuses itself and prevents default on a touch event will
+        be properly assisted when it has been programmatically focused (either through _javascript_ or the
+        autofocus attribute) prior to receiving the touch event. This patch also removes the now
+        unnecessary special-casing of the Gmail settings app that currently makes the keyboard deploy
+        upon autofocus.
+
+        * dom/Element.cpp:
+        (WebCore::Element::focus): Notifies the chrome client that the element has refocused before
+            returning early.
+        * page/ChromeClient.h: Refocusing an element does nothing by default.
+        * platform/RuntimeApplicationChecksIOS.h: Removed special casing for Gmail Add Account.
+        * platform/RuntimeApplicationChecksIOS.mm: See above.
+        (WebCore::applicationIsGmailAddAccountOnIOS): See above.
+
 2015-08-13  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Unreviewed build fix.

Modified: trunk/Source/WebCore/dom/Element.cpp (188404 => 188405)


--- trunk/Source/WebCore/dom/Element.cpp	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebCore/dom/Element.cpp	2015-08-13 21:48:50 UTC (rev 188405)
@@ -2117,8 +2117,12 @@
     if (!inDocument())
         return;
 
-    if (document().focusedElement() == this)
+    if (document().focusedElement() == this) {
+        if (document().page())
+            document().page()->chrome().client().elementDidRefocus(this);
+
         return;
+    }
 
     // If the stylesheets have already been loaded we can reliably check isFocusable.
     // If not, we continue and set the focused node on the focus controller below so

Modified: trunk/Source/WebCore/page/ChromeClient.h (188404 => 188405)


--- trunk/Source/WebCore/page/ChromeClient.h	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebCore/page/ChromeClient.h	2015-08-13 21:48:50 UTC (rev 188405)
@@ -281,6 +281,7 @@
         
     virtual void elementDidFocus(const Node*) { };
     virtual void elementDidBlur(const Node*) { };
+    virtual void elementDidRefocus(const Node*) { };
     
     virtual bool shouldPaintEntireContents() const { return false; }
     virtual bool hasStablePageScaleFactor() const { return true; }

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecksIOS.h (188404 => 188405)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecksIOS.h	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecksIOS.h	2015-08-13 21:48:50 UTC (rev 188405)
@@ -43,7 +43,6 @@
 WEBCORE_EXPORT bool applicationIsTheEconomistOnIPhone();
 bool applicationIsWebProcess();
 bool applicationIsIBooksOnIOS();
-WEBCORE_EXPORT bool applicationIsGmailAddAccountOnIOS();
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecksIOS.mm (188404 => 188405)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecksIOS.mm	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecksIOS.mm	2015-08-13 21:48:50 UTC (rev 188405)
@@ -122,12 +122,6 @@
     return isIBooksOnIOS;
 }
 
-bool applicationIsGmailAddAccountOnIOS()
-{
-    static const bool isGmailAddAccountOnIOS = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.social.SLGoogleAuth.SLGoogleAuthService"];
-    return isGmailAddAccountOnIOS;
-}
-
 } // namespace WebCore
 
 #endif // PLATFORM(IOS)

Modified: trunk/Source/WebKit2/ChangeLog (188404 => 188405)


--- trunk/Source/WebKit2/ChangeLog	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebKit2/ChangeLog	2015-08-13 21:48:50 UTC (rev 188405)
@@ -1,3 +1,30 @@
+2015-08-13  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        A focused node should not be assisted when handling touch events synchronously
+        https://bugs.webkit.org/show_bug.cgi?id=147836
+        <rdar://problem/22204108>
+
+        Reviewed by Enrica Casucci.
+
+        Makes interaction with touch handlers no longer assist the currently focused element in the
+        general case. Added plumbing to reassist a currently focused node when dispatching touch events,
+        so that an input that programmatically focuses itself and prevents default on a touch event will
+        be properly assisted when it has been programmatically focused (either through _javascript_ or the
+        autofocus attribute) prior to receiving the touch event. This patch also removes the now
+        unnecessary special-casing of the Gmail settings app that currently makes the keyboard deploy
+        upon autofocus.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]): Removed
+            special case to avoid the early return for Gmail Add Account.
+        * WebProcess/WebCoreSupport/WebChromeClient.h: Added a handler for refocusing an element.
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        (WebKit::WebChromeClient::elementDidRefocus): Makes refocusing an element trigger input
+            assistance on iOS.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::dispatchTouchEvent): Removes logic to focus the currently focused element upon
+            receiving a touch event.
+
 2015-08-13  Anders Carlsson  <ander...@apple.com>
 
         Add WKWindowFeaturesRef and a new modern createNewPage UI client callback

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (188404 => 188405)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-08-13 21:48:50 UTC (rev 188405)
@@ -3012,7 +3012,7 @@
 {
     // FIXME: This is a temporary workaround for <rdar://problem/22126518>. The real fix will involve refactoring
     // the way we assist programmatically focused nodes.
-    if (!applicationIsGmailAddAccountOnIOS() && !userIsInteracting && !_textSelectionAssistant)
+    if (!userIsInteracting && !_textSelectionAssistant)
         return;
 
     if (blurPreviousNode)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (188404 => 188405)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2015-08-13 21:48:50 UTC (rev 188405)
@@ -243,6 +243,7 @@
 #if PLATFORM(IOS)
     virtual void elementDidFocus(const WebCore::Node*) override;
     virtual void elementDidBlur(const WebCore::Node*) override;
+    virtual void elementDidRefocus(const WebCore::Node*) override;
 #endif
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (188404 => 188405)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2015-08-13 21:48:50 UTC (rev 188405)
@@ -54,6 +54,11 @@
     m_page->elementDidBlur(const_cast<WebCore::Node*>(node));
 }
 
+void WebChromeClient::elementDidRefocus(const WebCore::Node* node)
+{
+    elementDidFocus(node);
+}
+
 void WebChromeClient::didReceiveMobileDocType(bool isMobileDoctype)
 {
     m_page->didReceiveMobileDocType(isMobileDoctype);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (188404 => 188405)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-08-13 21:31:36 UTC (rev 188404)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-08-13 21:48:50 UTC (rev 188405)
@@ -2190,24 +2190,12 @@
 #if ENABLE(IOS_TOUCH_EVENTS)
 void WebPage::dispatchTouchEvent(const WebTouchEvent& touchEvent, bool& handled)
 {
-    RefPtr<Frame> oldFocusedFrame = m_page->focusController().focusedFrame();
-    RefPtr<Element> oldFocusedElement = oldFocusedFrame ? oldFocusedFrame->document()->focusedElement() : nullptr;
     m_userIsInteracting = true;
 
     m_lastInteractionLocation = touchEvent.position();
     CurrentEvent currentEvent(touchEvent);
     handled = handleTouchEvent(touchEvent, m_page.get());
 
-    RefPtr<Frame> newFocusedFrame = m_page->focusController().focusedFrame();
-    RefPtr<Element> newFocusedElement = newFocusedFrame ? newFocusedFrame->document()->focusedElement() : nullptr;
-
-    // If the focus has not changed, we need to notify the client anyway, since it might be
-    // necessary to start assisting the node.
-    // If the node has been focused by _javascript_ without user interaction, the
-    // keyboard is not on screen.
-    if (newFocusedElement && newFocusedElement == oldFocusedElement)
-        elementDidFocus(newFocusedElement.get());
-
     m_userIsInteracting = false;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to