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

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

Issue 1668603003: Devtools: Switch JS execution context to match inspected node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TargetManager.Observer} 7 * @implements {WebInspector.TargetManager.Observer}
8 * @param {!Element} selectElement 8 * @param {!Element} selectElement
9 */ 9 */
10 WebInspector.ExecutionContextModel = function(selectElement) 10 WebInspector.ExecutionContextModel = function(selectElement)
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 WebInspector.context.setFlavor(WebInspector.ExecutionContext, newContext ); 145 WebInspector.context.setFlavor(WebInspector.ExecutionContext, newContext );
146 }, 146 },
147 147
148 /** 148 /**
149 * @override 149 * @override
150 * @param {!WebInspector.Target} target 150 * @param {!WebInspector.Target} target
151 */ 151 */
152 targetAdded: function(target) 152 targetAdded: function(target)
153 { 153 {
154 target.runtimeModel.executionContexts().forEach(this._executionContextCr eated, this); 154 target.runtimeModel.executionContexts().forEach(this._executionContextCr eated, this);
155 var domModel = WebInspector.DOMModel.fromTarget(target);
156 if (domModel)
157 domModel.addEventListener(WebInspector.DOMModel.Events.NodeInspected , this._nodeInspected, this);
pfeldman 2016/02/04 00:18:53 This code should move to the UI level in order to
samli 2016/02/05 19:43:16 Done
155 }, 158 },
156 159
157 /** 160 /**
158 * @override 161 * @override
159 * @param {!WebInspector.Target} target 162 * @param {!WebInspector.Target} target
160 */ 163 */
161 targetRemoved: function(target) 164 targetRemoved: function(target)
162 { 165 {
163 var executionContexts = this._optionByExecutionContext.keysArray(); 166 var executionContexts = this._optionByExecutionContext.keysArray();
164 for (var i = 0; i < executionContexts.length; ++i) { 167 for (var i = 0; i < executionContexts.length; ++i) {
165 if (executionContexts[i].target() === target) 168 if (executionContexts[i].target() === target)
166 this._executionContextDestroyed(executionContexts[i]); 169 this._executionContextDestroyed(executionContexts[i]);
167 } 170 }
171 var domModel = WebInspector.DOMModel.fromTarget(target);
172 if (domModel)
173 domModel.removeEventListener(WebInspector.DOMModel.Events.NodeInspec ted, this._nodeInspected, this);
168 }, 174 },
169 175
170 /** 176 /**
177 * @param {!WebInspector.Event} event
178 */
179 _nodeInspected: function(event)
180 {
181 /**
182 * @param {?WebInspector.DOMNode} domNode
183 * @this {!WebInspector.ExecutionContextModel}
184 */
185 function updateExecutionContext(domNode)
186 {
187 if (!domNode)
188 return;
189 var executionContexts = this._optionByExecutionContext.keysArray();
190 for (var context of executionContexts) {
191 if (context.frameId == domNode.frameId() || (!domNode.frameId() && context.isMainWorldContext)) {
192 WebInspector.context.setFlavor(WebInspector.ExecutionContext , context);
193 return;
194 }
195 }
196 }
197
198 var deferredNode = /** @type {!WebInspector.DeferredDOMNode} */(event.da ta);
199 deferredNode.resolvePromise().then(updateExecutionContext.bind(this));
200 },
201
202 /**
171 * @param {!Element} option 203 * @param {!Element} option
172 */ 204 */
173 _select: function(option) 205 _select: function(option)
174 { 206 {
175 this._selectElement.selectedIndex = Array.prototype.indexOf.call(/** @ty pe {?} */ (this._selectElement), option); 207 this._selectElement.selectedIndex = Array.prototype.indexOf.call(/** @ty pe {?} */ (this._selectElement), option);
176 }, 208 },
177 209
178 /** 210 /**
179 * @return {?Element} 211 * @return {?Element}
180 */ 212 */
181 _selectedOption: function() 213 _selectedOption: function()
182 { 214 {
183 if (this._selectElement.selectedIndex >= 0) 215 if (this._selectElement.selectedIndex >= 0)
184 return this._selectElement[this._selectElement.selectedIndex]; 216 return this._selectElement[this._selectElement.selectedIndex];
185 return null; 217 return null;
186 } 218 }
187 } 219 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698