Title: [264047] trunk/Source/WebKit
Revision
264047
Author
[email protected]
Date
2020-07-07 16:30:49 -0700 (Tue, 07 Jul 2020)

Log Message

Use sendWithAsyncReply instead of EditingRangeCallback
https://bugs.webkit.org/show_bug.cgi?id=214056

Patch by Alex Christensen <[email protected]> on 2020-07-07
Reviewed by Chris Dumez.

No change in behavior.

* UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
(-[WKReloadFrameErrorRecoveryAttempter initWithWebView:frameHandle:urlString:]):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::selectedRangeWithCompletionHandler):
(WebKit::WebViewImpl::markedRangeWithCompletionHandler):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::getMarkedRangeAsync):
(WebKit::WebPageProxy::getSelectedRangeAsync):
(WebKit::WebPageProxy::editingRangeCallback): Deleted.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (264046 => 264047)


--- trunk/Source/WebKit/ChangeLog	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/ChangeLog	2020-07-07 23:30:49 UTC (rev 264047)
@@ -1,3 +1,26 @@
+2020-07-07  Alex Christensen  <[email protected]>
+
+        Use sendWithAsyncReply instead of EditingRangeCallback
+        https://bugs.webkit.org/show_bug.cgi?id=214056
+
+        Reviewed by Chris Dumez.
+
+        No change in behavior.
+
+        * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
+        (-[WKReloadFrameErrorRecoveryAttempter initWithWebView:frameHandle:urlString:]):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::selectedRangeWithCompletionHandler):
+        (WebKit::WebViewImpl::markedRangeWithCompletionHandler):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::getMarkedRangeAsync):
+        (WebKit::WebPageProxy::getSelectedRangeAsync):
+        (WebKit::WebPageProxy::editingRangeCallback): Deleted.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2020-07-07  Brent Fulgham  <[email protected]>
 
         [macOS] Allow additional IOKit classes for Apple Silicon

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (264046 => 264047)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-07-07 23:30:49 UTC (rev 264047)
@@ -4920,13 +4920,8 @@
     auto completionHandler = adoptNS([completionHandlerPtr copy]);
 
     LOG(TextInput, "selectedRange");
