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

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

Issue 2137773002: [DevTools] Replace the target type with capabilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [DevTools] Replace target type with capabilities Created 4 years, 5 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 */
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 WebInspector.ExecutionContextSelector.prototype = { 23 WebInspector.ExecutionContextSelector.prototype = {
24 24
25 /** 25 /**
26 * @override 26 * @override
27 * @param {!WebInspector.Target} target 27 * @param {!WebInspector.Target} target
28 */ 28 */
29 targetAdded: function(target) 29 targetAdded: function(target)
30 { 30 {
31 if (!target.hasJSContext()) 31 if (!target.hasJSDomains())
32 return; 32 return;
33 // Defer selecting default target since we need all clients to get their 33 // Defer selecting default target since we need all clients to get their
34 // targetAdded notifications first. 34 // targetAdded notifications first.
35 setImmediate(deferred.bind(this)); 35 setImmediate(deferred.bind(this));
36 36
37 /** 37 /**
38 * @this {WebInspector.ExecutionContextSelector} 38 * @this {WebInspector.ExecutionContextSelector}
39 */ 39 */
40 function deferred() 40 function deferred()
41 { 41 {
42 // We always want the second context for the service worker targets. 42 // We always want the second context for the service worker targets.
43 if (!this._context.flavor(WebInspector.Target)) 43 if (!this._context.flavor(WebInspector.Target))
44 this._context.setFlavor(WebInspector.Target, target); 44 this._context.setFlavor(WebInspector.Target, target);
45 } 45 }
46 }, 46 },
47 47
48 /** 48 /**
49 * @override 49 * @override
50 * @param {!WebInspector.Target} target 50 * @param {!WebInspector.Target} target
51 */ 51 */
52 targetRemoved: function(target) 52 targetRemoved: function(target)
53 { 53 {
54 if (!target.hasJSContext()) 54 if (!target.hasJSDomains())
55 return; 55 return;
56 var currentExecutionContext = this._context.flavor(WebInspector.Executio nContext); 56 var currentExecutionContext = this._context.flavor(WebInspector.Executio nContext);
57 if (currentExecutionContext && currentExecutionContext.target() === targ et) 57 if (currentExecutionContext && currentExecutionContext.target() === targ et)
58 this._currentExecutionContextGone(); 58 this._currentExecutionContextGone();
59 59
60 var targets = this._targetManager.targetsWithJSContext(); 60 var targets = this._targetManager.targetsWithJSContext();
61 if (this._context.flavor(WebInspector.Target) === target && targets.leng th) 61 if (this._context.flavor(WebInspector.Target) === target && targets.leng th)
62 this._context.setFlavor(WebInspector.Target, targets[0]); 62 this._context.setFlavor(WebInspector.Target, targets[0]);
63 }, 63 },
64 64
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (eve nt.data); 161 var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (eve nt.data);
162 if (this._context.flavor(WebInspector.ExecutionContext) === executionCon text) 162 if (this._context.flavor(WebInspector.ExecutionContext) === executionCon text)
163 this._currentExecutionContextGone(); 163 this._currentExecutionContextGone();
164 }, 164 },
165 165
166 _currentExecutionContextGone: function() 166 _currentExecutionContextGone: function()
167 { 167 {
168 var targets = this._targetManager.targetsWithJSContext(); 168 var targets = this._targetManager.targetsWithJSContext();
169 var newContext = null; 169 var newContext = null;
170 for (var i = 0; i < targets.length && !newContext; ++i) { 170 for (var i = 0; i < targets.length && !newContext; ++i) {
171 if (targets[i].isServiceWorker()) 171 if (!targets[i].hasJSDomains())
172 continue; 172 continue;
173 var executionContexts = targets[i].runtimeModel.executionContexts(); 173 var executionContexts = targets[i].runtimeModel.executionContexts();
174 for (var executionContext of executionContexts) { 174 for (var executionContext of executionContexts) {
175 if (this._isMainFrameContext(executionContext)) { 175 if (this._isMainFrameContext(executionContext)) {
176 newContext = executionContext; 176 newContext = executionContext;
177 break; 177 break;
178 } 178 }
179 } 179 }
180 } 180 }
181 if (!newContext) { 181 if (!newContext) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 var expressionString = expressionRange.toString(); 214 var expressionString = expressionRange.toString();
215 215
216 // The "[" is also a stop character, except when it's the last character of the expression. 216 // The "[" is also a stop character, except when it's the last character of the expression.
217 var pos = expressionString.lastIndexOf("[", expressionString.length - 2); 217 var pos = expressionString.lastIndexOf("[", expressionString.length - 2);
218 if (pos !== -1) 218 if (pos !== -1)
219 expressionString = expressionString.substr(pos + 1); 219 expressionString = expressionString.substr(pos + 1);
220 220
221 var prefix = wordRange.toString(); 221 var prefix = wordRange.toString();
222 executionContext.completionsForExpression(expressionString, text, cursorOffs et, prefix, force, completionsReadyCallback); 222 executionContext.completionsForExpression(expressionString, text, cursorOffs et, prefix, force, completionsReadyCallback);
223 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698