Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
| index a7436d5c505ba9c66b9712175e72f9dd6e057f53..7ddadc86cc28e8511bb0077de76a9fc99eb94c12 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js |
| @@ -7,6 +7,29 @@ |
| */ |
| Console.ConsoleContextSelector = class { |
| /** |
| + * @param {!SDK.ExecutionContext} executionContext |
| + * @param {boolean} showStatus |
| + * @return {string} |
| + */ |
| + static titleFor(executionContext, showStatus) { |
|
allada
2017/01/19 02:38:08
I feel like this isn't very descriptive, I would s
luoe
2017/01/19 23:22:59
Done.
|
| + var result; |
| + if (executionContext.isDefault) { |
|
allada
2017/01/19 02:38:08
I suggest something more like:
if (executionConte
|
| + if (executionContext.frameId) { |
| + var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target()); |
| + var frame = resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId); |
| + result = frame ? frame.displayName() : executionContext.label(showStatus); |
| + } else { |
| + result = executionContext.target().decorateLabel(executionContext.label(showStatus)); |
| + } |
| + } else { |
| + result = executionContext.label(showStatus) || executionContext.origin; |
| + } |
| + |
| + var maxLength = 50; |
|
allada
2017/01/19 02:38:08
nit: inline or change this to const.
luoe
2017/01/19 23:22:59
Done.
|
| + return result.trimMiddle(maxLength); |
| + } |
| + |
| + /** |
| * @param {!Element} selectElement |
| */ |
| constructor(selectElement) { |
| @@ -30,28 +53,6 @@ Console.ConsoleContextSelector = class { |
| /** |
| * @param {!SDK.ExecutionContext} executionContext |
| - * @return {string} |
| - */ |
| - _titleFor(executionContext) { |
| - var result; |
| - if (executionContext.isDefault) { |
| - if (executionContext.frameId) { |
| - var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target()); |
| - var frame = resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId); |
| - result = frame ? frame.displayName() : executionContext.label(); |
| - } else { |
| - result = executionContext.target().decorateLabel(executionContext.label()); |
| - } |
| - } else { |
| - result = '\u00a0\u00a0\u00a0\u00a0' + (executionContext.label() || executionContext.origin); |
|
allada
2017/01/19 02:38:08
Looks like this unicode stuff was used for indenti
|
| - } |
| - |
| - var maxLength = 50; |
| - return result.trimMiddle(maxLength); |
| - } |
| - |
| - /** |
| - * @param {!SDK.ExecutionContext} executionContext |
| */ |
| _executionContextCreated(executionContext) { |
| // FIXME(413886): We never want to show execution context for the main thread of shadow page in service/shared worker frontend. |
| @@ -61,7 +62,7 @@ Console.ConsoleContextSelector = class { |
| var newOption = createElement('option'); |
| newOption.__executionContext = executionContext; |
| - newOption.text = this._titleFor(executionContext); |
| + newOption.text = Console.ConsoleContextSelector.titleFor(executionContext, true /* showStatus */); |
| this._optionByExecutionContext.set(executionContext, newOption); |
| var options = this._selectElement.options; |
| var contexts = Array.prototype.map.call(options, mapping); |
| @@ -96,7 +97,7 @@ Console.ConsoleContextSelector = class { |
| var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); |
| var option = this._optionByExecutionContext.get(executionContext); |
| if (option) |
| - option.text = this._titleFor(executionContext); |
| + option.text = Console.ConsoleContextSelector.titleFor(executionContext, true /* showStatus */); |
| this._updateSelectionWarning(); |
| } |