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 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "platform/geometry/IntRect.h" | 33 #include "platform/geometry/IntRect.h" |
34 #include "wtf/Forward.h" | 34 #include "wtf/Forward.h" |
35 #include "wtf/RefCounted.h" | 35 #include "wtf/RefCounted.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class Event; | 39 class Event; |
40 class GraphicsContext; | 40 class GraphicsContext; |
41 class HostWindow; | 41 class HostWindow; |
42 | 42 |
43 // The Widget class serves as a base class for three kinds of objects: | 43 // The Widget class serves as a base class for FrameView, Scrollbar, and PluginV
iew. |
44 // (1) Scrollable areas (ScrollView) | |
45 // (2) Scrollbars (Scrollbar) | |
46 // (3) Plugins (PluginView) | |
47 // | 44 // |
48 // Widgets are connected in a hierarchy, with the restriction that plugins and | 45 // Widgets are connected in a hierarchy, with the restriction that plugins and |
49 // scrollbars are always leaves of the tree. Only ScrollViews can have children | 46 // scrollbars are always leaves of the tree. Only FrameView can have children |
50 // (and therefore the Widget class has no concept of children). | 47 // (and therefore the Widget class has no concept of children). |
51 class PLATFORM_EXPORT Widget : public RefCounted<Widget> { | 48 class PLATFORM_EXPORT Widget : public RefCounted<Widget> { |
52 public: | 49 public: |
53 Widget(); | 50 Widget(); |
54 virtual ~Widget(); | 51 virtual ~Widget(); |
55 | 52 |
56 int x() const { return frameRect().x(); } | 53 int x() const { return frameRect().x(); } |
57 int y() const { return frameRect().y(); } | 54 int y() const { return frameRect().y(); } |
58 int width() const { return frameRect().width(); } | 55 int width() const { return frameRect().width(); } |
59 int height() const { return frameRect().height(); } | 56 int height() const { return frameRect().height(); } |
(...skipping 22 matching lines...) Expand all Loading... |
82 bool isVisible() const { return m_selfVisible && m_parentVisible; } // Wheth
er or not we are actually visible. | 79 bool isVisible() const { return m_selfVisible && m_parentVisible; } // Wheth
er or not we are actually visible. |
83 virtual void setParentVisible(bool visible) { m_parentVisible = visible; } | 80 virtual void setParentVisible(bool visible) { m_parentVisible = visible; } |
84 void setSelfVisible(bool v) { m_selfVisible = v; } | 81 void setSelfVisible(bool v) { m_selfVisible = v; } |
85 | 82 |
86 virtual bool isFrameView() const { return false; } | 83 virtual bool isFrameView() const { return false; } |
87 virtual bool isRemoteFrameView() const { return false; } | 84 virtual bool isRemoteFrameView() const { return false; } |
88 virtual bool isPluginView() const { return false; } | 85 virtual bool isPluginView() const { return false; } |
89 virtual bool isPluginContainer() const { return false; } | 86 virtual bool isPluginContainer() const { return false; } |
90 virtual bool pluginShouldPersist() const { return false; } | 87 virtual bool pluginShouldPersist() const { return false; } |
91 virtual bool isScrollbar() const { return false; } | 88 virtual bool isScrollbar() const { return false; } |
92 virtual bool isScrollView() const { return false; } | |
93 | 89 |
94 virtual HostWindow* hostWindow() const { ASSERT_NOT_REACHED(); return 0; } | 90 virtual HostWindow* hostWindow() const { ASSERT_NOT_REACHED(); return 0; } |
95 virtual void setParent(Widget*); | 91 virtual void setParent(Widget*); |
96 Widget* parent() const { return m_parent; } | 92 Widget* parent() const { return m_parent; } |
97 Widget* root() const; | 93 Widget* root() const; |
98 | 94 |
99 virtual void handleEvent(Event*) { } | 95 virtual void handleEvent(Event*) { } |
100 | 96 |
101 // It is important for cross-platform code to realize that Mac has flipped c
oordinates. Therefore any code | 97 // It is important for cross-platform code to realize that Mac has flipped c
oordinates. Therefore any code |
102 // that tries to convert the location of a rect using the point-based conver
tFromContainingWindow will end | 98 // that tries to convert the location of a rect using the point-based conver
tFromContainingWindow will end |
103 // up with an inaccurate rect. Always make sure to use the rect-based conver
tFromContainingWindow method | 99 // up with an inaccurate rect. Always make sure to use the rect-based conver
tFromContainingWindow method |
104 // when converting window rects. | 100 // when converting window rects. |
105 IntRect convertToContainingWindow(const IntRect&) const; | 101 IntRect convertToContainingWindow(const IntRect&) const; |
106 IntRect convertFromContainingWindow(const IntRect&) const; | 102 IntRect convertFromContainingWindow(const IntRect&) const; |
107 | 103 |
108 IntPoint convertToContainingWindow(const IntPoint&) const; | 104 IntPoint convertToContainingWindow(const IntPoint&) const; |
109 IntPoint convertFromContainingWindow(const IntPoint&) const; | 105 IntPoint convertFromContainingWindow(const IntPoint&) const; |
110 FloatPoint convertFromContainingWindow(const FloatPoint&) const; | 106 FloatPoint convertFromContainingWindow(const FloatPoint&) const; |
111 | 107 |
112 virtual void frameRectsChanged() { } | 108 virtual void frameRectsChanged() { } |
113 | 109 |
114 // Notifies this widget that other widgets on the page have been repositione
d. | 110 // Notifies this widget that other widgets on the page have been repositione
d. |
115 virtual void widgetPositionsUpdated() { } | 111 virtual void widgetPositionsUpdated() { } |
116 | 112 |
117 // Virtual methods to convert points to/from the containing ScrollView | 113 // Virtual methods to convert points to/from the containing Widget |
118 virtual IntRect convertToContainingView(const IntRect&) const; | 114 virtual IntRect convertToContainingView(const IntRect&) const; |
119 virtual IntRect convertFromContainingView(const IntRect&) const; | 115 virtual IntRect convertFromContainingView(const IntRect&) const; |
120 virtual IntPoint convertToContainingView(const IntPoint&) const; | 116 virtual IntPoint convertToContainingView(const IntPoint&) const; |
121 virtual IntPoint convertFromContainingView(const IntPoint&) const; | 117 virtual IntPoint convertFromContainingView(const IntPoint&) const; |
122 | 118 |
123 // Virtual methods to convert points to/from child widgets | 119 // Virtual methods to convert points to/from child widgets |
124 virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const; | 120 virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const; |
125 virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const; | 121 virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const; |
126 | 122 |
127 // Notifies this widget that it will no longer be receiving events. | 123 // Notifies this widget that it will no longer be receiving events. |
128 virtual void eventListenersRemoved() { } | 124 virtual void eventListenersRemoved() { } |
129 | 125 |
130 #if ENABLE(OILPAN) | 126 #if ENABLE(OILPAN) |
131 virtual void detach() { } | 127 virtual void detach() { } |
132 #endif | 128 #endif |
133 | 129 |
134 private: | 130 private: |
135 Widget* m_parent; | 131 Widget* m_parent; |
136 IntRect m_frame; | 132 IntRect m_frame; |
137 bool m_selfVisible; | 133 bool m_selfVisible; |
138 bool m_parentVisible; | 134 bool m_parentVisible; |
139 }; | 135 }; |
140 | 136 |
141 } // namespace blink | 137 } // namespace blink |
142 | 138 |
143 #endif // Widget_h | 139 #endif // Widget_h |
OLD | NEW |