OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright (c) 2011, Google Inc. All rights reserved. | 3 * Copyright (c) 2011, Google Inc. 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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * 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 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #ifndef PopupContainer_h | 32 #ifndef PopupContainer_h |
33 #define PopupContainer_h | 33 #define PopupContainer_h |
34 | 34 |
35 #include "platform/PopupMenuStyle.h" | 35 #include "platform/PopupMenuStyle.h" |
36 #include "platform/geometry/FloatQuad.h" | 36 #include "platform/geometry/FloatQuad.h" |
37 #include "platform/scroll/FramelessScrollView.h" | |
38 #include "web/PopupListBox.h" | 37 #include "web/PopupListBox.h" |
39 | 38 |
40 namespace blink { | 39 namespace blink { |
41 | 40 |
42 class ChromeClient; | 41 class ChromeClient; |
43 class FrameView; | 42 class FrameView; |
| 43 class PopupContainerClient; |
44 class PopupMenuClient; | 44 class PopupMenuClient; |
45 struct WebPopupMenuInfo; | 45 struct WebPopupMenuInfo; |
46 | 46 |
47 class PopupContainer FINAL : public FramelessScrollView { | 47 // This class wraps a PopupListBox. It positions the popup, paints the border |
| 48 // around it, and forwards input events. |
| 49 // FIXME(skobes): This class can probably be combined with PopupListBox. |
| 50 class PopupContainer FINAL : public Widget { |
48 public: | 51 public: |
49 static PassRefPtr<PopupContainer> create(PopupMenuClient*, bool deviceSuppor
tsTouch); | 52 static PassRefPtr<PopupContainer> create(PopupMenuClient*, bool deviceSuppor
tsTouch); |
50 | 53 |
51 // Whether a key event should be sent to this popup. | 54 // Whether a key event should be sent to this popup. |
52 bool isInterestedInEventForKey(int keyCode); | 55 bool isInterestedInEventForKey(int keyCode); |
53 | 56 |
54 // FramelessScrollView | 57 // Widget |
55 virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE; | 58 virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE; |
56 virtual void hide() OVERRIDE; | 59 virtual void hide() OVERRIDE; |
57 virtual bool handleMouseDownEvent(const PlatformMouseEvent&) OVERRIDE; | 60 virtual HostWindow* hostWindow() const OVERRIDE; |
58 virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) OVERRIDE; | 61 virtual void invalidateRect(const IntRect&) OVERRIDE; |
59 virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) OVERRIDE; | |
60 virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE; | |
61 virtual bool handleKeyEvent(const PlatformKeyboardEvent&) OVERRIDE; | |
62 virtual bool handleTouchEvent(const PlatformTouchEvent&) OVERRIDE; | |
63 virtual bool handleGestureEvent(const PlatformGestureEvent&) OVERRIDE; | |
64 | 62 |
65 // PopupContainer methods | 63 // PopupContainer methods |
66 | 64 |
| 65 bool handleMouseDownEvent(const PlatformMouseEvent&); |
| 66 bool handleMouseMoveEvent(const PlatformMouseEvent&); |
| 67 bool handleMouseReleaseEvent(const PlatformMouseEvent&); |
| 68 bool handleWheelEvent(const PlatformWheelEvent&); |
| 69 bool handleKeyEvent(const PlatformKeyboardEvent&); |
| 70 bool handleTouchEvent(const PlatformTouchEvent&); |
| 71 bool handleGestureEvent(const PlatformGestureEvent&); |
| 72 |
| 73 PopupContainerClient* client() const { return m_client; } |
| 74 void setClient(PopupContainerClient* client) { m_client = client; } |
| 75 |
67 // Show the popup | 76 // Show the popup |
68 void showPopup(FrameView*); | 77 void showPopup(FrameView*); |
69 | 78 |
70 // Show the popup in the specified rect for the specified frame. | 79 // Show the popup in the specified rect for the specified frame. |
71 // Note: this code was somehow arbitrarily factored-out of the Popup class | 80 // Note: this code was somehow arbitrarily factored-out of the Popup class |
72 // so WebViewImpl can create a PopupContainer. This method is used for | 81 // so WebViewImpl can create a PopupContainer. This method is used for |
73 // displaying auto complete popup menus on Mac Chromium, and for all | 82 // displaying auto complete popup menus on Mac Chromium, and for all |
74 // popups on other platforms. | 83 // popups on other platforms. |
75 void showInRect(const FloatQuad& controlPosition, const IntSize& controlSize
, FrameView*, int index); | 84 void showInRect(const FloatQuad& controlPosition, const IntSize& controlSize
, FrameView*, int index); |
76 | 85 |
(...skipping 25 matching lines...) Expand all Loading... |
102 | 111 |
103 // The style of the menu being used. | 112 // The style of the menu being used. |
104 PopupMenuStyle menuStyle() const; | 113 PopupMenuStyle menuStyle() const; |
105 | 114 |
106 // While hovering popup menu window, we want to show tool tip message. | 115 // While hovering popup menu window, we want to show tool tip message. |
107 String getSelectedItemToolTip(); | 116 String getSelectedItemToolTip(); |
108 | 117 |
109 // This is public for testing. | 118 // This is public for testing. |
110 static IntRect layoutAndCalculateWidgetRectInternal(IntRect widgetRectInScre
en, int targetControlHeight, const FloatRect& windowRect, const FloatRect& scree
n, bool isRTL, const int rtlOffset, const int verticalOffset, const IntSize& tra
nsformOffset, PopupContent*, bool& needToResizeView); | 119 static IntRect layoutAndCalculateWidgetRectInternal(IntRect widgetRectInScre
en, int targetControlHeight, const FloatRect& windowRect, const FloatRect& scree
n, bool isRTL, const int rtlOffset, const int verticalOffset, const IntSize& tra
nsformOffset, PopupContent*, bool& needToResizeView); |
111 | 120 |
| 121 void disconnectClient() { m_listBox->disconnectClient(); } |
| 122 |
| 123 void updateFromElement() { m_listBox->updateFromElement(); } |
| 124 |
112 private: | 125 private: |
113 friend class WTF::RefCounted<PopupContainer>; | 126 friend class WTF::RefCounted<PopupContainer>; |
114 | 127 |
115 PopupContainer(PopupMenuClient*, bool deviceSupportsTouch); | 128 PopupContainer(PopupMenuClient*, bool deviceSupportsTouch); |
116 virtual ~PopupContainer(); | 129 virtual ~PopupContainer(); |
117 | 130 |
118 // Paint the border. | 131 // Paint the border. |
119 void paintBorder(GraphicsContext*, const IntRect&); | 132 void paintBorder(GraphicsContext*, const IntRect&); |
120 | 133 |
121 // Layout and calculate popup widget size and location and returns it as Int
Rect. | 134 // Layout and calculate popup widget size and location and returns it as Int
Rect. |
(...skipping 20 matching lines...) Expand all Loading... |
142 // m_controlPosition (p1) | 155 // m_controlPosition (p1) |
143 // RTL : If the popup is positioned down it will align with the bottom right | 156 // RTL : If the popup is positioned down it will align with the bottom right |
144 // of m_controlPosition (p3) | 157 // of m_controlPosition (p3) |
145 // If the popup is positioned up it will align with the top right of | 158 // If the popup is positioned up it will align with the top right of |
146 // m_controlPosition (p2) | 159 // m_controlPosition (p2) |
147 FloatQuad m_controlPosition; | 160 FloatQuad m_controlPosition; |
148 IntSize m_controlSize; | 161 IntSize m_controlSize; |
149 | 162 |
150 // Whether the popup is currently open. | 163 // Whether the popup is currently open. |
151 bool m_popupOpen; | 164 bool m_popupOpen; |
| 165 |
| 166 PopupContainerClient* m_client; |
152 }; | 167 }; |
153 | 168 |
154 } // namespace blink | 169 } // namespace blink |
155 | 170 |
156 #endif | 171 #endif |
OLD | NEW |