OLD | NEW |
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return binding.network.isDirty(); | 91 return binding.network.isDirty(); |
92 return sourceCode.isDirty(); | 92 return sourceCode.isDirty(); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 if (!window.opener) | 96 if (!window.opener) |
97 window.addEventListener("beforeunload", handleBeforeUnload, true); | 97 window.addEventListener("beforeunload", handleBeforeUnload, true); |
98 | 98 |
99 this._shortcuts = {}; | 99 this._shortcuts = {}; |
100 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal
se); | 100 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal
se); |
101 } | 101 }; |
102 | 102 |
103 /** @enum {symbol} */ | 103 /** @enum {symbol} */ |
104 WebInspector.SourcesView.Events = { | 104 WebInspector.SourcesView.Events = { |
105 EditorClosed: Symbol("EditorClosed"), | 105 EditorClosed: Symbol("EditorClosed"), |
106 EditorSelected: Symbol("EditorSelected"), | 106 EditorSelected: Symbol("EditorSelected"), |
107 } | 107 }; |
108 | 108 |
109 WebInspector.SourcesView.prototype = { | 109 WebInspector.SourcesView.prototype = { |
110 /** | 110 /** |
111 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func
tion(!Event=):boolean)} registerShortcutDelegate | 111 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func
tion(!Event=):boolean)} registerShortcutDelegate |
112 */ | 112 */ |
113 registerShortcuts: function(registerShortcutDelegate) | 113 registerShortcuts: function(registerShortcutDelegate) |
114 { | 114 { |
115 /** | 115 /** |
116 * @this {WebInspector.SourcesView} | 116 * @this {WebInspector.SourcesView} |
117 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts | 117 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 _projectRemoved: function(event) | 300 _projectRemoved: function(event) |
301 { | 301 { |
302 var project = event.data; | 302 var project = event.data; |
303 var uiSourceCodes = project.uiSourceCodes(); | 303 var uiSourceCodes = project.uiSourceCodes(); |
304 this._removeUISourceCodes(uiSourceCodes); | 304 this._removeUISourceCodes(uiSourceCodes); |
305 }, | 305 }, |
306 | 306 |
307 _updateScriptViewToolbarItems: function() | 307 _updateScriptViewToolbarItems: function() |
308 { | 308 { |
309 this._scriptViewToolbar.removeToolbarItems(); | 309 this._scriptViewToolbar.removeToolbarItems(); |
310 var view = this.visibleView() | 310 var view = this.visibleView(); |
311 if (view instanceof WebInspector.SimpleView) { | 311 if (view instanceof WebInspector.SimpleView) { |
312 for (var item of (/** @type {?WebInspector.SimpleView} */(view)).syn
cToolbarItems()) | 312 for (var item of (/** @type {?WebInspector.SimpleView} */(view)).syn
cToolbarItems()) |
313 this._scriptViewToolbar.appendToolbarItem(item); | 313 this._scriptViewToolbar.appendToolbarItem(item); |
314 } | 314 } |
315 }, | 315 }, |
316 | 316 |
317 /** | 317 /** |
318 * @param {!WebInspector.UISourceCode} uiSourceCode | 318 * @param {!WebInspector.UISourceCode} uiSourceCode |
319 * @param {number=} lineNumber 0-based | 319 * @param {number=} lineNumber 0-based |
320 * @param {number=} columnNumber | 320 * @param {number=} columnNumber |
321 * @param {boolean=} omitFocus | 321 * @param {boolean=} omitFocus |
322 * @param {boolean=} omitHighlight | 322 * @param {boolean=} omitHighlight |
323 */ | 323 */ |
324 showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, omitFoc
us, omitHighlight) | 324 showSourceLocation: function(uiSourceCode, lineNumber, columnNumber, omitFoc
us, omitHighlight) |
325 { | 325 { |
326 this._historyManager.updateCurrentState(); | 326 this._historyManager.updateCurrentState(); |
327 this._editorContainer.showFile(uiSourceCode) | 327 this._editorContainer.showFile(uiSourceCode); |
328 var currentSourceFrame = this.currentSourceFrame(); | 328 var currentSourceFrame = this.currentSourceFrame(); |
329 if (currentSourceFrame && typeof lineNumber === "number") | 329 if (currentSourceFrame && typeof lineNumber === "number") |
330 currentSourceFrame.revealPosition(lineNumber, columnNumber, !omitHig
hlight); | 330 currentSourceFrame.revealPosition(lineNumber, columnNumber, !omitHig
hlight); |
331 this._historyManager.pushNewState(); | 331 this._historyManager.pushNewState(); |
332 if (!omitFocus) | 332 if (!omitFocus) |
333 this.visibleView().focus(); | 333 this.visibleView().focus(); |
334 }, | 334 }, |
335 | 335 |
336 /** | 336 /** |
337 * @param {!WebInspector.UISourceCode} uiSourceCode | 337 * @param {!WebInspector.UISourceCode} uiSourceCode |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 706 |
707 /** | 707 /** |
708 * @param {boolean} active | 708 * @param {boolean} active |
709 */ | 709 */ |
710 toggleBreakpointsActiveState: function(active) | 710 toggleBreakpointsActiveState: function(active) |
711 { | 711 { |
712 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv
ated", !active); | 712 this._editorContainer.view.element.classList.toggle("breakpoints-deactiv
ated", !active); |
713 }, | 713 }, |
714 | 714 |
715 __proto__: WebInspector.VBox.prototype | 715 __proto__: WebInspector.VBox.prototype |
716 } | 716 }; |
717 | 717 |
718 /** | 718 /** |
719 * @interface | 719 * @interface |
720 */ | 720 */ |
721 WebInspector.SourcesView.EditorAction = function() | 721 WebInspector.SourcesView.EditorAction = function() |
722 { | 722 { |
723 } | 723 }; |
724 | 724 |
725 WebInspector.SourcesView.EditorAction.prototype = { | 725 WebInspector.SourcesView.EditorAction.prototype = { |
726 /** | 726 /** |
727 * @param {!WebInspector.SourcesView} sourcesView | 727 * @param {!WebInspector.SourcesView} sourcesView |
728 * @return {!WebInspector.ToolbarButton} | 728 * @return {!WebInspector.ToolbarButton} |
729 */ | 729 */ |
730 button: function(sourcesView) { } | 730 button: function(sourcesView) { } |
731 } | 731 }; |
732 | 732 |
733 /** | 733 /** |
734 * @constructor | 734 * @constructor |
735 * @implements {WebInspector.ActionDelegate} | 735 * @implements {WebInspector.ActionDelegate} |
736 */ | 736 */ |
737 WebInspector.SourcesView.SwitchFileActionDelegate = function() | 737 WebInspector.SourcesView.SwitchFileActionDelegate = function() |
738 { | 738 { |
739 } | 739 }; |
740 | 740 |
741 /** | 741 /** |
742 * @param {!WebInspector.UISourceCode} currentUISourceCode | 742 * @param {!WebInspector.UISourceCode} currentUISourceCode |
743 * @return {?WebInspector.UISourceCode} | 743 * @return {?WebInspector.UISourceCode} |
744 */ | 744 */ |
745 WebInspector.SourcesView.SwitchFileActionDelegate._nextFile = function(currentUI
SourceCode) | 745 WebInspector.SourcesView.SwitchFileActionDelegate._nextFile = function(currentUI
SourceCode) |
746 { | 746 { |
747 /** | 747 /** |
748 * @param {string} name | 748 * @param {string} name |
749 * @return {string} | 749 * @return {string} |
(...skipping 15 matching lines...) Expand all Loading... |
765 if (url !== uiSourceCode.parentURL()) | 765 if (url !== uiSourceCode.parentURL()) |
766 continue; | 766 continue; |
767 if (fileNamePrefix(uiSourceCode.name()) === namePrefix) | 767 if (fileNamePrefix(uiSourceCode.name()) === namePrefix) |
768 candidates.push(uiSourceCode.name()); | 768 candidates.push(uiSourceCode.name()); |
769 } | 769 } |
770 candidates.sort(String.naturalOrderComparator); | 770 candidates.sort(String.naturalOrderComparator); |
771 var index = mod(candidates.indexOf(name) + 1, candidates.length); | 771 var index = mod(candidates.indexOf(name) + 1, candidates.length); |
772 var fullURL = (url ? url + "/" : "") + candidates[index]; | 772 var fullURL = (url ? url + "/" : "") + candidates[index]; |
773 var nextUISourceCode = currentUISourceCode.project().uiSourceCodeForURL(full
URL); | 773 var nextUISourceCode = currentUISourceCode.project().uiSourceCodeForURL(full
URL); |
774 return nextUISourceCode !== currentUISourceCode ? nextUISourceCode : null; | 774 return nextUISourceCode !== currentUISourceCode ? nextUISourceCode : null; |
775 } | 775 }; |
776 | 776 |
777 | 777 |
778 WebInspector.SourcesView.SwitchFileActionDelegate.prototype = { | 778 WebInspector.SourcesView.SwitchFileActionDelegate.prototype = { |
779 /** | 779 /** |
780 * @override | 780 * @override |
781 * @param {!WebInspector.Context} context | 781 * @param {!WebInspector.Context} context |
782 * @param {string} actionId | 782 * @param {string} actionId |
783 * @return {boolean} | 783 * @return {boolean} |
784 */ | 784 */ |
785 handleAction: function(context, actionId) | 785 handleAction: function(context, actionId) |
786 { | 786 { |
787 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); | 787 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); |
788 var currentUISourceCode = sourcesView.currentUISourceCode(); | 788 var currentUISourceCode = sourcesView.currentUISourceCode(); |
789 if (!currentUISourceCode) | 789 if (!currentUISourceCode) |
790 return false; | 790 return false; |
791 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate
._nextFile(currentUISourceCode); | 791 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate
._nextFile(currentUISourceCode); |
792 if (!nextUISourceCode) | 792 if (!nextUISourceCode) |
793 return false; | 793 return false; |
794 sourcesView.showSourceLocation(nextUISourceCode); | 794 sourcesView.showSourceLocation(nextUISourceCode); |
795 return true; | 795 return true; |
796 } | 796 } |
797 } | 797 }; |
798 | 798 |
799 /** | 799 /** |
800 * @constructor | 800 * @constructor |
801 * @implements {WebInspector.ActionDelegate} | 801 * @implements {WebInspector.ActionDelegate} |
802 */ | 802 */ |
803 WebInspector.SourcesView.CloseAllActionDelegate = function() | 803 WebInspector.SourcesView.CloseAllActionDelegate = function() |
804 { | 804 { |
805 } | 805 }; |
806 | 806 |
807 WebInspector.SourcesView.CloseAllActionDelegate.prototype = { | 807 WebInspector.SourcesView.CloseAllActionDelegate.prototype = { |
808 /** | 808 /** |
809 * @override | 809 * @override |
810 * @param {!WebInspector.Context} context | 810 * @param {!WebInspector.Context} context |
811 * @param {string} actionId | 811 * @param {string} actionId |
812 * @return {boolean} | 812 * @return {boolean} |
813 */ | 813 */ |
814 handleAction: function(context, actionId) | 814 handleAction: function(context, actionId) |
815 { | 815 { |
816 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); | 816 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); |
817 if (!sourcesView) | 817 if (!sourcesView) |
818 return false; | 818 return false; |
819 sourcesView._editorContainer.closeAllFiles(); | 819 sourcesView._editorContainer.closeAllFiles(); |
820 return true; | 820 return true; |
821 } | 821 } |
822 } | 822 }; |
OLD | NEW |