Diff
Modified: trunk/Source/WebKit/ChangeLog (272605 => 272606)
--- trunk/Source/WebKit/ChangeLog 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/ChangeLog 2021-02-09 21:18:43 UTC (rev 272606)
@@ -1,5 +1,27 @@
2021-02-09 Alex Christensen <[email protected]>
+ Use CompletionHandler instead of ComputedPagesCallback
+ https://bugs.webkit.org/show_bug.cgi?id=221619
+
+ Reviewed by Chris Dumez.
+
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageComputePagesForPrinting):
+ * UIProcess/GenericCallback.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::computePagesForPrinting):
+ (WebKit::WebPageProxy::computedPagesCallback): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/WKPrintingView.mm:
+ (-[WKPrintingView _askPageToComputePageRects]):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::computePagesForPrinting):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
+2021-02-09 Alex Christensen <[email protected]>
+
Use CompletionHandler instead of NowPlayingInfoCallback
https://bugs.webkit.org/show_bug.cgi?id=221617
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (272605 => 272606)
--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2021-02-09 21:18:43 UTC (rev 272606)
@@ -2643,12 +2643,12 @@
void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
{
- toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create([context, callback](const Vector<WebCore::IntRect>& rects, double scaleFactor, const WebCore::FloatBoxExtent& computedPageMargin, WebKit::CallbackBase::Error error) {
+ toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), [context, callback](const Vector<WebCore::IntRect>& rects, double scaleFactor, const WebCore::FloatBoxExtent& computedPageMargin) {
Vector<WKRect> wkRects(rects.size());
for (size_t i = 0; i < rects.size(); ++i)
wkRects[i] = toAPI(rects[i]);
- callback(wkRects.data(), wkRects.size(), scaleFactor, error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : 0, context);
- }));
+ callback(wkRects.data(), wkRects.size(), scaleFactor, nullptr, context);
+ });
}
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/UIProcess/GenericCallback.h (272605 => 272606)
--- trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-09 21:18:43 UTC (rev 272606)
@@ -155,7 +155,6 @@
}
typedef GenericCallback<> VoidCallback;
-typedef GenericCallback<const Vector<WebCore::IntRect>&, double, WebCore::FloatBoxExtent> ComputedPagesCallback;
typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback;
template<typename T>
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (272605 => 272606)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-09 21:18:43 UTC (rev 272606)
@@ -7161,17 +7161,6 @@
callback->invalidate();
}
-void WebPageProxy::computedPagesCallback(const Vector<IntRect>& pageRects, double totalScaleFactorForPrinting, const FloatBoxExtent& computedPageMargin, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<ComputedPagesCallback>(callbackID);
- if (!callback) {
- // FIXME: Log error or assert.
- return;
- }
-
- callback->performCallbackWithReturnValue(pageRects, totalScaleFactorForPrinting, computedPageMargin);
-}
-
void WebPageProxy::unsignedCallback(uint64_t result, CallbackID callbackID)
{
auto callback = m_callbacks.take<UnsignedCallback>(callbackID);
@@ -8545,17 +8534,10 @@
send(Messages::WebPage::EndPrinting(), printingSendOptions(m_isPerformingDOMPrintOperation));
}
-void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, Ref<ComputedPagesCallback>&& callback)
+uint64_t WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& callback)
{
- if (!hasRunningProcess()) {
- callback->invalidate();
- return;
- }
-
- auto callbackID = callback->callbackID();
- m_callbacks.put(WTFMove(callback));
m_isInPrintingMode = true;
- send(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo, callbackID), printingSendOptions(m_isPerformingDOMPrintOperation));
+ return sendWithAsyncReply(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo), WTFMove(callback), printingSendOptions(m_isPerformingDOMPrintOperation));
}
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (272605 => 272606)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-09 21:18:43 UTC (rev 272606)
@@ -1292,7 +1292,7 @@
void beginPrinting(WebFrameProxy*, const PrintInfo&);
void endPrinting();
- void computePagesForPrinting(WebFrameProxy*, const PrintInfo&, Ref<ComputedPagesCallback>&&);
+ uint64_t computePagesForPrinting(WebFrameProxy*, const PrintInfo&, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&&);
#if PLATFORM(COCOA)
void drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, Ref<ImageCallback>&&);
void drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, Ref<DataCallback>&&);
@@ -2158,7 +2158,6 @@
void imageCallback(const ShareableBitmap::Handle&, CallbackID);
void stringCallback(const String&, CallbackID);
void invalidateStringCallback(CallbackID);
- void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, CallbackID);
void unsignedCallback(uint64_t, CallbackID);
#if ENABLE(APPLICATION_MANIFEST)
void applicationManifestCallback(const Optional<WebCore::ApplicationManifest>&, CallbackID);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (272605 => 272606)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-09 21:18:43 UTC (rev 272606)
@@ -168,7 +168,6 @@
ImageCallback(WebKit::ShareableBitmap::Handle bitmapHandle, WebKit::CallbackID callbackID)
StringCallback(String resultString, WebKit::CallbackID callbackID)
InvalidateStringCallback(WebKit::CallbackID callbackID)
- ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin, WebKit::CallbackID callbackID)
UnsignedCallback(uint64_t result, WebKit::CallbackID callbackID)
#if ENABLE(APPLICATION_MANIFEST)
ApplicationManifestCallback(Optional<WebCore::ApplicationManifest> manifest, WebKit::CallbackID callbackID)
Modified: trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm (272605 => 272606)
--- trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm 2021-02-09 21:18:43 UTC (rev 272606)
@@ -361,15 +361,14 @@
ASSERT(!_expectedComputedPagesCallback);
IPCCallbackContext* context = new IPCCallbackContext;
- auto callback = WebKit::ComputedPagesCallback::create([context](const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, WebKit::CallbackBase::Error) {
+ auto callback = [context](const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin) {
std::unique_ptr<IPCCallbackContext> contextDeleter(context);
pageDidComputePageRects(pageRects, totalScaleFactorForPrinting, computedPageMargin, context);
- });
- _expectedComputedPagesCallback = callback->callbackID().toInteger();
+ };
+ _expectedComputedPagesCallback = _webFrame->page()->computePagesForPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), WTFMove(callback));
context->view = self;
context->callbackID = _expectedComputedPagesCallback;
- _webFrame->page()->computePagesForPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), WTFMove(callback));
return YES;
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (272605 => 272606)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-09 21:18:43 UTC (rev 272606)
@@ -5068,13 +5068,13 @@
}
}
-void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CallbackID callbackID)
+void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& completionHandler)
{
Vector<IntRect> resultPageRects;
double resultTotalScaleFactorForPrinting = 1;
auto computedPageMargin = printInfo.margin;
computePagesForPrintingImpl(frameID, printInfo, resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin);
- send(Messages::WebPageProxy::ComputedPagesCallback(resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin, callbackID));
+ completionHandler(resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin);
}
void WebPage::computePagesForPrintingImpl(FrameIdentifier frameID, const PrintInfo& printInfo, Vector<WebCore::IntRect>& resultPageRects, double& resultTotalScaleFactorForPrinting, FloatBoxExtent& computedPageMargin)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (272605 => 272606)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-09 21:18:43 UTC (rev 272606)
@@ -961,7 +961,7 @@
void beginPrinting(WebCore::FrameIdentifier, const PrintInfo&);
void endPrinting();
- void computePagesForPrinting(WebCore::FrameIdentifier, const PrintInfo&, CallbackID);
+ void computePagesForPrinting(WebCore::FrameIdentifier, const PrintInfo&, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&&);
void computePagesForPrintingImpl(WebCore::FrameIdentifier, const PrintInfo&, Vector<WebCore::IntRect>& pageRects, double& totalScaleFactor, WebCore::FloatBoxExtent& computedMargin);
#if PLATFORM(COCOA)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (272605 => 272606)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-02-09 21:17:47 UTC (rev 272605)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-02-09 21:18:43 UTC (rev 272606)
@@ -397,7 +397,7 @@
# Printing.
BeginPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo)
EndPrinting()
- ComputePagesForPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebKit::CallbackID callbackID)
+ ComputePagesForPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin) Async
#if PLATFORM(COCOA)
DrawRectToImage(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebCore::IntRect rect, WebCore::IntSize imageSize, WebKit::CallbackID callbackID)
DrawPagesToPDF(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, WebKit::CallbackID callbackID)