2010-07-15 Shinichiro Hamaji <hamaji@chromium.org>
authorhamaji@chromium.org <hamaji@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jul 2010 06:25:48 +0000 (06:25 +0000)
committerhamaji@chromium.org <hamaji@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jul 2010 06:25:48 +0000 (06:25 +0000)
        Reviewed by Darin Adler.

        Printing test results differ between machines, we should use ImageDiff instead
        https://bugs.webkit.org/show_bug.cgi?id=20011

        Added printing/setPrinting.html to check there is the page boundary.

        Enabled printing/composite-layer-printing.html with setPrinting.

        The result of printing/media-queries-print.html shrunk because of
        PrintingMinimumShrinkFactor in PrintContext::begin().

        * platform/mac/Skipped:
        * platform/mac/printing/compositing-layer-printing-expected.checksum: Added.
        * platform/mac/printing/compositing-layer-printing-expected.png: Added.
        * platform/mac/printing/compositing-layer-printing-expected.txt: Added.
        * platform/mac/printing/media-queries-print-expected.checksum:
        * platform/mac/printing/media-queries-print-expected.png:
        * platform/mac/printing/setPrinting-expected.checksum: Added.
        * platform/mac/printing/setPrinting-expected.png: Added.
        * platform/mac/printing/setPrinting-expected.txt: Added.
        * printing/compositing-layer-printing.html:
        * printing/setPrinting.html: Added.
2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>

        Reviewed by Darin Adler.

        Printing test results differ between machines, we should use ImageDiff instead
        https://bugs.webkit.org/show_bug.cgi?id=20011

        Added spoolAllPagesWithBoundaries into PrintContext.

        Test: printing/setPrinting.html

        * WebCore.base.exp:
        * page/PrintContext.cpp:
        (WebCore::PrintContext::spoolAllPagesWithBoundaries):
        * page/PrintContext.h:
2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>

        Reviewed by Darin Adler.

        Printing test results differ between machines, we should use ImageDiff instead
        https://bugs.webkit.org/show_bug.cgi?id=20011

        * Misc/WebCoreStatistics.h:
        * Misc/WebCoreStatistics.mm:
        (-[WebFrame printToCGContext:cgContext:pageWidthInPixels:]):
2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>

        Reviewed by Darin Adler.

        Printing test results differ between machines, we should use ImageDiff instead
        https://bugs.webkit.org/show_bug.cgi?id=20011

        * DumpRenderTree/PixelDumpSupport.cpp:
        (dumpWebViewAsPixelsAndCompareWithExpected):
        * DumpRenderTree/PixelDumpSupport.h:
        * DumpRenderTree/mac/PixelDumpSupportMac.mm:
        (createBitmapContext): This function was added to share bitmap context creation code.
        (createBitmapContextFromWebView):
        (createPagedBitmapContext):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63521 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/mac/printing/compositing-layer-printing-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/printing/compositing-layer-printing-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/printing/compositing-layer-printing-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/printing/media-queries-print-expected.checksum
LayoutTests/platform/mac/printing/media-queries-print-expected.png
LayoutTests/platform/mac/printing/setPrinting-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/printing/setPrinting-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/printing/setPrinting-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/printing/compositing-layer-printing.html
LayoutTests/printing/setPrinting.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.exp.in
WebCore/page/PrintContext.cpp
WebCore/page/PrintContext.h
WebKit/mac/ChangeLog
WebKit/mac/Misc/WebCoreStatistics.h
WebKit/mac/Misc/WebCoreStatistics.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/PixelDumpSupport.cpp
WebKitTools/DumpRenderTree/PixelDumpSupport.h
WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm

index 47dda52..2706351 100644 (file)
@@ -1,3 +1,29 @@
+2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Printing test results differ between machines, we should use ImageDiff instead
+        https://bugs.webkit.org/show_bug.cgi?id=20011
+
+        Added printing/setPrinting.html to check there is the page boundary.
+
+        Enabled printing/composite-layer-printing.html with setPrinting.
+
+        The result of printing/media-queries-print.html shrunk because of
+        PrintingMinimumShrinkFactor in PrintContext::begin().
+
+        * platform/mac/Skipped:
+        * platform/mac/printing/compositing-layer-printing-expected.checksum: Added.
+        * platform/mac/printing/compositing-layer-printing-expected.png: Added.
+        * platform/mac/printing/compositing-layer-printing-expected.txt: Added.
+        * platform/mac/printing/media-queries-print-expected.checksum:
+        * platform/mac/printing/media-queries-print-expected.png:
+        * platform/mac/printing/setPrinting-expected.checksum: Added.
+        * platform/mac/printing/setPrinting-expected.png: Added.
+        * platform/mac/printing/setPrinting-expected.txt: Added.
+        * printing/compositing-layer-printing.html:
+        * printing/setPrinting.html: Added.
+
 2010-07-15  MORITA Hajime  <morrita@google.com>
 
         Unrviewed, added missing expectations.
index 0cf3a82..1813c7e 100644 (file)
@@ -5861,3 +5861,6 @@ http/tests/loading/preload-slow-loading.php
 
 # Directory upload is not enabled.
 fast/forms/input-file-directory-upload.html
+
+# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
+printing/setPrinting.html
index b65fd8f..8063621 100644 (file)
@@ -35,9 +35,6 @@ fast/events/attempt-scroll-with-no-scrollbars.html
 # see bug <rdar://problem/5646437> REGRESSION (r28015): svg/batik/text/smallFonts fails
 svg/batik/text/smallFonts.svg
 
-# see bug https://bugs.webkit.org/show_bug.cgi?id=20011 -- Printing tests should use ImageDiff
-printing/compositing-layer-printing.html
-
 # Skip because fix for https://bugs.webkit.org/show_bug.cgi?id=26770 was reverted
 compositing/animation/animated-composited-inside-hidden.html
 
diff --git a/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.checksum b/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.checksum
new file mode 100644 (file)
index 0000000..af8e568
--- /dev/null
@@ -0,0 +1 @@
+590ebb52f9258d18c8e95839d2823f84
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.png b/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.png
new file mode 100644 (file)
index 0000000..3cf070f
Binary files /dev/null and b/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.png differ
diff --git a/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.txt b/LayoutTests/platform/mac/printing/compositing-layer-printing-expected.txt
new file mode 100644 (file)
index 0000000..cdaf9c2
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 1000x270
+  RenderView at (0,0) size 1000x270
+layer at (0,0) size 1000x270
+  RenderBlock {HTML} at (0,0) size 1000x270
+    RenderBody {BODY} at (8,16) size 984x244
+      RenderBlock {P} at (0,0) size 984x18
+        RenderText {#text} at (0,0) size 454x18
+          text run at (0,0) width 454: "You should see two green squares below on screen, and when printed."
+      RenderBlock {DIV} at (10,34) size 100x100 [bgcolor=#008000]
+layer at (18,160) size 100x100
+  RenderBlock {DIV} at (10,144) size 100x100 [bgcolor=#008000]
index 1f110c9..98cd556 100644 (file)
Binary files a/LayoutTests/platform/mac/printing/media-queries-print-expected.png and b/LayoutTests/platform/mac/printing/media-queries-print-expected.png differ
diff --git a/LayoutTests/platform/mac/printing/setPrinting-expected.checksum b/LayoutTests/platform/mac/printing/setPrinting-expected.checksum
new file mode 100644 (file)
index 0000000..717bf61
--- /dev/null
@@ -0,0 +1 @@
+acb402590109e72d730b68ed674c8708
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/printing/setPrinting-expected.png b/LayoutTests/platform/mac/printing/setPrinting-expected.png
new file mode 100644 (file)
index 0000000..c01dde6
Binary files /dev/null and b/LayoutTests/platform/mac/printing/setPrinting-expected.png differ
diff --git a/LayoutTests/platform/mac/printing/setPrinting-expected.txt b/LayoutTests/platform/mac/printing/setPrinting-expected.txt
new file mode 100644 (file)
index 0000000..caf78a3
--- /dev/null
@@ -0,0 +1,12 @@
+layer at (0,0) size 982x785
+  RenderView at (0,0) size 982x785
+layer at (0,0) size 982x785
+  RenderBlock {HTML} at (0,0) size 982x785
+    RenderBody {BODY} at (0,0) size 982x785
+      RenderBlock {DIV} at (0,0) size 800x749 [bgcolor=#008000]
+        RenderText {#text} at (0,0) size 237x18
+          text run at (0,0) width 237: "This test case should output 2 pages."
+      RenderBlock (anonymous) at (0,749) size 982x36
+        RenderText {#text} at (0,0) size 972x36
+          text run at (0,0) width 972: "There should be a blue line above this test. This line is the boundary of 2 pages. As the height of green box is shorter than the height of a page by one"
+          text run at (0,18) width 485: "pixel, there should be a white line between the green box and the blue line."
index 1e4acd8..c30fb16 100644 (file)
@@ -5463,3 +5463,6 @@ inspector/timeline-recalculate-styles.html
 
 # Directory upload is not enabled.
 fast/forms/input-file-directory-upload.html
+
+# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
+printing/setPrinting.html
index e5ea19f..e0e5695 100644 (file)
@@ -956,3 +956,6 @@ userscripts/user-style-top-frame-only.html
 
 # Directory upload is not enabled.
 fast/forms/input-file-directory-upload.html
+
+# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
+printing/setPrinting.html
index ca7efa2..8db4ca6 100644 (file)
@@ -13,7 +13,7 @@
   </style>
   <script>
     if (window.layoutTestController)
-      layoutTestController.printToPDF();
+      layoutTestController.setPrinting();
   </script>
 </head>
 <body>
diff --git a/LayoutTests/printing/setPrinting.html b/LayoutTests/printing/setPrinting.html
new file mode 100644 (file)
index 0000000..ff31df7
--- /dev/null
@@ -0,0 +1,19 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController)
+    layoutTestController.setPrinting();
+</script>
+</head>
+
+<body style="margin: 0px;">
+<div style="width: 800px; height: 749px; background-color: green;">
+This test case should output 2 pages.
+</div>
+There should be a blue line above this test.
+This line is the boundary of 2 pages.
+As the height of green box is shorter than the height of a page by one pixel,
+there should be a white line between the green box and the blue line.
+</div>
+</body>
+</html>
index a4a26d2..01eb076 100644 (file)
@@ -1,3 +1,19 @@
+2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Printing test results differ between machines, we should use ImageDiff instead
+        https://bugs.webkit.org/show_bug.cgi?id=20011
+
+        Added spoolAllPagesWithBoundaries into PrintContext.
+
+        Test: printing/setPrinting.html
+
+        * WebCore.base.exp:
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::spoolAllPagesWithBoundaries):
+        * page/PrintContext.h:
+
 2010-07-15  Kent Tamura  <tkent@chromium.org>
 
         Unreviewed, small style fixes.
index c9eb488..a4ed7ce 100644 (file)
@@ -255,6 +255,7 @@ __ZN7WebCore12PrintContext13numberOfPagesEPNS_5FrameERKNS_9FloatSizeE
 __ZN7WebCore12PrintContext16isPageBoxVisibleEPNS_5FrameEi
 __ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE
 __ZN7WebCore12PrintContext26pageSizeAndMarginsInPixelsEPNS_5FrameEiiiiiii
+__ZN7WebCore12PrintContext27spoolAllPagesWithBoundariesEPNS_5FrameERNS_15GraphicsContextERKNS_9FloatSizeE
 __ZN7WebCore12PrintContext28computePageRectsWithPageSizeERKNS_9FloatSizeEb
 __ZN7WebCore12PrintContextC1EPNS_5FrameE
 __ZN7WebCore12PrintContextD1Ev
index 7e1e35d..a41bed3 100644 (file)
@@ -244,4 +244,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();
+}
+
 }
index 1080c29..8492718 100644 (file)
@@ -59,6 +59,10 @@ public:
     static bool isPageBoxVisible(Frame* frame, int pageNumber);
     static String pageSizeAndMarginsInPixels(Frame* frame, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
     static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels);
+    // Draw all pages into a graphics context with lines which mean page boundaries.
+    // The height of the graphics context should be
+    // (pageSizeInPixels.height() + 1) * number-of-pages - 1
+    static void spoolAllPagesWithBoundaries(Frame*, GraphicsContext&, const FloatSize& pageSizeInPixels);
 
 protected:
     Frame* m_frame;
index c2f1a74..069bcc5 100644 (file)
@@ -1,3 +1,14 @@
+2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Printing test results differ between machines, we should use ImageDiff instead
+        https://bugs.webkit.org/show_bug.cgi?id=20011
+
+        * Misc/WebCoreStatistics.h:
+        * Misc/WebCoreStatistics.mm:
+        (-[WebFrame printToCGContext:cgContext:pageWidthInPixels:]):
+
 2010-07-15  Daniel Bates  <dbates@rim.com>
 
         Reviewed by Darin Adler.
index 33e3e0f..1565c26 100644 (file)
@@ -90,4 +90,5 @@
 - (NSString *)pageProperty:(const char*)propertyName:(int)pageNumber;
 - (bool)isPageBoxVisible:(int)pageNumber;
 - (NSString *)pageSizeAndMarginsInPixels:(int)pageNumber:(int)width:(int)height:(int)marginTop:(int)marginRight:(int)marginBottom:(int)marginLeft;
+- (void)printToCGContext:(CGContextRef)cgContext:(float)pageWidthInPixels:(float)pageHeightInPixels;
 @end
index bbe07d5..a5d5ae1 100644 (file)
@@ -37,6 +37,7 @@
 #import <WebCore/Frame.h>
 #import <WebCore/GCController.h>
 #import <WebCore/GlyphPageTreeNode.h>
+#import <WebCore/GraphicsContext.h>
 #import <WebCore/IconDatabase.h>
 #import <WebCore/JSDOMWindow.h>
 #import <WebCore/PageCache.h>
@@ -289,4 +290,15 @@ using namespace WebCore;
 {
     return PrintContext::pageSizeAndMarginsInPixels(_private->coreFrame, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft);
 }
+
+- (void)printToCGContext:(CGContextRef)cgContext:(float)pageWidthInPixels:(float)pageHeightInPixels
+{
+    Frame* coreFrame = _private->coreFrame;
+    if (!coreFrame)
+        return;
+
+    GraphicsContext graphicsContext(cgContext);
+    PrintContext::spoolAllPagesWithBoundaries(coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
+}
+
 @end
index 8ef7428..94097dc 100644 (file)
@@ -1,3 +1,18 @@
+2010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Printing test results differ between machines, we should use ImageDiff instead
+        https://bugs.webkit.org/show_bug.cgi?id=20011
+
+        * DumpRenderTree/PixelDumpSupport.cpp:
+        (dumpWebViewAsPixelsAndCompareWithExpected):
+        * DumpRenderTree/PixelDumpSupport.h:
+        * DumpRenderTree/mac/PixelDumpSupportMac.mm:
+        (createBitmapContext): This function was added to share bitmap context creation code.
+        (createBitmapContextFromWebView):
+        (createPagedBitmapContext):
+
 2010-07-15  Yuta Kitamura  <yutak@chromium.org>
 
         Reviewed by Kent Tamura.
index e372827..6212add 100644 (file)
 
 void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
 {
-    RefPtr<BitmapContext> context = createBitmapContextFromWebView(gLayoutTestController->testOnscreen(), gLayoutTestController->testRepaint(), gLayoutTestController->testRepaintSweepHorizontally(), gLayoutTestController->dumpSelectionRect());
+    RefPtr<BitmapContext> context;
+    if (gLayoutTestController->isPrinting())
+        context = createPagedBitmapContext();
+    else
+        context = createBitmapContextFromWebView(gLayoutTestController->testOnscreen(), gLayoutTestController->testRepaint(), gLayoutTestController->testRepaintSweepHorizontally(), gLayoutTestController->dumpSelectionRect());
     ASSERT(context);
     
     // Compute the hash of the bitmap context pixels
index 94c5312..e172a83 100644 (file)
@@ -36,6 +36,7 @@
 class BitmapContext;
 
 void computeMD5HashStringForBitmapContext(BitmapContext*, char hashString[33]);
+PassRefPtr<BitmapContext> createPagedBitmapContext();
 PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect);
 void dumpBitmap(BitmapContext*);
 void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash);
index 0059b69..97b12bb 100644 (file)
@@ -38,6 +38,7 @@
 #include <wtf/Assertions.h>
 #include <wtf/RefPtr.h>
 
+#import <WebKit/WebCoreStatistics.h>
 #import <WebKit/WebDocumentPrivate.h>
 #import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebKit.h>
@@ -104,18 +105,8 @@ void setupMainDisplayColorProfile()
     signal(SIGTERM, restoreMainDisplayColorProfile);
 }
 
-PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
+static PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh)
 {
-    WebView* view = [mainFrame webView];
-
-    // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path
-    // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled.
-    if ([view _isUsingAcceleratedCompositing])
-        onscreen = YES;
-
-    NSSize webViewSize = [view frame].size;
-    size_t pixelsWide = static_cast<size_t>(webViewSize.width);
-    size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
     size_t rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance
 
     void *buffer = calloc(pixelsHigh, rowBytes);
@@ -140,9 +131,26 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc
         return 0;
     }
 
-    // The BitmapContext keeps the CGContextRef and the pixel buffer alive
-    RefPtr<BitmapContext> bitmapContext = BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
-    
+    return BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
+}
+
+PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
+{
+    WebView* view = [mainFrame webView];
+
+    // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path
+    // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled.
+    if ([view _isUsingAcceleratedCompositing])
+        onscreen = YES;
+
+    NSSize webViewSize = [view frame].size;
+    size_t pixelsWide = static_cast<size_t>(webViewSize.width);
+    size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
+    RefPtr<BitmapContext> bitmapContext = createBitmapContext(pixelsWide, pixelsHigh);
+    if (!bitmapContext)
+        return 0;
+    CGContextRef context = bitmapContext->cgContext();
+
     NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
     ASSERT(nsContext);
     
@@ -254,3 +262,14 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc
     
     return bitmapContext.release();
 }
+
+PassRefPtr<BitmapContext> createPagedBitmapContext()
+{
+    int pageWidthInPixels = LayoutTestController::maxViewWidth;
+    int pageHeightInPixels = LayoutTestController::maxViewHeight;
+    int numberOfPages = [mainFrame numberOfPages:pageWidthInPixels:pageHeightInPixels];
+
+    RefPtr<BitmapContext> bitmapContext = createBitmapContext(pageWidthInPixels, numberOfPages * (pageHeightInPixels + 1) - 1);
+    [mainFrame printToCGContext:bitmapContext->cgContext():pageWidthInPixels:pageHeightInPixels];
+    return bitmapContext.release();
+}