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

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

Issue 2585393003: DevTools: [Persistence] implement Persistence.subscribeForBindingEvents (Closed)
Patch Set: address comments Created 3 years, 12 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
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 * @implements {Sources.TabbedEditorContainerDelegate} 5 * @implements {Sources.TabbedEditorContainerDelegate}
6 * @implements {UI.Searchable} 6 * @implements {UI.Searchable}
7 * @implements {UI.Replaceable} 7 * @implements {UI.Replaceable}
8 * @unrestricted 8 * @unrestricted
9 */ 9 */
10 Sources.SourcesView = class extends UI.VBox { 10 Sources.SourcesView = class extends UI.VBox {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 * @param {!Array.<!Sources.SourcesView.EditorAction>} actions 45 * @param {!Array.<!Sources.SourcesView.EditorAction>} actions
46 * @this {Sources.SourcesView} 46 * @this {Sources.SourcesView}
47 */ 47 */
48 function appendButtonsForExtensions(actions) { 48 function appendButtonsForExtensions(actions) {
49 for (var i = 0; i < actions.length; ++i) 49 for (var i = 0; i < actions.length; ++i)
50 this._toolbarEditorActions.appendToolbarItem(actions[i].button(this)); 50 this._toolbarEditorActions.appendToolbarItem(actions[i].button(this));
51 } 51 }
52 this._scriptViewToolbar = new UI.Toolbar('', this._toolbarContainerElement); 52 this._scriptViewToolbar = new UI.Toolbar('', this._toolbarContainerElement);
53 this._scriptViewToolbar.element.style.flex = 'auto'; 53 this._scriptViewToolbar.element.style.flex = 'auto';
54 this._bottomToolbar = new UI.Toolbar('', this._toolbarContainerElement); 54 this._bottomToolbar = new UI.Toolbar('', this._toolbarContainerElement);
55 this._bindingChangeBound = this._onBindingChanged.bind(this);
55 56
56 UI.startBatchUpdate(); 57 UI.startBatchUpdate();
57 workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); 58 workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));
58 UI.endBatchUpdate(); 59 UI.endBatchUpdate();
59 60
60 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, thi s._uiSourceCodeAdded, this); 61 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, thi s._uiSourceCodeAdded, this);
61 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t his._uiSourceCodeRemoved, this); 62 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t his._uiSourceCodeRemoved, this);
62 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._ projectRemoved.bind(this), this); 63 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._ projectRemoved.bind(this), this);
63 64
64 /** 65 /**
(...skipping 17 matching lines...) Expand all
82 UI.viewManager.showView('sources'); 83 UI.viewManager.showView('sources');
83 for (var i = 0; i < unsavedSourceCodes.length; ++i) 84 for (var i = 0; i < unsavedSourceCodes.length; ++i)
84 Common.Revealer.reveal(unsavedSourceCodes[i]); 85 Common.Revealer.reveal(unsavedSourceCodes[i]);
85 } 86 }
86 87
87 if (!window.opener) 88 if (!window.opener)
88 window.addEventListener('beforeunload', handleBeforeUnload, true); 89 window.addEventListener('beforeunload', handleBeforeUnload, true);
89 90
90 this._shortcuts = {}; 91 this._shortcuts = {};
91 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal se); 92 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal se);
92
93 Persistence.persistence.addEventListener(
94 Persistence.Persistence.Events.BindingCreated, this._onBindingChanged, t his);
95 Persistence.persistence.addEventListener(
96 Persistence.Persistence.Events.BindingRemoved, this._onBindingChanged, t his);
97 } 93 }
98 94
99 /** 95 /**
100 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event= ):boolean)} registerShortcutDelegate 96 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event= ):boolean)} registerShortcutDelegate
101 */ 97 */
102 registerShortcuts(registerShortcutDelegate) { 98 registerShortcuts(registerShortcutDelegate) {
103 /** 99 /**
104 * @this {Sources.SourcesView} 100 * @this {Sources.SourcesView}
105 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts 101 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts
106 * @param {function(!Event=):boolean} handler 102 * @param {function(!Event=):boolean} handler
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 * @param {!Workspace.UISourceCode} uiSourceCode 388 * @param {!Workspace.UISourceCode} uiSourceCode
393 */ 389 */
394 _removeSourceFrame(uiSourceCode) { 390 _removeSourceFrame(uiSourceCode) {
395 var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode); 391 var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode);
396 this._sourceViewByUISourceCode.remove(uiSourceCode); 392 this._sourceViewByUISourceCode.remove(uiSourceCode);
397 uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this); 393 uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
398 if (sourceView && sourceView instanceof Sources.UISourceCodeFrame) 394 if (sourceView && sourceView instanceof Sources.UISourceCodeFrame)
399 /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose(); 395 /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose();
400 } 396 }
401 397
402 /** 398 _onBindingChanged() {
403 * @param {!Common.Event} event
404 */
405 _onBindingChanged(event) {
406 if (!this._executionLocation)
407 return;
408 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
409 var uiSourceCode = this._executionLocation.uiSourceCode;
410 if (binding.network !== uiSourceCode)
411 return;
412 this.setExecutionLocation(this._executionLocation); 399 this.setExecutionLocation(this._executionLocation);
413 this.showSourceLocation( 400 this.showSourceLocation(
414 this._executionLocation.uiSourceCode, this._executionLocation.lineNumber , this._executionLocation.columnNumber); 401 this._executionLocation.uiSourceCode, this._executionLocation.lineNumber , this._executionLocation.columnNumber);
415 } 402 }
416 403
417 clearCurrentExecutionLine() { 404 clearCurrentExecutionLine() {
418 if (this._executionSourceFrame) 405 if (!this._executionLocation)
419 this._executionSourceFrame.clearExecutionLine(); 406 return;
407 Persistence.persistence.unsubscribeFromBindingEvent(this._executionLocation. uiSourceCode, this._bindingChangeBound);
408 this._executionSourceFrame.clearExecutionLine();
420 this._executionSourceFrame = null; 409 this._executionSourceFrame = null;
421 this._executionLocation = null; 410 this._executionLocation = null;
422 } 411 }
423 412
424 /** 413 /**
425 * @param {!Workspace.UILocation} uiLocation 414 * @param {!Workspace.UILocation} uiLocation
426 */ 415 */
427 setExecutionLocation(uiLocation) { 416 setExecutionLocation(uiLocation) {
428 this.clearCurrentExecutionLine(); 417 this.clearCurrentExecutionLine();
429 var binding = Persistence.persistence.binding(uiLocation.uiSourceCode); 418 var binding = Persistence.persistence.binding(uiLocation.uiSourceCode);
430 var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode; 419 var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode;
431 var sourceView = this._getOrCreateSourceView(uiSourceCode); 420 var sourceView = this._getOrCreateSourceView(uiSourceCode);
432 if (sourceView instanceof Sources.UISourceCodeFrame) { 421 if (!(sourceView instanceof Sources.UISourceCodeFrame))
433 var sourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceView); 422 return;
434 sourceFrame.setExecutionLocation( 423 Persistence.persistence.subscribeForBindingEvent(uiLocation.uiSourceCode, th is._bindingChangeBound);
435 new Workspace.UILocation(uiSourceCode, uiLocation.lineNumber, uiLocati on.columnNumber)); 424 var sourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceView);
436 this._executionSourceFrame = sourceFrame; 425 sourceFrame.setExecutionLocation(
437 this._executionLocation = uiLocation; 426 new Workspace.UILocation(uiSourceCode, uiLocation.lineNumber, uiLocation .columnNumber));
438 } 427 this._executionSourceFrame = sourceFrame;
428 this._executionLocation = uiLocation;
439 } 429 }
440 430
441 /** 431 /**
442 * @param {!Common.Event} event 432 * @param {!Common.Event} event
443 */ 433 */
444 _editorClosed(event) { 434 _editorClosed(event) {
445 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); 435 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
446 this._historyManager.removeHistoryForSourceCode(uiSourceCode); 436 this._historyManager.removeHistoryForSourceCode(uiSourceCode);
447 437
448 var wasSelected = false; 438 var wasSelected = false;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 * @return {boolean} 768 * @return {boolean}
779 */ 769 */
780 handleAction(context, actionId) { 770 handleAction(context, actionId) {
781 var sourcesView = UI.context.flavor(Sources.SourcesView); 771 var sourcesView = UI.context.flavor(Sources.SourcesView);
782 if (!sourcesView) 772 if (!sourcesView)
783 return false; 773 return false;
784 sourcesView._editorContainer.closeAllFiles(); 774 sourcesView._editorContainer.closeAllFiles();
785 return true; 775 return true;
786 } 776 }
787 }; 777 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698