| 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 "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
| 11 #include "skia/ext/platform_canvas_win.h" | 11 #include "skia/ext/platform_canvas_win.h" |
| 12 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
| 13 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
| 13 #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" |
| 15 #include "third_party/WebKit/WebKit/chromium/public/win/WebScreenInfoFactory.h" |
| 14 #include "webkit/glue/webwidget.h" | 16 #include "webkit/glue/webwidget.h" |
| 15 #include "webkit/tools/test_shell/test_shell.h" | 17 #include "webkit/tools/test_shell/test_shell.h" |
| 16 | 18 |
| 17 using WebKit::WebInputEvent; | 19 using WebKit::WebInputEvent; |
| 18 using WebKit::WebInputEventFactory; | 20 using WebKit::WebInputEventFactory; |
| 19 using WebKit::WebKeyboardEvent; | 21 using WebKit::WebKeyboardEvent; |
| 20 using WebKit::WebMouseEvent; | 22 using WebKit::WebMouseEvent; |
| 21 using WebKit::WebMouseWheelEvent; | 23 using WebKit::WebMouseWheelEvent; |
| 24 using WebKit::WebScreenInfo; |
| 25 using WebKit::WebScreenInfoFactory; |
| 22 | 26 |
| 23 static const wchar_t kWindowClassName[] = L"WebWidgetHost"; | 27 static const wchar_t kWindowClassName[] = L"WebWidgetHost"; |
| 24 | 28 |
| 25 /*static*/ | 29 /*static*/ |
| 26 WebWidgetHost* WebWidgetHost::Create(HWND parent_view, | 30 WebWidgetHost* WebWidgetHost::Create(HWND parent_view, |
| 27 WebWidgetDelegate* delegate) { | 31 WebWidgetDelegate* delegate) { |
| 28 WebWidgetHost* host = new WebWidgetHost(); | 32 WebWidgetHost* host = new WebWidgetHost(); |
| 29 | 33 |
| 30 static bool registered_class = false; | 34 static bool registered_class = false; |
| 31 if (!registered_class) { | 35 if (!registered_class) { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 canvas_->getTopPlatformDevice().drawToHDC(ps.hdc, | 270 canvas_->getTopPlatformDevice().drawToHDC(ps.hdc, |
| 267 ps.rcPaint.left, | 271 ps.rcPaint.left, |
| 268 ps.rcPaint.top, | 272 ps.rcPaint.top, |
| 269 &ps.rcPaint); | 273 &ps.rcPaint); |
| 270 EndPaint(view_, &ps); | 274 EndPaint(view_, &ps); |
| 271 | 275 |
| 272 // Draw children | 276 // Draw children |
| 273 UpdateWindow(view_); | 277 UpdateWindow(view_); |
| 274 } | 278 } |
| 275 | 279 |
| 280 WebScreenInfo WebWidgetHost::GetScreenInfo() { |
| 281 return WebScreenInfoFactory::screenInfo(view_); |
| 282 } |
| 283 |
| 276 void WebWidgetHost::Resize(LPARAM lparam) { | 284 void WebWidgetHost::Resize(LPARAM lparam) { |
| 277 // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. | 285 // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. |
| 278 DiscardBackingStore(); | 286 DiscardBackingStore(); |
| 279 | 287 |
| 280 webwidget_->Resize(gfx::Size(LOWORD(lparam), HIWORD(lparam))); | 288 webwidget_->Resize(gfx::Size(LOWORD(lparam), HIWORD(lparam))); |
| 281 } | 289 } |
| 282 | 290 |
| 283 void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { | 291 void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { |
| 284 const WebMouseEvent& event = WebInputEventFactory::mouseEvent( | 292 const WebMouseEvent& event = WebInputEventFactory::mouseEvent( |
| 285 view_, message, wparam, lparam); | 293 view_, message, wparam, lparam); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 363 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
| 356 #ifndef NDEBUG | 364 #ifndef NDEBUG |
| 357 DCHECK(!painting_); | 365 DCHECK(!painting_); |
| 358 #endif | 366 #endif |
| 359 DCHECK(canvas_.get()); | 367 DCHECK(canvas_.get()); |
| 360 | 368 |
| 361 set_painting(true); | 369 set_painting(true); |
| 362 webwidget_->Paint(canvas_.get(), rect); | 370 webwidget_->Paint(canvas_.get(), rect); |
| 363 set_painting(false); | 371 set_painting(false); |
| 364 } | 372 } |
| OLD | NEW |