Title: [96005] trunk
Revision
96005
Author
[email protected]
Date
2011-09-26 15:19:10 -0700 (Mon, 26 Sep 2011)

Log Message

Repaint tests don't work in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=68453

Tools:

Reviewed by Sam Weinig.

Convert DumpRenderTree to use use the repaint rects
exposed via WebKit API when generating the repaint test
overlay.

Fix WebKitTestRunner to work with repaint tests, again
using the repaint rects exposed from WK2.

In both cases, layoutTestController.display() now just
forces a display of the web view, and turns on repaint
rect tracking on the main FrameView.

Later, when pixel results are requested, the alpha overlay
that shows the repaint rects is generated using the list
of rects supplied by WebCore.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetDefaultsToConsistentValues):
(resetWebViewToConsistentStateBeforeTesting):
(displayWebView):
* DumpRenderTree/mac/PixelDumpSupportMac.mm:
(paintRepaintRectOverlay):
(createBitmapContextFromWebView):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
(WTR::InjectedBundle::done):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(WTR::InjectedBundle::setRepaintRects):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::reset):
(WTR::InjectedBundlePage::dump):
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::display):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestInvocation.h:
* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::paintRepaintRectOverlay):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):

LayoutTests:

Reviewed by Sam Weinig.

Update Mac results to use the new repaint rects. Differences from old results:
	        * There are no longer invalidates from scrolling.
	        * We no longer see the effects of AppKit rect coalescing.
	        * Composting tests show the overlay now, but repaints in compositing layers do not show.

	    Bad results in a couple of tests are covered by bugs 68830 and 68829.

* platform/mac/fast/repaint/4774354-expected.png:
* platform/mac/fast/repaint/block-layout-inline-children-float-positioned-expected.png:
* platform/mac/fast/repaint/block-selection-gap-in-composited-layer-expected.png:
* platform/mac/fast/repaint/border-radius-repaint-expected.png:
* platform/mac/fast/repaint/clipped-relative-expected.png:
* platform/mac/fast/repaint/containing-block-position-change-expected.png:
* platform/mac/fast/repaint/control-clip-expected.png:
* platform/mac/fast/repaint/delete-into-nested-block-expected.png:
* platform/mac/fast/repaint/fixed-and-absolute-position-scrolled-expected.png:
* platform/mac/fast/repaint/fixed-scroll-simple-expected.png:
* platform/mac/fast/repaint/flexible-box-overflow-expected.png:
* platform/mac/fast/repaint/flexible-box-overflow-horizontal-expected.png:
* platform/mac/fast/repaint/float-move-during-layout-expected.png:
* platform/mac/fast/repaint/float-overflow-expected.png:
* platform/mac/fast/repaint/float-overflow-right-expected.png:
* platform/mac/fast/repaint/iframe-scroll-repaint-expected.png:
* platform/mac/fast/repaint/inline-block-overflow-expected.png:
* platform/mac/fast/repaint/japanese-rl-selection-repaint-expected.png:
* platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.png:
* platform/mac/fast/repaint/layer-child-outline-expected.png:
* platform/mac/fast/repaint/layer-outline-expected.png:
* platform/mac/fast/repaint/layer-outline-horizontal-expected.png:
* platform/mac/fast/repaint/line-flow-with-floats-in-regions-expected.png:
* platform/mac/fast/repaint/line-overflow-expected.png:
* platform/mac/fast/repaint/nested-iframe-scroll-inner-expected.png:
* platform/mac/fast/repaint/nested-iframe-scroll-outer-expected.png:
* platform/mac/fast/repaint/outline-child-repaint-expected.png:
* platform/mac/fast/repaint/outline-shrinking-expected.png:
* platform/mac/fast/repaint/overflow-delete-line-expected.png:
* platform/mac/fast/repaint/overflow-flipped-writing-mode-block-in-regions-expected.png:
* platform/mac/fast/repaint/repaint-during-scroll-expected.png:
* platform/mac/fast/repaint/scale-page-shrink-expected.png:
* platform/mac/fast/repaint/search-field-cancel-expected.png:
* platform/mac/fast/repaint/selection-after-remove-expected.png:
* platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png:
* platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png:
* platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png:
* platform/mac/fast/repaint/shadow-multiple-vertical-expected.png:
* platform/mac/fast/repaint/static-to-positioned-expected.png:
* platform/mac/fast/repaint/table-cell-move-expected.png:
* platform/mac/fast/repaint/text-selection-rect-in-overflow-2-expected.png:
* platform/mac/fast/repaint/text-shadow-expected.png:
* platform/mac/fast/repaint/text-shadow-horizontal-expected.png:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96004 => 96005)


