Title: [242551] trunk
Revision
242551
Author
[email protected]
Date
2019-03-06 09:38:37 -0800 (Wed, 06 Mar 2019)

Log Message

[iOS] Frequent 1 second IPC deadlocks when showing a paste callout
https://bugs.webkit.org/show_bug.cgi?id=195354
<rdar://problem/48624675>

Reviewed by Tim Horton.

Source/WebKit:

When triggering programmatic paste, we frequently hit deadlocks due to sync IPC going from the UI process to the
web process and vice versa. What happens in this scenario is that prior to triggering programmatic paste, the
page may try to move focus to a different element (e.g. a hidden editable area) before calling `execCommand`.
This causes us to send an ElementDidFocus message to the UI process, followed by RequestDOMPasteAccess.

However, upon receiving ElementDidFocus, we reload input views and (in the process) UIKit requests the
autocorrection context, which we implement in WebKit using a sync message to the web process due to
<rdar://problem/16207002> and its blocking bug <rdar://problem/48383001>. This means we'll end up in a state
where both the UI process and web process are blocked on each other waiting for a sync IPC response, and the UI
process is hung for a second until the IPC message times out.

Ideally, we should fix this by addressing <rdar://problem/16207002>. However, this requires potentially large
changes in UIKit (<rdar://problem/48383001>); for the time being, work around this deadlock by refactoring
synchronous autocorrection context requests such that they can be resolved by an out-of-band IPC response
(HandleAutocorrectionContext). Then prior to requesting DOM paste access, preemptively send a
HandleAutocorrectionContext message to the UI process to unblock any pending synchronous autocorrection context
requests.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::handleAutocorrectionContext):
* UIProcess/ios/WKContentViewInteraction.h:

Make it possible for WKContentView to remember its current pending autocorrection context completion handler.
This is invoked and cleared out in `-_invokePendingAutocorrectionContextHandler:`.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _invokePendingAutocorrectionContextHandler:]):
(-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
(-[WKContentView _handleAutocorrectionContext:]):

Handle an autocorrection context response. This is invoked when the web process either handles an autocorrection
context message, or when it preemptively sends an autocorrection context before requesting DOM paste access.

(+[WKAutocorrectionContext emptyAutocorrectionContext]):

Add a helper to create an empty autocorrection context.

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::requestAutocorrectionContext):
(WebKit::WebPageProxy::handleAutocorrectionContext):
(WebKit::WebPageProxy::autocorrectionContextSync): Deleted.

Removed this sync version, since we now only have requestAutocorrectionContext.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::requestDOMPasteAccess):

Send WebPageProxy::HandleAutocorrectionContext, and add a FIXME referencing <rdar://problem/16207002>.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Split AutocorrectionContextSync into RequestAutocorrectionContext and HandleAutocorrectionContext; additionally,
remove the existing RequestAutocorrectionContext message.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestAutocorrectionContext):
(WebKit::WebPage::autocorrectionContextSync): Deleted.

LayoutTests:

Most of these tests currently encounter and rely on the 1 second IPC timeout to finish. To test this fix, force
`ignoreSynchronousMessagingTimeouts=true` to make them fail if the processes encounter a deadlock.

* editing/pasteboard/ios/dom-paste-confirmation.html:
* editing/pasteboard/ios/dom-paste-consecutive-confirmations.html:
* editing/pasteboard/ios/dom-paste-rejection.html:
* editing/pasteboard/ios/dom-paste-requires-user-gesture.html:
* editing/pasteboard/ios/dom-paste-same-origin.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242550 => 242551)


