Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: webkit/tools/test_shell/webwidget_host_gtk.cc

Issue 11371: Fix infinite paint loop on Linux. (Closed)
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/tools/test_shell/webwidget_host.h" 5 #include "webkit/tools/test_shell/webwidget_host.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/gfx/platform_canvas_linux.h" 11 #include "base/gfx/platform_canvas_linux.h"
12 #include "base/gfx/platform_device_linux.h" 12 #include "base/gfx/platform_device_linux.h"
13 #include "base/gfx/bitmap_platform_device_linux.h" 13 #include "base/gfx/bitmap_platform_device_linux.h"
14 #include "webkit/glue/webinputevent.h" 14 #include "webkit/glue/webinputevent.h"
15 #include "webkit/glue/webwidget.h" 15 #include "webkit/glue/webwidget.h"
16 16
17 namespace { 17 namespace {
18 18
19 bool handling_expose = false;
20
19 // ----------------------------------------------------------------------------- 21 // -----------------------------------------------------------------------------
20 // Callback functions to proxy to host... 22 // Callback functions to proxy to host...
21 23
22 gboolean ConfigureEvent(GtkWidget* widget, GdkEventConfigure* config, 24 gboolean ConfigureEvent(GtkWidget* widget, GdkEventConfigure* config,
23 WebWidgetHost* host) { 25 WebWidgetHost* host) {
24 host->Resize(gfx::Size(config->width, config->height)); 26 host->Resize(gfx::Size(config->width, config->height));
25 return FALSE; 27 return FALSE;
26 } 28 }
27 29
28 gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose, 30 gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose,
29 WebWidgetHost* host) { 31 WebWidgetHost* host) {
32 handling_expose = true;
30 gfx::Rect rect(expose->area); 33 gfx::Rect rect(expose->area);
31 host->UpdatePaintRect(rect); 34 host->UpdatePaintRect(rect);
32 host->Paint(); 35 host->Paint();
36 handling_expose = false;
33 return FALSE; 37 return FALSE;
34 } 38 }
35 39
36 gboolean DestroyEvent(GtkWidget* widget, GdkEvent* event, 40 gboolean DestroyEvent(GtkWidget* widget, GdkEvent* event,
37 WebWidgetHost* host) { 41 WebWidgetHost* host) {
38 host->WindowDestroyed(); 42 host->WindowDestroyed();
39 return FALSE; 43 return FALSE;
40 } 44 }
41 45
42 gboolean KeyPressReleaseEvent(GtkWidget* widget, GdkEventKey* event, 46 gboolean KeyPressReleaseEvent(GtkWidget* widget, GdkEventKey* event,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 152
149 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { 153 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
150 paint_rect_ = paint_rect_.Union(rect); 154 paint_rect_ = paint_rect_.Union(rect);
151 } 155 }
152 156
153 void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { 157 void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
154 DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; 158 DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
155 159
156 UpdatePaintRect(damaged_rect); 160 UpdatePaintRect(damaged_rect);
157 161
158 gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(), 162 if (!handling_expose) {
159 damaged_rect.y(), damaged_rect.width(), damaged_rect.height()); 163 gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(),
164 damaged_rect.y(), damaged_rect.width(), damaged_rect.height());
165 }
160 } 166 }
161 167
162 void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { 168 void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
163 // This is used for optimizing painting when the renderer is scrolled. We're 169 // This is used for optimizing painting when the renderer is scrolled. We're
164 // currently not doing any optimizations so just invalidate the region. 170 // currently not doing any optimizations so just invalidate the region.
165 DidInvalidateRect(clip_rect); 171 DidInvalidateRect(clip_rect);
166 } 172 }
167 173
168 WebWidgetHost* FromWindow(gfx::WindowHandle view) { 174 WebWidgetHost* FromWindow(gfx::WindowHandle view) {
169 const gpointer p = g_object_get_data(G_OBJECT(view), "webwidgethost"); 175 const gpointer p = g_object_get_data(G_OBJECT(view), "webwidgethost");
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 255 }
250 256
251 // ----------------------------------------------------------------------------- 257 // -----------------------------------------------------------------------------
252 // This is called when the GTK window is destroyed. In the Windows code this 258 // This is called when the GTK window is destroyed. In the Windows code this
253 // deletes this object. Since it's only test_shell it probably doesn't matter 259 // deletes this object. Since it's only test_shell it probably doesn't matter
254 // that much. 260 // that much.
255 // ----------------------------------------------------------------------------- 261 // -----------------------------------------------------------------------------
256 void WebWidgetHost::WindowDestroyed() { 262 void WebWidgetHost::WindowDestroyed() {
257 delete this; 263 delete this;
258 } 264 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698