<!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>[167774] 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/167774">167774</a></dd>
<dt>Author</dt> <dd>enrica@apple.com</dd>
<dt>Date</dt> <dd>2014-04-24 14:44:42 -0700 (Thu, 24 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WebKit2] Should properly handle focus redirect (keyboard state changes when focus changes).
https://bugs.webkit.org/show_bug.cgi?id=132136
&lt;rdar://problem/16238336&gt;

Reviewed by Benjamin Poulain.

Focusing a field from JavaScript should not make the keyboard or the select picker
appear unless the user has already started interacting with one of the fields in the page.
Adding a parameter to StartAssistingNode to indicate whether the focus change is a result
of a user action.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::startAssistingNode):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startAssistingNode:userIsInteracting:userObject:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::startAssistingNode):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::dispatchTouchEvent):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleTap):
(WebKit::WebPage::elementDidFocus):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</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="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.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 (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/ChangeLog        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2014-04-24  Enrica Casucci  &lt;enrica@apple.com&gt;
+
+        [iOS WebKit2] Should properly handle focus redirect (keyboard state changes when focus changes).
+        https://bugs.webkit.org/show_bug.cgi?id=132136
+        &lt;rdar://problem/16238336&gt;
+
+        Reviewed by Benjamin Poulain.
+
+        Focusing a field from JavaScript should not make the keyboard or the select picker
+        appear unless the user has already started interacting with one of the fields in the page.
+        Adding a parameter to StartAssistingNode to indicate whether the focus change is a result
+        of a user action.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::startAssistingNode):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startAssistingNode:userIsInteracting:userObject:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::startAssistingNode):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::dispatchTouchEvent):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleTap):
+        (WebKit::WebPage::elementDidFocus):
+
</ins><span class="cx"> 2014-04-24  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         FontCache::fontCache() never returns nullptr so it can be made to return a reference instead
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -243,7 +243,7 @@
</span><span class="cx">     virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&amp;) = 0;
</span><span class="cx">     virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition) = 0;
</span><span class="cx"> 
</span><del>-    virtual void startAssistingNode(const AssistedNodeInformation&amp;, API::Object* userData) = 0;
</del><ins>+    virtual void startAssistingNode(const AssistedNodeInformation&amp;, bool userIsInteracting, API::Object* userData) = 0;
</ins><span class="cx">     virtual void stopAssistingNode() = 0;
</span><span class="cx">     virtual void selectionDidChange() = 0;
</span><span class="cx">     virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&amp;, bool isCharEvent) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -1356,7 +1356,7 @@
</span><span class="cx">     void dynamicViewportUpdateChangedTarget(double newTargetScale, const WebCore::FloatPoint&amp; newScrollPosition);
</span><span class="cx">     void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&amp; color, const Vector&lt;WebCore::FloatQuad&gt;&amp; geometries, const WebCore::IntSize&amp; topLeftRadius, const WebCore::IntSize&amp; topRightRadius, const WebCore::IntSize&amp; bottomLeftRadius, const WebCore::IntSize&amp; bottomRightRadius);
</span><span class="cx"> 
</span><del>-    void startAssistingNode(const AssistedNodeInformation&amp;, IPC::MessageDecoder&amp;);
</del><ins>+    void startAssistingNode(const AssistedNodeInformation&amp;, bool userIsInteracting, IPC::MessageDecoder&amp;);
</ins><span class="cx">     void stopAssistingNode();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INSPECTOR)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -320,7 +320,7 @@
</span><span class="cx">     DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition)
</span><span class="cx">     DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector&lt;WebCore::FloatQuad&gt; geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius)
</span><span class="cx"> 
</span><del>-    StartAssistingNode(WebKit::AssistedNodeInformation information, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</del><ins>+    StartAssistingNode(WebKit::AssistedNodeInformation information, bool userIsInteracting, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
</ins><span class="cx">     StopAssistingNode()
</span><span class="cx">     NotifyRevealedSelection()
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx">     virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&amp;) override;
</span><span class="cx">     virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition) override;
</span><span class="cx"> 
</span><del>-    virtual void startAssistingNode(const AssistedNodeInformation&amp;, API::Object* userData) override;
</del><ins>+    virtual void startAssistingNode(const AssistedNodeInformation&amp;, bool userIsInteracting, API::Object* userData) override;
</ins><span class="cx">     virtual void stopAssistingNode() override;
</span><span class="cx">     virtual void selectionDidChange() override;
</span><span class="cx">     virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&amp;, bool isCharEvent) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -373,7 +373,7 @@
</span><span class="cx">     [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::startAssistingNode(const AssistedNodeInformation&amp; nodeInformation, API::Object* userData)
</del><ins>+void PageClientImpl::startAssistingNode(const AssistedNodeInformation&amp; nodeInformation, bool userIsInteracting, API::Object* userData)
</ins><span class="cx"> {
</span><span class="cx">     MESSAGE_CHECK(!userData || userData-&gt;type() == API::Object::Type::Data);
</span><span class="cx"> 
</span><span class="lines">@@ -389,7 +389,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    [m_contentView _startAssistingNode:nodeInformation userObject:userObject];
</del><ins>+    [m_contentView _startAssistingNode:nodeInformation userIsInteracting:userIsInteracting userObject:userObject];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::stopAssistingNode()
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx"> - (void)_webTouchEvent:(const WebKit::NativeWebTouchEvent&amp;)touchEvent preventsNativeGestures:(BOOL)preventsDefault;
</span><span class="cx"> - (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&amp;)color quads:(const Vector&lt;WebCore::FloatQuad&gt;&amp;)highlightedQuads topLeftRadius:(const WebCore::IntSize&amp;)topLeftRadius topRightRadius:(const WebCore::IntSize&amp;)topRightRadius bottomLeftRadius:(const WebCore::IntSize&amp;)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&amp;)bottomRightRadius;
</span><span class="cx"> 
</span><del>-- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&amp;)information userObject:(NSObject &lt;NSSecureCoding&gt; *)userObject;
</del><ins>+- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&amp;)information userIsInteracting:(BOOL)userIsInteracting userObject:(NSObject &lt;NSSecureCoding&gt; *)userObject;
</ins><span class="cx"> - (void)_stopAssistingNode;
</span><span class="cx"> - (void)_selectionChanged;
</span><span class="cx"> - (void)_updateChangedSelection;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -1979,8 +1979,11 @@
</span><span class="cx">     return _formAccessoryView.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_startAssistingNode:(const AssistedNodeInformation&amp;)information userObject:(NSObject &lt;NSSecureCoding&gt; *)userObject
</del><ins>+- (void)_startAssistingNode:(const AssistedNodeInformation&amp;)information userIsInteracting:(BOOL)userIsInteracting userObject:(NSObject &lt;NSSecureCoding&gt; *)userObject
</ins><span class="cx"> {
</span><ins>+    if (!userIsInteracting &amp;&amp; !_textSelectionAssistant)
+        return;
+
</ins><span class="cx">     _isEditable = YES;
</span><span class="cx">     _assistedNodeInformation = information;
</span><span class="cx">     _inputPeripheral = nil;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -488,14 +488,14 @@
</span><span class="cx">     m_pageClient.didGetTapHighlightGeometries(requestID, color, highlightedQuads, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::startAssistingNode(const AssistedNodeInformation&amp; information, IPC::MessageDecoder&amp; decoder)
</del><ins>+void WebPageProxy::startAssistingNode(const AssistedNodeInformation&amp; information, bool userIsInteracting, IPC::MessageDecoder&amp; decoder)
</ins><span class="cx"> {
</span><span class="cx">     RefPtr&lt;API::Object&gt; userData;
</span><span class="cx">     WebContextUserMessageDecoder messageDecoder(userData, process());
</span><span class="cx">     if (!decoder.decode(messageDecoder))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_pageClient.startAssistingNode(information, userData.get());
</del><ins>+    m_pageClient.startAssistingNode(information, userIsInteracting, userData.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::stopAssistingNode()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -286,6 +286,7 @@
</span><span class="cx">     , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false)
</span><span class="cx">     , m_scaleWasSetByUIProcess(false)
</span><span class="cx">     , m_userHasChangedPageScaleFactor(false)
</span><ins>+    , m_userIsInteracting(false)
</ins><span class="cx">     , m_screenSize(parameters.screenSize)
</span><span class="cx">     , m_availableScreenSize(parameters.availableScreenSize)
</span><span class="cx">     , m_inDynamicSizeUpdate(false)
</span><span class="lines">@@ -1955,9 +1956,25 @@
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx"> void WebPage::dispatchTouchEvent(const WebTouchEvent&amp; touchEvent, bool&amp; handled)
</span><span class="cx"> {
</span><ins>+    RefPtr&lt;Frame&gt; oldFocusedFrame = m_page-&gt;focusController().focusedFrame();
+    RefPtr&lt;Element&gt; oldFocusedElement = oldFocusedFrame ? oldFocusedFrame-&gt;document()-&gt;focusedElement() : nullptr;
+    m_userIsInteracting = true;
+
</ins><span class="cx">     m_lastInteractionLocation = touchEvent.position();
</span><span class="cx">     CurrentEvent currentEvent(touchEvent);
</span><span class="cx">     handled = handleTouchEvent(touchEvent, m_page.get());
</span><ins>+
+    RefPtr&lt;Frame&gt; newFocusedFrame = m_page-&gt;focusController().focusedFrame();
+    RefPtr&lt;Element&gt; newFocusedElement = newFocusedFrame ? newFocusedFrame-&gt;document()-&gt;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 &amp;&amp; newFocusedElement == oldFocusedElement)
+        elementDidFocus(newFocusedElement.get());
+
+    m_userIsInteracting = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::touchEventSync(const WebTouchEvent&amp; touchEvent, bool&amp; handled)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -1162,6 +1162,7 @@
</span><span class="cx">     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad;
</span><span class="cx">     bool m_scaleWasSetByUIProcess;
</span><span class="cx">     bool m_userHasChangedPageScaleFactor;
</span><ins>+    bool m_userIsInteracting;
</ins><span class="cx">     WebCore::FloatSize m_screenSize;
</span><span class="cx">     WebCore::FloatSize m_availableScreenSize;
</span><span class="cx">     WebCore::IntSize m_blockSelectionDesiredSize;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (167773 => 167774)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-04-24 21:20:54 UTC (rev 167773)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-04-24 21:44:42 UTC (rev 167774)
</span><span class="lines">@@ -312,9 +312,25 @@
</span><span class="cx">     if (WKObservedContentChange() != WKContentNoChange)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;Frame&gt; oldFocusedFrame = m_page-&gt;focusController().focusedFrame();
+    RefPtr&lt;Element&gt; oldFocusedElement = oldFocusedFrame ? oldFocusedFrame-&gt;document()-&gt;focusedElement() : nullptr;
+    m_userIsInteracting = true;
+
</ins><span class="cx">     m_lastInteractionLocation = roundedAdjustedPoint;
</span><span class="cx">     mainframe.eventHandler().handleMousePressEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, 0));
</span><span class="cx">     mainframe.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 1, false, false, false, false, 0));
</span><ins>+
+    RefPtr&lt;Frame&gt; newFocusedFrame = m_page-&gt;focusController().focusedFrame();
+    RefPtr&lt;Element&gt; newFocusedElement = newFocusedFrame ? newFocusedFrame-&gt;document()-&gt;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 &amp;&amp; newFocusedElement == oldFocusedElement)
+        elementDidFocus(newFocusedElement.get());
+
+    m_userIsInteracting = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::tapHighlightAtPosition(uint64_t requestID, const FloatPoint&amp; position)
</span><span class="lines">@@ -1747,7 +1763,7 @@
</span><span class="cx">         getAssistedNodeInformation(information);
</span><span class="cx">         RefPtr&lt;API::Object&gt; userData;
</span><span class="cx">         m_formClient-&gt;willBeginInputSession(this, toElement(node), WebFrame::fromCoreFrame(*node-&gt;document().frame()), userData);
</span><del>-        send(Messages::WebPageProxy::StartAssistingNode(information, InjectedBundleUserMessageEncoder(userData.get())));
</del><ins>+        send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, InjectedBundleUserMessageEncoder(userData.get())));
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>