--- trunk/LayoutTests/ChangeLog	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/LayoutTests/ChangeLog	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,3 +1,20 @@
+2019-03-06  Wenson Hsieh  <[email protected]>
+
+        [iOS] Frequent 1 second IPC deadlocks when showing a paste callout
+        https://bugs.webkit.org/show_bug.cgi?id=195354
+        <rdar://problem/48624675>
+
+        Reviewed by Tim Horton.
+
+        Most of these tests currently encounter and rely on the 1 second IPC timeout to finish. To test this fix, force
+        `ignoreSynchronousMessagingTimeouts=true` to make them fail if the processes encounter a deadlock.
+
+        * editing/pasteboard/ios/dom-paste-confirmation.html:
+        * editing/pasteboard/ios/dom-paste-consecutive-confirmations.html:
+        * editing/pasteboard/ios/dom-paste-rejection.html:
+        * editing/pasteboard/ios/dom-paste-requires-user-gesture.html:
+        * editing/pasteboard/ios/dom-paste-same-origin.html:
+
 2019-03-06  Javier Fernandez  <[email protected]>
 
         Import new tests from the CSS Text 3 WPT test suite

Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html (242550 => 242551)


--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
 <html>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <head>

Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html (242550 => 242551)


--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
 <html>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <head>

Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html (242550 => 242551)


--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
 <html>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <head>

Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html (242550 => 242551)


--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
 <html>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <head>

Modified: trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html (242550 => 242551)


--- trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
 <html>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <head>

Modified: trunk/Source/WebKit/ChangeLog (242550 => 242551)


--- trunk/Source/WebKit/ChangeLog	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/ChangeLog	2019-03-06 17:38:37 UTC (rev 242551)
@@ -1,3 +1,74 @@
+2019-03-06  Wenson Hsieh  <[email protected]>
+
+        [iOS] Frequent 1 second IPC deadlocks when showing a paste callout
+        https://bugs.webkit.org/show_bug.cgi?id=195354
+        <rdar://problem/48624675>
+
+        Reviewed by Tim Horton.
+
+        When triggering programmatic paste, we frequently hit deadlocks due to sync IPC going from the UI process to the
+        web process and vice versa. What happens in this scenario is that prior to triggering programmatic paste, the
+        page may try to move focus to a different element (e.g. a hidden editable area) before calling `execCommand`.
+        This causes us to send an ElementDidFocus message to the UI process, followed by RequestDOMPasteAccess.
+
+        However, upon receiving ElementDidFocus, we reload input views and (in the process) UIKit requests the
+        autocorrection context, which we implement in WebKit using a sync message to the web process due to
+        <rdar://problem/16207002> and its blocking bug <rdar://problem/48383001>. This means we'll end up in a state
+        where both the UI process and web process are blocked on each other waiting for a sync IPC response, and the UI
+        process is hung for a second until the IPC message times out.
+
+        Ideally, we should fix this by addressing <rdar://problem/16207002>. However, this requires potentially large
+        changes in UIKit (<rdar://problem/48383001>); for the time being, work around this deadlock by refactoring
+        synchronous autocorrection context requests such that they can be resolved by an out-of-band IPC response
+        (HandleAutocorrectionContext). Then prior to requesting DOM paste access, preemptively send a
+        HandleAutocorrectionContext message to the UI process to unblock any pending synchronous autocorrection context
+        requests.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::handleAutocorrectionContext):
+        * UIProcess/ios/WKContentViewInteraction.h:
+
+        Make it possible for WKContentView to remember its current pending autocorrection context completion handler.
+        This is invoked and cleared out in `-_invokePendingAutocorrectionContextHandler:`.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _invokePendingAutocorrectionContextHandler:]):
+        (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
+        (-[WKContentView _handleAutocorrectionContext:]):
+
+        Handle an autocorrection context response. This is invoked when the web process either handles an autocorrection
+        context message, or when it preemptively sends an autocorrection context before requesting DOM paste access.
+
+        (+[WKAutocorrectionContext emptyAutocorrectionContext]):
+
+        Add a helper to create an empty autocorrection context.
+
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::requestAutocorrectionContext):
+        (WebKit::WebPageProxy::handleAutocorrectionContext):
+        (WebKit::WebPageProxy::autocorrectionContextSync): Deleted.
+
+        Removed this sync version, since we now only have requestAutocorrectionContext.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::requestDOMPasteAccess):
+
+        Send WebPageProxy::HandleAutocorrectionContext, and add a FIXME referencing <rdar://problem/16207002>.
+
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
+        Split AutocorrectionContextSync into RequestAutocorrectionContext and HandleAutocorrectionContext; additionally,
+        remove the existing RequestAutocorrectionContext message.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestAutocorrectionContext):
+        (WebKit::WebPage::autocorrectionContextSync): Deleted.
+
 2019-03-06  Rob Buis  <[email protected]>
 
         Consider supporting the `referrerpolicy` attribute.

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2019-03-06 17:38:37 UTC (rev 242551)
@@ -130,6 +130,7 @@
 
 struct FocusedElementInformation;
 struct InteractionInformationAtPosition;
