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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js

Issue 2250473002: DevTools: Repick execution context when frames are loaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TargetManager.Observer} 7 * @implements {WebInspector.TargetManager.Observer}
8 * @param {!WebInspector.TargetManager} targetManager 8 * @param {!WebInspector.TargetManager} targetManager
9 * @param {!WebInspector.Context} context 9 * @param {!WebInspector.Context} context
10 */ 10 */
11 WebInspector.ExecutionContextSelector = function(targetManager, context) 11 WebInspector.ExecutionContextSelector = function(targetManager, context)
12 { 12 {
13 targetManager.observeTargets(this, WebInspector.Target.Capability.JS); 13 targetManager.observeTargets(this, WebInspector.Target.Capability.JS);
14 context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executi onContextChanged, this); 14 context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executi onContextChanged, this);
15 context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, th is); 15 context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, th is);
16 16
17 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti meModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this); 17 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti meModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this);
18 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti meModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, thi s); 18 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti meModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, thi s);
19 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti meModel.Events.ResortExecutionContexts, this._onResortExecutionContexts, this);
pfeldman 2016/08/16 16:28:28 ExecutionContextOrderChanged.
einbinder 2016/08/16 17:36:09 Done.
19 this._targetManager = targetManager; 20 this._targetManager = targetManager;
20 this._context = context; 21 this._context = context;
21 } 22 }
22 23
23 WebInspector.ExecutionContextSelector.prototype = { 24 WebInspector.ExecutionContextSelector.prototype = {
24 25
25 /** 26 /**
26 * @override 27 * @override
27 * @param {!WebInspector.Target} target 28 * @param {!WebInspector.Target} target
28 */ 29 */
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 /** 153 /**
153 * @param {!WebInspector.Event} event 154 * @param {!WebInspector.Event} event
154 */ 155 */
155 _onExecutionContextDestroyed: function(event) 156 _onExecutionContextDestroyed: function(event)
156 { 157 {
157 var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (eve nt.data); 158 var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (eve nt.data);
158 if (this._context.flavor(WebInspector.ExecutionContext) === executionCon text) 159 if (this._context.flavor(WebInspector.ExecutionContext) === executionCon text)
159 this._currentExecutionContextGone(); 160 this._currentExecutionContextGone();
160 }, 161 },
161 162
163 /**
164 * @param {!WebInspector.Event} event
165 */
166 _onResortExecutionContexts: function(event)
167 {
168 var runtimeModel = /** @type {!WebInspector.RuntimeModel} */ (event.data );
169 var executionContexts = runtimeModel.executionContexts();
170 for (var i = 0; i < executionContexts.length; i++) {
171 var executionContext = executionContexts[i];
172 if (this._shouldSwitchToContext(executionContext)) {
pfeldman 2016/08/16 16:28:28 _onExecutionContextCreated has similar semantics.
einbinder 2016/08/16 17:36:09 Done.
173 this._ignoreContextChanged = true;
174 this._context.setFlavor(WebInspector.ExecutionContext, execution Context);
175 this._ignoreContextChanged = false;
176 break;
177 }
178 }
179 },
180
162 _currentExecutionContextGone: function() 181 _currentExecutionContextGone: function()
163 { 182 {
164 var targets = this._targetManager.targets(WebInspector.Target.Capability .JS); 183 var targets = this._targetManager.targets(WebInspector.Target.Capability .JS);
165 var newContext = null; 184 var newContext = null;
166 for (var i = 0; i < targets.length && !newContext; ++i) { 185 for (var i = 0; i < targets.length && !newContext; ++i) {
167 var executionContexts = targets[i].runtimeModel.executionContexts(); 186 var executionContexts = targets[i].runtimeModel.executionContexts();
168 for (var executionContext of executionContexts) { 187 for (var executionContext of executionContexts) {
169 if (this._isMainFrameContext(executionContext)) { 188 if (this._isMainFrameContext(executionContext)) {
170 newContext = executionContext; 189 newContext = executionContext;
171 break; 190 break;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 bracketCount--; 252 bracketCount--;
234 if (bracketCount < 0) 253 if (bracketCount < 0)
235 break; 254 break;
236 } 255 }
237 index--; 256 index--;
238 } 257 }
239 clippedExpression = clippedExpression.substring(index + 1); 258 clippedExpression = clippedExpression.substring(index + 1);
240 259
241 executionContext.completionsForExpression(clippedExpression, completionsPref ix, force, completionsReadyCallback); 260 executionContext.completionsForExpression(clippedExpression, completionsPref ix, force, completionsReadyCallback);
242 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698