Changeset 95249 in webkit
- Timestamp:
- Sep 15, 2011 6:17:37 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r95242 r95249 1 2011-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 1 24 2011-09-15 David Hyatt <hyatt@apple.com> 2 25 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r95241 r95249 2104 2104 // Need setPrinting. 2105 2105 BUGWK20011 : printing/setPrinting.html = FAIL 2106 BUGWK65005 : printing/single-line-must-not-be-split-into-two-pages.html = FAIL 2106 2107 2107 2108 // Needs V8 change. -
trunk/LayoutTests/platform/gtk/Skipped
r94925 r95249 1245 1245 # Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011 1246 1246 printing/setPrinting.html 1247 printing/single-line-must-not-be-split-into-two-pages.html 1247 1248 1248 1249 # Accuracy problems in the results -
trunk/LayoutTests/platform/qt/Skipped
r94848 r95249 1684 1684 # Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011 1685 1685 printing/setPrinting.html 1686 printing/single-line-must-not-be-split-into-two-pages.html 1686 1687 1687 1688 # Web Timing related bugs -
trunk/LayoutTests/platform/win/Skipped
r94405 r95249 1130 1130 # Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011 1131 1131 printing/setPrinting.html 1132 printing/single-line-must-not-be-split-into-two-pages.html 1132 1133 1133 1134 # Need to call Settings::setInteractiveFormValidationEnabled(true). -
trunk/LayoutTests/platform/wk2/Skipped
r95039 r95249 701 701 printing/page-rule-in-media-query.html 702 702 printing/setPrinting.html 703 printing/single-line-must-not-be-split-into-two-pages.html 703 704 printing/simultaneous-position-float-change.html 704 705 -
trunk/Source/WebCore/ChangeLog
r95248 r95249 1 2011-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 1 30 2011-09-15 Sheriff Bot <webkit.review.bot@gmail.com> 2 31 -
trunk/Source/WebCore/WebCore.exp.in
r95216 r95249 974 974 __ZN7WebCore9FrameView22setBaseBackgroundColorERKNS_5ColorE 975 975 __ZN7WebCore9FrameView23updateCanHaveScrollbarsEv 976 __ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeE fNS_19AdjustViewSizeOrNotE976 __ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeES3_fNS_19AdjustViewSizeOrNotE 977 977 __ZN7WebCore9FrameView25serviceScriptedAnimationsEy 978 978 __ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff -
trunk/Source/WebCore/page/Frame.cpp
r95093 r95249 504 504 } 505 505 506 void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)506 void Frame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize) 507 507 { 508 508 // In setting printing, we should not validate resources already cached for the document. … … 515 515 m_doc->styleSelectorChanged(RecalcStyleImmediately); 516 516 if (printing) 517 view()->forceLayoutForPagination(pageSize, maximumShrinkRatio, shouldAdjustViewSize);517 view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize); 518 518 else { 519 519 view()->forceLayout(); … … 524 524 // Subframes of the one we're printing don't lay out to the page size. 525 525 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); 527 527 } 528 528 -
trunk/Source/WebCore/page/Frame.h
r94889 r95249 148 148 Settings* settings() const; // can be NULL 149 149 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); 151 151 FloatSize resizePageRectsKeepingRatio(const FloatSize& originalSize, const FloatSize& expectedSize); 152 152 -
trunk/Source/WebCore/page/FrameView.cpp
r95158 r95249 2806 2806 } 2807 2807 2808 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, AdjustViewSizeOrNot shouldAdjustViewSize)2808 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot shouldAdjustViewSize) 2809 2809 { 2810 2810 // Dumping externalRepresentation(m_frame->renderer()).ascii() is a good trick to see … … 2816 2816 2817 2817 LayoutUnit flooredPageLogicalWidth = static_cast<LayoutUnit>(pageLogicalWidth); 2818 LayoutUnit flooredPageLogicalHeight = static_cast<LayoutUnit>(pageLogicalHeight); 2818 2819 root->setLogicalWidth(flooredPageLogicalWidth); 2819 root->setPageLogicalHeight( pageLogicalHeight);2820 root->setPageLogicalHeight(flooredPageLogicalHeight); 2820 2821 root->setNeedsLayoutAndPrefWidthsRecalc(); 2821 2822 forceLayout(); 2822 2823 2823 2824 // If we don't fit in the given page width, we'll lay out again. If we don't fit in the 2824 2825 // page width when shrunk, we will lay out at maximum shrink and clip extra content. … … 2826 2827 // implementation should not do this! 2827 2828 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(); 2829 2831 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); 2833 2840 root->setLogicalWidth(flooredPageLogicalWidth); 2841 root->setPageLogicalHeight(flooredPageLogicalHeight); 2834 2842 root->setNeedsLayoutAndPrefWidthsRecalc(); 2835 2843 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(); 2840 2849 LayoutUnit clippedLogicalLeft = 0; 2841 2850 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 2844 2854 if (!horizontalWritingMode) 2845 2855 overflow = overflow.transposedRect(); -
trunk/Source/WebCore/page/FrameView.h
r95158 r95249 236 236 237 237 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); 239 239 240 240 // 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 166 166 m_isPrinting = true; 167 167 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)); 169 170 170 171 // 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); 172 173 } 173 174 … … 218 219 ASSERT(m_isPrinting); 219 220 m_isPrinting = false; 220 m_frame->setPrinting(false, FloatSize(), 0, AdjustViewSize);221 m_frame->setPrinting(false, FloatSize(), FloatSize(), 0, AdjustViewSize); 221 222 } 222 223 -
trunk/Source/WebKit/mac/ChangeLog
r95234 r95249 1 2011-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 1 31 2011-09-15 Eric Seidel <eric@webkit.org> 2 32 -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r94613 r95249 413 413 414 414 @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; 416 416 - (void)_updateSecureInputState; 417 417 @end … … 1061 1061 - (void)_web_setPrintingModeRecursive 1062 1062 { 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]]; 1064 1064 1065 1065 #ifndef NDEBUG … … 1073 1073 unsigned count = [descendantWebHTMLViews count]; 1074 1074 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]]; 1076 1076 1077 1077 [descendantWebHTMLViews release]; … … 1084 1084 - (void)_web_clearPrintingModeRecursive 1085 1085 { 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]]; 1087 1087 1088 1088 #ifndef NDEBUG … … 1096 1096 unsigned count = [descendantWebHTMLViews count]; 1097 1097 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]]; 1099 1099 1100 1100 [descendantWebHTMLViews release]; … … 1107 1107 - (void)_web_setPrintingModeRecursiveAndAdjustViewSize 1108 1108 { 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]]; 1110 1110 1111 1111 #ifndef NDEBUG … … 1119 1119 unsigned count = [descendantWebHTMLViews count]; 1120 1120 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]]; 1122 1122 1123 1123 [descendantWebHTMLViews release]; … … 2123 2123 maximumShrinkRatio = maximumPageWidth / minimumPageWidth; 2124 2124 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]]; 2126 2126 return YES; 2127 2127 } … … 2148 2148 } 2149 2149 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]]; 2151 2151 2152 2152 return YES; … … 2155 2155 - (void)_endPrintMode 2156 2156 { 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]]; 2158 2158 } 2159 2159 … … 2184 2184 } 2185 2185 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]]; 2187 2187 2188 2188 return YES; … … 2191 2191 - (void)_endScreenPaginationMode 2192 2192 { 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]; 2194 2194 } 2195 2195 … … 2996 2996 // Do a layout, but set up a new fixed width for the purposes of doing printing layout. 2997 2997 // minPageWidth==0 implies a non-printing layout 2998 - (void)layoutToMinimumPageWidth:(float)minPageLogicalWidth height:(float)minPageLogicalHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustingViewSize:(BOOL)adjustViewSize2998 - (void)layoutToMinimumPageWidth:(float)minPageLogicalWidth height:(float)minPageLogicalHeight originalPageWidth:(float)originalPageWidth originalPageHeight:(float)originalPageHeight maximumShrinkRatio:(float)maximumShrinkRatio adjustingViewSize:(BOOL)adjustViewSize 2999 2999 { 3000 3000 if (![self _needsLayout]) … … 3014 3014 if (minPageLogicalWidth > 0.0) { 3015 3015 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()) { 3017 3018 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); 3019 3022 } else { 3020 3023 coreView->forceLayout(!adjustViewSize); … … 3032 3035 - (void)layout 3033 3036 { 3034 [self layoutToMinimumPageWidth:0 height:0 maximumShrinkRatio:0 adjustingViewSize:NO];3037 [self layoutToMinimumPageWidth:0 height:0 originalPageWidth:0 originalPageHeight:0 maximumShrinkRatio:0 adjustingViewSize:NO]; 3035 3038 } 3036 3039 … … 3790 3793 // Does setNeedsDisplay:NO as a side effect when printing is ending. 3791 3794 // 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)paginateScreenContent3795 - (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 3793 3796 { 3794 3797 if (printing == _private->printing && paginateScreenContent == _private->paginateScreenContent) … … 3803 3806 WebFrameView *frameView = [subframe frameView]; 3804 3807 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]; 3806 3809 } 3807 3810 } … … 3828 3831 3829 3832 [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]; 3831 3834 if (!printing) { 3832 3835 // Can't do this when starting printing or nested printing won't work, see 3491427. … … 3848 3851 BOOL wasInPrintingMode = _private->printing; 3849 3852 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]]; 3851 3854 3852 3855 *newBottom = [self _adjustedBottomOfPageWithTop:oldTop bottom:oldBottom limit:bottomLimit]; … … 3859 3862 else 3860 3863 // 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]]; 3862 3865 } 3863 3866 } … … 3896 3899 - (void)setPageWidthForPrinting:(float)pageWidth 3897 3900 { 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]]; 3900 3903 } 3901 3904 -
trunk/Source/WebKit/win/ChangeLog
r94613 r95249 1 2011-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 1 21 2011-09-06 Ryosuke Niwa <rniwa@webkit.org> 2 22 -
trunk/Source/WebKit/win/WebFrame.cpp
r91797 r95249 2011 2011 } 2012 2012 2013 void WebFrame::setPrinting(bool printing, float minPageWidth, float minPageHeight, float maximumShrinkRatio, booladjustViewSize)2013 void WebFrame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot adjustViewSize) 2014 2014 { 2015 2015 Frame* coreFrame = core(this); 2016 2016 ASSERT(coreFrame); 2017 coreFrame->setPrinting(printing, FloatSize(minPageWidth, minPageHeight), maximumShrinkRatio, adjustViewSize ? AdjustViewSize : DoNotAdjustViewSize);2017 coreFrame->setPrinting(printing, pageSize, originalPageSize, maximumShrinkRatio, adjustViewSize ? AdjustViewSize : DoNotAdjustViewSize); 2018 2018 } 2019 2019 … … 2034 2034 // according to the paper size 2035 2035 FloatSize minLayoutSize(0.0, 0.0); 2036 FloatSize originalPageSize(0.0, 0.0); 2036 2037 if (m_inPrintingMode && !coreFrame->document()->isFrameSet()) { 2037 2038 if (!printDC) { … … 2043 2044 IntRect printRect = printerRect(printDC); 2044 2045 int paperHorizontalPixelsPerInch = ::GetDeviceCaps(printDC, LOGPIXELSX); 2046 int paperVerticalPixelsPerInch = ::GetDeviceCaps(printDC, LOGPIXELSY); 2045 2047 int paperWidth = printRect.width() * desiredPixelsPerInch / paperHorizontalPixelsPerInch; 2046 int paperVerticalPixelsPerInch = ::GetDeviceCaps(printDC, LOGPIXELSY);2047 2048 int paperHeight = printRect.height() * desiredPixelsPerInch / paperVerticalPixelsPerInch; 2049 originalPageSize = FloatSize(paperWidth, paperHeight); 2048 2050 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); 2053 2055 2054 2056 if (!m_inPrintingMode) -
trunk/Source/WebKit/win/WebFrame.h
r91797 r95249 34 34 #include "AccessibleDocument.h" 35 35 36 #include <WebCore/AdjustViewSizeOrNot.h> 36 37 #include <WebCore/FrameWin.h> 37 38 #include <WebCore/GraphicsContext.h> … … 48 49 class DocumentLoader; 49 50 class Element; 51 class FloatSize; 50 52 class Frame; 51 53 class GraphicsContext; … … 392 394 void loadData(PassRefPtr<WebCore::SharedBuffer>, BSTR mimeType, BSTR textEncodingName, BSTR baseURL, BSTR failingURL); 393 395 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); 395 397 void headerAndFooterHeights(float*, float*); 396 398 WebCore::IntRect printerMarginRect(HDC);
Note: See TracChangeset
for help on using the changeset viewer.