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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js

Issue 2623143002: DevTools: insert console message decorations in order
Patch Set: a Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
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 b1913a0f6fd741103fcb9693add42ae71c310360..66e0ae1154749661c46a52a073fb1b8b76a1e030 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
@@ -29,10 +29,24 @@ Console.ConsoleContextSelector = class {
}
/**
+ * @param {?SDK.ExecutionContext} executionContext
+ * @return {boolean}
+ */
+ static isTopContext(executionContext) {
+ if (!executionContext || !executionContext.isDefault)
+ return false;
+ var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target());
+ var frame = executionContext.frameId && resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId);
+ if (!frame)
+ return false;
+ return frame.isMainFrame();
+ }
+
+ /**
* @param {!SDK.ExecutionContext} executionContext
* @return {string}
*/
- _titleFor(executionContext) {
+ static titleForContext(executionContext) {
var target = executionContext.target();
var depth = 0;
var label = executionContext.label() ? target.decorateLabel(executionContext.label()) : '';
@@ -79,7 +93,7 @@ Console.ConsoleContextSelector = class {
var newOption = createElement('option');
newOption.__executionContext = executionContext;
- newOption.text = this._titleFor(executionContext);
+ newOption.text = Console.ConsoleContextSelector.titleForContext(executionContext);
this._optionByExecutionContext.set(executionContext, newOption);
var options = this._selectElement.options;
var contexts = Array.prototype.map.call(options, mapping);
@@ -114,7 +128,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.titleForContext(executionContext);
this._updateSelectionWarning();
}
@@ -160,21 +174,7 @@ Console.ConsoleContextSelector = class {
_updateSelectionWarning() {
var executionContext = UI.context.flavor(SDK.ExecutionContext);
this._selectElement.parentElement.classList.toggle(
- 'warning', !this._isTopContext(executionContext) && this._hasTopContext());
- }
-
- /**
- * @param {?SDK.ExecutionContext} executionContext
- * @return {boolean}
- */
- _isTopContext(executionContext) {
- if (!executionContext || !executionContext.isDefault)
- return false;
- var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target());
- var frame = executionContext.frameId && resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId);
- if (!frame)
- return false;
- return frame.isMainFrame();
+ 'warning', !Console.ConsoleContextSelector.isTopContext(executionContext) && this._hasTopContext());
}
/**
@@ -183,7 +183,7 @@ Console.ConsoleContextSelector = class {
_hasTopContext() {
var options = this._selectElement.options;
for (var i = 0; i < options.length; i++) {
- if (this._isTopContext(options[i].__executionContext))
+ if (Console.ConsoleContextSelector.isTopContext(options[i].__executionContext))
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698