Changeset 95249 in webkit


Ignore:
Timestamp:
Sep 15, 2011 6:17:37 PM (13 years ago)
Author:
haraken@google.com
Message:

A single line must not be split into two pages.
https://bugs.webkit.org/show_bug.cgi?id=65005

Reviewed by David Hyatt.

When the document width of a page is overflowed, the last line of the page can be
split into the next page. This is the regression caused by r88737. r88737 tried to
fix rounding errors in rendering calculations by expanding and shrinking a page
using one common method, resizePageRectsKeepingRatio(), but overlooked the case where
a document width gets overflowed.

Source/WebCore:

This patch fixes the problem by also using resizePageRectsKeepingRatio() for the case
where the document width gets overflowed.

Test: printing/single-line-must-not-be-split-into-two-pages.html

  • WebCore.exp.in: Updated the signature of forceLayoutForPagination().
  • page/Frame.cpp:

(WebCore::Frame::setPrinting): Added a new argument |originalPageSize|, which is an original page size before being expanded or shrunk.

  • page/Frame.h:
  • page/FrameView.cpp:

(WebCore::FrameView::forceLayoutForPagination): Uses resizePageRectsKeepingRatio() in the case where the document width gets overflowed.

  • page/FrameView.h:
  • page/PrintContext.cpp:

(WebCore::PrintContext::begin): Passes an original page size to setPrinting().
(WebCore::PrintContext::end): Ditto.

Source/WebKit/mac:

