- Revision
- 117970
- Author
- [email protected]
- Date
- 2012-05-22 07:32:27 -0700 (Tue, 22 May 2012)
Log Message
[Chromium] Implement the ContextMenuItem SubMenu type
https://bugs.webkit.org/show_bug.cgi?id=86625
Reviewed by Pavel Feldman.
Source/WebCore:
This change is the WebKit part of a two-sided patch that adds subMenuItems to ContextMenuItem
and introduces code needed to handle it properly.
* platform/ContextMenuItem.h:
(PlatformMenuItemDescription): Add a Vector for subMenuItems.
* platform/PlatformMenuDescription.h:
(WebCore): Introduce a meaningful typedef for PlatformMenuDescription in Chromium.
* platform/chromium/ContextMenuChromium.cpp:
(WebCore::ContextMenu::itemWithAction): Search submenus when looking up a requested action id.
(WebCore::ContextMenu::platformDescription): Return a real PlatformMenuDescription rather than 0.
* platform/chromium/ContextMenuItemChromium.cpp:
(WebCore::ContextMenuItem::ContextMenuItem): Set submenu if one has been passed in.
(WebCore::ContextMenuItem::platformSubMenu): Return real subMenuItems instead of an empty PlatformMenuDescription.
(WebCore::ContextMenuItem::setSubMenu): Implemented.
(WebCore):
Source/WebKit/chromium:
* public/WebMenuItemInfo.h:
(WebMenuItemInfo): Add the SubMenu type and a vector of subMenuItems.
* src/ContextMenuClientImpl.cpp:
(WebKit::populateSubMenuItems): A recursive implementation that populates submenu items as well as other item types.
(WebKit):
(WebKit::ContextMenuClientImpl::populateCustomMenuItems): Consider submenus when populating WebMenuItemInfos.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (117969 => 117970)
--- trunk/Source/WebCore/ChangeLog 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebCore/ChangeLog 2012-05-22 14:32:27 UTC (rev 117970)
@@ -1,3 +1,26 @@
+2012-05-22 Alexander Pavlov <[email protected]>
+
+ [Chromium] Implement the ContextMenuItem SubMenu type
+ https://bugs.webkit.org/show_bug.cgi?id=86625
+
+ Reviewed by Pavel Feldman.
+
+ This change is the WebKit part of a two-sided patch that adds subMenuItems to ContextMenuItem
+ and introduces code needed to handle it properly.
+
+ * platform/ContextMenuItem.h:
+ (PlatformMenuItemDescription): Add a Vector for subMenuItems.
+ * platform/PlatformMenuDescription.h:
+ (WebCore): Introduce a meaningful typedef for PlatformMenuDescription in Chromium.
+ * platform/chromium/ContextMenuChromium.cpp:
+ (WebCore::ContextMenu::itemWithAction): Search submenus when looking up a requested action id.
+ (WebCore::ContextMenu::platformDescription): Return a real PlatformMenuDescription rather than 0.
+ * platform/chromium/ContextMenuItemChromium.cpp:
+ (WebCore::ContextMenuItem::ContextMenuItem): Set submenu if one has been passed in.
+ (WebCore::ContextMenuItem::platformSubMenu): Return real subMenuItems instead of an empty PlatformMenuDescription.
+ (WebCore::ContextMenuItem::setSubMenu): Implemented.
+ (WebCore):
+
2012-05-22 Andrey Kosyakov <[email protected]>
Web Inspector: use canvas to render timeline category strips in overview pane
Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (117969 => 117970)
--- trunk/Source/WebCore/platform/ContextMenuItem.h 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h 2012-05-22 14:32:27 UTC (rev 117970)
@@ -223,6 +223,7 @@
ContextMenuItemType type;
ContextMenuAction action;
String title;
+ Vector<ContextMenuItem> subMenuItems;
bool checked;
bool enabled;
};
Modified: trunk/Source/WebCore/platform/PlatformMenuDescription.h (117969 => 117970)
--- trunk/Source/WebCore/platform/PlatformMenuDescription.h 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebCore/platform/PlatformMenuDescription.h 2012-05-22 14:32:27 UTC (rev 117970)
@@ -34,7 +34,7 @@
typedef struct _GtkMenu GtkMenu;
#elif PLATFORM(WX)
class wxMenu;
-#elif PLATFORM(EFL)
+#elif PLATFORM(CHROMIUM) || PLATFORM(EFL)
#include <wtf/Vector.h>
#endif
@@ -50,7 +50,7 @@
typedef GtkMenu* PlatformMenuDescription;
#elif PLATFORM(WX)
typedef wxMenu* PlatformMenuDescription;
-#elif PLATFORM(EFL)
+#elif PLATFORM(CHROMIUM) || PLATFORM(EFL)
class ContextMenuItem;
typedef const Vector<ContextMenuItem>* PlatformMenuDescription;
#else
Modified: trunk/Source/WebCore/platform/chromium/ContextMenuChromium.cpp (117969 => 117970)
--- trunk/Source/WebCore/platform/chromium/ContextMenuChromium.cpp 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebCore/platform/chromium/ContextMenuChromium.cpp 2012-05-22 14:32:27 UTC (rev 117970)
@@ -65,9 +65,17 @@
ContextMenuItem* ContextMenu::itemWithAction(unsigned action)
{
- for (size_t i = 0; i < m_items.size(); ++i) {
- if (m_items[i].action() == static_cast<ContextMenuAction>(action))
- return &m_items[i];
+ Vector<Vector<ContextMenuItem>*> menuItemStack;
+ menuItemStack.append(&m_items);
+ while (!menuItemStack.isEmpty()) {
+ Vector<ContextMenuItem>& items = *(menuItemStack.last());
+ menuItemStack.removeLast();
+ for (size_t i = 0; i < items.size(); ++i) {
+ if (items[i].action() == static_cast<ContextMenuAction>(action))
+ return &items[i];
+ if (items[i].type() == SubmenuType)
+ menuItemStack.append(const_cast<Vector<ContextMenuItem>*>(items[i].platformSubMenu()));
+ }
}
return 0;
}
@@ -83,7 +91,7 @@
PlatformMenuDescription ContextMenu::platformDescription() const
{
- return 0;
+ return &m_items;
}
PlatformMenuDescription ContextMenu::releasePlatformDescription()
Modified: trunk/Source/WebCore/platform/chromium/ContextMenuItemChromium.cpp (117969 => 117970)
--- trunk/Source/WebCore/platform/chromium/ContextMenuItemChromium.cpp 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebCore/platform/chromium/ContextMenuItemChromium.cpp 2012-05-22 14:32:27 UTC (rev 117970)
@@ -31,6 +31,8 @@
#include "config.h"
#include "ContextMenuItem.h"
+#include "ContextMenu.h"
+
namespace WebCore {
// This is a stub implementation of WebKit's ContextMenu class that does
@@ -49,6 +51,8 @@
m_platformDescription.type = type;
m_platformDescription.action = ""
m_platformDescription.title = title;
+ if (subMenu)
+ setSubMenu(subMenu);
}
ContextMenuItem::~ContextMenuItem()
@@ -87,7 +91,7 @@
PlatformMenuDescription ContextMenuItem::platformSubMenu() const
{
- return PlatformMenuDescription();
+ return &m_platformDescription.subMenuItems;
}
void ContextMenuItem::setType(ContextMenuItemType type)
@@ -105,10 +109,16 @@
m_platformDescription.title = title;
}
-void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
+void ContextMenuItem::setSubMenu(ContextMenu* menu)
{
+ m_platformDescription.subMenuItems = *menu->platformDescription();
}
+void ContextMenuItem::setSubMenu(Vector<ContextMenuItem>& items)
+{
+ m_platformDescription.subMenuItems = items;
+}
+
void ContextMenuItem::setChecked(bool checked)
{
m_platformDescription.checked = checked;
Modified: trunk/Source/WebKit/chromium/ChangeLog (117969 => 117970)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-22 14:32:27 UTC (rev 117970)
@@ -1,3 +1,17 @@
+2012-05-22 Alexander Pavlov <[email protected]>
+
+ [Chromium] Implement the ContextMenuItem SubMenu type
+ https://bugs.webkit.org/show_bug.cgi?id=86625
+
+ Reviewed by Pavel Feldman.
+
+ * public/WebMenuItemInfo.h:
+ (WebMenuItemInfo): Add the SubMenu type and a vector of subMenuItems.
+ * src/ContextMenuClientImpl.cpp:
+ (WebKit::populateSubMenuItems): A recursive implementation that populates submenu items as well as other item types.
+ (WebKit):
+ (WebKit::ContextMenuClientImpl::populateCustomMenuItems): Consider submenus when populating WebMenuItemInfos.
+
2012-05-22 Ian Vollick <[email protected]>
[chromium] Speed up CCLayerTreeHostTestTickAnimationWhileBackgrounded
Modified: trunk/Source/WebKit/chromium/public/WebMenuItemInfo.h (117969 => 117970)
--- trunk/Source/WebKit/chromium/public/WebMenuItemInfo.h 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebKit/chromium/public/WebMenuItemInfo.h 2012-05-22 14:32:27 UTC (rev 117970)
@@ -44,6 +44,7 @@
CheckableOption,
Group,
Separator,
+ SubMenu
};
WebMenuItemInfo()
@@ -61,6 +62,7 @@
Type type;
unsigned action;
WebTextDirection textDirection;
+ WebVector<WebMenuItemInfo> subMenuItems;
bool hasTextDirectionOverride;
bool enabled;
bool checked;
Modified: trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (117969 => 117970)
--- trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-05-22 14:06:47 UTC (rev 117969)
+++ trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-05-22 14:32:27 UTC (rev 117970)
@@ -347,12 +347,12 @@
return 0;
}
-void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
+static void populateSubMenuItems(PlatformMenuDescription inputMenu, WebVector<WebMenuItemInfo>& subMenuItems)
{
- Vector<WebMenuItemInfo> customItems;
- for (size_t i = 0; i < defaultMenu->itemCount(); ++i) {
- ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription());
- if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() > ContextMenuItemLastCustomTag)
+ Vector<WebMenuItemInfo> subItems;
+ for (size_t i = 0; i < inputMenu->size(); ++i) {
+ const ContextMenuItem* inputItem = &inputMenu->at(i);
+ if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() > ContextMenuItemLastCustomTag)
continue;
WebMenuItemInfo outputItem;
@@ -371,16 +371,22 @@
outputItem.type = WebMenuItemInfo::Separator;
break;
case SubmenuType:
- outputItem.type = WebMenuItemInfo::Group;
+ outputItem.type = WebMenuItemInfo::SubMenu;
+ populateSubMenuItems(inputItem->platformSubMenu(), outputItem.subMenuItems);
break;
}
- customItems.append(outputItem);
+ subItems.append(outputItem);
}
- WebVector<WebMenuItemInfo> outputItems(customItems.size());
- for (size_t i = 0; i < customItems.size(); ++i)
- outputItems[i] = customItems[i];
- data->customItems.swap(outputItems);
+ WebVector<WebMenuItemInfo> outputItems(subItems.size());
+ for (size_t i = 0; i < subItems.size(); ++i)
+ outputItems[i] = subItems[i];
+ subMenuItems.swap(outputItems);
}
+void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
+{
+ populateSubMenuItems(defaultMenu->platformDescription(), data->customItems);
+}
+
} // namespace WebKit