Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js b/third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js |
| index 66afc6a1c2bbbb0eeaf860371cf6d23931ba59bd..3dc1adaa6d696ea4e0783957b6ab7f4ed65d964a 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js |
| @@ -61,6 +61,9 @@ WebInspector.TabbedEditorContainer = function(delegate, setting, placeholderText |
| this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabClosed, this._tabClosed, this); |
| this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected, this._tabSelected, this); |
| + WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.BindingCreated, this._onBindingCreated, this); |
| + WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.BindingRemoved, this._onBindingRemoved, this); |
| + |
| this._tabIds = new Map(); |
| this._files = {}; |
| @@ -80,6 +83,38 @@ WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; |
| WebInspector.TabbedEditorContainer.prototype = { |
| /** |
| + * @param {!WebInspector.Event} event |
| + */ |
| + _onBindingCreated: function(event) |
| + { |
| + var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data); |
| + var fileSystemTabId = this._tabIds.get(binding.fileSystem); |
| + if (!fileSystemTabId) |
| + return; |
| + |
| + var isSelected = this._currentFile === binding.fileSystem; |
| + var tabIndex = this._tabbedPane.tabIndex(fileSystemTabId); |
| + this._closeTabs([fileSystemTabId]); |
| + if (this._tabIds.has(binding.network)) |
| + return; |
|
dgozman
2016/09/23 23:03:21
select if isSelected
lushnikov
2016/09/24 00:30:50
Done.
|
| + var tabId = this._appendFileTab(binding.network, false, tabIndex); |
| + if (isSelected) |
| + this._tabbedPane.selectTab(tabId, false); |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.Event} event |
| + */ |
| + _onBindingRemoved: function(event) |
| + { |
| + var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data); |
| + var networkTabId = this._tabIds.get(binding.network); |
| + if (!networkTabId) |
| + return; |
| + this._appendFileTab(binding.fileSystem, false); |
| + }, |
| + |
| + /** |
| * @return {!WebInspector.Widget} |
| */ |
| get view() |
| @@ -215,6 +250,8 @@ WebInspector.TabbedEditorContainer.prototype = { |
| */ |
| _innerShowFile: function(uiSourceCode, userGesture) |
| { |
| + var binding = WebInspector.persistence.binding(uiSourceCode); |
| + uiSourceCode = binding ? binding.network : uiSourceCode; |
|
dgozman
2016/09/23 23:03:21
Let's add a test for this line.
lushnikov
2016/09/24 00:30:50
Done.
|
| if (this._currentFile === uiSourceCode) |
| return; |
| @@ -248,7 +285,7 @@ WebInspector.TabbedEditorContainer.prototype = { |
| { |
| var maxDisplayNameLength = 30; |
| var title = uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLength); |
| - if (uiSourceCode.isDirty() || uiSourceCode.hasUnsavedCommittedChanges()) |
| + if (uiSourceCode.isDirty() || WebInspector.persistence.hasUnsavedCommittedChanges(uiSourceCode)) |
| title += "*"; |
| return title; |
| }, |
| @@ -403,9 +440,10 @@ WebInspector.TabbedEditorContainer.prototype = { |
| /** |
| * @param {!WebInspector.UISourceCode} uiSourceCode |
| * @param {boolean=} userGesture |
| + * @param {number=} index |
| * @return {string} |
| */ |
| - _appendFileTab: function(uiSourceCode, userGesture) |
| + _appendFileTab: function(uiSourceCode, userGesture, index) |
| { |
| var view = this._delegate.viewForFile(uiSourceCode); |
| var sourceFrame = view instanceof WebInspector.SourceFrame ? /** @type {!WebInspector.SourceFrame} */ (view) : null; |
| @@ -423,7 +461,7 @@ WebInspector.TabbedEditorContainer.prototype = { |
| if (sourceFrame && savedScrollLineNumber) |
| sourceFrame.scrollToLine(savedScrollLineNumber); |
| - this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture); |
| + this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture, undefined, index); |
| this._updateFileTitle(uiSourceCode); |
| this._addUISourceCodeListeners(uiSourceCode); |
| @@ -496,7 +534,7 @@ WebInspector.TabbedEditorContainer.prototype = { |
| if (tabId) { |
| var title = this._titleForFile(uiSourceCode); |
| this._tabbedPane.changeTabTitle(tabId, title); |
| - if (uiSourceCode.hasUnsavedCommittedChanges()) |
| + if (WebInspector.persistence.hasUnsavedCommittedChanges(uiSourceCode)) |
| this._tabbedPane.setTabIcon(tabId, "warning-icon", WebInspector.UIString("Changes to this file were not saved to file system.")); |
| else |
| this._tabbedPane.setTabIcon(tabId, ""); |