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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js

Issue 2152293002: DevTools: kill WI.SourcesView._showFile method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TabbedEditorContainerDelegate} 7 * @implements {WebInspector.TabbedEditorContainerDelegate}
8 * @implements {WebInspector.Searchable} 8 * @implements {WebInspector.Searchable}
9 * @implements {WebInspector.Replaceable} 9 * @implements {WebInspector.Replaceable}
10 * @extends {WebInspector.VBox} 10 * @extends {WebInspector.VBox}
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (uiSourceCode.isFromServiceProject()) 241 if (uiSourceCode.isFromServiceProject())
242 return; 242 return;
243 this._editorContainer.addUISourceCode(uiSourceCode); 243 this._editorContainer.addUISourceCode(uiSourceCode);
244 // Replace debugger script-based uiSourceCode with a network-based one. 244 // Replace debugger script-based uiSourceCode with a network-based one.
245 var currentUISourceCode = this._currentUISourceCode; 245 var currentUISourceCode = this._currentUISourceCode;
246 if (!currentUISourceCode) 246 if (!currentUISourceCode)
247 return; 247 return;
248 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode); 248 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode);
249 var currentNetworkURL = WebInspector.networkMapping.networkURL(currentUI SourceCode); 249 var currentNetworkURL = WebInspector.networkMapping.networkURL(currentUI SourceCode);
250 if (currentUISourceCode.isFromServiceProject() && currentUISourceCode != = uiSourceCode && currentNetworkURL === networkURL && networkURL) { 250 if (currentUISourceCode.isFromServiceProject() && currentUISourceCode != = uiSourceCode && currentNetworkURL === networkURL && networkURL) {
251 this._showFile(uiSourceCode); 251 this._editorContainer.showFile(uiSourceCode);
252 this._editorContainer.removeUISourceCode(currentUISourceCode); 252 this._editorContainer.removeUISourceCode(currentUISourceCode);
253 } 253 }
254 }, 254 },
255 255
256 _uiSourceCodeRemoved: function(event) 256 _uiSourceCodeRemoved: function(event)
257 { 257 {
258 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); 258 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
259 this._removeUISourceCodes([uiSourceCode]); 259 this._removeUISourceCodes([uiSourceCode]);
260 }, 260 },
261 261
(...skipping 29 matching lines...) Expand all
291 /** 291 /**
292 * @param {!WebInspector.UISourceCode} uiSourceCode 292 * @param {!WebInspector.UISourceCode} uiSourceCode
293 * @param {number=} lineNumber 0-based 293 * @param {number=} lineNumber 0-based
294 * @param {number=} columnNumber 294 * @param {number=} columnNumber
295 * @param {boolean=} omitFocus 295 * @param {boolean=} omitFocus
296 * @param {boolean=} omitHighlight 296 * @param {boolean=} omitHighlight
297 */ 297 */
298 showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, omitFoc us, omitHighlight) 298 showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, omitFoc us, omitHighlight)
299 { 299 {
300 this._historyManager.updateCurrentState(); 300 this._historyManager.updateCurrentState();
301 var sourceView = this._showFile(uiSourceCode); 301 this._editorContainer.showFile(uiSourceCode)
302 if (typeof lineNumber === "number" && sourceView instanceof WebInspector .UISourceCodeFrame) 302 var currentSourceFrame = this.currentSourceFrame();
303 /** @type {!WebInspector.UISourceCodeFrame} */(sourceView).revealPos ition(lineNumber, columnNumber, !omitHighlight); 303 if (currentSourceFrame && typeof lineNumber === "number")
304 currentSourceFrame.revealPosition(lineNumber, columnNumber, !omitHig hlight);
304 this._historyManager.pushNewState(); 305 this._historyManager.pushNewState();
305 if (!omitFocus) 306 if (!omitFocus)
306 sourceView.focus(); 307 this.visibleView().focus();
307 }, 308 },
308 309
309 /** 310 /**
310 * @param {!WebInspector.UISourceCode} uiSourceCode
311 * @return {!WebInspector.Widget}
312 */
313 _showFile: function(uiSourceCode)
314 {
315 var sourceView = this._getOrCreateSourceView(uiSourceCode);
316 if (this._currentUISourceCode === uiSourceCode)
317 return sourceView;
318
319 var currentFrame = this.currentSourceFrame();
320 if (currentFrame)
321 currentFrame.setSearchableView(null);
322
323 this._currentUISourceCode = uiSourceCode;
324 this._editorContainer.showFile(uiSourceCode);
325 this._updateScriptViewToolbarItems();
326
327 currentFrame = this.currentSourceFrame();
328 if (currentFrame)
329 currentFrame.setSearchableView(this._searchableView);
330
331 return sourceView;
332 },
333
334 /**
335 * @param {!WebInspector.UISourceCode} uiSourceCode 311 * @param {!WebInspector.UISourceCode} uiSourceCode
336 * @return {!WebInspector.Widget} 312 * @return {!WebInspector.Widget}
337 */ 313 */
338 _createSourceView: function(uiSourceCode) 314 _createSourceView: function(uiSourceCode)
339 { 315 {
340 var sourceFrame; 316 var sourceFrame;
341 var sourceView; 317 var sourceView;
342 var contentType = uiSourceCode.contentType(); 318 var contentType = uiSourceCode.contentType();
343 319
344 if (contentType.hasScripts()) 320 if (contentType.hasScripts())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 setExecutionLocation: function(uiLocation) 410 setExecutionLocation: function(uiLocation)
435 { 411 {
436 var sourceView = this._getOrCreateSourceView(uiLocation.uiSourceCode); 412 var sourceView = this._getOrCreateSourceView(uiLocation.uiSourceCode);
437 if (sourceView instanceof WebInspector.UISourceCodeFrame) { 413 if (sourceView instanceof WebInspector.UISourceCodeFrame) {
438 var sourceFrame = /** @type {!WebInspector.UISourceCodeFrame} */(sou rceView); 414 var sourceFrame = /** @type {!WebInspector.UISourceCodeFrame} */(sou rceView);
439 sourceFrame.setExecutionLocation(uiLocation); 415 sourceFrame.setExecutionLocation(uiLocation);
440 this._executionSourceFrame = sourceFrame; 416 this._executionSourceFrame = sourceFrame;
441 } 417 }
442 }, 418 },
443 419
420 /**
421 * @param {!WebInspector.Event} event
422 */
444 _editorClosed: function(event) 423 _editorClosed: function(event)
445 { 424 {
446 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data ); 425 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data );
447 this._historyManager.removeHistoryForSourceCode(uiSourceCode); 426 this._historyManager.removeHistoryForSourceCode(uiSourceCode);
448 427
449 var wasSelected = false; 428 var wasSelected = false;
450 if (this._currentUISourceCode === uiSourceCode) { 429 if (this._currentUISourceCode === uiSourceCode) {
451 delete this._currentUISourceCode; 430 delete this._currentUISourceCode;
452 wasSelected = true; 431 wasSelected = true;
453 } 432 }
454 433
455 // SourcesNavigator does not need to update on EditorClosed. 434 // SourcesNavigator does not need to update on EditorClosed.
456 this._updateScriptViewToolbarItems(); 435 this._updateScriptViewToolbarItems();
457 this._searchableView.resetSearch(); 436 this._searchableView.resetSearch();
458 437
459 var data = {}; 438 var data = {};
460 data.uiSourceCode = uiSourceCode; 439 data.uiSourceCode = uiSourceCode;
461 data.wasSelected = wasSelected; 440 data.wasSelected = wasSelected;
462 this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorClos ed, data); 441 this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorClos ed, data);
463 }, 442 },
464 443
444 /**
445 * @param {!WebInspector.Event} event
446 */
465 _editorSelected: function(event) 447 _editorSelected: function(event)
466 { 448 {
467 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data .currentFile); 449 this._currentUISourceCode = /** @type {!WebInspector.UISourceCode} */(ev ent.data.currentFile);
468 var shouldUseHistoryManager = uiSourceCode !== this._currentUISourceCode && event.data.userGesture; 450 var previousSourceFrame = event.data.previousView instanceof WebInspecto r.UISourceCodeFrame ? event.data.previousView : null;
469 if (shouldUseHistoryManager) 451 if (previousSourceFrame)
470 this._historyManager.updateCurrentState(); 452 previousSourceFrame.setSearchableView(null);
471 var sourceView = this._showFile(uiSourceCode); 453 var currentSourceFrame = event.data.currentView instanceof WebInspector. UISourceCodeFrame ? event.data.currentView : null;
472 if (shouldUseHistoryManager) 454 if (currentSourceFrame)
473 this._historyManager.pushNewState(); 455 currentSourceFrame.setSearchableView(this._searchableView);
474 456
475 this._searchableView.setReplaceable(sourceView instanceof WebInspector.U ISourceCodeFrame && /** @type {!WebInspector.UISourceCodeFrame} */(sourceView).c anEditSource()); 457 this._searchableView.setReplaceable(!!currentSourceFrame && currentSourc eFrame.canEditSource());
476 this._searchableView.refreshSearch(); 458 this._searchableView.refreshSearch();
459 this._updateScriptViewToolbarItems();
477 460
478 this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorSele cted, uiSourceCode); 461 this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorSele cted, this._currentUISourceCode);
479 }, 462 },
480 463
481 /** 464 /**
482 * @param {!WebInspector.UISourceCode} uiSourceCode 465 * @param {!WebInspector.UISourceCode} uiSourceCode
483 */ 466 */
484 sourceRenamed: function(uiSourceCode) 467 sourceRenamed: function(uiSourceCode)
485 { 468 {
486 this._recreateSourceFrameIfNeeded(uiSourceCode); 469 this._recreateSourceFrameIfNeeded(uiSourceCode);
487 }, 470 },
488 471
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 */ 787 */
805 handleAction: function(context, actionId) 788 handleAction: function(context, actionId)
806 { 789 {
807 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); 790 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView);
808 if (!sourcesView) 791 if (!sourcesView)
809 return false; 792 return false;
810 sourcesView._editorContainer.closeAllFiles(); 793 sourcesView._editorContainer.closeAllFiles();
811 return true; 794 return true;
812 } 795 }
813 } 796 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sources/TabbedEditorContainer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698