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

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

Issue 2647153002: [DevTools] Improve context and target naming. (Closed)
Patch Set: fixed comments and sorting 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 a7436d5c505ba9c66b9712175e72f9dd6e057f53..b1913a0f6fd741103fcb9693add42ae71c310360 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
@@ -33,21 +33,39 @@ Console.ConsoleContextSelector = class {
* @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();
+ var target = executionContext.target();
+ var depth = 0;
+ var label = executionContext.label() ? target.decorateLabel(executionContext.label()) : '';
+ if (!executionContext.isDefault)
+ depth++;
+ if (executionContext.frameId) {
+ var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
+ var frame = resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId);
+ if (frame) {
+ label = label || frame.displayName();
+ while (frame.parentFrame) {
+ depth++;
+ frame = frame.parentFrame;
+ }
+ }
+ }
+ label = label || executionContext.origin;
+ var targetDepth = 0;
+ while (target.parentTarget()) {
+ if (target.parentTarget().hasJSCapability()) {
+ targetDepth++;
} else {
- result = executionContext.target().decorateLabel(executionContext.label());
+ // Special casing service workers to be top-level.
+ targetDepth = 0;
+ break;
}
- } else {
- result = '\u00a0\u00a0\u00a0\u00a0' + (executionContext.label() || executionContext.origin);
+ target = target.parentTarget();
}
+ depth += targetDepth;
+ var prefix = new Array(4 * depth + 1).join('\u00a0');
var maxLength = 50;
- return result.trimMiddle(maxLength);
+ return (prefix + label).trimMiddle(maxLength);
}
/**

Powered by Google App Engine
This is Rietveld 408576698