Skip to content
  • mitz@apple.com's avatar
    <rdar://problem/8257783> Short documents may print a second blank page · aca7dab0
    mitz@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=43271
    
    Reviewed by Darin Adler.
    
    WebCore: 
    
    Test: printing/stretch-to-view-height.html
    
    * WebCore.exp.in: Export Frame::forceLayoutForPagination(), replacing forceLayoutWithPageWidthRange().
    * page/Frame.cpp:
    (WebCore::Frame::setPrinting): Now takes a page width and height and a maximum shrink factor and passes
    them down to forceLayoutForPagination().
    * page/Frame.h:
    (WebCore::Frame::):
    * page/FrameView.cpp:
    (WebCore::FrameView::reset): Initialize m_pageHeight.
    (WebCore::FrameView::forceLayoutForPagination): Renamed forceLayoutWithPageWidthRange() to this and
    changed it to take a page width and height and a maximum shrink factor. Sets m_pageHeight, which is
    queried by RenderBox::calcHeight() during layout. If the given pageHeight is 0, m_pageHeight is set
    to the visible height, retaining the behavior before this change.
    * page/FrameView.h:
    (WebCore::FrameView::pageHeight): Added this accessor.
    * page/PrintContext.cpp:
    (WebCore::PrintContext::begin): Added a height parameter, used when calling setPrinting().
    (WebCore::PrintContext::end): Updated for setPrinting() changes.
    (WebCore::PrintContext::pageNumberForElement): Account for shrink-to-fit.
    (WebCore::PrintContext::pageProperty): Pass 0 for the height, retaining current behavior.
    (WebCore::PrintContext::numberOfPages): Account for shrink-to-fit.
    (WebCore::PrintContext::spoolAllPagesWithBoundaries): Pass the page width to begin().
    * page/PrintContext.h:
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::calcHeight): When printing, use FrameView::pageHeight() as the basis for
    viewport-relative heights.
    
    WebKit/mac: 
    
    * WebView/WebHTMLView.mm:
    (-[WebHTMLView _web_setPrintingModeRecursive]): Updated for additional height parameter
    to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
    (-[WebHTMLView _web_clearPrintingModeRecursive]): Ditto.
    (-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): Ditto.
    (-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): Added height parameter,
    which is scaled and passed on to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
    (-[WebHTMLView _endPrintMode]): Updated for additional height parameter to
    _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
    (-[WebHTMLView layoutToMinimumPageWidth:height:maximumPageWidth:adjustingViewSize:]): Added
    height parameter, which is passed on to FrameView::forceLayoutForPagination().
    (-[WebHTMLView layout]): Updated for additional height parameter.
    (-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:]): Added height
    parameter, which is passed on to -layoutToMinimumPageWidth:height:maximumPageWidth:adjustViewSize:.
    (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Updated for additional height
    parameter.
    (-[WebHTMLView setPageWidthForPrinting:]): Ditto.
    (-[WebHTMLView knowsPageRange:]): Pass the available height on the page on to
    _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize.
    * WebView/WebHTMLViewPrivate.h: 
    
    WebKit/win: 
    
    * WebFrame.cpp:
    (WebFrame::setPrinting): Updated for changes to Frame::setPrinting(). Passing 0 for the
    page height, which maintains existing behavior.
    
    LayoutTests: 
    
    * platform/mac/printing/media-queries-print-expected.txt:
    * printing/page-break-margin-collapsed-expected.txt:
    * printing/resources/paged-media-test-utils.js:
    (ratioToPageHeightToPixels): Changed to reflect the default shrink factor of 1.25.
    * printing/script-tests/stretch-to-view-height.js: Added.
    (test):
    * printing/stretch-to-view-height-expected.txt: Added.
    * printing/stretch-to-view-height.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64409 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    aca7dab0