OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @param {!WebInspector.SourcesPanel} sourcesPanel | 33 * @param {!WebInspector.SourcesEditor} sourcesEditor |
34 * @param {!function():?WebInspector.SourceFrame} currentSourceFrameCallback | 34 * @param {!function():?WebInspector.SourceFrame} currentSourceFrameCallback |
35 */ | 35 */ |
36 WebInspector.EditingLocationHistoryManager = function(sourcesPanel, currentSourc
eFrameCallback) | 36 WebInspector.EditingLocationHistoryManager = function(sourcesEditor, currentSour
ceFrameCallback) |
37 { | 37 { |
38 this._sourcesPanel = sourcesPanel; | 38 this._sourcesEditor = sourcesEditor; |
39 this._historyManager = new WebInspector.SimpleHistoryManager(WebInspector.Ed
itingLocationHistoryManager.HistoryDepth); | 39 this._historyManager = new WebInspector.SimpleHistoryManager(WebInspector.Ed
itingLocationHistoryManager.HistoryDepth); |
40 this._currentSourceFrameCallback = currentSourceFrameCallback; | 40 this._currentSourceFrameCallback = currentSourceFrameCallback; |
41 } | 41 } |
42 | 42 |
43 WebInspector.EditingLocationHistoryManager.HistoryDepth = 20; | 43 WebInspector.EditingLocationHistoryManager.HistoryDepth = 20; |
44 | 44 |
45 WebInspector.EditingLocationHistoryManager.prototype = { | 45 WebInspector.EditingLocationHistoryManager.prototype = { |
46 /** | 46 /** |
47 * @param {!WebInspector.UISourceCodeFrame} sourceFrame | 47 * @param {!WebInspector.UISourceCodeFrame} sourceFrame |
48 */ | 48 */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 * @param {!WebInspector.TextRange} selection | 92 * @param {!WebInspector.TextRange} selection |
93 */ | 93 */ |
94 _updateActiveState: function(selection) | 94 _updateActiveState: function(selection) |
95 { | 95 { |
96 var active = this._historyManager.active(); | 96 var active = this._historyManager.active(); |
97 if (!active) | 97 if (!active) |
98 return; | 98 return; |
99 var sourceFrame = this._currentSourceFrameCallback(); | 99 var sourceFrame = this._currentSourceFrameCallback(); |
100 if (!sourceFrame) | 100 if (!sourceFrame) |
101 return; | 101 return; |
102 var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesPa
nel, this, sourceFrame, selection); | 102 var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesEd
itor, this, sourceFrame, selection); |
103 active.merge(entry); | 103 active.merge(entry); |
104 }, | 104 }, |
105 | 105 |
106 /** | 106 /** |
107 * @param {!WebInspector.TextRange} selection | 107 * @param {!WebInspector.TextRange} selection |
108 */ | 108 */ |
109 _pushActiveState: function(selection) | 109 _pushActiveState: function(selection) |
110 { | 110 { |
111 var sourceFrame = this._currentSourceFrameCallback(); | 111 var sourceFrame = this._currentSourceFrameCallback(); |
112 if (!sourceFrame) | 112 if (!sourceFrame) |
113 return; | 113 return; |
114 var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesPa
nel, this, sourceFrame, selection); | 114 var entry = new WebInspector.EditingLocationHistoryEntry(this._sourcesEd
itor, this, sourceFrame, selection); |
115 this._historyManager.push(entry); | 115 this._historyManager.push(entry); |
116 }, | 116 }, |
117 | 117 |
118 /** | 118 /** |
119 * @param {!WebInspector.UISourceCode} uiSourceCode | 119 * @param {!WebInspector.UISourceCode} uiSourceCode |
120 */ | 120 */ |
121 removeHistoryForSourceCode: function(uiSourceCode) | 121 removeHistoryForSourceCode: function(uiSourceCode) |
122 { | 122 { |
123 function filterOut(entry) | 123 function filterOut(entry) |
124 { | 124 { |
125 return entry._projectId === uiSourceCode.project().id() && entry._pa
th === uiSourceCode.path(); | 125 return entry._projectId === uiSourceCode.project().id() && entry._pa
th === uiSourceCode.path(); |
126 } | 126 } |
127 | 127 |
128 this._historyManager.filterOut(filterOut); | 128 this._historyManager.filterOut(filterOut); |
129 }, | 129 }, |
130 } | 130 } |
131 | 131 |
132 | 132 |
133 /** | 133 /** |
134 * @constructor | 134 * @constructor |
135 * @implements {WebInspector.HistoryEntry} | 135 * @implements {WebInspector.HistoryEntry} |
136 * @param {!WebInspector.SourcesPanel} sourcesPanel | 136 * @param {!WebInspector.SourcesEditor} sourcesEditor |
137 * @param {!WebInspector.EditingLocationHistoryManager} editingLocationManager | 137 * @param {!WebInspector.EditingLocationHistoryManager} editingLocationManager |
138 * @param {!WebInspector.SourceFrame} sourceFrame | 138 * @param {!WebInspector.SourceFrame} sourceFrame |
139 * @param {!WebInspector.TextRange} selection | 139 * @param {!WebInspector.TextRange} selection |
140 */ | 140 */ |
141 WebInspector.EditingLocationHistoryEntry = function(sourcesPanel, editingLocatio
nManager, sourceFrame, selection) | 141 WebInspector.EditingLocationHistoryEntry = function(sourcesEditor, editingLocati
onManager, sourceFrame, selection) |
142 { | 142 { |
143 this._sourcesPanel = sourcesPanel; | 143 this._sourcesEditor = sourcesEditor; |
144 this._editingLocationManager = editingLocationManager; | 144 this._editingLocationManager = editingLocationManager; |
145 var uiSourceCode = sourceFrame.uiSourceCode(); | 145 var uiSourceCode = sourceFrame.uiSourceCode(); |
146 this._projectId = uiSourceCode.project().id(); | 146 this._projectId = uiSourceCode.project().id(); |
147 this._path = uiSourceCode.path(); | 147 this._path = uiSourceCode.path(); |
148 | 148 |
149 var position = this._positionFromSelection(selection); | 149 var position = this._positionFromSelection(selection); |
150 this._positionHandle = sourceFrame.textEditor.textEditorPositionHandle(posit
ion.lineNumber, position.columnNumber); | 150 this._positionHandle = sourceFrame.textEditor.textEditorPositionHandle(posit
ion.lineNumber, position.columnNumber); |
151 } | 151 } |
152 | 152 |
153 WebInspector.EditingLocationHistoryEntry.prototype = { | 153 WebInspector.EditingLocationHistoryEntry.prototype = { |
(...skipping 30 matching lines...) Expand all Loading... |
184 }, | 184 }, |
185 | 185 |
186 reveal: function() | 186 reveal: function() |
187 { | 187 { |
188 var position = this._positionHandle.resolve(); | 188 var position = this._positionHandle.resolve(); |
189 var uiSourceCode = WebInspector.workspace.project(this._projectId).uiSou
rceCode(this._path); | 189 var uiSourceCode = WebInspector.workspace.project(this._projectId).uiSou
rceCode(this._path); |
190 if (!position || !uiSourceCode) | 190 if (!position || !uiSourceCode) |
191 return; | 191 return; |
192 | 192 |
193 this._editingLocationManager.updateCurrentState(); | 193 this._editingLocationManager.updateCurrentState(); |
194 this._sourcesPanel.showUISourceCode(uiSourceCode, position.lineNumber, p
osition.columnNumber); | 194 this._sourcesEditor.showSourceLocation(uiSourceCode, position.lineNumber
, position.columnNumber); |
195 } | 195 } |
196 }; | 196 }; |
OLD | NEW |