-    m_page->getSelectedRangeAsync([completionHandler](const EditingRange& editingRangeResult, WebKit::CallbackBase::Error error) {
+    m_page->getSelectedRangeAsync([completionHandler](const EditingRange& editingRangeResult) {
         void (^completionHandlerBlock)(NSRange) = (void (^)(NSRange))completionHandler.get();
-        if (error != WebKit::CallbackBase::Error::None) {
-            LOG(TextInput, "    ...selectedRange failed.");
-            completionHandlerBlock(NSMakeRange(NSNotFound, 0));
-            return;
-        }
         NSRange result = editingRangeResult;
         if (result.location == NSNotFound)
             LOG(TextInput, "    -> selectedRange returned (NSNotFound, %llu)", result.length);
@@ -4941,13 +4936,8 @@
     auto completionHandler = adoptNS([completionHandlerPtr copy]);
 
     LOG(TextInput, "markedRange");
-    m_page->getMarkedRangeAsync([completionHandler](const EditingRange& editingRangeResult, WebKit::CallbackBase::Error error) {
+    m_page->getMarkedRangeAsync([completionHandler](const EditingRange& editingRangeResult) {
         void (^completionHandlerBlock)(NSRange) = (void (^)(NSRange))completionHandler.get();
-        if (error != WebKit::CallbackBase::Error::None) {
-            LOG(TextInput, "    ...markedRange failed.");
-            completionHandlerBlock(NSMakeRange(NSNotFound, 0));
-            return;
-        }
         NSRange result = editingRangeResult;
         if (result.location == NSNotFound)
             LOG(TextInput, "    -> markedRange returned (NSNotFound, %llu)", result.length);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (264046 => 264047)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-07-07 23:30:49 UTC (rev 264047)
@@ -7161,20 +7161,6 @@
     callback->performCallbackWithReturnValue(result);
 }
 
-void WebPageProxy::editingRangeCallback(const EditingRange& range, CallbackID callbackID)
-{
-    MESSAGE_CHECK(m_process, range.isValid());
-
-    auto callback = m_callbacks.take<EditingRangeCallback>(callbackID);
-    if (!callback) {
-        // FIXME: Log error or assert.
-        // this can validly happen if a load invalidated the callback, though
-        return;
-    }
-
-    callback->performCallbackWithReturnValue(range);
-}
-
 void WebPageProxy::editorStateChanged(const EditorState& editorState)
 {
     updateEditorState(editorState);
@@ -8749,26 +8735,24 @@
     sendWithAsyncReply(Messages::WebPage::HasMarkedText(), WTFMove(callback));
 }
 
-void WebPageProxy::getMarkedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::getMarkedRangeAsync(CompletionHandler<void(const EditingRange&)>&& callbackFunction)
 {
     if (!hasRunningProcess()) {
-        callbackFunction(EditingRange(), CallbackBase::Error::Unknown);
+        callbackFunction(EditingRange());
         return;
     }
 
-    auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getMarkedRangeAsync"_s));
-    send(Messages::WebPage::GetMarkedRangeAsync(callbackID));
+    sendWithAsyncReply(Messages::WebPage::GetMarkedRangeAsync(), WTFMove(callbackFunction));
 }
 
-void WebPageProxy::getSelectedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::getSelectedRangeAsync(CompletionHandler<void(const EditingRange&)>&& callbackFunction)
 {
     if (!hasRunningProcess()) {
-        callbackFunction(EditingRange(), CallbackBase::Error::Unknown);
+        callbackFunction(EditingRange());
         return;
     }
 
-    auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getSelectedRangeAsync"_s));
-    send(Messages::WebPage::GetSelectedRangeAsync(callbackID));
+    sendWithAsyncReply(Messages::WebPage::GetSelectedRangeAsync(), WTFMove(callbackFunction));
 }
 
 void WebPageProxy::characterIndexForPointAsync(const WebCore::IntPoint& point, WTF::Function<void (uint64_t, CallbackBase::Error)>&& callbackFunction)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (264046 => 264047)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-07-07 23:30:49 UTC (rev 264047)
@@ -366,7 +366,6 @@
 
 typedef GenericCallback<API::Data*> DataCallback;
 typedef GenericCallback<uint64_t> UnsignedCallback;
-typedef GenericCallback<EditingRange> EditingRangeCallback;
 typedef GenericCallback<const String&> StringCallback;
 typedef GenericCallback<API::SerializedScriptValue*, Optional<WebCore::ExceptionDetails>> ScriptValueCallback;
 typedef GenericCallback<const WebCore::FontAttributes&> FontAttributesCallback;
@@ -878,8 +877,8 @@
     void insertDictatedTextAsync(const String&, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>&, InsertTextOptions&&);
 
     void hasMarkedText(CompletionHandler<void(bool)>&&);
-    void getMarkedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&&);
-    void getSelectedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&&);
+    void getMarkedRangeAsync(CompletionHandler<void(const EditingRange&)>&&);
+    void getSelectedRangeAsync(CompletionHandler<void(const EditingRange&)>&&);
     void characterIndexForPointAsync(const WebCore::IntPoint&, WTF::Function<void (uint64_t, CallbackBase::Error)>&&);
     void firstRectForCharacterRangeAsync(const EditingRange&, WTF::Function<void (const WebCore::IntRect&, const EditingRange&, CallbackBase::Error)>&&);
     void setCompositionAsync(const String& text, const Vector<WebCore::CompositionUnderline>&, const Vector<WebCore::CompositionHighlight>&, const EditingRange& selectionRange, const EditingRange& replacementRange);
@@ -2106,7 +2105,6 @@
     void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, CallbackID);
     void validateCommandCallback(const String&, bool, int, CallbackID);
     void unsignedCallback(uint64_t, CallbackID);
-    void editingRangeCallback(const EditingRange&, CallbackID);
 #if ENABLE(APPLICATION_MANIFEST)
     void applicationManifestCallback(const Optional<WebCore::ApplicationManifest>&, CallbackID);
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (264046 => 264047)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2020-07-07 23:30:49 UTC (rev 264047)
@@ -165,7 +165,6 @@
     ScriptValueCallback(IPC::DataReference resultData, Optional<WebCore::ExceptionDetails> details, WebKit::CallbackID callbackID)
     ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin, WebKit::CallbackID callbackID)
     ValidateCommandCallback(String command, bool isEnabled, int32_t state, WebKit::CallbackID callbackID)
-    EditingRangeCallback(struct WebKit::EditingRange range, WebKit::CallbackID callbackID)
     UnsignedCallback(uint64_t result, WebKit::CallbackID callbackID)
     RectForCharacterRangeCallback(WebCore::IntRect rect, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
 #if ENABLE(APPLICATION_MANIFEST)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (264046 => 264047)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-07-07 23:30:49 UTC (rev 264047)
@@ -5418,18 +5418,18 @@
     completionHandler(m_page->focusController().focusedOrMainFrame().editor().hasComposition());
 }
 
-void WebPage::getMarkedRangeAsync(CallbackID callbackID)
+void WebPage::getMarkedRangeAsync(CompletionHandler<void(const EditingRange&)>&& completionHandler)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     auto editingRange = EditingRange::fromRange(frame, frame.editor().compositionRange().get());
-    send(Messages::WebPageProxy::EditingRangeCallback(editingRange, callbackID));
+    completionHandler(editingRange);
 }
 
-void WebPage::getSelectedRangeAsync(CallbackID callbackID)
+void WebPage::getSelectedRangeAsync(CompletionHandler<void(const EditingRange&)>&& completionHandler)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
     auto editingRange = EditingRange::fromRange(frame, createLiveRange(frame.selection().selection().toNormalizedRange()).get());
-    send(Messages::WebPageProxy::EditingRangeCallback(editingRange, callbackID));
+    completionHandler(editingRange);
 }
 
 void WebPage::characterIndexForPointAsync(const WebCore::IntPoint& point, CallbackID callbackID)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (264046 => 264047)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-07-07 23:30:49 UTC (rev 264047)
@@ -851,8 +851,8 @@
     void setTextAsync(const String&);
     void insertTextAsync(const String& text, const EditingRange& replacementRange, InsertTextOptions&&);
     void hasMarkedText(CompletionHandler<void(bool)>&&);
-    void getMarkedRangeAsync(CallbackID);
-    void getSelectedRangeAsync(CallbackID);
+    void getMarkedRangeAsync(CompletionHandler<void(const EditingRange&)>&&);
+    void getSelectedRangeAsync(CompletionHandler<void(const EditingRange&)>&&);
     void characterIndexForPointAsync(const WebCore::IntPoint&, CallbackID);
     void firstRectForCharacterRangeAsync(const EditingRange&, CallbackID);
     void setCompositionAsync(const String& text, const Vector<WebCore::CompositionUnderline>&, const Vector<WebCore::CompositionHighlight>&, const EditingRange& selectionRange, const EditingRange& replacementRange);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (264046 => 264047)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-07-07 23:00:25 UTC (rev 264046)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2020-07-07 23:30:49 UTC (rev 264047)
@@ -450,8 +450,8 @@
     InsertDictatedTextAsync(String text, struct WebKit::EditingRange replacementRange, Vector<WebCore::DictationAlternative> dictationAlternatives, struct WebKit::InsertTextOptions options)
 
     HasMarkedText() -> (bool hasMarkedText) Async
-    GetMarkedRangeAsync(WebKit::CallbackID callbackID)
-    GetSelectedRangeAsync(WebKit::CallbackID callbackID)
+    GetMarkedRangeAsync() -> (struct WebKit::EditingRange range) Async
+    GetSelectedRangeAsync() -> (struct WebKit::EditingRange range) Async
     CharacterIndexForPointAsync(WebCore::IntPoint point, WebKit::CallbackID callbackID);
     FirstRectForCharacterRangeAsync(struct WebKit::EditingRange range, WebKit::CallbackID callbackID);
     SetCompositionAsync(String text, Vector<WebCore::CompositionUnderline> underlines, Vector<WebCore::CompositionHighlight> highlights, struct WebKit::EditingRange selectionRange, struct WebKit::EditingRange replacementRange)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to