| 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 #ifndef WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H__ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H__ |
| 6 #define WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H__ | 6 #define WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H__ |
| 7 | 7 |
| 8 #if defined(OS_WIN) |
| 8 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif |
| 9 | 11 |
| 10 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
| 11 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 12 | 14 |
| 13 class WebWidget; | 15 class WebWidget; |
| 14 class WebWidgetDelegate; | 16 class WebWidgetDelegate; |
| 15 | 17 |
| 16 namespace gfx { | 18 namespace gfx { |
| 17 class PlatformCanvasWin; | 19 class PlatformCanvasWin; |
| 18 class Size; | 20 class Size; |
| 19 } | 21 } |
| 20 | 22 |
| 21 // This class is a simple HWND-based host for a WebWidget | 23 // This class is a simple HWND-based host for a WebWidget |
| 22 class WebWidgetHost { | 24 class WebWidgetHost { |
| 23 public: | 25 public: |
| 24 // The new instance is deleted once the associated HWND is destroyed. The | 26 // The new instance is deleted once the associated native window is |
| 25 // newly created window should be resized after it is created, using the | 27 // destroyed. The newly created window should be resized after it is |
| 26 // MoveWindow (or equivalent) function. | 28 // created, using the MoveWindow (or equivalent) function. |
| 29 #if defined(OS_WIN) |
| 27 static WebWidgetHost* Create(HWND parent_window, WebWidgetDelegate* delegate); | 30 static WebWidgetHost* Create(HWND parent_window, WebWidgetDelegate* delegate); |
| 28 | |
| 29 static WebWidgetHost* FromWindow(HWND hwnd); | 31 static WebWidgetHost* FromWindow(HWND hwnd); |
| 30 | 32 |
| 31 HWND window_handle() const { return hwnd_; } | 33 HWND window_handle() const { return hwnd_; } |
| 34 void SetCursor(HCURSOR cursor); |
| 35 #else // null port. |
| 36 static WebWidgetHost* Create(void* parent_window, WebWidgetDelegate* delegate)
; |
| 37 static WebWidgetHost* FromWindow(void* window); |
| 38 |
| 39 void* window_handle() const { return window_; } |
| 40 void SetCursor(void* cursor); |
| 41 #endif |
| 42 |
| 32 WebWidget* webwidget() const { return webwidget_; } | 43 WebWidget* webwidget() const { return webwidget_; } |
| 33 | 44 |
| 34 void DidInvalidateRect(const gfx::Rect& rect); | 45 void DidInvalidateRect(const gfx::Rect& rect); |
| 35 void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); | 46 void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); |
| 36 void SetCursor(HCURSOR cursor); | |
| 37 | 47 |
| 38 void DiscardBackingStore(); | 48 void DiscardBackingStore(); |
| 39 | 49 |
| 40 protected: | 50 protected: |
| 41 WebWidgetHost(); | 51 WebWidgetHost(); |
| 42 ~WebWidgetHost(); | 52 ~WebWidgetHost(); |
| 43 | 53 |
| 54 #if defined(OS_WIN) |
| 44 // Per-class wndproc. Returns true if the event should be swallowed. | 55 // Per-class wndproc. Returns true if the event should be swallowed. |
| 45 virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam); | 56 virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam); |
| 57 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); |
| 46 | 58 |
| 47 void Paint(); | 59 void Paint(); |
| 48 void Resize(LPARAM lparam); | 60 void Resize(LPARAM lparam); |
| 49 void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam); | 61 void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam); |
| 50 void WheelEvent(WPARAM wparam, LPARAM lparam); | 62 void WheelEvent(WPARAM wparam, LPARAM lparam); |
| 51 void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam); | 63 void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam); |
| 52 void CaptureLostEvent(); | 64 void CaptureLostEvent(); |
| 53 void SetFocus(bool enable); | 65 void SetFocus(bool enable); |
| 54 | 66 |
| 55 void TrackMouseLeave(bool enable); | 67 void TrackMouseLeave(bool enable); |
| 56 void ResetScrollRect(); | 68 void ResetScrollRect(); |
| 57 void PaintRect(const gfx::Rect& rect); | 69 void PaintRect(const gfx::Rect& rect); |
| 70 #endif |
| 58 | 71 |
| 59 void set_painting(bool value) { | 72 void set_painting(bool value) { |
| 60 #ifndef NDEBUG | 73 #ifndef NDEBUG |
| 61 painting_ = value; | 74 painting_ = value; |
| 62 #endif | 75 #endif |
| 63 } | 76 } |
| 64 | 77 |
| 65 static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); | 78 #if defined(OS_WIN) |
| 66 | |
| 67 HWND hwnd_; | 79 HWND hwnd_; |
| 80 #else // null port. |
| 81 void* window_; |
| 82 #endif |
| 68 WebWidget* webwidget_; | 83 WebWidget* webwidget_; |
| 69 scoped_ptr<gfx::PlatformCanvasWin> canvas_; | 84 scoped_ptr<gfx::PlatformCanvasWin> canvas_; |
| 70 | 85 |
| 71 // specifies the portion of the webwidget that needs painting | 86 // specifies the portion of the webwidget that needs painting |
| 72 gfx::Rect paint_rect_; | 87 gfx::Rect paint_rect_; |
| 73 | 88 |
| 74 // specifies the portion of the webwidget that needs scrolling | 89 // specifies the portion of the webwidget that needs scrolling |
| 75 gfx::Rect scroll_rect_; | 90 gfx::Rect scroll_rect_; |
| 76 int scroll_dx_; | 91 int scroll_dx_; |
| 77 int scroll_dy_; | 92 int scroll_dy_; |
| 78 | 93 |
| 79 bool track_mouse_leave_; | 94 bool track_mouse_leave_; |
| 80 | 95 |
| 81 #ifndef NDEBUG | 96 #ifndef NDEBUG |
| 82 bool painting_; | 97 bool painting_; |
| 83 #endif | 98 #endif |
| 84 }; | 99 }; |
| 85 | 100 |
| 86 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H__ | 101 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H__ |
| 87 | 102 |
| OLD | NEW |