| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); | 43 wcex.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 44 wcex.lpszClassName = kWindowClassName; | 44 wcex.lpszClassName = kWindowClassName; |
| 45 RegisterClassEx(&wcex); | 45 RegisterClassEx(&wcex); |
| 46 registered_class = true; | 46 registered_class = true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW, | 49 host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW, |
| 50 kWindowClassName, kWindowClassName, WS_POPUP, | 50 kWindowClassName, kWindowClassName, WS_POPUP, |
| 51 0, 0, 0, 0, | 51 0, 0, 0, 0, |
| 52 parent_view, NULL, GetModuleHandle(NULL), NULL); | 52 parent_view, NULL, GetModuleHandle(NULL), NULL); |
| 53 TRACK_HWND_CREATION(host->view_); | |
| 54 win_util::SetWindowUserData(host->view_, host); | 53 win_util::SetWindowUserData(host->view_, host); |
| 55 | 54 |
| 56 host->webwidget_ = WebWidget::Create(delegate); | 55 host->webwidget_ = WebWidget::Create(delegate); |
| 57 | 56 |
| 58 return host; | 57 return host; |
| 59 } | 58 } |
| 60 | 59 |
| 61 static WebWidgetHost* FromWindow(HWND view) { | 60 static WebWidgetHost* FromWindow(HWND view) { |
| 62 return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(view)); | 61 return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(view)); |
| 63 } | 62 } |
| 64 | 63 |
| 65 /*static*/ | 64 /*static*/ |
| 66 LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam, | 65 LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam, |
| 67 LPARAM lparam) { | 66 LPARAM lparam) { |
| 68 WebWidgetHost* host = FromWindow(hwnd); | 67 WebWidgetHost* host = FromWindow(hwnd); |
| 69 if (host && !host->WndProc(message, wparam, lparam)) { | 68 if (host && !host->WndProc(message, wparam, lparam)) { |
| 70 switch (message) { | 69 switch (message) { |
| 71 case WM_DESTROY: | 70 case WM_DESTROY: |
| 72 delete host; | 71 delete host; |
| 73 break; | 72 break; |
| 74 case WM_NCDESTROY: | |
| 75 TRACK_HWND_DESTRUCTION(hwnd); | |
| 76 break; | |
| 77 | 73 |
| 78 case WM_PAINT: { | 74 case WM_PAINT: { |
| 79 RECT rect; | 75 RECT rect; |
| 80 if (GetUpdateRect(hwnd, &rect, FALSE)) { | 76 if (GetUpdateRect(hwnd, &rect, FALSE)) { |
| 81 host->UpdatePaintRect(gfx::Rect(rect)); | 77 host->UpdatePaintRect(gfx::Rect(rect)); |
| 82 } | 78 } |
| 83 host->Paint(); | 79 host->Paint(); |
| 84 return 0; | 80 return 0; |
| 85 } | 81 } |
| 86 | 82 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 361 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
| 366 #ifndef NDEBUG | 362 #ifndef NDEBUG |
| 367 DCHECK(!painting_); | 363 DCHECK(!painting_); |
| 368 #endif | 364 #endif |
| 369 DCHECK(canvas_.get()); | 365 DCHECK(canvas_.get()); |
| 370 | 366 |
| 371 set_painting(true); | 367 set_painting(true); |
| 372 webwidget_->Paint(canvas_.get(), rect); | 368 webwidget_->Paint(canvas_.get(), rect); |
| 373 set_painting(false); | 369 set_painting(false); |
| 374 } | 370 } |
| OLD | NEW |