+struct WebAutocorrectionContext;
 struct WebHitTestResultData;
 
 #if ENABLE(TOUCH_EVENTS)
@@ -394,6 +395,8 @@
 
     virtual void enableInspectorNodeSearch() = 0;
     virtual void disableInspectorNodeSearch() = 0;
+
+    virtual void handleAutocorrectionContext(const WebAutocorrectionContext&) = 0;
 #endif
 
     // Auxiliary Client Creation

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-03-06 17:38:37 UTC (rev 242551)
@@ -650,8 +650,8 @@
     void requestAutocorrectionData(const String& textForAutocorrection, WTF::Function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>&&);
     void applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&&);
     bool applyAutocorrection(const String& correction, const String& originalText);
-    void requestAutocorrectionContext(Function<void(const WebAutocorrectionContext&, CallbackBase::Error)>&&);
-    WebAutocorrectionContext autocorrectionContextSync();
+    void requestAutocorrectionContext();
+    void handleAutocorrectionContext(const WebAutocorrectionContext&);
     void requestDictationContext(WTF::Function<void (const String&, const String&, const String&, CallbackBase::Error)>&&);
     void replaceDictatedText(const String& oldText, const String& newText);
     void replaceSelectedText(const String& oldText, const String& newText);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-03-06 17:38:37 UTC (rev 242551)
@@ -417,6 +417,7 @@
     DisableInspectorNodeSearch()
 
     UpdateStringForFind(String findString)
+    HandleAutocorrectionContext(struct WebKit::WebAutocorrectionContext context)
 #endif
 
     DidChangeInspectorFrontendCount(uint64_t count)

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2019-03-06 17:38:37 UTC (rev 242551)
@@ -236,6 +236,8 @@
     void didChangeDragCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override;
 #endif
 
+    void handleAutocorrectionContext(const WebAutocorrectionContext&) final;
+
     void didFinishProcessingAllPendingMouseEvents() final { }
 
 #if HAVE(PENCILKIT)

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2019-03-06 17:38:37 UTC (rev 242551)
@@ -857,6 +857,11 @@
 }
 #endif
 
+void PageClientImpl::handleAutocorrectionContext(const WebAutocorrectionContext& context)
+{
+    [m_contentView _handleAutocorrectionContext:context];
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-03-06 17:38:37 UTC (rev 242551)
@@ -85,6 +85,7 @@
 class SmartMagnificationController;
 class WebOpenPanelResultListenerProxy;
 class WebPageProxy;
+struct WebAutocorrectionContext;
 }
 
 @class _UILookupGestureRecognizer;
@@ -318,6 +319,7 @@
 
     BOOL _hasSetUpInteractions;
     CompletionHandler<void(WebCore::DOMPasteAccessResponse)> _domPasteRequestHandler;
+    BlockPtr<void(UIWKAutocorrectionContext *)> _pendingAutocorrectionContextHandler;
 
 #if ENABLE(DATA_INTERACTION)
     WebKit::DragDropInteractionState _dragDropInteractionState;
@@ -465,6 +467,8 @@
 - (WKDrawingCoordinator *)_drawingCoordinator;
 #endif
 
+- (void)_handleAutocorrectionContext:(const WebKit::WebAutocorrectionContext&)context;
+
 @end
 
 @interface WKContentView (WKTesting)

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-06 17:38:37 UTC (rev 242551)
@@ -276,6 +276,7 @@
 @end
 
 @interface WKAutocorrectionContext : UIWKAutocorrectionContext
++ (WKAutocorrectionContext *)emptyAutocorrectionContext;
 + (WKAutocorrectionContext *)autocorrectionContextWithContext:(const WebKit::WebAutocorrectionContext&)context;
 @end
 
