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

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

Issue 2502413004: WTF/std normalization: replace WTF::Vector::last with ::back (Closed)
Patch Set: rebase Created 4 years, 1 month 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
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 "core/page/CustomContextMenuProvider.h" 5 #include "core/page/CustomContextMenuProvider.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ElementTraversal.h" 8 #include "core/dom/ElementTraversal.h"
9 #include "core/events/EventDispatcher.h" 9 #include "core/events/EventDispatcher.h"
10 #include "core/events/MouseEvent.h" 10 #include "core/events/MouseEvent.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 m_subjectElement = nullptr; 51 m_subjectElement = nullptr;
52 } 52 }
53 53
54 void CustomContextMenuProvider::appendSeparator(ContextMenu& contextMenu) { 54 void CustomContextMenuProvider::appendSeparator(ContextMenu& contextMenu) {
55 // Avoid separators at the start of any menu and submenu. 55 // Avoid separators at the start of any menu and submenu.
56 if (!contextMenu.items().size()) 56 if (!contextMenu.items().size())
57 return; 57 return;
58 58
59 // Collapse all sequences of two or more adjacent separators in the menu or 59 // Collapse all sequences of two or more adjacent separators in the menu or
60 // any submenus to a single separator. 60 // any submenus to a single separator.
61 ContextMenuItem lastItem = contextMenu.items().last(); 61 ContextMenuItem lastItem = contextMenu.items().back();
62 if (lastItem.type() == SeparatorType) 62 if (lastItem.type() == SeparatorType)
63 return; 63 return;
64 64
65 contextMenu.appendItem(ContextMenuItem( 65 contextMenu.appendItem(ContextMenuItem(
66 SeparatorType, ContextMenuItemCustomTagNoAction, String(), String())); 66 SeparatorType, ContextMenuItemCustomTagNoAction, String(), String()));
67 } 67 }
68 68
69 void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem, 69 void CustomContextMenuProvider::appendMenuItem(HTMLMenuItemElement* menuItem,
70 ContextMenu& contextMenu) { 70 ContextMenu& contextMenu) {
71 // Avoid menuitems with no label. 71 // Avoid menuitems with no label.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ContextMenuItemLastCustomTag) 124 ContextMenuItemLastCustomTag)
125 break; 125 break;
126 nextElement = Traversal<HTMLElement>::next(*nextElement, &menu); 126 nextElement = Traversal<HTMLElement>::next(*nextElement, &menu);
127 } else { 127 } else {
128 nextElement = Traversal<HTMLElement>::next(*nextElement, &menu); 128 nextElement = Traversal<HTMLElement>::next(*nextElement, &menu);
129 } 129 }
130 } 130 }
131 131
132 // Remove separators at the end of the menu and any submenus. 132 // Remove separators at the end of the menu and any submenus.
133 while (contextMenu.items().size() && 133 while (contextMenu.items().size() &&
134 contextMenu.items().last().type() == SeparatorType) 134 contextMenu.items().back().type() == SeparatorType)
135 contextMenu.removeLastItem(); 135 contextMenu.removeLastItem();
136 } 136 }
137 137
138 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId) { 138 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId) {
139 int itemIndex = menuId - ContextMenuItemBaseCustomTag; 139 int itemIndex = menuId - ContextMenuItemBaseCustomTag;
140 if (itemIndex < 0 || 140 if (itemIndex < 0 ||
141 static_cast<unsigned long>(itemIndex) >= m_menuItems.size()) 141 static_cast<unsigned long>(itemIndex) >= m_menuItems.size())
142 return nullptr; 142 return nullptr;
143 return m_menuItems[itemIndex].get(); 143 return m_menuItems[itemIndex].get();
144 } 144 }
145 145
146 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698