| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef Widget_h | 28 #ifndef Widget_h |
| 29 #define Widget_h | 29 #define Widget_h |
| 30 | 30 |
| 31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 32 #include "wtf/Forward.h" | 32 #include "wtf/Forward.h" |
| 33 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 class AXObjectCache; | |
| 38 class Cursor; | 37 class Cursor; |
| 39 class Event; | 38 class Event; |
| 40 class GraphicsContext; | 39 class GraphicsContext; |
| 41 class ScrollView; | 40 class HostWindow; |
| 41 class Widget; |
| 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 three kinds of objects: |
| 44 // (1) Scrollable areas (ScrollView) | 44 // (1) Scrollable areas (Widget) |
| 45 // (2) Scrollbars (Scrollbar) | 45 // (2) Scrollbars (Scrollbar) |
| 46 // (3) Plugins (PluginView) | 46 // (3) Plugins (PluginView) |
| 47 // | 47 // |
| 48 // Widgets are connected in a hierarchy, with the restriction that plugins and s
crollbars are always leaves of the | 48 // Widgets are connected in a hierarchy, with the restriction that plugins and |
| 49 // tree. Only ScrollViews can have children (and therefore the Widget class has
no concept of children). | 49 // scrollbars are always leaves of the tree. Only Widgets can have children |
| 50 // (and therefore the Widget class has no concept of children). |
| 50 class Widget : public RefCounted<Widget> { | 51 class Widget : public RefCounted<Widget> { |
| 51 public: | 52 public: |
| 52 Widget(); | 53 Widget(); |
| 53 virtual ~Widget(); | 54 virtual ~Widget(); |
| 54 | 55 |
| 55 int x() const { return frameRect().x(); } | 56 int x() const { return frameRect().x(); } |
| 56 int y() const { return frameRect().y(); } | 57 int y() const { return frameRect().y(); } |
| 57 int width() const { return frameRect().width(); } | 58 int width() const { return frameRect().width(); } |
| 58 int height() const { return frameRect().height(); } | 59 int height() const { return frameRect().height(); } |
| 59 IntSize size() const { return frameRect().size(); } | 60 IntSize size() const { return frameRect().size(); } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 83 bool isVisible() const { return m_selfVisible && m_parentVisible; } // Wheth
er or not we are actually visible. | 84 bool isVisible() const { return m_selfVisible && m_parentVisible; } // Wheth
er or not we are actually visible. |
| 84 virtual void setParentVisible(bool visible) { m_parentVisible = visible; } | 85 virtual void setParentVisible(bool visible) { m_parentVisible = visible; } |
| 85 void setSelfVisible(bool v) { m_selfVisible = v; } | 86 void setSelfVisible(bool v) { m_selfVisible = v; } |
| 86 | 87 |
| 87 virtual bool isFrameView() const { return false; } | 88 virtual bool isFrameView() const { return false; } |
| 88 virtual bool isPluginView() const { return false; } | 89 virtual bool isPluginView() const { return false; } |
| 89 virtual bool isPluginContainer() const { return false; } | 90 virtual bool isPluginContainer() const { return false; } |
| 90 virtual bool isScrollbar() const { return false; } | 91 virtual bool isScrollbar() const { return false; } |
| 91 virtual bool isScrollView() const { return false; } | 92 virtual bool isScrollView() const { return false; } |
| 92 | 93 |
| 93 void removeFromParent(); | 94 virtual void setParent(Widget*); |
| 94 virtual void setParent(ScrollView* view); | 95 Widget* parent() const { return m_parent; } |
| 95 ScrollView* parent() const { return m_parent; } | 96 Widget* root() const; |
| 96 ScrollView* root() const; | 97 virtual HostWindow* hostWindow() const; |
| 97 | 98 |
| 98 virtual void handleEvent(Event*) { } | 99 virtual void handleEvent(Event*) { } |
| 99 | 100 |
| 100 IntRect convertToRootView(const IntRect&) const; | 101 IntRect convertToRootView(const IntRect&) const; |
| 101 IntRect convertFromRootView(const IntRect&) const; | 102 IntRect convertFromRootView(const IntRect&) const; |
| 102 | 103 |
| 103 IntPoint convertToRootView(const IntPoint&) const; | 104 IntPoint convertToRootView(const IntPoint&) const; |
| 104 IntPoint convertFromRootView(const IntPoint&) const; | 105 IntPoint convertFromRootView(const IntPoint&) const; |
| 105 | 106 |
| 106 // It is important for cross-platform code to realize that Mac has flipped c
oordinates. Therefore any code | 107 // It is important for cross-platform code to realize that Mac has flipped c
oordinates. Therefore any code |
| 107 // that tries to convert the location of a rect using the point-based conver
tFromContainingWindow will end | 108 // that tries to convert the location of a rect using the point-based conver
tFromContainingWindow will end |
| 108 // up with an inaccurate rect. Always make sure to use the rect-based conve
rtFromContainingWindow method | 109 // up with an inaccurate rect. Always make sure to use the rect-based conve
rtFromContainingWindow method |
| 109 // when converting window rects. | 110 // when converting window rects. |
| 110 IntRect convertToContainingWindow(const IntRect&) const; | 111 IntRect convertToContainingWindow(const IntRect&) const; |
| 111 IntRect convertFromContainingWindow(const IntRect&) const; | 112 IntRect convertFromContainingWindow(const IntRect&) const; |
| 112 | 113 |
| 113 IntPoint convertToContainingWindow(const IntPoint&) const; | 114 IntPoint convertToContainingWindow(const IntPoint&) const; |
| 114 IntPoint convertFromContainingWindow(const IntPoint&) const; | 115 IntPoint convertFromContainingWindow(const IntPoint&) const; |
| 115 | 116 |
| 116 virtual void frameRectsChanged() { } | 117 virtual void frameRectsChanged() { } |
| 117 | 118 |
| 118 // Notifies this widget that other widgets on the page have been repositione
d. | 119 // Notifies this widget that other widgets on the page have been repositione
d. |
| 119 virtual void widgetPositionsUpdated() {} | 120 virtual void widgetPositionsUpdated() {} |
| 120 | 121 |
| 121 // Notifies this widget that its clip rect changed. | 122 // Notifies this widget that its clip rect changed. |
| 122 virtual void clipRectChanged() { } | 123 virtual void clipRectChanged() { } |
| 123 | 124 |
| 124 // Virtual methods to convert points to/from the containing ScrollView | 125 // Virtual methods to convert points to/from the containing Widget |
| 125 virtual IntRect convertToContainingView(const IntRect&) const; | 126 virtual IntRect convertToContainingView(const IntRect&) const; |
| 126 virtual IntRect convertFromContainingView(const IntRect&) const; | 127 virtual IntRect convertFromContainingView(const IntRect&) const; |
| 127 virtual IntPoint convertToContainingView(const IntPoint&) const; | 128 virtual IntPoint convertToContainingView(const IntPoint&) const; |
| 128 virtual IntPoint convertFromContainingView(const IntPoint&) const; | 129 virtual IntPoint convertFromContainingView(const IntPoint&) const; |
| 129 | 130 |
| 130 // A means to access the AX cache when this object can get a pointer to it. | 131 // Virtual methods to convert points to/from child widgets |
| 131 virtual AXObjectCache* axObjectCache() const { return 0; } | 132 virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const; |
| 133 virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const; |
| 132 | 134 |
| 133 // Notifies this widget that it will no longer be receiving events. | 135 // Notifies this widget that it will no longer be receiving events. |
| 134 virtual void eventListenersRemoved() { } | 136 virtual void eventListenersRemoved() { } |
| 135 | 137 |
| 136 private: | 138 private: |
| 137 ScrollView* m_parent; | 139 Widget* m_parent; |
| 138 IntRect m_frame; | 140 IntRect m_frame; |
| 139 bool m_selfVisible; | 141 bool m_selfVisible; |
| 140 bool m_parentVisible; | 142 bool m_parentVisible; |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 } // namespace WebCore | 145 } // namespace WebCore |
| 144 | 146 |
| 145 #endif // Widget_h | 147 #endif // Widget_h |
| OLD | NEW |