@@ -3579,6 +3580,12 @@
     });
 }
 
+- (void)_invokePendingAutocorrectionContextHandler:(WKAutocorrectionContext *)context
+{
+    if (auto handler = WTFMove(_pendingAutocorrectionContextHandler))
+        handler(context);
+}
+
 - (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler
 {
     if (!completionHandler) {
@@ -3588,7 +3595,7 @@
 
 #if USE(UIKIT_KEYBOARD_ADDITIONS)
     if ([self _disableAutomaticKeyboardUI]) {
-        completionHandler([WKAutocorrectionContext autocorrectionContextWithContext:(WebKit::WebAutocorrectionContext { })]);
+        completionHandler(WKAutocorrectionContext.emptyAutocorrectionContext);
         return;
     }
 #endif
@@ -3596,14 +3603,21 @@
     // FIXME: Remove the synchronous call when <rdar://problem/16207002> is fixed.
     const bool useSyncRequest = true;
 
+    [self _invokePendingAutocorrectionContextHandler:WKAutocorrectionContext.emptyAutocorrectionContext];
+
+    _pendingAutocorrectionContextHandler = completionHandler;
+    _page->requestAutocorrectionContext();
+
     if (useSyncRequest) {
-        completionHandler([WKAutocorrectionContext autocorrectionContextWithContext:_page->autocorrectionContextSync()]);
+        _page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::HandleAutocorrectionContext>(_page->pageID(), 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
+        [self _invokePendingAutocorrectionContextHandler:WKAutocorrectionContext.emptyAutocorrectionContext];
         return;
     }
+}
 
-    _page->requestAutocorrectionContext([protectedSelf = retainPtr(self), completion = makeBlockPtr(completionHandler)] (auto& context, auto) {
-        completion([WKAutocorrectionContext autocorrectionContextWithContext:context]);
-    });
+- (void)_handleAutocorrectionContext:(const WebKit::WebAutocorrectionContext&)context
+{
+    [self _invokePendingAutocorrectionContextHandler:[WKAutocorrectionContext autocorrectionContextWithContext:context]];
 }
 
 // UIWebFormAccessoryDelegate
@@ -7410,6 +7424,11 @@
 
 @implementation WKAutocorrectionContext
 
++ (WKAutocorrectionContext *)emptyAutocorrectionContext
+{
+    return [self autocorrectionContextWithContext:WebKit::WebAutocorrectionContext { }];
+}
+
 + (WKAutocorrectionContext *)autocorrectionContextWithContext:(const WebKit::WebAutocorrectionContext&)webContext
 {
     WKAutocorrectionContext *context = [[WKAutocorrectionContext alloc] init];

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (242550 => 242551)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-03-06 17:38:37 UTC (rev 242551)
@@ -563,22 +563,14 @@
     m_process->send(Messages::WebPage::RequestDictationContext(callbackID), m_pageID);
 }
 
-void WebPageProxy::requestAutocorrectionContext(Function<void(const WebAutocorrectionContext&, CallbackBase::Error)>&& callback)
+void WebPageProxy::requestAutocorrectionContext()
 {
-    if (!isValid()) {
-        callback({ }, CallbackBase::Error::OwnerWasInvalidated);
-        return;
-    }
-
-    auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken());
-    m_process->send(Messages::WebPage::RequestAutocorrectionContext(callbackID), m_pageID);
+    m_process->send(Messages::WebPage::RequestAutocorrectionContext(), m_pageID);
 }
 
-WebAutocorrectionContext WebPageProxy::autocorrectionContextSync()
+void WebPageProxy::handleAutocorrectionContext(const WebAutocorrectionContext& context)
 {
-    WebAutocorrectionContext context;
-    m_process->sendSync(Messages::WebPage::AutocorrectionContextSync(), Messages::WebPage::AutocorrectionContextSync::Reply(context), m_pageID);
-    return context;
+    pageClient().handleAutocorrectionContext(context);
 }
 
 void WebPageProxy::getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&& callbackFunction)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (242550 => 242551)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-03-06 17:38:37 UTC (rev 242551)
@@ -268,6 +268,7 @@
 #include "InteractionInformationAtPosition.h"
 #include "InteractionInformationRequest.h"
 #include "RemoteLayerTreeDrawingArea.h"
+#include "WebAutocorrectionContext.h"
 #include <CoreGraphics/CoreGraphics.h>
 #include <WebCore/Icon.h>
 #include <pal/spi/cocoa/CoreTextSPI.h>
@@ -6373,6 +6374,13 @@
 WebCore::DOMPasteAccessResponse WebPage::requestDOMPasteAccess(const String& originIdentifier)
 {
     auto response = WebCore::DOMPasteAccessResponse::DeniedForGesture;
+#if PLATFORM(IOS_FAMILY)
+    // FIXME: Computing and sending an autocorrection context is a workaround for the fact that autocorrection context
+    // requests on iOS are currently synchronous in the web process. This allows us to immediately fulfill pending
+    // autocorrection context requests in the UI process on iOS before handling the DOM paste request. This workaround
+    // should be removed once <rdar://problem/16207002> is resolved.
+    send(Messages::WebPageProxy::HandleAutocorrectionContext(autocorrectionContext()));
+#endif
     sendSyncWithDelayedReply(Messages::WebPageProxy::RequestDOMPasteAccess(rectForElementAtInteractionLocation(), originIdentifier), Messages::WebPageProxy::RequestDOMPasteAccess::Reply(response));
     return response;
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (242550 => 242551)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-03-06 17:38:37 UTC (rev 242551)
@@ -641,8 +641,7 @@
     void requestAutocorrectionData(const String& textForAutocorrection, CallbackID);
     void applyAutocorrection(const String& correction, const String& originalText, CallbackID);
     void syncApplyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(bool)>&&);
-    void requestAutocorrectionContext(CallbackID);
-    void autocorrectionContextSync(CompletionHandler<void(WebAutocorrectionContext&&)>&&);
+    void requestAutocorrectionContext();
     void getPositionInformation(const InteractionInformationRequest&, CompletionHandler<void(InteractionInformationAtPosition&&)>&&);
     void requestPositionInformation(const InteractionInformationRequest&);
     void startInteractionWithElementAtPosition(const WebCore::IntPoint&);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (242550 => 242551)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-03-06 17:38:37 UTC (rev 242551)
@@ -78,8 +78,7 @@
     RequestAutocorrectionData(String textForAutocorrection, WebKit::CallbackID callbackID)
     ApplyAutocorrection(String correction, String originalText, WebKit::CallbackID callbackID)
     SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied) Delayed
