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:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96005
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-26 Simon Fraser <simon.fraser@apple.com>
+
+ 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 <jbauman@chromium.org>
Fix nonpremultiplied webgl toDataURL to jpeg
+2011-09-26 Simon Fraser <simon.fraser@apple.com>
+
+ 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 <nayankk@motorola.com>
Get hover'ed element URL from HitTest.
// Called before each test.
static void resetDefaultsToConsistentValues()
{
- // Give some clear to undocumented defaults values
static const int NoFontSmoothing = 0;
static const int BlueTintedAppearance = 1;
[WebView _removeAllUserContentFromGroup:[webView groupName]];
[[webView window] setAutodisplay:NO];
[webView _setMinimumTimerInterval:[WebView _defaultMinimumTimerInterval]];
-
+ [webView setTracksRepaints:NO];
+
resetDefaultsToConsistentValues();
if (gLayoutTestController)
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
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];
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];
RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
[NSGraphicsContext setCurrentContext:nsContext];
[imageRep draw];
+
+ if ([view isTrackingRepaints])
+ paintRepaintRectOverlay(view, context);
+
[NSGraphicsContext setCurrentContext:savedContext.get()];
}
}
m_outputStream.str("");
m_pixelResult.clear();
+ m_repaintRects.clear();
m_layoutTestController = LayoutTestController::create();
m_gcController = GCController::create();
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();
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; }
bool m_dumpPixels;
WKRetainPtr<WKImageRef> m_pixelResult;
+ WKRetainPtr<WKArrayRef> m_repaintRects;
};
} // namespace WTR
m_previousTestBackForwardListItem = adoptWK(WKBundleBackForwardListCopyItemAtIndex(WKBundlePageGetBackForwardList(m_page), 0));
WKBundleFrameClearOpener(WKBundlePageGetMainFrame(m_page));
+
+ WKBundlePageSetTracksRepaints(m_page, false);
}
// Loader Client Callbacks
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();
}
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)
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);
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;
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))