Changeset 272592 in webkit
- Timestamp:
- Feb 9, 2021 10:38:58 AM (3 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r272586 r272592 1 2021-02-09 Alex Christensen <achristensen@webkit.org> 2 3 Use CompletionHandler instead of DrawToPDFCallback 4 https://bugs.webkit.org/show_bug.cgi?id=220120 5 6 Reviewed by Chris Dumez. 7 8 Along the way I made all asynchronous message replies use 8 fewer bytes by using the destination ID for the listener ID 9 instead of encoding 0 as the destination ID and then encoding the listener ID. This was needed in order to make implementing 10 waitForAsyncCallbackAndDispatchImmediately possible, which looks at the destination IDs of incoming messages. 11 I also made it so that if we are just snapshotting the first page, we don't send a synchronous message because we already know the page count: 12 1! 13 14 * Platform/IPC/Connection.cpp: 15 (IPC::Connection::dispatchMessage): 16 * Platform/IPC/Connection.h: 17 (IPC::Connection::sendWithAsyncReply): 18 (IPC::Connection::waitForAndDispatchImmediately): 19 (IPC::Connection::waitForAsyncCallbackAndDispatchImmediately): 20 * Platform/IPC/HandleMessage.h: 21 (IPC::handleMessageAsync): 22 (IPC::handleMessageAsyncWantsConnection): 23 * Platform/IPC/JSIPCBinding.cpp: 24 (IPC::jsValueForDecodedArgumentValue): 25 * Platform/IPC/JSIPCBinding.h: 26 * Platform/IPC/MessageSender.h: 27 (IPC::MessageSender::sendWithAsyncReply): 28 * Scripts/webkit/messages.py: 29 * UIProcess/API/Cocoa/WKWebView.mm: 30 (-[WKWebView createPDFWithConfiguration:completionHandler:]): 31 * UIProcess/AuxiliaryProcessProxy.h: 32 (WebKit::AuxiliaryProcessProxy::sendWithAsyncReply): 33 * UIProcess/WebPageProxy.cpp: 34 (WebKit::WebPageProxy::drawToPDF): 35 (WebKit::WebPageProxy::getLoadDecisionForIcon): 36 (WebKit::WebPageProxy::drawToPDFCallback): Deleted. 37 * UIProcess/WebPageProxy.h: 38 * UIProcess/WebPageProxy.messages.in: 39 * UIProcess/ios/WKContentView.mm: 40 (-[WKContentView _processDidExit]): 41 (-[WKContentView _wk_pageCountForPrintFormatter:]): 42 (-[WKContentView _waitForDrawToPDFCallback]): 43 (-[WKContentView _wk_printedDocument]): 44 * UIProcess/ios/WebPageProxyIOS.mm: 45 (WebKit::WebPageProxy::computePagesForPrintingAndDrawToPDF): 46 * WebProcess/WebPage/WebPage.cpp: 47 (WebKit::WebPage::drawToPDF): 48 * WebProcess/WebPage/WebPage.h: 49 * WebProcess/WebPage/WebPage.messages.in: 50 * WebProcess/WebPage/ios/WebPageIOS.mm: 51 (WebKit::WebPage::computePagesForPrintingiOS): 52 (WebKit::WebPage::drawToPDFiOS): 53 (WebKit::WebPage::computePagesForPrintingAndDrawToPDF): Deleted. 54 1 55 2021-02-09 Per Arne <pvollan@apple.com> 2 56 -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r271243 r272592 1007 1007 RELEASE_ASSERT(isValid()); 1008 1008 if (decoder.messageReceiverName() == ReceiverName::AsyncReply) { 1009 Optional<uint64_t> listenerID; 1010 decoder >> listenerID; 1011 if (!listenerID) { 1012 ASSERT_NOT_REACHED(); 1013 return; 1014 } 1015 auto handler = takeAsyncReplyHandler(*this, *listenerID); 1009 auto handler = takeAsyncReplyHandler(*this, decoder.destinationID()); 1016 1010 if (!handler) { 1017 1011 ASSERT_NOT_REACHED(); -
trunk/Source/WebKit/Platform/IPC/Connection.h
r272058 r272592 226 226 227 227 void postConnectionDidCloseOnConnectionWorkQueue(); 228 template<typename T, typename C> voidsendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID = 0, OptionSet<SendOption> = { }); // Thread-safe.228 template<typename T, typename C> uint64_t sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID = 0, OptionSet<SendOption> = { }); // Thread-safe. 229 229 template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }); // Thread-safe. 230 230 // Sync senders should check the SendSyncResult for true/false in case they need to know if the result was really received. … … 232 232 using SendSyncResult = std::unique_ptr<Decoder>; 233 233 template<typename T> SendSyncResult sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout = Seconds::infinity(), OptionSet<SendSyncOption> sendSyncOptions = { }); // Main thread only. 234 template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions = { }); // Main thread only. 235 234 template<typename> bool waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions = { }); // Main thread only. 235 template<typename> bool waitForAsyncCallbackAndDispatchImmediately(uint64_t callbackID, Seconds timeout); // Main thread only. 236 236 237 // Thread-safe. 237 238 template<typename T, typename C, typename U> 238 voidsendWithAsyncReply(T&& message, C&& completionHandler, ObjectIdentifier<U> destinationID = { }, OptionSet<SendOption> sendOptions = { })239 { 240 sendWithAsyncReply<T, C>(WTFMove(message), WTFMove(completionHandler), destinationID.toUInt64(), sendOptions);239 uint64_t sendWithAsyncReply(T&& message, C&& completionHandler, ObjectIdentifier<U> destinationID = { }, OptionSet<SendOption> sendOptions = { }) 240 { 241 return sendWithAsyncReply<T, C>(WTFMove(message), WTFMove(completionHandler), destinationID.toUInt64(), sendOptions); 241 242 } 242 243 … … 516 517 517 518 template<typename T, typename C> 518 voidConnection::sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID, OptionSet<SendOption> sendOptions)519 uint64_t Connection::sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID, OptionSet<SendOption> sendOptions) 519 520 { 520 521 COMPILE_ASSERT(!T::isSync, AsyncMessageExpected); … … 531 532 *encoder << message.arguments(); 532 533 sendMessage(WTFMove(encoder), sendOptions); 534 return listenerID; 533 535 } 534 536 … … 594 596 } 595 597 598 template<typename T> bool Connection::waitForAsyncCallbackAndDispatchImmediately(uint64_t destinationID, Seconds timeout) 599 { 600 RELEASE_ASSERT(RunLoop::isMain()); 601 std::unique_ptr<Decoder> decoder = waitForMessage(T::asyncMessageReplyName(), destinationID, timeout, { }); 602 if (!decoder) 603 return false; 604 605 ASSERT(decoder->messageReceiverName() == ReceiverName::AsyncReply); 606 ASSERT(decoder->destinationID() == destinationID); 607 auto handler = takeAsyncReplyHandler(*this, decoder->destinationID()); 608 if (!handler) { 609 ASSERT_NOT_REACHED(); 610 return false; 611 } 612 handler(decoder.get()); 613 return true; 614 } 615 596 616 class UnboundedSynchronousIPCScope { 597 617 public: -
trunk/Source/WebKit/Platform/IPC/HandleMessage.h
r270573 r272592 174 174 return; 175 175 } 176 176 177 177 Optional<typename CodingType<typename T::Arguments>::Type> arguments; 178 178 decoder >> arguments; … … 183 183 184 184 typename T::AsyncReply completionHandler = [listenerID = *listenerID, connection = makeRef(connection)] (auto&&... args) mutable { 185 auto encoder = makeUnique<Encoder>(T::asyncMessageReplyName(), 0); 186 *encoder << listenerID; 185 auto encoder = makeUnique<Encoder>(T::asyncMessageReplyName(), listenerID); 187 186 T::send(WTFMove(encoder), WTFMove(connection), args...); 188 187 }; … … 193 192 void handleMessageAsyncWantsConnection(Connection& connection, Decoder& decoder, C* object, MF function) 194 193 { 195 Optional<uint64_t> listenerID; 196 decoder >> listenerID; 197 if (!listenerID) { 198 decoder.markInvalid(); 199 return; 200 } 201 202 Optional<typename CodingType<typename T::Arguments>::Type> arguments; 203 decoder >> arguments; 204 if (!arguments) { 205 decoder.markInvalid(); 206 return; 207 } 208 209 typename T::AsyncReply completionHandler = [listenerID = *listenerID, connection = makeRef(connection)] (auto&&... args) mutable { 210 auto encoder = makeUnique<Encoder>(T::asyncMessageReplyName(), 0); 211 *encoder << listenerID; 194 Optional<typename CodingType<typename T::Arguments>::Type> arguments; 195 decoder >> arguments; 196 if (!arguments) { 197 decoder.markInvalid(); 198 return; 199 } 200 201 typename T::AsyncReply completionHandler = [listenerID = decoder.destinationID(), connection = makeRef(connection)] (auto&&... args) mutable { 202 auto encoder = makeUnique<Encoder>(T::asyncMessageReplyName(), listenerID); 212 203 T::send(WTFMove(encoder), WTFMove(connection), args...); 213 204 }; -
trunk/Source/WebKit/Platform/IPC/JSIPCBinding.cpp
r268946 r272592 158 158 } 159 159 160 template<> 161 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, size_t value) 162 { 163 return jsValueForDecodedNumericArgumentValue(globalObject, value, "size_t"); 164 } 165 160 166 template<typename RectType> 161 167 JSC::JSValue jsValueForDecodedArgumentRect(JSC::JSGlobalObject* globalObject, const RectType& value, const String& type) -
trunk/Source/WebKit/Platform/IPC/JSIPCBinding.h
r268946 r272592 87 87 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, uint32_t); 88 88 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, uint64_t); 89 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, size_t); 89 90 90 91 template<typename U> -
trunk/Source/WebKit/Platform/IPC/MessageSender.h
r272058 r272592 81 81 82 82 template<typename T, typename C> 83 voidsendWithAsyncReply(T&& message, C&& completionHandler, OptionSet<SendOption> sendOptions = { })83 uint64_t sendWithAsyncReply(T&& message, C&& completionHandler, OptionSet<SendOption> sendOptions = { }) 84 84 { 85 sendWithAsyncReply(WTFMove(message), WTFMove(completionHandler), messageSenderDestinationID(), sendOptions);85 return sendWithAsyncReply(WTFMove(message), WTFMove(completionHandler), messageSenderDestinationID(), sendOptions); 86 86 } 87 87 88 88 template<typename T, typename C> 89 voidsendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID, OptionSet<SendOption> sendOptions = { })89 uint64_t sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }) 90 90 { 91 91 COMPILE_ASSERT(!T::isSync, AsyncMessageExpected); … … 101 101 T::cancelReply(WTFMove(completionHandler)); 102 102 }, listenerID }}); 103 return listenerID; 103 104 } 104 105 -
trunk/Source/WebKit/Scripts/webkit/messages.py
r272475 r272592 129 129 'int32_t', 130 130 'int64_t', 131 'size_t', 131 132 ]) 132 133 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r272425 r272592 1474 1474 floatRect = WebCore::FloatRect(pdfConfiguration.rect); 1475 1475 1476 auto handler = makeBlockPtr(completionHandler); 1477 _page->drawToPDF(frameID, floatRect, [retainedSelf = retainPtr(self), handler = WTFMove(handler)](const IPC::DataReference& pdfData, WebKit::CallbackBase::Error error) { 1478 if (error != WebKit::CallbackBase::Error::None) { 1476 _page->drawToPDF(frameID, floatRect, [handler = makeBlockPtr(completionHandler)](const IPC::DataReference& pdfData) { 1477 if (pdfData.isEmpty()) { 1479 1478 handler(nil, createNSError(WKErrorUnknown).get()); 1480 1479 return; -
trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
r272058 r272592 58 58 59 59 enum class ShouldStartProcessThrottlerActivity : bool { No, Yes }; 60 template<typename T, typename C> voidsendWithAsyncReply(T&&, C&&, uint64_t destinationID = 0, OptionSet<IPC::SendOption> = { }, ShouldStartProcessThrottlerActivity = ShouldStartProcessThrottlerActivity::Yes);60 template<typename T, typename C> uint64_t sendWithAsyncReply(T&&, C&&, uint64_t destinationID = 0, OptionSet<IPC::SendOption> = { }, ShouldStartProcessThrottlerActivity = ShouldStartProcessThrottlerActivity::Yes); 61 61 62 62 template<typename T, typename U> … … 183 183 184 184 template<typename T, typename C> 185 voidAuxiliaryProcessProxy::sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions, ShouldStartProcessThrottlerActivity shouldStartProcessThrottlerActivity)185 uint64_t AuxiliaryProcessProxy::sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions, ShouldStartProcessThrottlerActivity shouldStartProcessThrottlerActivity) 186 186 { 187 187 COMPILE_ASSERT(!T::isSync, AsyncMessageExpected); … … 197 197 T::cancelReply(WTFMove(completionHandler)); 198 198 }, listenerID }}, shouldStartProcessThrottlerActivity); 199 return listenerID; 199 200 } 200 201 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r272575 r272592 8599 8599 8600 8600 #if PLATFORM(COCOA) 8601 void WebPageProxy::drawToPDF(FrameIdentifier frameID, const Optional<FloatRect>& rect, DrawToPDFCallback::CallbackFunction&& callback)8601 void WebPageProxy::drawToPDF(FrameIdentifier frameID, const Optional<FloatRect>& rect, CompletionHandler<void(const IPC::DataReference&)>&& callback) 8602 8602 { 8603 8603 if (!hasRunningProcess()) { 8604 callback(IPC::DataReference(), CallbackBase::Error::OwnerWasInvalidated); 8605 return; 8606 } 8607 8608 auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::drawToPDF"_s)); 8609 send(Messages::WebPage::DrawToPDF(frameID, rect, callbackID)); 8610 } 8611 8612 void WebPageProxy::drawToPDFCallback(const IPC::DataReference& pdfData, CallbackID callbackID) 8613 { 8614 auto callback = m_callbacks.take<DrawToPDFCallback>(callbackID); 8615 RELEASE_ASSERT(callback); 8616 callback->performCallbackWithReturnValue(pdfData); 8604 callback({ }); 8605 return; 8606 } 8607 sendWithAsyncReply(Messages::WebPage::DrawToPDF(frameID, rect), WTFMove(callback)); 8617 8608 } 8618 8609 #endif // PLATFORM(COCOA) … … 9514 9505 } 9515 9506 9516 if (!callback) 9517 return sendWithAsyncReply(Messages::WebPage::DidGetLoadDecisionForIcon(false, loadIdentifier), [](auto) { }); 9507 if (!callback) { 9508 sendWithAsyncReply(Messages::WebPage::DidGetLoadDecisionForIcon(false, loadIdentifier), [](auto) { }); 9509 return; 9510 } 9518 9511 sendWithAsyncReply(Messages::WebPage::DidGetLoadDecisionForIcon(true, loadIdentifier), [callback = WTFMove(callback)](const IPC::DataReference& iconData) mutable { 9519 9512 callback(API::Data::create(iconData).get()); -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r272573 r272592 407 407 408 408 #if PLATFORM(COCOA) 409 using DrawToPDFCallback = GenericCallback<const IPC::DataReference&>;410 409 typedef GenericCallback<bool, bool, String, double, double, uint64_t> NowPlayingInfoCallback; 411 410 #endif … … 1302 1301 void drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, Ref<ImageCallback>&&); 1303 1302 void drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, Ref<DataCallback>&&); 1304 void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, DrawToPDFCallback::CallbackFunction&&); 1305 void drawToPDFCallback(const IPC::DataReference& pdfData, WebKit::CallbackID); 1303 void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, CompletionHandler<void(const IPC::DataReference&)>&&); 1306 1304 #if PLATFORM(IOS_FAMILY) 1307 uint32_t computePagesForPrintingAndDrawToPDF(WebCore::FrameIdentifier, const PrintInfo&, DrawToPDFCallback::CallbackFunction&&);1305 std::pair<size_t, uint64_t> computePagesForPrintingAndDrawToPDF(WebCore::FrameIdentifier, const PrintInfo&, CompletionHandler<void(const IPC::DataReference&)>&&); 1308 1306 #endif 1309 1307 #elif PLATFORM(GTK) -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r272573 r272592 192 192 #endif 193 193 #if PLATFORM(COCOA) 194 DrawToPDFCallback(IPC::DataReference pdfData, WebKit::CallbackID callbackID)195 194 NowPlayingInfoCallback(bool active, bool registeredAsNowPlayingApplication, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackID callbackID) 196 195 #endif -
trunk/Source/WebKit/UIProcess/ios/WKContentView.mm
r271771 r272592 50 50 #import "WebKit2Initialize.h" 51 51 #import "WebPageGroup.h" 52 #import "WebPageMessages.h" 52 53 #import "WebPageProxyMessages.h" 53 54 #import "WebProcessPool.h" … … 144 145 RetainPtr<WKQuirkyNSUndoManager> _quirkyUndoManager; 145 146 146 BOOL _isPrintingToPDF;147 uint64_t _pdfPrintCallbackID; 147 148 RetainPtr<CGPDFDocumentRef> _printedDocument; 148 149 } … … 621 622 #endif 622 623 623 _ isPrintingToPDF = NO;624 _pdfPrintCallbackID = 0; 624 625 } 625 626 … … 792 793 - (NSUInteger)_wk_pageCountForPrintFormatter:(_WKWebViewPrintFormatter *)printFormatter 793 794 { 794 if (_ isPrintingToPDF)795 if (_pdfPrintCallbackID) 795 796 [self _waitForDrawToPDFCallback]; 796 797 … … 825 826 printInfo.availablePaperHeight = CGRectGetHeight(printingRect); 826 827 827 _isPrintingToPDF = YES;828 828 auto retainedSelf = retainPtr(self); 829 return _page->computePagesForPrintingAndDrawToPDF(frameID, printInfo, [retainedSelf](const IPC::DataReference& pdfData, WebKit::CallbackBase::Error error) {830 retainedSelf->_ isPrintingToPDF = NO;831 if ( error != WebKit::CallbackBase::Error::None)829 auto pair = _page->computePagesForPrintingAndDrawToPDF(frameID, printInfo, [retainedSelf](const IPC::DataReference& pdfData) { 830 retainedSelf->_pdfPrintCallbackID = 0; 831 if (pdfData.isEmpty()) 832 832 return; 833 833 … … 836 836 retainedSelf->_printedDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get())); 837 837 }); 838 _pdfPrintCallbackID = pair.second; 839 return pair.first; 838 840 } 839 841 840 842 - (BOOL)_waitForDrawToPDFCallback 841 843 { 842 if (!_page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DrawToPDFCallback>(_page->webPageID(), Seconds::infinity())) 844 ASSERT(_pdfPrintCallbackID); 845 if (!_page->process().connection()->waitForAsyncCallbackAndDispatchImmediately<Messages::WebPage::DrawToPDFiOS>(std::exchange(_pdfPrintCallbackID, 0), Seconds::infinity())) 843 846 return false; 844 ASSERT(!_ isPrintingToPDF);847 ASSERT(!_pdfPrintCallbackID); 845 848 return true; 846 849 } … … 848 851 - (CGPDFDocumentRef)_wk_printedDocument 849 852 { 850 if (_ isPrintingToPDF) {853 if (_pdfPrintCallbackID) { 851 854 if (![self _waitForDrawToPDFCallback]) 852 855 return nullptr; -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r271969 r272592 1047 1047 } 1048 1048 1049 uint32_t WebPageProxy::computePagesForPrintingAndDrawToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, DrawToPDFCallback::CallbackFunction&& callback) 1050 { 1051 if (!hasRunningProcess()) { 1052 callback(IPC::DataReference(), CallbackBase::Error::OwnerWasInvalidated); 1053 return 0; 1054 } 1055 1056 uint32_t pageCount = 0; 1057 auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::computePagesForPrintingAndDrawToPDF"_s)); 1058 sendSync(Messages::WebPage::ComputePagesForPrintingAndDrawToPDF(frameID, printInfo, callbackID), Messages::WebPage::ComputePagesForPrintingAndDrawToPDF::Reply(pageCount), Seconds::infinity()); 1059 return pageCount; 1049 std::pair<size_t, uint64_t> WebPageProxy::computePagesForPrintingAndDrawToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, CompletionHandler<void(const IPC::DataReference&)>&& callback) 1050 { 1051 if (!hasRunningProcess()) { 1052 callback({ }); 1053 return { 0, 0 }; 1054 } 1055 1056 size_t pageCount = 0; 1057 if (printInfo.snapshotFirstPage) 1058 pageCount = 1; 1059 else 1060 sendSync(Messages::WebPage::ComputePagesForPrintingiOS(frameID, printInfo), Messages::WebPage::ComputePagesForPrintingiOS::Reply(pageCount), Seconds::infinity()); 1061 1062 auto callbackID = sendWithAsyncReply(Messages::WebPage::DrawToPDFiOS(frameID, printInfo, pageCount), WTFMove(callback)); 1063 1064 return { pageCount, callbackID }; 1060 1065 } 1061 1066 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r272573 r272592 5101 5101 5102 5102 #if PLATFORM(COCOA) 5103 void WebPage::drawToPDF(FrameIdentifier frameID, const Optional<FloatRect>& rect, C allbackID callbackID)5103 void WebPage::drawToPDF(FrameIdentifier frameID, const Optional<FloatRect>& rect, CompletionHandler<void(const IPC::DataReference&)>&& completionHandler) 5104 5104 { 5105 5105 auto& frameView = *m_page->mainFrame().view(); … … 5126 5126 frameView.setPaintBehavior(originalPaintBehavior); 5127 5127 5128 send(Messages::WebPageProxy::DrawToPDFCallback(IPC::DataReference(CFDataGetBytePtr(pdfData.get()), CFDataGetLength(pdfData.get())), callbackID));5128 completionHandler(IPC::DataReference(CFDataGetBytePtr(pdfData.get()), CFDataGetLength(pdfData.get()))); 5129 5129 } 5130 5130 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r272573 r272592 972 972 973 973 #if PLATFORM(IOS_FAMILY) 974 void computePagesForPrintingAndDrawToPDF(WebCore::FrameIdentifier, const PrintInfo&, CallbackID, Messages::WebPage::ComputePagesForPrintingAndDrawToPDFDelayedReply&&); 975 #endif 976 977 void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, CallbackID); 974 void computePagesForPrintingiOS(WebCore::FrameIdentifier, const PrintInfo&, Messages::WebPage::ComputePagesForPrintingiOSDelayedReply&&); 975 void drawToPDFiOS(WebCore::FrameIdentifier, const PrintInfo&, size_t, Messages::WebPage::DrawToPDFiOSAsyncReply&&); 976 #endif 977 978 void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, CompletionHandler<void(const IPC::DataReference&)>&&); 978 979 979 980 #if PLATFORM(GTK) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r272573 r272592 403 403 DrawPagesToPDF(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, WebKit::CallbackID callbackID) 404 404 #if PLATFORM(IOS_FAMILY) 405 ComputePagesForPrintingAndDrawToPDF(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebKit::CallbackID callbackID) -> (uint32_t pageCount) Synchronous 406 #endif 407 DrawToPDF(WebCore::FrameIdentifier frameID, Optional<WebCore::FloatRect> rect, WebKit::CallbackID callbackID) 405 ComputePagesForPrintingiOS(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (size_t pageCount) Synchronous 406 DrawToPDFiOS(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, size_t pageCount) -> (IPC::DataReference data) Async 407 #endif 408 DrawToPDF(WebCore::FrameIdentifier frameID, Optional<WebCore::FloatRect> rect) -> (IPC::DataReference data) Async 408 409 #endif 409 410 #if PLATFORM(GTK) -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r272558 r272592 3972 3972 #endif 3973 3973 3974 void WebPage::computePagesForPrintingAndDrawToPDF(WebCore::FrameIdentifier frameID, const PrintInfo& printInfo, CallbackID callbackID, Messages::WebPage::ComputePagesForPrintingAndDrawToPDF::DelayedReply&& reply) 3975 { 3976 if (printInfo.snapshotFirstPage) { 3977 reply(1); 3978 IntSize snapshotSize { FloatSize { printInfo.availablePaperWidth, printInfo.availablePaperHeight } }; 3979 IntRect snapshotRect { {0, 0}, snapshotSize }; 3980 3981 auto& frameView = *m_page->mainFrame().view(); 3982 auto originalLayoutViewportOverrideRect = frameView.layoutViewportOverrideRect(); 3983 frameView.setLayoutViewportOverrideRect(LayoutRect(snapshotRect)); 3984 3985 auto pdfData = pdfSnapshotAtSize(snapshotRect, snapshotSize, 0); 3986 3987 frameView.setLayoutViewportOverrideRect(originalLayoutViewportOverrideRect); 3988 send(Messages::WebPageProxy::DrawToPDFCallback(IPC::DataReference(CFDataGetBytePtr(pdfData.get()), CFDataGetLength(pdfData.get())), callbackID)); 3989 return; 3990 } 3974 void WebPage::computePagesForPrintingiOS(WebCore::FrameIdentifier frameID, const PrintInfo& printInfo, Messages::WebPage::ComputePagesForPrintingiOS::DelayedReply&& reply) 3975 { 3976 ASSERT_WITH_MESSAGE(!printInfo.snapshotFirstPage, "If we are just snapshotting the first page, we don't need a synchronous message to determine the page count, which is 1."); 3991 3977 3992 3978 Vector<WebCore::IntRect> pageRects; … … 3996 3982 3997 3983 ASSERT(pageRects.size() >= 1); 3998 std::size_t pageCount = pageRects.size(); 3999 ASSERT(pageCount <= std::numeric_limits<uint32_t>::max()); 4000 reply(pageCount); 3984 reply(pageRects.size()); 3985 } 3986 3987 void WebPage::drawToPDFiOS(WebCore::FrameIdentifier frameID, const PrintInfo& printInfo, size_t pageCount, Messages::WebPage::DrawToPDFiOSAsyncReply&& reply) 3988 { 3989 if (printInfo.snapshotFirstPage) { 3990 IntSize snapshotSize { FloatSize { printInfo.availablePaperWidth, printInfo.availablePaperHeight } }; 3991 IntRect snapshotRect { {0, 0}, snapshotSize }; 3992 3993 auto& frameView = *m_page->mainFrame().view(); 3994 auto originalLayoutViewportOverrideRect = frameView.layoutViewportOverrideRect(); 3995 frameView.setLayoutViewportOverrideRect(LayoutRect(snapshotRect)); 3996 3997 auto pdfData = pdfSnapshotAtSize(snapshotRect, snapshotSize, 0); 3998 3999 frameView.setLayoutViewportOverrideRect(originalLayoutViewportOverrideRect); 4000 reply(IPC::DataReference(CFDataGetBytePtr(pdfData.get()), CFDataGetLength(pdfData.get()))); 4001 return; 4002 } 4001 4003 4002 4004 RetainPtr<CFMutableDataRef> pdfPageData; 4003 4005 drawPagesToPDFImpl(frameID, printInfo, 0, pageCount, pdfPageData); 4004 send(Messages::WebPageProxy::DrawToPDFCallback(IPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID));4006 reply(IPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get()))); 4005 4007 4006 4008 endPrinting();
Note: See TracChangeset
for help on using the changeset viewer.