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

Side by Side Diff: ui/webui/resources/js/cr/ui/menu.js

Issue 1095303004: Make Menu.findMenuItem_ return the first MenuItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 6
7 /** @const */ var MenuItem = cr.ui.MenuItem; 7 /** @const */ var MenuItem = cr.ui.MenuItem;
8 8
9 /** 9 /**
10 * Creates a new menu element. Menu dispatches all commands on the element it 10 * Creates a new menu element. Menu dispatches all commands on the element it
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 }, 81 },
82 82
83 /** 83 /**
84 * Walks up the ancestors of |node| until a menu item belonging to this menu 84 * Walks up the ancestors of |node| until a menu item belonging to this menu
85 * is found. 85 * is found.
86 * @param {Node} node The node to start searching from. 86 * @param {Node} node The node to start searching from.
87 * @return {cr.ui.MenuItem} The found menu item or null. 87 * @return {cr.ui.MenuItem} The found menu item or null.
88 * @private 88 * @private
89 */ 89 */
90 findMenuItem_: function(node) { 90 findMenuItem_: function(node) {
91 while (node && node.parentNode != this) { 91 while (node && node.parentNode != this && !(node instanceof MenuItem)) {
92 node = node.parentNode; 92 node = node.parentNode;
93 } 93 }
94 return node ? assertInstanceof(node, MenuItem) : null; 94 return node ? assertInstanceof(node, MenuItem) : null;
95 }, 95 },
96 96
97 /** 97 /**
98 * Handles mouseover events and selects the hovered item. 98 * Handles mouseover events and selects the hovered item.
99 * @param {Event} e The mouseover event. 99 * @param {Event} e The mouseover event.
100 * @private 100 * @private
101 */ 101 */
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 /** 273 /**
274 * Selector for children which are menu items. 274 * Selector for children which are menu items.
275 */ 275 */
276 cr.defineProperty(Menu, 'menuItemSelector', cr.PropertyKind.ATTR); 276 cr.defineProperty(Menu, 'menuItemSelector', cr.PropertyKind.ATTR);
277 277
278 // Export 278 // Export
279 return { 279 return {
280 Menu: Menu 280 Menu: Menu
281 }; 281 };
282 }); 282 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698