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

Side by Side Diff: Source/devtools/front_end/ui/SoftContextMenu.js

Issue 669113002: DevTools: replace mouseout with mouseleave where possible. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: for landing Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineView.js ('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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 WebInspector.SoftContextMenu.prototype = { 39 WebInspector.SoftContextMenu.prototype = {
40 /** 40 /**
41 * @param {!Document} document 41 * @param {!Document} document
42 * @param {number} x 42 * @param {number} x
43 * @param {number} y 43 * @param {number} y
44 */ 44 */
45 show: function(document, x, y) 45 show: function(document, x, y)
46 { 46 {
47 if (this._contextMenuElement)
48 this._discardMenu(true);
49 if (!this._items.length)
50 return;
51
47 this._document = document; 52 this._document = document;
48 this._x = x; 53 this._x = x;
49 this._y = y; 54 this._y = y;
50 this._time = new Date().getTime(); 55 this._time = new Date().getTime();
51 56
52 // Create context menu. 57 // Create context menu.
53 this._contextMenuElement = createElementWithClass("div", "soft-context-m enu"); 58 this._contextMenuElement = createElementWithClass("div", "soft-context-m enu");
54 this._contextMenuElement.tabIndex = 0; 59 this._contextMenuElement.tabIndex = 0;
55 this._contextMenuElement.style.top = y + "px"; 60 this._contextMenuElement.style.top = y + "px";
56 this._contextMenuElement.style.left = x + "px"; 61 this._contextMenuElement.style.left = x + "px";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (!item.checked) 108 if (!item.checked)
104 checkMarkElement.style.opacity = "0"; 109 checkMarkElement.style.opacity = "0";
105 110
106 menuItemElement.createTextChild(item.label); 111 menuItemElement.createTextChild(item.label);
107 112
108 menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bi nd(this), false); 113 menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bi nd(this), false);
109 menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(t his), false); 114 menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(t his), false);
110 115
111 // Manually manage hover highlight since :hover does not work in case of click-and-hold menu invocation. 116 // Manually manage hover highlight since :hover does not work in case of click-and-hold menu invocation.
112 menuItemElement.addEventListener("mouseover", this._menuItemMouseOver.bi nd(this), false); 117 menuItemElement.addEventListener("mouseover", this._menuItemMouseOver.bi nd(this), false);
113 menuItemElement.addEventListener("mouseout", this._menuItemMouseOut.bind (this), false); 118 menuItemElement.addEventListener("mouseleave", this._menuItemMouseLeave. bind(this), false);
114 119
115 menuItemElement._actionId = item.id; 120 menuItemElement._actionId = item.id;
116 return menuItemElement; 121 return menuItemElement;
117 }, 122 },
118 123
119 _createSubMenu: function(item) 124 _createSubMenu: function(item)
120 { 125 {
121 var menuItemElement = createElementWithClass("div", "soft-context-menu-i tem"); 126 var menuItemElement = createElementWithClass("div", "soft-context-menu-i tem");
122 menuItemElement._subItems = item.subItems; 127 menuItemElement._subItems = item.subItems;
123 128
124 // Occupy the same space on the left in all items. 129 // Occupy the same space on the left in all items.
125 var checkMarkElement = menuItemElement.createChild("span", "soft-context -menu-item-checkmark"); 130 var checkMarkElement = menuItemElement.createChild("span", "soft-context -menu-item-checkmark");
126 checkMarkElement.textContent = "\u2713 "; // Checkmark Unicode symbol 131 checkMarkElement.textContent = "\u2713 "; // Checkmark Unicode symbol
127 checkMarkElement.style.opacity = "0"; 132 checkMarkElement.style.opacity = "0";
128 133
129 menuItemElement.createTextChild(item.label); 134 menuItemElement.createTextChild(item.label);
130 135
131 var subMenuArrowElement = menuItemElement.createChild("span", "soft-cont ext-menu-item-submenu-arrow"); 136 var subMenuArrowElement = menuItemElement.createChild("span", "soft-cont ext-menu-item-submenu-arrow");
132 subMenuArrowElement.textContent = "\u25B6"; // BLACK RIGHT-POINTING TRIA NGLE 137 subMenuArrowElement.textContent = "\u25B6"; // BLACK RIGHT-POINTING TRIA NGLE
133 138
134 menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bi nd(this), false); 139 menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bi nd(this), false);
135 menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(t his), false); 140 menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(t his), false);
136 141
137 // Manually manage hover highlight since :hover does not work in case of click-and-hold menu invocation. 142 // Manually manage hover highlight since :hover does not work in case of click-and-hold menu invocation.
138 menuItemElement.addEventListener("mouseover", this._menuItemMouseOver.bi nd(this), false); 143 menuItemElement.addEventListener("mouseover", this._menuItemMouseOver.bi nd(this), false);
139 menuItemElement.addEventListener("mouseout", this._menuItemMouseOut.bind (this), false); 144 menuItemElement.addEventListener("mouseleave", this._menuItemMouseLeave. bind(this), false);
140 145
141 return menuItemElement; 146 return menuItemElement;
142 }, 147 },
143 148
144 _createSeparator: function() 149 _createSeparator: function()
145 { 150 {
146 var separatorElement = createElementWithClass("div", "soft-context-menu- separator"); 151 var separatorElement = createElementWithClass("div", "soft-context-menu- separator");
147 separatorElement._isSeparator = true; 152 separatorElement._isSeparator = true;
148 separatorElement.addEventListener("mouseover", this._hideSubMenu.bind(th is), false); 153 separatorElement.addEventListener("mouseover", this._hideSubMenu.bind(th is), false);
149 separatorElement.createChild("div", "separator-line"); 154 separatorElement.createChild("div", "separator-line");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return; 206 return;
202 this._subMenu._discardSubMenus(); 207 this._subMenu._discardSubMenus();
203 this._focus(); 208 this._focus();
204 }, 209 },
205 210
206 _menuItemMouseOver: function(event) 211 _menuItemMouseOver: function(event)
207 { 212 {
208 this._highlightMenuItem(event.target); 213 this._highlightMenuItem(event.target);
209 }, 214 },
210 215
211 _menuItemMouseOut: function(event) 216 _menuItemMouseLeave: function(event)
212 { 217 {
213 if (!this._subMenu || !event.relatedTarget) { 218 if (!this._subMenu || !event.relatedTarget) {
214 this._highlightMenuItem(null); 219 this._highlightMenuItem(null);
215 return; 220 return;
216 } 221 }
217 222
218 var relatedTarget = event.relatedTarget; 223 var relatedTarget = event.relatedTarget;
219 if (this._contextMenuElement.isSelfOrAncestor(relatedTarget) || relatedT arget.classList.contains("soft-context-menu-glass-pane")) 224 if (relatedTarget.classList.contains("soft-context-menu-glass-pane"))
220 this._highlightMenuItem(null); 225 this._highlightMenuItem(null);
221 }, 226 },
222 227
223 _highlightMenuItem: function(menuItemElement) 228 _highlightMenuItem: function(menuItemElement)
224 { 229 {
225 if (this._highlightedMenuItemElement === menuItemElement) 230 if (this._highlightedMenuItemElement === menuItemElement)
226 return; 231 return;
227 232
228 this._hideSubMenu(); 233 this._hideSubMenu();
229 if (this._highlightedMenuItemElement) { 234 if (this._highlightedMenuItemElement) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 343
339 _discardSubMenus: function() 344 _discardSubMenus: function()
340 { 345 {
341 if (this._subMenu) 346 if (this._subMenu)
342 this._subMenu._discardSubMenus(); 347 this._subMenu._discardSubMenus();
343 this._contextMenuElement.remove(); 348 this._contextMenuElement.remove();
344 if (this._parentMenu) 349 if (this._parentMenu)
345 delete this._parentMenu._subMenu; 350 delete this._parentMenu._subMenu;
346 } 351 }
347 } 352 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698