From a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 25 May 2012 15:09:11 +0200 Subject: Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516) --- .../WebKit/chromium/src/ContextMenuClientImpl.cpp | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'Source/WebKit/chromium/src/ContextMenuClientImpl.cpp') diff --git a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp index d35eb0e6c..5871f44e1 100644 --- a/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp +++ b/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -280,7 +280,7 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) { RefPtr range = selectedFrame->selection()->toNormalizedRange(); if (range.get()) { - Vector markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling); + Vector markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); if (!markers.isEmpty()) { Vector suggestions; for (size_t i = 0; i < markers.size(); ++i) { @@ -347,12 +347,12 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( return 0; } -void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) +static void populateSubMenuItems(PlatformMenuDescription inputMenu, WebVector& subMenuItems) { - Vector 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 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 @@ void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaul 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 outputItems(customItems.size()); - for (size_t i = 0; i < customItems.size(); ++i) - outputItems[i] = customItems[i]; - data->customItems.swap(outputItems); + WebVector 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 -- cgit v1.2.1