Commit 0256fbae authored by pfeldman's avatar pfeldman Committed by Commit bot

DevTools: remove UISourceCodeFrame from context when switching panels.

BUG=640375

Review-Url: https://codereview.chromium.org/2314503005
Cr-Commit-Position: refs/heads/master@{#417120}
parent 609dcc05
......@@ -453,7 +453,7 @@ Runtime.prototype = {
{
if (!predicate)
return false;
var contextTypes = /** @type {!Array.<string>|undefined} */ (extension.descriptor().contextTypes);
var contextTypes = extension.descriptor().contextTypes;
if (!contextTypes)
return true;
for (var i = 0; i < contextTypes.length; ++i) {
......@@ -921,6 +921,22 @@ Runtime.Extension.prototype = {
{
// FIXME: should be WebInspector.UIString() but runtime is not l10n aware yet.
return this._descriptor["title-" + Runtime._platform] || this._descriptor["title"];
},
/**
* @param {function(new:Object)} contextType
* @return {boolean}
*/
hasContextType: function(contextType)
{
var contextTypes = this.descriptor().contextTypes;
if (!contextTypes)
return false;
for (var i = 0; i < contextTypes.length; ++i) {
if (contextType === this._module._manager._resolve(contextTypes[i]))
return true;
}
return false;
}
}
......
......@@ -365,6 +365,13 @@ WebInspector.SourceFrame.prototype = {
this._resetCurrentSearchResultIndex();
},
/**
* @override
*/
editorBlurred: function()
{
},
_resetCurrentSearchResultIndex: function()
{
if (!this._searchResults.length)
......
......@@ -27,6 +27,7 @@ WebInspector.SourcesTextEditor = function(delegate)
this.codeMirror().on("gutterClick", this._gutterClick.bind(this));
this.codeMirror().on("scroll", this._scroll.bind(this));
this.codeMirror().on("focus", this._focus.bind(this));
this.codeMirror().on("blur", this._blur.bind(this));
this.codeMirror().on("beforeSelectionChange", this._beforeSelectionChangeForDelegate.bind(this));
this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false);
......@@ -432,6 +433,11 @@ WebInspector.SourcesTextEditor.prototype = {
this._delegate.editorFocused();
},
_blur: function()
{
this._delegate.editorBlurred();
},
/**
* @param {!CodeMirror} codeMirror
* @param {{ranges: !Array.<{head: !CodeMirror.Pos, anchor: !CodeMirror.Pos}>}} selection
......@@ -627,6 +633,8 @@ WebInspector.SourcesTextEditorDelegate.prototype = {
editorFocused: function() { },
editorBlurred: function() { },
/**
* @param {!WebInspector.ContextMenu} contextMenu
* @param {number} lineNumber
......
......@@ -215,7 +215,6 @@ WebInspector.TabbedEditorContainer.prototype = {
var previousView = this._currentView;
this._currentView = this.visibleView;
WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, this._currentView instanceof WebInspector.UISourceCodeFrame ? this._currentView : null);
this._addViewListeners();
var eventData = {
......@@ -255,8 +254,6 @@ WebInspector.TabbedEditorContainer.prototype = {
if (nextTabId)
this._tabbedPane.selectTab(nextTabId, true);
this._tabbedPane.closeTab(id, true);
if (WebInspector.context.flavor(WebInspector.UISourceCodeFrame) === previousView)
WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, null);
return true;
}
return false;
......
......@@ -91,11 +91,30 @@ WebInspector.UISourceCodeFrame.prototype = {
willHide: function()
{
WebInspector.SourceFrame.prototype.willHide.call(this);
WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, null);
this.element.ownerDocument.defaultView.removeEventListener("focus", this._boundWindowFocused, false);
delete this._boundWindowFocused;
this._uiSourceCode.removeWorkingCopyGetter();
},
/**
* @override
*/
editorFocused: function()
{
WebInspector.SourceFrame.prototype.editorFocused.call(this);
WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, this);
},
/**
* @override
*/
editorBlurred: function()
{
WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, null);
WebInspector.SourceFrame.prototype.editorBlurred.call(this);
},
/**
* @override
* @return {boolean}
......
......@@ -42,10 +42,10 @@ WebInspector.Context.prototype = {
*/
_dispatchFlavorChange: function(flavorType, flavorValue)
{
self.runtime.extensions(WebInspector.ContextFlavorListener, flavorValue).map(extension => {
extension.instance().then(instance => /** @type {!WebInspector.ContextFlavorListener} */ (instance).flavorChanged(flavorValue));
});
for (var extension of self.runtime.extensions(WebInspector.ContextFlavorListener)) {
if (extension.hasContextType(flavorType))
extension.instance().then(instance => /** @type {!WebInspector.ContextFlavorListener} */ (instance).flavorChanged(flavorValue));
}
var dispatcher = this._eventDispatchers.get(flavorType);
if (!dispatcher)
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment