Changeset 117970 in webkit
- Timestamp:
- May 22, 2012 7:32:27 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117969 r117970 1 2012-05-22 Alexander Pavlov <apavlov@chromium.org> 2 3 [Chromium] Implement the ContextMenuItem SubMenu type 4 https://bugs.webkit.org/show_bug.cgi?id=86625 5 6 Reviewed by Pavel Feldman. 7 8 This change is the WebKit part of a two-sided patch that adds subMenuItems to ContextMenuItem 9 and introduces code needed to handle it properly. 10 11 * platform/ContextMenuItem.h: 12 (PlatformMenuItemDescription): Add a Vector for subMenuItems. 13 * platform/PlatformMenuDescription.h: 14 (WebCore): Introduce a meaningful typedef for PlatformMenuDescription in Chromium. 15 * platform/chromium/ContextMenuChromium.cpp: 16 (WebCore::ContextMenu::itemWithAction): Search submenus when looking up a requested action id. 17 (WebCore::ContextMenu::platformDescription): Return a real PlatformMenuDescription rather than 0. 18 * platform/chromium/ContextMenuItemChromium.cpp: 19 (WebCore::ContextMenuItem::ContextMenuItem): Set submenu if one has been passed in. 20 (WebCore::ContextMenuItem::platformSubMenu): Return real subMenuItems instead of an empty PlatformMenuDescription. 21 (WebCore::ContextMenuItem::setSubMenu): Implemented. 22 (WebCore): 23 1 24 2012-05-22 Andrey Kosyakov <caseq@chromium.org> 2 25 -
trunk/Source/WebCore/platform/ContextMenuItem.h
r114367 r117970 224 224 ContextMenuAction action; 225 225 String title; 226 Vector<ContextMenuItem> subMenuItems; 226 227 bool checked; 227 228 bool enabled; -
trunk/Source/WebCore/platform/PlatformMenuDescription.h
r114902 r117970 35 35 #elif PLATFORM(WX) 36 36 class wxMenu; 37 #elif PLATFORM( EFL)37 #elif PLATFORM(CHROMIUM) || PLATFORM(EFL) 38 38 #include <wtf/Vector.h> 39 39 #endif … … 51 51 #elif PLATFORM(WX) 52 52 typedef wxMenu* PlatformMenuDescription; 53 #elif PLATFORM( EFL)53 #elif PLATFORM(CHROMIUM) || PLATFORM(EFL) 54 54 class ContextMenuItem; 55 55 typedef const Vector<ContextMenuItem>* PlatformMenuDescription; -
trunk/Source/WebCore/platform/chromium/ContextMenuChromium.cpp
r95901 r117970 66 66 ContextMenuItem* ContextMenu::itemWithAction(unsigned action) 67 67 { 68 for (size_t i = 0; i < m_items.size(); ++i) { 69 if (m_items[i].action() == static_cast<ContextMenuAction>(action)) 70 return &m_items[i]; 68 Vector<Vector<ContextMenuItem>*> menuItemStack; 69 menuItemStack.append(&m_items); 70 while (!menuItemStack.isEmpty()) { 71 Vector<ContextMenuItem>& items = *(menuItemStack.last()); 72 menuItemStack.removeLast(); 73 for (size_t i = 0; i < items.size(); ++i) { 74 if (items[i].action() == static_cast<ContextMenuAction>(action)) 75 return &items[i]; 76 if (items[i].type() == SubmenuType) 77 menuItemStack.append(const_cast<Vector<ContextMenuItem>*>(items[i].platformSubMenu())); 78 } 71 79 } 72 80 return 0; … … 84 92 PlatformMenuDescription ContextMenu::platformDescription() const 85 93 { 86 return 0;94 return &m_items; 87 95 } 88 96 -
trunk/Source/WebCore/platform/chromium/ContextMenuItemChromium.cpp
r95901 r117970 32 32 #include "ContextMenuItem.h" 33 33 34 #include "ContextMenu.h" 35 34 36 namespace WebCore { 35 37 … … 50 52 m_platformDescription.action = action; 51 53 m_platformDescription.title = title; 54 if (subMenu) 55 setSubMenu(subMenu); 52 56 } 53 57 … … 88 92 PlatformMenuDescription ContextMenuItem::platformSubMenu() const 89 93 { 90 return PlatformMenuDescription();94 return &m_platformDescription.subMenuItems; 91 95 } 92 96 … … 106 110 } 107 111 108 void ContextMenuItem::setSubMenu(ContextMenu* subMenu)112 void ContextMenuItem::setSubMenu(ContextMenu* menu) 109 113 { 114 m_platformDescription.subMenuItems = *menu->platformDescription(); 115 } 116 117 void ContextMenuItem::setSubMenu(Vector<ContextMenuItem>& items) 118 { 119 m_platformDescription.subMenuItems = items; 110 120 } 111 121 -
trunk/Source/WebKit/chromium/ChangeLog
r117960 r117970 1 2012-05-22 Alexander Pavlov <apavlov@chromium.org> 2 3 [Chromium] Implement the ContextMenuItem SubMenu type 4 https://bugs.webkit.org/show_bug.cgi?id=86625 5 6 Reviewed by Pavel Feldman. 7 8 * public/WebMenuItemInfo.h: 9 (WebMenuItemInfo): Add the SubMenu type and a vector of subMenuItems. 10 * src/ContextMenuClientImpl.cpp: 11 (WebKit::populateSubMenuItems): A recursive implementation that populates submenu items as well as other item types. 12 (WebKit): 13 (WebKit::ContextMenuClientImpl::populateCustomMenuItems): Consider submenus when populating WebMenuItemInfos. 14 1 15 2012-05-22 Ian Vollick <vollick@chromium.org> 2 16 -
trunk/Source/WebKit/chromium/public/WebMenuItemInfo.h
r101122 r117970 45 45 Group, 46 46 Separator, 47 SubMenu 47 48 }; 48 49 … … 62 63 unsigned action; 63 64 WebTextDirection textDirection; 65 WebVector<WebMenuItemInfo> subMenuItems; 64 66 bool hasTextDirectionOverride; 65 67 bool enabled; -
trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
r116607 r117970 348 348 } 349 349 350 void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)351 { 352 Vector<WebMenuItemInfo> customItems;353 for (size_t i = 0; i < defaultMenu->itemCount(); ++i) {354 ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription());355 if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() > 350 static void populateSubMenuItems(PlatformMenuDescription inputMenu, WebVector<WebMenuItemInfo>& subMenuItems) 351 { 352 Vector<WebMenuItemInfo> subItems; 353 for (size_t i = 0; i < inputMenu->size(); ++i) { 354 const ContextMenuItem* inputItem = &inputMenu->at(i); 355 if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() > ContextMenuItemLastCustomTag) 356 356 continue; 357 357 … … 372 372 break; 373 373 case SubmenuType: 374 outputItem.type = WebMenuItemInfo::Group; 374 outputItem.type = WebMenuItemInfo::SubMenu; 375 populateSubMenuItems(inputItem->platformSubMenu(), outputItem.subMenuItems); 375 376 break; 376 377 } 377 customItems.append(outputItem); 378 } 379 380 WebVector<WebMenuItemInfo> outputItems(customItems.size()); 381 for (size_t i = 0; i < customItems.size(); ++i) 382 outputItems[i] = customItems[i]; 383 data->customItems.swap(outputItems); 378 subItems.append(outputItem); 379 } 380 381 WebVector<WebMenuItemInfo> outputItems(subItems.size()); 382 for (size_t i = 0; i < subItems.size(); ++i) 383 outputItems[i] = subItems[i]; 384 subMenuItems.swap(outputItems); 385 } 386 387 void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) 388 { 389 populateSubMenuItems(defaultMenu->platformDescription(), data->customItems); 384 390 } 385 391
Note: See TracChangeset
for help on using the changeset viewer.