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

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: Rename fire event 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.ExecutionContextOrderChanged, this._onExecutionContextOrderChange d, this);
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (frame && frame.isMainFrame()) 135 if (frame && frame.isMainFrame())
135 return true; 136 return true;
136 return false; 137 return false;
137 }, 138 },
138 139
139 /** 140 /**
140 * @param {!WebInspector.Event} event 141 * @param {!WebInspector.Event} event
141 */ 142 */
142 _onExecutionContextCreated: function(event) 143 _onExecutionContextCreated: function(event)
143 { 144 {
144 var executionContext = /** @type {!WebInspector.ExecutionContext} */ (ev ent.data); 145 this._switchContextIfNecessary(/** @type {!WebInspector.ExecutionContext } */ (event.data));
145 if (!this._context.flavor(WebInspector.ExecutionContext) || this._should SwitchToContext(executionContext)) {
146 this._ignoreContextChanged = true;
147 this._context.setFlavor(WebInspector.ExecutionContext, executionCont ext);
148 this._ignoreContextChanged = false;
149 }
150 }, 146 },
151 147
152 /** 148 /**
153 * @param {!WebInspector.Event} event 149 * @param {!WebInspector.Event} event
154 */ 150 */
155 _onExecutionContextDestroyed: function(event) 151 _onExecutionContextDestroyed: function(event)
156 { 152 {
157 var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (eve nt.data); 153 var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (eve nt.data);
158 if (this._context.flavor(WebInspector.ExecutionContext) === executionCon text) 154 if (this._context.flavor(WebInspector.ExecutionContext) === executionCon text)
159 this._currentExecutionContextGone(); 155 this._currentExecutionContextGone();
160 }, 156 },
161 157
158 /**
159 * @param {!WebInspector.Event} event
160 */
161 _onExecutionContextOrderChanged: function(event)
162 {
163 var runtimeModel = /** @type {!WebInspector.RuntimeModel} */ (event.data );
164 var executionContexts = runtimeModel.executionContexts();
165 for (var i = 0; i < executionContexts.length; i++) {
166 if (this._switchContextIfNecessary(executionContexts[i]))
167 break;
168 }
169 },
170
171 /**
172 * @param {!WebInspector.ExecutionContext} executionContext
173 * @return {boolean}
174 */
175 _switchContextIfNecessary: function(executionContext)
176 {
177 if (!this._context.flavor(WebInspector.ExecutionContext) || this._should SwitchToContext(executionContext)) {
178 this._ignoreContextChanged = true;
179 this._context.setFlavor(WebInspector.ExecutionContext, executionCont ext);
180 this._ignoreContextChanged = false;
181 return true;
182 }
183 return false;
184 },
185
162 _currentExecutionContextGone: function() 186 _currentExecutionContextGone: function()
163 { 187 {
164 var targets = this._targetManager.targets(WebInspector.Target.Capability .JS); 188 var targets = this._targetManager.targets(WebInspector.Target.Capability .JS);
165 var newContext = null; 189 var newContext = null;
166 for (var i = 0; i < targets.length && !newContext; ++i) { 190 for (var i = 0; i < targets.length && !newContext; ++i) {
167 var executionContexts = targets[i].runtimeModel.executionContexts(); 191 var executionContexts = targets[i].runtimeModel.executionContexts();
168 for (var executionContext of executionContexts) { 192 for (var executionContext of executionContexts) {
169 if (this._isMainFrameContext(executionContext)) { 193 if (this._isMainFrameContext(executionContext)) {
170 newContext = executionContext; 194 newContext = executionContext;
171 break; 195 break;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 bracketCount--; 257 bracketCount--;
234 if (bracketCount < 0) 258 if (bracketCount < 0)
235 break; 259 break;
236 } 260 }
237 index--; 261 index--;
238 } 262 }
239 clippedExpression = clippedExpression.substring(index + 1); 263 clippedExpression = clippedExpression.substring(index + 1);
240 264
241 executionContext.completionsForExpression(clippedExpression, completionsPref ix, force, completionsReadyCallback); 265 executionContext.completionsForExpression(clippedExpression, completionsPref ix, force, completionsReadyCallback);
242 } 266 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698