Changeset 272606 in webkit
- Timestamp:
- Feb 9, 2021, 1:18:43 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r272605 r272606 1 2021-02-09 Alex Christensen <achristensen@webkit.org> 2 3 Use CompletionHandler instead of ComputedPagesCallback 4 https://bugs.webkit.org/show_bug.cgi?id=221619 5 6 Reviewed by Chris Dumez. 7 8 * UIProcess/API/C/WKPage.cpp: 9 (WKPageComputePagesForPrinting): 10 * UIProcess/GenericCallback.h: 11 * UIProcess/WebPageProxy.cpp: 12 (WebKit::WebPageProxy::computePagesForPrinting): 13 (WebKit::WebPageProxy::computedPagesCallback): Deleted. 14 * UIProcess/WebPageProxy.h: 15 * UIProcess/WebPageProxy.messages.in: 16 * UIProcess/mac/WKPrintingView.mm: 17 (-[WKPrintingView _askPageToComputePageRects]): 18 * WebProcess/WebPage/WebPage.cpp: 19 (WebKit::WebPage::computePagesForPrinting): 20 * WebProcess/WebPage/WebPage.h: 21 * WebProcess/WebPage/WebPage.messages.in: 22 1 23 2021-02-09 Alex Christensen <achristensen@webkit.org> 2 24 -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r272573 r272606 2644 2644 void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context) 2645 2645 { 2646 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) {2646 toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), [context, callback](const Vector<WebCore::IntRect>& rects, double scaleFactor, const WebCore::FloatBoxExtent& computedPageMargin) { 2647 2647 Vector<WKRect> wkRects(rects.size()); 2648 2648 for (size_t i = 0; i < rects.size(); ++i) 2649 2649 wkRects[i] = toAPI(rects[i]); 2650 callback(wkRects.data(), wkRects.size(), scaleFactor, error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : 0, context);2651 }) );2650 callback(wkRects.data(), wkRects.size(), scaleFactor, nullptr, context); 2651 }); 2652 2652 } 2653 2653 -
trunk/Source/WebKit/UIProcess/GenericCallback.h
r272558 r272606 156 156 157 157 typedef GenericCallback<> VoidCallback; 158 typedef GenericCallback<const Vector<WebCore::IntRect>&, double, WebCore::FloatBoxExtent> ComputedPagesCallback;159 158 typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback; 160 159 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r272605 r272606 7162 7162 } 7163 7163 7164 void WebPageProxy::computedPagesCallback(const Vector<IntRect>& pageRects, double totalScaleFactorForPrinting, const FloatBoxExtent& computedPageMargin, CallbackID callbackID)7165 {7166 auto callback = m_callbacks.take<ComputedPagesCallback>(callbackID);7167 if (!callback) {7168 // FIXME: Log error or assert.7169 return;7170 }7171 7172 callback->performCallbackWithReturnValue(pageRects, totalScaleFactorForPrinting, computedPageMargin);7173 }7174 7175 7164 void WebPageProxy::unsignedCallback(uint64_t result, CallbackID callbackID) 7176 7165 { … … 8546 8535 } 8547 8536 8548 void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, Ref<ComputedPagesCallback>&& callback) 8549 { 8550 if (!hasRunningProcess()) { 8551 callback->invalidate(); 8552 return; 8553 } 8554 8555 auto callbackID = callback->callbackID(); 8556 m_callbacks.put(WTFMove(callback)); 8537 uint64_t WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& callback) 8538 { 8557 8539 m_isInPrintingMode = true; 8558 send(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo, callbackID), printingSendOptions(m_isPerformingDOMPrintOperation));8540 return sendWithAsyncReply(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo), WTFMove(callback), printingSendOptions(m_isPerformingDOMPrintOperation)); 8559 8541 } 8560 8542 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r272605 r272606 1293 1293 void beginPrinting(WebFrameProxy*, const PrintInfo&); 1294 1294 void endPrinting(); 1295 void computePagesForPrinting(WebFrameProxy*, const PrintInfo&, Ref<ComputedPagesCallback>&&);1295 uint64_t computePagesForPrinting(WebFrameProxy*, const PrintInfo&, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&&); 1296 1296 #if PLATFORM(COCOA) 1297 1297 void drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, Ref<ImageCallback>&&); … … 2159 2159 void stringCallback(const String&, CallbackID); 2160 2160 void invalidateStringCallback(CallbackID); 2161 void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, CallbackID);2162 2161 void unsignedCallback(uint64_t, CallbackID); 2163 2162 #if ENABLE(APPLICATION_MANIFEST) -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r272605 r272606 169 169 StringCallback(String resultString, WebKit::CallbackID callbackID) 170 170 InvalidateStringCallback(WebKit::CallbackID callbackID) 171 ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin, WebKit::CallbackID callbackID)172 171 UnsignedCallback(uint64_t result, WebKit::CallbackID callbackID) 173 172 #if ENABLE(APPLICATION_MANIFEST) -
trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm
r271384 r272606 362 362 363 363 IPCCallbackContext* context = new IPCCallbackContext; 364 auto callback = WebKit::ComputedPagesCallback::create([context](const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, WebKit::CallbackBase::Error) {364 auto callback = [context](const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin) { 365 365 std::unique_ptr<IPCCallbackContext> contextDeleter(context); 366 366 pageDidComputePageRects(pageRects, totalScaleFactorForPrinting, computedPageMargin, context); 367 } );368 _expectedComputedPagesCallback = callback->callbackID().toInteger();367 }; 368 _expectedComputedPagesCallback = _webFrame->page()->computePagesForPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), WTFMove(callback)); 369 369 context->view = self; 370 370 context->callbackID = _expectedComputedPagesCallback; 371 371 372 _webFrame->page()->computePagesForPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), WTFMove(callback));373 372 return YES; 374 373 } -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r272592 r272606 5069 5069 } 5070 5070 5071 void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, C allbackID callbackID)5071 void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& completionHandler) 5072 5072 { 5073 5073 Vector<IntRect> resultPageRects; … … 5075 5075 auto computedPageMargin = printInfo.margin; 5076 5076 computePagesForPrintingImpl(frameID, printInfo, resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin); 5077 send(Messages::WebPageProxy::ComputedPagesCallback(resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin, callbackID));5077 completionHandler(resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin); 5078 5078 } 5079 5079 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r272605 r272606 962 962 void beginPrinting(WebCore::FrameIdentifier, const PrintInfo&); 963 963 void endPrinting(); 964 void computePagesForPrinting(WebCore::FrameIdentifier, const PrintInfo&, C allbackID);964 void computePagesForPrinting(WebCore::FrameIdentifier, const PrintInfo&, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&&); 965 965 void computePagesForPrintingImpl(WebCore::FrameIdentifier, const PrintInfo&, Vector<WebCore::IntRect>& pageRects, double& totalScaleFactor, WebCore::FloatBoxExtent& computedMargin); 966 966 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r272605 r272606 398 398 BeginPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) 399 399 EndPrinting() 400 ComputePagesForPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo , WebKit::CallbackID callbackID)400 ComputePagesForPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin) Async 401 401 #if PLATFORM(COCOA) 402 402 DrawRectToImage(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebCore::IntRect rect, WebCore::IntSize imageSize, WebKit::CallbackID callbackID)
Note:
See TracChangeset
for help on using the changeset viewer.