summaryrefslogtreecommitdiffstats
path: root/WebCore/page/PrintContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/page/PrintContext.cpp')
-rw-r--r--WebCore/page/PrintContext.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp
index 7b0179d..8cc7dd6 100644
--- a/WebCore/page/PrintContext.cpp
+++ b/WebCore/page/PrintContext.cpp
@@ -95,26 +95,22 @@ 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());
- const float pageWidth = pageSizeInPixels.width();
- const float docWidth = root->layer()->width();
- const float docHeight = root->layer()->height();
- float currPageHeight = pageSizeInPixels.height();
-
- // always return at least one page, since empty files should print a blank page
- float printedPagesHeight = 0;
- do {
- float proposedBottom = std::min(docHeight, printedPagesHeight + pageSizeInPixels.height());
- m_frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight);
- currPageHeight = max(1.0f, proposedBottom - printedPagesHeight);
+ int docWidth = root->layer()->width();
+ int docHeight = root->layer()->height();
+ int pageWidth = pageSizeInPixels.width();
+ int pageHeight = pageSizeInPixels.height();
+
+ unsigned pageCount = ceilf((float)docHeight / pageHeight);
+ for (unsigned i = 0; i < pageCount; ++i) {
if (allowHorizontalMultiPages) {
- for (float curWidth = 0; curWidth < docWidth; curWidth += pageWidth)
- m_pageRects.append(IntRect(curWidth, (int)printedPagesHeight, (int)pageWidth, (int)currPageHeight));
+ for (int currWidth = 0; currWidth < docWidth; currWidth += pageWidth)
+ m_pageRects.append(IntRect(currWidth, i * pageHeight, pageWidth, pageHeight));
} else
- m_pageRects.append(IntRect(0, (int)printedPagesHeight, (int)pageWidth, (int)currPageHeight));
- printedPagesHeight += currPageHeight;
- } while (printedPagesHeight < docHeight);
+ m_pageRects.append(IntRect(0, i * pageHeight, pageWidth, pageHeight));
+ }
}
void PrintContext::begin(float width, float height)