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

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

Issue 1312883002: DevTools: don't highlight custom elements in soft context menu. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | « 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 /* 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return this._createSubMenu(item); 115 return this._createSubMenu(item);
116 116
117 var menuItemElement = createElementWithClass("div", "soft-context-menu-i tem"); 117 var menuItemElement = createElementWithClass("div", "soft-context-menu-i tem");
118 var checkMarkElement = menuItemElement.createChild("div", "checkmark"); 118 var checkMarkElement = menuItemElement.createChild("div", "checkmark");
119 if (!item.checked) 119 if (!item.checked)
120 checkMarkElement.style.opacity = "0"; 120 checkMarkElement.style.opacity = "0";
121 121
122 if (item.element) { 122 if (item.element) {
123 var wrapper = menuItemElement.createChild("div", "soft-context-menu- custom-item"); 123 var wrapper = menuItemElement.createChild("div", "soft-context-menu- custom-item");
124 wrapper.appendChild(item.element); 124 wrapper.appendChild(item.element);
125 menuItemElement._isCustom = true;
125 return menuItemElement; 126 return menuItemElement;
126 } 127 }
127 128
128 menuItemElement.createTextChild(item.label); 129 menuItemElement.createTextChild(item.label);
129 menuItemElement.createChild("span", "soft-context-menu-shortcut").textCo ntent = item.shortcut; 130 menuItemElement.createChild("span", "soft-context-menu-shortcut").textCo ntent = item.shortcut;
130 131
131 menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bi nd(this), false); 132 menuItemElement.addEventListener("mousedown", this._menuItemMouseDown.bi nd(this), false);
132 menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(t his), false); 133 menuItemElement.addEventListener("mouseup", this._menuItemMouseUp.bind(t his), false);
133 134
134 // Manually manage hover highlight since :hover does not work in case of click-and-hold menu invocation. 135 // Manually manage hover highlight since :hover does not work in case of click-and-hold menu invocation.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 this._highlightedMenuItemElement.classList.add("soft-context-menu-it em-mouse-over"); 267 this._highlightedMenuItemElement.classList.add("soft-context-menu-it em-mouse-over");
267 this._contextMenuElement.focus(); 268 this._contextMenuElement.focus();
268 if (this._highlightedMenuItemElement._subItems && !this._highlighted MenuItemElement._subMenuTimer) 269 if (this._highlightedMenuItemElement._subItems && !this._highlighted MenuItemElement._subMenuTimer)
269 this._highlightedMenuItemElement._subMenuTimer = setTimeout(this ._showSubMenu.bind(this, this._highlightedMenuItemElement), 150); 270 this._highlightedMenuItemElement._subMenuTimer = setTimeout(this ._showSubMenu.bind(this, this._highlightedMenuItemElement), 150);
270 } 271 }
271 }, 272 },
272 273
273 _highlightPrevious: function() 274 _highlightPrevious: function()
274 { 275 {
275 var menuItemElement = this._highlightedMenuItemElement ? this._highlight edMenuItemElement.previousSibling : this._contextMenuElement.lastChild; 276 var menuItemElement = this._highlightedMenuItemElement ? this._highlight edMenuItemElement.previousSibling : this._contextMenuElement.lastChild;
276 while (menuItemElement && menuItemElement._isSeparator) 277 while (menuItemElement && (menuItemElement._isSeparator || menuItemEleme nt._isCustom))
277 menuItemElement = menuItemElement.previousSibling; 278 menuItemElement = menuItemElement.previousSibling;
278 if (menuItemElement) 279 if (menuItemElement)
279 this._highlightMenuItem(menuItemElement); 280 this._highlightMenuItem(menuItemElement);
280 }, 281 },
281 282
282 _highlightNext: function() 283 _highlightNext: function()
283 { 284 {
284 var menuItemElement = this._highlightedMenuItemElement ? this._highlight edMenuItemElement.nextSibling : this._contextMenuElement.firstChild; 285 var menuItemElement = this._highlightedMenuItemElement ? this._highlight edMenuItemElement.nextSibling : this._contextMenuElement.firstChild;
285 while (menuItemElement && menuItemElement._isSeparator) 286 while (menuItemElement && (menuItemElement._isSeparator || menuItemEleme nt._isCustom))
286 menuItemElement = menuItemElement.nextSibling; 287 menuItemElement = menuItemElement.nextSibling;
287 if (menuItemElement) 288 if (menuItemElement)
288 this._highlightMenuItem(menuItemElement); 289 this._highlightMenuItem(menuItemElement);
289 }, 290 },
290 291
291 _menuKeyDown: function(event) 292 _menuKeyDown: function(event)
292 { 293 {
293 switch (event.keyIdentifier) { 294 switch (event.keyIdentifier) {
294 case "Up": 295 case "Up":
295 this._highlightPrevious(); break; 296 this._highlightPrevious(); break;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 373
373 _discardSubMenus: function() 374 _discardSubMenus: function()
374 { 375 {
375 if (this._subMenu) 376 if (this._subMenu)
376 this._subMenu._discardSubMenus(); 377 this._subMenu._discardSubMenus();
377 this._contextMenuElement.remove(); 378 this._contextMenuElement.remove();
378 if (this._parentMenu) 379 if (this._parentMenu)
379 delete this._parentMenu._subMenu; 380 delete this._parentMenu._subMenu;
380 } 381 }
381 } 382 }
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