| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * | 10 * |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @return {!Array.<!WebInspector.UISourceCode>} | 135 * @return {!Array.<!WebInspector.UISourceCode>} |
| 136 */ | 136 */ |
| 137 historyUISourceCodes: function() | 137 historyUISourceCodes: function() |
| 138 { | 138 { |
| 139 // FIXME: there should be a way to fetch UISourceCode for its uri. | 139 // FIXME: there should be a way to fetch UISourceCode for its uri. |
| 140 var uriToUISourceCode = {}; | 140 var uriToUISourceCode = {}; |
| 141 for (var id in this._files) { | 141 for (var id in this._files) { |
| 142 var uiSourceCode = this._files[id]; | 142 var uiSourceCode = this._files[id]; |
| 143 uriToUISourceCode[uiSourceCode.uri()] = uiSourceCode; | 143 uriToUISourceCode[uiSourceCode.url()] = uiSourceCode; |
| 144 } | 144 } |
| 145 | 145 |
| 146 var result = []; | 146 var result = []; |
| 147 var uris = this._history._urls(); | 147 var uris = this._history._urls(); |
| 148 for (var i = 0; i < uris.length; ++i) { | 148 for (var i = 0; i < uris.length; ++i) { |
| 149 var uiSourceCode = uriToUISourceCode[uris[i]]; | 149 var uiSourceCode = uriToUISourceCode[uris[i]]; |
| 150 if (uiSourceCode) | 150 if (uiSourceCode) |
| 151 result.push(uiSourceCode); | 151 result.push(uiSourceCode); |
| 152 } | 152 } |
| 153 return result; | 153 return result; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 168 this._currentView.removeEventListener(WebInspector.SourceFrame.Events.Sc
rollChanged, this._scrollChanged, this); | 168 this._currentView.removeEventListener(WebInspector.SourceFrame.Events.Sc
rollChanged, this._scrollChanged, this); |
| 169 this._currentView.removeEventListener(WebInspector.SourceFrame.Events.Se
lectionChanged, this._selectionChanged, this); | 169 this._currentView.removeEventListener(WebInspector.SourceFrame.Events.Se
lectionChanged, this._selectionChanged, this); |
| 170 }, | 170 }, |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * @param {!WebInspector.Event} event | 173 * @param {!WebInspector.Event} event |
| 174 */ | 174 */ |
| 175 _scrollChanged: function(event) | 175 _scrollChanged: function(event) |
| 176 { | 176 { |
| 177 var lineNumber = /** @type {number} */ (event.data); | 177 var lineNumber = /** @type {number} */ (event.data); |
| 178 this._history.updateScrollLineNumber(this._currentFile.uri(), lineNumber
); | 178 this._history.updateScrollLineNumber(this._currentFile.url(), lineNumber
); |
| 179 this._history.save(this._previouslyViewedFilesSetting); | 179 this._history.save(this._previouslyViewedFilesSetting); |
| 180 }, | 180 }, |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * @param {!WebInspector.Event} event | 183 * @param {!WebInspector.Event} event |
| 184 */ | 184 */ |
| 185 _selectionChanged: function(event) | 185 _selectionChanged: function(event) |
| 186 { | 186 { |
| 187 var range = /** @type {!WebInspector.TextRange} */ (event.data); | 187 var range = /** @type {!WebInspector.TextRange} */ (event.data); |
| 188 this._history.updateSelectionRange(this._currentFile.uri(), range); | 188 this._history.updateSelectionRange(this._currentFile.url(), range); |
| 189 this._history.save(this._previouslyViewedFilesSetting); | 189 this._history.save(this._previouslyViewedFilesSetting); |
| 190 }, | 190 }, |
| 191 | 191 |
| 192 /** | 192 /** |
| 193 * @param {!WebInspector.UISourceCode} uiSourceCode | 193 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 194 * @param {boolean=} userGesture | 194 * @param {boolean=} userGesture |
| 195 */ | 195 */ |
| 196 _innerShowFile: function(uiSourceCode, userGesture) | 196 _innerShowFile: function(uiSourceCode, userGesture) |
| 197 { | 197 { |
| 198 if (this._currentFile === uiSourceCode) | 198 if (this._currentFile === uiSourceCode) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 var uiSourceCode = this._files[tabId]; | 280 var uiSourceCode = this._files[tabId]; |
| 281 if (uiSourceCode) | 281 if (uiSourceCode) |
| 282 contextMenu.appendApplicableItems(uiSourceCode); | 282 contextMenu.appendApplicableItems(uiSourceCode); |
| 283 }, | 283 }, |
| 284 | 284 |
| 285 /** | 285 /** |
| 286 * @param {!WebInspector.UISourceCode} uiSourceCode | 286 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 287 */ | 287 */ |
| 288 addUISourceCode: function(uiSourceCode) | 288 addUISourceCode: function(uiSourceCode) |
| 289 { | 289 { |
| 290 var uri = uiSourceCode.uri(); | 290 var uri = uiSourceCode.url(); |
| 291 var index = this._history.index(uri); | 291 var index = this._history.index(uri); |
| 292 if (index === -1) | 292 if (index === -1) |
| 293 return; | 293 return; |
| 294 | 294 |
| 295 if (!this._tabIds.has(uiSourceCode)) | 295 if (!this._tabIds.has(uiSourceCode)) |
| 296 this._appendFileTab(uiSourceCode, false); | 296 this._appendFileTab(uiSourceCode, false); |
| 297 | 297 |
| 298 // Select tab if this file was the last to be shown. | 298 // Select tab if this file was the last to be shown. |
| 299 if (!index) { | 299 if (!index) { |
| 300 this._innerShowFile(uiSourceCode, false); | 300 this._innerShowFile(uiSourceCode, false); |
| 301 return; | 301 return; |
| 302 } | 302 } |
| 303 | 303 |
| 304 if (!this._currentFile) | 304 if (!this._currentFile) |
| 305 return; | 305 return; |
| 306 var currentProjectType = this._currentFile.project().type(); | 306 var currentProjectType = this._currentFile.project().type(); |
| 307 var addedProjectType = uiSourceCode.project().type(); | 307 var addedProjectType = uiSourceCode.project().type(); |
| 308 var snippetsProjectType = WebInspector.projectTypes.Snippets; | 308 var snippetsProjectType = WebInspector.projectTypes.Snippets; |
| 309 if (this._history.index(this._currentFile.uri()) && currentProjectType =
== snippetsProjectType && addedProjectType !== snippetsProjectType) | 309 if (this._history.index(this._currentFile.url()) && currentProjectType =
== snippetsProjectType && addedProjectType !== snippetsProjectType) |
| 310 this._innerShowFile(uiSourceCode, false); | 310 this._innerShowFile(uiSourceCode, false); |
| 311 }, | 311 }, |
| 312 | 312 |
| 313 /** | 313 /** |
| 314 * @param {!WebInspector.UISourceCode} uiSourceCode | 314 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 315 */ | 315 */ |
| 316 removeUISourceCode: function(uiSourceCode) | 316 removeUISourceCode: function(uiSourceCode) |
| 317 { | 317 { |
| 318 this.removeUISourceCodes([uiSourceCode]); | 318 this.removeUISourceCodes([uiSourceCode]); |
| 319 }, | 319 }, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 331 tabIds.push(tabId); | 331 tabIds.push(tabId); |
| 332 } | 332 } |
| 333 this._tabbedPane.closeTabs(tabIds); | 333 this._tabbedPane.closeTabs(tabIds); |
| 334 }, | 334 }, |
| 335 | 335 |
| 336 /** | 336 /** |
| 337 * @param {!WebInspector.UISourceCode} uiSourceCode | 337 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 338 */ | 338 */ |
| 339 _editorClosedByUserAction: function(uiSourceCode) | 339 _editorClosedByUserAction: function(uiSourceCode) |
| 340 { | 340 { |
| 341 this._history.remove(uiSourceCode.uri()); | 341 this._history.remove(uiSourceCode.url()); |
| 342 this._updateHistory(); | 342 this._updateHistory(); |
| 343 }, | 343 }, |
| 344 | 344 |
| 345 _editorSelectedByUserAction: function() | 345 _editorSelectedByUserAction: function() |
| 346 { | 346 { |
| 347 this._updateHistory(); | 347 this._updateHistory(); |
| 348 }, | 348 }, |
| 349 | 349 |
| 350 _updateHistory: function() | 350 _updateHistory: function() |
| 351 { | 351 { |
| 352 var tabIds = this._tabbedPane.lastOpenedTabIds(WebInspector.TabbedEditor
Container.maximalPreviouslyViewedFilesCount); | 352 var tabIds = this._tabbedPane.lastOpenedTabIds(WebInspector.TabbedEditor
Container.maximalPreviouslyViewedFilesCount); |
| 353 | 353 |
| 354 /** | 354 /** |
| 355 * @param {string} tabId | 355 * @param {string} tabId |
| 356 * @this {WebInspector.TabbedEditorContainer} | 356 * @this {WebInspector.TabbedEditorContainer} |
| 357 */ | 357 */ |
| 358 function tabIdToURI(tabId) | 358 function tabIdToURI(tabId) |
| 359 { | 359 { |
| 360 return this._files[tabId].uri(); | 360 return this._files[tabId].url(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 this._history.update(tabIds.map(tabIdToURI.bind(this))); | 363 this._history.update(tabIds.map(tabIdToURI.bind(this))); |
| 364 this._history.save(this._previouslyViewedFilesSetting); | 364 this._history.save(this._previouslyViewedFilesSetting); |
| 365 }, | 365 }, |
| 366 | 366 |
| 367 /** | 367 /** |
| 368 * @param {!WebInspector.UISourceCode} uiSourceCode | 368 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 369 * @return {string} | 369 * @return {string} |
| 370 */ | 370 */ |
| 371 _tooltipForFile: function(uiSourceCode) | 371 _tooltipForFile: function(uiSourceCode) |
| 372 { | 372 { |
| 373 return uiSourceCode.originURL(); | 373 return uiSourceCode.url(); |
| 374 }, | 374 }, |
| 375 | 375 |
| 376 /** | 376 /** |
| 377 * @param {!WebInspector.UISourceCode} uiSourceCode | 377 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 378 * @param {boolean=} userGesture | 378 * @param {boolean=} userGesture |
| 379 * @return {string} | 379 * @return {string} |
| 380 */ | 380 */ |
| 381 _appendFileTab: function(uiSourceCode, userGesture) | 381 _appendFileTab: function(uiSourceCode, userGesture) |
| 382 { | 382 { |
| 383 var view = this._delegate.viewForFile(uiSourceCode); | 383 var view = this._delegate.viewForFile(uiSourceCode); |
| 384 var sourceFrame = view instanceof WebInspector.SourceFrame ? /** @type {
!WebInspector.SourceFrame} */ (view) : null; | 384 var sourceFrame = view instanceof WebInspector.SourceFrame ? /** @type {
!WebInspector.SourceFrame} */ (view) : null; |
| 385 var title = this._titleForFile(uiSourceCode); | 385 var title = this._titleForFile(uiSourceCode); |
| 386 var tooltip = this._tooltipForFile(uiSourceCode); | 386 var tooltip = this._tooltipForFile(uiSourceCode); |
| 387 | 387 |
| 388 var tabId = this._generateTabId(); | 388 var tabId = this._generateTabId(); |
| 389 this._tabIds.set(uiSourceCode, tabId); | 389 this._tabIds.set(uiSourceCode, tabId); |
| 390 this._files[tabId] = uiSourceCode; | 390 this._files[tabId] = uiSourceCode; |
| 391 | 391 |
| 392 var savedSelectionRange = this._history.selectionRange(uiSourceCode.uri(
)); | 392 var savedSelectionRange = this._history.selectionRange(uiSourceCode.url(
)); |
| 393 if (sourceFrame && savedSelectionRange) | 393 if (sourceFrame && savedSelectionRange) |
| 394 sourceFrame.setSelection(savedSelectionRange); | 394 sourceFrame.setSelection(savedSelectionRange); |
| 395 var savedScrollLineNumber = this._history.scrollLineNumber(uiSourceCode.
uri()); | 395 var savedScrollLineNumber = this._history.scrollLineNumber(uiSourceCode.
url()); |
| 396 if (sourceFrame && savedScrollLineNumber) | 396 if (sourceFrame && savedScrollLineNumber) |
| 397 sourceFrame.scrollToLine(savedScrollLineNumber); | 397 sourceFrame.scrollToLine(savedScrollLineNumber); |
| 398 | 398 |
| 399 this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture); | 399 this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture); |
| 400 | 400 |
| 401 this._updateFileTitle(uiSourceCode); | 401 this._updateFileTitle(uiSourceCode); |
| 402 this._addUISourceCodeListeners(uiSourceCode); | 402 this._addUISourceCodeListeners(uiSourceCode); |
| 403 return tabId; | 403 return tabId; |
| 404 }, | 404 }, |
| 405 | 405 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 /** | 737 /** |
| 738 * @override | 738 * @override |
| 739 * @param {string} tabId | 739 * @param {string} tabId |
| 740 * @param {!WebInspector.ContextMenu} contextMenu | 740 * @param {!WebInspector.ContextMenu} contextMenu |
| 741 */ | 741 */ |
| 742 onContextMenu: function(tabId, contextMenu) | 742 onContextMenu: function(tabId, contextMenu) |
| 743 { | 743 { |
| 744 this._editorContainer._onContextMenu(tabId, contextMenu); | 744 this._editorContainer._onContextMenu(tabId, contextMenu); |
| 745 } | 745 } |
| 746 } | 746 } |
| OLD | NEW |