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 | 39 TRACK_HWND_CREATION(host->view_); |
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; |
61 | 64 |
62 case WM_PAINT: { | 65 case WM_PAINT: { |
63 RECT rect; | 66 RECT rect; |
64 if (GetUpdateRect(hwnd, &rect, FALSE)) { | 67 if (GetUpdateRect(hwnd, &rect, FALSE)) { |
65 host->UpdatePaintRect(gfx::Rect(rect)); | 68 host->UpdatePaintRect(gfx::Rect(rect)); |
66 } | 69 } |
67 host->Paint(); | 70 host->Paint(); |
68 return 0; | 71 return 0; |
69 } | 72 } |
70 | 73 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 342 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
340 #ifndef NDEBUG | 343 #ifndef NDEBUG |
341 DCHECK(!painting_); | 344 DCHECK(!painting_); |
342 #endif | 345 #endif |
343 DCHECK(canvas_.get()); | 346 DCHECK(canvas_.get()); |
344 | 347 |
345 set_painting(true); | 348 set_painting(true); |
346 webwidget_->Paint(canvas_.get(), rect); | 349 webwidget_->Paint(canvas_.get(), rect); |
347 set_painting(false); | 350 set_painting(false); |
348 } | 351 } |
OLD | NEW |