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

Side by Side Diff: Source/core/page/CustomContextMenuProvider.cpp

Issue 786753003: Implement type=radio and radiogroup attribute for menuitem. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaselined Created 6 years 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 unified diff | Download patch
« no previous file with comments | « Source/core/page/ContextMenuControllerTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/page/CustomContextMenuProvider.h" 6 #include "core/page/CustomContextMenuProvider.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/ElementTraversal.h" 9 #include "core/dom/ElementTraversal.h"
10 #include "core/events/EventDispatcher.h" 10 #include "core/events/EventDispatcher.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 { 76 {
77 // Avoid menuitems with no label. 77 // Avoid menuitems with no label.
78 String labelString = menuItem->fastGetAttribute(labelAttr); 78 String labelString = menuItem->fastGetAttribute(labelAttr);
79 if (labelString.isEmpty()) 79 if (labelString.isEmpty())
80 return; 80 return;
81 81
82 m_menuItems.append(menuItem); 82 m_menuItems.append(menuItem);
83 83
84 bool enabled = !menuItem->fastHasAttribute(disabledAttr); 84 bool enabled = !menuItem->fastHasAttribute(disabledAttr);
85 ContextMenuAction action = static_cast<ContextMenuAction>(ContextMenuItemBas eCustomTag + m_menuItems.size() - 1); 85 ContextMenuAction action = static_cast<ContextMenuAction>(ContextMenuItemBas eCustomTag + m_menuItems.size() - 1);
86 if (equalIgnoringCase(menuItem->fastGetAttribute(typeAttr), "checkbox")) 86 if (equalIgnoringCase(menuItem->fastGetAttribute(typeAttr), "checkbox") || e qualIgnoringCase(menuItem->fastGetAttribute(typeAttr), "radio"))
87 contextMenu.appendItem(ContextMenuItem(CheckableActionType, action, labe lString, enabled, menuItem->fastHasAttribute(checkedAttr))); 87 contextMenu.appendItem(ContextMenuItem(CheckableActionType, action, labe lString, enabled, menuItem->fastHasAttribute(checkedAttr)));
88 else 88 else
89 contextMenu.appendItem(ContextMenuItem(ActionType, action, labelString, enabled, false)); 89 contextMenu.appendItem(ContextMenuItem(ActionType, action, labelString, enabled, false));
90 } 90 }
91 91
92 void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement& menu, ContextMenu& contextMenu) 92 void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement& menu, ContextMenu& contextMenu)
93 { 93 {
94 HTMLElement* nextElement = Traversal<HTMLElement>::firstWithin(menu); 94 HTMLElement* nextElement = Traversal<HTMLElement>::firstWithin(menu);
95 while (nextElement) { 95 while (nextElement) {
96 if (isHTMLHRElement(*nextElement)) { 96 if (isHTMLHRElement(*nextElement)) {
(...skipping 28 matching lines...) Expand all
125 125
126 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId) 126 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId)
127 { 127 {
128 int itemIndex = menuId - ContextMenuItemBaseCustomTag; 128 int itemIndex = menuId - ContextMenuItemBaseCustomTag;
129 if (itemIndex < 0 || static_cast<unsigned long>(itemIndex) >= m_menuItems.si ze()) 129 if (itemIndex < 0 || static_cast<unsigned long>(itemIndex) >= m_menuItems.si ze())
130 return nullptr; 130 return nullptr;
131 return m_menuItems[itemIndex].get(); 131 return m_menuItems[itemIndex].get();
132 } 132 }
133 133
134 } // namespace blink 134 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/ContextMenuControllerTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698