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

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

Issue 2782773002: [DevTools] Remove SDKModels' fromTarget methods (Closed)
Patch Set: addressed review comments Created 3 years, 8 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.SDKModelObserver<!SDK.RuntimeModel>} 5 * @implements {SDK.SDKModelObserver<!SDK.RuntimeModel>}
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 21 matching lines...) Expand all
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 target = executionContext.target(); 36 var target = executionContext.target();
37 var depth = 0; 37 var depth = 0;
38 var label = executionContext.label() ? target.decorateLabel(executionContext .label()) : ''; 38 var label = executionContext.label() ? target.decorateLabel(executionContext .label()) : '';
39 if (!executionContext.isDefault) 39 if (!executionContext.isDefault)
40 depth++; 40 depth++;
41 if (executionContext.frameId) { 41 if (executionContext.frameId) {
42 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); 42 var resourceTreeModel = target.model(SDK.ResourceTreeModel);
43 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId); 43 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId);
44 if (frame) { 44 if (frame) {
45 label = label || frame.displayName(); 45 label = label || frame.displayName();
46 while (frame.parentFrame) { 46 while (frame.parentFrame) {
47 depth++; 47 depth++;
48 frame = frame.parentFrame; 48 frame = frame.parentFrame;
49 } 49 }
50 } 50 }
51 } 51 }
52 label = label || executionContext.origin; 52 label = label || executionContext.origin;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 'warning', !this._isTopContext(executionContext) && this._hasTopContext( )); 163 'warning', !this._isTopContext(executionContext) && this._hasTopContext( ));
164 } 164 }
165 165
166 /** 166 /**
167 * @param {?SDK.ExecutionContext} executionContext 167 * @param {?SDK.ExecutionContext} executionContext
168 * @return {boolean} 168 * @return {boolean}
169 */ 169 */
170 _isTopContext(executionContext) { 170 _isTopContext(executionContext) {
171 if (!executionContext || !executionContext.isDefault) 171 if (!executionContext || !executionContext.isDefault)
172 return false; 172 return false;
173 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.ta rget()); 173 var resourceTreeModel = executionContext.target().model(SDK.ResourceTreeMode l);
174 var frame = executionContext.frameId && resourceTreeModel && resourceTreeMod el.frameForId(executionContext.frameId); 174 var frame = executionContext.frameId && resourceTreeModel && resourceTreeMod el.frameForId(executionContext.frameId);
175 if (!frame) 175 if (!frame)
176 return false; 176 return false;
177 return frame.isMainFrame(); 177 return frame.isMainFrame();
178 } 178 }
179 179
180 /** 180 /**
181 * @return {boolean} 181 * @return {boolean}
182 */ 182 */
183 _hasTopContext() { 183 _hasTopContext() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 /** 220 /**
221 * @return {?Element} 221 * @return {?Element}
222 */ 222 */
223 _selectedOption() { 223 _selectedOption() {
224 if (this._selectElement.selectedIndex >= 0) 224 if (this._selectElement.selectedIndex >= 0)
225 return this._selectElement[this._selectElement.selectedIndex]; 225 return this._selectElement[this._selectElement.selectedIndex];
226 return null; 226 return null;
227 } 227 }
228 }; 228 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698