Changeset 106238 in webkit
- Timestamp:
- Jan 30, 2012 5:10:24 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r106237 r106238 1 2012-01-27 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: TabbedEditorContainer should save open tabs. 4 https://bugs.webkit.org/show_bug.cgi?id=76912 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/tabbed-editors-history-expected.txt: Added. 9 * inspector/tabbed-editors-history.html: Added. 10 1 11 2012-01-30 Alexander Pavlov <apavlov@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r106237 r106238 1 2012-01-27 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: TabbedEditorContainer should save open tabs. 4 https://bugs.webkit.org/show_bug.cgi?id=76912 5 6 Reviewed by Pavel Feldman. 7 8 Test: inspector/tabbed-editors-history.html 9 10 * inspector/front-end/ScriptsPanel.js: 11 (WebInspector.ScriptsPanel.prototype._uiSourceCodeAdded): 12 (WebInspector.ScriptsPanel.prototype._reset): 13 (WebInspector.ScriptsPanel.prototype._showFile): 14 (WebInspector.ScriptsPanel.prototype._updateExecutionLine): 15 (WebInspector.ScriptsPanel.prototype._editorSelected): 16 (WebInspector.EditorContainer.prototype.uiSourceCodeAdded): 17 (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.showFile): 18 (WebInspector.ScriptsPanel.SingleFileEditorContainer.prototype.reset): 19 * inspector/front-end/TabbedEditorContainer.js: 20 (WebInspector.TabbedEditorContainer): 21 (WebInspector.TabbedEditorContainer.prototype.showFile): 22 (WebInspector.TabbedEditorContainer.prototype._editorClosedByUserAction): 23 (WebInspector.TabbedEditorContainer.prototype._editorSelectedByUserAction): 24 (WebInspector.TabbedEditorContainer.prototype._updateHistory.tabIdToURL): 25 (WebInspector.TabbedEditorContainer.prototype._updateHistory): 26 (WebInspector.TabbedEditorContainer.prototype._appendFileTab): 27 (WebInspector.TabbedEditorContainer.prototype._tabClosed): 28 (WebInspector.TabbedEditorContainer.prototype._tabSelected): 29 (WebInspector.TabbedEditorContainer.prototype.reset): 30 (WebInspector.TabbedEditorContainer.History): 31 (WebInspector.TabbedEditorContainer.History.prototype.index): 32 (WebInspector.TabbedEditorContainer.History.prototype.update): 33 (WebInspector.TabbedEditorContainer.History.prototype.remove): 34 (WebInspector.TabbedEditorContainer.History.prototype.save): 35 * inspector/front-end/TabbedPane.js: 36 (WebInspector.TabbedPane.prototype.appendTab): 37 (WebInspector.TabbedPane.prototype.closeTab): 38 (WebInspector.TabbedPane.prototype._innerCloseTab): 39 (WebInspector.TabbedPane.prototype.closeAllTabs): 40 (WebInspector.TabbedPane.prototype.lastOpenedTabIds): 41 (WebInspector.TabbedPane.prototype._tabsSelectChanged): 42 1 43 2012-01-30 Alexander Pavlov <apavlov@chromium.org> 2 44 -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r106236 r106238 257 257 } 258 258 this._fileSelector.addUISourceCode(uiSourceCode); 259 260 var lastViewedURL = WebInspector.settings.lastViewedScriptFile.get(); 261 if (!this._initialViewSelectionProcessed) { 262 this._initialViewSelectionProcessed = true; 263 // Option we just added is the only option in files select. 264 // We have to show corresponding source frame immediately. 265 this._showFile(uiSourceCode); 266 // Restore original value of lastViewedScriptFile because 267 // source frame was shown as a result of initial load. 268 WebInspector.settings.lastViewedScriptFile.set(lastViewedURL); 269 } else if (uiSourceCode.url === lastViewedURL) 270 this._showFile(uiSourceCode); 259 this._editorContainer.uiSourceCodeAdded(uiSourceCode); 271 260 }, 272 261 … … 416 405 this._debuggerResumed(); 417 406 418 delete this._initialViewSelectionProcessed;419 407 delete this._curentUISourceCode; 420 421 408 this._editorContainer.reset(); 422 409 this._updateScriptViewStatusBarItems(); … … 487 474 if (!this._fileSelector.isScriptSourceAdded(uiSourceCode)) 488 475 return null; 489 476 490 477 var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode); 491 478 if (this._curentUISourceCode === uiSourceCode) … … 496 483 this._editorContainer.showFile(uiSourceCode); 497 484 this._updateScriptViewStatusBarItems(); 498 499 if (uiSourceCode.url)500 WebInspector.settings.lastViewedScriptFile.set(uiSourceCode.url);501 485 502 486 return sourceFrame; … … 618 602 // Anonymous scripts are not added to files select by default. 619 603 this._fileSelector.addUISourceCode(uiLocation.uiSourceCode); 620 604 621 605 var sourceFrame = this._showFile(uiLocation.uiSourceCode); 622 606 sourceFrame.setExecutionLine(uiLocation.lineNumber); … … 1111 1095 */ 1112 1096 setFileIsDirty: function(uiSourceCode, isDirty) { }, 1097 1098 /** 1099 * @param {WebInspector.UISourceCode} uiSourceCode 1100 */ 1101 uiSourceCodeAdded: function(uiSourceCode) { }, 1113 1102 1114 1103 /** … … 1530 1519 return; 1531 1520 1521 this._innerShowFile(uiSourceCode, true); 1522 }, 1523 1524 /** 1525 * @param {WebInspector.UISourceCode} uiSourceCode 1526 * @param {boolean} userGesture 1527 */ 1528 _innerShowFile: function(uiSourceCode, userGesture) 1529 { 1532 1530 if (this._currentSourceFrame) 1533 1531 this._currentSourceFrame.detach(); 1534 1532 1533 this._initialViewSelectionProcessed = true; 1534 1535 var sourceFrame = this._delegate.viewForFile(uiSourceCode); 1535 1536 this._currentSourceFrame = sourceFrame; 1536 1537 this._currentFile = uiSourceCode; 1538 1539 if (userGesture) { 1540 this._userSelectedFiles = true; 1541 WebInspector.settings.lastViewedScriptFile.set(uiSourceCode.url); 1542 } 1537 1543 1538 1544 if (sourceFrame) 1539 1545 sourceFrame.show(this.element); 1546 this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorSelected, uiSourceCode); 1547 }, 1548 1549 /** 1550 * @param {WebInspector.UISourceCode} uiSourceCode 1551 */ 1552 uiSourceCodeAdded: function(uiSourceCode) 1553 { 1554 var lastViewedURL = WebInspector.settings.lastViewedScriptFile.get(); 1555 // Show first file that was added or file with the last viewed url. 1556 if (this._userSelectedFiles) 1557 return; 1558 if (uiSourceCode.url === lastViewedURL || !this._initialViewSelectionProcessed) 1559 this._innerShowFile(uiSourceCode, false); 1540 1560 }, 1541 1561 … … 1565 1585 this._currentSourceFrame = null; 1566 1586 this._currentFile = null; 1587 delete this._initialViewSelectionProcessed; 1588 delete this._userSelectedFiles; 1567 1589 } 1568 1590 } -
trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js
r106112 r106238 44 44 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this); 45 45 46 this._tabIds = new Map(); 46 this._tabIds = new Map(); 47 47 this._files = {}; 48 this._loadedURLs = {}; 49 50 this._previouslyViewedFilesSetting = WebInspector.settings.createSetting("previouslyViewedFiles", []); 51 this._history = new WebInspector.TabbedEditorContainer.History(this._previouslyViewedFilesSetting.get()); 48 52 } 49 53 50 54 WebInspector.TabbedEditorContainer._tabId = 0; 51 55 56 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; 57 52 58 WebInspector.TabbedEditorContainer.prototype = { 53 59 /** … … 72 78 showFile: function(uiSourceCode) 73 79 { 80 this._innerShowFile(uiSourceCode, true); 81 }, 82 83 /** 84 * @param {WebInspector.UISourceCode} uiSourceCode 85 * @param {boolean=} userGesture 86 */ 87 _innerShowFile: function(uiSourceCode, userGesture) 88 { 74 89 if (this._currentFile === uiSourceCode) 75 90 return; 76 77 91 this._currentFile = uiSourceCode; 78 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCode); 79 this._tabbedPane.selectTab(tabId); 92 93 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCode, userGesture); 94 95 this._tabbedPane.selectTab(tabId, userGesture); 96 if (userGesture) 97 this._editorSelectedByUserAction(); 98 99 this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorSelected, this._currentFile); 80 100 }, 81 101 … … 91 111 /** 92 112 * @param {WebInspector.UISourceCode} uiSourceCode 113 */ 114 uiSourceCodeAdded: function(uiSourceCode) 115 { 116 if (this._userSelectedFiles || this._loadedURLs[uiSourceCode.url]) 117 return; 118 this._loadedURLs[uiSourceCode.url] = true; 119 120 var index = this._history.index(uiSourceCode.url) 121 if (index === -1) 122 return; 123 124 var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCode, false); 125 126 // Select tab if this file was the last to be shown. 127 if (index === 0) 128 this._innerShowFile(uiSourceCode, false); 129 }, 130 131 /** 132 * @param {WebInspector.UISourceCode} uiSourceCode 133 */ 134 _editorClosedByUserAction: function(uiSourceCode) 135 { 136 this._userSelectedFiles = true; 137 this._history.remove(uiSourceCode.url); 138 this._updateHistory(); 139 }, 140 141 _editorSelectedByUserAction: function() 142 { 143 this._userSelectedFiles = true; 144 this._updateHistory(); 145 }, 146 147 _updateHistory: function() 148 { 149 var tabIds = this._tabbedPane.lastOpenedTabIds(WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount); 150 151 function tabIdToURL(tabId) 152 { 153 return this._files[tabId].url; 154 } 155 156 this._history.update(tabIds.map(tabIdToURL.bind(this))); 157 this._history.save(this._previouslyViewedFilesSetting); 158 }, 159 160 /** 161 * @param {WebInspector.UISourceCode} uiSourceCode 93 162 * @return {string} 94 163 */ … … 100 169 /** 101 170 * @param {WebInspector.UISourceCode} uiSourceCode 102 */ 103 _appendFileTab: function(uiSourceCode) 171 * @param {boolean=} userGesture 172 */ 173 _appendFileTab: function(uiSourceCode, userGesture) 104 174 { 105 175 var view = this._delegate.viewForFile(uiSourceCode); … … 111 181 this._files[tabId] = uiSourceCode; 112 182 113 this._tabbedPane.appendTab(tabId, title, view, tooltip );183 this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture); 114 184 return tabId; 115 185 }, … … 132 202 { 133 203 var tabId = /** @type {string} */ event.data.tabId; 204 var userGesture = /** @type {boolean} */ event.data.isUserGesture; 134 205 135 206 var uiSourceCode = this._files[tabId]; … … 137 208 delete this._files[tabId]; 138 209 139 this.dispatchEventToListeners(WebInspector.ScriptsPanel.EditorContainer.Events.EditorClosed, uiSourceCode); 210 this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorClosed, uiSourceCode); 211 212 if (userGesture) 213 this._editorClosedByUserAction(uiSourceCode); 140 214 }, 141 215 … … 146 220 { 147 221 var tabId = /** @type {string} */ event.data.tabId; 222 var userGesture = /** @type {boolean} */ event.data.isUserGesture; 223 148 224 var uiSourceCode = this._files[tabId]; 149 150 if (this._currentFile === uiSourceCode) 151 return; 152 this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorSelected, uiSourceCode); 225 this._innerShowFile(uiSourceCode, userGesture); 153 226 }, 154 227 … … 218 291 this._files = {}; 219 292 delete this._currentFile; 293 delete this._userSelectedFiles; 294 this._loadedURLs = {}; 220 295 }, 221 296 … … 230 305 231 306 WebInspector.TabbedEditorContainer.prototype.__proto__ = WebInspector.Object.prototype; 307 308 /** 309 * @constructor 310 */ 311 WebInspector.TabbedEditorContainer.History = function(urls) 312 { 313 this._urls = urls; 314 } 315 316 WebInspector.TabbedEditorContainer.History.prototype = { 317 /** 318 * @param {string} url 319 */ 320 index: function(url) 321 { 322 return this._urls.indexOf(url); 323 }, 324 325 /** 326 * @param {Array.<string>} urls 327 */ 328 update: function(urls) 329 { 330 for (var i = urls.length - 1; i >= 0; --i) { 331 var index = this._urls.indexOf(urls[i]); 332 if (index !== -1) 333 this._urls.splice(index, 1); 334 this._urls.unshift(urls[i]); 335 } 336 }, 337 338 /** 339 * @param {string} url 340 */ 341 remove: function(url) 342 { 343 var index = this._urls.indexOf(url); 344 if (index !== -1) 345 this._urls.splice(index, 1); 346 }, 347 348 /** 349 * @param {WebInspector.Setting} setting 350 */ 351 save: function(setting) 352 { 353 setting.set(this._urls); 354 } 355 } 356 357 WebInspector.TabbedEditorContainer.History.prototype.__proto__ = WebInspector.Object.prototype; -
trunk/Source/WebCore/inspector/front-end/TabbedPane.js
r105748 r106238 92 92 * @param {WebInspector.View} view 93 93 * @param {string=} tabTooltip 94 */ 95 appendTab: function(id, tabTitle, view, tabTooltip) 94 * @param {boolean=} userGesture 95 */ 96 appendTab: function(id, tabTitle, view, tabTooltip, userGesture) 96 97 { 97 98 var tab = new WebInspector.TabbedPaneTab(this, this._tabsElement, id, tabTitle, this._closeableTabs, view, tabTooltip); 99 this._tabsById[id] = tab; 98 100 99 101 this._tabs.push(tab); 100 this._tabsById[id] = tab;101 102 this._tabsHistory.push(tab); 103 104 if (this._tabsHistory[0] === tab) 105 this.selectTab(tab.id, userGesture); 106 102 107 this._updateTabElements(); 103 108 }, … … 108 113 */ 109 114 closeTab: function(id, userGesture) 115 { 116 this._innerCloseTab(id, userGesture); 117 118 if (this._tabsHistory.length) 119 this.selectTab(this._tabsHistory[0].id, userGesture); 120 else 121 this._updateTabElements(); 122 }, 123 124 /** 125 * @param {string} id 126 * @param {boolean=} userGesture 127 */ 128 _innerCloseTab: function(id, userGesture) 110 129 { 111 130 if (this._currentTab && this._currentTab.id === id) … … 120 139 this._hideTabElement(tab); 121 140 122 if (this._tabsHistory.length)123 this.selectTab(this._tabsHistory[0].id);124 else125 this._updateTabElements();126 127 141 var eventData = { tabId: id, view: tab.view, isUserGesture: userGesture }; 128 142 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabClosed, eventData); … … 130 144 }, 131 145 132 closeAllTabs: function() 146 /** 147 * @param {boolean=} userGesture 148 */ 149 closeAllTabs: function(userGesture) 133 150 { 134 151 var tabs = this._tabs.slice(); 135 152 for (var i = 0; i < tabs.length; ++i) 136 this.closeTab(tabs[i].id, false); 153 this._innerCloseTab(tabs[i].id, userGesture); 154 this._updateTabElements(); 137 155 }, 138 156 … … 161 179 this.dispatchEventToListeners(WebInspector.TabbedPane.EventTypes.TabSelected, eventData); 162 180 return true; 181 }, 182 183 /** 184 * @param {number} tabsCount 185 * @return {Array.<string>} 186 */ 187 lastOpenedTabIds: function(tabsCount) 188 { 189 function tabToTabId(tab) { 190 return tab.id; 191 } 192 193 return this._tabsHistory.slice(0, tabsCount).map(tabToTabId); 163 194 }, 164 195 … … 297 328 var options = this._tabsSelect.options; 298 329 var selectedOption = options[this._tabsSelect.selectedIndex]; 299 this.selectTab(selectedOption.tab.id );330 this.selectTab(selectedOption.tab.id, true); 300 331 }, 301 332
Note: See TracChangeset
for help on using the changeset viewer.