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

Unified Diff: Source/core/page/CustomContextMenuProvider.cpp

Issue 802233004: Implement icon attribute for menuitem (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: LayoutTest rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLMenuItemElement.idl ('k') | Source/platform/ContextMenuItem.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/CustomContextMenuProvider.cpp
diff --git a/Source/core/page/CustomContextMenuProvider.cpp b/Source/core/page/CustomContextMenuProvider.cpp
index d60fe9ebc9fc5b7b378263303cf794968c2c1629..1fbb11efb639a887105867fcbeeea01f1df5ea37 100644
--- a/Source/core/page/CustomContextMenuProvider.cpp
+++ b/Source/core/page/CustomContextMenuProvider.cpp
@@ -69,7 +69,7 @@ void CustomContextMenuProvider::appendSeparator(ContextMenu& contextMenu)
if (lastItem.type() == SeparatorType)
return;
- contextMenu.appendItem(ContextMenuItem(SeparatorType, ContextMenuItemCustomTagNoAction, String()));
+ contextMenu.appendItem(ContextMenuItem(SeparatorType, ContextMenuItemCustomTagNoAction, String(), String()));
}
void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem, ContextMenu& contextMenu)
@@ -82,11 +82,18 @@ void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem, Co
m_menuItems.append(menuItem);
bool enabled = !menuItem->fastHasAttribute(disabledAttr);
+ String icon = menuItem->fastGetAttribute(iconAttr);
+ if (!icon.isEmpty()) {
+ // To obtain the absolute URL of the icon when the attribute's value is not the empty string,
+ // the attribute's value must be resolved relative to the element.
+ KURL iconURL = KURL(menuItem->baseURI(), icon);
+ icon = iconURL.string();
+ }
ContextMenuAction action = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + m_menuItems.size() - 1);
if (equalIgnoringCase(menuItem->fastGetAttribute(typeAttr), "checkbox") || equalIgnoringCase(menuItem->fastGetAttribute(typeAttr), "radio"))
- contextMenu.appendItem(ContextMenuItem(CheckableActionType, action, labelString, enabled, menuItem->fastHasAttribute(checkedAttr)));
+ contextMenu.appendItem(ContextMenuItem(CheckableActionType, action, labelString, icon, enabled, menuItem->fastHasAttribute(checkedAttr)));
else
- contextMenu.appendItem(ContextMenuItem(ActionType, action, labelString, enabled, false));
+ contextMenu.appendItem(ContextMenuItem(ActionType, action, labelString, icon, enabled, false));
}
void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement& menu, ContextMenu& contextMenu)
@@ -105,7 +112,7 @@ void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement&
appendSeparator(contextMenu);
} else if (!labelString.isEmpty()) {
populateContextMenuItems(*toHTMLMenuElement(nextElement), subMenu);
- contextMenu.appendItem(ContextMenuItem(SubmenuType, ContextMenuItemCustomTagNoAction, labelString, &subMenu));
+ contextMenu.appendItem(ContextMenuItem(SubmenuType, ContextMenuItemCustomTagNoAction, labelString, String(), &subMenu));
}
nextElement = Traversal<HTMLElement>::nextSibling(*nextElement);
} else if (isHTMLMenuItemElement(*nextElement)) {
« no previous file with comments | « Source/core/html/HTMLMenuItemElement.idl ('k') | Source/platform/ContextMenuItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698