<!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>[203312] 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/203312">203312</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2016-07-15 17:39:50 -0700 (Fri, 15 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Mac UI process needs to know about element focus and blur, much like iOS
https://bugs.webkit.org/show_bug.cgi?id=159843
-and corresponding-
rdar://problem/27229504

Reviewed by Tim Horton.

This patch makes the existing iOS machinery to handle focus and blurring of 
elements cross-platform. Instead of using the existing iOS messages for 
startAssistingNode/stopAssistingNode, this patch adds a new message that 
require only a boolean parameter: setEditableElementIsFocused.

Now that more of this code is shared, this patch teases 
m_hasFocusedDueToUserInteraction out into two variables. I realized that it 
was being used to mean two slightly different things on Mac and iOS, which 
was very confusing. Now we have m_isAssistingNodeDueToUserInteraction to 
represent the way iOS was using the variable, and we have 
m_hasEverFocusedElementDueToUserInteractionSincePageTransition to represent 
how Mac was using the variable. There should not be any behavior changes with 
this re-name, just added clarity.

WebViewImpl has a new member variable m_editableElementIsFocused.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::setEditableElementIsFocused):

Pipe the new setEditableElementIsFocused message to WebViewImpl.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setEditableElementIsFocused):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setEditableElementIsFocused):

elementDidFocus() and elementDidBlur() are now PLATFORM(COCOA) instead of 
PLATFORM(IOS)
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::elementDidFocus):
(WebKit::WebChromeClient::elementDidBlur):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
(WebKit::WebChromeClient::elementDidFocus): Deleted.
(WebKit::WebChromeClient::elementDidBlur): Deleted.

m_hasPendingBlurNotification is no longer iOS-only.
* WebProcess/WebPage/WebPage.cpp:

Use our two new bools m_isAssistingNodeDueToUserInteraction and 
m_hasEverFocusedElementDueToUserInteractionSincePageTransition 
(WebKit::WebPage::didStartPageTransition):
(WebKit::WebPage::didChangeSelection):

These functions are all newly cross-platform. The Messages they send are 
still platform-specific, but otherwise the logic is the same. We 
dispatch_async the blur messages so that the UI process features won’t be 
flashy when the user is tapping, tabbing, or clicking through form fields.
(WebKit::WebPage::resetAssistedNodeForFrame):
(WebKit::WebPage::elementDidFocus):
(WebKit::WebPage::elementDidBlur):

resetAssistedNodeForFrame() is no longer iOS-only. 
(WebKit::WebPage::didCommitLoad):

Move variables and functions around so that they are defined for the right 
platform, and declare the two new bools in place of the old one.
* WebProcess/WebPage/WebPage.h:

