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

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

Issue 1358893003: Ignore mouseup shortly after showing cr.ui.Menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix context menus Created 5 years, 2 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 | « chrome/test/data/webui/menu_test.html ('k') | ui/webui/resources/js/cr/ui/menu.js » ('j') | 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 // require: event_target.js 5 // require: event_target.js
6 6
7 cr.define('cr.ui', function() { 7 cr.define('cr.ui', function() {
8 /** @const */ var EventTarget = cr.EventTarget; 8 /** @const */ var EventTarget = cr.EventTarget;
9 /** @const */ var Menu = cr.ui.Menu; 9 /** @const */ var Menu = cr.ui.Menu;
10 10
(...skipping 25 matching lines...) Expand all
36 * event). 36 * event).
37 * @param {!cr.ui.Menu} menu The menu to show. 37 * @param {!cr.ui.Menu} menu The menu to show.
38 */ 38 */
39 showMenu: function(e, menu) { 39 showMenu: function(e, menu) {
40 menu.updateCommands(assertInstanceof(e.currentTarget, Node)); 40 menu.updateCommands(assertInstanceof(e.currentTarget, Node));
41 if (!menu.hasVisibleItems()) 41 if (!menu.hasVisibleItems())
42 return; 42 return;
43 43
44 this.menu_ = menu; 44 this.menu_ = menu;
45 menu.classList.remove('hide-delayed'); 45 menu.classList.remove('hide-delayed');
46 menu.hidden = false; 46 menu.show({x: e.screenX, y: e.screenY});
47 menu.contextElement = e.currentTarget; 47 menu.contextElement = e.currentTarget;
48 48
49 // When the menu is shown we steal a lot of events. 49 // When the menu is shown we steal a lot of events.
50 var doc = menu.ownerDocument; 50 var doc = menu.ownerDocument;
51 var win = doc.defaultView; 51 var win = doc.defaultView;
52 this.showingEvents_.add(doc, 'keydown', this, true); 52 this.showingEvents_.add(doc, 'keydown', this, true);
53 this.showingEvents_.add(doc, 'mousedown', this, true); 53 this.showingEvents_.add(doc, 'mousedown', this, true);
54 this.showingEvents_.add(doc, 'touchstart', this, true); 54 this.showingEvents_.add(doc, 'touchstart', this, true);
55 this.showingEvents_.add(doc, 'focus', this); 55 this.showingEvents_.add(doc, 'focus', this);
56 this.showingEvents_.add(win, 'popstate', this); 56 this.showingEvents_.add(win, 'popstate', this);
(...skipping 16 matching lines...) Expand all
73 */ 73 */
74 hideMenu: function(opt_hideType) { 74 hideMenu: function(opt_hideType) {
75 var menu = this.menu; 75 var menu = this.menu;
76 if (!menu) 76 if (!menu)
77 return; 77 return;
78 78
79 if (opt_hideType == cr.ui.HideType.DELAYED) 79 if (opt_hideType == cr.ui.HideType.DELAYED)
80 menu.classList.add('hide-delayed'); 80 menu.classList.add('hide-delayed');
81 else 81 else
82 menu.classList.remove('hide-delayed'); 82 menu.classList.remove('hide-delayed');
83 menu.hidden = true; 83 menu.hide();
84 var originalContextElement = menu.contextElement; 84 var originalContextElement = menu.contextElement;
85 menu.contextElement = null; 85 menu.contextElement = null;
86 this.showingEvents_.removeAll(); 86 this.showingEvents_.removeAll();
87 menu.selectedIndex = -1; 87 menu.selectedIndex = -1;
88 this.menu_ = null; 88 this.menu_ = null;
89 89
90 // On windows we might hide the menu in a right mouse button up and if 90 // On windows we might hide the menu in a right mouse button up and if
91 // that is the case we wait some short period before we allow the menu 91 // that is the case we wait some short period before we allow the menu
92 // to be shown again. 92 // to be shown again.
93 this.hideTimestamp_ = cr.isWindows ? Date.now() : 0; 93 this.hideTimestamp_ = cr.isWindows ? Date.now() : 0;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 * The singleton context menu handler. 280 * The singleton context menu handler.
281 * @type {!ContextMenuHandler} 281 * @type {!ContextMenuHandler}
282 */ 282 */
283 var contextMenuHandler = new ContextMenuHandler; 283 var contextMenuHandler = new ContextMenuHandler;
284 284
285 // Export 285 // Export
286 return { 286 return {
287 contextMenuHandler: contextMenuHandler, 287 contextMenuHandler: contextMenuHandler,
288 }; 288 };
289 }); 289 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/menu_test.html ('k') | ui/webui/resources/js/cr/ui/menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698