OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |