<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[167940] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/167940">167940</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2014-04-29 09:56:36 -0700 (Tue, 29 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Introduce -didNotHandleTapAsClickAtPoint: to WKUIDelegatePrivate
https://bugs.webkit.org/show_bug.cgi?id=132316

Reviewed by Darin Adler.

One WebKit2 client is interested to know if a tap was not handled by an element that responds to clicks.
Introduce a new, private WKUIDelegate method telling it that a tap at a location was not handled as a click on
an element.

* UIProcess/API/APIUIClient.h:
(API::UIClient::didNotHandleTapAsClick):
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::didNotHandleTapAsClick):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didNotHandleTapAsClick):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleTap): Sent Messages::WebPageProxy::DidNotHandleTapAsClick if the tap wasn't handled, no
node responded to the click event, or the responding node wasn't an element.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIUIClienth">trunk/Source/WebKit2/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIDelegateh">trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIDelegatemm">trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/ChangeLog        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-04-28  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [iOS] Introduce -didNotHandleTapAsClickAtPoint: to WKUIDelegatePrivate
+        https://bugs.webkit.org/show_bug.cgi?id=132316
+
+        Reviewed by Darin Adler.
+
+        One WebKit2 client is interested to know if a tap was not handled by an element that responds to clicks.
+        Introduce a new, private WKUIDelegate method telling it that a tap at a location was not handled as a click on
+        an element.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::didNotHandleTapAsClick):
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate):
+        (WebKit::UIDelegate::UIClient::didNotHandleTapAsClick):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didNotHandleTapAsClick):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleTap): Sent Messages::WebPageProxy::DidNotHandleTapAsClick if the tap wasn't handled, no
+        node responded to the click event, or the responding node wasn't an element.
+
</ins><span class="cx"> 2014-04-29  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK][WK2] Avoid Vector copies in WebViewBaseInputMethodFilter::setPreedit()
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -135,6 +135,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     virtual RetainPtr&lt;NSArray&gt; actionsForElement(_WKActivatedElementInfo *, RetainPtr&lt;NSArray&gt; defaultActions) { return std::move(defaultActions); }
</span><ins>+    virtual void didNotHandleTapAsClick(const WebCore::IntPoint&amp;) { }
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> - (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray *)defaultActions;
</span><ins>+- (void)_webView:(WKWebView *)webView didNotHandleTapAsClickAtPoint:(CGPoint)point;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx">         virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&amp;, const WTF::String&amp;, WebKit::WebFrameProxy*, std::function&lt;void (const WTF::String&amp;)&gt; completionHandler) override;
</span><span class="cx">     #if PLATFORM(IOS)
</span><span class="cx">         virtual RetainPtr&lt;NSArray&gt; actionsForElement(_WKActivatedElementInfo *, RetainPtr&lt;NSArray&gt; defaultActions) override;
</span><ins>+        virtual void didNotHandleTapAsClick(const WebCore::IntPoint&amp;) override;
</ins><span class="cx">     #endif
</span><span class="cx"> 
</span><span class="cx">         UIDelegate&amp; m_uiDelegate;
</span><span class="lines">@@ -79,6 +80,7 @@
</span><span class="cx">         bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">         bool webViewActionsForElementDefaultActions : 1;
</span><ins>+        bool webViewDidNotHandleTapAsClickAtPoint : 1;
</ins><span class="cx"> #endif
</span><span class="cx">     } m_delegateMethods;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx">     m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
</span><ins>+    m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -175,6 +176,18 @@
</span><span class="cx"> 
</span><span class="cx">     return [(id &lt;WKUIDelegatePrivate&gt;)delegate _webView:m_uiDelegate.m_webView actionsForElement:elementInfo defaultActions:defaultActions.get()];
</span><span class="cx"> }
</span><ins>+
+void UIDelegate::UIClient::didNotHandleTapAsClick(const WebCore::IntPoint&amp; point)
+{
+    if (!m_uiDelegate.m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint)
+        return;
+
+    auto delegate = m_uiDelegate.m_delegate.get();
+    if (!delegate)
+        return;
+
+    [static_cast&lt;id &lt;WKUIDelegatePrivate&gt;&gt;(delegate) _webView:m_uiDelegate.m_webView didNotHandleTapAsClickAtPoint:point];
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -614,6 +614,7 @@
</span><span class="cx">     void applicationWillResignActive();
</span><span class="cx">     void applicationDidBecomeActive();
</span><span class="cx">     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
</span><ins>+    void didNotHandleTapAsClick(const WebCore::IntPoint&amp;);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     const EditorState&amp; editorState() const { return m_editorState; }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -169,6 +169,7 @@
</span><span class="cx">     DidUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold)
</span><span class="cx">     ShowPlaybackTargetPicker(bool hasVideo, WebCore::IntRect elementRect)
</span><span class="cx">     ZoomToRect(WebCore::FloatRect rect, double minimumScale, double maximumScale)
</span><ins>+    DidNotHandleTapAsClick(WebCore::IntPoint point)
</ins><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx">     PrintFinishedCallback(WebCore::ResourceError error, uint64_t callbackID)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;APIUIClient.h&quot;
</ins><span class="cx"> #import &quot;DataReference.h&quot;
</span><span class="cx"> #import &quot;EditingRange.h&quot;
</span><span class="cx"> #import &quot;NativeWebKeyboardEvent.h&quot;
</span><span class="lines">@@ -580,6 +581,11 @@
</span><span class="cx">     m_pageClient.zoomToRect(rect, minimumScale, maximumScale);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::didNotHandleTapAsClick(const WebCore::IntPoint&amp; point)
+{
+    m_uiClient-&gt;didNotHandleTapAsClick(point);
+}
+
</ins><span class="cx"> #if USE(QUICK_LOOK)
</span><span class="cx">     
</span><span class="cx"> void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String&amp; fileName, const String&amp; uti)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (167939 => 167940)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-04-29 16:50:26 UTC (rev 167939)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-04-29 16:56:36 UTC (rev 167940)
</span><span class="lines">@@ -322,7 +322,7 @@
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; mainframe = m_page-&gt;mainFrame();
</span><span class="cx">     FloatPoint adjustedPoint;
</span><del>-    mainframe.nodeRespondingToClickEvents(point, adjustedPoint);
</del><ins>+    Node* nodeRespondingToClick = mainframe.nodeRespondingToClickEvents(point, adjustedPoint);
</ins><span class="cx">     IntPoint roundedAdjustedPoint = roundedIntPoint(adjustedPoint);
</span><span class="cx"> 
</span><span class="cx">     WKBeginObservingContentChanges(true);
</span><span class="lines">@@ -336,9 +336,10 @@
</span><span class="cx">     RefPtr&lt;Element&gt; oldFocusedElement = oldFocusedFrame ? oldFocusedFrame-&gt;document()-&gt;focusedElement() : nullptr;
</span><span class="cx">     m_userIsInteracting = true;
</span><span class="cx"> 
</span><ins>+    bool tapWasHandled = false;
</ins><span class="cx">     m_lastInteractionLocation = roundedAdjustedPoint;
</span><del>-    mainframe.eventHandler().handleMousePressEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, 0));
-    mainframe.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 1, false, false, false, false, 0));
</del><ins>+    tapWasHandled |= mainframe.eventHandler().handleMousePressEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, 0));
+    tapWasHandled |= mainframe.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 1, false, false, false, false, 0));
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Frame&gt; newFocusedFrame = m_page-&gt;focusController().focusedFrame();
</span><span class="cx">     RefPtr&lt;Element&gt; newFocusedElement = newFocusedFrame ? newFocusedFrame-&gt;document()-&gt;focusedElement() : nullptr;
</span><span class="lines">@@ -351,6 +352,9 @@
</span><span class="cx">         elementDidFocus(newFocusedElement.get());
</span><span class="cx"> 
</span><span class="cx">     m_userIsInteracting = false;
</span><ins>+
+    if (!tapWasHandled || !nodeRespondingToClick || !nodeRespondingToClick-&gt;isElementNode())
+        send(Messages::WebPageProxy::DidNotHandleTapAsClick(point));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::tapHighlightAtPosition(uint64_t requestID, const FloatPoint&amp; position)
</span></span></pre>
</div>
</div>

</body>
</html>