From: hyatt@apple.com Date: Mon, 3 Jan 2011 18:55:03 +0000 (+0000) Subject: https://bugs.webkit.org/show_bug.cgi?id=51328 X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=91797dc3ab8c54187b54a4e1a53889637266bdd0;ds=sidebyside https://bugs.webkit.org/show_bug.cgi?id=51328 Reviewed by Simon Fraser. WebCore: Printing on a page with body { height: 100% } clips out the overflow contents. This happened because the computePageRects function was never correct. It was using the layer's width and height for the document's width and height, and the layer no longer includes overflow in its width and height. It was also incorrectly assuming the first page would begin at (0,0), and this is an invalid assumption in RTL or vertical text environments. Added printing/page-count-percentage-height.html * page/PrintContext.cpp: (WebCore::PrintContext::computePageRects): (WebCore::PrintContext::computePageRectsWithPageSizeInternal): LayoutTests: Add layout test for printing clipping bug. * printing/page-count-percentage-height-expected.txt: Added. * printing/page-count-percentage-height.html: Added. * printing/script-tests/page-count-percentage-height.js: Added. (test): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74908 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 7d58e34..f7c7238 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,16 @@ +2011-01-03 David Hyatt + + Reviewed by Simon Fraser. + + https://bugs.webkit.org/show_bug.cgi?id=51328 + + Add layout test for printing clipping bug. + + * printing/page-count-percentage-height-expected.txt: Added. + * printing/page-count-percentage-height.html: Added. + * printing/script-tests/page-count-percentage-height.js: Added. + (test): + 2011-01-03 Csaba Osztrogonác Unreviewed, rolling out unnecessary r74905. diff --git a/LayoutTests/printing/page-count-percentage-height-expected.txt b/LayoutTests/printing/page-count-percentage-height-expected.txt new file mode 100644 index 0000000..7fde3da --- /dev/null +++ b/LayoutTests/printing/page-count-percentage-height-expected.txt @@ -0,0 +1,15 @@ +Test to make sure 2nd page is printed. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + + +PASS: page number of "page1" is 0 +PASS: page number of "page2" is 1 +PASS: number of pages is 2 +All tests passed + +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/printing/page-count-percentage-height.html b/LayoutTests/printing/page-count-percentage-height.html new file mode 100644 index 0000000..215aecc --- /dev/null +++ b/LayoutTests/printing/page-count-percentage-height.html @@ -0,0 +1,19 @@ + + + + + + + + + +

+
+
+ + + + + diff --git a/LayoutTests/printing/script-tests/page-count-percentage-height.js b/LayoutTests/printing/script-tests/page-count-percentage-height.js new file mode 100644 index 0000000..f9ef4f0 --- /dev/null +++ b/LayoutTests/printing/script-tests/page-count-percentage-height.js @@ -0,0 +1,16 @@ +description("Test to make sure 2nd page is printed."); + +function test() +{ + createBlockWithRatioToPageHeight("page1", 1); + createBlockWithRatioToPageHeight("page2", 0.5); + + pageNumberForElementShouldBe("page1", 0); + pageNumberForElementShouldBe("page2", 1); + + numberOfPagesShouldBe(2); + + document.body.removeChild(document.getElementById("sandbox")); +} + +var successfullyParsed = true; diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 9c8b73d..db3efe3 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2011-01-03 David Hyatt + + Reviewed by Simon Fraser. + + https://bugs.webkit.org/show_bug.cgi?id=51328 + + Printing on a page with body { height: 100% } clips out the overflow contents. This happened + because the computePageRects function was never correct. It was using the layer's width and height + for the document's width and height, and the layer no longer includes overflow in its width and + height. It was also incorrectly assuming the first page would begin at (0,0), and this is an invalid + assumption in RTL or vertical text environments. + + Added printing/page-count-percentage-height.html + + * page/PrintContext.cpp: + (WebCore::PrintContext::computePageRects): + (WebCore::PrintContext::computePageRectsWithPageSizeInternal): + 2011-01-03 Csaba Osztrogonác [Qt] Unreviewed buildfix for --minimal build after r74895. diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp index 7acca96..f051ead 100644 --- a/WebCore/page/PrintContext.cpp +++ b/WebCore/page/PrintContext.cpp @@ -68,11 +68,11 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig return; } - RenderView* root = toRenderView(m_frame->document()->renderer()); + RenderView* view = toRenderView(m_frame->document()->renderer()); float ratio = printRect.height() / printRect.width(); - float pageWidth = (float)root->rightLayoutOverflow(); + float pageWidth = view->docWidth(); float pageHeight = pageWidth * ratio; outPageHeight = pageHeight; // this is the height of the page adjusted by margins pageHeight -= headerHeight + footerHeight; @@ -96,20 +96,20 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer()) return; - RenderView* root = toRenderView(m_frame->document()->renderer()); + RenderView* view = toRenderView(m_frame->document()->renderer()); + + IntRect docRect = view->documentRect(); - int docWidth = root->layer()->width(); - int docHeight = root->layer()->height(); int pageWidth = pageSizeInPixels.width(); int pageHeight = pageSizeInPixels.height(); - unsigned pageCount = ceilf((float)docHeight / pageHeight); + unsigned pageCount = ceilf((float)docRect.height() / pageHeight); for (unsigned i = 0; i < pageCount; ++i) { if (allowHorizontalMultiPages) { - for (int currWidth = 0; currWidth < docWidth; currWidth += pageWidth) - m_pageRects.append(IntRect(currWidth, i * pageHeight, pageWidth, pageHeight)); + for (int currentX = docRect.x(); currentX < docRect.right(); currentX += pageWidth) + m_pageRects.append(IntRect(currentX, docRect.y() + i * pageHeight, pageWidth, pageHeight)); } else - m_pageRects.append(IntRect(0, i * pageHeight, pageWidth, pageHeight)); + m_pageRects.append(IntRect(docRect.x(), docRect.y() + i * pageHeight, pageWidth, pageHeight)); } }