--- trunk/LayoutTests/ChangeLog	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/LayoutTests/ChangeLog	2011-09-26 22:19:10 UTC (rev 96005)
@@ -1,3 +1,61 @@
+2011-09-26  Simon Fraser  <[email protected]>
+
+        Repaint tests don't work in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=68453
+
+        Reviewed by Sam Weinig.
+        
+        Update Mac results to use the new repaint rects. Differences from old results:
+	        * There are no longer invalidates from scrolling.
+	        * We no longer see the effects of AppKit rect coalescing.
+	        * Composting tests show the overlay now, but repaints in compositing layers do not show.
+	        
+	    Bad results in a couple of tests are covered by bugs 68830 and 68829.
+
+        * platform/mac/fast/repaint/4774354-expected.png:
+        * platform/mac/fast/repaint/block-layout-inline-children-float-positioned-expected.png:
+        * platform/mac/fast/repaint/block-selection-gap-in-composited-layer-expected.png:
+        * platform/mac/fast/repaint/border-radius-repaint-expected.png:
+        * platform/mac/fast/repaint/clipped-relative-expected.png:
+        * platform/mac/fast/repaint/containing-block-position-change-expected.png:
+        * platform/mac/fast/repaint/control-clip-expected.png:
+        * platform/mac/fast/repaint/delete-into-nested-block-expected.png:
+        * platform/mac/fast/repaint/fixed-and-absolute-position-scrolled-expected.png:
+        * platform/mac/fast/repaint/fixed-scroll-simple-expected.png:
+        * platform/mac/fast/repaint/flexible-box-overflow-expected.png:
+        * platform/mac/fast/repaint/flexible-box-overflow-horizontal-expected.png:
+        * platform/mac/fast/repaint/float-move-during-layout-expected.png:
+        * platform/mac/fast/repaint/float-overflow-expected.png:
+        * platform/mac/fast/repaint/float-overflow-right-expected.png:
+        * platform/mac/fast/repaint/iframe-scroll-repaint-expected.png:
+        * platform/mac/fast/repaint/inline-block-overflow-expected.png:
+        * platform/mac/fast/repaint/japanese-rl-selection-repaint-expected.png:
+        * platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.png:
+        * platform/mac/fast/repaint/layer-child-outline-expected.png:
+        * platform/mac/fast/repaint/layer-outline-expected.png:
+        * platform/mac/fast/repaint/layer-outline-horizontal-expected.png:
+        * platform/mac/fast/repaint/line-flow-with-floats-in-regions-expected.png:
+        * platform/mac/fast/repaint/line-overflow-expected.png:
+        * platform/mac/fast/repaint/nested-iframe-scroll-inner-expected.png:
+        * platform/mac/fast/repaint/nested-iframe-scroll-outer-expected.png:
+        * platform/mac/fast/repaint/outline-child-repaint-expected.png:
+        * platform/mac/fast/repaint/outline-shrinking-expected.png:
+        * platform/mac/fast/repaint/overflow-delete-line-expected.png:
+        * platform/mac/fast/repaint/overflow-flipped-writing-mode-block-in-regions-expected.png:
+        * platform/mac/fast/repaint/repaint-during-scroll-expected.png:
+        * platform/mac/fast/repaint/scale-page-shrink-expected.png:
+        * platform/mac/fast/repaint/search-field-cancel-expected.png:
+        * platform/mac/fast/repaint/selection-after-remove-expected.png:
+        * platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png:
+        * platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png:
+        * platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png:
+        * platform/mac/fast/repaint/shadow-multiple-vertical-expected.png:
+        * platform/mac/fast/repaint/static-to-positioned-expected.png:
+        * platform/mac/fast/repaint/table-cell-move-expected.png:
+        * platform/mac/fast/repaint/text-selection-rect-in-overflow-2-expected.png:
+        * platform/mac/fast/repaint/text-shadow-expected.png:
+        * platform/mac/fast/repaint/text-shadow-horizontal-expected.png:
+
 2011-09-26  John Bauman  <[email protected]>
 
         Fix nonpremultiplied webgl toDataURL to jpeg

