Chromium Code Reviews| Index: Source/devtools/front_end/SourcesPanel.js |
| diff --git a/Source/devtools/front_end/SourcesPanel.js b/Source/devtools/front_end/SourcesPanel.js |
| index 3806df3e2885dc91b5aedac35bbf3c91efbb9300..808942bed19fd5b06dba02651ea0861c197612bc 100644 |
| --- a/Source/devtools/front_end/SourcesPanel.js |
| +++ b/Source/devtools/front_end/SourcesPanel.js |
| @@ -26,6 +26,8 @@ |
| importScript("BreakpointsSidebarPane.js"); |
| importScript("CallStackSidebarPane.js"); |
| +importScript("SimpleHistoryManager.js"); |
| +importScript("EditingLocationHistoryManager.js"); |
| importScript("FilePathScoreFunction.js"); |
| importScript("FilteredItemSelectionDialog.js"); |
| importScript("UISourceCodeFrame.js"); |
| @@ -68,7 +70,7 @@ WebInspector.SourcesPanel = function(workspaceForTest) |
| */ |
| function viewGetter() |
| { |
| - return this.visibleView; |
| + return this; |
| } |
| WebInspector.GoToLineDialog.install(this, viewGetter.bind(this)); |
| @@ -141,6 +143,21 @@ WebInspector.SourcesPanel = function(workspaceForTest) |
| this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane(WebInspector.workerManager); |
| } |
| + /** |
| + * @this {WebInspector.SourcesPanel} |
| + */ |
| + function currentSourceFrame() |
| + { |
| + var uiSourceCode = this.currentUISourceCode(); |
| + if (!uiSourceCode) |
| + return null; |
| + return this._sourceFramesByUISourceCode.get(uiSourceCode); |
| + } |
| + |
| + this._historyManager = new WebInspector.EditingLocationHistoryManager(this, currentSourceFrame.bind(this)); |
| + this.registerShortcuts(WebInspector.SourcesPanelDescriptor.ShortcutKeys.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this)); |
| + this.registerShortcuts(WebInspector.SourcesPanelDescriptor.ShortcutKeys.JumpToNextLocation, this._onJumpToNextLocation.bind(this)); |
| + |
| this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this)); |
| this.registerShortcuts(WebInspector.SourcesPanelDescriptor.ShortcutKeys.GoToMember, this._showOutlineDialog.bind(this)); |
| this.registerShortcuts(WebInspector.SourcesPanelDescriptor.ShortcutKeys.ToggleBreakpoint, this._toggleBreakpoint.bind(this)); |
| @@ -216,6 +233,24 @@ WebInspector.SourcesPanel = function(workspaceForTest) |
| WebInspector.SourcesPanel.prototype = { |
| /** |
| + * @param {?Event=} event |
| + */ |
| + _onJumpToPreviousLocation: function(event) |
| + { |
| + this._historyManager.rollback(); |
| + return true; |
| + }, |
| + |
| + /** |
| + * @param {?Event=} event |
| + */ |
| + _onJumpToNextLocation: function(event) |
| + { |
| + this._historyManager.rollover(); |
| + return true; |
| + }, |
| + |
| + /** |
| * @return {!Element} |
| */ |
| defaultFocusedElement: function() |
| @@ -297,6 +332,7 @@ WebInspector.SourcesPanel.prototype = { |
| for (var i = 0; i < uiSourceCodes.length; ++i) { |
| this._navigator.removeUISourceCode(uiSourceCodes[i]); |
| this._removeSourceFrame(uiSourceCodes[i]); |
| + this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]); |
| } |
| this._editorContainer.removeUISourceCodes(uiSourceCodes); |
| }, |
| @@ -513,12 +549,17 @@ WebInspector.SourcesPanel.prototype = { |
| */ |
| _showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, forceShowInPanel) |
| { |
| + if (uiSourceCode === this._currentUISourceCode && typeof lineNumber === "number") { |
| + this.highlightPosition(lineNumber, columnNumber); |
|
vsevik
2014/01/17 13:00:23
remove this!
lushnikov
2014/01/17 13:28:45
Done.
|
| + return; |
| + } |
| this._showEditor(forceShowInPanel); |
| + this._historyManager.updateCurrentState(); |
| var sourceFrame = this._showFile(uiSourceCode); |
| if (typeof lineNumber === "number") |
| sourceFrame.highlightPosition(lineNumber, columnNumber); |
| + this._historyManager.pushNewState(); |
| sourceFrame.focus(); |
| - |
| WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction, { |
| action: WebInspector.UserMetrics.UserActionNames.OpenSourceLink, |
| url: uiSourceCode.originURL(), |
| @@ -535,9 +576,11 @@ WebInspector.SourcesPanel.prototype = { |
| var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode); |
| if (this._currentUISourceCode === uiSourceCode) |
| return sourceFrame; |
| + |
| this._currentUISourceCode = uiSourceCode; |
| if (!uiSourceCode.project().isServiceProject()) |
| this._navigator.revealUISourceCode(uiSourceCode, true); |
| + |
| this._editorContainer.showFile(uiSourceCode); |
| this._updateScriptViewStatusBarItems(); |
| @@ -572,6 +615,7 @@ WebInspector.SourcesPanel.prototype = { |
| } |
| sourceFrame.setHighlighterType(uiSourceCode.highlighterType()); |
| this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame); |
| + this._historyManager.trackSourceFrameCursorJumps(sourceFrame); |
| return sourceFrame; |
| }, |
| @@ -664,7 +708,11 @@ WebInspector.SourcesPanel.prototype = { |
| if (this._skipExecutionLineRevealing) |
| return; |
| this._skipExecutionLineRevealing = true; |
| + |
| + this._historyManager.updateCurrentState(); |
| var sourceFrame = this._showFile(uiSourceCode); |
| + this._historyManager.pushNewState(); |
|
vsevik
2014/01/17 13:00:23
one line below
lushnikov
2014/01/17 13:28:45
Moved to correct places
|
| + |
| sourceFrame.revealLine(uiLocation.lineNumber); |
| if (sourceFrame.canEditSource()) |
| sourceFrame.setSelection(WebInspector.TextRange.createFromLocation(uiLocation.lineNumber, 0)); |
| @@ -688,6 +736,7 @@ WebInspector.SourcesPanel.prototype = { |
| { |
| this._navigatorController.hideNavigatorOverlay(); |
| var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); |
| + this._historyManager.removeHistoryForSourceCode(uiSourceCode); |
| if (this._currentUISourceCode === uiSourceCode) |
| delete this._currentUISourceCode; |
| @@ -699,8 +748,14 @@ WebInspector.SourcesPanel.prototype = { |
| _editorSelected: function(event) |
| { |
| - var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); |
| + var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data.currentFile); |
| + var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode && event.data.userGesture; |
| + if (shouldUseHistoryManager) |
| + this._historyManager.updateCurrentState(); |
| var sourceFrame = this._showFile(uiSourceCode); |
| + if (shouldUseHistoryManager) |
| + this._historyManager.pushNewState(); |
| + |
| this._navigatorController.hideNavigatorOverlay(); |
| if (!this._navigatorController.isNavigatorPinned()) |
| sourceFrame.focus(); |
| @@ -711,7 +766,15 @@ WebInspector.SourcesPanel.prototype = { |
| _sourceSelected: function(event) |
| { |
| var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data.uiSourceCode); |
| + |
| + var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode; |
| + |
| + if (shouldUseHistoryManager) |
| + this._historyManager.updateCurrentState(); |
| var sourceFrame = this._showFile(uiSourceCode); |
| + if (shouldUseHistoryManager) |
| + this._historyManager.pushNewState(); |
| + |
| this._navigatorController.hideNavigatorOverlay(); |
| if (sourceFrame && (!this._navigatorController.isNavigatorPinned() || event.data.focusSource)) |
| sourceFrame.focus(); |
| @@ -1630,7 +1693,9 @@ WebInspector.SourcesPanel.prototype = { |
| { |
| if (!this.canHighlightPosition()) |
| return; |
| + this._historyManager.updateCurrentState(); |
| this.visibleView.highlightPosition(line, column); |
| + this._historyManager.pushNewState(); |
| }, |
| /** |