Changeset 272606 in webkit


Ignore:
Timestamp:
Feb 9, 2021 1:18:43 PM (3 years ago)
Author:
achristensen@apple.com
Message:

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:
Location:
trunk/Source/WebKit
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r272605 r272606  
     12021-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
    1232021-02-09  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r272573 r272606  
    26442644void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
    26452645{
    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) {
    26472647        Vector<WKRect> wkRects(rects.size());
    26482648        for (size_t i = 0; i < rects.size(); ++i)
    26492649            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    });
    26522652}
    26532653
  • trunk/Source/WebKit/UIProcess/GenericCallback.h

    r272558 r272606  
    156156
    157157typedef GenericCallback<> VoidCallback;
    158 typedef GenericCallback<const Vector<WebCore::IntRect>&, double, WebCore::FloatBoxExtent> ComputedPagesCallback;
    159158typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback;
    160159
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r272605 r272606  
    71627162}
    71637163
    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 
    71757164void WebPageProxy::unsignedCallback(uint64_t result, CallbackID callbackID)
    71767165{
     
    85468535}
    85478536
    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));
     8537uint64_t WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& callback)
     8538{
    85578539    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));
    85598541}
    85608542
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r272605 r272606  
    12931293    void beginPrinting(WebFrameProxy*, const PrintInfo&);
    12941294    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&)>&&);
    12961296#if PLATFORM(COCOA)
    12971297    void drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, Ref<ImageCallback>&&);
     
    21592159    void stringCallback(const String&, CallbackID);
    21602160    void invalidateStringCallback(CallbackID);
    2161     void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, CallbackID);
    21622161    void unsignedCallback(uint64_t, CallbackID);
    21632162#if ENABLE(APPLICATION_MANIFEST)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r272605 r272606  
    169169    StringCallback(String resultString, WebKit::CallbackID callbackID)
    170170    InvalidateStringCallback(WebKit::CallbackID callbackID)
    171     ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin, WebKit::CallbackID callbackID)
    172171    UnsignedCallback(uint64_t result, WebKit::CallbackID callbackID)
    173172#if ENABLE(APPLICATION_MANIFEST)
  • trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm

    r271384 r272606  
    362362
    363363    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) {
    365365        std::unique_ptr<IPCCallbackContext> contextDeleter(context);
    366366        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));
    369369    context->view = self;
    370370    context->callbackID = _expectedComputedPagesCallback;
    371371
    372     _webFrame->page()->computePagesForPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), WTFMove(callback));
    373372    return YES;
    374373}
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r272592 r272606  
    50695069}
    50705070
    5071 void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CallbackID callbackID)
     5071void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& completionHandler)
    50725072{
    50735073    Vector<IntRect> resultPageRects;
     
    50755075    auto computedPageMargin = printInfo.margin;
    50765076    computePagesForPrintingImpl(frameID, printInfo, resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin);
    5077     send(Messages::WebPageProxy::ComputedPagesCallback(resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin, callbackID));
     5077    completionHandler(resultPageRects, resultTotalScaleFactorForPrinting, computedPageMargin);
    50785078}
    50795079
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r272605 r272606  
    962962    void beginPrinting(WebCore::FrameIdentifier, const PrintInfo&);
    963963    void endPrinting();
    964     void computePagesForPrinting(WebCore::FrameIdentifier, const PrintInfo&, CallbackID);
     964    void computePagesForPrinting(WebCore::FrameIdentifier, const PrintInfo&, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&&);
    965965    void computePagesForPrintingImpl(WebCore::FrameIdentifier, const PrintInfo&, Vector<WebCore::IntRect>& pageRects, double& totalScaleFactor, WebCore::FloatBoxExtent& computedMargin);
    966966
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r272605 r272606  
    398398    BeginPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo)
    399399    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
    401401#if PLATFORM(COCOA)
    402402    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.