Changeset 282496 in webkit
- Timestamp:
- Sep 16, 2021, 1:00:07 AM (5 years ago)
- Location:
- releases/WebKitGTK/webkit-2.32/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
-
releases/WebKitGTK/webkit-2.32/Source/WebKit/ChangeLog
r280839 r282496 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-03-09 Chris Dumez <cdumez@apple.com> 2 26 -
releases/WebKitGTK/webkit-2.32/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r273452 r282496 5101 5101 void WebPage::beginPrinting(FrameIdentifier frameID, const PrintInfo& printInfo) 5102 5102 { 5103 PrintContextAccessScope scope { *this }; 5104 5103 5105 WebFrame* frame = WebProcess::singleton().webFrame(frameID); 5104 5106 if (!frame) … … 5122 5124 5123 5125 auto computedPageSize = m_printContext->computedPageSize(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight), printInfo.margin); 5126 5124 5127 m_printContext->begin(computedPageSize.width(), computedPageSize.height()); 5125 5128 … … 5143 5146 void WebPage::endPrinting() 5144 5147 { 5148 if (m_inActivePrintContextAccessScope) { 5149 m_shouldEndPrintingImmediately = true; 5150 return; 5151 } 5152 endPrintingImmediately(); 5153 } 5154 5155 void WebPage::endPrintingImmediately() 5156 { 5157 RELEASE_ASSERT(!m_inActivePrintContextAccessScope); 5158 m_shouldEndPrintingImmediately = false; 5159 5145 5160 unfreezeLayerTree(LayerTreeFreezeReason::Printing); 5146 5161 … … 5153 5168 void WebPage::computePagesForPrinting(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&& completionHandler) 5154 5169 { 5170 PrintContextAccessScope scope { *this }; 5155 5171 Vector<IntRect> resultPageRects; 5156 5172 double resultTotalScaleFactorForPrinting = 1; … … 5167 5183 5168 5184 if (m_printContext) { 5185 PrintContextAccessScope scope { *this }; 5169 5186 resultPageRects = m_printContext->pageRects(); 5170 5187 computedPageMargin = m_printContext->computedPageMargin(printInfo.margin); … … 5213 5230 void WebPage::drawRectToImage(FrameIdentifier frameID, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&& completionHandler) 5214 5231 { 5232 PrintContextAccessScope scope { *this }; 5215 5233 WebFrame* frame = WebProcess::singleton().webFrame(frameID); 5216 5234 Frame* coreFrame = frame ? frame->coreFrame() : 0; … … 5263 5281 void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&& callback) 5264 5282 { 5283 PrintContextAccessScope scope { *this }; 5265 5284 RetainPtr<CFMutableDataRef> pdfPageData; 5266 5285 drawPagesToPDFImpl(frameID, printInfo, first, count, pdfPageData); -
releases/WebKitGTK/webkit-2.32/Source/WebKit/WebProcess/WebPage/WebPage.h
r280839 r282496 1641 1641 #endif 1642 1642 1643 void endPrintingImmediately(); 1644 1643 1645 #if HAVE(APP_ACCENT_COLORS) 1644 1646 void setAccentColor(WebCore::Color); … … 2011 2013 2012 2014 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 2013 2040 #if PLATFORM(GTK) 2014 2041 RefPtr<WebPrintOperationGtk> m_printOperation;
Note:
See TracChangeset
for help on using the changeset viewer.