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