From bd2886174cfbea513c0f3bf89342dfffff362109 Mon Sep 17 00:00:00 2001 From: "vsevik@chromium.org" Date: Thu, 26 Jan 2012 18:45:10 +0000 Subject: [PATCH] Web Inspector: Scripts panel editor container should be based on UISourceCode objects, not SourceFrames. https://bugs.webkit.org/show_bug.cgi?id=77098 Reviewed by Pavel Feldman. * inspector/front-end/ScriptsNavigator.js: * inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype.setScriptSourceIsBeingEdited): (WebInspector.ScriptsPanel.prototype.get visibleView): (WebInspector.ScriptsPanel.prototype.viewForFile): (WebInspector.ScriptsPanel.prototype._uiSourceCodeReplaced): (WebInspector.EditorContainer): (WebInspector.EditorContainer.prototype.get visibleView): (WebInspector.EditorContainer.prototype.showFile): (WebInspector.EditorContainer.prototype.setFileIsDirty): (WebInspector.EditorContainer.prototype.replaceFiles): (WebInspector.EditorContainer.prototype.reset): (WebInspector.EditorContainerDelegate): (WebInspector.EditorContainerDelegate.prototype.viewForFile): (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype.replaceUISourceCodes): (WebInspector.ScriptsPanel.SingleFileEditorContainer): (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.get visibleView): (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.showFile): (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.setFileIsDirty): (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.replaceFiles): (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.reset): * inspector/front-end/TabbedEditorContainer.js: (WebInspector.TabbedEditorContainer): (WebInspector.TabbedEditorContainer.prototype.get visibleView): (WebInspector.TabbedEditorContainer.prototype._titleForFile): (WebInspector.TabbedEditorContainer.prototype._tooltipForFile): (WebInspector.TabbedEditorContainer.prototype._appendFileTab): (WebInspector.TabbedEditorContainer.prototype._tabClosed): (WebInspector.TabbedEditorContainer.prototype._tabSelected): (WebInspector.TabbedEditorContainer.prototype.replaceFiles.get if): (WebInspector.TabbedEditorContainer.prototype.replaceFiles): (WebInspector.TabbedEditorContainer.prototype.setFileIsDirty.get if): (WebInspector.TabbedEditorContainer.prototype.setFileIsDirty): (WebInspector.TabbedEditorContainer.prototype.reset): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106011 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 42 +++++ .../inspector/front-end/ScriptsNavigator.js | 19 +- Source/WebCore/inspector/front-end/ScriptsPanel.js | 195 ++++++++++----------- .../inspector/front-end/TabbedEditorContainer.js | 158 +++++++++-------- 4 files changed, 228 insertions(+), 186 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 17fa621..bb72ccd 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,45 @@ +2012-01-26 Vsevolod Vlasov + + Web Inspector: Scripts panel editor container should be based on UISourceCode objects, not SourceFrames. + https://bugs.webkit.org/show_bug.cgi?id=77098 + + Reviewed by Pavel Feldman. + + * inspector/front-end/ScriptsNavigator.js: + * inspector/front-end/ScriptsPanel.js: + (WebInspector.ScriptsPanel.prototype.setScriptSourceIsBeingEdited): + (WebInspector.ScriptsPanel.prototype.get visibleView): + (WebInspector.ScriptsPanel.prototype.viewForFile): + (WebInspector.ScriptsPanel.prototype._uiSourceCodeReplaced): + (WebInspector.EditorContainer): + (WebInspector.EditorContainer.prototype.get visibleView): + (WebInspector.EditorContainer.prototype.showFile): + (WebInspector.EditorContainer.prototype.setFileIsDirty): + (WebInspector.EditorContainer.prototype.replaceFiles): + (WebInspector.EditorContainer.prototype.reset): + (WebInspector.EditorContainerDelegate): + (WebInspector.EditorContainerDelegate.prototype.viewForFile): + (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype.replaceUISourceCodes): + (WebInspector.ScriptsPanel.SingleFileEditorContainer): + (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.get visibleView): + (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.showFile): + (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.setFileIsDirty): + (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.replaceFiles): + (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.reset): + * inspector/front-end/TabbedEditorContainer.js: + (WebInspector.TabbedEditorContainer): + (WebInspector.TabbedEditorContainer.prototype.get visibleView): + (WebInspector.TabbedEditorContainer.prototype._titleForFile): + (WebInspector.TabbedEditorContainer.prototype._tooltipForFile): + (WebInspector.TabbedEditorContainer.prototype._appendFileTab): + (WebInspector.TabbedEditorContainer.prototype._tabClosed): + (WebInspector.TabbedEditorContainer.prototype._tabSelected): + (WebInspector.TabbedEditorContainer.prototype.replaceFiles.get if): + (WebInspector.TabbedEditorContainer.prototype.replaceFiles): + (WebInspector.TabbedEditorContainer.prototype.setFileIsDirty.get if): + (WebInspector.TabbedEditorContainer.prototype.setFileIsDirty): + (WebInspector.TabbedEditorContainer.prototype.reset): + 2012-01-26 Nikolas Zimmermann SVG + tests are flakey diff --git a/Source/WebCore/inspector/front-end/ScriptsNavigator.js b/Source/WebCore/inspector/front-end/ScriptsNavigator.js index 09b9f73..33e10c3 100644 --- a/Source/WebCore/inspector/front-end/ScriptsNavigator.js +++ b/Source/WebCore/inspector/front-end/ScriptsNavigator.js @@ -146,16 +146,21 @@ WebInspector.ScriptsNavigator.prototype = { */ replaceUISourceCodes: function(oldUISourceCodeList, uiSourceCodeList) { + var added = false; var selected = false; for (var i = 0; i < oldUISourceCodeList.length; ++i) { var uiSourceCode = oldUISourceCodeList[i]; - var treeElement = this._scriptTreeElementsByUISourceCode.get(uiSourceCode); - if (treeElement) { - if (this._lastSelectedUISourceCode && this._lastSelectedUISourceCode === uiSourceCode) - selected = true; - this.removeUISourceCode(uiSourceCode); - } + if (!this._scriptTreeElementsByUISourceCode.get(uiSourceCode)) + continue; + added = true; + + if (this._lastSelectedUISourceCode === uiSourceCode) + selected = true; + this._removeUISourceCode(uiSourceCode); } + + if (!added) + return; for (var i = 0; i < uiSourceCodeList.length; ++i) this.addUISourceCode(uiSourceCodeList[i]); @@ -176,7 +181,7 @@ WebInspector.ScriptsNavigator.prototype = { /** * @param {WebInspector.UISourceCode} uiSourceCode */ - removeUISourceCode: function(uiSourceCode) + _removeUISourceCode: function(uiSourceCode) { var treeElement = this._scriptTreeElementsByUISourceCode.get(uiSourceCode); while (treeElement) { diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js index fcd02b0..cadc2e9 100644 --- a/Source/WebCore/inspector/front-end/ScriptsPanel.js +++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js @@ -26,6 +26,7 @@ /** * @constructor + * @implements {WebInspector.EditorContainerDelegate} * @extends {WebInspector.Panel} */ WebInspector.ScriptsPanel = function(presentationModel) @@ -77,20 +78,20 @@ WebInspector.ScriptsPanel = function(presentationModel) this.editorView.installResizer(this._navigatorResizeWidgetElement); this.editorView.sidebarElement.appendChild(this._navigatorResizeWidgetElement); - this._editorContainer = new WebInspector.TabbedEditorContainer(); + this._editorContainer = new WebInspector.TabbedEditorContainer(this); this._editorContainer.show(this.editorView.mainElement); WebInspector.OpenResourceDialog.install(this, this._presentationModel, this.editorView.mainElement); } else { this._fileSelector = new WebInspector.ScriptsPanel.ComboBoxFileSelector(this._presentationModel); this._fileSelector.show(this.splitView.mainElement); - this._editorContainer = new WebInspector.ScriptsPanel.SingleFileEditorContainer(); + this._editorContainer = new WebInspector.ScriptsPanel.SingleFileEditorContainer(this); this._editorContainer.show(this.splitView.mainElement); WebInspector.OpenResourceDialog.install(this, this._presentationModel, this.splitView.mainElement); } this._fileSelector.addEventListener(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, this._fileSelected, this); this._fileSelector.addEventListener(WebInspector.ScriptsPanel.FileSelector.Events.ReleasedFocusAfterSelection, this._fileSelectorReleasedFocus, this); - this._editorContainer.addEventListener(WebInspector.ScriptsPanel.EditorContainer.Events.EditorSelected, this._editorSelected, this); + this._editorContainer.addEventListener(WebInspector.EditorContainer.Events.EditorSelected, this._editorSelected, this); this.splitView.mainElement.appendChild(this.debugSidebarResizeWidgetElement); @@ -282,9 +283,7 @@ WebInspector.ScriptsPanel.prototype = { setScriptSourceIsBeingEdited: function(uiSourceCode, inEditMode) { this._fileSelector.setScriptSourceIsDirty(uiSourceCode, inEditMode); - var sourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode) - if (sourceFrame) - this._editorContainer.setSourceFrameIsDirty(sourceFrame, inEditMode); + this._editorContainer.setFileIsDirty(uiSourceCode, inEditMode); }, _consoleMessagesCleared: function() @@ -429,7 +428,7 @@ WebInspector.ScriptsPanel.prototype = { get visibleView() { - return this._editorContainer.currentSourceFrame; + return this._editorContainer.visibleView; }, _updateScriptViewStatusBarItems: function() @@ -484,9 +483,9 @@ WebInspector.ScriptsPanel.prototype = { */ _showFile: function(uiSourceCode) { - var sourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode) || this._createSourceFrame(uiSourceCode); + var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode); - this._editorContainer.showSourceFrame(uiSourceCode.displayName, sourceFrame, uiSourceCode.url); + this._editorContainer.showFile(uiSourceCode); this._updateScriptViewStatusBarItems(); if (uiSourceCode.url) @@ -526,6 +525,7 @@ WebInspector.ScriptsPanel.prototype = { /** * @param {WebInspector.UISourceCode} uiSourceCode + * @return {WebInspector.SourceFrame} */ _createSourceFrame: function(uiSourceCode) { @@ -536,6 +536,24 @@ WebInspector.ScriptsPanel.prototype = { this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame); return sourceFrame; }, + + /** + * @param {WebInspector.UISourceCode} uiSourceCode + * @return {WebInspector.SourceFrame} + */ + _getOrCreateSourceFrame: function(uiSourceCode) + { + return this._sourceFramesByUISourceCode.get(uiSourceCode) || this._createSourceFrame(uiSourceCode); + }, + + /** + * @param {WebInspector.UISourceCode} uiSourceCode + * @return {WebInspector.SourceFrame} + */ + viewForFile: function(uiSourceCode) + { + return this._getOrCreateSourceFrame(uiSourceCode); + }, /** * @param {WebInspector.UISourceCode} uiSourceCode @@ -558,38 +576,10 @@ WebInspector.ScriptsPanel.prototype = { var oldUISourceCodeList = /** @type {Array.} */ event.data.oldUISourceCodeList; var uiSourceCodeList = /** @type {Array.} */ event.data.uiSourceCodeList; - var addedToFileSelector = false; - var sourceFrames = []; - for (var i = 0; i < oldUISourceCodeList.length; ++i) { - var uiSourceCode = oldUISourceCodeList[i]; - var oldSourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode); - - if (this._fileSelector.isScriptSourceAdded(uiSourceCode)) { - addedToFileSelector = true; - - if (oldSourceFrame) - sourceFrames.push(oldSourceFrame); - this._removeSourceFrame(uiSourceCode); - } - } - - if (addedToFileSelector) { - this._fileSelector.replaceUISourceCodes(oldUISourceCodeList, uiSourceCodeList); - - var shouldReplace = false; - for (var i = 0; i < sourceFrames.length; ++i) { - if (this._editorContainer.isSourceFrameOpen(sourceFrames[i])) { - shouldReplace = true; - break; - } - } - - if (shouldReplace) { - var newUISourceCode = uiSourceCodeList[0]; - var sourceFrame = this._sourceFramesByUISourceCode.get(newUISourceCode) || this._createSourceFrame(newUISourceCode); - this._editorContainer.replaceSourceFrames(sourceFrames, newUISourceCode.displayName, sourceFrame, newUISourceCode.url); - } - } + this._fileSelector.replaceUISourceCodes(oldUISourceCodeList, uiSourceCodeList); + this._editorContainer.replaceFiles(oldUISourceCodeList, uiSourceCodeList); + for (var i = 0; i < oldUISourceCodeList.length; ++i) + this._removeSourceFrame(oldUISourceCodeList[i]); }, _sourceFrameLoaded: function(event) @@ -658,8 +648,8 @@ WebInspector.ScriptsPanel.prototype = { _editorSelected: function(event) { - var sourceFrame = /** @type {WebInspector.SourceFrame} */ event.data; - this._fileSelector.revealUISourceCode(sourceFrame._uiSourceCode); + var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data; + this._fileSelector.revealUISourceCode(uiSourceCode); }, _fileSelected: function(event) @@ -1086,17 +1076,17 @@ WebInspector.ScriptsPanel.FileSelector.prototype = { /** * @interface */ -WebInspector.ScriptsPanel.EditorContainer = function() { } +WebInspector.EditorContainer = function() { } -WebInspector.ScriptsPanel.EditorContainer.Events = { +WebInspector.EditorContainer.Events = { EditorSelected: "EditorSelected" } -WebInspector.ScriptsPanel.EditorContainer.prototype = { +WebInspector.EditorContainer.prototype = { /** * @type {WebInspector.SourceFrame} */ - get currentSourceFrame() { }, + get visibleView() { }, /** * @param {Element} element @@ -1104,33 +1094,36 @@ WebInspector.ScriptsPanel.EditorContainer.prototype = { show: function(element) { }, /** - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {WebInspector.UISourceCode} uiSourceCode */ - showSourceFrame: function(title, sourceFrame, tooltip) { }, + showFile: function(uiSourceCode) { }, /** - * @param {WebInspector.SourceFrame} sourceFrame - * @return {boolean} + * @param {WebInspector.UISourceCode} uiSourceCode + * @param {boolean} isDirty */ - isSourceFrameOpen: function(sourceFrame) { return false; }, + setFileIsDirty: function(uiSourceCode, isDirty) { }, /** - * @param {Array.} oldSourceFrames - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {Array.} oldUISourceCodeList + * @param {Array.} uiSourceCodeList */ - replaceSourceFrames: function(oldSourceFrames, title, sourceFrame, tooltip) { }, + replaceFiles: function(oldUISourceCodeList, uiSourceCodeList) { }, + + reset: function() { } +} + +/** + * @interface + */ +WebInspector.EditorContainerDelegate = function() { } +WebInspector.EditorContainerDelegate.prototype = { /** - * @param {WebInspector.SourceFrame} sourceFrame - * @param {boolean} isDirty + * @param {WebInspector.UISourceCode} uiSourceCode + * @return {WebInspector.SourceFrame} */ - setSourceFrameIsDirty: function(sourceFrame, isDirty) { }, - - reset: function() { } + viewForFile: function(uiSourceCode) { } } /** @@ -1235,23 +1228,32 @@ WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype = { */ replaceUISourceCodes: function(oldUISourceCodeList, uiSourceCodeList) { - var visible = false; + var selected = false; + var added = false; var selectedOption = this._filesSelectElement[this._filesSelectElement.selectedIndex]; var selectedUISourceCode = selectedOption ? selectedOption._uiSourceCode : null; for (var i = 0; i < oldUISourceCodeList.length; ++i) { var uiSourceCode = oldUISourceCodeList[i]; - if (selectedUISourceCode === oldUISourceCodeList[i]) - visible = true; var option = uiSourceCode._option; + if (!option) + continue; + added = true; + // FIXME: find out why we are getting here with option detached. - if (option && this._filesSelectElement === option.parentElement) + if (this._filesSelectElement === option.parentElement) this._filesSelectElement.removeChild(option); + + if (selectedUISourceCode === oldUISourceCodeList[i]) + selected = true; } + if (!added) + return; + for (var i = 0; i < uiSourceCodeList.length; ++i) this._addOptionToFilesSelect(uiSourceCodeList[i]); - if (visible) + if (selected) this._filesSelectElement.selectedIndex = uiSourceCodeList[0]._option.index; }, @@ -1348,7 +1350,6 @@ WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype = { select.folderOptions = {}; var option = document.createElement("option"); - option._uiSourceCode = uiSourceCode; var parsedURL = uiSourceCode.url.asParsedURL(); const indent = WebInspector.isMac() ? "" : "\u00a0\u00a0\u00a0\u00a0"; @@ -1482,12 +1483,14 @@ WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype = { WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype.__proto__ = WebInspector.Object.prototype; /** - * @implements {WebInspector.ScriptsPanel.EditorContainer} + * @implements {WebInspector.EditorContainer} * @extends {WebInspector.Object} * @constructor + * @param {WebInspector.EditorContainerDelegate} delegate */ -WebInspector.ScriptsPanel.SingleFileEditorContainer = function() +WebInspector.ScriptsPanel.SingleFileEditorContainer = function(delegate) { + this._delegate = delegate; this.element = document.createElement("div"); this.element.className = "scripts-views-container"; } @@ -1496,7 +1499,7 @@ WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype = { /** * @type {WebInspector.SourceFrame} */ - get currentSourceFrame() + get visibleView() { return this._currentSourceFrame; }, @@ -1508,14 +1511,13 @@ WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype = { { element.appendChild(this.element); }, - + /** - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {WebInspector.UISourceCode} uiSourceCode */ - showSourceFrame: function(title, sourceFrame, tooltip) + showFile: function(uiSourceCode) { + var sourceFrame = this._delegate.viewForFile(uiSourceCode); if (this._currentSourceFrame === sourceFrame) return; @@ -1523,48 +1525,37 @@ WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype = { this._currentSourceFrame.detach(); this._currentSourceFrame = sourceFrame; + this._currentFile = uiSourceCode; if (sourceFrame) sourceFrame.show(this.element); }, /** - * @param {WebInspector.SourceFrame} sourceFrame - * @return {boolean} - */ - isSourceFrameOpen: function(sourceFrame) - { - return this._currentSourceFrame && this._currentSourceFrame === sourceFrame; - }, - - /** - * @param {Array.} oldSourceFrames - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {WebInspector.UISourceCode} uiSourceCode + * @param {boolean} isDirty */ - replaceSourceFrames: function(oldSourceFrames, title, sourceFrame, tooltip) + setFileIsDirty: function(uiSourceCode, isDirty) { - this._currentSourceFrame.detach(); - this._currentSourceFrame = null; - this.showSourceFrame(title, sourceFrame, tooltip); + // Do nothing. }, /** - * @param {WebInspector.SourceFrame} sourceFrame - * @param {boolean} isDirty + * @param {Array.} oldUISourceCodeList + * @param {Array.} uiSourceCodeList */ - setSourceFrameIsDirty: function(sourceFrame, isDirty) + replaceFiles: function(oldUISourceCodeList, uiSourceCodeList) { - // Do nothing. + if (oldUISourceCodeList.indexOf(this._currentFile) !== -1) + this.showFile(uiSourceCodeList[0]); }, reset: function() { - if (this._currentSourceFrame) { + if (this._currentSourceFrame) this._currentSourceFrame.detach(); - this._currentSourceFrame = null; - } + this._currentSourceFrame = null; + this._currentFile = null; } } diff --git a/Source/WebCore/inspector/front-end/TabbedEditorContainer.js b/Source/WebCore/inspector/front-end/TabbedEditorContainer.js index dbcf773..f1f73d1 100644 --- a/Source/WebCore/inspector/front-end/TabbedEditorContainer.js +++ b/Source/WebCore/inspector/front-end/TabbedEditorContainer.js @@ -27,12 +27,15 @@ */ /** - * @implements {WebInspector.ScriptsPanel.EditorContainer} + * @implements {WebInspector.EditorContainer} * @extends {WebInspector.Object} * @constructor + * @param {WebInspector.EditorContainerDelegate} delegate */ -WebInspector.TabbedEditorContainer = function() +WebInspector.TabbedEditorContainer = function(delegate) { + this._delegate = delegate; + this._tabbedPane = new WebInspector.TabbedPane(); this._tabbedPane.closeableTabs = true; this._tabbedPane.element.id = "scripts-editor-container-tabbed-pane"; @@ -40,9 +43,8 @@ WebInspector.TabbedEditorContainer = function() this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabClosed, this._tabClosed, this); this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this); - this._titles = new Map(); - this._tooltips = new Map(); this._tabIds = new Map(); + this._files = {}; } WebInspector.TabbedEditorContainer._tabId = 0; @@ -51,7 +53,7 @@ WebInspector.TabbedEditorContainer.prototype = { /** * @type {WebInspector.SourceFrame} */ - get currentSourceFrame() + get visibleView() { return this._tabbedPane.visibleView; }, @@ -65,38 +67,55 @@ WebInspector.TabbedEditorContainer.prototype = { }, /** - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {WebInspector.UISourceCode} uiSourceCode */ - showSourceFrame: function(title, sourceFrame, tooltip) + showFile: function(uiSourceCode) { - var tabId = this._tabIds.get(sourceFrame) || this._appendSourceFrameTab(title, sourceFrame, tooltip); + var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCode); this._tabbedPane.selectTab(tabId); }, /** - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {WebInspector.UISourceCode} uiSourceCode + * @return {string} + */ + _titleForFile: function(uiSourceCode) + { + return uiSourceCode.displayName; + }, + + /** + * @param {WebInspector.UISourceCode} uiSourceCode + * @return {string} */ - _appendSourceFrameTab: function(title, sourceFrame, tooltip) + _tooltipForFile: function(uiSourceCode) { + return uiSourceCode.url; + }, + + /** + * @param {WebInspector.UISourceCode} uiSourceCode + */ + _appendFileTab: function(uiSourceCode) + { + var view = this._delegate.viewForFile(uiSourceCode); + var title = this._titleForFile(uiSourceCode); + var tooltip = this._tooltipForFile(uiSourceCode); + var tabId = this._generateTabId(); - this._tabIds.put(sourceFrame, tabId) - this._titles.put(sourceFrame, title) - this._tooltips.put(sourceFrame, tooltip) + this._tabIds.put(uiSourceCode, tabId); + this._files[tabId] = uiSourceCode; - this._tabbedPane.appendTab(tabId, title, sourceFrame, tooltip); + this._tabbedPane.appendTab(tabId, title, view, tooltip); return tabId; }, /** - * @param {WebInspector.SourceFrame} sourceFrame + * @param {WebInspector.UISourceCode} uiSourceCode */ - _removeSourceFrameTab: function(sourceFrame) + _removeFileTab: function(uiSourceCode) { - var tabId = this._tabIds.get(sourceFrame); + var tabId = this._tabIds.get(uiSourceCode); if (tabId) this._tabbedPane.closeTab(tabId); @@ -107,10 +126,9 @@ WebInspector.TabbedEditorContainer.prototype = { */ _tabClosed: function(event) { - var sourceFrame = /** @type {WebInspector.UISourceCode} */ event.data.view; - this._tabIds.remove(sourceFrame); - this._titles.remove(sourceFrame); - this._tooltips.remove(sourceFrame); + var tabId = /** @type {string} */ event.data.tabId; + this._tabIds.remove(this._files[tabId]); + delete this._files[tabId]; }, /** @@ -118,77 +136,63 @@ WebInspector.TabbedEditorContainer.prototype = { */ _tabSelected: function(event) { - var sourceFrame = /** @type {WebInspector.UISourceCode} */ event.data.view; - this.dispatchEventToListeners(WebInspector.ScriptsPanel.EditorContainer.Events.EditorSelected, sourceFrame); + var tabId = /** @type {string} */ event.data.tabId; + this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorSelected, this._files[tabId]); }, /** - * @param {WebInspector.SourceFrame} oldSourceFrame - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {WebInspector.UISourceCode} oldUISourceCode + * @param {WebInspector.UISourceCode} newUISourceCode */ - _replaceSourceFrameTab: function(oldSourceFrame, title, sourceFrame, tooltip) + _replaceFileTab: function(oldUISourceCode, newUISourceCode) { - var tabId = this._tabIds.get(oldSourceFrame); + var tabId = this._tabIds.get(oldUISourceCode); - if (tabId) { - this._tabIds.remove(oldSourceFrame); - this._titles.remove(oldSourceFrame); - this._tooltips.remove(oldSourceFrame); - - this._tabIds.put(sourceFrame, tabId); - this._titles.put(sourceFrame, title); - this._tooltips.put(sourceFrame, tooltip); - - this._tabbedPane.changeTabTitle(tabId, title); - this._tabbedPane.changeTabView(tabId, sourceFrame); - this._tabbedPane.changeTabTooltip(tabId, tooltip); - } - }, - - /** - * @param {WebInspector.SourceFrame} sourceFrame - * @return {boolean} - */ - isSourceFrameOpen: function(sourceFrame) - { - return !!this._tabIds.get(sourceFrame); + if (!tabId) + return; + + delete this._files[this._tabIds.get(oldUISourceCode)] + this._tabIds.remove(oldUISourceCode); + this._tabIds.put(newUISourceCode, tabId); + this._files[tabId] = newUISourceCode; + + this._tabbedPane.changeTabTitle(tabId, this._titleForFile(newUISourceCode)); + this._tabbedPane.changeTabView(tabId, this._delegate.viewForFile(newUISourceCode)); + this._tabbedPane.changeTabTooltip(tabId, this._tooltipForFile(newUISourceCode)); }, /** - * @param {Array.} oldSourceFrames - * @param {string} title - * @param {WebInspector.SourceFrame} sourceFrame - * @param {string} tooltip + * @param {Array.} oldUISourceCodeList + * @param {Array.} uiSourceCodeList */ - replaceSourceFrames: function(oldSourceFrames, title, sourceFrame, tooltip) + replaceFiles: function(oldUISourceCodeList, uiSourceCodeList) { - var mainSourceFrame; - for (var i = 0; i < oldSourceFrames.length; ++i) { - var tabId = this._tabIds.get(oldSourceFrames[i]); - if (tabId && (!mainSourceFrame || this._tabbedPane.selectedTabId === tabId)) { - mainSourceFrame = oldSourceFrames[i]; + var mainFile; + for (var i = 0; i < oldUISourceCodeList.length; ++i) { + var tabId = this._tabIds.get(oldUISourceCodeList[i]); + if (tabId && (!mainFile || this._tabbedPane.selectedTabId === tabId)) { + mainFile = oldUISourceCodeList[i]; break; } } - if (mainSourceFrame) - this._replaceSourceFrameTab(mainSourceFrame, title, sourceFrame, tooltip); + if (!mainFile) + return; - for (var i = 0; i < oldSourceFrames.length; ++i) - this._removeSourceFrameTab(oldSourceFrames[i]); + this._replaceFileTab(mainFile, uiSourceCodeList[0]); + for (var i = 0; i < oldUISourceCodeList.length; ++i) + this._removeFileTab(oldUISourceCodeList[i]); }, - + /** - * @param {WebInspector.SourceFrame} sourceFrame + * @param {WebInspector.UISourceCode} uiSourceCode * @param {boolean} isDirty */ - setSourceFrameIsDirty: function(sourceFrame, isDirty) + setFileIsDirty: function(uiSourceCode, isDirty) { - var tabId = this._tabIds.get(sourceFrame); + var tabId = this._tabIds.get(uiSourceCode); if (tabId) { - var title = this._titles.get(sourceFrame); + var title = this._titleForFile(uiSourceCode); if (isDirty) title += "*"; this._tabbedPane.changeTabTitle(tabId, title); @@ -198,9 +202,9 @@ WebInspector.TabbedEditorContainer.prototype = { reset: function() { this._tabbedPane.closeAllTabs(); - this._titles = new Map(); - this._tooltips = new Map(); - this._tabIds = new Map(); + this._tabIds = new Map(); + this._files = {}; + }, /** -- 2.7.4