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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/ContextMenu.js

Issue 1978323002: DevTools: reveal object path in console tooltip (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add beforeShow Created 4 years, 7 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
OLDNEW
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 WebInspector.ContextMenu.prototype = { 344 WebInspector.ContextMenu.prototype = {
345 /** 345 /**
346 * @return {number} 346 * @return {number}
347 */ 347 */
348 _nextId: function() 348 _nextId: function()
349 { 349 {
350 return this._id++; 350 return this._id++;
351 }, 351 },
352 352
353 /**
354 * @param {function()} callback
355 */
356 beforeShow: function(callback)
357 {
358 this._beforeShow = callback;
359 },
360
353 show: function() 361 show: function()
354 { 362 {
355 Promise.all(this._pendingPromises).then(populateAndShow.bind(this)); 363 Promise.all(this._pendingPromises).then(populate.bind(this)).then(this._ innerShow.bind(this));
356 WebInspector.ContextMenu._pendingMenu = this; 364 WebInspector.ContextMenu._pendingMenu = this;
357 365
358 /** 366 /**
359 * @param {!Array.<!Array.<!WebInspector.ContextMenu.Provider>>} appendC allResults 367 * @param {!Array.<!Array.<!WebInspector.ContextMenu.Provider>>} appendC allResults
360 * @this {WebInspector.ContextMenu} 368 * @this {WebInspector.ContextMenu}
361 */ 369 */
362 function populateAndShow(appendCallResults) 370 function populate(appendCallResults)
363 { 371 {
364 if (WebInspector.ContextMenu._pendingMenu !== this) 372 if (WebInspector.ContextMenu._pendingMenu !== this)
365 return; 373 return;
366 delete WebInspector.ContextMenu._pendingMenu; 374 delete WebInspector.ContextMenu._pendingMenu;
367 375
368 for (var i = 0; i < appendCallResults.length; ++i) { 376 for (var i = 0; i < appendCallResults.length; ++i) {
369 var providers = appendCallResults[i]; 377 var providers = appendCallResults[i];
370 var target = this._pendingTargets[i]; 378 var target = this._pendingTargets[i];
371 379
372 for (var j = 0; j < providers.length; ++j) { 380 for (var j = 0; j < providers.length; ++j) {
373 var provider = /** @type {!WebInspector.ContextMenu.Provider } */ (providers[j]); 381 var provider = /** @type {!WebInspector.ContextMenu.Provider } */ (providers[j]);
374 this.appendSeparator(); 382 this.appendSeparator();
375 provider.appendApplicableItems(this._event, this, target); 383 provider.appendApplicableItems(this._event, this, target);
376 this.appendSeparator(); 384 this.appendSeparator();
377 } 385 }
378 } 386 }
379 387
380 this._pendingPromises = []; 388 this._pendingPromises = [];
381 this._pendingTargets = []; 389 this._pendingTargets = [];
382 this._innerShow();
383 } 390 }
384 391
385 this._event.consume(true); 392 this._event.consume(true);
386 }, 393 },
387 394
388 discard: function() 395 discard: function()
389 { 396 {
390 if (this._softMenu) 397 if (this._softMenu)
391 this._softMenu.discard(); 398 this._softMenu.discard();
392 }, 399 },
393 400
394 _innerShow: function() 401 _innerShow: function()
395 { 402 {
403 if (typeof this._beforeShow === "function")
404 this._beforeShow();
dgozman 2016/05/18 23:56:32 delete this._beforeShow;
luoe 2016/05/19 00:04:58 Done.
405
396 var menuObject = this._buildDescriptors(); 406 var menuObject = this._buildDescriptors();
397 407
398 WebInspector._contextMenu = this; 408 WebInspector._contextMenu = this;
399 if (this._useSoftMenu || WebInspector.ContextMenu._useSoftMenu || Inspec torFrontendHost.isHostedMode()) { 409 if (this._useSoftMenu || WebInspector.ContextMenu._useSoftMenu || Inspec torFrontendHost.isHostedMode()) {
400 this._softMenu = new WebInspector.SoftContextMenu(menuObject, this._ itemSelected.bind(this)); 410 this._softMenu = new WebInspector.SoftContextMenu(menuObject, this._ itemSelected.bind(this));
401 this._softMenu.show(this._event.target.ownerDocument, this._x, this. _y); 411 this._softMenu.show(this._event.target.ownerDocument, this._x, this. _y);
402 } else { 412 } else {
403 InspectorFrontendHost.showContextMenuAtPoint(this._x, this._y, menuO bject, this._event.target.ownerDocument); 413 InspectorFrontendHost.showContextMenuAtPoint(this._x, this._y, menuO bject, this._event.target.ownerDocument);
404 414
405 /** 415 /**
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 491 }
482 492
483 WebInspector.ContextMenu.Provider.prototype = { 493 WebInspector.ContextMenu.Provider.prototype = {
484 /** 494 /**
485 * @param {!Event} event 495 * @param {!Event} event
486 * @param {!WebInspector.ContextMenu} contextMenu 496 * @param {!WebInspector.ContextMenu} contextMenu
487 * @param {!Object} target 497 * @param {!Object} target
488 */ 498 */
489 appendApplicableItems: function(event, contextMenu, target) { } 499 appendApplicableItems: function(event, contextMenu, target) { }
490 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698