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

Side by Side Diff: third_party/WebKit/WebCore/platform/chromium/PopupMenuChromium.h

Issue 67017: Merge in the WebKit popup menu changes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 #include "PopupMenuClient.h" 35 #include "PopupMenuClient.h"
36 36
37 #include "FramelessScrollView.h" 37 #include "FramelessScrollView.h"
38 #include "IntRect.h" 38 #include "IntRect.h"
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 class FrameView; 42 class FrameView;
43 class PopupListBox; 43 class PopupListBox;
44 44
45 // A container for the data for each menu item (e.g. represented by <option>
46 // or <optgroup> in a <select> widget) and is used by PopupListBox.
47 struct PopupItem {
48 enum Type {
49 TypeOption,
50 TypeGroup,
51 TypeSeparator
52 };
53
54 PopupItem(const String& label, Type type)
55 : label(label), type(type), yOffset(0) { }
56 String label;
57 Type type;
58 int yOffset; // y offset of this item, relative to the top of the popup .
59 bool enabled;
60 };
61
45 // FIXME: Our FramelessScrollView classes should probably implement HostWind ow! 62 // FIXME: Our FramelessScrollView classes should probably implement HostWind ow!
46 63
47 // The PopupContainer class holds a PopupListBox (see cpp file). Its sole p urpose is to be 64 // The PopupContainer class holds a PopupListBox (see cpp file). Its sole p urpose is to be
48 // able to draw a border around its child. All its paint/event handling is 65 // able to draw a border around its child. All its paint/event handling is
49 // just forwarded to the child listBox (with the appropriate transforms). 66 // just forwarded to the child listBox (with the appropriate transforms).
50 // NOTE: this class is exposed so it can be instantiated direcly for the 67 // NOTE: this class is exposed so it can be instantiated direcly for the
51 // autofill popup. We cannot use the Popup class directly in that case as t he 68 // autofill popup. We cannot use the Popup class directly in that case as t he
52 // autofill popup should not be focused when shown and we want to forward th e 69 // autofill popup should not be focused when shown and we want to forward th e
53 // key events to it (through handleKeyEvent). 70 // key events to it (through handleKeyEvent).
54 71
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual bool handleMouseMoveEvent(const PlatformMouseEvent&); 104 virtual bool handleMouseMoveEvent(const PlatformMouseEvent&);
88 virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&); 105 virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&);
89 virtual bool handleWheelEvent(const PlatformWheelEvent&); 106 virtual bool handleWheelEvent(const PlatformWheelEvent&);
90 virtual bool handleKeyEvent(const PlatformKeyboardEvent&); 107 virtual bool handleKeyEvent(const PlatformKeyboardEvent&);
91 108
92 // PopupContainer methods 109 // PopupContainer methods
93 110
94 // Show the popup 111 // Show the popup
95 void showPopup(FrameView*); 112 void showPopup(FrameView*);
96 113
114 // Used on Mac Chromium for HTML select popup menus.
115 void showExternal(const IntRect&, FrameView*, int index);
116
97 // Show the popup in the specified rect for the specified frame. 117 // Show the popup in the specified rect for the specified frame.
98 // Note: this code was somehow arbitrarily factored-out of the Popup cla ss 118 // Note: this code was somehow arbitrarily factored-out of the Popup cla ss
99 // so WebViewImpl can create a PopupContainer. 119 // so WebViewImpl can create a PopupContainer. This method is used for
120 // displaying auto complete popup menus on Mac Chromium, and for all
121 // popups on other platforms.
100 void show(const IntRect&, FrameView*, int index); 122 void show(const IntRect&, FrameView*, int index);
101 123
102 // Hide the popup. Do not call this directly: use client->hidePopup(). 124 // Hide the popup. Do not call this directly: use client->hidePopup().
103 void hidePopup(); 125 void hidePopup();
104 126
105 // Compute size of widget and children. 127 // Compute size of widget and children.
106 void layout(); 128 void layout();
107 129
108 PopupListBox* listBox() const { return m_listBox.get(); } 130 PopupListBox* listBox() const { return m_listBox.get(); }
109 131
110 // Gets the index of the item that the user is currently moused-over or 132 // Gets the index of the item that the user is currently moused-over or
111 // has selected with the keyboard up/down arrows. 133 // has selected with the keyboard up/down arrows.
112 int selectedIndex() const; 134 int selectedIndex() const;
113 135
114 // Refresh the popup values from the PopupMenuClient. 136 // Refresh the popup values from the PopupMenuClient.
115 void refresh(); 137 void refresh();
116 138
139 // The menu per-item data.
140 const WTF::Vector<PopupItem*>& popupData() const;
141
142 // The height of a row in the menu.
143 int menuItemHeight() const;
144
117 private: 145 private:
118 friend class WTF::RefCounted<PopupContainer>; 146 friend class WTF::RefCounted<PopupContainer>;
119 147
120 PopupContainer(PopupMenuClient*, const PopupContainerSettings&); 148 PopupContainer(PopupMenuClient*, const PopupContainerSettings&);
121 ~PopupContainer(); 149 ~PopupContainer();
122 150
123 // Paint the border. 151 // Paint the border.
124 void paintBorder(GraphicsContext*, const IntRect&); 152 void paintBorder(GraphicsContext*, const IntRect&);
125 153
126 RefPtr<PopupListBox> m_listBox; 154 RefPtr<PopupListBox> m_listBox;
127 155
128 PopupContainerSettings m_settings; 156 PopupContainerSettings m_settings;
129 }; 157 };
130 158
131 } // namespace WebCore 159 } // namespace WebCore
132 160
133 #endif 161 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698