Title: [247583] branches/safari-608-branch/Source/WebKit
Revision
247583
Author
kocsen_ch...@apple.com
Date
2019-07-18 13:23:18 -0700 (Thu, 18 Jul 2019)

Log Message

Cherry-pick r247460. rdar://problem/53229628

    Followup to r247439
    https://bugs.webkit.org/show_bug.cgi?id=199788
    <rdar://problem/52142570>

    Reviewed by Tim Horton.

    As it turns out, sending modern async completion-handler based IPC messages while processing incoming sync
    messages results in a debug assertion. Instead of migrating FontAtSelection to the new async IPC mechanism,
    restore the older CallbackID-based async IPC.

    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    * UIProcess/mac/WebPageProxyMac.mm:
    (WebKit::WebPageProxy::fontAtSelection):
    (WebKit::WebPageProxy::fontAtSelectionCallback):
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/WebPage.messages.in:
    * WebProcess/WebPage/mac/WebPageMac.mm:
    (WebKit::WebPage::fontAtSelection):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247460 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-18 20:23:18 UTC (rev 247583)
@@ -1,5 +1,53 @@
 2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
 
+        Cherry-pick r247460. rdar://problem/53229628
+
+    Followup to r247439
+    https://bugs.webkit.org/show_bug.cgi?id=199788
+    <rdar://problem/52142570>
+    
+    Reviewed by Tim Horton.
+    
+    As it turns out, sending modern async completion-handler based IPC messages while processing incoming sync
+    messages results in a debug assertion. Instead of migrating FontAtSelection to the new async IPC mechanism,
+    restore the older CallbackID-based async IPC.
+    
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * UIProcess/mac/WebPageProxyMac.mm:
+    (WebKit::WebPageProxy::fontAtSelection):
+    (WebKit::WebPageProxy::fontAtSelectionCallback):
+    * WebProcess/WebPage/WebPage.h:
+    * WebProcess/WebPage/WebPage.messages.in:
+    * WebProcess/WebPage/mac/WebPageMac.mm:
+    (WebKit::WebPage::fontAtSelection):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247460 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-15  Wenson Hsieh  <wenson_hs...@apple.com>
+
+            Followup to r247439
+            https://bugs.webkit.org/show_bug.cgi?id=199788
+            <rdar://problem/52142570>
+
+            Reviewed by Tim Horton.
+
+            As it turns out, sending modern async completion-handler based IPC messages while processing incoming sync
+            messages results in a debug assertion. Instead of migrating FontAtSelection to the new async IPC mechanism,
+            restore the older CallbackID-based async IPC.
+
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * UIProcess/mac/WebPageProxyMac.mm:
+            (WebKit::WebPageProxy::fontAtSelection):
+            (WebKit::WebPageProxy::fontAtSelectionCallback):
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::fontAtSelection):
+
+2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
+
         Cherry-pick r247439. rdar://problem/53229628
 
     [macOS 10.15] Cannot unbold selected text when the system font is used

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-07-18 20:23:18 UTC (rev 247583)
@@ -2810,7 +2810,10 @@
     if (!fontPanelIsVisible && !m_page->editorState().isContentRichlyEditable)
         return;
 