Modified: trunk/LayoutTests/platform/mac/fast/repaint/4774354-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/block-layout-inline-children-float-positioned-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/block-selection-gap-in-composited-layer-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/border-radius-repaint-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/clipped-relative-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/containing-block-position-change-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/control-clip-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/delete-into-nested-block-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/fixed-and-absolute-position-scrolled-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/fixed-scroll-simple-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/flexible-box-overflow-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/flexible-box-overflow-horizontal-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/float-move-during-layout-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/float-overflow-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/float-overflow-right-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/iframe-scroll-repaint-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/inline-block-overflow-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/japanese-rl-selection-repaint-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/layer-child-outline-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/layer-outline-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/layer-outline-horizontal-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/line-flow-with-floats-in-regions-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/line-overflow-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/nested-iframe-scroll-inner-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/nested-iframe-scroll-outer-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/outline-child-repaint-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/outline-shrinking-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/overflow-delete-line-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/overflow-flipped-writing-mode-block-in-regions-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/repaint-during-scroll-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/scale-page-shrink-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/search-field-cancel-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/selection-after-remove-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/shadow-multiple-horizontal-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-horizontal-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/shadow-multiple-strict-vertical-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/shadow-multiple-vertical-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/static-to-positioned-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/table-cell-move-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/text-selection-rect-in-overflow-2-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/text-shadow-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/repaint/text-shadow-horizontal-expected.png


(Binary files differ)

Modified: trunk/Tools/ChangeLog (96004 => 96005)


--- trunk/Tools/ChangeLog	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/ChangeLog	2011-09-26 22:19:10 UTC (rev 96005)
@@ -1,3 +1,49 @@
+2011-09-26  Simon Fraser  <[email protected]>
+
+        Repaint tests don't work in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=68453
+
+        Reviewed by Sam Weinig.
+        
+        Convert DumpRenderTree to use use the repaint rects
+        exposed via WebKit API when generating the repaint test
+        overlay.
+        
+        Fix WebKitTestRunner to work with repaint tests, again
+        using the repaint rects exposed from WK2.
+        
+        In both cases, layoutTestController.display() now just
+        forces a display of the web view, and turns on repaint
+        rect tracking on the main FrameView.
+        
+        Later, when pixel results are requested, the alpha overlay
+        that shows the repaint rects is generated using the list
+        of rects supplied by WebCore.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetDefaultsToConsistentValues):
+        (resetWebViewToConsistentStateBeforeTesting):
+        (displayWebView):
+        * DumpRenderTree/mac/PixelDumpSupportMac.mm:
+        (paintRepaintRectOverlay):
+        (createBitmapContextFromWebView):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        (WTR::InjectedBundle::done):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        (WTR::InjectedBundle::setRepaintRects):
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::reset):
+        (WTR::InjectedBundlePage::dump):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::display):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+        * WebKitTestRunner/TestInvocation.h:
+        * WebKitTestRunner/cg/TestInvocationCG.cpp:
+        (WTR::paintRepaintRectOverlay):
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+
 2011-09-26  Nayan Kumar K  <[email protected]>
 
         Get hover'ed element URL from HitTest.

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (96004 => 96005)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2011-09-26 22:19:10 UTC (rev 96005)
@@ -350,7 +350,6 @@
 // Called before each test.
 static void resetDefaultsToConsistentValues()
 {
-    // Give some clear to undocumented defaults values
     static const int NoFontSmoothing = 0;
     static const int BlueTintedAppearance = 1;
 
@@ -1012,7 +1011,8 @@
     [WebView _removeAllUserContentFromGroup:[webView groupName]];
     [[webView window] setAutodisplay:NO];
     [webView _setMinimumTimerInterval:[WebView _defaultMinimumTimerInterval]];
-
+    [webView setTracksRepaints:NO];
+    
     resetDefaultsToConsistentValues();
 
     if (gLayoutTestController)
@@ -1172,12 +1172,11 @@
 
 void displayWebView()
 {
-    NSView *webView = [mainFrame webView];
+    WebView *webView = [mainFrame webView];
     [webView display];
-    [webView lockFocus];
-    [[[NSColor blackColor] colorWithAlphaComponent:0.66] set];
-    NSRectFillUsingOperation([webView frame], NSCompositeSourceOver);
-    [webView unlockFocus];
+    
+    [webView setTracksRepaints:YES];
+    [webView resetTrackedRepaints];
 }
 
 @implementation DumpRenderTreeEvent

Modified: trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm (96004 => 96005)


--- trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/DumpRenderTree/mac/PixelDumpSupportMac.mm	2011-09-26 22:19:10 UTC (rev 96005)
@@ -130,6 +130,35 @@
     return BitmapContext::createByAdoptingBitmapAndContext(buffer, context);
 }
 
