diff options
Diffstat (limited to 'WebCore/page/PrintContext.cpp')
-rw-r--r-- | WebCore/page/PrintContext.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp index cc3707e..2bbc63a 100644 --- a/WebCore/page/PrintContext.cpp +++ b/WebCore/page/PrintContext.cpp @@ -245,4 +245,52 @@ int PrintContext::numberOfPages(Frame* frame, const FloatSize& pageSizeInPixels) return printContext.pageCount(); } +void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels) +{ + if (!frame->document() || !frame->view() || !frame->document()->renderer()) + return; + + frame->document()->updateLayout(); + + PrintContext printContext(frame); + printContext.begin(pageSizeInPixels.width()); + + float pageHeight; + printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight); + + const float pageWidth = pageSizeInPixels.width(); + const Vector<IntRect>& pageRects = printContext.pageRects(); + int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1; + + // Fill the whole background by white. + graphicsContext.setFillColor(Color(255, 255, 255), DeviceColorSpace); + graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight)); + + graphicsContext.save(); + graphicsContext.translate(0, totalHeight); + graphicsContext.scale(FloatSize(1, -1)); + + int currentHeight = 0; + for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) { + // Draw a line for a page boundary if this isn't the first page. + if (pageIndex > 0) { + graphicsContext.save(); + graphicsContext.setStrokeColor(Color(0, 0, 255), DeviceColorSpace); + graphicsContext.setFillColor(Color(0, 0, 255), DeviceColorSpace); + graphicsContext.drawLine(IntPoint(0, currentHeight), + IntPoint(pageWidth, currentHeight)); + graphicsContext.restore(); + } + + graphicsContext.save(); + graphicsContext.translate(0, currentHeight); + printContext.spoolPage(graphicsContext, pageIndex, pageWidth); + graphicsContext.restore(); + + currentHeight += pageSizeInPixels.height() + 1; + } + + graphicsContext.restore(); +} + } |