Test: printing/single-line-must-not-be-split-into-two-pages.html

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _web_setPrintingModeRecursive]): Passes an original page size to setPrinting().
(-[WebHTMLView _web_clearPrintingModeRecursive]): Ditto.
(-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): Ditto.
(-[WebHTMLView _beginPrintModeWithMinimumPageWidth:height:maximumPageWidth:]): Ditto.
(-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): Ditto.
(-[WebHTMLView _endPrintMode]): Ditto.
(-[WebHTMLView _beginScreenPaginationModeWithPageSize:shrinkToFit:]): Ditto.
(-[WebHTMLView _endScreenPaginationMode]): Ditto.
(-[WebHTMLView layoutToMinimumPageWidth:height:originalPageWidth:originalPageHeight:maximumShrinkRatio:adjustingViewSize:]): Ditto.
(-[WebHTMLView layout]): Ditto.
(-[WebHTMLView _setPrinting:minimumPageLogicalWidth:logicalHeight:originalPageWidth:originalPageHeight:maximumShrinkRatio:adjustViewSize:paginateScreenContent:]): Ditto.
(-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Ditto.
(-[WebHTMLView setPageWidthForPrinting:]): Ditto.

Source/WebKit/win:

Test: printing/single-line-must-not-be-split-into-two-pages.html

  • WebFrame.cpp:

(WebFrame::setPrinting): Passes an original page size to setPrinting().
(WebFrame::setInPrintingMode): Ditto.

  • WebFrame.h:

LayoutTests:

The added test checks if the last line does not split across pages.

  • platform/chromium/test_expectations.txt: Skipped the added test since setPrinting() is not yet implemented.
  • platform/gtk/Skipped: Ditto.
  • platform/mac/printing/single-line-must-not-be-split-into-two-pages-expected.txt: Added.
  • platform/qt/Skipped: Ditto.
  • platform/win/Skipped: Ditto.
  • platform/wk2/Skipped: Ditto.
  • printing/single-line-must-not-be-split-into-two-pages.html: Added.
Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95242 r95249  
     12011-09-15  Kentaro Hara  <haraken@google.com>
     2
     3        A single line must not be split into two pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=65005
     5
     6        Reviewed by David Hyatt.
     7
     8        When the document width of a page is overflowed, the last line of the page can be
     9        split into the next page. This is the regression caused by r88737. r88737 tried to
     10        fix rounding errors in rendering calculations by expanding and shrinking a page
     11        using one common method, resizePageRectsKeepingRatio(), but overlooked the case where
     12        a document width gets overflowed.
     13
     14        The added test checks if the last line does not split across pages.
     15
     16        * platform/chromium/test_expectations.txt: Skipped the added test since setPrinting() is not yet implemented.
     17        * platform/gtk/Skipped: Ditto.
     18        * platform/mac/printing/single-line-must-not-be-split-into-two-pages-expected.txt: Added.
     19        * platform/qt/Skipped: Ditto.
     20        * platform/win/Skipped: Ditto.
     21        * platform/wk2/Skipped: Ditto.
     22        * printing/single-line-must-not-be-split-into-two-pages.html: Added.
     23
    1242011-09-15  David Hyatt  <hyatt@apple.com>
    225
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r95241 r95249  
    21042104// Need setPrinting.
    21052105BUGWK20011 : printing/setPrinting.html = FAIL
     2106BUGWK65005 : printing/single-line-must-not-be-split-into-two-pages.html = FAIL
    21062107
    21072108// Needs V8 change.
  • trunk/LayoutTests/platform/gtk/Skipped

    r94925 r95249  
    12451245# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
    12461246printing/setPrinting.html
     1247printing/single-line-must-not-be-split-into-two-pages.html
    12471248
    12481249# Accuracy problems in the results
  • trunk/LayoutTests/platform/qt/Skipped

    r94848 r95249  
    16841684# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
    16851685printing/setPrinting.html
     1686printing/single-line-must-not-be-split-into-two-pages.html
    16861687
    16871688# Web Timing related bugs
  • trunk/LayoutTests/platform/win/Skipped

    r94405 r95249  
    11301130# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
    11311131printing/setPrinting.html
     1132printing/single-line-must-not-be-split-into-two-pages.html
    11321133
    11331134# Need to call Settings::setInteractiveFormValidationEnabled(true).
  • trunk/LayoutTests/platform/wk2/Skipped

    r95039 r95249  
    701701printing/page-rule-in-media-query.html
    702702printing/setPrinting.html
     703printing/single-line-must-not-be-split-into-two-pages.html
    703704printing/simultaneous-position-float-change.html
    704705
  • trunk/Source/WebCore/ChangeLog

    r95248 r95249  
     12011-09-15  Kentaro Hara  <haraken@google.com>
     2
     3        A single line must not be split into two pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=65005
     5
     6        Reviewed by David Hyatt.
     7
     8        When the document width of a page is overflowed, the last line of the page can be
     9        split into the next page. This is the regression caused by r88737. r88737 tried to
     10        fix rounding errors in rendering calculations by expanding and shrinking a page
     11        using one common method, resizePageRectsKeepingRatio(), but overlooked the case where
     12        a document width gets overflowed.
     13
     14        This patch fixes the problem by also using resizePageRectsKeepingRatio() for the case
     15        where the document width gets overflowed.
     16
     17        Test: printing/single-line-must-not-be-split-into-two-pages.html
     18
     19        * WebCore.exp.in: Updated the signature of forceLayoutForPagination().
     20        * page/Frame.cpp:
     21        (WebCore::Frame::setPrinting): Added a new argument |originalPageSize|, which is an original page size before being expanded or shrunk.
     22        * page/Frame.h:
     23        * page/FrameView.cpp:
     24        (WebCore::FrameView::forceLayoutForPagination): Uses resizePageRectsKeepingRatio() in the case where the document width gets overflowed.
     25        * page/FrameView.h:
     26        * page/PrintContext.cpp:
     27        (WebCore::PrintContext::begin): Passes an original page size to setPrinting().
     28        (WebCore::PrintContext::end): Ditto.
     29
    1302011-09-15  Sheriff Bot  <webkit.review.bot@gmail.com>
    231
  • trunk/Source/WebCore/WebCore.exp.in

    r95216 r95249  
    974974__ZN7WebCore9FrameView22setBaseBackgroundColorERKNS_5ColorE
    975975__ZN7WebCore9FrameView23updateCanHaveScrollbarsEv
    976 __ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeEfNS_19AdjustViewSizeOrNotE
     976__ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeES3_fNS_19AdjustViewSizeOrNotE
    977977__ZN7WebCore9FrameView25serviceScriptedAnimationsEy
    978978__ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff
  • trunk/Source/WebCore/page/Frame.cpp

    r95093 r95249  
    504504}
    505505
    506 void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
     506void Frame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
    507507{
    508508    // In setting printing, we should not validate resources already cached for the document.
     
    515515    m_doc->styleSelectorChanged(RecalcStyleImmediately);
    516516    if (printing)
    517         view()->forceLayoutForPagination(pageSize, maximumShrinkRatio, shouldAdjustViewSize);
     517        view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
    518518    else {
    519519        view()->forceLayout();
     
    524524    // Subframes of the one we're printing don't lay out to the page size.
    525525    for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
    526         child->setPrinting(printing, IntSize(), 0, shouldAdjustViewSize);
     526        child->setPrinting(printing, FloatSize(), FloatSize(), 0, shouldAdjustViewSize);
    527527}
    528528
  • trunk/Source/WebCore/page/Frame.h

    r94889 r95249  
    148148        Settings* settings() const; // can be NULL
    149149
    150         void setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot);
     150        void setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot);
    151151        FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize);
    152152
  • trunk/Source/WebCore/page/FrameView.cpp

    r95158 r95249  
    28062806}
    28072807
    2808 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, AdjustViewSizeOrNot shouldAdjustViewSize)
     2808void FrameView::forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot shouldAdjustViewSize)
    28092809{
    28102810    // Dumping externalRepresentation(m_frame->renderer()).ascii() is a good trick to see
     
    28162816
    28172817        LayoutUnit flooredPageLogicalWidth = static_cast<LayoutUnit>(pageLogicalWidth);
     2818        LayoutUnit flooredPageLogicalHeight = static_cast<LayoutUnit>(pageLogicalHeight);
    28182819        root->setLogicalWidth(flooredPageLogicalWidth);
    2819         root->setPageLogicalHeight(pageLogicalHeight);
     2820        root->setPageLogicalHeight(flooredPageLogicalHeight);
    28202821        root->setNeedsLayoutAndPrefWidthsRecalc();
    28212822        forceLayout();
    2822        
     2823
    28232824        // If we don't fit in the given page width, we'll lay out again. If we don't fit in the
    28242825        // page width when shrunk, we will lay out at maximum shrink and clip extra content.
     
    28262827        // implementation should not do this!
    28272828        bool horizontalWritingMode = root->style()->isHorizontalWritingMode();
    2828         LayoutUnit docLogicalWidth = horizontalWritingMode ? root->documentRect().width() : root->documentRect().height();
     2829        const LayoutRect& documentRect = root->documentRect();
     2830        LayoutUnit docLogicalWidth = horizontalWritingMode ? documentRect.width() : documentRect.height();
    28292831        if (docLogicalWidth > pageLogicalWidth) {
    2830             flooredPageLogicalWidth = std::min<float>(docLogicalWidth, pageLogicalWidth * maximumShrinkFactor);
    2831             if (pageLogicalHeight)
    2832                 root->setPageLogicalHeight(flooredPageLogicalWidth / pageSize.width() * pageSize.height());
     2832            int expectedPageWidth = std::min<float>(documentRect.width(), originalPageSize.width() * maximumShrinkFactor);
     2833            int expectedPageHeight = std::min<float>(documentRect.height(), originalPageSize.height() * maximumShrinkFactor);
     2834            FloatSize maxPageSize = m_frame->resizePageRectsKeepingRatio(FloatSize(originalPageSize.width(), originalPageSize.height()), FloatSize(expectedPageWidth, expectedPageHeight));
     2835            pageLogicalWidth = horizontalWritingMode ? maxPageSize.width() : maxPageSize.height();
     2836            pageLogicalHeight = horizontalWritingMode ? maxPageSize.height() : maxPageSize.width();
     2837
     2838            flooredPageLogicalWidth = static_cast<LayoutUnit>(pageLogicalWidth);
     2839            flooredPageLogicalHeight = static_cast<LayoutUnit>(pageLogicalHeight);
    28332840            root->setLogicalWidth(flooredPageLogicalWidth);
     2841            root->setPageLogicalHeight(flooredPageLogicalHeight);
    28342842            root->setNeedsLayoutAndPrefWidthsRecalc();
    28352843            forceLayout();
    2836             const LayoutRect& documentRect = root->documentRect();
    2837             LayoutUnit docLogicalHeight = horizontalWritingMode ? documentRect.height() : documentRect.width();
    2838             LayoutUnit docLogicalTop = horizontalWritingMode ? documentRect.y() : documentRect.x();
    2839             LayoutUnit docLogicalRight = horizontalWritingMode ? documentRect.maxX() : documentRect.maxY();
     2844
     2845            const LayoutRect& updatedDocumentRect = root->documentRect();
     2846            LayoutUnit docLogicalHeight = horizontalWritingMode ? updatedDocumentRect.height() : updatedDocumentRect.width();
     2847            LayoutUnit docLogicalTop = horizontalWritingMode ? updatedDocumentRect.y() : updatedDocumentRect.x();
     2848            LayoutUnit docLogicalRight = horizontalWritingMode ? updatedDocumentRect.maxX() : updatedDocumentRect.maxY();
    28402849            LayoutUnit clippedLogicalLeft = 0;
    28412850            if (!root->style()->isLeftToRightDirection())
    2842                 clippedLogicalLeft = docLogicalRight - flooredPageLogicalWidth;
    2843             LayoutRect overflow(clippedLogicalLeft, docLogicalTop, flooredPageLogicalWidth, docLogicalHeight);
     2851                clippedLogicalLeft = docLogicalRight - pageLogicalWidth;
     2852            LayoutRect overflow(clippedLogicalLeft, docLogicalTop, pageLogicalWidth, docLogicalHeight);
     2853
    28442854            if (!horizontalWritingMode)
    28452855                overflow = overflow.transposedRect();
  • trunk/Source/WebCore/page/FrameView.h

    r95158 r95249  
    236236
    237237    void forceLayout(bool allowSubtree = false);
    238     void forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
     238    void forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot);
    239239
    240240    // FIXME: This method is retained because of embedded WebViews in AppKit.  When a WebView is embedded inside
  • trunk/Source/WebCore/page/PrintContext.cpp

    r88737 r95249  
    166166    m_isPrinting = true;
    167167
    168     FloatSize minLayoutSize = m_frame->resizePageRectsKeepingRatio(FloatSize(width, height), FloatSize(width * printingMinimumShrinkFactor, height * printingMinimumShrinkFactor));
     168    FloatSize originalPageSize = FloatSize(width, height);
     169    FloatSize minLayoutSize = m_frame->resizePageRectsKeepingRatio(originalPageSize, FloatSize(width * printingMinimumShrinkFactor, height * printingMinimumShrinkFactor));
    169170
    170171    // This changes layout, so callers need to make sure that they don't paint to screen while in printing mode.
    171     m_frame->setPrinting(true, minLayoutSize, printingMaximumShrinkFactor / printingMinimumShrinkFactor, AdjustViewSize);
     172    m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumShrinkFactor / printingMinimumShrinkFactor, AdjustViewSize);
    172173}
    173174
     
    218219    ASSERT(m_isPrinting);
    219220    m_isPrinting = false;
    220     m_frame->setPrinting(false, FloatSize(), 0, AdjustViewSize);
     221    m_frame->setPrinting(false, FloatSize(), FloatSize(), 0, AdjustViewSize);
    221222}
    222223
  • trunk/Source/WebKit/mac/ChangeLog

    r95234 r95249  
     12011-09-15  Kentaro Hara  <haraken@google.com>
     2
     3        A single line must not be split into two pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=65005
     5
     6        Reviewed by David Hyatt.
     7
     8        When the document width of a page is overflowed, the last line of the page can be
     9        split into the next page. This is the regression caused by r88737. r88737 tried to
     10        fix rounding errors in rendering calculations by expanding and shrinking a page
     11        using one common method, resizePageRectsKeepingRatio(), but overlooked the case where
     12        a document width gets overflowed.
     13
     14        Test: printing/single-line-must-not-be-split-into-two-pages.html
     15
     16        * WebView/WebHTMLView.mm:
     17        (-[WebHTMLView _web_setPrintingModeRecursive]): Passes an original page size to setPrinting().
     18        (-[WebHTMLView _web_clearPrintingModeRecursive]): Ditto.
     19        (-[WebHTMLView _web_setPrintingModeRecursiveAndAdjustViewSize]): Ditto.
     20        (-[WebHTMLView _beginPrintModeWithMinimumPageWidth:height:maximumPageWidth:]): Ditto.
     21        (-[WebHTMLView _beginPrintModeWithPageWidth:height:shrinkToFit:]): Ditto.
     22        (-[WebHTMLView _endPrintMode]): Ditto.
     23        (-[WebHTMLView _beginScreenPaginationModeWithPageSize:shrinkToFit:]): Ditto.
     24        (-[WebHTMLView _endScreenPaginationMode]): Ditto.
     25        (-[WebHTMLView layoutToMinimumPageWidth:height:originalPageWidth:originalPageHeight:maximumShrinkRatio:adjustingViewSize:]): Ditto.
     26        (-[WebHTMLView layout]): Ditto.
     27        (-[WebHTMLView _setPrinting:minimumPageLogicalWidth:logicalHeight:originalPageWidth:originalPageHeight:maximumShrinkRatio:adjustViewSize:paginateScreenContent:]): Ditto.
     28        (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Ditto.
     29        (-[WebHTMLView setPageWidthForPrinting:]): Ditto.
     30
    1312011-09-15  Eric Seidel  <eric@webkit.org>
    232
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r94613 r95249  
    413413
    414414@interface WebHTMLView (WebForwardDeclaration) // FIXME: Put this in a normal category and stop doing the forward declaration trick.
    415 - (void)_setPrinting:(BOOL)printing minimumPageLogicalWidth:(float)minPageWidth logicalHeight:(float)minPageHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent;
     415- (void)_setPrinting:(BOOL)printing minimumPageLogicalWidth:(float)minPageWidth logicalHeight:(float)minPageHeight originalPageWidth:(float)pageLogicalWidth originalPageHeight:(float)pageLogicalHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent;
    416416- (void)_updateSecureInputState;
    417417@end
     
    10611061- (void)_web_setPrintingModeRecursive
    10621062{
    1063     [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     1063    [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    10641064
    10651065#ifndef NDEBUG
     
    10731073    unsigned count = [descendantWebHTMLViews count];
    10741074    for (unsigned i = 0; i < count; ++i)
    1075         [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     1075        [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    10761076
    10771077    [descendantWebHTMLViews release];
     
    10841084- (void)_web_clearPrintingModeRecursive
    10851085{
    1086     [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     1086    [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    10871087
    10881088#ifndef NDEBUG
     
    10961096    unsigned count = [descendantWebHTMLViews count];
    10971097    for (unsigned i = 0; i < count; ++i)
    1098         [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     1098        [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    10991099
    11001100    [descendantWebHTMLViews release];
     
    11071107- (void)_web_setPrintingModeRecursiveAndAdjustViewSize
    11081108{
    1109     [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     1109    [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    11101110
    11111111#ifndef NDEBUG
     
    11191119    unsigned count = [descendantWebHTMLViews count];
    11201120    for (unsigned i = 0; i < count; ++i)
    1121         [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     1121        [[descendantWebHTMLViews objectAtIndex:i] _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    11221122
    11231123    [descendantWebHTMLViews release];
     
    21232123        maximumShrinkRatio = maximumPageWidth / minimumPageWidth;
    21242124
    2125     [self _setPrinting:YES minimumPageLogicalWidth:minimumPageWidth logicalHeight:minimumPageHeight maximumShrinkRatio:maximumShrinkRatio adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     2125    [self _setPrinting:YES minimumPageLogicalWidth:minimumPageWidth logicalHeight:minimumPageHeight originalPageWidth:minimumPageWidth originalPageHeight:minimumPageHeight maximumShrinkRatio:maximumShrinkRatio adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    21262126    return YES;
    21272127}
     
    21482148    }
    21492149
    2150     [self _setPrinting:YES minimumPageLogicalWidth:minLayoutSize.width() logicalHeight:minLayoutSize.height() maximumShrinkRatio:maximumShrinkRatio adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     2150    [self _setPrinting:YES minimumPageLogicalWidth:minLayoutSize.width() logicalHeight:minLayoutSize.height() originalPageWidth:pageLogicalWidth originalPageHeight:pageLogicalHeight maximumShrinkRatio:maximumShrinkRatio adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    21512151
    21522152    return YES;
     
    21552155- (void)_endPrintMode
    21562156{
    2157     [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     2157    [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    21582158}
    21592159
     
    21842184    }
    21852185
    2186     [self _setPrinting:[self _isInPrintMode] minimumPageLogicalWidth:minLayoutSize.width() logicalHeight:minLayoutSize.height() maximumShrinkRatio:maximumShrinkRatio adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     2186    [self _setPrinting:[self _isInPrintMode] minimumPageLogicalWidth:minLayoutSize.width() logicalHeight:minLayoutSize.height() originalPageWidth:pageLogicalWidth originalPageHeight:pageLogicalHeight maximumShrinkRatio:maximumShrinkRatio adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    21872187
    21882188    return YES;
     
    21912191- (void)_endScreenPaginationMode
    21922192{
    2193     [self _setPrinting:[self _isInPrintMode] minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:NO];
     2193    [self _setPrinting:[self _isInPrintMode] minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:YES paginateScreenContent:NO];
    21942194}
    21952195
     
    29962996// Do a layout, but set up a new fixed width for the purposes of doing printing layout.
    29972997// minPageWidth==0 implies a non-printing layout
    2998 - (void)layoutToMinimumPageWidth:(float)minPageLogicalWidth height:(float)minPageLogicalHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustingViewSize:(BOOL)adjustViewSize
     2998- (void)layoutToMinimumPageWidth:(float)minPageLogicalWidth height:(float)minPageLogicalHeight originalPageWidth:(float)originalPageWidth originalPageHeight:(float)originalPageHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustingViewSize:(BOOL)adjustViewSize
    29992999{   
    30003000    if (![self _needsLayout])
     
    30143014        if (minPageLogicalWidth > 0.0) {
    30153015            FloatSize pageSize(minPageLogicalWidth, minPageLogicalHeight);
    3016             if (coreFrame->document() && coreFrame->document()->renderView() && !coreFrame->document()->renderView()->style()->isHorizontalWritingMode())
     3016            FloatSize originalPageSize(originalPageWidth, originalPageHeight);
     3017            if (coreFrame->document() && coreFrame->document()->renderView() && !coreFrame->document()->renderView()->style()->isHorizontalWritingMode()) {
    30173018                pageSize = FloatSize(minPageLogicalHeight, minPageLogicalWidth);
    3018             coreView->forceLayoutForPagination(pageSize, maximumShrinkRatio, adjustViewSize ? AdjustViewSize : DoNotAdjustViewSize);
     3019                originalPageSize = FloatSize(originalPageHeight, originalPageWidth);
     3020            }
     3021            coreView->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, adjustViewSize ? AdjustViewSize : DoNotAdjustViewSize);
    30193022        } else {
    30203023            coreView->forceLayout(!adjustViewSize);
     
    30323035- (void)layout
    30333036{
    3034     [self layoutToMinimumPageWidth:0 height:0 maximumShrinkRatio:0 adjustingViewSize:NO];
     3037    [self layoutToMinimumPageWidth:0 height:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustingViewSize:NO];
    30353038}
    30363039
     
    37903793// Does setNeedsDisplay:NO as a side effect when printing is ending.
    37913794// pageWidth != 0 implies we will relayout to a new width
    3792 - (void)_setPrinting:(BOOL)printing minimumPageLogicalWidth:(float)minPageLogicalWidth logicalHeight:(float)minPageLogicalHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent
     3795- (void)_setPrinting:(BOOL)printing minimumPageLogicalWidth:(float)minPageLogicalWidth logicalHeight:(float)minPageLogicalHeight originalPageWidth:(float)originalPageWidth originalPageHeight:(float)originalPageHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustViewSize:(BOOL)adjustViewSize paginateScreenContent:(BOOL)paginateScreenContent
    37933796{
    37943797    if (printing == _private->printing && paginateScreenContent == _private->paginateScreenContent)
     
    38033806        WebFrameView *frameView = [subframe frameView];
    38043807        if ([[subframe _dataSource] _isDocumentHTML]) {
    3805             [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:adjustViewSize paginateScreenContent:paginateScreenContent];
     3808            [(WebHTMLView *)[frameView documentView] _setPrinting:printing minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:adjustViewSize paginateScreenContent:paginateScreenContent];
    38063809        }
    38073810    }
     
    38283831
    38293832    [self setNeedsLayout:YES];
    3830     [self layoutToMinimumPageWidth:minPageLogicalWidth height:minPageLogicalHeight maximumShrinkRatio:maximumShrinkRatio adjustingViewSize:adjustViewSize];
     3833    [self layoutToMinimumPageWidth:minPageLogicalWidth height:minPageLogicalHeight originalPageWidth:originalPageWidth originalPageHeight:originalPageHeight maximumShrinkRatio:maximumShrinkRatio adjustingViewSize:adjustViewSize];
    38313834    if (!printing) {
    38323835        // Can't do this when starting printing or nested printing won't work, see 3491427.
     
    38483851    BOOL wasInPrintingMode = _private->printing;
    38493852    if (!wasInPrintingMode)
    3850         [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     3853        [self _setPrinting:YES minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    38513854
    38523855    *newBottom = [self _adjustedBottomOfPageWithTop:oldTop bottom:oldBottom limit:bottomLimit];
     
    38593862        else
    38603863            // not sure if this is actually ever invoked, it probably shouldn't be
    3861             [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     3864            [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    38623865    }
    38633866}
     
    38963899- (void)setPageWidthForPrinting:(float)pageWidth
    38973900{
    3898     [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
    3899     [self _setPrinting:YES minimumPageLogicalWidth:pageWidth logicalHeight:0 maximumShrinkRatio:1 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
     3901    [self _setPrinting:NO minimumPageLogicalWidth:0 logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustViewSize:NO paginateScreenContent:[self _isInScreenPaginationMode]];
     3902    [self _setPrinting:YES minimumPageLogicalWidth:pageWidth logicalHeight:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:1 adjustViewSize:YES paginateScreenContent:[self _isInScreenPaginationMode]];
    39003903}
    39013904
  • trunk/Source/WebKit/win/ChangeLog

    r94613 r95249  
     12011-09-15  Kentaro Hara  <haraken@google.com>
     2
     3        A single line must not be split into two pages.
     4        https://bugs.webkit.org/show_bug.cgi?id=65005
     5
     6        Reviewed by David Hyatt.
     7
     8        When the document width of a page is overflowed, the last line of the page can be
     9        split into the next page. This is the regression caused by r88737. r88737 tried to
     10        fix rounding errors in rendering calculations by expanding and shrinking a page
     11        using one common method, resizePageRectsKeepingRatio(), but overlooked the case where
     12        a document width gets overflowed.
     13
     14        Test: printing/single-line-must-not-be-split-into-two-pages.html
     15
     16        * WebFrame.cpp:
     17        (WebFrame::setPrinting): Passes an original page size to setPrinting().
     18        (WebFrame::setInPrintingMode): Ditto.
     19        * WebFrame.h:
     20
    1212011-09-06  Ryosuke Niwa  <rniwa@webkit.org>
    222
  • trunk/Source/WebKit/win/WebFrame.cpp

    r91797 r95249  
    20112011}
    20122012
    2013 void WebFrame::setPrinting(bool printing, float minPageWidth, float minPageHeight, float maximumShrinkRatio, bool adjustViewSize)
     2013void WebFrame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot adjustViewSize)
    20142014{
    20152015    Frame* coreFrame = core(this);
    20162016    ASSERT(coreFrame);
    2017     coreFrame->setPrinting(printing, FloatSize(minPageWidth, minPageHeight), maximumShrinkRatio, adjustViewSize ? AdjustViewSize : DoNotAdjustViewSize);
     2017    coreFrame->setPrinting(printing, pageSize, originalPageSize, maximumShrinkRatio, adjustViewSize ? AdjustViewSize : DoNotAdjustViewSize);
    20182018}
    20192019
     
    20342034    // according to the paper size
    20352035    FloatSize minLayoutSize(0.0, 0.0);
     2036    FloatSize originalPageSize(0.0, 0.0);
    20362037    if (m_inPrintingMode && !coreFrame->document()->isFrameSet()) {
    20372038        if (!printDC) {
     
    20432044        IntRect printRect = printerRect(printDC);
    20442045        int paperHorizontalPixelsPerInch = ::GetDeviceCaps(printDC, LOGPIXELSX);
     2046        int paperVerticalPixelsPerInch = ::GetDeviceCaps(printDC, LOGPIXELSY);
    20452047        int paperWidth = printRect.width() * desiredPixelsPerInch / paperHorizontalPixelsPerInch;
    2046         int paperVerticalPixelsPerInch = ::GetDeviceCaps(printDC, LOGPIXELSY);
    20472048        int paperHeight = printRect.height() * desiredPixelsPerInch / paperVerticalPixelsPerInch;
     2049        originalPageSize = FloatSize(paperWidth, paperHeight);
    20482050        Frame* coreFrame = core(this);
    2049         minLayoutSize = coreFrame->resizePageRectsKeepingRatio(FloatSize(paperWidth, paperHeight), FloatSize(paperWidth * PrintingMinimumShrinkFactor, paperHeight * PrintingMinimumShrinkFactor));
    2050     }
    2051 
    2052     setPrinting(m_inPrintingMode, minLayoutSize.width(), minLayoutSize.height(), PrintingMaximumShrinkFactor / PrintingMinimumShrinkFactor, true);
     2051        minLayoutSize = coreFrame->resizePageRectsKeepingRatio(originalPageSize, FloatSize(paperWidth * PrintingMinimumShrinkFactor, paperHeight * PrintingMinimumShrinkFactor));
     2052    }
     2053
     2054    setPrinting(m_inPrintingMode, minLayoutSize, originalPageSize, PrintingMaximumShrinkFactor / PrintingMinimumShrinkFactor, AdjustViewSize);
    20532055
    20542056    if (!m_inPrintingMode)
  • trunk/Source/WebKit/win/WebFrame.h

    r91797 r95249  
    3434#include "AccessibleDocument.h"
    3535
     36#include <WebCore/AdjustViewSizeOrNot.h>
    3637#include <WebCore/FrameWin.h>
    3738#include <WebCore/GraphicsContext.h>
     
    4849    class DocumentLoader;
    4950    class Element;
     51    class FloatSize;
    5052    class Frame;
    5153    class GraphicsContext;
     
    392394    void loadData(PassRefPtr<WebCore::SharedBuffer>, BSTR mimeType, BSTR textEncodingName, BSTR baseURL, BSTR failingURL);
    393395    const Vector<WebCore::IntRect>& computePageRects(HDC printDC);
    394     void setPrinting(bool printing, float minPageWidth, float minPageHeight, float maximumShrinkRatio, bool adjustViewSize);
     396    void setPrinting(bool printing, const WebCore::FloatSize& pageSize, const WebCore::FloatSize& originalPageSize, float maximumShrinkRatio, WebCore::AdjustViewSizeOrNot);
    395397    void headerAndFooterHeights(float*, float*);
    396398    WebCore::IntRect printerMarginRect(HDC);
Note: See TracChangeset for help on using the changeset viewer.