From 78c23fc30bca8299fd9678e56aba1aa08888d6b5 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 18 Oct 2011 00:06:44 +0000 Subject: [PATCH] Mac: fix repaint artifacts introduced by issue #360 when overlapping elements are scrolled. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@319 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/webwidget_host_mac.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libcef/webwidget_host_mac.mm b/libcef/webwidget_host_mac.mm index b3733763e..a830b3e1e 100644 --- a/libcef/webwidget_host_mac.mm +++ b/libcef/webwidget_host_mac.mm @@ -61,8 +61,8 @@ void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { DCHECK(dx || dy); - gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); - gfx::Rect rect = clip_rect.Intersect(client_rect); + const gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); + const gfx::Rect rect = clip_rect.Intersect(client_rect); // Convert scroll rectangle to the view's coordinate system, and perform the // scroll directly, without invalidating the view. In theory this could cause @@ -105,6 +105,16 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { paint_rect_ = gfx::Rect(rect.x(), rect.y() + dy, rect.width(), -dx); Paint(); + // If any part of the scrolled rect was marked as dirty, make sure to redraw + // it in the new scrolled-to location. Otherwise we can end up with artifacts + // for overlapping elements. + gfx::Rect moved_paint_rect = saved_paint_rect.Intersect(clip_rect); + if (!moved_paint_rect.IsEmpty()) { + moved_paint_rect.Offset(dx, dy); + paint_rect_ = moved_paint_rect; + Paint(); + } + paint_rect_ = saved_paint_rect; }