| 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 10 matching lines...) Expand all Loading... |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef Widget_h | 28 #ifndef Widget_h |
| 29 #define Widget_h | 29 #define Widget_h |
| 30 | 30 |
| 31 #include "platform/PlatformExport.h" | 31 #include "platform/FrameViewBase.h" |
| 32 #include "platform/geometry/FloatPoint.h" | |
| 33 #include "platform/geometry/IntRect.h" | |
| 34 #include "platform/heap/Handle.h" | |
| 35 #include "public/platform/WebFocusType.h" | |
| 36 #include "wtf/Forward.h" | |
| 37 | 32 |
| 38 namespace blink { | 33 namespace blink { |
| 39 | 34 |
| 40 class CullRect; | 35 // TODO(joelhockey): Remove this file once all users are including |
| 41 class Event; | 36 // FrameViewBase.h instead. |
| 42 class GraphicsContext; | |
| 43 | 37 |
| 44 // The Widget class serves as a base class for FrameView, Scrollbar, and | 38 using Widget = FrameViewBase; |
| 45 // PluginView. | |
| 46 // | |
| 47 // Widgets are connected in a hierarchy, with the restriction that plugins and | |
| 48 // scrollbars are always leaves of the tree. Only FrameView can have children | |
| 49 // (and therefore the Widget class has no concept of children). | |
| 50 class PLATFORM_EXPORT Widget : public GarbageCollectedFinalized<Widget> { | |
| 51 public: | |
| 52 Widget(); | |
| 53 virtual ~Widget(); | |
| 54 | |
| 55 int x() const { return frameRect().x(); } | |
| 56 int y() const { return frameRect().y(); } | |
| 57 int width() const { return frameRect().width(); } | |
| 58 int height() const { return frameRect().height(); } | |
| 59 IntSize size() const { return frameRect().size(); } | |
| 60 IntPoint location() const { return frameRect().location(); } | |
| 61 | |
| 62 virtual void setFrameRect(const IntRect& frameRect) { | |
| 63 m_frameRect = frameRect; | |
| 64 } | |
| 65 const IntRect& frameRect() const { return m_frameRect; } | |
| 66 IntRect boundsRect() const { return IntRect(0, 0, width(), height()); } | |
| 67 | |
| 68 void resize(int w, int h) { setFrameRect(IntRect(x(), y(), w, h)); } | |
| 69 void resize(const IntSize& s) { setFrameRect(IntRect(location(), s)); } | |
| 70 | |
| 71 virtual void paint(GraphicsContext&, const CullRect&) const {} | |
| 72 void invalidate() { invalidateRect(boundsRect()); } | |
| 73 virtual void invalidateRect(const IntRect&) = 0; | |
| 74 | |
| 75 virtual void setFocused(bool, WebFocusType) {} | |
| 76 | |
| 77 virtual void show() {} | |
| 78 virtual void hide() {} | |
| 79 bool isSelfVisible() const { | |
| 80 return m_selfVisible; | |
| 81 } // Whether or not we have been explicitly marked as visible or not. | |
| 82 bool isParentVisible() const { | |
| 83 return m_parentVisible; | |
| 84 } // Whether or not our parent is visible. | |
| 85 bool isVisible() const { | |
| 86 return m_selfVisible && m_parentVisible; | |
| 87 } // Whether or not we are actually visible. | |
| 88 virtual void setParentVisible(bool visible) { m_parentVisible = visible; } | |
| 89 void setSelfVisible(bool v) { m_selfVisible = v; } | |
| 90 | |
| 91 virtual bool isFrameView() const { return false; } | |
| 92 virtual bool isRemoteFrameView() const { return false; } | |
| 93 virtual bool isPluginView() const { return false; } | |
| 94 virtual bool isPluginContainer() const { return false; } | |
| 95 virtual bool isScrollbar() const { return false; } | |
| 96 | |
| 97 virtual void setParent(Widget*); | |
| 98 Widget* parent() const { return m_parent; } | |
| 99 Widget* root() const; | |
| 100 | |
| 101 virtual void handleEvent(Event*) {} | |
| 102 | |
| 103 IntRect convertToRootFrame(const IntRect&) const; | |
| 104 IntRect convertFromRootFrame(const IntRect&) const; | |
| 105 | |
| 106 IntPoint convertToRootFrame(const IntPoint&) const; | |
| 107 IntPoint convertFromRootFrame(const IntPoint&) const; | |
| 108 FloatPoint convertFromRootFrame(const FloatPoint&) const; | |
| 109 | |
| 110 virtual void frameRectsChanged() {} | |
| 111 | |
| 112 virtual void widgetGeometryMayHaveChanged() {} | |
| 113 | |
| 114 virtual IntRect convertToContainingWidget(const IntRect&) const; | |
| 115 virtual IntRect convertFromContainingWidget(const IntRect&) const; | |
| 116 virtual IntPoint convertToContainingWidget(const IntPoint&) const; | |
| 117 virtual IntPoint convertFromContainingWidget(const IntPoint&) const; | |
| 118 | |
| 119 // Virtual methods to convert points to/from child widgets | |
| 120 virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const; | |
| 121 virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const; | |
| 122 | |
| 123 // Notifies this widget that it will no longer be receiving events. | |
| 124 virtual void eventListenersRemoved() {} | |
| 125 | |
| 126 DECLARE_VIRTUAL_TRACE(); | |
| 127 virtual void dispose() {} | |
| 128 | |
| 129 private: | |
| 130 Member<Widget> m_parent; | |
| 131 IntRect m_frameRect; | |
| 132 bool m_selfVisible; | |
| 133 bool m_parentVisible; | |
| 134 }; | |
| 135 | 39 |
| 136 } // namespace blink | 40 } // namespace blink |
| 137 | 41 |
| 138 #endif // Widget_h | 42 #endif // Widget_h |
| OLD | NEW |