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 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "gfx/native_widget_types.h" | 11 #include "gfx/native_widget_types.h" |
12 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
13 #include "skia/ext/platform_canvas.h" | 13 #include "skia/ext/platform_canvas.h" |
| 14 #include "webkit/tools/test_shell/simple_webpaintsurface_impl.h" |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 class Size; | 17 class Size; |
17 } | 18 } |
18 | 19 |
19 namespace WebKit { | 20 namespace WebKit { |
20 class WebWidget; | 21 class WebWidget; |
21 class WebWidgetClient; | 22 class WebWidgetClient; |
22 struct WebScreenInfo; | 23 struct WebScreenInfo; |
23 } | 24 } |
24 | 25 |
25 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
26 #ifdef __OBJC__ | 27 #ifdef __OBJC__ |
27 @class NSEvent; | 28 @class NSEvent; |
28 #else | 29 #else |
29 class NSEvent; | 30 class NSEvent; |
30 #endif | 31 #endif |
31 #endif | 32 #endif |
32 | 33 |
33 // This class is a simple NativeView-based host for a WebWidget | 34 // This class is a simple NativeView-based host for a WebWidget |
34 class WebWidgetHost { | 35 class WebWidgetHost : public SimpleWebPaintSurfaceImpl::Delegate { |
35 public: | 36 public: |
36 // The new instance is deleted once the associated NativeView is destroyed. | 37 // The new instance is deleted once the associated NativeView is destroyed. |
37 // The newly created window should be resized after it is created, using the | 38 // The newly created window should be resized after it is created, using the |
38 // MoveWindow (or equivalent) function. | 39 // MoveWindow (or equivalent) function. |
39 static WebWidgetHost* Create(gfx::NativeView parent_view, | 40 static WebWidgetHost* Create(gfx::NativeView parent_view, |
40 WebKit::WebWidgetClient* client); | 41 WebKit::WebWidgetClient* client); |
41 | 42 |
42 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
43 static void HandleEvent(gfx::NativeView view, NSEvent* event); | 44 static void HandleEvent(gfx::NativeView view, NSEvent* event); |
44 #endif | 45 #endif |
45 | 46 |
46 gfx::NativeView view_handle() const { return view_; } | 47 gfx::NativeView view_handle() const { return view_; } |
47 WebKit::WebWidget* webwidget() const { return webwidget_; } | 48 WebKit::WebWidget* webwidget() const { return webwidget_; } |
48 | 49 |
| 50 WebKit::WebPaintSurface* GetPaintSurface(); |
| 51 #if !WEBKIT_USING_PAINTSURFACE |
49 void DidInvalidateRect(const gfx::Rect& rect); | 52 void DidInvalidateRect(const gfx::Rect& rect); |
50 void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); | 53 void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); |
| 54 #endif |
51 void ScheduleComposite(); | 55 void ScheduleComposite(); |
52 void ScheduleAnimation(); | 56 void ScheduleAnimation(); |
53 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
54 void SetCursor(HCURSOR cursor); | 58 void SetCursor(HCURSOR cursor); |
55 #endif | 59 #endif |
56 | 60 |
57 void DiscardBackingStore(); | 61 void DiscardBackingStore(); |
58 // Allow clients to update the paint rect. For example, if we get a gdk | 62 // Allow clients to update the paint rect. For example, if we get a gdk |
59 // expose or WM_PAINT event, we need to update the paint rect. | 63 // expose or WM_PAINT event, we need to update the paint rect. |
60 void UpdatePaintRect(const gfx::Rect& rect); | 64 void UpdatePaintRect(const gfx::Rect& rect); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 #endif | 123 #endif |
120 | 124 |
121 void ResetScrollRect(); | 125 void ResetScrollRect(); |
122 | 126 |
123 void set_painting(bool value) { | 127 void set_painting(bool value) { |
124 #ifndef NDEBUG | 128 #ifndef NDEBUG |
125 painting_ = value; | 129 painting_ = value; |
126 #endif | 130 #endif |
127 } | 131 } |
128 | 132 |
| 133 // SimpleWebPaintSurfaceImpl::Delegate methods: |
| 134 virtual void DidModifyPaintSurface(const gfx::Rect& bounds); |
| 135 |
129 gfx::NativeView view_; | 136 gfx::NativeView view_; |
130 WebKit::WebWidget* webwidget_; | 137 WebKit::WebWidget* webwidget_; |
131 scoped_ptr<skia::PlatformCanvas> canvas_; | 138 scoped_ptr<skia::PlatformCanvas> canvas_; |
132 | 139 |
| 140 scoped_ptr<SimpleWebPaintSurfaceImpl> paint_surface_; |
| 141 scoped_ptr<SimpleWebPaintSurfaceImpl> pending_paint_surface_; |
| 142 |
133 // specifies the portion of the webwidget that needs painting | 143 // specifies the portion of the webwidget that needs painting |
134 gfx::Rect paint_rect_; | 144 gfx::Rect paint_rect_; |
135 | 145 |
136 // specifies the portion of the webwidget that needs scrolling | 146 // specifies the portion of the webwidget that needs scrolling |
137 gfx::Rect scroll_rect_; | 147 gfx::Rect scroll_rect_; |
138 int scroll_dx_; | 148 int scroll_dx_; |
139 int scroll_dy_; | 149 int scroll_dy_; |
140 | 150 |
141 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
142 bool track_mouse_leave_; | 152 bool track_mouse_leave_; |
143 #endif | 153 #endif |
144 | 154 |
145 #if defined(TOOLKIT_USES_GTK) | 155 #if defined(TOOLKIT_USES_GTK) |
146 // Since GtkWindow resize is asynchronous, we have to stash the dimensions, | 156 // Since GtkWindow resize is asynchronous, we have to stash the dimensions, |
147 // so that the backing store doesn't have to wait for sizing to take place. | 157 // so that the backing store doesn't have to wait for sizing to take place. |
148 gfx::Size logical_size_; | 158 gfx::Size logical_size_; |
149 #endif | 159 #endif |
150 | 160 |
151 #ifndef NDEBUG | 161 #ifndef NDEBUG |
152 bool painting_; | 162 bool painting_; |
153 #endif | 163 #endif |
154 | 164 |
155 private: | 165 private: |
156 ScopedRunnableMethodFactory<WebWidgetHost> factory_; | 166 ScopedRunnableMethodFactory<WebWidgetHost> factory_; |
157 }; | 167 }; |
158 | 168 |
159 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_ | 169 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_ |
OLD | NEW |