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

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

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes Created 8 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 | « webkit/plugins/webview_plugin.cc ('k') | webkit/tools/test_shell/webwidget_host_mac.mm » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 host->view_ = CreateWidget(parent_view, host); 283 host->view_ = CreateWidget(parent_view, host);
284 host->webwidget_ = WebPopupMenu::create(client); 284 host->webwidget_ = WebPopupMenu::create(client);
285 // We manage our own double buffering because we need to be able to update 285 // We manage our own double buffering because we need to be able to update
286 // the expose area in an ExposeEvent within the lifetime of the event handler. 286 // the expose area in an ExposeEvent within the lifetime of the event handler.
287 gtk_widget_set_double_buffered(GTK_WIDGET(host->view_), false); 287 gtk_widget_set_double_buffered(GTK_WIDGET(host->view_), false);
288 288
289 return host; 289 return host;
290 } 290 }
291 291
292 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { 292 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
293 paint_rect_ = paint_rect_.Union(rect); 293 paint_rect_.Union(rect);
294 } 294 }
295 295
296 void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { 296 void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
297 DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; 297 DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
298 298
299 UpdatePaintRect(damaged_rect); 299 UpdatePaintRect(damaged_rect);
300 300
301 if (!g_handling_expose) { 301 if (!g_handling_expose) {
302 gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(), 302 gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(),
303 damaged_rect.y(), damaged_rect.width(), damaged_rect.height()); 303 damaged_rect.y(), damaged_rect.width(), damaged_rect.height());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // This may result in more invalidation 370 // This may result in more invalidation
371 webwidget_->layout(); 371 webwidget_->layout();
372 372
373 // Paint the canvas if necessary. Allow painting to generate extra rects the 373 // Paint the canvas if necessary. Allow painting to generate extra rects the
374 // first time we call it. This is necessary because some WebCore rendering 374 // first time we call it. This is necessary because some WebCore rendering
375 // objects update their layout only when painted. 375 // objects update their layout only when painted.
376 // Store the total area painted in total_paint. Then tell the gdk window 376 // Store the total area painted in total_paint. Then tell the gdk window
377 // to update that area after we're done painting it. 377 // to update that area after we're done painting it.
378 gfx::Rect total_paint; 378 gfx::Rect total_paint;
379 for (int i = 0; i < 2; ++i) { 379 for (int i = 0; i < 2; ++i) {
380 paint_rect_ = client_rect.Intersect(paint_rect_); 380 paint_rect_.Intersect(client_rect);
381 if (!paint_rect_.IsEmpty()) { 381 if (!paint_rect_.IsEmpty()) {
382 gfx::Rect rect(paint_rect_); 382 gfx::Rect rect(paint_rect_);
383 paint_rect_ = gfx::Rect(); 383 paint_rect_ = gfx::Rect();
384 384
385 DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; 385 DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations";
386 PaintRect(rect); 386 PaintRect(rect);
387 total_paint = total_paint.Union(rect); 387 total_paint.Union(rect);
388 } 388 }
389 } 389 }
390 //DCHECK(paint_rect_.IsEmpty()); 390 //DCHECK(paint_rect_.IsEmpty());
391 391
392 // Invalidate the paint region on the widget's underlying gdk window. Note 392 // Invalidate the paint region on the widget's underlying gdk window. Note
393 // that gdk_window_invalidate_* will generate extra expose events, which 393 // that gdk_window_invalidate_* will generate extra expose events, which
394 // we wish to avoid. So instead we use calls to begin_paint/end_paint. 394 // we wish to avoid. So instead we use calls to begin_paint/end_paint.
395 GdkRectangle grect = { 395 GdkRectangle grect = {
396 total_paint.x(), 396 total_paint.x(),
397 total_paint.y(), 397 total_paint.y(),
(...skipping 28 matching lines...) Expand all
426 426
427 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { 427 void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
428 set_painting(true); 428 set_painting(true);
429 webwidget_->paint(canvas_.get(), rect); 429 webwidget_->paint(canvas_.get(), rect);
430 set_painting(false); 430 set_painting(false);
431 } 431 }
432 432
433 void WebWidgetHost::WindowDestroyed() { 433 void WebWidgetHost::WindowDestroyed() {
434 delete this; 434 delete this;
435 } 435 }
OLDNEW
« no previous file with comments | « webkit/plugins/webview_plugin.cc ('k') | webkit/tools/test_shell/webwidget_host_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698