+static void paintRepaintRectOverlay(WebView* webView, CGContextRef context)
+{
+    CGRect viewRect = NSRectToCGRect([webView bounds]);
+
+    CGContextSaveGState(context);
+
+    // Using a transparency layer is easier than futzing with clipping.
+    CGContextBeginTransparencyLayer(context, 0);
+
+    // Flip the context.
+    CGContextScaleCTM(context, 1, -1);
+    CGContextTranslateCTM(context, 0, -viewRect.size.height);
+    
+    CGContextSetRGBFillColor(context, 0, 0, 0, static_cast<CGFloat>(0.66));
+    CGContextFillRect(context, viewRect);
+
+    NSArray *repaintRects = [webView trackedRepaintRects];
+    if (repaintRects) {
+        
+        for (NSValue *value in repaintRects) {
+            CGRect currRect = NSRectToCGRect([value rectValue]);
+            CGContextClearRect(context, currRect);
+        }
+    }
+    
+    CGContextEndTransparencyLayer(context);
+    CGContextRestoreGState(context);
+}
+
 PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect)
 {
     WebView* view = [mainFrame webView];
@@ -175,6 +204,9 @@
             CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque);
             CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);
             CGImageRelease(image);
+
+            if ([view isTrackingRepaints])
+                paintRepaintRectOverlay(view, context);
         } else {
             // Make sure the view has been painted.
             [view displayIfNeeded];
@@ -188,6 +220,10 @@
             RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
             [NSGraphicsContext setCurrentContext:nsContext];
             [imageRep draw];
+            
+            if ([view isTrackingRepaints])
+                paintRepaintRectOverlay(view, context);
+            
             [NSGraphicsContext setCurrentContext:savedContext.get()];
         }
     }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2011-09-26 22:19:10 UTC (rev 96005)
@@ -170,6 +170,7 @@
 
     m_outputStream.str("");
     m_pixelResult.clear();
+    m_repaintRects.clear();
 
     m_layoutTestController = LayoutTestController::create();
     m_gcController = GCController::create();
@@ -209,6 +210,9 @@
     WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult"));
     WKDictionaryAddItem(doneMessageBody.get(), pixelResultKey.get(), m_pixelResult.get());
 
+    WKRetainPtr<WKStringRef> repaintRectsKey = adoptWK(WKStringCreateWithUTF8CString("RepaintRects"));
+    WKDictionaryAddItem(doneMessageBody.get(), repaintRectsKey.get(), m_repaintRects.get());
+
     WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
 
     closeOtherPages();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2011-09-26 22:19:10 UTC (rev 96005)
@@ -64,6 +64,7 @@
     void done();
     std::ostringstream& os() { return m_outputStream; }
     void setPixelResult(WKImageRef image) { m_pixelResult = image; }
+    void setRepaintRects(WKArrayRef rects) { m_repaintRects = rects; }
 
     bool isTestRunning() { return m_state == Testing; }
 
@@ -115,6 +116,7 @@
     bool m_dumpPixels;
 
     WKRetainPtr<WKImageRef> m_pixelResult;
+    WKRetainPtr<WKArrayRef> m_repaintRects;
 };
 
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2011-09-26 22:19:10 UTC (rev 96005)
@@ -307,6 +307,8 @@
     m_previousTestBackForwardListItem = adoptWK(WKBundleBackForwardListCopyItemAtIndex(WKBundlePageGetBackForwardList(m_page), 0));
 
     WKBundleFrameClearOpener(WKBundlePageGetMainFrame(m_page));
+    
+    WKBundlePageSetTracksRepaints(m_page, false);
 }
 
 // Loader Client Callbacks
@@ -575,8 +577,11 @@
     if (InjectedBundle::shared().layoutTestController()->shouldDumpBackForwardListsForAllWindows())
         InjectedBundle::shared().dumpBackForwardListsForAllPages();
 