These functions are now defined in WebPage.cpp
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetAssistedNodeForFrame): Deleted.
(WebKit::WebPage::elementDidFocus): Deleted.
(WebKit::WebPage::elementDidBlur): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</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="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportiosWebChromeClientIOSmm">trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</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 (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/ChangeLog        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -1,3 +1,80 @@
</span><ins>+2016-07-15  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Mac UI process needs to know about element focus and blur, much like iOS
+        https://bugs.webkit.org/show_bug.cgi?id=159843
+        -and corresponding-
+        rdar://problem/27229504
+
+        Reviewed by Tim Horton.
+
+        This patch makes the existing iOS machinery to handle focus and blurring of 
+        elements cross-platform. Instead of using the existing iOS messages for 
+        startAssistingNode/stopAssistingNode, this patch adds a new message that 
+        require only a boolean parameter: setEditableElementIsFocused.
+
+        Now that more of this code is shared, this patch teases 
+        m_hasFocusedDueToUserInteraction out into two variables. I realized that it 
+        was being used to mean two slightly different things on Mac and iOS, which 
+        was very confusing. Now we have m_isAssistingNodeDueToUserInteraction to 
+        represent the way iOS was using the variable, and we have 
+        m_hasEverFocusedElementDueToUserInteractionSincePageTransition to represent 
+        how Mac was using the variable. There should not be any behavior changes with 
+        this re-name, just added clarity.
+
+        WebViewImpl has a new member variable m_editableElementIsFocused.
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::setEditableElementIsFocused):
+
+        Pipe the new setEditableElementIsFocused message to WebViewImpl.
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setEditableElementIsFocused):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setEditableElementIsFocused):
+
+        elementDidFocus() and elementDidBlur() are now PLATFORM(COCOA) instead of 
+        PLATFORM(IOS)
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::elementDidFocus):
+        (WebKit::WebChromeClient::elementDidBlur):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        (WebKit::WebChromeClient::elementDidFocus): Deleted.
+        (WebKit::WebChromeClient::elementDidBlur): Deleted.
+
+        m_hasPendingBlurNotification is no longer iOS-only.
+        * WebProcess/WebPage/WebPage.cpp:
+
+        Use our two new bools m_isAssistingNodeDueToUserInteraction and 
+        m_hasEverFocusedElementDueToUserInteractionSincePageTransition 
+        (WebKit::WebPage::didStartPageTransition):
+        (WebKit::WebPage::didChangeSelection):
+
+        These functions are all newly cross-platform. The Messages they send are 
+        still platform-specific, but otherwise the logic is the same. We 
+        dispatch_async the blur messages so that the UI process features won’t be 
+        flashy when the user is tapping, tabbing, or clicking through form fields.
+        (WebKit::WebPage::resetAssistedNodeForFrame):
+        (WebKit::WebPage::elementDidFocus):
+        (WebKit::WebPage::elementDidBlur):
+
+        resetAssistedNodeForFrame() is no longer iOS-only. 
+        (WebKit::WebPage::didCommitLoad):
+
+        Move variables and functions around so that they are defined for the right 
+        platform, and declare the two new bools in place of the old one.
+        * WebProcess/WebPage/WebPage.h:
+
+        These functions are now defined in WebPage.cpp
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::resetAssistedNodeForFrame): Deleted.
+        (WebKit::WebPage::elementDidFocus): Deleted.
+        (WebKit::WebPage::elementDidBlur): Deleted.
+
</ins><span class="cx"> 2016-07-15  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Added a makeRef&lt;T&gt; helper
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -272,6 +272,7 @@
</span><span class="cx">     void updateFontPanelIfNeeded();
</span><span class="cx">     void changeFontFromFontPanel();
</span><span class="cx">     bool validateUserInterfaceItem(id &lt;NSValidatedUserInterfaceItem&gt;);
</span><ins>+    void setEditableElementIsFocused(bool);
</ins><span class="cx"> 
</span><span class="cx">     void startSpeaking();
</span><span class="cx">     void stopSpeaking(id);
</span><span class="lines">@@ -647,6 +648,7 @@
</span><span class="cx">     NSRange m_softSpaceRange { NSNotFound, 0 };
</span><span class="cx">     bool m_isHandlingAcceptedCandidate { false };
</span><span class="cx">     bool m_requiresUserActionForEditingControlsManager { false };
</span><ins>+    bool m_editableElementIsFocused { false };
</ins><span class="cx"> };
</span><span class="cx">     
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -453,6 +453,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebViewImpl::setEditableElementIsFocused(bool editableElementIsFocused)
+{
+    m_editableElementIsFocused = editableElementIsFocused;
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> #endif // __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200 &amp;&amp; USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -275,6 +275,7 @@
</span><span class="cx">     virtual void registerInsertionUndoGrouping() = 0;
</span><span class="cx"> #endif // USE(INSERTION_UNDO_GROUPING)
</span><span class="cx"> #endif // USE(APPKIT)
</span><ins>+    virtual void setEditableElementIsFocused(bool) = 0;
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -5955,6 +5955,11 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void WebPageProxy::setEditableElementIsFocused(bool editableElementIsFocused)
+{
+    m_pageClient.setEditableElementIsFocused(editableElementIsFocused);
+}
+
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -1419,6 +1419,8 @@
</span><span class="cx">     void removeDictationAlternatives(uint64_t dictationContext);
</span><span class="cx">     void dictationAlternatives(uint64_t dictationContext, Vector&lt;String&gt;&amp; result);
</span><span class="cx"> #endif
</span><ins>+
+    void setEditableElementIsFocused(bool);
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -342,6 +342,8 @@
</span><span class="cx">     DismissCorrectionPanel(int32_t reason)
</span><span class="cx">     DismissCorrectionPanelSoon(int32_t reason) -&gt; (String result)
</span><span class="cx">     RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString);
</span><ins>+
+    SetEditableElementIsFocused(bool editableElementIsFocused)
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(DICTATION_ALTERNATIVES)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -171,6 +171,8 @@
</span><span class="cx">     void showDictationAlternativeUI(const WebCore::FloatRect&amp; boundingBoxOfDictatedText, uint64_t dictationContext) override;
</span><span class="cx">     Vector&lt;String&gt; dictationAlternatives(uint64_t dictationContext) override;
</span><span class="cx"> #endif
</span><ins>+    void setEditableElementIsFocused(bool) override;
+
</ins><span class="cx"> #if USE(INSERTION_UNDO_GROUPING)
</span><span class="cx">     void registerInsertionUndoGrouping() override;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -621,6 +621,11 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void PageClientImpl::setEditableElementIsFocused(bool editableElementIsFocused)
+{
+    m_impl-&gt;setEditableElementIsFocused(editableElementIsFocused);
+}
+
</ins><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="cx"> 
</span><span class="cx"> WebFullScreenManagerProxyClient&amp; PageClientImpl::fullScreenManagerProxyClient()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -169,6 +169,16 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+void WebChromeClient::elementDidFocus(const WebCore::Node* node)
+{
+    m_page-&gt;elementDidFocus(const_cast&lt;WebCore::Node*&gt;(node));
+}
+
+void WebChromeClient::elementDidBlur(const WebCore::Node* node)
+{
+    m_page-&gt;elementDidBlur(const_cast&lt;WebCore::Node*&gt;(node));
+}
+
</ins><span class="cx"> void WebChromeClient::makeFirstResponder()
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebPageProxy::MakeFirstResponder());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -236,8 +236,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    void elementDidFocus(const WebCore::Node*) override;
-    void elementDidBlur(const WebCore::Node*) override;
</del><span class="cx">     void elementDidRefocus(const WebCore::Node*) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -259,6 +257,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+    void elementDidFocus(const WebCore::Node*) override;
+    void elementDidBlur(const WebCore::Node*) override;
+
</ins><span class="cx">     void makeFirstResponder() override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportiosWebChromeClientIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -44,16 +44,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void WebChromeClient::elementDidFocus(const WebCore::Node* node)
-{
-    m_page-&gt;elementDidFocus(const_cast&lt;WebCore::Node*&gt;(node));
-}
-
-void WebChromeClient::elementDidBlur(const WebCore::Node* node)
-{
-    m_page-&gt;elementDidBlur(const_cast&lt;WebCore::Node*&gt;(node));
-}
-
</del><span class="cx"> void WebChromeClient::elementDidRefocus(const WebCore::Node* node)
</span><span class="cx"> {
</span><span class="cx">     elementDidFocus(node);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;APIArray.h&quot;
</span><span class="cx"> #include &quot;APIGeometry.h&quot;
</span><span class="cx"> #include &quot;Arguments.h&quot;
</span><ins>+#include &quot;AssistedNodeInformation.h&quot;
</ins><span class="cx"> #include &quot;DataReference.h&quot;
</span><span class="cx"> #include &quot;DragControllerAction.h&quot;
</span><span class="cx"> #include &quot;DrawingArea.h&quot;
</span><span class="lines">@@ -348,6 +349,7 @@
</span><span class="cx"> #if ENABLE(CONTEXT_MENUS)
</span><span class="cx">     , m_isShowingContextMenu(false)
</span><span class="cx"> #endif
</span><ins>+    , m_hasPendingBlurNotification(false)
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     , m_selectionAnchor(Start)
</span><span class="cx">     , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false)
</span><span class="lines">@@ -354,7 +356,6 @@
</span><span class="cx">     , m_scaleWasSetByUIProcess(false)
</span><span class="cx">     , m_userHasChangedPageScaleFactor(false)
</span><span class="cx">     , m_hasStablePageScaleFactor(true)
</span><del>-    , m_hasPendingBlurNotification(false)
</del><span class="cx">     , m_useTestingViewportConfiguration(false)
</span><span class="cx">     , m_isInStableState(true)
</span><span class="cx">     , m_forceAlwaysUserScalable(parameters.ignoresViewportScaleLimits)
</span><span class="lines">@@ -2608,12 +2609,13 @@
</span><span class="cx">     m_drawingArea-&gt;setLayerTreeStateIsFrozen(true);
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    bool hasPreviouslyFocusedDueToUserInteraction = m_hasFocusedDueToUserInteraction;
</del><ins>+    bool hasPreviouslyFocusedDueToUserInteraction = m_hasEverFocusedElementDueToUserInteractionSincePageTransition;
</ins><span class="cx"> #endif
</span><del>-    m_hasFocusedDueToUserInteraction = false;
</del><ins>+    m_hasEverFocusedElementDueToUserInteractionSincePageTransition = false;
+    m_isAssistingNodeDueToUserInteraction = false;
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     if (hasPreviouslyFocusedDueToUserInteraction)
</span><del>-        send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasFocusedDueToUserInteraction));
</del><ins>+        send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition));
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4753,11 +4755,12 @@
</span><span class="cx">     m_isEditorStateMissingPostLayoutData = editorState.isMissingPostLayoutData;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    bool hasPreviouslyFocusedDueToUserInteraction = m_hasFocusedDueToUserInteraction;
-    m_hasFocusedDueToUserInteraction |= m_userIsInteracting;
-    if (!hasPreviouslyFocusedDueToUserInteraction &amp;&amp; m_hasFocusedDueToUserInteraction)
-        send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasFocusedDueToUserInteraction));
</del><ins>+    bool hasPreviouslyFocusedDueToUserInteraction = m_hasEverFocusedElementDueToUserInteractionSincePageTransition;
+    m_hasEverFocusedElementDueToUserInteractionSincePageTransition |= m_userIsInteracting;
</ins><span class="cx"> 
</span><ins>+    if (!hasPreviouslyFocusedDueToUserInteraction &amp;&amp; m_hasEverFocusedElementDueToUserInteractionSincePageTransition)
+        send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition));
+
</ins><span class="cx">     // Abandon the current inline input session if selection changed for any other reason but an input method direct action.
</span><span class="cx">     // FIXME: This logic should be in WebCore.
</span><span class="cx">     // FIXME: Many changes that affect composition node do not go through didChangeSelection(). We need to do something when DOM manipulation affects the composition, because otherwise input method's idea about it will be different from Editor's.
</span><span class="lines">@@ -4776,6 +4779,68 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::resetAssistedNodeForFrame(WebFrame* frame)
+{
+    if (!m_assistedNode)
+        return;
+    if (m_assistedNode-&gt;document().frame() == frame-&gt;coreFrame()) {
+#if PLATFORM(IOS)
+        send(Messages::WebPageProxy::StopAssistingNode());
+#elif PLATFORM(MAC)
+        send(Messages::WebPageProxy::SetEditableElementIsFocused(false));
+#endif
+        m_assistedNode = nullptr;
+    }
+}
+
+void WebPage::elementDidFocus(WebCore::Node* node)
+{
+    if (m_assistedNode == node &amp;&amp; m_isAssistingNodeDueToUserInteraction)
+        return;
+
+    if (node-&gt;hasTagName(WebCore::HTMLNames::selectTag) || node-&gt;hasTagName(WebCore::HTMLNames::inputTag) || node-&gt;hasTagName(WebCore::HTMLNames::textareaTag) || node-&gt;hasEditableStyle()) {
+        m_assistedNode = node;
+        m_isAssistingNodeDueToUserInteraction |= m_userIsInteracting;
+
+#if PLATFORM(IOS)
+        AssistedNodeInformation information;
+        getAssistedNodeInformation(information);
+        RefPtr&lt;API::Object&gt; userData;
+
+        m_formClient-&gt;willBeginInputSession(this, downcast&lt;Element&gt;(node), WebFrame::fromCoreFrame(*node-&gt;document().frame()), userData, m_userIsInteracting);
+
+        send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, m_hasPendingBlurNotification, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
+#elif PLATFORM(MAC)
+        if (node-&gt;hasTagName(WebCore::HTMLNames::selectTag))
+            send(Messages::WebPageProxy::SetEditableElementIsFocused(false));
+        else
+            send(Messages::WebPageProxy::SetEditableElementIsFocused(true));
+#endif
+        m_hasPendingBlurNotification = false;
+    }
+}
+
+void WebPage::elementDidBlur(WebCore::Node* node)
+{
+    if (m_assistedNode == node) {
+        m_hasPendingBlurNotification = true;
+        RefPtr&lt;WebPage&gt; protectedThis(this);
+        callOnMainThread([protectedThis] {
+            if (protectedThis-&gt;m_hasPendingBlurNotification) {
+#if PLATFORM(IOS)
+                protectedThis-&gt;send(Messages::WebPageProxy::StopAssistingNode());
+#elif PLATFORM(MAC)
+                protectedThis-&gt;send(Messages::WebPageProxy::SetEditableElementIsFocused(false));
+#endif
+            }
+            protectedThis-&gt;m_hasPendingBlurNotification = false;
+        });
+
+        m_isAssistingNodeDueToUserInteraction = false;
+        m_assistedNode = nullptr;
+    }
+}
+
</ins><span class="cx"> void WebPage::sendPostLayoutEditorStateIfNeeded()
</span><span class="cx"> {
</span><span class="cx">     if (!m_isEditorStateMissingPostLayoutData)
</span><span class="lines">@@ -4914,8 +4979,8 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     frame-&gt;setFirstLayerTreeTransactionIDAfterDidCommitLoad(downcast&lt;RemoteLayerTreeDrawingArea&gt;(*m_drawingArea).nextTransactionID());
</span><span class="cx">     cancelPotentialTapInFrame(*frame);
</span><ins>+#endif
</ins><span class="cx">     resetAssistedNodeForFrame(frame);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     if (!frame-&gt;isMainFrame())
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -496,6 +496,10 @@
</span><span class="cx">     UserMediaPermissionRequestManager&amp; userMediaPermissionRequestManager() { return m_userMediaPermissionRequestManager; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    void elementDidFocus(WebCore::Node*);
+    void elementDidBlur(WebCore::Node*);
+    void resetAssistedNodeForFrame(WebFrame*);
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     WebCore::FloatSize screenSize() const;
</span><span class="cx">     WebCore::FloatSize availableScreenSize() const;
</span><span class="lines">@@ -538,8 +542,6 @@
</span><span class="cx">     void updateSelectionWithExtentPoint(const WebCore::IntPoint&amp;, bool isInteractingWithAssistedNode, uint64_t callbackID);
</span><span class="cx">     void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&amp;, uint32_t granularity, bool isInteractingWithAssistedNode, uint64_t callbackID);
</span><span class="cx"> 
</span><del>-    void elementDidFocus(WebCore::Node*);
-    void elementDidBlur(WebCore::Node*);
</del><span class="cx">     void requestDictationContext(uint64_t callbackID);
</span><span class="cx">     void replaceDictatedText(const String&amp; oldText, const String&amp; newText);
</span><span class="cx">     void replaceSelectedText(const String&amp; oldText, const String&amp; newText);
</span><span class="lines">@@ -557,7 +559,6 @@
</span><span class="cx">     void setAssistedNodeValue(const String&amp;);
</span><span class="cx">     void setAssistedNodeValueAsNumber(double);
</span><span class="cx">     void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection);
</span><del>-    void resetAssistedNodeForFrame(WebFrame*);
</del><span class="cx">     WebCore::IntRect rectForElementAtInteractionLocation();
</span><span class="cx">     void updateSelectionAppearance();
</span><span class="cx">     void getSelectionContext(uint64_t callbackID);
</span><span class="lines">@@ -1388,14 +1389,17 @@
</span><span class="cx">     bool m_autoSizingShouldExpandToViewHeight;
</span><span class="cx"> 
</span><span class="cx">     bool m_userIsInteracting;
</span><del>-    bool m_hasFocusedDueToUserInteraction { false };
</del><ins>+    bool m_isAssistingNodeDueToUserInteraction { false };
+    bool m_hasEverFocusedElementDueToUserInteractionSincePageTransition { false };
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTEXT_MENUS)
</span><span class="cx">     bool m_isShowingContextMenu;
</span><span class="cx"> #endif
</span><ins>+
+    RefPtr&lt;WebCore::Node&gt; m_assistedNode;
+    bool m_hasPendingBlurNotification;
</ins><span class="cx">     
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    RefPtr&lt;WebCore::Node&gt; m_assistedNode;
</del><span class="cx">     RefPtr&lt;WebCore::Range&gt; m_currentWordRange;
</span><span class="cx">     RefPtr&lt;WebCore::Node&gt; m_interactionNode;
</span><span class="cx">     WebCore::IntPoint m_lastInteractionLocation;
</span><span class="lines">@@ -1414,7 +1418,6 @@
</span><span class="cx">     bool m_scaleWasSetByUIProcess;
</span><span class="cx">     bool m_userHasChangedPageScaleFactor;
</span><span class="cx">     bool m_hasStablePageScaleFactor;
</span><del>-    bool m_hasPendingBlurNotification;
</del><span class="cx">     bool m_useTestingViewportConfiguration;
</span><span class="cx">     bool m_isInStableState;
</span><span class="cx">     bool m_forceAlwaysUserScalable;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (203311 => 203312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2016-07-16 00:09:06 UTC (rev 203311)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2016-07-16 00:39:50 UTC (rev 203312)
</span><span class="lines">@@ -2632,50 +2632,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::resetAssistedNodeForFrame(WebFrame* frame)
-{
-    if (!m_assistedNode)
-        return;
-    if (m_assistedNode-&gt;document().frame() == frame-&gt;coreFrame()) {
-        send(Messages::WebPageProxy::StopAssistingNode());
-        m_assistedNode = nullptr;
-    }
-}
-
-void WebPage::elementDidFocus(WebCore::Node* node)
-{
-    if (m_assistedNode == node &amp;&amp; m_hasFocusedDueToUserInteraction)
-        return;
-
-    if (node-&gt;hasTagName(WebCore::HTMLNames::selectTag) || node-&gt;hasTagName(WebCore::HTMLNames::inputTag) || node-&gt;hasTagName(WebCore::HTMLNames::textareaTag) || node-&gt;hasEditableStyle()) {
-        m_assistedNode = node;
-        m_hasFocusedDueToUserInteraction |= m_userIsInteracting;
-        AssistedNodeInformation information;
-        getAssistedNodeInformation(information);
-        RefPtr&lt;API::Object&gt; userData;
-
-        m_formClient-&gt;willBeginInputSession(this, downcast&lt;Element&gt;(node), WebFrame::fromCoreFrame(*node-&gt;document().frame()), userData, m_userIsInteracting);
-
-        send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, m_hasPendingBlurNotification, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
-        m_hasPendingBlurNotification = false;
-    }
-}
-
-void WebPage::elementDidBlur(WebCore::Node* node)
-{
-    if (m_assistedNode == node) {
-        m_hasPendingBlurNotification = true;
-        RefPtr&lt;WebPage&gt; protectedThis(this);
-        dispatch_async(dispatch_get_main_queue(), [protectedThis] {
-            if (protectedThis-&gt;m_hasPendingBlurNotification)
-                protectedThis-&gt;send(Messages::WebPageProxy::StopAssistingNode());
-            protectedThis-&gt;m_hasPendingBlurNotification = false;
-        });
-        m_hasFocusedDueToUserInteraction = false;
-        m_assistedNode = nullptr;
-    }
-}
-
</del><span class="cx"> void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize&amp; size)
</span><span class="cx"> {
</span><span class="cx">     if (m_viewportConfiguration.setMinimumLayoutSize(size))
</span></span></pre>
</div>
</div>

</body>
</html>