-    RequestAutocorrectionContext(WebKit::CallbackID callbackID)
-    AutocorrectionContextSync() -> (struct WebKit::WebAutocorrectionContext context) Delayed
+    RequestAutocorrectionContext()
     RequestEvasionRectsAboveSelection() -> (Vector<WebCore::FloatRect> rects) Async
     GetPositionInformation(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information) Delayed
     RequestPositionInformation(struct WebKit::InteractionInformationRequest request)

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (242550 => 242551)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-03-06 15:57:06 UTC (rev 242550)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-03-06 17:38:37 UTC (rev 242551)
@@ -2157,16 +2157,11 @@
     return { WTFMove(contextBefore), WTFMove(markedText), WTFMove(selectedText), WTFMove(contextAfter), location, length };
 }
 
-void WebPage::requestAutocorrectionContext(CallbackID callbackID)
+void WebPage::requestAutocorrectionContext()
 {
-    send(Messages::WebPageProxy::AutocorrectionContextCallback(autocorrectionContext(), callbackID));
+    send(Messages::WebPageProxy::HandleAutocorrectionContext(autocorrectionContext()));
 }
 
-void WebPage::autocorrectionContextSync(CompletionHandler<void(WebAutocorrectionContext&&)>&& completionHandler)
-{
-    completionHandler(autocorrectionContext());
-}
-
 static HTMLAnchorElement* containingLinkElement(Element* element)
 {
     for (auto& currentElement : elementLineage(element)) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to