⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 282496 in webkit


Ignore:
Timestamp:
Sep 16, 2021, 1:00:07 AM (5 years ago)
Author:
Adrian Perez de Castro
Message:

Merge r275549 - Delay the end of printing while PrintContext is in use.
​https://bugs.webkit.org/show_bug.cgi?id=224229

Reviewed by Antti Koivisto.

Added a new RAII object, PrintContextAccessScope, to delay the call to endPrinting
and deployed in various IPC messages used during printing.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::beginPrinting): Deployed PrintContextAccessScope.
(WebKit::WebPage::endPrinting): Exit early without ending printing if there is an active
PrintContextAccessScope in the stack.
(WebKit::WebPage::endPrintingImmediately): Extracted from endPrintingImmediately.
(WebKit::WebPage::computePagesForPrinting): Deployed PrintContextAccessScope.
(WebKit::WebPage::computePagesForPrintingImpl): Ditto.
(WebKit::WebPage::drawRectToImage): Ditto.
(WebKit::WebPage::drawPagesToPDF): Ditto.

  • WebProcess/WebPage/WebPage.h:

(WebKit::WebPage::PrintContextAccessScope): Added.
(WebKit::WebPage::PrintContextAccessScope::PrintContextAccessScope): Added.
(WebKit::WebPage::PrintContextAccessScope::~PrintContextAccessScope): Added.

Location:
releases/WebKitGTK/webkit-2.32/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.32/Source/WebKit/ChangeLog

    r280839 r282496  
     12021-04-06  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Delay the end of printing while PrintContext is in use.
     4        https://bugs.webkit.org/show_bug.cgi?id=224229
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added a new RAII object, PrintContextAccessScope, to delay the call to endPrinting
     9        and deployed in various IPC messages used during printing.
     10
     11        * WebProcess/WebPage/WebPage.cpp:
     12        (WebKit::WebPage::beginPrinting): Deployed PrintContextAccessScope.
     13        (WebKit::WebPage::endPrinting): Exit early without ending printing if there is an active
     14        PrintContextAccessScope in the stack.
     15        (WebKit::WebPage::endPrintingImmediately): Extracted from endPrintingImmediately.
     16        (WebKit::WebPage::computePagesForPrinting): Deployed PrintContextAccessScope.
     17        (WebKit::WebPage::computePagesForPrintingImpl): Ditto.
     18        (WebKit::WebPage::drawRectToImage): Ditto.
     19        (WebKit::WebPage::drawPagesToPDF): Ditto.
     20        * WebProcess/WebPage/WebPage.h:
     21        (WebKit::WebPage::PrintContextAccessScope): Added.
     22        (WebKit::WebPage::PrintContextAccessScope::PrintContextAccessScope): Added.
     23        (WebKit::WebPage::PrintContextAccessScope::~PrintContextAccessScope): Added.
     24
    1252021-03-09  Chris Dumez  <cdumez@apple.com>
    226
  • releases/WebKitGTK/webkit-2.32/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r273452 r282496  
    51015101void WebPage::beginPrinting(FrameIdentifier frameID, const PrintInfo& printInfo)
    51025102{
     5103    PrintContextAccessScope scope { *this };
     5104
    51035105    WebFrame* frame = WebProcess::singleton().webFrame(frameID);
    51045106    if (!frame)
    … …  
    51225124
    51235125    auto computedPageSize = m_printContext->computedPageSize(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight), printInfo.margin);
     5126
    51245127    m_printContext->begin(computedPageSize.width(), computedPageSize.height());
    51255128
    … …  
    51435146void WebPage::endPrinting()
    51445147{
     5148    if (m_inActivePrintContextAccessScope) {
     5149        m_shouldEndPrintingImmediately = true;
     5150        return;
     5151    }
     5152    endPrintingImmediately();
     5153}
     5154
     5155void WebPage::endPrintingImmediately()
     5156{
     5157    RELEASE_ASSERT(!m_inActivePrintContextAccessScope);
     5158    m_shouldEndPrintingImmediately = false;
     5159
    51455160    unfreezeLayerTree(LayerTreeFreezeReason::Printing);
    51465161
    … …  
    51535168void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& completionHandler)
    51545169{
     5170    PrintContextAccessScope scope { *this };
    51555171    Vector<IntRect> resultPageRects;
    51565172    double resultTotalScaleFactorForPrinting = 1;
    … …  
    51675183
    51685184    if (m_printContext) {
     5185        PrintContextAccessScope scope { *this };
    51695186        resultPageRects = m_printContext->pageRects();
    51705187        computedPageMargin = m_printContext->computedPageMargin(printInfo.margin);
    … …  
    52135230void WebPage::drawRectToImage(FrameIdentifier frameID, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&& completionHandler)
    52145231{
     5232    PrintContextAccessScope scope { *this };
    52155233    WebFrame* frame = WebProcess::singleton().webFrame(frameID);
    52165234    Frame* coreFrame = frame ? frame->coreFrame() : 0;
    … …  
    52635281void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&& callback)
    52645282{
     5283    PrintContextAccessScope scope { *this };
    52655284    RetainPtr<CFMutableDataRef> pdfPageData;
    52665285    drawPagesToPDFImpl(frameID, printInfo, first, count, pdfPageData);
  • releases/WebKitGTK/webkit-2.32/Source/WebKit/WebProcess/WebPage/WebPage.h

    r280839 r282496  
    16411641#endif
    16421642
     1643    void endPrintingImmediately();
     1644
    16431645#if HAVE(APP_ACCENT_COLORS)
    16441646    void setAccentColor(WebCore::Color);
    … …  
    20112013
    20122014    std::unique_ptr<WebCore::PrintContext> m_printContext;
     2015    bool m_inActivePrintContextAccessScope { false };
     2016    bool m_shouldEndPrintingImmediately { false };
     2017
     2018    class PrintContextAccessScope {
     2019    public:
     2020        PrintContextAccessScope(WebPage& webPage)
     2021            : m_webPage { webPage }
     2022            , m_wasInActivePrintContextAccessScope { webPage.m_inActivePrintContextAccessScope }
     2023        {
     2024            m_webPage->m_inActivePrintContextAccessScope = true;
     2025        }
     2026
     2027        ~PrintContextAccessScope()
     2028        {
     2029            m_webPage->m_inActivePrintContextAccessScope = m_wasInActivePrintContextAccessScope;
     2030            if (!m_wasInActivePrintContextAccessScope && m_webPage->m_shouldEndPrintingImmediately)
     2031                m_webPage->endPrintingImmediately();
     2032        }
     2033    private:
     2034        Ref<WebPage> m_webPage;
     2035        const bool m_wasInActivePrintContextAccessScope;
     2036    };
     2037
     2038    friend class PrintContextAccessScope;
     2039
    20132040#if PLATFORM(GTK)
    20142041    RefPtr<WebPrintOperationGtk> m_printOperation;
Note: See TracChangeset for help on using the changeset viewer.