Changeset 51874 in webkit
- Timestamp:
- Dec 8, 2009 2:43:45 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r51872 r51874 1 2009-12-08 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 Chromium: support custom WebCore context menu items in Chromium port. 6 7 https://bugs.webkit.org/show_bug.cgi?id=32277 8 9 * platform/ContextMenu.h: 10 * platform/ContextMenuItem.h: 11 (WebCore::PlatformMenuItemDescription::PlatformMenuItemDescription): 12 * platform/chromium/ContextMenuChromium.cpp: 13 (WebCore::ContextMenu::ContextMenu): 14 (WebCore::ContextMenu::itemCount): 15 (WebCore::ContextMenu::insertItem): 16 (WebCore::ContextMenu::appendItem): 17 (WebCore::ContextMenu::itemWithAction): 18 (WebCore::ContextMenu::itemAtIndex): 19 (WebCore::ContextMenu::platformDescription): 20 * platform/chromium/ContextMenuItemChromium.cpp: 21 (WebCore::ContextMenuItem::ContextMenuItem): 22 (WebCore::ContextMenuItem::releasePlatformDescription): 23 (WebCore::ContextMenuItem::type): 24 (WebCore::ContextMenuItem::action): 25 (WebCore::ContextMenuItem::title): 26 (WebCore::ContextMenuItem::checked): 27 (WebCore::ContextMenuItem::enabled): 28 (WebCore::ContextMenuItem::setType): 29 (WebCore::ContextMenuItem::setAction): 30 (WebCore::ContextMenuItem::setTitle): 31 (WebCore::ContextMenuItem::setChecked): 32 (WebCore::ContextMenuItem::setEnabled): 33 1 34 2009-12-08 Adam Langley <agl@google.com> 2 35 -
trunk/WebCore/platform/ContextMenu.h
r45891 r51874 79 79 #elif PLATFORM(QT) 80 80 QList<ContextMenuItem> m_items; 81 #elif PLATFORM(CHROMIUM) 82 Vector<ContextMenuItem> m_items; 81 83 #else 82 84 PlatformMenuDescription m_platformDescription; -
trunk/WebCore/platform/ContextMenuItem.h
r51839 r51874 210 210 #elif PLATFORM(HAIKU) 211 211 typedef BMenuItem* PlatformMenuItemDescription; 212 #elif PLATFORM(CHROMIUM) 213 struct PlatformMenuItemDescription { 214 PlatformMenuItemDescription() 215 : type(ActionType) 216 , action(ContextMenuItemTagNoAction) 217 , checked(false) 218 , enabled(true) { } 219 ContextMenuItemType type; 220 ContextMenuAction action; 221 String title; 222 bool checked; 223 bool enabled; 224 }; 212 225 #else 213 226 typedef void* PlatformMenuItemDescription; … … 239 252 240 253 void setChecked(bool = true); 241 254 bool checked() const; 255 242 256 void setEnabled(bool = true); 243 257 bool enabled() const; -
trunk/WebCore/platform/chromium/ContextMenuChromium.cpp
r39903 r51874 39 39 ContextMenu::ContextMenu(const HitTestResult& result) 40 40 : m_hitTestResult(result) 41 , m_platformDescription(0)42 41 { 43 42 } … … 45 44 ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu) 46 45 : m_hitTestResult(result) 47 , m_platformDescription(0)48 46 { 49 47 } … … 55 53 unsigned ContextMenu::itemCount() const 56 54 { 57 return 0;55 return m_items.size(); 58 56 } 59 57 60 58 void ContextMenu::insertItem(unsigned position, ContextMenuItem& item) 61 59 { 60 m_items.insert(position, item); 62 61 } 63 62 64 63 void ContextMenu::appendItem(ContextMenuItem& item) 65 64 { 65 m_items.append(item); 66 66 } 67 67 68 68 ContextMenuItem* ContextMenu::itemWithAction(unsigned action) 69 69 { 70 for (size_t i = 0; i < m_items.size(); ++i) { 71 if (m_items[i].action() == static_cast<ContextMenuAction>(action)) 72 return &m_items[i]; 73 } 70 74 return 0; 71 75 } … … 73 77 ContextMenuItem* ContextMenu::itemAtIndex(unsigned index, const PlatformMenuDescription platformDescription) 74 78 { 75 return 0;79 return &m_items[index]; 76 80 } 77 81 … … 82 86 PlatformMenuDescription ContextMenu::platformDescription() const 83 87 { 84 return m_platformDescription;88 return 0; 85 89 } 86 90 -
trunk/WebCore/platform/chromium/ContextMenuItemChromium.cpp
r39861 r51874 47 47 ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu) 48 48 { 49 m_platformDescription.type = type; 50 m_platformDescription.action = action; 51 m_platformDescription.title = title; 49 52 } 50 53 … … 55 58 PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() 56 59 { 57 return PlatformMenuItemDescription();60 return m_platformDescription; 58 61 } 59 62 60 63 ContextMenuItemType ContextMenuItem::type() const 61 64 { 62 return ContextMenuItemType();65 return m_platformDescription.type; 63 66 } 64 67 65 68 ContextMenuAction ContextMenuItem::action() const 66 69 { 67 return ContextMenuAction();70 return m_platformDescription.action; 68 71 } 69 72 70 73 String ContextMenuItem::title() const 71 74 { 72 return String(); 75 return m_platformDescription.title; 76 } 77 78 bool ContextMenuItem::checked() const 79 { 80 return m_platformDescription.checked; 81 } 82 83 bool ContextMenuItem::enabled() const 84 { 85 return m_platformDescription.enabled; 73 86 } 74 87 … … 80 93 void ContextMenuItem::setType(ContextMenuItemType type) 81 94 { 95 m_platformDescription.type = type; 82 96 } 83 97 84 98 void ContextMenuItem::setAction(ContextMenuAction action) 85 99 { 100 m_platformDescription.action = action; 86 101 } 87 102 88 103 void ContextMenuItem::setTitle(const String& title) 89 104 { 105 m_platformDescription.title = title; 90 106 } 91 107 … … 96 112 void ContextMenuItem::setChecked(bool checked) 97 113 { 114 m_platformDescription.checked = checked; 98 115 } 99 116 100 117 void ContextMenuItem::setEnabled(bool enabled) 101 118 { 102 } 103 104 bool ContextMenuItem::enabled() const 105 { 106 return false; 119 m_platformDescription.enabled = enabled; 107 120 } 108 121 -
trunk/WebKit/chromium/ChangeLog
r51868 r51874 1 2009-12-08 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 Chromium: support custom WebCore context menu items in Chromium port. 6 7 https://bugs.webkit.org/show_bug.cgi?id=32277 8 9 * public/WebContextMenuData.h: 10 * public/WebPopupMenuInfo.h: 11 (WebKit::WebPopupMenuInfo::Item::): 12 * public/WebView.h: 13 * src/ContextMenuClientImpl.cpp: 14 (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): 15 * src/WebViewImpl.cpp: 16 (WebKit::WebViewImpl::executeCustomContextMenuAction): 17 * src/WebViewImpl.h: 18 1 19 2009-12-08 Albert J. Wong <ajwong@chromium.org> 2 20 -
trunk/WebKit/chromium/WebKit.gyp
r51788 r51874 132 132 'public/WebMediaPlayerAction.h', 133 133 'public/WebMediaPlayerClient.h', 134 'public/WebMenuItemInfo.h', 134 135 'public/WebMessagePortChannel.h', 135 136 'public/WebMessagePortChannelClient.h', -
trunk/WebKit/chromium/public/WebContextMenuData.h
r50678 r51874 32 32 #define WebContextMenuData_h 33 33 34 #include "WebMenuItemInfo.h" 34 35 #include "WebPoint.h" 35 36 #include "WebString.h" 36 37 #include "WebURL.h" 38 #include "WebVector.h" 37 39 38 40 namespace WebKit { … … 112 114 // Security information for the context. 113 115 WebCString securityInfo; 116 117 // Custom context menu items provided by the WebCore internals. 118 WebVector<WebMenuItemInfo> customItems; 114 119 }; 115 120 -
trunk/WebKit/chromium/public/WebMenuItemInfo.h
r51873 r51874 29 29 */ 30 30 31 #ifndef Web PopupMenuInfo_h32 #define Web PopupMenuInfo_h31 #ifndef WebMenuItemInfo_h 32 #define WebMenuItemInfo_h 33 33 34 34 #include "WebCommon.h" 35 #include "WebRect.h"36 35 #include "WebString.h" 37 36 #include "WebVector.h" … … 39 38 namespace WebKit { 40 39 41 // Describes the contents of a popup menu. 42 struct WebPopupMenuInfo { 43 struct Item { 44 enum Type { 45 Option, 46 Group, 47 Separator, 48 }; 49 WebString label; 50 Type type; 51 bool enabled; 40 struct WebMenuItemInfo { 41 enum Type { 42 Option, 43 CheckableOption, 44 Group, 45 Separator, 52 46 }; 53 54 int itemHeight; 55 int selectedIndex; 56 WebVector<Item> items; 47 WebString label; 48 Type type; 49 unsigned action; 50 bool enabled; 51 bool checked; 57 52 }; 58 53 -
trunk/WebKit/chromium/public/WebPopupMenuInfo.h
r50717 r51874 32 32 #define WebPopupMenuInfo_h 33 33 34 #include "WebCommon.h" 35 #include "WebRect.h" 36 #include "WebString.h" 34 #include "WebMenuItemInfo.h" 37 35 #include "WebVector.h" 38 36 … … 41 39 // Describes the contents of a popup menu. 42 40 struct WebPopupMenuInfo { 43 struct Item { 44 enum Type { 45 Option, 46 Group, 47 Separator, 48 }; 49 WebString label; 50 Type type; 51 bool enabled; 52 }; 53 41 // FIXME: migrate clients to WebMenuItemInfo and remove this temporary Item typedef. 42 typedef WebMenuItemInfo Item; 54 43 int itemHeight; 55 44 int selectedIndex; 56 WebVector< Item> items;45 WebVector<WebMenuItemInfo> items; 57 46 }; 58 47 -
trunk/WebKit/chromium/public/WebView.h
r51827 r51874 236 236 237 237 238 // Context menu -------------------------------------------------------- 239 240 virtual void performCustomContextMenuAction(unsigned action) = 0; 241 242 238 243 // Visited link state -------------------------------------------------- 239 244 … … 245 250 // their links. 246 251 WEBKIT_API static void resetVisitedLinkState(); 252 247 253 248 254 // Scrollbar colors ---------------------------------------------------- -
trunk/WebKit/chromium/src/ContextMenuClientImpl.cpp
r50741 r51874 51 51 #include "WebDataSourceImpl.h" 52 52 #include "WebFrameImpl.h" 53 #include "WebMenuItemInfo.h" 53 54 #include "WebPoint.h" 54 55 #include "WebString.h" 55 56 #include "WebURL.h" 56 57 #include "WebURLResponse.h" 58 #include "WebVector.h" 57 59 #include "WebViewClient.h" 58 60 #include "WebViewImpl.h" … … 229 231 data.editFlags |= WebContextMenuData::CanSelectAll; 230 232 233 // Filter out custom menu elements and add them into the data. 234 populateCustomMenuItems(defaultMenu, &data); 235 231 236 WebFrame* selected_web_frame = WebFrameImpl::fromFrame(selectedFrame); 232 237 if (m_webView->client()) … … 236 241 } 237 242 243 void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) 244 { 245 Vector<WebMenuItemInfo> customItems; 246 for (size_t i = 0; i < defaultMenu->itemCount(); ++i) { 247 ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription()); 248 if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() >= ContextMenuItemBaseApplicationTag) 249 continue; 250 251 WebMenuItemInfo outputItem; 252 outputItem.label = inputItem->title(); 253 outputItem.enabled = inputItem->enabled(); 254 outputItem.checked = inputItem->checked(); 255 outputItem.action = static_cast<unsigned>(inputItem->action() - ContextMenuItemBaseCustomTag); 256 switch (inputItem->type()) { 257 case ActionType: 258 outputItem.type = WebMenuItemInfo::Option; 259 break; 260 case CheckableActionType: 261 outputItem.type = WebMenuItemInfo::CheckableOption; 262 break; 263 case SeparatorType: 264 outputItem.type = WebMenuItemInfo::Separator; 265 break; 266 case SubmenuType: 267 outputItem.type = WebMenuItemInfo::Group; 268 break; 269 } 270 customItems.append(outputItem); 271 } 272 273 WebVector<WebMenuItemInfo> outputItems(customItems.size()); 274 for (size_t i = 0; i < customItems.size(); ++i) 275 outputItems[i] = customItems[i]; 276 data->customItems.swap(outputItems); 277 } 278 238 279 } // namespace WebKit -
trunk/WebKit/chromium/src/ContextMenuClientImpl.h
r50741 r51874 36 36 namespace WebKit { 37 37 38 class WebContextMenuData; 38 39 class WebViewImpl; 39 40 … … 54 55 virtual void stopSpeaking() {} 55 56 private: 57 void populateCustomMenuItems(WebCore::ContextMenu*, WebContextMenuData*); 56 58 WebViewImpl* m_webView; 57 59 }; -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r51832 r51874 34 34 #include "AutocompletePopupMenuClient.h" 35 35 #include "AXObjectCache.h" 36 #include "ContextMenu.h" 37 #include "ContextMenuController.h" 38 #include "ContextMenuItem.h" 36 39 #include "CSSStyleSelector.h" 37 40 #include "CSSValueKeywords.h" … … 1587 1590 } 1588 1591 1592 void WebViewImpl::performCustomContextMenuAction(unsigned action) 1593 { 1594 if (!m_page) 1595 return; 1596 ContextMenu* menu = m_page->contextMenuController()->contextMenu(); 1597 if (!menu) 1598 return; 1599 ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + action)); 1600 if (item) 1601 m_page->contextMenuController()->contextMenuItemSelected(item); 1602 m_page->contextMenuController()->clearContextMenu(); 1603 } 1604 1589 1605 // WebView -------------------------------------------------------------------- 1590 1606 -
trunk/WebKit/chromium/src/WebViewImpl.h
r51827 r51874 158 158 unsigned activeColor, 159 159 unsigned trackColor); 160 virtual void performCustomContextMenuAction(unsigned action); 160 161 161 162 // WebViewImpl
Note: See TracChangeset
for help on using the changeset viewer.