⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 64409 in webkit


Ignore:
Timestamp:
Jul 30, 2010, 10:59:02 PM (16 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/8257783> Short documents may print a second blank page
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.
Location:
trunk
Files:
3 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64408 r64409  
     12010-07-30  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/8257783> Short documents may print a second blank page
     6        https://bugs.webkit.org/show_bug.cgi?id=43271
     7
     8        * platform/mac/printing/media-queries-print-expected.txt:
     9        * printing/page-break-margin-collapsed-expected.txt:
     10        * printing/resources/paged-media-test-utils.js:
     11        (ratioToPageHeightToPixels): Changed to reflect the default shrink factor of 1.25.
     12        * printing/script-tests/stretch-to-view-height.js: Added.
     13        (test):
     14        * printing/stretch-to-view-height-expected.txt: Added.
     15        * printing/stretch-to-view-height.html: Added.
     16
    1172010-07-30  Mihai Parparita  <mihaip@chromium.org>
    218
  • trunk/LayoutTests/platform/mac/printing/media-queries-print-expected.txt

    r63403 r64409  
    1 layer at (0,0) size 1000x585
    2   RenderView at (0,0) size 1000x585
    3 layer at (0,0) size 1000x585
    4   RenderBlock {HTML} at (0,0) size 1000x585
    5     RenderBody {BODY} at (8,8) size 984x569
     1layer at (0,0) size 1000x600
     2  RenderView at (0,0) size 1000x600
     3layer at (0,0) size 1000x600
     4  RenderBlock {HTML} at (0,0) size 1000x600
     5    RenderBody {BODY} at (8,8) size 984x584
    66      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
    77      RenderBlock (anonymous) at (0,100) size 984x18
  • trunk/LayoutTests/printing/page-break-margin-collapsed-expected.txt

    r61530 r64409  
    66
    77PASS: page number of "page1" is 1
    8 FAIL: expected page number of "page2" is 2. Was 167
     8FAIL: expected page number of "page2" is 2. Was 134
    99
    1010PASS successfullyParsed is true
  • trunk/LayoutTests/printing/resources/paged-media-test-utils.js

    r61309 r64409  
    6363function ratioToPageHeightToPixels(heightInRatioToPageHeight)
    6464{
    65   var pageHeightInPixels = 600;
     65  var pageHeightInPixels = 600 * 1.25;
    6666  return Math.floor(pageHeightInPixels * heightInRatioToPageHeight);
    6767}
  • trunk/WebCore/ChangeLog

    r64408 r64409  
     12010-07-30  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/8257783> Short documents may print a second blank page
     6        https://bugs.webkit.org/show_bug.cgi?id=43271
     7
     8        Test: printing/stretch-to-view-height.html
     9
     10        * WebCore.exp.in: Export Frame::forceLayoutForPagination(), replacing forceLayoutWithPageWidthRange().
     11        * page/Frame.cpp:
     12        (WebCore::Frame::setPrinting): Now takes a page width and height and a maximum shrink factor and passes
     13        them down to forceLayoutForPagination().
     14        * page/Frame.h:
     15        (WebCore::Frame::):
     16        * page/FrameView.cpp:
     17        (WebCore::FrameView::reset): Initialize m_pageHeight.
     18        (WebCore::FrameView::forceLayoutForPagination): Renamed forceLayoutWithPageWidthRange() to this and
     19        changed it to take a page width and height and a maximum shrink factor. Sets m_pageHeight, which is
     20        queried by RenderBox::calcHeight() during layout. If the given pageHeight is 0, m_pageHeight is set
     21        to the visible height, retaining the behavior before this change.
     22        * page/FrameView.h:
     23        (WebCore::FrameView::pageHeight): Added this accessor.
     24        * page/PrintContext.cpp:
     25        (WebCore::PrintContext::begin): Added a height parameter, used when calling setPrinting().
     26        (WebCore::PrintContext::end): Updated for setPrinting() changes.
     27        (WebCore::PrintContext::pageNumberForElement): Account for shrink-to-fit.
     28        (WebCore::PrintContext::pageProperty): Pass 0 for the height, retaining current behavior.
     29        (WebCore::PrintContext::numberOfPages): Account for shrink-to-fit.
     30        (WebCore::PrintContext::spoolAllPagesWithBoundaries): Pass the page width to begin().
     31        * page/PrintContext.h:
     32        * rendering/RenderBox.cpp:
     33        (WebCore::RenderBox::calcHeight): When printing, use FrameView::pageHeight() as the basis for
     34        viewport-relative heights.
     35
    1362010-07-30  Mihai Parparita  <mihaip@chromium.org>
    237
  • trunk/WebCore/WebCore.exp.in

    r64400 r64409  
    770770__ZN7WebCore9FrameView23layoutIfNeededRecursiveEv
    771771__ZN7WebCore9FrameView23updateCanHaveScrollbarsEv
    772 __ZN7WebCore9FrameView29forceLayoutWithPageWidthRangeEffb
     772__ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeEfNS_5Frame19AdjustViewSizeOrNotE
    773773__ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
    774774__ZN7WebCore9FrameView29syncCompositingStateRecursiveEv
  • trunk/WebCore/page/Frame.cpp

    r63927 r64409  
    618618}
    619619
    620 void Frame::setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize)
     620void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
    621621{
    622622    m_doc->setPrinting(printing);
     
    624624
    625625    m_doc->updateStyleSelector();
    626     view()->forceLayoutWithPageWidthRange(minPageWidth, maxPageWidth, adjustViewSize);
     626    view()->forceLayoutForPagination(pageSize, maximumShrinkRatio, shouldAdjustViewSize);
    627627
    628628    for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
    629         child->setPrinting(printing, minPageWidth, maxPageWidth, adjustViewSize);
     629        child->setPrinting(printing, pageSize, maximumShrinkRatio, shouldAdjustViewSize);
    630630}
    631631
  • trunk/WebCore/page/Frame.h

    r61324 r64409  
    141141        Settings* settings() const; // can be NULL
    142142
    143         void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
     143        enum AdjustViewSizeOrNot { DoNotAdjustViewSize, AdjustViewSize };
     144        void setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot);
    144145
    145146        bool inViewSourceMode() const;
  • trunk/WebCore/page/FrameView.cpp

    r64158 r64409  
    213213    m_lastLayoutSize = IntSize();
    214214    m_lastZoomFactor = 1.0f;
     215    m_pageHeight = 0;
    215216    m_deferringRepaints = 0;
    216217    m_repaintCount = 0;
     
    20432044}
    20442045
    2045 void FrameView::forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool _adjustViewSize)
     2046void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot shouldAdjustViewSize)
    20462047{
    20472048    // Dumping externalRepresentation(m_frame->renderer()).ascii() is a good trick to see
     
    20492050    RenderView *root = toRenderView(m_frame->document()->renderer());
    20502051    if (root) {
    2051         // This magic is basically copied from khtmlview::print
    2052         int pageW = (int)ceilf(minPageWidth);
     2052        int pageW = ceilf(pageSize.width());
     2053        m_pageHeight = pageSize.height() ? pageSize.height() : visibleHeight();
    20532054        root->setWidth(pageW);
    20542055        root->setNeedsLayoutAndPrefWidthsRecalc();
    20552056        forceLayout();
    20562057
    2057         // If we don't fit in the minimum page width, we'll lay out again. If we don't fit in the
    2058         // maximum page width, we will lay out to the maximum page width and clip extra content.
     2058        // If we don't fit in the given page width, we'll lay out again. If we don't fit in the
     2059        // page width when shrunk, we will lay out at maximum shrink and clip extra content.
    20592060        // FIXME: We are assuming a shrink-to-fit printing implementation.  A cropping
    20602061        // implementation should not do this!
    20612062        int rightmostPos = root->rightmostPosition();
    2062         if (rightmostPos > minPageWidth) {
    2063             pageW = std::min(rightmostPos, (int)ceilf(maxPageWidth));
     2063        if (rightmostPos > pageSize.width()) {
     2064            pageW = std::min<int>(rightmostPos, ceilf(pageSize.width() * maximumShrinkFactor));
     2065            if (pageSize.height())
     2066                m_pageHeight = pageW / pageSize.width() * pageSize.height();
    20642067            root->setWidth(pageW);
    20652068            root->setNeedsLayoutAndPrefWidthsRecalc();
     
    20682071    }
    20692072
    2070     if (_adjustViewSize)
     2073    if (shouldAdjustViewSize)
    20712074        adjustViewSize();
     2075    m_pageHeight = 0;
    20722076}
    20732077
  • trunk/WebCore/page/FrameView.h

    r64054 r64409  
    200200
    201201    void forceLayout(bool allowSubtree = false);
    202     void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool adjustViewSize);
     202    void forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot);
     203    int pageHeight() const { return m_pageHeight; }
    203204
    204205    void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit);
     
    333334    String m_mediaTypeWhenNotPrinting;
    334335
     336    int m_pageHeight;
     337
    335338    unsigned m_enqueueEvents;
    336339    Vector<ScheduledEvent*> m_scheduledEvents;
  • trunk/WebCore/page/PrintContext.cpp

    r64187 r64409  
    117117}
    118118
    119 void PrintContext::begin(float width)
     119void PrintContext::begin(float width, float height)
    120120{
    121121    ASSERT(!m_isPrinting);
     
    136136
    137137    float minLayoutWidth = width * PrintingMinimumShrinkFactor;
    138     float maxLayoutWidth = width * PrintingMaximumShrinkFactor;
     138    float minLayoutHeight = height * PrintingMinimumShrinkFactor;
    139139
    140140    // FIXME: This will modify the rendering of the on-screen frame.
    141141    // Could lead to flicker during printing.
    142     m_frame->setPrinting(true, minLayoutWidth, maxLayoutWidth, true);
     142    m_frame->setPrinting(true, FloatSize(minLayoutWidth, minLayoutHeight), PrintingMaximumShrinkFactor / PrintingMinimumShrinkFactor, Frame::AdjustViewSize);
    143143}
    144144
     
    160160    ASSERT(m_isPrinting);
    161161    m_isPrinting = false;
    162     m_frame->setPrinting(false, 0, 0, true);
     162    m_frame->setPrinting(false, FloatSize(), 0, Frame::AdjustViewSize);
    163163}
    164164
     
    186186    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
    187187    PrintContext printContext(frame);
    188     printContext.begin(pageRect.width());
    189     printContext.computePageRectsWithPageSize(pageSizeInPixels, false);
     188    printContext.begin(pageRect.width(), pageRect.height());
     189    FloatSize scaledPageSize = pageSizeInPixels;
     190    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
     191    printContext.computePageRectsWithPageSize(scaledPageSize, false);
    190192
    191193    int top = box->offsetTop();
     
    244246    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
    245247    PrintContext printContext(frame);
    246     printContext.begin(pageRect.width());
    247     printContext.computePageRectsWithPageSize(pageSizeInPixels, false);
     248    printContext.begin(pageRect.width(), pageRect.height());
     249    // Account for shrink-to-fit.
     250    FloatSize scaledPageSize = pageSizeInPixels;
     251    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
     252    printContext.computePageRectsWithPageSize(scaledPageSize, false);
    248253    return printContext.pageCount();
    249254}
     
    257262
    258263    PrintContext printContext(frame);
    259     printContext.begin(pageSizeInPixels.width());
     264    printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());
    260265
    261266    float pageHeight;
  • trunk/WebCore/page/PrintContext.h

    r63521 r64409  
    4747
    4848    // TODO: eliminate width param
    49     void begin(float width);
     49    void begin(float width, float height = 0);
    5050
    5151    // TODO: eliminate width param
  • trunk/WebCore/rendering/RenderBox.cpp

    r64272 r64409  
    15141514    if (stretchesToViewHeight() || printingNeedsBaseHeight) {
    15151515        int margins = collapsedMarginTop() + collapsedMarginBottom();
    1516         int visHeight = document()->printing() ? view()->frameView()->visibleHeight() : view()->viewHeight();
     1516        int visHeight = document()->printing() ? view()->frameView()->pageHeight() : view()->viewHeight();
    15171517        if (isRoot())
    15181518            setHeight(max(height(), visHeight - margins));
  • trunk/WebKit/mac/ChangeLog

    r64403 r64409  
     12010-07-30  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/8257783> Short documents may print a second blank page
     6        https://bugs.webkit.org/show_bug.cgi?id=43271
     7
     8        * WebView/WebHTMLView.mm:
     9        (-[WebHTMLView _web_setPrintingModeRecursive]): Updated for additional height parameter
     10        to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
     11        (-[WebHTMLView _web_clearPrintingModeRecursive]): Ditto.
     12        (-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): Ditto.
     13        (-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): Added height parameter,
     14        which is scaled and passed on to _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
     15        (-[WebHTMLView _endPrintMode]): Updated for additional height parameter to
     16        _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:.
     17        (-[WebHTMLView layoutToMinimumPageWidth:height:maximumPageWidth:adjustingViewSize:]): Added
     18        height parameter, which is passed on to FrameView::forceLayoutForPagination().
     19        (-[WebHTMLView layout]): Updated for additional height parameter.
     20        (-[WebHTMLView _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize:]): Added height
     21        parameter, which is passed on to -layoutToMinimumPageWidth:height:maximumPageWidth:adjustViewSize:.
     22        (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Updated for additional height
     23        parameter.
     24        (-[WebHTMLView setPageWidthForPrinting:]): Ditto.
     25        (-[WebHTMLView knowsPageRange:]): Pass the available height on the page on to
     26        _setPrinting:minimumPageWidth:height:maximumPageWidth:adjustViewSize.
     27        * WebView/WebHTMLViewPrivate.h:
     28
    1292010-07-30  Joseph Pecoraro  <joepeck@webkit.org>
    230
  • trunk/WebKit/mac/WebView/WebHTMLView.mm

    r63856 r64409  
    400400
    401401@interface WebHTMLView (WebForwardDeclaration) // FIXME: Put this in a normal category and stop doing the forward declaration trick.
    402 - (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
     402- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
    403403@end
    404404
     
    10411041- (void)_web_setPrintingModeRecursive
    10421042{
    1043     [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
     1043    [self _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
    10441044
    10451045#ifndef NDEBUG
     
    10531053    unsigned count = [descendantWebHTMLViews count];
    10541054    for (unsigned i = 0; i < count; ++i)
    1055         [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
     1055        [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
    10561056
    10571057    [descendantWebHTMLViews release];
     
    10641064- (void)_web_clearPrintingModeRecursive
    10651065{
    1066     [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
     1066    [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
    10671067
    10681068#ifndef NDEBUG
     
    10761076    unsigned count = [descendantWebHTMLViews count];
    10771077    for (unsigned i = 0; i < count; ++i)
    1078         [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
     1078        [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
    10791079
    10801080    [descendantWebHTMLViews release];
     
    10871087- (void)_web_setPrintingModeRecursiveAndAdjustViewSize
    10881088{
    1089     [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
     1089    [self _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:YES];
    10901090
    10911091#ifndef NDEBUG
     
    10991099    unsigned count = [descendantWebHTMLViews count];
    11001100    for (unsigned i = 0; i < count; ++i)
    1101         [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES];
     1101        [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:YES];
    11021102
    11031103    [descendantWebHTMLViews release];
     
    22312231}
    22322232
    2233 - (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth shrinkToFit:(BOOL)shrinkToFit
     2233- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth height:(float)pageHeight shrinkToFit:(BOOL)shrinkToFit
    22342234{
    22352235    Frame* frame = core([self _frame]);
     
    22382238
    22392239    float minLayoutWidth = 0;
     2240    float minLayoutHeight = 0;
    22402241    float maxLayoutWidth = 0;
    22412242
     
    22442245    if (!frame->document() || !frame->document()->isFrameSet()) {
    22452246        minLayoutWidth = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMinimumShrinkFactor : pageWidth;
     2247        minLayoutHeight = shrinkToFit ? pageHeight * _WebHTMLViewPrintingMinimumShrinkFactor : pageHeight;
    22462248        maxLayoutWidth = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMaximumShrinkFactor : pageWidth;
    22472249    }
    2248     [self _setPrinting:YES minimumPageWidth:minLayoutWidth maximumPageWidth:maxLayoutWidth adjustViewSize:YES];
     2250    [self _setPrinting:YES minimumPageWidth:minLayoutWidth height:minLayoutHeight maximumPageWidth:maxLayoutWidth adjustViewSize:YES];
    22492251
    22502252    return YES;
     
    22532255- (void)_endPrintMode
    22542256{
    2255     [self _setPrinting:NO minimumPageWidth:0 maximumPageWidth:0 adjustViewSize:YES];
     2257    [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:YES];
    22562258}
    22572259
     
    31053107// Do a layout, but set up a new fixed width for the purposes of doing printing layout.
    31063108// minPageWidth==0 implies a non-printing layout
    3107 - (void)layoutToMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize
     3109- (void)layoutToMinimumPageWidth:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustViewSize
    31083110{
    31093111    [self reapplyStyles];
     
    31243126    if (FrameView* coreView = coreFrame->view()) {
    31253127        if (minPageWidth > 0.0)
    3126             coreView->forceLayoutWithPageWidthRange(minPageWidth, maxPageWidth, adjustViewSize);
     3128            coreView->forceLayoutForPagination(FloatSize(minPageWidth, minPageHeight), maxPageWidth / minPageWidth, adjustViewSize ? Frame::AdjustViewSize : Frame::DoNotAdjustViewSize);
    31273129        else {
    31283130            coreView->forceLayout(!adjustViewSize);
     
    31403142- (void)layout
    31413143{
    3142     [self layoutToMinimumPageWidth:0.0f maximumPageWidth:0.0f adjustingViewSize:NO];
     3144    [self layoutToMinimumPageWidth:0 height:0 maximumPageWidth:0 adjustingViewSize:NO];
    31433145}
    31443146
     
    38213823// Does setNeedsDisplay:NO as a side effect when printing is ending.
    38223824// pageWidth != 0 implies we will relayout to a new width
    3823 - (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
     3825- (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth height:(float)minPageHeight maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
    38243826{
    38253827    WebFrame *frame = [self _frame];
     
    38313833        WebFrameView *frameView = [subframe frameView];
    38323834        if ([[subframe _dataSource] _isDocumentHTML]) {
    3833             [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:adjustViewSize];
     3835            [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:adjustViewSize];
    38343836        }
    38353837    }
     
    38433845        [self setNeedsToApplyStyles:YES];
    38443846        [self setNeedsLayout:YES];
    3845         [self layoutToMinimumPageWidth:minPageWidth maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
     3847        [self layoutToMinimumPageWidth:minPageWidth height:minPageHeight maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
    38463848        if (!printing) {
    38473849            // Can't do this when starting printing or nested printing won't work, see 3491427.
     
    38643866    BOOL wasInPrintingMode = _private->printing;
    38653867    if (!wasInPrintingMode)
    3866         [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
     3868        [self _setPrinting:YES minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
    38673869
    38683870    *newBottom = [self _adjustedBottomOfPageWithTop:oldTop bottom:oldBottom limit:bottomLimit];
     
    38753877        else
    38763878            // not sure if this is actually ever invoked, it probably shouldn't be
    3877             [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
     3879            [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
    38783880    }
    38793881}
     
    39053907- (void)setPageWidthForPrinting:(float)pageWidth
    39063908{
    3907     [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO];
    3908     [self _setPrinting:YES minimumPageWidth:pageWidth maximumPageWidth:pageWidth adjustViewSize:YES];
     3909    [self _setPrinting:NO minimumPageWidth:0 height:0 maximumPageWidth:0 adjustViewSize:NO];
     3910    [self _setPrinting:YES minimumPageWidth:pageWidth height:0 maximumPageWidth:pageWidth adjustViewSize:YES];
    39093911}
    39103912
     
    39493951    [[self window] setAutodisplay:NO];   
    39503952
     3953    [[self _webView] _adjustPrintingMarginsForHeaderAndFooter];
    39513954    NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
    3952     if (![self _beginPrintModeWithPageWidth:[printOperation _web_availablePaperWidth] shrinkToFit:YES])
     3955    if (![self _beginPrintModeWithPageWidth:[printOperation _web_availablePaperWidth] height:[printOperation _web_availablePaperHeight] shrinkToFit:YES])
    39533956        return NO;
    39543957
     
    39603963    // which is after beginDocument and endDocument would be called.
    39613964    [self performSelector:@selector(_delayedEndPrintMode:) withObject:printOperation afterDelay:0];
    3962     [[self _webView] _adjustPrintingMarginsForHeaderAndFooter];
    39633965   
    39643966    // There is a theoretical chance that someone could do some drawing between here and endDocument,
  • trunk/WebKit/mac/WebView/WebHTMLViewPrivate.h

    r57723 r64409  
    136136- (WebCGFloat)_adjustedBottomOfPageWithTop:(WebCGFloat)top bottom:(WebCGFloat)bottom limit:(WebCGFloat)bottomLimit;
    137137- (BOOL)_isInPrintMode;
    138 - (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth shrinkToFit:(BOOL)shrinkToFit;
     138- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth height:(float)pageHeight shrinkToFit:(BOOL)shrinkToFit;
    139139- (void)_endPrintMode;
    140140
  • trunk/WebKit/win/ChangeLog

    r64400 r64409  
     12010-07-30  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/8257783> Short documents may print a second blank page
     6        https://bugs.webkit.org/show_bug.cgi?id=43271
     7
     8        * WebFrame.cpp:
     9        (WebFrame::setPrinting): Updated for changes to Frame::setPrinting(). Passing 0 for the
     10        page height, which maintains existing behavior.
     11
    1122010-07-30  Joseph Pecoraro  <joepeck@webkit.org>
    213
  • trunk/WebKit/win/WebFrame.cpp

    r61572 r64409  
    19401940    Frame* coreFrame = core(this);
    19411941    ASSERT(coreFrame);
    1942     coreFrame->setPrinting(printing, minPageWidth, maxPageWidth, adjustViewSize);
     1942    coreFrame->setPrinting(printing, FloatSize(minPageWidth, 0), maxPageWidth / minPageWidth, adjustViewSize ? Frame::AdjustViewSize : Frame:DoNotAdjustViewSize);
    19431943}
    19441944
Note: See TracChangeset for help on using the changeset viewer.