Expose a WKWebView API for allowing programmatic focus to trigger node assistance
[WebKit-https.git] / Source / WebKit2 / UIProcess / ios / WebPageProxyIOS.mm
index ed3fd48..a3ee2b5 100644 (file)
@@ -358,6 +358,12 @@ void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&
         m_hitRenderTreeSizeThreshold = true;
         didLayout(WebCore::ReachedSessionRestorationRenderTreeSizeThreshold);
     }
+
+    if (m_hasDeferredStartAssistingNode) {
+        m_pageClient.startAssistingNode(m_deferredNodeAssistanceArguments->m_nodeInformation, m_deferredNodeAssistanceArguments->m_userIsInteracting, m_deferredNodeAssistanceArguments->m_blurPreviousNode, m_deferredNodeAssistanceArguments->m_userData.get());
+        m_hasDeferredStartAssistingNode = false;
+        m_deferredNodeAssistanceArguments = nullptr;
+    }
 }
 
 void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, WebCore::TextGranularity granularity, uint32_t gestureType, uint32_t gestureState, std::function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)> callbackFunction)
@@ -805,11 +811,22 @@ void WebPageProxy::didGetTapHighlightGeometries(uint64_t requestID, const WebCor
 
 void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information, bool userIsInteracting, bool blurPreviousNode, const UserData& userData)
 {
-    m_pageClient.startAssistingNode(information, userIsInteracting, blurPreviousNode, process().transformHandlesToObjects(userData.object()).get());
+    API::Object* userDataObject = process().transformHandlesToObjects(userData.object()).get();
+    if (m_editorState.isMissingPostLayoutData) {
+        m_deferredNodeAssistanceArguments = std::make_unique<NodeAssistanceArguments>(NodeAssistanceArguments { information, userIsInteracting, blurPreviousNode, userDataObject });
+        m_hasDeferredStartAssistingNode = true;
+        return;
+    }
+
+    m_pageClient.startAssistingNode(information, userIsInteracting, blurPreviousNode, userDataObject);
 }
 
 void WebPageProxy::stopAssistingNode()
 {
+    if (m_hasDeferredStartAssistingNode) {
+        m_hasDeferredStartAssistingNode = false;
+        m_deferredNodeAssistanceArguments = nullptr;
+    }
     m_pageClient.stopAssistingNode();
 }