| Index: third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js b/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js
|
| index ee2b485db90dbee365cbd8cb23f494cb1672b159..3fddc4d44a5404af7c7734a6fa0706c1075b00fd 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js
|
| @@ -2,27 +2,27 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
| /**
|
| - * @implements {WebInspector.TargetManager.Observer}
|
| + * @implements {SDK.TargetManager.Observer}
|
| * @unrestricted
|
| */
|
| -WebInspector.ExecutionContextSelector = class {
|
| +Components.ExecutionContextSelector = class {
|
| /**
|
| - * @param {!WebInspector.TargetManager} targetManager
|
| - * @param {!WebInspector.Context} context
|
| + * @param {!SDK.TargetManager} targetManager
|
| + * @param {!UI.Context} context
|
| */
|
| constructor(targetManager, context) {
|
| - targetManager.observeTargets(this, WebInspector.Target.Capability.JS);
|
| - context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this);
|
| - context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, this);
|
| + targetManager.observeTargets(this, SDK.Target.Capability.JS);
|
| + context.addFlavorChangeListener(SDK.ExecutionContext, this._executionContextChanged, this);
|
| + context.addFlavorChangeListener(SDK.Target, this._targetChanged, this);
|
|
|
| targetManager.addModelListener(
|
| - WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextCreated,
|
| + SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextCreated,
|
| this._onExecutionContextCreated, this);
|
| targetManager.addModelListener(
|
| - WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextDestroyed,
|
| + SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextDestroyed,
|
| this._onExecutionContextDestroyed, this);
|
| targetManager.addModelListener(
|
| - WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextOrderChanged,
|
| + SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextOrderChanged,
|
| this._onExecutionContextOrderChanged, this);
|
| this._targetManager = targetManager;
|
| this._context = context;
|
| @@ -30,7 +30,7 @@ WebInspector.ExecutionContextSelector = class {
|
|
|
| /**
|
| * @override
|
| - * @param {!WebInspector.Target} target
|
| + * @param {!SDK.Target} target
|
| */
|
| targetAdded(target) {
|
| // Defer selecting default target since we need all clients to get their
|
| @@ -38,43 +38,43 @@ WebInspector.ExecutionContextSelector = class {
|
| setImmediate(deferred.bind(this));
|
|
|
| /**
|
| - * @this {WebInspector.ExecutionContextSelector}
|
| + * @this {Components.ExecutionContextSelector}
|
| */
|
| function deferred() {
|
| // We always want the second context for the service worker targets.
|
| - if (!this._context.flavor(WebInspector.Target))
|
| - this._context.setFlavor(WebInspector.Target, target);
|
| + if (!this._context.flavor(SDK.Target))
|
| + this._context.setFlavor(SDK.Target, target);
|
| }
|
| }
|
|
|
| /**
|
| * @override
|
| - * @param {!WebInspector.Target} target
|
| + * @param {!SDK.Target} target
|
| */
|
| targetRemoved(target) {
|
| - var currentExecutionContext = this._context.flavor(WebInspector.ExecutionContext);
|
| + var currentExecutionContext = this._context.flavor(SDK.ExecutionContext);
|
| if (currentExecutionContext && currentExecutionContext.target() === target)
|
| this._currentExecutionContextGone();
|
|
|
| - var targets = this._targetManager.targets(WebInspector.Target.Capability.JS);
|
| - if (this._context.flavor(WebInspector.Target) === target && targets.length)
|
| - this._context.setFlavor(WebInspector.Target, targets[0]);
|
| + var targets = this._targetManager.targets(SDK.Target.Capability.JS);
|
| + if (this._context.flavor(SDK.Target) === target && targets.length)
|
| + this._context.setFlavor(SDK.Target, targets[0]);
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.Event} event
|
| + * @param {!Common.Event} event
|
| */
|
| _executionContextChanged(event) {
|
| - var newContext = /** @type {?WebInspector.ExecutionContext} */ (event.data);
|
| + var newContext = /** @type {?SDK.ExecutionContext} */ (event.data);
|
| if (newContext) {
|
| - this._context.setFlavor(WebInspector.Target, newContext.target());
|
| + this._context.setFlavor(SDK.Target, newContext.target());
|
| if (!this._ignoreContextChanged)
|
| this._lastSelectedContextId = this._contextPersistentId(newContext);
|
| }
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.ExecutionContext} executionContext
|
| + * @param {!SDK.ExecutionContext} executionContext
|
| * @return {string}
|
| */
|
| _contextPersistentId(executionContext) {
|
| @@ -82,11 +82,11 @@ WebInspector.ExecutionContextSelector = class {
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.Event} event
|
| + * @param {!Common.Event} event
|
| */
|
| _targetChanged(event) {
|
| - var newTarget = /** @type {?WebInspector.Target} */ (event.data);
|
| - var currentContext = this._context.flavor(WebInspector.ExecutionContext);
|
| + var newTarget = /** @type {?SDK.Target} */ (event.data);
|
| + var currentContext = this._context.flavor(SDK.ExecutionContext);
|
|
|
| if (!newTarget || (currentContext && currentContext.target() === newTarget))
|
| return;
|
| @@ -105,12 +105,12 @@ WebInspector.ExecutionContextSelector = class {
|
| newContext = executionContexts[i];
|
| }
|
| this._ignoreContextChanged = true;
|
| - this._context.setFlavor(WebInspector.ExecutionContext, newContext || executionContexts[0]);
|
| + this._context.setFlavor(SDK.ExecutionContext, newContext || executionContexts[0]);
|
| this._ignoreContextChanged = false;
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.ExecutionContext} executionContext
|
| + * @param {!SDK.ExecutionContext} executionContext
|
| * @return {boolean}
|
| */
|
| _shouldSwitchToContext(executionContext) {
|
| @@ -122,7 +122,7 @@ WebInspector.ExecutionContextSelector = class {
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.ExecutionContext} executionContext
|
| + * @param {!SDK.ExecutionContext} executionContext
|
| * @return {boolean}
|
| */
|
| _isDefaultContext(executionContext) {
|
| @@ -130,7 +130,7 @@ WebInspector.ExecutionContextSelector = class {
|
| return false;
|
| if (executionContext.target().parentTarget())
|
| return false;
|
| - var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(executionContext.target());
|
| + var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(executionContext.target());
|
| var frame = resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId);
|
| if (frame && frame.isMainFrame())
|
| return true;
|
| @@ -138,26 +138,26 @@ WebInspector.ExecutionContextSelector = class {
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.Event} event
|
| + * @param {!Common.Event} event
|
| */
|
| _onExecutionContextCreated(event) {
|
| - this._switchContextIfNecessary(/** @type {!WebInspector.ExecutionContext} */ (event.data));
|
| + this._switchContextIfNecessary(/** @type {!SDK.ExecutionContext} */ (event.data));
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.Event} event
|
| + * @param {!Common.Event} event
|
| */
|
| _onExecutionContextDestroyed(event) {
|
| - var executionContext = /** @type {!WebInspector.ExecutionContext}*/ (event.data);
|
| - if (this._context.flavor(WebInspector.ExecutionContext) === executionContext)
|
| + var executionContext = /** @type {!SDK.ExecutionContext}*/ (event.data);
|
| + if (this._context.flavor(SDK.ExecutionContext) === executionContext)
|
| this._currentExecutionContextGone();
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.Event} event
|
| + * @param {!Common.Event} event
|
| */
|
| _onExecutionContextOrderChanged(event) {
|
| - var runtimeModel = /** @type {!WebInspector.RuntimeModel} */ (event.data);
|
| + var runtimeModel = /** @type {!SDK.RuntimeModel} */ (event.data);
|
| var executionContexts = runtimeModel.executionContexts();
|
| for (var i = 0; i < executionContexts.length; i++) {
|
| if (this._switchContextIfNecessary(executionContexts[i]))
|
| @@ -166,13 +166,13 @@ WebInspector.ExecutionContextSelector = class {
|
| }
|
|
|
| /**
|
| - * @param {!WebInspector.ExecutionContext} executionContext
|
| + * @param {!SDK.ExecutionContext} executionContext
|
| * @return {boolean}
|
| */
|
| _switchContextIfNecessary(executionContext) {
|
| - if (!this._context.flavor(WebInspector.ExecutionContext) || this._shouldSwitchToContext(executionContext)) {
|
| + if (!this._context.flavor(SDK.ExecutionContext) || this._shouldSwitchToContext(executionContext)) {
|
| this._ignoreContextChanged = true;
|
| - this._context.setFlavor(WebInspector.ExecutionContext, executionContext);
|
| + this._context.setFlavor(SDK.ExecutionContext, executionContext);
|
| this._ignoreContextChanged = false;
|
| return true;
|
| }
|
| @@ -180,7 +180,7 @@ WebInspector.ExecutionContextSelector = class {
|
| }
|
|
|
| _currentExecutionContextGone() {
|
| - var targets = this._targetManager.targets(WebInspector.Target.Capability.JS);
|
| + var targets = this._targetManager.targets(SDK.Target.Capability.JS);
|
| var newContext = null;
|
| for (var i = 0; i < targets.length && !newContext; ++i) {
|
| var executionContexts = targets[i].runtimeModel.executionContexts();
|
| @@ -201,7 +201,7 @@ WebInspector.ExecutionContextSelector = class {
|
| }
|
| }
|
| this._ignoreContextChanged = true;
|
| - this._context.setFlavor(WebInspector.ExecutionContext, newContext);
|
| + this._context.setFlavor(SDK.ExecutionContext, newContext);
|
| this._ignoreContextChanged = false;
|
| }
|
| };
|
|
|