-    if (InjectedBundle::shared().shouldDumpPixels() && InjectedBundle::shared().layoutTestController()->shouldDumpPixels())
+    if (InjectedBundle::shared().shouldDumpPixels() && InjectedBundle::shared().layoutTestController()->shouldDumpPixels()) {
         InjectedBundle::shared().setPixelResult(adoptWK(WKBundlePageCreateSnapshotInViewCoordinates(m_page, WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page)), kWKImageOptionsShareable)).get());
+        if (WKBundlePageIsTrackingRepaints(m_page))
+            InjectedBundle::shared().setRepaintRects(adoptWK(WKBundlePageCopyTrackedRepaintRects(m_page)).get());
+    }
 
     InjectedBundle::shared().done();
 }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-09-26 22:19:10 UTC (rev 96005)
@@ -122,7 +122,10 @@
 
 void LayoutTestController::display()
 {
-    // FIXME: actually implement, once we want pixel tests
+    WKBundlePageRef page = InjectedBundle::shared().page()->page();
+    WKBundlePageForceRepaint(page);
+    WKBundlePageSetTracksRepaints(page, true);
+    WKBundlePageResetTrackedRepaints(page);
 }
 
 void LayoutTestController::dumpAsText(bool dumpPixels)

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2011-09-26 22:19:10 UTC (rev 96005)
@@ -222,13 +222,16 @@
         WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult"));
         WKImageRef pixelResult = static_cast<WKImageRef>(WKDictionaryGetItemForKey(messageBodyDictionary, pixelResultKey.get()));
         ASSERT(!pixelResult || m_dumpPixels);
+        
+        WKRetainPtr<WKStringRef> repaintRectsKey = adoptWK(WKStringCreateWithUTF8CString("RepaintRects"));
+        WKArrayRef repaintRects = static_cast<WKArrayRef>(WKDictionaryGetItemForKey(messageBodyDictionary, repaintRectsKey.get()));        
 
         // Dump text.
         dump(toSTD(textOutput).c_str(), true);
 
         // Dump pixels (if necessary).
         if (m_dumpPixels && pixelResult)
-            dumpPixelsAndCompareWithExpected(pixelResult);
+            dumpPixelsAndCompareWithExpected(pixelResult, repaintRects);
 
         fputs("#EOF\n", stdout);
         fflush(stdout);

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2011-09-26 22:19:10 UTC (rev 96005)
@@ -46,7 +46,7 @@
 
 private:
     void dump(const char*, bool singleEOF = false);
-    void dumpPixelsAndCompareWithExpected(WKImageRef);
+    void dumpPixelsAndCompareWithExpected(WKImageRef, WKArrayRef repaintRects);
     bool compareActualHashToExpectedAndDumpResults(const char[33]);
     
     WKRetainPtr<WKURLRef> m_url;

Modified: trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp (96004 => 96005)


--- trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2011-09-26 22:19:05 UTC (rev 96004)
+++ trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2011-09-26 22:19:10 UTC (rev 96005)
@@ -114,10 +114,42 @@
     printPNG(data, dataLength, checksum);
 }
 
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image)
+static void paintRepaintRectOverlay(CGContextRef context, WKImageRef image, WKArrayRef repaintRects)
 {
+    WKSize imageSize = WKImageGetSize(image);
+
+    CGContextSaveGState(context);
+
+    // Using a transparency layer is easier than futzing with clipping.
+    CGContextBeginTransparencyLayer(context, 0);
+    
+    // Flip the context.
+    CGContextScaleCTM(context, 1, -1);
+    CGContextTranslateCTM(context, 0, -imageSize.height);
+    
+    CGContextSetRGBFillColor(context, 0, 0, 0, static_cast<CGFloat>(0.66));
+    CGContextFillRect(context, CGRectMake(0, 0, imageSize.width, imageSize.height));
+
+    // Clear the repaint rects.
+    size_t count = WKArrayGetSize(repaintRects);
+    for (size_t i = 0; i < count; ++i) {
+        WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i)));
+        CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+        CGContextClearRect(context, cgRect);
+    }
+    
+    CGContextEndTransparencyLayer(context);
+    CGContextRestoreGState(context);
+}
+
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects)
+{
     CGContextRef context = createCGContextFromImage(image);
 
+    // A non-null repaintRects array means we're doing a repaint test.
+    if (repaintRects)
+        paintRepaintRectOverlay(context, image, repaintRects);
+
     char actualHash[33];
     computeMD5HashStringForContext(context, actualHash);
     if (!compareActualHashToExpectedAndDumpResults(actualHash))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to