-    m_page->fontAtSelection([](const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts) {
+    m_page->fontAtSelection([](const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts, CallbackBase::Error error) {
+        if (error != CallbackBase::Error::None)
+            return;
+
         NSDictionary *attributeDictionary = (__bridge NSDictionary *)fontInfo.fontAttributeDictionary.get();
         if (!attributeDictionary)
             return;

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h	2019-07-18 20:23:18 UTC (rev 247583)
@@ -338,6 +338,7 @@
 
 #if PLATFORM(MAC)
 typedef GenericCallback<const AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
+typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
@@ -788,7 +789,7 @@
 #if PLATFORM(MAC)
     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives, bool registerUndoGroup);
     void attributedSubstringForCharacterRangeAsync(const EditingRange&, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
-    void fontAtSelection(Function<void(const FontInfo&, double, bool)>&&);
+    void fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&&);
 
     void startWindowDrag();
     NSWindow *platformWindow();
@@ -1869,6 +1870,7 @@
     void rectForCharacterRangeCallback(const WebCore::IntRect&, const EditingRange&, CallbackID);
 #if PLATFORM(MAC)
     void attributedStringForCharacterRangeCallback(const AttributedString&, const EditingRange&, CallbackID);
+    void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
 #endif
 #if PLATFORM(IOS_FAMILY)
     void gestureCallback(const WebCore::IntPoint&, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID);

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-07-18 20:23:18 UTC (rev 247583)
@@ -180,6 +180,7 @@
 #endif
 #if PLATFORM(MAC)
     AttributedStringForCharacterRangeCallback(struct WebKit::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
+    FontAtSelectionCallback(struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts, WebKit::CallbackID callbackID)
 #endif
     FontAttributesCallback(struct WebCore::FontAttributes attributes, WebKit::CallbackID callbackID)
 #if PLATFORM(IOS_FAMILY)

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2019-07-18 20:23:18 UTC (rev 247583)
@@ -241,15 +241,28 @@
     callback->performCallbackWithReturnValue(string, actualRange);
 }
 
-void WebPageProxy::fontAtSelection(Function<void(const FontInfo&, double, bool)>&& callback)
+void WebPageProxy::fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&& callback)
 {
     if (!hasRunningProcess()) {
-        callback({ }, 0, false);
+        callback({ }, 0, false, CallbackBase::Error::Unknown);
         return;
     }
-    m_process->connection()->sendWithAsyncReply(Messages::WebPage::FontAtSelection(), WTFMove(callback), m_pageID);
+
+    auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken());
+    process().send(Messages::WebPage::FontAtSelection(callbackID), m_pageID);
 }
 
+void WebPageProxy::fontAtSelectionCallback(const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts, CallbackID callbackID)
+{
+    auto callback = m_callbacks.take<FontAtSelectionCallback>(callbackID);
+    if (!callback) {
+        // FIXME: Log error or assert.
+        return;
+    }
+
+    callback->performCallbackWithReturnValue(fontInfo, fontSize, selectionHasMultipleFonts);
+}
+
 String WebPageProxy::stringSelectionForPasteboard()
 {
     String value;

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-18 20:23:18 UTC (rev 247583)
@@ -811,7 +811,7 @@
 #if PLATFORM(MAC)
     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool registerUndoGroup = false);
     void attributedSubstringForCharacterRangeAsync(const EditingRange&, CallbackID);
-    void fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&&);
+    void fontAtSelection(CallbackID);
 #endif
 
 #if PLATFORM(COCOA) && ENABLE(SERVICE_CONTROLS)

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-07-18 20:23:18 UTC (rev 247583)
@@ -445,7 +445,7 @@
 #if PLATFORM(MAC)
     InsertDictatedTextAsync(String text, struct WebKit::EditingRange replacementRange, Vector<WebCore::DictationAlternative> dictationAlternatives, bool registerUndoGroup)
     AttributedSubstringForCharacterRangeAsync(struct WebKit::EditingRange range, WebKit::CallbackID callbackID);
-    FontAtSelection() -> (struct WebKit::FontInfo info, double fontSize, bool hasMultipleFonts) Async
+    FontAtSelection(WebKit::CallbackID callbackID)
 #endif
 
     SetAlwaysShowsHorizontalScroller(bool alwaysShowsHorizontalScroller)

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (247582 => 247583)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2019-07-18 20:23:15 UTC (rev 247582)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2019-07-18 20:23:18 UTC (rev 247583)
@@ -377,35 +377,35 @@
     send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback(attributedString, rangeToSend, callbackID));
 }
 
-void WebPage::fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&& reply)
+void WebPage::fontAtSelection(CallbackID callbackID)
 {
     bool selectionHasMultipleFonts = false;
     auto& frame = m_page->focusController().focusedOrMainFrame();
 
     if (frame.selection().selection().isNone()) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
     auto* font = frame.editor().fontForSelection(selectionHasMultipleFonts);
     if (!font) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
     auto ctFont = font->getCTFont();
     if (!ctFont) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
     auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(ctFont));
     if (!fontDescriptor) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
-    reply({ adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get())) }, CTFontGetSize(ctFont), selectionHasMultipleFonts);
+    send(Messages::WebPageProxy::FontAtSelectionCallback({ adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get())) }, CTFontGetSize(ctFont), selectionHasMultipleFonts, callbackID));
 }
     
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to