OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2008 Collabora Ltd. All rights reserved. | 3 * Copyright (C) 2008 Collabora Ltd. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 10 matching lines...) Expand all Loading... |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #ifndef Widget_h | 27 #ifndef Widget_h |
28 #define Widget_h | 28 #define Widget_h |
29 | 29 |
30 #include "IntRect.h" | 30 #include "IntRect.h" |
| 31 #include "PageClientChromium.h" |
31 #include <wtf/Forward.h> | 32 #include <wtf/Forward.h> |
32 #include <wtf/RefCounted.h> | 33 #include <wtf/RefCounted.h> |
33 | 34 |
34 #if PLATFORM(CHROMIUM) | |
35 #include "PageClientChromium.h" | |
36 #include "PlatformWidget.h" | |
37 #endif | |
38 | |
39 #if PLATFORM(MAC) | 35 #if PLATFORM(MAC) |
40 #include <wtf/RetainPtr.h> | 36 #include <wtf/RetainPtr.h> |
41 #endif | 37 #endif |
42 | 38 |
43 #if PLATFORM(QT) | 39 #if PLATFORM(QT) |
44 #include <QPointer> | 40 #include <QPointer> |
45 #include <qglobal.h> | 41 #include <qglobal.h> |
46 #endif | 42 #endif |
47 | 43 |
48 #if PLATFORM(MAC) | |
49 OBJC_CLASS NSView; | |
50 OBJC_CLASS NSWindow; | |
51 typedef NSView *PlatformWidget; | |
52 #endif | |
53 | |
54 #if PLATFORM(WIN) | |
55 typedef struct HWND__* HWND; | |
56 typedef HWND PlatformWidget; | |
57 #endif | |
58 | |
59 #if PLATFORM(GTK) | |
60 typedef struct _GtkWidget GtkWidget; | |
61 typedef struct _GtkContainer GtkContainer; | |
62 typedef GtkWidget* PlatformWidget; | |
63 #endif | |
64 | |
65 #if PLATFORM(QT) | |
66 QT_BEGIN_NAMESPACE | |
67 class QObject; | |
68 QT_END_NAMESPACE | |
69 typedef QObject* PlatformWidget; | |
70 #endif | |
71 | |
72 #if PLATFORM(BLACKBERRY) | |
73 typedef void* PlatformWidget; | |
74 #endif | |
75 | |
76 #if PLATFORM(WX) | |
77 class wxWindow; | |
78 typedef wxWindow* PlatformWidget; | |
79 #endif | |
80 | |
81 #if PLATFORM(EFL) | |
82 #if USE(EO) | |
83 typedef struct _Eo Evas_Object; | |
84 #else | |
85 typedef struct _Evas_Object Evas_Object; | |
86 #endif | |
87 typedef Evas_Object* PlatformWidget; | |
88 #endif | |
89 | |
90 #if PLATFORM(QT) | |
91 class QWebPageClient; | |
92 typedef QWebPageClient* PlatformPageClient; | |
93 #elif PLATFORM(BLACKBERRY) | |
94 #include "PageClientBlackBerry.h" | |
95 typedef PageClientBlackBerry* PlatformPageClient; | |
96 #elif PLATFORM(EFL) | |
97 class PageClientEfl; | |
98 typedef PageClientEfl* PlatformPageClient; | |
99 #elif PLATFORM(CHROMIUM) | |
100 typedef WebCore::PageClientChromium* PlatformPageClient; | 44 typedef WebCore::PageClientChromium* PlatformPageClient; |
101 #else | |
102 typedef PlatformWidget PlatformPageClient; | |
103 #endif | |
104 | 45 |
105 namespace WebCore { | 46 namespace WebCore { |
106 | 47 |
107 class AXObjectCache; | 48 class AXObjectCache; |
108 class Cursor; | 49 class Cursor; |
109 class Event; | 50 class Event; |
110 class Font; | 51 class Font; |
111 class GraphicsContext; | 52 class GraphicsContext; |
112 class PlatformMouseEvent; | 53 class PlatformMouseEvent; |
113 class ScrollView; | 54 class ScrollView; |
114 class WidgetPrivate; | 55 class WidgetPrivate; |
115 | 56 |
116 enum WidgetNotification { WillPaintFlattened, DidPaintFlattened }; | 57 enum WidgetNotification { WillPaintFlattened, DidPaintFlattened }; |
117 | 58 |
118 // The Widget class serves as a base class for three kinds of objects: | 59 // The Widget class serves as a base class for three kinds of objects: |
119 // (1) Scrollable areas (ScrollView) | 60 // (1) Scrollable areas (ScrollView) |
120 // (2) Scrollbars (Scrollbar) | 61 // (2) Scrollbars (Scrollbar) |
121 // (3) Plugins (PluginView) | 62 // (3) Plugins (PluginView) |
122 // | 63 // |
123 // A widget may or may not be backed by a platform-specific object (e.g., HWND o
n Windows, NSView on Mac, QWidget on Qt). | |
124 // | |
125 // Widgets are connected in a hierarchy, with the restriction that plugins and s
crollbars are always leaves of the | 64 // Widgets are connected in a hierarchy, with the restriction that plugins and s
crollbars are always leaves of the |
126 // tree. Only ScrollViews can have children (and therefore the Widget class has
no concept of children). | 65 // tree. Only ScrollViews can have children (and therefore the Widget class has
no concept of children). |
127 // | |
128 // The rules right now for which widgets get platform-specific objects are as fo
llows: | |
129 // ScrollView - Mac | |
130 // Scrollbar - Mac, Gtk | |
131 // Plugin - Mac, Windows (windowed only), Qt (windowed only, widget is an HWND o
n windows), Gtk (windowed only) | |
132 // | |
133 class Widget : public RefCounted<Widget> { | 66 class Widget : public RefCounted<Widget> { |
134 public: | 67 public: |
135 explicit Widget(PlatformWidget = 0); | 68 Widget(); |
136 virtual ~Widget(); | 69 virtual ~Widget(); |
137 | 70 |
138 PlatformWidget platformWidget() const; | |
139 void setPlatformWidget(PlatformWidget); | |
140 | |
141 int x() const { return frameRect().x(); } | 71 int x() const { return frameRect().x(); } |
142 int y() const { return frameRect().y(); } | 72 int y() const { return frameRect().y(); } |
143 int width() const { return frameRect().width(); } | 73 int width() const { return frameRect().width(); } |
144 int height() const { return frameRect().height(); } | 74 int height() const { return frameRect().height(); } |
145 IntSize size() const { return frameRect().size(); } | 75 IntSize size() const { return frameRect().size(); } |
146 IntPoint location() const { return frameRect().location(); } | 76 IntPoint location() const { return frameRect().location(); } |
147 | 77 |
148 virtual void setFrameRect(const IntRect&); | 78 virtual void setFrameRect(const IntRect&); |
149 IntRect frameRect() const; | 79 IntRect frameRect() const; |
150 IntRect boundsRect() const { return IntRect(0, 0, width(), height()); } | 80 IntRect boundsRect() const { return IntRect(0, 0, width(), height()); } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Virtual methods to convert points to/from the containing ScrollView | 169 // Virtual methods to convert points to/from the containing ScrollView |
240 virtual IntRect convertToContainingView(const IntRect&) const; | 170 virtual IntRect convertToContainingView(const IntRect&) const; |
241 virtual IntRect convertFromContainingView(const IntRect&) const; | 171 virtual IntRect convertFromContainingView(const IntRect&) const; |
242 virtual IntPoint convertToContainingView(const IntPoint&) const; | 172 virtual IntPoint convertToContainingView(const IntPoint&) const; |
243 virtual IntPoint convertFromContainingView(const IntPoint&) const; | 173 virtual IntPoint convertFromContainingView(const IntPoint&) const; |
244 | 174 |
245 // A means to access the AX cache when this object can get a pointer to it. | 175 // A means to access the AX cache when this object can get a pointer to it. |
246 virtual AXObjectCache* axObjectCache() const { return 0; } | 176 virtual AXObjectCache* axObjectCache() const { return 0; } |
247 | 177 |
248 private: | 178 private: |
249 void init(PlatformWidget); // Must be called by all Widget constructors to i
nitialize cross-platform data. | 179 void init(); // Must be called by all Widget constructors to initialize cros
s-platform data. |
250 | |
251 void releasePlatformWidget(); | |
252 void retainPlatformWidget(); | |
253 | 180 |
254 // These methods are used to convert from the root widget to the containing
window, | 181 // These methods are used to convert from the root widget to the containing
window, |
255 // which has behavior that may differ between platforms (e.g. Mac uses flipp
ed window coordinates). | 182 // which has behavior that may differ between platforms (e.g. Mac uses flipp
ed window coordinates). |
256 static IntRect convertFromRootToContainingWindow(const Widget* rootWidget, c
onst IntRect&); | 183 static IntRect convertFromRootToContainingWindow(const Widget* rootWidget, c
onst IntRect&); |
257 static IntRect convertFromContainingWindowToRoot(const Widget* rootWidget, c
onst IntRect&); | 184 static IntRect convertFromContainingWindowToRoot(const Widget* rootWidget, c
onst IntRect&); |
258 | 185 |
259 static IntPoint convertFromRootToContainingWindow(const Widget* rootWidget,
const IntPoint&); | 186 static IntPoint convertFromRootToContainingWindow(const Widget* rootWidget,
const IntPoint&); |
260 static IntPoint convertFromContainingWindowToRoot(const Widget* rootWidget,
const IntPoint&); | 187 static IntPoint convertFromContainingWindowToRoot(const Widget* rootWidget,
const IntPoint&); |
261 | 188 |
262 private: | 189 private: |
263 ScrollView* m_parent; | 190 ScrollView* m_parent; |
264 #if !PLATFORM(MAC) | |
265 PlatformWidget m_widget; | |
266 #else | |
267 RetainPtr<NSView> m_widget; | |
268 #endif | |
269 bool m_selfVisible; | 191 bool m_selfVisible; |
270 bool m_parentVisible; | 192 bool m_parentVisible; |
271 | 193 |
272 IntRect m_frame; // Not used when a native widget exists. | 194 IntRect m_frame; // Not used when a native widget exists. |
273 | 195 |
274 #if PLATFORM(MAC) | 196 #if PLATFORM(MAC) |
275 WidgetPrivate* m_data; | 197 WidgetPrivate* m_data; |
276 #endif | 198 #endif |
277 | 199 |
278 #if PLATFORM(EFL) | 200 #if PLATFORM(EFL) |
279 Evas_Object* m_evasObject; | 201 Evas_Object* m_evasObject; |
280 #endif | 202 #endif |
281 | 203 |
282 #if PLATFORM(QT) | 204 #if PLATFORM(QT) |
283 QPointer<QObject> m_bindingObject; | 205 QPointer<QObject> m_bindingObject; |
284 #endif | 206 #endif |
285 | 207 |
286 }; | 208 }; |
287 | 209 |
288 #if !PLATFORM(MAC) | |
289 | |
290 inline PlatformWidget Widget::platformWidget() const | |
291 { | |
292 return m_widget; | |
293 } | |
294 | |
295 inline void Widget::setPlatformWidget(PlatformWidget widget) | |
296 { | |
297 if (widget != m_widget) { | |
298 releasePlatformWidget(); | |
299 m_widget = widget; | |
300 retainPlatformWidget(); | |
301 } | |
302 } | |
303 | |
304 #endif | |
305 | |
306 #if !PLATFORM(GTK) | |
307 | |
308 inline void Widget::releasePlatformWidget() | |
309 { | |
310 } | |
311 | |
312 inline void Widget::retainPlatformWidget() | |
313 { | |
314 } | |
315 | |
316 #endif | |
317 | |
318 } // namespace WebCore | 210 } // namespace WebCore |
319 | 211 |
320 #endif // Widget_h | 212 #endif // Widget_h |
OLD | NEW |