| OLD | NEW |
| 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/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "skia/ext/bitmap_platform_device_linux.h" | 12 #include "skia/ext/bitmap_platform_device_linux.h" |
| 13 #include "skia/ext/platform_canvas_linux.h" | 13 #include "skia/ext/platform_canvas_linux.h" |
| 14 #include "skia/ext/platform_device_linux.h" | 14 #include "skia/ext/platform_device_linux.h" |
| 15 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/gtk/WebScreenInfoFactory.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
| 18 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
| 17 #include "webkit/glue/webwidget.h" | 19 #include "webkit/glue/webwidget.h" |
| 18 #include "webkit/tools/test_shell/test_shell.h" | 20 #include "webkit/tools/test_shell/test_shell.h" |
| 19 | 21 |
| 20 using WebKit::WebInputEventFactory; | 22 using WebKit::WebInputEventFactory; |
| 21 using WebKit::WebKeyboardEvent; | 23 using WebKit::WebKeyboardEvent; |
| 22 using WebKit::WebMouseEvent; | 24 using WebKit::WebMouseEvent; |
| 23 using WebKit::WebMouseWheelEvent; | 25 using WebKit::WebMouseWheelEvent; |
| 26 using WebKit::WebScreenInfo; |
| 27 using WebKit::WebScreenInfoFactory; |
| 24 | 28 |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| 27 // In response to an invalidation, we call into WebKit to do layout. On | 31 // In response to an invalidation, we call into WebKit to do layout. On |
| 28 // Windows, WM_PAINT is a virtual message so any extra invalidates that come up | 32 // Windows, WM_PAINT is a virtual message so any extra invalidates that come up |
| 29 // while it's doing layout are implicitly swallowed as soon as we actually do | 33 // while it's doing layout are implicitly swallowed as soon as we actually do |
| 30 // drawing via BeginPaint. | 34 // drawing via BeginPaint. |
| 31 // | 35 // |
| 32 // Though GTK does know how to collapse multiple paint requests, it won't erase | 36 // Though GTK does know how to collapse multiple paint requests, it won't erase |
| 33 // paint requests from the future when we start drawing. To avoid an infinite | 37 // paint requests from the future when we start drawing. To avoid an infinite |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 skia::BitmapPlatformDeviceLinux* const bitdev = | 358 skia::BitmapPlatformDeviceLinux* const bitdev = |
| 355 static_cast<skia::BitmapPlatformDeviceLinux* >(&platdev); | 359 static_cast<skia::BitmapPlatformDeviceLinux* >(&platdev); |
| 356 cairo_t* cairo_drawable = gdk_cairo_create(window); | 360 cairo_t* cairo_drawable = gdk_cairo_create(window); |
| 357 cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0); | 361 cairo_set_source_surface(cairo_drawable, bitdev->surface(), 0, 0); |
| 358 cairo_paint(cairo_drawable); | 362 cairo_paint(cairo_drawable); |
| 359 cairo_destroy(cairo_drawable); | 363 cairo_destroy(cairo_drawable); |
| 360 | 364 |
| 361 gdk_window_end_paint(window); | 365 gdk_window_end_paint(window); |
| 362 } | 366 } |
| 363 | 367 |
| 368 WebScreenInfo WebWidgetHost::GetScreenInfo() { |
| 369 return WebScreenInfoFactory::screenInfo(view_); |
| 370 } |
| 371 |
| 364 void WebWidgetHost::ResetScrollRect() { | 372 void WebWidgetHost::ResetScrollRect() { |
| 365 // This method is only needed for optimized scroll painting, which we don't | 373 // This method is only needed for optimized scroll painting, which we don't |
| 366 // care about in the test shell, yet. | 374 // care about in the test shell, yet. |
| 367 } | 375 } |
| 368 | 376 |
| 369 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 377 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
| 370 set_painting(true); | 378 set_painting(true); |
| 371 webwidget_->Paint(canvas_.get(), rect); | 379 webwidget_->Paint(canvas_.get(), rect); |
| 372 set_painting(false); | 380 set_painting(false); |
| 373 } | 381 } |
| 374 | 382 |
| 375 void WebWidgetHost::WindowDestroyed() { | 383 void WebWidgetHost::WindowDestroyed() { |
| 376 delete this; | 384 delete this; |
| 377 } | 385 } |
| OLD | NEW |