Changeset 63521 in webkit


Ignore:
Timestamp:
Jul 15, 2010 11:25:48 PM (14 years ago)
Author:
hamaji@chromium.org
Message:

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 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):
Location:
trunk
Files:
7 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r63520 r63521  
     12010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Printing test results differ between machines, we should use ImageDiff instead
     6        https://bugs.webkit.org/show_bug.cgi?id=20011
     7
     8        Added printing/setPrinting.html to check there is the page boundary.
     9
     10        Enabled printing/composite-layer-printing.html with setPrinting.
     11
     12        The result of printing/media-queries-print.html shrunk because of
     13        PrintingMinimumShrinkFactor in PrintContext::begin().
     14
     15        * platform/mac/Skipped:
     16        * platform/mac/printing/compositing-layer-printing-expected.checksum: Added.
     17        * platform/mac/printing/compositing-layer-printing-expected.png: Added.
     18        * platform/mac/printing/compositing-layer-printing-expected.txt: Added.
     19        * platform/mac/printing/media-queries-print-expected.checksum:
     20        * platform/mac/printing/media-queries-print-expected.png:
     21        * platform/mac/printing/setPrinting-expected.checksum: Added.
     22        * platform/mac/printing/setPrinting-expected.png: Added.
     23        * platform/mac/printing/setPrinting-expected.txt: Added.
     24        * printing/compositing-layer-printing.html:
     25        * printing/setPrinting.html: Added.
     26
    1272010-07-15  MORITA Hajime  <morrita@google.com>
    228
  • trunk/LayoutTests/platform/gtk/Skipped

    r63454 r63521  
    58625862# Directory upload is not enabled.
    58635863fast/forms/input-file-directory-upload.html
     5864
     5865# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
     5866printing/setPrinting.html
  • trunk/LayoutTests/platform/mac/Skipped

    r63454 r63521  
    3535# see bug <rdar://problem/5646437> REGRESSION (r28015): svg/batik/text/smallFonts fails
    3636svg/batik/text/smallFonts.svg
    37 
    38 # see bug https://bugs.webkit.org/show_bug.cgi?id=20011 -- Printing tests should use ImageDiff
    39 printing/compositing-layer-printing.html
    4037
    4138# Skip because fix for https://bugs.webkit.org/show_bug.cgi?id=26770 was reverted
  • trunk/LayoutTests/platform/mac/printing/media-queries-print-expected.checksum

    r58396 r63521  
    1 6090d2b0a19649aba8a379f982a345d3
     19ea3bf56e7033cfee8a2beb3a800d85f
  • trunk/LayoutTests/platform/qt/Skipped

    r63454 r63521  
    54645464# Directory upload is not enabled.
    54655465fast/forms/input-file-directory-upload.html
     5466
     5467# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
     5468printing/setPrinting.html
  • trunk/LayoutTests/platform/win/Skipped

    r63454 r63521  
    957957# Directory upload is not enabled.
    958958fast/forms/input-file-directory-upload.html
     959
     960# Need setPrinting. See https://bugs.webkit.org/show_bug.cgi?id=20011
     961printing/setPrinting.html
  • trunk/LayoutTests/printing/compositing-layer-printing.html

    r51718 r63521  
    1414  <script>
    1515    if (window.layoutTestController)
    16       layoutTestController.printToPDF();
     16      layoutTestController.setPrinting();
    1717  </script>
    1818</head>
  • trunk/WebCore/ChangeLog

    r63518 r63521  
     12010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Printing test results differ between machines, we should use ImageDiff instead
     6        https://bugs.webkit.org/show_bug.cgi?id=20011
     7
     8        Added spoolAllPagesWithBoundaries into PrintContext.
     9
     10        Test: printing/setPrinting.html
     11
     12        * WebCore.base.exp:
     13        * page/PrintContext.cpp:
     14        (WebCore::PrintContext::spoolAllPagesWithBoundaries):
     15        * page/PrintContext.h:
     16
    1172010-07-15  Kent Tamura  <tkent@chromium.org>
    218
  • trunk/WebCore/WebCore.exp.in

    r63462 r63521  
    256256__ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE
    257257__ZN7WebCore12PrintContext26pageSizeAndMarginsInPixelsEPNS_5FrameEiiiiiii
     258__ZN7WebCore12PrintContext27spoolAllPagesWithBoundariesEPNS_5FrameERNS_15GraphicsContextERKNS_9FloatSizeE
    258259__ZN7WebCore12PrintContext28computePageRectsWithPageSizeERKNS_9FloatSizeEb
    259260__ZN7WebCore12PrintContextC1EPNS_5FrameE
  • trunk/WebCore/page/PrintContext.cpp

    r61975 r63521  
    245245}
    246246
    247 }
     247void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
     248{
     249    if (!frame->document() || !frame->view() || !frame->document()->renderer())
     250        return;
     251
     252    frame->document()->updateLayout();
     253
     254    PrintContext printContext(frame);
     255    printContext.begin(pageSizeInPixels.width());
     256
     257    float pageHeight;
     258    printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
     259
     260    const float pageWidth = pageSizeInPixels.width();
     261    const Vector<IntRect>& pageRects = printContext.pageRects();
     262    int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
     263
     264    // Fill the whole background by white.
     265    graphicsContext.setFillColor(Color(255, 255, 255), DeviceColorSpace);
     266    graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
     267
     268    graphicsContext.save();
     269    graphicsContext.translate(0, totalHeight);
     270    graphicsContext.scale(FloatSize(1, -1));
     271
     272    int currentHeight = 0;
     273    for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
     274        // Draw a line for a page boundary if this isn't the first page.
     275        if (pageIndex > 0) {
     276            graphicsContext.save();
     277            graphicsContext.setStrokeColor(Color(0, 0, 255), DeviceColorSpace);
     278            graphicsContext.setFillColor(Color(0, 0, 255), DeviceColorSpace);
     279            graphicsContext.drawLine(IntPoint(0, currentHeight),
     280                                     IntPoint(pageWidth, currentHeight));
     281            graphicsContext.restore();
     282        }
     283
     284        graphicsContext.save();
     285        graphicsContext.translate(0, currentHeight);
     286        printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
     287        graphicsContext.restore();
     288
     289        currentHeight += pageSizeInPixels.height() + 1;
     290    }
     291
     292    graphicsContext.restore();
     293}
     294
     295}
  • trunk/WebCore/page/PrintContext.h

    r61975 r63521  
    6060    static String pageSizeAndMarginsInPixels(Frame* frame, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
    6161    static int numberOfPages(Frame*, const FloatSize& pageSizeInPixels);
     62    // Draw all pages into a graphics context with lines which mean page boundaries.
     63    // The height of the graphics context should be
     64    // (pageSizeInPixels.height() + 1) * number-of-pages - 1
     65    static void spoolAllPagesWithBoundaries(Frame*, GraphicsContext&, const FloatSize& pageSizeInPixels);
    6266
    6367protected:
  • trunk/WebKit/mac/ChangeLog

    r63445 r63521  
     12010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Printing test results differ between machines, we should use ImageDiff instead
     6        https://bugs.webkit.org/show_bug.cgi?id=20011
     7
     8        * Misc/WebCoreStatistics.h:
     9        * Misc/WebCoreStatistics.mm:
     10        (-[WebFrame printToCGContext:cgContext:pageWidthInPixels:]):
     11
    1122010-07-15  Daniel Bates  <dbates@rim.com>
    213
  • trunk/WebKit/mac/Misc/WebCoreStatistics.h

    r61975 r63521  
    9191- (bool)isPageBoxVisible:(int)pageNumber;
    9292- (NSString *)pageSizeAndMarginsInPixels:(int)pageNumber:(int)width:(int)height:(int)marginTop:(int)marginRight:(int)marginBottom:(int)marginLeft;
     93- (void)printToCGContext:(CGContextRef)cgContext:(float)pageWidthInPixels:(float)pageHeightInPixels;
    9394@end
  • trunk/WebKit/mac/Misc/WebCoreStatistics.mm

    r61975 r63521  
    3838#import <WebCore/GCController.h>
    3939#import <WebCore/GlyphPageTreeNode.h>
     40#import <WebCore/GraphicsContext.h>
    4041#import <WebCore/IconDatabase.h>
    4142#import <WebCore/JSDOMWindow.h>
     
    290291    return PrintContext::pageSizeAndMarginsInPixels(_private->coreFrame, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft);
    291292}
     293
     294- (void)printToCGContext:(CGContextRef)cgContext:(float)pageWidthInPixels:(float)pageHeightInPixels
     295{
     296    Frame* coreFrame = _private->coreFrame;
     297    if (!coreFrame)
     298        return;
     299
     300    GraphicsContext graphicsContext(cgContext);
     301    PrintContext::spoolAllPagesWithBoundaries(coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
     302}
     303
    292304@end
  • trunk/WebKitTools/ChangeLog

    r63508 r63521  
     12010-07-15  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Printing test results differ between machines, we should use ImageDiff instead
     6        https://bugs.webkit.org/show_bug.cgi?id=20011
     7
     8        * DumpRenderTree/PixelDumpSupport.cpp:
     9        (dumpWebViewAsPixelsAndCompareWithExpected):
     10        * DumpRenderTree/PixelDumpSupport.h:
     11        * DumpRenderTree/mac/PixelDumpSupportMac.mm:
     12        (createBitmapContext): This function was added to share bitmap context creation code.
     13        (createBitmapContextFromWebView):
     14        (createPagedBitmapContext):
     15
    1162010-07-15  Yuta Kitamura  <yutak@chromium.org>
    217
  • trunk/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp

    r63130 r63521  
    4343void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
    4444{
    45     RefPtr<BitmapContext> context = createBitmapContextFromWebView(gLayoutTestController->testOnscreen(), gLayoutTestController->testRepaint(), gLayoutTestController->testRepaintSweepHorizontally(), gLayoutTestController->dumpSelectionRect());
     45    RefPtr<BitmapContext> context;
     46    if (gLayoutTestController->isPrinting())
     47        context = createPagedBitmapContext();
     48    else
     49        context = createBitmapContextFromWebView(gLayoutTestController->testOnscreen(), gLayoutTestController->testRepaint(), gLayoutTestController->testRepaintSweepHorizontally(), gLayoutTestController->dumpSelectionRect());
    4650    ASSERT(context);
    4751   
  • trunk/WebKitTools/DumpRenderTree/PixelDumpSupport.h

    r45505 r63521  
    3737
    3838void computeMD5HashStringForBitmapContext(BitmapContext*, char hashString[33]);
     39PassRefPtr<BitmapContext> createPagedBitmapContext();
    3940PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect);
    4041void dumpBitmap(BitmapContext*);
  • trunk/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm

    r46340 r63521  
    3939#include <wtf/RefPtr.h>
    4040
     41#import <WebKit/WebCoreStatistics.h>
    4142#import <WebKit/WebDocumentPrivate.h>
    4243#import <WebKit/WebHTMLViewPrivate.h>
     
    105106}
    106107
    107 PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
    108 {
    109     WebView* view = [mainFrame webView];
    110 
    111     // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path
    112     // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled.
    113     if ([view _isUsingAcceleratedCompositing])
    114         onscreen = YES;
    115 
    116     NSSize webViewSize = [view frame].size;
    117     size_t pixelsWide = static_cast<size_t>(webViewSize.width);
    118     size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
     108static PassRefPtr<BitmapContext> createBitmapContext(size_t pixelsWide, size_t pixelsHigh)
     109{
    119110    size_t rowBytes = (4 * pixelsWide + 63) & ~63; // Use a multiple of 64 bytes to improve CG performance
    120111
     
    141132    }
    142133
    143     // The BitmapContext keeps the CGContextRef and the pixel buffer alive
    144     RefPtr<BitmapContext> bitmapContext = BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
    145    
     134    return BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
     135}
     136
     137PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
     138{
     139    WebView* view = [mainFrame webView];
     140
     141    // If the WebHTMLView uses accelerated compositing, we need for force the on-screen capture path
     142    // and also force Core Animation to start its animations with -display since the DRT window has autodisplay disabled.
     143    if ([view _isUsingAcceleratedCompositing])
     144        onscreen = YES;
     145
     146    NSSize webViewSize = [view frame].size;
     147    size_t pixelsWide = static_cast<size_t>(webViewSize.width);
     148    size_t pixelsHigh = static_cast<size_t>(webViewSize.height);
     149    RefPtr<BitmapContext> bitmapContext = createBitmapContext(pixelsWide, pixelsHigh);
     150    if (!bitmapContext)
     151        return 0;
     152    CGContextRef context = bitmapContext->cgContext();
     153
    146154    NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
    147155    ASSERT(nsContext);
     
    255263    return bitmapContext.release();
    256264}
     265
     266PassRefPtr<BitmapContext> createPagedBitmapContext()
     267{
     268    int pageWidthInPixels = LayoutTestController::maxViewWidth;
     269    int pageHeightInPixels = LayoutTestController::maxViewHeight;
     270    int numberOfPages = [mainFrame numberOfPages:pageWidthInPixels:pageHeightInPixels];
     271
     272    RefPtr<BitmapContext> bitmapContext = createBitmapContext(pageWidthInPixels, numberOfPages * (pageHeightInPixels + 1) - 1);
     273    [mainFrame printToCGContext:bitmapContext->cgContext():pageWidthInPixels:pageHeightInPixels];
     274    return bitmapContext.release();
     275}
Note: See TracChangeset for help on using the changeset viewer.