Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: Source/core/platform/chromium/PopupContainer.h

Issue 16077002: Move popup menu code from core/platform to WebKit/chromium/src. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/chromium/PopupContainer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef PopupContainer_h
32 #define PopupContainer_h
33
34 #include "core/platform/PopupMenuStyle.h"
35 #include "core/platform/chromium/FramelessScrollView.h"
36 #include "core/platform/chromium/PopupListBox.h"
37 #include "core/platform/graphics/FloatQuad.h"
38
39 namespace WebCore {
40
41 class ChromeClient;
42 class FrameView;
43 class PopupMenuClient;
44
45 class PopupContainer : public FramelessScrollView {
46 public:
47 enum PopupType {
48 Select, // HTML select popup.
49 Suggestion, // Autocomplete/autofill popup.
50 };
51
52 static PassRefPtr<PopupContainer> create(PopupMenuClient*, PopupType, const PopupContainerSettings&);
53
54 // Whether a key event should be sent to this popup.
55 bool isInterestedInEventForKey(int keyCode);
56
57 // FramelessScrollView
58 virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
59 virtual void hide() OVERRIDE;
60 virtual bool handleMouseDownEvent(const PlatformMouseEvent&) OVERRIDE;
61 virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) OVERRIDE;
62 virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) OVERRIDE;
63 virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
64 virtual bool handleKeyEvent(const PlatformKeyboardEvent&) OVERRIDE;
65 virtual bool handleTouchEvent(const PlatformTouchEvent&) OVERRIDE;
66 virtual bool handleGestureEvent(const PlatformGestureEvent&) OVERRIDE;
67
68 // PopupContainer methods
69
70 // Show the popup
71 void showPopup(FrameView*);
72
73 // Show the popup in the specified rect for the specified frame.
74 // Note: this code was somehow arbitrarily factored-out of the Popup class
75 // so WebViewImpl can create a PopupContainer. This method is used for
76 // displaying auto complete popup menus on Mac Chromium, and for all
77 // popups on other platforms.
78 void showInRect(const FloatQuad& controlPosition, const IntSize& controlSize , FrameView*, int index);
79
80 // Hides the popup.
81 void hidePopup();
82
83 // The popup was hidden.
84 void notifyPopupHidden();
85
86 PopupListBox* listBox() const { return m_listBox.get(); }
87
88 bool isRTL() const;
89
90 // Gets the index of the item that the user is currently moused-over or
91 // has selected with the keyboard up/down arrows.
92 int selectedIndex() const;
93
94 // Refresh the popup values from the PopupMenuClient.
95 IntRect refresh(const IntRect& targetControlRect);
96
97 // The menu per-item data.
98 const WTF::Vector<PopupItem*>& popupData() const;
99
100 // The height of a row in the menu.
101 int menuItemHeight() const;
102
103 // The size of the font being used.
104 int menuItemFontSize() const;
105
106 // The style of the menu being used.
107 PopupMenuStyle menuStyle() const;
108
109 PopupType popupType() const { return m_popupType; }
110
111 // While hovering popup menu window, we want to show tool tip message.
112 String getSelectedItemToolTip();
113
114 // This is public for testing.
115 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);
116
117 private:
118 friend class WTF::RefCounted<PopupContainer>;
119
120 PopupContainer(PopupMenuClient*, PopupType, const PopupContainerSettings&);
121 ~PopupContainer();
122
123 // Paint the border.
124 void paintBorder(GraphicsContext*, const IntRect&);
125
126 // Layout and calculate popup widget size and location and returns it as Int Rect.
127 IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const IntSize& transformOffset, const IntPoint& popupInitialCoordinate);
128
129 void fitToListBox();
130
131 // Returns the ChromeClient of the page this popup is associated with.
132 ChromeClient* chromeClient();
133
134 RefPtr<PopupListBox> m_listBox;
135 RefPtr<FrameView> m_frameView;
136
137 PopupContainerSettings m_settings;
138 PopupType m_popupType;
139
140 // m_controlPosition contains the transformed position of the
141 // <select>/<input> associated with this popup. m_controlSize is the size
142 // of the <select>/<input> without transform.
143 // The popup menu will be positioned as follows:
144 // LTR : If the popup is positioned down it will align with the bottom left
145 // of m_controlPosition (p4)
146 // If the popup is positioned up it will align with the top left of
147 // m_controlPosition (p1)
148 // RTL : If the popup is positioned down it will align with the bottom right
149 // of m_controlPosition (p3)
150 // If the popup is positioned up it will align with the top right of
151 // m_controlPosition (p2)
152 FloatQuad m_controlPosition;
153 IntSize m_controlSize;
154
155 // Whether the popup is currently open.
156 bool m_popupOpen;
157 };
158
159 } // namespace WebCore
160
161 #endif
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/chromium/PopupContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698