| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 var result = this.appendItem(label, action.execute.bind(action)); | 164 var result = this.appendItem(label, action.execute.bind(action)); |
| 165 var shortcut = WebInspector.shortcutRegistry.shortcutTitleForAction(acti
onId); | 165 var shortcut = WebInspector.shortcutRegistry.shortcutTitleForAction(acti
onId); |
| 166 if (shortcut) | 166 if (shortcut) |
| 167 result.setShortcut(shortcut); | 167 result.setShortcut(shortcut); |
| 168 return result; | 168 return result; |
| 169 }, | 169 }, |
| 170 | 170 |
| 171 /** | 171 /** |
| 172 * @param {string} label | 172 * @param {string} label |
| 173 * @param {boolean=} disabled | 173 * @param {boolean=} disabled |
| 174 * @param {string=} subMenuId | |
| 175 * @return {!WebInspector.ContextSubMenuItem} | 174 * @return {!WebInspector.ContextSubMenuItem} |
| 176 */ | 175 */ |
| 177 appendSubMenuItem: function(label, disabled, subMenuId) | 176 appendSubMenuItem: function(label, disabled) |
| 178 { | 177 { |
| 179 var item = new WebInspector.ContextSubMenuItem(this._contextMenu, label,
disabled); | 178 var item = new WebInspector.ContextSubMenuItem(this._contextMenu, label,
disabled); |
| 180 if (subMenuId) | |
| 181 this._contextMenu._namedSubMenus.set(subMenuId, item); | |
| 182 this._pushItem(item); | 179 this._pushItem(item); |
| 183 return item; | 180 return item; |
| 184 }, | 181 }, |
| 185 | 182 |
| 186 /** | 183 /** |
| 187 * @param {string} label | 184 * @param {string} label |
| 188 * @param {function()} handler | 185 * @param {function()} handler |
| 189 * @param {boolean=} checked | 186 * @param {boolean=} checked |
| 190 * @param {boolean=} disabled | 187 * @param {boolean=} disabled |
| 191 * @return {!WebInspector.ContextMenuItem} | 188 * @return {!WebInspector.ContextMenuItem} |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 appendItemsAtLocation: function(location) | 239 appendItemsAtLocation: function(location) |
| 243 { | 240 { |
| 244 /** | 241 /** |
| 245 * @param {!WebInspector.ContextSubMenuItem} menu | 242 * @param {!WebInspector.ContextSubMenuItem} menu |
| 246 * @param {!Runtime.Extension} extension | 243 * @param {!Runtime.Extension} extension |
| 247 */ | 244 */ |
| 248 function appendExtension(menu, extension) | 245 function appendExtension(menu, extension) |
| 249 { | 246 { |
| 250 var subMenuId = extension.descriptor()["subMenuId"]; | 247 var subMenuId = extension.descriptor()["subMenuId"]; |
| 251 if (subMenuId) { | 248 if (subMenuId) { |
| 252 var subMenuItem = menu.appendSubMenuItem(extension.title(), fals
e, subMenuId); | 249 var subMenuItem = menu.appendSubMenuItem(extension.title(WebInsp
ector.platform())); |
| 253 subMenuItem.appendItemsAtLocation(subMenuId); | 250 subMenuItem.appendItemsAtLocation(subMenuId); |
| 254 } else { | 251 } else { |
| 255 menu.appendAction(extension.descriptor()["actionId"]); | 252 menu.appendAction(extension.descriptor()["actionId"]); |
| 256 } | 253 } |
| 257 } | 254 } |
| 258 | 255 |
| 259 // Hard-coded named groups for elements to maintain generic order. | 256 // Hard-coded named groups for elements to maintain generic order. |
| 260 var groupWeights = ["new", "open", "clipboard", "navigate", "footer"]; | 257 var groupWeights = ["new", "open", "clipboard", "navigate", "footer"]; |
| 261 | 258 |
| 262 /** @type {!Map.<string, !Array.<!Runtime.Extension>>} */ | 259 /** @type {!Map.<string, !Array.<!Runtime.Extension>>} */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 /** @type {!Array.<!Promise.<!Array.<!WebInspector.ContextMenu.Provider>>>}
*/ | 302 /** @type {!Array.<!Promise.<!Array.<!WebInspector.ContextMenu.Provider>>>}
*/ |
| 306 this._pendingPromises = []; | 303 this._pendingPromises = []; |
| 307 /** @type {!Array<!Object>} */ | 304 /** @type {!Array<!Object>} */ |
| 308 this._pendingTargets = []; | 305 this._pendingTargets = []; |
| 309 this._event = event; | 306 this._event = event; |
| 310 this._useSoftMenu = !!useSoftMenu; | 307 this._useSoftMenu = !!useSoftMenu; |
| 311 this._x = x === undefined ? event.x : x; | 308 this._x = x === undefined ? event.x : x; |
| 312 this._y = y === undefined ? event.y : y; | 309 this._y = y === undefined ? event.y : y; |
| 313 this._handlers = {}; | 310 this._handlers = {}; |
| 314 this._id = 0; | 311 this._id = 0; |
| 315 /** @type {!Map<string, !WebInspector.ContextSubMenuItem>} */ | |
| 316 this._namedSubMenus = new Map(); | |
| 317 } | 312 } |
| 318 | 313 |
| 319 WebInspector.ContextMenu.initialize = function() | 314 WebInspector.ContextMenu.initialize = function() |
| 320 { | 315 { |
| 321 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.SetUseSoftMenu, setUseSoftMenu); | 316 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.SetUseSoftMenu, setUseSoftMenu); |
| 322 /** | 317 /** |
| 323 * @param {!WebInspector.Event} event | 318 * @param {!WebInspector.Event} event |
| 324 */ | 319 */ |
| 325 function setUseSoftMenu(event) | 320 function setUseSoftMenu(event) |
| 326 { | 321 { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 476 |
| 482 /** | 477 /** |
| 483 * @param {!Object} target | 478 * @param {!Object} target |
| 484 */ | 479 */ |
| 485 appendApplicableItems: function(target) | 480 appendApplicableItems: function(target) |
| 486 { | 481 { |
| 487 this._pendingPromises.push(self.runtime.instancesPromise(WebInspector.Co
ntextMenu.Provider, target)); | 482 this._pendingPromises.push(self.runtime.instancesPromise(WebInspector.Co
ntextMenu.Provider, target)); |
| 488 this._pendingTargets.push(target); | 483 this._pendingTargets.push(target); |
| 489 }, | 484 }, |
| 490 | 485 |
| 491 /** | |
| 492 * @param {string} name | |
| 493 * @return {?WebInspector.ContextSubMenuItem} | |
| 494 */ | |
| 495 namedSubMenu: function(name) | |
| 496 { | |
| 497 return this._namedSubMenus.get(name) || null; | |
| 498 }, | |
| 499 | |
| 500 __proto__: WebInspector.ContextSubMenuItem.prototype | 486 __proto__: WebInspector.ContextSubMenuItem.prototype |
| 501 } | 487 } |
| 502 | 488 |
| 503 /** | 489 /** |
| 504 * @interface | 490 * @interface |
| 505 */ | 491 */ |
| 506 WebInspector.ContextMenu.Provider = function() { | 492 WebInspector.ContextMenu.Provider = function() { |
| 507 } | 493 } |
| 508 | 494 |
| 509 WebInspector.ContextMenu.Provider.prototype = { | 495 WebInspector.ContextMenu.Provider.prototype = { |
| 510 /** | 496 /** |
| 511 * @param {!Event} event | 497 * @param {!Event} event |
| 512 * @param {!WebInspector.ContextMenu} contextMenu | 498 * @param {!WebInspector.ContextMenu} contextMenu |
| 513 * @param {!Object} target | 499 * @param {!Object} target |
| 514 */ | 500 */ |
| 515 appendApplicableItems: function(event, contextMenu, target) { } | 501 appendApplicableItems: function(event, contextMenu, target) { } |
| 516 } | 502 } |
| OLD | NEW |