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

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

Issue 1092933004: Swallow double-click events on menu buttons in Web UI in chrome://bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolving merge conflict. 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 // <include src="../../assert.js"> 5 // <include src="../../assert.js">
6 6
7 cr.exportPath('cr.ui'); 7 cr.exportPath('cr.ui');
8 8
9 /** 9 /**
10 * Enum for type of hide. Delayed is used when called by clicking on a 10 * Enum for type of hide. Delayed is used when called by clicking on a
(...skipping 26 matching lines...) Expand all
37 37
38 MenuButton.prototype = { 38 MenuButton.prototype = {
39 __proto__: HTMLButtonElement.prototype, 39 __proto__: HTMLButtonElement.prototype,
40 40
41 /** 41 /**
42 * Initializes the menu button. 42 * Initializes the menu button.
43 */ 43 */
44 decorate: function() { 44 decorate: function() {
45 this.addEventListener('mousedown', this); 45 this.addEventListener('mousedown', this);
46 this.addEventListener('keydown', this); 46 this.addEventListener('keydown', this);
47 this.addEventListener('dblclick', this);
47 48
48 // Adding the 'custom-appearance' class prevents widgets.css from changing 49 // Adding the 'custom-appearance' class prevents widgets.css from changing
49 // the appearance of this element. 50 // the appearance of this element.
50 this.classList.add('custom-appearance'); 51 this.classList.add('custom-appearance');
51 this.classList.add('menu-button'); // For styles in menu_button.css. 52 this.classList.add('menu-button'); // For styles in menu_button.css.
52 53
53 var menu; 54 var menu;
54 if ((menu = this.getAttribute('menu'))) 55 if ((menu = this.getAttribute('menu')))
55 this.menu = menu; 56 this.menu = menu;
56 57
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 this.hideMenu(); 156 this.hideMenu();
156 break; 157 break;
157 case 'contextmenu': 158 case 'contextmenu':
158 if ((!this.menu || !this.menu.contains(e.target)) && 159 if ((!this.menu || !this.menu.contains(e.target)) &&
159 (!this.hideTimestamp_ || Date.now() - this.hideTimestamp_ > 50)) 160 (!this.hideTimestamp_ || Date.now() - this.hideTimestamp_ > 50))
160 this.showMenu(true); 161 this.showMenu(true);
161 e.preventDefault(); 162 e.preventDefault();
162 // Don't allow elements further up in the DOM to show their menus. 163 // Don't allow elements further up in the DOM to show their menus.
163 e.stopPropagation(); 164 e.stopPropagation();
164 break; 165 break;
166 case 'dblclick':
167 // Don't allow double click events to propagate.
168 e.preventDefault();
169 e.stopPropagation();
170 break;
165 } 171 }
166 }, 172 },
167 173
168 /** 174 /**
169 * Shows the menu. 175 * Shows the menu.
170 * @param {boolean} shouldSetFocus Whether to set focus on the 176 * @param {boolean} shouldSetFocus Whether to set focus on the
171 * selected menu item. 177 * selected menu item.
172 */ 178 */
173 showMenu: function(shouldSetFocus) { 179 showMenu: function(shouldSetFocus) {
174 this.hideMenu(); 180 this.hideMenu();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, opt_hoverColor); 319 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, opt_hoverColor);
314 createDropDownArrowCanvas( 320 createDropDownArrowCanvas(
315 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, opt_activeColor); 321 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, opt_activeColor);
316 }; 322 };
317 323
318 // Export 324 // Export
319 return { 325 return {
320 MenuButton: MenuButton, 326 MenuButton: MenuButton,
321 }; 327 };
322 }); 328 });
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