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

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

Issue 761743002: Implement disabled and checked attribute for menuitem. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: "disabled" only 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 | « LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu-expected.txt ('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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem, Co ntextMenu& contextMenu) 75 void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem, Co ntextMenu& contextMenu)
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 contextMenu.appendItem(ContextMenuItem(ActionType, static_cast<ContextMenuAc tion>(ContextMenuItemBaseCustomTag + m_menuItems.size() - 1), labelString)); 83 contextMenu.appendItem(ContextMenuItem(ActionType, static_cast<ContextMenuAc tion>(ContextMenuItemBaseCustomTag + m_menuItems.size() - 1), labelString, !menu Item->fastHasAttribute(disabledAttr), false));
84 } 84 }
85 85
86 void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement& menu, ContextMenu& contextMenu) 86 void CustomContextMenuProvider::populateContextMenuItems(const HTMLMenuElement& menu, ContextMenu& contextMenu)
87 { 87 {
88 HTMLElement* nextElement = Traversal<HTMLElement>::firstWithin(menu); 88 HTMLElement* nextElement = Traversal<HTMLElement>::firstWithin(menu);
89 while (nextElement) { 89 while (nextElement) {
90 if (isHTMLHRElement(*nextElement)) { 90 if (isHTMLHRElement(*nextElement)) {
91 appendSeparator(contextMenu); 91 appendSeparator(contextMenu);
92 nextElement = Traversal<HTMLElement>::next(*nextElement, &menu); 92 nextElement = Traversal<HTMLElement>::next(*nextElement, &menu);
93 } else if (isHTMLMenuElement(*nextElement)) { 93 } else if (isHTMLMenuElement(*nextElement)) {
(...skipping 25 matching lines...) Expand all
119 119
120 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId) 120 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId)
121 { 121 {
122 int itemIndex = menuId - ContextMenuItemBaseCustomTag; 122 int itemIndex = menuId - ContextMenuItemBaseCustomTag;
123 if (itemIndex < 0 || static_cast<unsigned long>(itemIndex) >= m_menuItems.si ze()) 123 if (itemIndex < 0 || static_cast<unsigned long>(itemIndex) >= m_menuItems.si ze())
124 return nullptr; 124 return nullptr;
125 return m_menuItems[itemIndex].get(); 125 return m_menuItems[itemIndex].get();
126 } 126 }
127 127
128 } // namespace blink 128 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698