Reviewed by Anders Carlsson and Darin Adler.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 00:27:12 +0000 (00:27 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 00:27:12 +0000 (00:27 +0000)
commit79b9afc3375976954dfdbe3dad3356e97957b054
tree0f1a7aedc1beceac2528cfc457ff801397428ed9
parent05da4a068fb5d6cdc28b14a100e1a7dbeb2581dc
    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: https://svn.webkit.org/repository/webkit/trunk@75979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/Scripts/webkit2/messages.py
Source/WebKit2/Shared/PrintInfo.cpp [new file with mode: 0644]
Source/WebKit2/Shared/PrintInfo.h [new file with mode: 0644]
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/Shared/mac/PrintInfoMac.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferences.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebKit2.pro
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/win/WebKit2.vcproj