Reviewed by Anders Carlsson and Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=52595
Make basic printing work in WebKit2
* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetShouldPrintBackgrounds):
(WKPreferencesGetShouldPrintBackgrounds):
* UIProcess/API/C/WKPreferences.h:
Implement a preference for printing backgrounds.
* Shared/PrintInfo.cpp: Added.
(WebKit::PrintInfo::encode):
(WebKit::PrintInfo::decode):
* Shared/PrintInfo.h: Added.
* Shared/mac/PrintInfoMac.mm: Added.
(WebKit::PrintInfo::PrintInfo):
A new class for passing page setup information down to the web process.
* WebKit2.xcodeproj/project.pbxproj:
* GNUmakefile.am:
* WebKit2.pro:
* win/WebKit2.vcproj:
Added PrintInfo.
* Scripts/webkit2/messages.py: Added PrintInfo.h to a list of structs.
* UIProcess/API/mac/WKView.mm:
(WKViewData): Cache page count and geometry.
(WebFrameWrapper): Added a wrapper class for adding a WebFrameProxy to an NSDictionary.
(-[WKView drawRect:]): Added logging.
(setFrameBeingPrinted): Store a frame into NSPrintOperation's NSPrintInfo, so that all
methods invoked for this operation would know what's being printed.
(frameBeingPrinted): Retrieve this data.
(-[WKView printOperationWithPrintInfo:forFrame:]): Create a print operation that's appropriate
for the frame.
(-[WKView knowsPageRange:]): Ask the web process.
(-[WKView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]):
Take over printing, because I couldn't make drawRect: work correctly with WebKit custom fit
to page implementation.
(-[WKView _provideTotalScaleFactorForPrintOperation:]): Help AppKit clip correctly.
(-[WKView rectForPage:]): Return a pre-calculated rect.
* UIProcess/WebPageProxy.h: Added m_isInPrintingMode to track whether the web page is in
printing mode. The UI process controls that.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize m_isInPrintingMode.
(WebKit::WebPageProxy::beginPrinting): Change printing mode in web process if the value changes.
(WebKit::WebPageProxy::endPrinting): Ditto.
(WebKit::WebPageProxy::computePagesForPrinting): Ask the web process about output page geometry.
(WebKit::WebPageProxy::drawRectToPDF): Ask the web process about printed page data.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close): Delete m_printContext while there is still a Frame pointer.
(WebKit::WebPage::updatePreferences): Pass through ShouldPrintBackgrounds.
(WebKit::WebPage::beginPrinting): Switch into printing mode (or update parameters if we're
already in printing mode).
(WebKit::WebPage::endPrinting): Delete m_printContext, implicitly calling end().
(WebKit::WebPage::computePagesForPrinting): Make sure that we're in printing mode, and
copmute page rects.
(WebKit::WebPage::drawRectToPDF): Added a CG specific function to create a PDF document out
of a page rect. It should really work for onscreen content, but we only need it for printing.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Added BeginPrinting, EndPrinting,
ComputePagesForPrinting and DrawRectToPDF.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75979
268f45cc-cd09-0410-ab3c-
d52691b4dbfc