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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @implements {SDK.TargetManager.Observer} 5 * @implements {SDK.TargetManager.Observer}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Console.ConsoleContextSelector = class { 8 Console.ConsoleContextSelector = class {
9 /** 9 /**
10 * @param {!Element} selectElement 10 * @param {!Element} selectElement
(...skipping 15 matching lines...) Expand all
26 26
27 this._selectElement.addEventListener('change', this._executionContextChanged .bind(this), false); 27 this._selectElement.addEventListener('change', this._executionContextChanged .bind(this), false);
28 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChangedExternally, this); 28 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChangedExternally, this);
29 } 29 }
30 30
31 /** 31 /**
32 * @param {!SDK.ExecutionContext} executionContext 32 * @param {!SDK.ExecutionContext} executionContext
33 * @return {string} 33 * @return {string}
34 */ 34 */
35 _titleFor(executionContext) { 35 _titleFor(executionContext) {
36 var result; 36 var target = executionContext.target();
37 if (executionContext.isDefault) { 37 var depth = 0;
38 if (executionContext.frameId) { 38 var label = executionContext.label() ? target.decorateLabel(executionContext .label()) : '';
39 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContex t.target()); 39 if (!executionContext.isDefault)
40 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionC ontext.frameId); 40 depth++;
41 result = frame ? frame.displayName() : executionContext.label(); 41 if (executionContext.frameId) {
42 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
43 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId);
44 if (frame) {
45 label = label || frame.displayName();
46 while (frame.parentFrame) {
47 depth++;
48 frame = frame.parentFrame;
49 }
50 }
51 }
52 label = label || executionContext.origin;
53 var targetDepth = 0;
54 while (target.parentTarget()) {
55 if (target.parentTarget().hasJSCapability()) {
56 targetDepth++;
42 } else { 57 } else {
43 result = executionContext.target().decorateLabel(executionContext.label( )); 58 // Special casing service workers to be top-level.
59 targetDepth = 0;
60 break;
44 } 61 }
45 } else { 62 target = target.parentTarget();
46 result = '\u00a0\u00a0\u00a0\u00a0' + (executionContext.label() || executi onContext.origin);
47 } 63 }
48 64
65 depth += targetDepth;
66 var prefix = new Array(4 * depth + 1).join('\u00a0');
49 var maxLength = 50; 67 var maxLength = 50;
50 return result.trimMiddle(maxLength); 68 return (prefix + label).trimMiddle(maxLength);
51 } 69 }
52 70
53 /** 71 /**
54 * @param {!SDK.ExecutionContext} executionContext 72 * @param {!SDK.ExecutionContext} executionContext
55 */ 73 */
56 _executionContextCreated(executionContext) { 74 _executionContextCreated(executionContext) {
57 // FIXME(413886): We never want to show execution context for the main threa d of shadow page in service/shared worker frontend. 75 // FIXME(413886): We never want to show execution context for the main threa d of shadow page in service/shared worker frontend.
58 // This check could be removed once we do not send this context to frontend. 76 // This check could be removed once we do not send this context to frontend.
59 if (!executionContext.target().hasJSCapability()) 77 if (!executionContext.target().hasJSCapability())
60 return; 78 return;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 219
202 /** 220 /**
203 * @return {?Element} 221 * @return {?Element}
204 */ 222 */
205 _selectedOption() { 223 _selectedOption() {
206 if (this._selectElement.selectedIndex >= 0) 224 if (this._selectElement.selectedIndex >= 0)
207 return this._selectElement[this._selectElement.selectedIndex]; 225 return this._selectElement[this._selectElement.selectedIndex];
208 return null; 226 return null;
209 } 227 }
210 }; 228 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698