summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-10 23:06:06 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-10 23:06:06 +0000
commit76d940b7d89f94f3ff4eea19f5970b57e0adcf93 (patch)
treed9ad129eb0b1c9c0b2463f5af484b4b4455aee89
parent185e83e4d68bad4ddc8bc48d93a38c9bc4219ba3 (diff)
downloadchromium_src-76d940b7d89f94f3ff4eea19f5970b57e0adcf93.zip
chromium_src-76d940b7d89f94f3ff4eea19f5970b57e0adcf93.tar.gz
chromium_src-76d940b7d89f94f3ff4eea19f5970b57e0adcf93.tar.bz2
Add support for the "repaint" layout tests (LayoutTests/fast/repaint/*), which draw a gray mask over regions that have not been updated.
This still doesn't match the mac expected results, because clip area is wrong. BUG=8630 Review URL: http://codereview.chromium.org/21192 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11396 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/webframe_impl.cc2
-rw-r--r--webkit/tools/layout_tests/test_lists/tests_fixable.txt30
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc7
-rw-r--r--webkit/tools/test_shell/mac/webwidget_host.mm32
-rwxr-xr-xwebkit/tools/test_shell/test_shell.cc29
-rw-r--r--webkit/tools/test_shell/test_shell.h4
-rw-r--r--webkit/tools/test_shell/webwidget_host.h12
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc26
-rw-r--r--webkit/tools/test_shell/webwidget_host_win.cc24
9 files changed, 139 insertions, 27 deletions
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index bf4fb03..9c09696 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1460,6 +1460,8 @@ void WebFrameImpl::Paint(skia::PlatformCanvas* canvas, const gfx::Rect& rect) {
GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
#endif
if (frame_->document() && frameview()) {
+ // TODO(eroman): See http://crbug.com/8630
+ // gc.clip(dirty_rect);
frameview()->paint(&gc, dirty_rect);
frame_->page()->inspectorController()->drawNodeHighlight(gc);
} else {
diff --git a/webkit/tools/layout_tests/test_lists/tests_fixable.txt b/webkit/tools/layout_tests/test_lists/tests_fixable.txt
index 8faec31..9a5d9b2 100644
--- a/webkit/tools/layout_tests/test_lists/tests_fixable.txt
+++ b/webkit/tools/layout_tests/test_lists/tests_fixable.txt
@@ -134,6 +134,30 @@ DEFER : LayoutTests/fast/html/keygen.html = FAIL
DEFER : LayoutTests/fast/invalid/residual-style.html = FAIL
// -----------------------------------------------------------------
+// Repaint tests
+// -----------------------------------------------------------------
+
+// Bug 8630: our repaint baselines are incorrect.
+
+DEFER : LayoutTests/fast/repaint = FAIL
+DEFER : LayoutTests/fast/backgrounds/solid-color-context-restore.html = FAIL
+DEFER : LayoutTests/fast/dom/anchor-toString.html = FAIL
+DEFER : LayoutTests/fast/dynamic/containing-block-change.html = FAIL
+DEFER : LayoutTests/fast/forms/hidden-listbox.html = FAIL
+DEFER : LayoutTests/fast/forms/listbox-clip.html = FAIL
+DEFER : LayoutTests/fast/frames/inline-object-inside-frameset.html = FAIL
+DEFER : LayoutTests/fast/layers/add-layer-with-nested-stacking.html = FAIL
+DEFER : LayoutTests/fast/layers/layer-content-visibility-change.html = FAIL
+DEFER : LayoutTests/fast/layers/remove-layer-with-nested-stacking.html = FAIL
+DEFER : LayoutTests/fast/overflow/hidden-scrollbar-resize.html = FAIL
+DEFER : LayoutTests/fast/reflections/inline-crash.html = FAIL
+DEFER : LayoutTests/fast/replaced/width100percent-textarea.html = FAIL
+DEFER : LayoutTests/fast/table/empty-section-crash.html = FAIL
+DEFER : LayoutTests/fast/text/font-initial.html = FAIL
+DEFER : LayoutTests/svg/W3C-SVG-1.1/struct-image-05-b.svg = FAIL
+DEFER : pending/fast/repaint/bugzilla-6473.html = FAIL
+
+// -----------------------------------------------------------------
// Other
// -----------------------------------------------------------------
@@ -582,8 +606,8 @@ DEFER LINUX WIN : LayoutTests/editing/selection/4960137.html = FAIL
// unpainted space (filled red in Debug but not in Release).
// https://bugs.webkit.org/show_bug.cgi?id=8423
DEFER : LayoutTests/tables/mozilla_expected_failures/bugs/bug178855.xml = FAIL PASS
-// Passes release. Fails debug.
-DEFER DEBUG : LayoutTests/fast/flexbox/flex-hang.html = FAIL PASS
+// Passes release. Fails debug. Looks like something is going off with repaint too.
+DEFER : LayoutTests/fast/flexbox/flex-hang.html = FAIL PASS
// Bug: 1166644
// Fails on webkit windows as well.
@@ -914,7 +938,6 @@ LINUX WIN : LayoutTests/fast/repaint/overflow-outline-repaint.html = FAIL
WIN : LayoutTests/fast/repaint/overflow-scroll-delete.html = FAIL
// Likely just needs to be baselined.
LINUX MAC : LayoutTests/fast/forms/form-element-geometry.html = FAIL
-LINUX MAC : LayoutTests/fast/replaced/width100percent-textarea.html = FAIL
LINUX : LayoutTests/fast/text/drawBidiText.html = FAIL
LINUX : LayoutTests/http/tests/security/dataURL/xss-DENIED-from-data-url-in-foreign-domain-subframe.html = TIMEOUT PASS
LayoutTests/http/tests/security/dataURL/xss-DENIED-from-data-url-sub-frame-to-data-url-sub-frame.html = FAIL
@@ -1649,7 +1672,6 @@ DEFER : LayoutTests/fast/dom/getBoundingClientRect-getClientRects-relative-to-vi
// Upstream regression. https://bugs.webkit.org/show_bug.cgi?id=24248
LINUX WIN : LayoutTests/fast/overflow/004.html = FAIL
// These need to be rebaselined.
-LINUX : LayoutTests/fast/overflow/hidden-scrollbar-resize.html = FAIL
LINUX : LayoutTests/fast/overflow/hit-test-overflow-controls.html = FAIL
// mbelshe to fix. Temporarily disable while tree red.
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index affd0da..50e0460 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -189,7 +189,7 @@ void LayoutTestController::WorkQueue::AddWork(WorkItem* work) {
}
void LayoutTestController::dumpAsText(const CppArgumentList& args,
- CppVariant* result) {
+ CppVariant* result) {
dump_as_text_ = true;
result->SetNull();
}
@@ -279,7 +279,7 @@ void LayoutTestController::notifyDone(
class WorkItemBackForward : public LayoutTestController::WorkItem {
public:
- WorkItemBackForward(int distance) : distance_(distance) {}
+ explicit WorkItemBackForward(int distance) : distance_(distance) {}
void Run(TestShell* shell) {
shell->GoBackOrForward(distance_);
}
@@ -316,7 +316,7 @@ void LayoutTestController::queueReload(
class WorkItemScript : public LayoutTestController::WorkItem {
public:
- WorkItemScript(const string& script) : script_(script) {}
+ explicit WorkItemScript(const string& script) : script_(script) {}
void Run(TestShell* shell) {
wstring url = L"javascript:" + UTF8ToWide(script_);
shell->LoadURL(url.c_str());
@@ -663,6 +663,7 @@ void LayoutTestController::dumpSelectionRect(
void LayoutTestController::display(
const CppArgumentList& args, CppVariant* result) {
+ shell_->webViewHost()->DisplayForRepaint();
result->SetNull();
}
diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm
index fd95535..1fed2f9 100644
--- a/webkit/tools/test_shell/mac/webwidget_host.mm
+++ b/webkit/tools/test_shell/mac/webwidget_host.mm
@@ -143,10 +143,14 @@ void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
}
void WebWidgetHost::Paint() {
+ PaintToCanvas();
+ PaintCanvasToView();
+}
+
+void WebWidgetHost::PaintToCanvas() {
NSRect r = [view_ frame];
gfx::Rect client_rect(NSRectToCGRect(r));
NSGraphicsContext* view_context = [NSGraphicsContext currentContext];
- CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]);
// Allocate a canvas if necessary
if (!canvas_.get()) {
@@ -191,21 +195,45 @@ void WebWidgetHost::Paint() {
// set the context back to our window
[NSGraphicsContext setCurrentContext: view_context];
+}
+void WebWidgetHost::PaintCanvasToView() {
// Paint to the screen
if ([view_ lockFocusIfCanDraw]) {
+ NSGraphicsContext* view_context = [NSGraphicsContext currentContext];
+ NSRect r = [view_ frame];
+ CGContextRef bitmap_context =
+ canvas_->getTopPlatformDevice().GetBitmapContext();
+ CGContextRef context =
+ static_cast<CGContextRef>([view_context graphicsPort]);
CGRect paint_rect = NSRectToCGRect(r);
int bitmap_height = CGBitmapContextGetHeight(bitmap_context);
int bitmap_width = CGBitmapContextGetWidth(bitmap_context);
CGRect bitmap_rect = { { 0, 0 },
{ bitmap_width, bitmap_height } };
canvas_->getTopPlatformDevice().DrawToContext(
- context, 0, client_rect.height() - bitmap_height, &bitmap_rect);
+ context, 0, r.size.height - bitmap_height, &bitmap_rect);
[view_ unlockFocus];
}
}
+void WebWidgetHost::DisplayForRepaint() {
+ PaintToCanvas();
+
+ // Paint a gray mask over everything for the repaint Layout tests.
+ CGContextRef bitmap_context =
+ canvas_->getTopPlatformDevice().GetBitmapContext();
+ CGRect bitmap_rect = { { 0, 0 },
+ { CGBitmapContextGetWidth(bitmap_context),
+ CGBitmapContextGetHeight(bitmap_context) } };
+ CGContextSetBlendMode(bitmap_context, kCGBlendModeNormal);
+ CGContextSetRGBFillColor(bitmap_context, 0, 0, 0, 0.66);
+ CGContextFillRect(bitmap_context, bitmap_rect);
+
+ PaintCanvasToView();
+}
+
void WebWidgetHost::Resize(const gfx::Rect& rect) {
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
DiscardBackingStore();
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 3dc08bb..47afbb4 100755
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -29,7 +29,7 @@
#include "net/base/mime_util.h"
#include "net/url_request/url_request_file_job.h"
#include "net/url_request/url_request_filter.h"
-#include "skia/ext/bitmap_platform_device.h"
+#include "skia/ext/platform_device.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/glue/screen_info.h"
#include "webkit/glue/webdatasource.h"
@@ -227,7 +227,8 @@ void TestShell::Dump(TestShell* shell) {
// command line (for the dump pixels argument), and the MD5 sum to
// stdout.
dumped_anything = true;
- std::string md5sum = DumpImage(webFrame, params->pixel_file_name);
+ std::string md5sum = DumpImage(shell->webViewHost(),
+ params->pixel_file_name);
printf("#MD5:%s\n", md5sum.c_str());
}
if (dumped_anything)
@@ -237,13 +238,20 @@ void TestShell::Dump(TestShell* shell) {
}
// static
-std::string TestShell::DumpImage(WebFrame* web_frame,
+std::string TestShell::DumpImage(WebViewHost* web_view_host,
const std::wstring& file_name) {
- scoped_ptr<skia::BitmapPlatformDevice> device;
- if (!web_frame->CaptureImage(&device, true))
- return std::string();
+ web_view_host->Paint();
+ skia::PlatformDevice& device =
+ web_view_host->canvas()->getTopPlatformDevice();
- const SkBitmap& src_bmp = device->accessBitmap(false);
+#if defined(OS_WIN)
+ // Make a copy, since we will have to fix the opacity.
+ const SkBitmap& orig = device.accessBitmap(false);
+ SkBitmap src_bmp;
+ orig.copyTo(&src_bmp, orig.config());
+#else
+ const SkBitmap& src_bmp = device.accessBitmap(false);
+#endif
// Encode image.
std::vector<unsigned char> png;
@@ -257,7 +265,12 @@ std::string TestShell::DumpImage(WebFrame* web_frame,
// doesn't have the wrong alpha like Windows, but we ignore it anyway.
#if defined(OS_WIN)
bool discard_transparency = true;
- device->makeOpaque(0, 0, src_bmp.width(), src_bmp.height());
+ // TODO(eroman): Clean this up. This used to be device.makeOpaque(), but I
+ // inlined it when resolving conflicts.
+ uint32_t* data = static_cast<uint32_t*> (src_bmp.getPixels());
+ for (int i = 0; i < src_bmp.width() * src_bmp.height(); ++i) {
+ *(data + i) |= (0xFF << SK_A32_SHIFT);
+ }
#elif defined(OS_LINUX)
bool discard_transparency = true;
#elif defined(OS_MACOSX)
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index 0777ae0..7366900 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -209,9 +209,9 @@ public:
// the flags set.
static void Dump(TestShell* shell);
- // Writes the image captured from the given web frame to the given file.
+ // Writes the image captured from the given web view to the given file.
// The returned string is the ASCII-ized MD5 sum of the image.
- static std::string DumpImage(WebFrame* web_frame,
+ static std::string DumpImage(WebViewHost* web_view_host,
const std::wstring& file_name);
static void ResetWebPreferences();
diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h
index 216c0b1..ca32948 100644
--- a/webkit/tools/test_shell/webwidget_host.h
+++ b/webkit/tools/test_shell/webwidget_host.h
@@ -46,7 +46,19 @@ class WebWidgetHost {
void UpdatePaintRect(const gfx::Rect& rect);
void Paint();
+ // Get the backing store.
+ skia::PlatformCanvas* canvas() const { return canvas_.get(); }
+
+ // Paint() the widget, and cover it with a gray mask (black with a=0.66).
+ void DisplayForRepaint();
+
protected:
+ // Paint the widget into canvas_.
+ void PaintToCanvas();
+
+ // Blit |canvas_| to |view_|.
+ void PaintCanvasToView();
+
WebWidgetHost();
~WebWidgetHost();
diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc
index 57d88d8..e12b7c3 100644
--- a/webkit/tools/test_shell/webwidget_host_gtk.cc
+++ b/webkit/tools/test_shell/webwidget_host_gtk.cc
@@ -285,6 +285,11 @@ void WebWidgetHost::Resize(const gfx::Size &newsize) {
}
void WebWidgetHost::Paint() {
+ PaintToCanvas();
+ PaintCanvasToView();
+}
+
+void WebWidgetHost::PaintToCanvas() {
int width = view_->allocation.width;
int height = view_->allocation.height;
gfx::Rect client_rect(width, height);
@@ -323,14 +328,17 @@ void WebWidgetHost::Paint() {
}
DCHECK(paint_rect_.IsEmpty());
+}
+
+void WebWidgetHost::PaintCanvasToView() {
// Invalidate the paint region on the widget's underlying gdk window. Note
// that gdk_window_invalidate_* will generate extra expose events, which
// we wish to avoid. So instead we use calls to begin_paint/end_paint.
GdkRectangle grect = {
- total_paint.x(),
- total_paint.y(),
- total_paint.width(),
- total_paint.height(),
+ 0,
+ 0,
+ canvas_->getDevice()->width(),
+ canvas_->getDevice()->height(),
};
GdkWindow* window = view_->window;
gdk_window_begin_paint_rect(window, &grect);
@@ -347,6 +355,16 @@ void WebWidgetHost::Paint() {
gdk_window_end_paint(window);
}
+void WebWidgetHost::DisplayForRepaint() {
+ PaintToCanvas();
+
+ // Paint a gray mask over everything for the repaint Layout tests.
+ const SkColor kMaskColor = SkColorSetARGB(168, 0, 0, 0); // alpha=0.66
+ canvas_->drawColor(kMaskColor, SkPorterDuff::kSrcOver_Mode);
+
+ PaintCanvasToView();
+}
+
void WebWidgetHost::ResetScrollRect() {
// This method is only needed for optimized scroll painting, which we don't
// care about in the test shell, yet.
diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc
index fc4be75..a8b561c 100644
--- a/webkit/tools/test_shell/webwidget_host_win.cc
+++ b/webkit/tools/test_shell/webwidget_host_win.cc
@@ -210,6 +210,11 @@ void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
}
void WebWidgetHost::Paint() {
+ PaintToCanvas();
+ PaintCanvasToView();
+}
+
+void WebWidgetHost::PaintToCanvas() {
RECT r;
GetClientRect(view_, &r);
gfx::Rect client_rect(r);
@@ -251,8 +256,9 @@ void WebWidgetHost::Paint() {
}
}
DCHECK(paint_rect_.IsEmpty());
+}
- // Paint to the screen
+void WebWidgetHost::PaintCanvasToView() {
PAINTSTRUCT ps;
BeginPaint(view_, &ps);
canvas_->getTopPlatformDevice().drawToHDC(ps.hdc,
@@ -265,6 +271,16 @@ void WebWidgetHost::Paint() {
UpdateWindow(view_);
}
+void WebWidgetHost::DisplayForRepaint() {
+ PaintToCanvas();
+
+ // Paint a gray mask over everything for the repaint Layout tests.
+ const SkColor kMaskColor = SkColorSetARGB(168, 0, 0, 0); // alpha=0.66
+ canvas_->drawColor(kMaskColor, SkPorterDuff::kSrcOver_Mode);
+
+ PaintCanvasToView();
+}
+
void WebWidgetHost::Resize(LPARAM lparam) {
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
DiscardBackingStore();
@@ -283,9 +299,9 @@ void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
break;
case WebInputEvent::MOUSE_DOWN:
SetCapture(view_);
- // This mimics a temporary workaround in RenderWidgetHostViewWin
- // for bug 765011 to get focus when the mouse is clicked. This
- // happens after the mouse down event is sent to the renderer
+ // This mimics a temporary workaround in RenderWidgetHostViewWin
+ // for bug 765011 to get focus when the mouse is clicked. This
+ // happens after the mouse down event is sent to the renderer
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
::SetFocus(view_);
break;