Changeset 275549 in webkit
- Timestamp:
- Apr 6, 2021, 1:57:44 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
WebProcess/WebPage/WebPage.cpp (modified) (7 diffs)
-
WebProcess/WebPage/WebPage.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r275546 r275549 1 2021-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 1 25 2021-04-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 26 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r275527 r275549 5095 5095 void WebPage::beginPrinting(FrameIdentifier frameID, const PrintInfo& printInfo) 5096 5096 { 5097 PrintContextAccessScope scope { *this }; 5098 5097 5099 WebFrame* frame = WebProcess::singleton().webFrame(frameID); 5098 5100 if (!frame) … … 5116 5118 5117 5119 auto computedPageSize = m_printContext->computedPageSize(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight), printInfo.margin); 5120 5118 5121 m_printContext->begin(computedPageSize.width(), computedPageSize.height()); 5119 5122 … … 5137 5140 void WebPage::endPrinting() 5138 5141 { 5142 if (m_inActivePrintContextAccessScope) { 5143 m_shouldEndPrintingImmediately = true; 5144 return; 5145 } 5146 endPrintingImmediately(); 5147 } 5148 5149 void WebPage::endPrintingImmediately() 5150 { 5151 RELEASE_ASSERT(!m_inActivePrintContextAccessScope); 5152 m_shouldEndPrintingImmediately = false; 5153 5139 5154 unfreezeLayerTree(LayerTreeFreezeReason::Printing); 5140 5155 … … 5147 5162 void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& completionHandler) 5148 5163 { 5164 PrintContextAccessScope scope { *this }; 5149 5165 Vector<IntRect> resultPageRects; 5150 5166 double resultTotalScaleFactorForPrinting = 1; … … 5161 5177 5162 5178 if (m_printContext) { 5179 PrintContextAccessScope scope { *this }; 5163 5180 resultPageRects = m_printContext->pageRects(); 5164 5181 computedPageMargin = m_printContext->computedPageMargin(printInfo.margin); … … 5207 5224 void WebPage::drawRectToImage(FrameIdentifier frameID, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&& completionHandler) 5208 5225 { 5226 PrintContextAccessScope scope { *this }; 5209 5227 WebFrame* frame = WebProcess::singleton().webFrame(frameID); 5210 5228 Frame* coreFrame = frame ? frame->coreFrame() : 0; … … 5257 5275 void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&& callback) 5258 5276 { 5277 PrintContextAccessScope scope { *this }; 5259 5278 RetainPtr<CFMutableDataRef> pdfPageData; 5260 5279 drawPagesToPDFImpl(frameID, printInfo, first, count, pdfPageData); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r275485 r275549 1660 1660 #endif 1661 1661 1662 void endPrintingImmediately(); 1663 1662 1664 #if HAVE(APP_ACCENT_COLORS) 1663 1665 void setAccentColor(WebCore::Color); … … 2036 2038 2037 2039 std::unique_ptr<WebCore::PrintContext> m_printContext; 2040 bool m_inActivePrintContextAccessScope { false }; 2041 bool m_shouldEndPrintingImmediately { false }; 2042 2043 class PrintContextAccessScope { 2044 public: 2045 PrintContextAccessScope(WebPage& webPage) 2046 : m_webPage { webPage } 2047 , m_wasInActivePrintContextAccessScope { webPage.m_inActivePrintContextAccessScope } 2048 { 2049 m_webPage->m_inActivePrintContextAccessScope = true; 2050 } 2051 2052 ~PrintContextAccessScope() 2053 { 2054 m_webPage->m_inActivePrintContextAccessScope = m_wasInActivePrintContextAccessScope; 2055 if (!m_wasInActivePrintContextAccessScope && m_webPage->m_shouldEndPrintingImmediately) 2056 m_webPage->endPrintingImmediately(); 2057 } 2058 private: 2059 Ref<WebPage> m_webPage; 2060 const bool m_wasInActivePrintContextAccessScope; 2061 }; 2062 2063 friend class PrintContextAccessScope; 2064 2038 2065 #if PLATFORM(GTK) 2039 2066 RefPtr<WebPrintOperationGtk> m_printOperation;
Note:
See TracChangeset
for help on using the changeset viewer.