summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/tools/test_shell/gtk/webwidget_host.cc42
-rw-r--r--webkit/tools/test_shell/webwidget_host.h4
2 files changed, 16 insertions, 30 deletions
diff --git a/webkit/tools/test_shell/gtk/webwidget_host.cc b/webkit/tools/test_shell/gtk/webwidget_host.cc
index 029b27c..5700fca 100644
--- a/webkit/tools/test_shell/gtk/webwidget_host.cc
+++ b/webkit/tools/test_shell/gtk/webwidget_host.cc
@@ -28,6 +28,8 @@ gboolean ConfigureEvent(GtkWidget* widget, GdkEventConfigure* config,
gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose,
WebWidgetHost* host) {
+ gfx::Rect rect(expose->area);
+ host->UpdatePaintRect(rect);
host->Paint();
return FALSE;
}
@@ -135,39 +137,23 @@ WebWidgetHost* WebWidgetHost::Create(gfx::WindowHandle box,
return host;
}
+void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
+ paint_rect_ = paint_rect_.Union(rect);
+}
+
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
- // If this invalidate overlaps with a pending scroll, then we have to
- // downgrade to invalidating the scroll rect.
- if (damaged_rect.Intersects(scroll_rect_)) {
- paint_rect_ = paint_rect_.Union(scroll_rect_);
- ResetScrollRect();
- }
- paint_rect_ = paint_rect_.Union(damaged_rect);
+ UpdatePaintRect(damaged_rect);
gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(),
damaged_rect.y(), damaged_rect.width(), damaged_rect.height());
}
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
- DCHECK(dx || dy);
-
- // If we already have a pending scroll operation or if this scroll operation
- // intersects the existing paint region, then just failover to invalidating.
- if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) {
- paint_rect_ = paint_rect_.Union(scroll_rect_);
- ResetScrollRect();
- paint_rect_ = paint_rect_.Union(clip_rect);
- }
-
- // We will perform scrolling lazily, when requested to actually paint.
- scroll_rect_ = clip_rect;
- scroll_dx_ = dx;
- scroll_dy_ = dy;
-
- gtk_widget_queue_draw_area(GTK_WIDGET(view_), clip_rect.x(), clip_rect.y(),
- clip_rect.width(), clip_rect.height());
+ // This is used for optimizing painting when the renderer is scrolled. We're
+ // currently not doing any optimizations so just invalidate the region.
+ DidInvalidateRect(clip_rect);
}
WebWidgetHost* FromWindow(gfx::WindowHandle view) {
@@ -217,9 +203,6 @@ void WebWidgetHost::Paint() {
// This may result in more invalidation
webwidget_->Layout();
- // TODO(agl): Optimized scrolling code would go here.
- ResetScrollRect();
-
// Paint the canvas if necessary. Allow painting to generate extra rects the
// first time we call it. This is necessary because some WebCore rendering
// objects update their layout only when painted.
@@ -247,9 +230,8 @@ void WebWidgetHost::Paint() {
}
void WebWidgetHost::ResetScrollRect() {
- scroll_rect_ = gfx::Rect();
- scroll_dx_ = 0;
- scroll_dy_ = 0;
+ // This method is only needed for optimized scroll painting, which we don't
+ // care about in the test shell, yet.
}
void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h
index 583c9bf..3bc2ac8 100644
--- a/webkit/tools/test_shell/webwidget_host.h
+++ b/webkit/tools/test_shell/webwidget_host.h
@@ -83,6 +83,10 @@ class WebWidgetHost {
static gfx::WindowHandle CreateWindow(gfx::WindowHandle parent, void* host);
void WindowDestroyed();
void Resize(const gfx::Size& size);
+
+ // Allow clients to update the paint rect. For example, if we get a gdk
+ // expose event, we need to update the paint rect.
+ void UpdatePaintRect(const gfx::Rect& rect);
#endif
void TrackMouseLeave(bool enable);