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

Side by Side Diff: Source/WebCore/platform/ContextMenuItem.h

Issue 14185003: Use ContextMenu code path that was guarded by CROSS_PLATFORM_CONTEXT_MENU (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use ContextMenu code path that was guarded by CROSS_PLATFORM_CONTEXT_MENU Created 7 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
« no previous file with comments | « Source/WebCore/platform/ContextMenu.cpp ('k') | Source/WebCore/platform/ContextMenuItem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2010 Igalia S.L 3 * Copyright (C) 2010 Igalia S.L
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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef ContextMenuItem_h 27 #ifndef ContextMenuItem_h
28 #define ContextMenuItem_h 28 #define ContextMenuItem_h
29 29
30 #if ENABLE(CONTEXT_MENUS) 30 #if ENABLE(CONTEXT_MENUS)
31 31
32 #include "PlatformMenuDescription.h"
33 #include <wtf/OwnPtr.h> 32 #include <wtf/OwnPtr.h>
34 #include <wtf/text/WTFString.h> 33 #include <wtf/text/WTFString.h>
35 34
36 #endif // ENABLE(CONTEXT_MENUS) 35 #endif // ENABLE(CONTEXT_MENUS)
37 36
38 namespace WebCore { 37 namespace WebCore {
39 38
40 class ContextMenu; 39 class ContextMenu;
41 40
41 typedef void* PlatformContextMenuItem;
42
42 // This enum needs to be in sync with the WebMenuItemTag enum in WebUIDelega te.h and the 43 // This enum needs to be in sync with the WebMenuItemTag enum in WebUIDelega te.h and the
43 // extra values in WebUIDelegatePrivate.h 44 // extra values in WebUIDelegatePrivate.h
44 enum ContextMenuAction { 45 enum ContextMenuAction {
45 ContextMenuItemTagNoAction=0, // This item is not actually in WebUIDeleg ate.h 46 ContextMenuItemTagNoAction=0, // This item is not actually in WebUIDeleg ate.h
46 ContextMenuItemTagOpenLinkInNewWindow=1, 47 ContextMenuItemTagOpenLinkInNewWindow=1,
47 ContextMenuItemTagDownloadLinkToDisk, 48 ContextMenuItemTagDownloadLinkToDisk,
48 ContextMenuItemTagCopyLinkToClipboard, 49 ContextMenuItemTagCopyLinkToClipboard,
49 ContextMenuItemTagOpenImageInNewWindow, 50 ContextMenuItemTagOpenImageInNewWindow,
50 ContextMenuItemTagDownloadImageToDisk, 51 ContextMenuItemTagDownloadImageToDisk,
51 ContextMenuItemTagCopyImageToClipboard, 52 ContextMenuItemTagCopyImageToClipboard,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 }; 122 };
122 123
123 enum ContextMenuItemType { 124 enum ContextMenuItemType {
124 ActionType, 125 ActionType,
125 CheckableActionType, 126 CheckableActionType,
126 SeparatorType, 127 SeparatorType,
127 SubmenuType 128 SubmenuType
128 }; 129 };
129 130
130 #if ENABLE(CONTEXT_MENUS) 131 #if ENABLE(CONTEXT_MENUS)
131 struct PlatformMenuItemDescription {
132 PlatformMenuItemDescription()
133 : type(ActionType)
134 , action(ContextMenuItemTagNoAction)
135 , checked(false)
136 , enabled(true) { }
137 ContextMenuItemType type;
138 ContextMenuAction action;
139 String title;
140 Vector<ContextMenuItem> subMenuItems;
141 bool checked;
142 bool enabled;
143 };
144
145 class ContextMenuItem { 132 class ContextMenuItem {
146 WTF_MAKE_FAST_ALLOCATED; 133 WTF_MAKE_FAST_ALLOCATED;
147 public: 134 public:
148 ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, C ontextMenu* subMenu = 0); 135 ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, C ontextMenu* subMenu = 0);
149 ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, b ool enabled, bool checked); 136 ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, b ool enabled, bool checked);
150 137
151 ~ContextMenuItem(); 138 ~ContextMenuItem();
152 139
153 void setType(ContextMenuItemType); 140 void setType(ContextMenuItemType);
154 ContextMenuItemType type() const; 141 ContextMenuItemType type() const;
155 142
156 void setAction(ContextMenuAction); 143 void setAction(ContextMenuAction);
157 ContextMenuAction action() const; 144 ContextMenuAction action() const;
158 145
159 void setChecked(bool = true); 146 void setChecked(bool = true);
160 bool checked() const; 147 bool checked() const;
161 148
162 void setEnabled(bool = true); 149 void setEnabled(bool = true);
163 bool enabled() const; 150 bool enabled() const;
164 151
165 void setSubMenu(ContextMenu*); 152 void setSubMenu(ContextMenu*);
166 153
167 #if USE(CROSS_PLATFORM_CONTEXT_MENUS)
168 ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool che cked, const Vector<ContextMenuItem>& subMenuItems); 154 ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool che cked, const Vector<ContextMenuItem>& subMenuItems);
169 explicit ContextMenuItem(const PlatformContextMenuItem&); 155 explicit ContextMenuItem(const PlatformContextMenuItem&);
170 156
171 // On Windows, the title (dwTypeData of the MENUITEMINFO) is not set in this function. Callers can set the title themselves,
172 // and handle the lifetime of the title, if they need it.
173 PlatformContextMenuItem platformContextMenuItem() const; 157 PlatformContextMenuItem platformContextMenuItem() const;
174 158
175 void setTitle(const String& title) { m_title = title; } 159 void setTitle(const String& title) { m_title = title; }
176 const String& title() const { return m_title; } 160 const String& title() const { return m_title; }
177 161
178 const Vector<ContextMenuItem>& subMenuItems() const { return m_subMenuIt ems; } 162 const Vector<ContextMenuItem>& subMenuItems() const { return m_subMenuIt ems; }
179 #else 163 private:
180 public:
181 explicit ContextMenuItem(PlatformMenuItemDescription);
182 explicit ContextMenuItem(ContextMenu* subMenu = 0);
183 ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool che cked, Vector<ContextMenuItem>& submenuItems);
184
185 PlatformMenuItemDescription releasePlatformDescription();
186
187 String title() const;
188 void setTitle(const String&);
189
190 PlatformMenuDescription platformSubMenu() const;
191 void setSubMenu(Vector<ContextMenuItem>&);
192
193 #endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
194 private:
195 #if USE(CROSS_PLATFORM_CONTEXT_MENUS)
196 ContextMenuItemType m_type; 164 ContextMenuItemType m_type;
197 ContextMenuAction m_action; 165 ContextMenuAction m_action;
198 String m_title; 166 String m_title;
199 bool m_enabled; 167 bool m_enabled;
200 bool m_checked; 168 bool m_checked;
201 Vector<ContextMenuItem> m_subMenuItems; 169 Vector<ContextMenuItem> m_subMenuItems;
202 #else
203 PlatformMenuItemDescription m_platformDescription;
204 #endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
205 }; 170 };
206
207 #endif // ENABLE(CONTEXT_MENUS) 171 #endif // ENABLE(CONTEXT_MENUS)
208 } 172 }
209 173
210 #endif // ContextMenuItem_h 174 #endif // ContextMenuItem_h
OLDNEW
« no previous file with comments | « Source/WebCore/platform/ContextMenu.cpp ('k') | Source/WebCore/platform/ContextMenuItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698