Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: Source/devtools/front_end/SourceFrame.js

Issue 204323003: DevTools: Merge highlightPosition and revealLine methods on SourceFrame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed tests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * * 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 */ 118 */
119 _isEditorShowing: function() 119 _isEditorShowing: function()
120 { 120 {
121 return this.isShowing() && this._editorAttached; 121 return this.isShowing() && this._editorAttached;
122 }, 122 },
123 123
124 willHide: function() 124 willHide: function()
125 { 125 {
126 WebInspector.View.prototype.willHide.call(this); 126 WebInspector.View.prototype.willHide.call(this);
127 127
128 this._clearPositionHighlight(); 128 this._clearPositionToReveal();
129 this._clearLineToReveal();
130 }, 129 },
131 130
132 /** 131 /**
133 * @return {?Element} 132 * @return {?Element}
134 */ 133 */
135 statusBarText: function() 134 statusBarText: function()
136 { 135 {
137 return this._sourcePosition.element; 136 return this._sourcePosition.element;
138 }, 137 },
139 138
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 canHighlightPosition: function() 205 canHighlightPosition: function()
207 { 206 {
208 return true; 207 return true;
209 }, 208 },
210 209
211 /** 210 /**
212 * @override 211 * @override
213 */ 212 */
214 highlightPosition: function(line, column) 213 highlightPosition: function(line, column)
215 { 214 {
216 this._clearLineToReveal(); 215 this.revealPosition(line, column, true);
216 },
217
218 /**
219 * @param {number} line
220 * @param {number=} column
221 * @param {boolean=} shouldHighlight
222 */
223 revealPosition: function(line, column, shouldHighlight)
224 {
217 this._clearLineToScrollTo(); 225 this._clearLineToScrollTo();
218 this._clearSelectionToSet(); 226 this._clearSelectionToSet();
219 this._positionToHighlight = { line: line, column: column }; 227 this._positionToReveal = { line: line, column: column, shouldHighlight: shouldHighlight };
220 this._innerHighlightPositionIfNeeded(); 228 this._innerRevealPositionIfNeeded();
221 }, 229 },
222 230
223 _innerHighlightPositionIfNeeded: function() 231 _innerRevealPositionIfNeeded: function()
224 { 232 {
225 if (!this._positionToHighlight) 233 if (!this._positionToReveal)
226 return; 234 return;
227 235
228 if (!this.loaded || !this._isEditorShowing()) 236 if (!this.loaded || !this._isEditorShowing())
229 return; 237 return;
230 238
231 this._textEditor.highlightPosition(this._positionToHighlight.line, this. _positionToHighlight.column); 239 this._textEditor.revealPosition(this._positionToReveal.line, this._posit ionToReveal.column, this._positionToReveal.shouldHighlight);
232 delete this._positionToHighlight; 240 delete this._positionToReveal;
233 }, 241 },
234 242
235 _clearPositionHighlight: function() 243 _clearPositionToReveal: function()
236 { 244 {
237 this._textEditor.clearPositionHighlight(); 245 this._textEditor.clearPositionHighlight();
238 delete this._positionToHighlight; 246 delete this._positionToReveal;
239 }, 247 },
240 248
241 /** 249 /**
242 * @param {number} line
243 */
244 revealLine: function(line)
245 {
246 this._clearPositionHighlight();
247 this._clearLineToScrollTo();
248 this._clearSelectionToSet();
249 this._lineToReveal = line;
250 this._innerRevealLineIfNeeded();
251 },
252
253 _innerRevealLineIfNeeded: function()
254 {
255 if (typeof this._lineToReveal === "number") {
256 if (this.loaded && this._isEditorShowing()) {
257 this._textEditor.revealLine(this._lineToReveal);
258 delete this._lineToReveal;
259 }
260 }
261 },
262
263 _clearLineToReveal: function()
264 {
265 delete this._lineToReveal;
266 },
267
268 /**
269 * @param {number} line 250 * @param {number} line
270 */ 251 */
271 scrollToLine: function(line) 252 scrollToLine: function(line)
272 { 253 {
273 this._clearPositionHighlight(); 254 this._clearPositionToReveal();
274 this._clearLineToReveal();
275 this._lineToScrollTo = line; 255 this._lineToScrollTo = line;
276 this._innerScrollToLineIfNeeded(); 256 this._innerScrollToLineIfNeeded();
277 }, 257 },
278 258
279 _innerScrollToLineIfNeeded: function() 259 _innerScrollToLineIfNeeded: function()
280 { 260 {
281 if (typeof this._lineToScrollTo === "number") { 261 if (typeof this._lineToScrollTo === "number") {
282 if (this.loaded && this._isEditorShowing()) { 262 if (this.loaded && this._isEditorShowing()) {
283 this._textEditor.scrollToLine(this._lineToScrollTo); 263 this._textEditor.scrollToLine(this._lineToScrollTo);
284 delete this._lineToScrollTo; 264 delete this._lineToScrollTo;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 296 }
317 }, 297 },
318 298
319 _clearSelectionToSet: function() 299 _clearSelectionToSet: function()
320 { 300 {
321 delete this._selectionToSet; 301 delete this._selectionToSet;
322 }, 302 },
323 303
324 _wasShownOrLoaded: function() 304 _wasShownOrLoaded: function()
325 { 305 {
326 this._innerHighlightPositionIfNeeded(); 306 this._innerRevealPositionIfNeeded();
327 this._innerRevealLineIfNeeded();
328 this._innerSetSelectionIfNeeded(); 307 this._innerSetSelectionIfNeeded();
329 this._innerScrollToLineIfNeeded(); 308 this._innerScrollToLineIfNeeded();
330 }, 309 },
331 310
332 onTextChanged: function(oldRange, newRange) 311 onTextChanged: function(oldRange, newRange)
333 { 312 {
334 if (this._searchResultsChangedCallback && !this._isReplacing) 313 if (this._searchResultsChangedCallback && !this._isReplacing)
335 this._searchResultsChangedCallback(); 314 this._searchResultsChangedCallback();
336 this.clearMessages(); 315 this.clearMessages();
337 }, 316 },
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 855
877 /** 856 /**
878 * @param {?WebInspector.TextRange} from 857 * @param {?WebInspector.TextRange} from
879 * @param {?WebInspector.TextRange} to 858 * @param {?WebInspector.TextRange} to
880 */ 859 */
881 onJumpToPosition: function(from, to) 860 onJumpToPosition: function(from, to)
882 { 861 {
883 this._sourceFrame.onJumpToPosition(from, to); 862 this._sourceFrame.onJumpToPosition(from, to);
884 } 863 }
885 } 864 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/CodeMirrorTextEditor.js ('k') | Source/devtools/front_end/SourcesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698