Diff
Modified: trunk/Source/WebKit/ChangeLog (271186 => 271187)
--- trunk/Source/WebKit/ChangeLog 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/ChangeLog 2021-01-06 03:03:44 UTC (rev 271187)
@@ -1,3 +1,26 @@
+2021-01-05 Alex Christensen <[email protected]>
+
+ Use sendWithAsyncReply instead of AttributedStringForCharacterRangeCallback and FontAtSelectionCallback
+ https://bugs.webkit.org/show_bug.cgi?id=220344
+
+ Reviewed by Geoffrey Garen.
+
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::updateFontManagerIfNeeded):
+ (WebKit::WebViewImpl::attributedSubstringForProposedRange):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync):
+ (WebKit::WebPageProxy::fontAtSelection):
+ (WebKit::WebPageProxy::attributedStringForCharacterRangeCallback): Deleted.
+ (WebKit::WebPageProxy::fontAtSelectionCallback): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::attributedSubstringForCharacterRangeAsync):
+ (WebKit::WebPage::fontAtSelection):
+
2021-01-05 John Wilander <[email protected]>
PCM: Experimental debug mode stops working after initial use
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (271186 => 271187)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-06 03:03:44 UTC (rev 271187)
@@ -2951,9 +2951,7 @@
if (!fontPanelIsVisible && !m_page->editorState().isContentRichlyEditable)
return;
- m_page->fontAtSelection([](const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts, CallbackBase::Error error) {
- if (error != CallbackBase::Error::None)
- return;
+ m_page->fontAtSelection([](const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts) {
BEGIN_BLOCK_OBJC_EXCEPTIONS
@@ -5025,20 +5023,12 @@
});
}
-void WebViewImpl::attributedSubstringForProposedRange(NSRange proposedRange, void(^completionHandlerPtr)(NSAttributedString *attrString, NSRange actualRange))
+void WebViewImpl::attributedSubstringForProposedRange(NSRange proposedRange, void(^completionHandler)(NSAttributedString *attrString, NSRange actualRange))
{
- auto completionHandler = adoptNS([completionHandlerPtr copy]);
-
LOG(TextInput, "attributedSubstringFromRange:(%u, %u)", proposedRange.location, proposedRange.length);
- m_page->attributedSubstringForCharacterRangeAsync(proposedRange, [completionHandler](const WebCore::AttributedString& string, const EditingRange& actualRange, WebKit::CallbackBase::Error error) {
- void (^completionHandlerBlock)(NSAttributedString *, NSRange) = (void (^)(NSAttributedString *, NSRange))completionHandler.get();
- if (error != WebKit::CallbackBase::Error::None) {
- LOG(TextInput, " ...attributedSubstringFromRange failed.");
- completionHandlerBlock(0, NSMakeRange(NSNotFound, 0));
- return;
- }
+ m_page->attributedSubstringForCharacterRangeAsync(proposedRange, [completionHandler = makeBlockPtr(completionHandler)](const WebCore::AttributedString& string, const EditingRange& actualRange) {
LOG(TextInput, " -> attributedSubstringFromRange returned %@", string.string.get());
- completionHandlerBlock(string.string.get(), actualRange);
+ completionHandler(string.string.get(), actualRange);
});
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (271186 => 271187)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-06 03:03:44 UTC (rev 271187)
@@ -399,11 +399,6 @@
typedef GenericCallback<const Optional<WebCore::ApplicationManifest>&> ApplicationManifestCallback;
#endif
-#if PLATFORM(MAC)
-typedef GenericCallback<const WebCore::AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
-typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback;
-#endif
-
#if PLATFORM(IOS_FAMILY)
typedef GenericCallback<const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>> GestureCallback;
typedef GenericCallback<const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>> TouchesCallback;
@@ -905,8 +900,8 @@
void changeFont(WebCore::FontChanges&&);
#if PLATFORM(MAC)
- void attributedSubstringForCharacterRangeAsync(const EditingRange&, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
- void fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&&);
+ void attributedSubstringForCharacterRangeAsync(const EditingRange&, CompletionHandler<void(const WebCore::AttributedString&, const EditingRange&)>&&);
+ void fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&&);
void startWindowDrag();
NSWindow *platformWindow();
@@ -2158,7 +2153,6 @@
void applicationManifestCallback(const Optional<WebCore::ApplicationManifest>&, CallbackID);
#endif
#if PLATFORM(MAC)
- void attributedStringForCharacterRangeCallback(const WebCore::AttributedString&, const EditingRange&, CallbackID);
void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
#endif
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (271186 => 271187)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-06 03:03:44 UTC (rev 271187)
@@ -173,10 +173,6 @@
#if ENABLE(APPLICATION_MANIFEST)
ApplicationManifestCallback(Optional<WebCore::ApplicationManifest> manifest, WebKit::CallbackID callbackID)
#endif
-#if PLATFORM(MAC)
- AttributedStringForCharacterRangeCallback(struct WebCore::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
- FontAtSelectionCallback(struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts, WebKit::CallbackID callbackID)
-#endif
#if PLATFORM(IOS_FAMILY)
GestureCallback(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
TouchesCallback(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (271186 => 271187)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2021-01-06 03:03:44 UTC (rev 271187)
@@ -192,54 +192,26 @@
send(Messages::WebPage::SetMainFrameIsScrollable(isScrollable));
}
-void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, Function<void(const WebCore::AttributedString&, const EditingRange&, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::attributedSubstringForCharacterRangeAsync(const EditingRange& range, CompletionHandler<void(const WebCore::AttributedString&, const EditingRange&)>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction({ }, EditingRange(), CallbackBase::Error::Unknown);
+ callbackFunction({ }, { });
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::attributedSubstringForCharacterRangeAsync"_s));
-
- send(Messages::WebPage::AttributedSubstringForCharacterRangeAsync(range, callbackID));
+ sendWithAsyncReply(Messages::WebPage::AttributedSubstringForCharacterRangeAsync(range), WTFMove(callbackFunction));
}
-void WebPageProxy::attributedStringForCharacterRangeCallback(const WebCore::AttributedString& string, const EditingRange& actualRange, CallbackID callbackID)
+void WebPageProxy::fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&& callback)
{
- MESSAGE_CHECK(actualRange.isValid());
-
- auto callback = m_callbacks.take<AttributedStringForCharacterRangeCallback>(callbackID);
- if (!callback) {
- // FIXME: Log error or assert.
- // this can validly happen if a load invalidated the callback, though
- return;
- }
-
- callback->performCallbackWithReturnValue(string, actualRange);
-}
-
-void WebPageProxy::fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&& callback)
-{
if (!hasRunningProcess()) {
- callback({ }, 0, false, CallbackBase::Error::Unknown);
+ callback({ }, 0, false);
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::fontAtSelection"_s));
- send(Messages::WebPage::FontAtSelection(callbackID));
+ sendWithAsyncReply(Messages::WebPage::FontAtSelection(), WTFMove(callback));
}
-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: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (271186 => 271187)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-01-06 03:03:44 UTC (rev 271187)
@@ -903,8 +903,8 @@
#endif
#if PLATFORM(MAC)
- void attributedSubstringForCharacterRangeAsync(const EditingRange&, CallbackID);
- void fontAtSelection(CallbackID);
+ void attributedSubstringForCharacterRangeAsync(const EditingRange&, CompletionHandler<void(const WebCore::AttributedString&, const EditingRange&)>&&);
+ void fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&&);
#endif
#if PLATFORM(COCOA) && ENABLE(SERVICE_CONTROLS)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (271186 => 271187)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-01-06 03:03:44 UTC (rev 271187)
@@ -457,8 +457,8 @@
ConfirmCompositionAsync()
#endif
#if PLATFORM(MAC)
- AttributedSubstringForCharacterRangeAsync(struct WebKit::EditingRange range, WebKit::CallbackID callbackID);
- FontAtSelection(WebKit::CallbackID callbackID)
+ AttributedSubstringForCharacterRangeAsync(struct WebKit::EditingRange range) -> (struct WebCore::AttributedString string, struct WebKit::EditingRange range) Async
+ FontAtSelection() -> (struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts) Async
#endif
SetAlwaysShowsHorizontalScroller(bool alwaysShowsHorizontalScroller)
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (271186 => 271187)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-01-06 03:03:43 UTC (rev 271186)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-01-06 03:03:44 UTC (rev 271187)
@@ -329,19 +329,19 @@
}
}
-void WebPage::attributedSubstringForCharacterRangeAsync(const EditingRange& editingRange, CallbackID callbackID)
+void WebPage::attributedSubstringForCharacterRangeAsync(const EditingRange& editingRange, CompletionHandler<void(const WebCore::AttributedString&, const EditingRange&)>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
const VisibleSelection& selection = frame.selection().selection();
if (selection.isNone() || !selection.isContentEditable() || selection.isInPasswordField()) {
- send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ }, EditingRange(), callbackID));
+ completionHandler({ }, { });
return;
}
auto range = EditingRange::toRange(frame, editingRange);
if (!range) {
- send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ }, EditingRange(), callbackID));
+ completionHandler({ }, { });
return;
}
@@ -360,42 +360,42 @@
ASSERT(rangeToSend.isValid());
if (!rangeToSend.isValid()) {
// Send an empty EditingRange as a last resort for <rdar://problem/27078089>.
- send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ WTFMove(attributedString), nil }, EditingRange(), callbackID));
+ completionHandler({ WTFMove(attributedString), nil }, EditingRange());
return;
}
- send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback({ WTFMove(attributedString), nil }, rangeToSend, callbackID));
+ completionHandler({ WTFMove(attributedString), nil }, rangeToSend);
}
-void WebPage::fontAtSelection(CallbackID callbackID)
+void WebPage::fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&& completionHandler)
{
bool selectionHasMultipleFonts = false;
auto& frame = m_page->focusController().focusedOrMainFrame();
if (frame.selection().selection().isNone()) {
- send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
+ completionHandler({ }, 0, false);
return;
}
auto* font = frame.editor().fontForSelection(selectionHasMultipleFonts);
if (!font) {
- send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
+ completionHandler({ }, 0, false);
return;
}
auto ctFont = font->getCTFont();
if (!ctFont) {
- send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
+ completionHandler({ }, 0, false);
return;
}
auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(ctFont));
if (!fontDescriptor) {
- send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
+ completionHandler({ }, 0, false);
return;
}
- send(Messages::WebPageProxy::FontAtSelectionCallback({ adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get())) }, CTFontGetSize(ctFont), selectionHasMultipleFonts, callbackID));
+ completionHandler({ adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get())) }, CTFontGetSize(ctFont), selectionHasMultipleFonts);
}