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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); | 29 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); |
30 wcex.lpszClassName = kWindowClassName; | 30 wcex.lpszClassName = kWindowClassName; |
31 RegisterClassEx(&wcex); | 31 RegisterClassEx(&wcex); |
32 registered_class = true; | 32 registered_class = true; |
33 } | 33 } |
34 | 34 |
35 host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW, | 35 host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW, |
36 kWindowClassName, kWindowClassName, WS_POPUP, | 36 kWindowClassName, kWindowClassName, WS_POPUP, |
37 0, 0, 0, 0, | 37 0, 0, 0, 0, |
38 parent_window, NULL, GetModuleHandle(NULL), NULL)
; | 38 parent_window, NULL, GetModuleHandle(NULL), NULL)
; |
39 TRACK_HWND_CREATION(host->view_); | 39 |
40 win_util::SetWindowUserData(host->view_, host); | 40 win_util::SetWindowUserData(host->view_, host); |
41 | 41 |
42 host->webwidget_ = WebWidget::Create(delegate); | 42 host->webwidget_ = WebWidget::Create(delegate); |
43 | 43 |
44 return host; | 44 return host; |
45 } | 45 } |
46 | 46 |
47 /*static*/ | 47 /*static*/ |
48 WebWidgetHost* WebWidgetHost::FromWindow(gfx::NativeWindow hwnd) { | 48 WebWidgetHost* WebWidgetHost::FromWindow(gfx::NativeWindow hwnd) { |
49 return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(hwnd)); | 49 return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(hwnd)); |
50 } | 50 } |
51 | 51 |
52 /*static*/ | 52 /*static*/ |
53 LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam, | 53 LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam, |
54 LPARAM lparam) { | 54 LPARAM lparam) { |
55 WebWidgetHost* host = FromWindow(hwnd); | 55 WebWidgetHost* host = FromWindow(hwnd); |
56 if (host && !host->WndProc(message, wparam, lparam)) { | 56 if (host && !host->WndProc(message, wparam, lparam)) { |
57 switch (message) { | 57 switch (message) { |
58 case WM_DESTROY: | 58 case WM_DESTROY: |
59 delete host; | 59 delete host; |
60 break; | 60 break; |
61 case WM_NCDESTROY: | |
62 TRACK_HWND_DESTRUCTION(hwnd); | |
63 break; | |
64 | 61 |
65 case WM_PAINT: { | 62 case WM_PAINT: { |
66 RECT rect; | 63 RECT rect; |
67 if (GetUpdateRect(hwnd, &rect, FALSE)) { | 64 if (GetUpdateRect(hwnd, &rect, FALSE)) { |
68 host->UpdatePaintRect(gfx::Rect(rect)); | 65 host->UpdatePaintRect(gfx::Rect(rect)); |
69 } | 66 } |
70 host->Paint(); | 67 host->Paint(); |
71 return 0; | 68 return 0; |
72 } | 69 } |
73 | 70 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 339 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
343 #ifndef NDEBUG | 340 #ifndef NDEBUG |
344 DCHECK(!painting_); | 341 DCHECK(!painting_); |
345 #endif | 342 #endif |
346 DCHECK(canvas_.get()); | 343 DCHECK(canvas_.get()); |
347 | 344 |
348 set_painting(true); | 345 set_painting(true); |
349 webwidget_->Paint(canvas_.get(), rect); | 346 webwidget_->Paint(canvas_.get(), rect); |
350 set_painting(false); | 347 set_painting(false); |
351 } | 348 } |
OLD | NEW |