| OLD | NEW |
| 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @interface | 30 * @interface |
| 31 */ | 31 */ |
| 32 WebInspector.TabbedEditorContainerDelegate = function() { } | 32 WebInspector.TabbedEditorContainerDelegate = function() { }; |
| 33 | 33 |
| 34 WebInspector.TabbedEditorContainerDelegate.prototype = { | 34 WebInspector.TabbedEditorContainerDelegate.prototype = { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.UISourceCode} uiSourceCode | 36 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 37 * @return {!WebInspector.Widget} | 37 * @return {!WebInspector.Widget} |
| 38 */ | 38 */ |
| 39 viewForFile: function(uiSourceCode) { }, | 39 viewForFile: function(uiSourceCode) { }, |
| 40 } | 40 }; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @constructor | 43 * @constructor |
| 44 * @extends {WebInspector.Object} | 44 * @extends {WebInspector.Object} |
| 45 * @param {!WebInspector.TabbedEditorContainerDelegate} delegate | 45 * @param {!WebInspector.TabbedEditorContainerDelegate} delegate |
| 46 * @param {!WebInspector.Setting} setting | 46 * @param {!WebInspector.Setting} setting |
| 47 * @param {string} placeholderText | 47 * @param {string} placeholderText |
| 48 */ | 48 */ |
| 49 WebInspector.TabbedEditorContainer = function(delegate, setting, placeholderText
) | 49 WebInspector.TabbedEditorContainer = function(delegate, setting, placeholderText
) |
| 50 { | 50 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected
, this._tabSelected, this); | 62 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected
, this._tabSelected, this); |
| 63 | 63 |
| 64 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi
ndingCreated, this._onBindingCreated, this); | 64 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi
ndingCreated, this._onBindingCreated, this); |
| 65 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi
ndingRemoved, this._onBindingRemoved, this); | 65 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi
ndingRemoved, this._onBindingRemoved, this); |
| 66 | 66 |
| 67 this._tabIds = new Map(); | 67 this._tabIds = new Map(); |
| 68 this._files = {}; | 68 this._files = {}; |
| 69 | 69 |
| 70 this._previouslyViewedFilesSetting = setting; | 70 this._previouslyViewedFilesSetting = setting; |
| 71 this._history = WebInspector.TabbedEditorContainer.History.fromObject(this._
previouslyViewedFilesSetting.get()); | 71 this._history = WebInspector.TabbedEditorContainer.History.fromObject(this._
previouslyViewedFilesSetting.get()); |
| 72 } | 72 }; |
| 73 | 73 |
| 74 /** @enum {symbol} */ | 74 /** @enum {symbol} */ |
| 75 WebInspector.TabbedEditorContainer.Events = { | 75 WebInspector.TabbedEditorContainer.Events = { |
| 76 EditorSelected: Symbol("EditorSelected"), | 76 EditorSelected: Symbol("EditorSelected"), |
| 77 EditorClosed: Symbol("EditorClosed") | 77 EditorClosed: Symbol("EditorClosed") |
| 78 } | 78 }; |
| 79 | 79 |
| 80 WebInspector.TabbedEditorContainer._tabId = 0; | 80 WebInspector.TabbedEditorContainer._tabId = 0; |
| 81 | 81 |
| 82 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; | 82 WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; |
| 83 | 83 |
| 84 WebInspector.TabbedEditorContainer.prototype = { | 84 WebInspector.TabbedEditorContainer.prototype = { |
| 85 /** | 85 /** |
| 86 * @param {!WebInspector.Event} event | 86 * @param {!WebInspector.Event} event |
| 87 */ | 87 */ |
| 88 _onBindingCreated: function(event) | 88 _onBindingCreated: function(event) |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 /** | 587 /** |
| 588 * @return {?WebInspector.UISourceCode} uiSourceCode | 588 * @return {?WebInspector.UISourceCode} uiSourceCode |
| 589 */ | 589 */ |
| 590 currentFile: function() | 590 currentFile: function() |
| 591 { | 591 { |
| 592 return this._currentFile || null; | 592 return this._currentFile || null; |
| 593 }, | 593 }, |
| 594 | 594 |
| 595 __proto__: WebInspector.Object.prototype | 595 __proto__: WebInspector.Object.prototype |
| 596 } | 596 }; |
| 597 | 597 |
| 598 /** | 598 /** |
| 599 * @constructor | 599 * @constructor |
| 600 * @param {string} url | 600 * @param {string} url |
| 601 * @param {!WebInspector.TextRange=} selectionRange | 601 * @param {!WebInspector.TextRange=} selectionRange |
| 602 * @param {number=} scrollLineNumber | 602 * @param {number=} scrollLineNumber |
| 603 */ | 603 */ |
| 604 WebInspector.TabbedEditorContainer.HistoryItem = function(url, selectionRange, s
crollLineNumber) | 604 WebInspector.TabbedEditorContainer.HistoryItem = function(url, selectionRange, s
crollLineNumber) |
| 605 { | 605 { |
| 606 /** @const */ this.url = url; | 606 /** @const */ this.url = url; |
| 607 /** @const */ this._isSerializable = url.length < WebInspector.TabbedEditorC
ontainer.HistoryItem.serializableUrlLengthLimit; | 607 /** @const */ this._isSerializable = url.length < WebInspector.TabbedEditorC
ontainer.HistoryItem.serializableUrlLengthLimit; |
| 608 this.selectionRange = selectionRange; | 608 this.selectionRange = selectionRange; |
| 609 this.scrollLineNumber = scrollLineNumber; | 609 this.scrollLineNumber = scrollLineNumber; |
| 610 } | 610 }; |
| 611 | 611 |
| 612 WebInspector.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit = 4096
; | 612 WebInspector.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit = 4096
; |
| 613 | 613 |
| 614 /** | 614 /** |
| 615 * @param {!Object} serializedHistoryItem | 615 * @param {!Object} serializedHistoryItem |
| 616 * @return {!WebInspector.TabbedEditorContainer.HistoryItem} | 616 * @return {!WebInspector.TabbedEditorContainer.HistoryItem} |
| 617 */ | 617 */ |
| 618 WebInspector.TabbedEditorContainer.HistoryItem.fromObject = function(serializedH
istoryItem) | 618 WebInspector.TabbedEditorContainer.HistoryItem.fromObject = function(serializedH
istoryItem) |
| 619 { | 619 { |
| 620 var selectionRange = serializedHistoryItem.selectionRange ? WebInspector.Tex
tRange.fromObject(serializedHistoryItem.selectionRange) : undefined; | 620 var selectionRange = serializedHistoryItem.selectionRange ? WebInspector.Tex
tRange.fromObject(serializedHistoryItem.selectionRange) : undefined; |
| 621 return new WebInspector.TabbedEditorContainer.HistoryItem(serializedHistoryI
tem.url, selectionRange, serializedHistoryItem.scrollLineNumber); | 621 return new WebInspector.TabbedEditorContainer.HistoryItem(serializedHistoryI
tem.url, selectionRange, serializedHistoryItem.scrollLineNumber); |
| 622 } | 622 }; |
| 623 | 623 |
| 624 WebInspector.TabbedEditorContainer.HistoryItem.prototype = { | 624 WebInspector.TabbedEditorContainer.HistoryItem.prototype = { |
| 625 /** | 625 /** |
| 626 * @return {?Object} | 626 * @return {?Object} |
| 627 */ | 627 */ |
| 628 serializeToObject: function() | 628 serializeToObject: function() |
| 629 { | 629 { |
| 630 if (!this._isSerializable) | 630 if (!this._isSerializable) |
| 631 return null; | 631 return null; |
| 632 var serializedHistoryItem = {}; | 632 var serializedHistoryItem = {}; |
| 633 serializedHistoryItem.url = this.url; | 633 serializedHistoryItem.url = this.url; |
| 634 serializedHistoryItem.selectionRange = this.selectionRange; | 634 serializedHistoryItem.selectionRange = this.selectionRange; |
| 635 serializedHistoryItem.scrollLineNumber = this.scrollLineNumber; | 635 serializedHistoryItem.scrollLineNumber = this.scrollLineNumber; |
| 636 return serializedHistoryItem; | 636 return serializedHistoryItem; |
| 637 } | 637 } |
| 638 } | 638 }; |
| 639 | 639 |
| 640 /** | 640 /** |
| 641 * @constructor | 641 * @constructor |
| 642 * @param {!Array.<!WebInspector.TabbedEditorContainer.HistoryItem>} items | 642 * @param {!Array.<!WebInspector.TabbedEditorContainer.HistoryItem>} items |
| 643 */ | 643 */ |
| 644 WebInspector.TabbedEditorContainer.History = function(items) | 644 WebInspector.TabbedEditorContainer.History = function(items) |
| 645 { | 645 { |
| 646 this._items = items; | 646 this._items = items; |
| 647 this._rebuildItemIndex(); | 647 this._rebuildItemIndex(); |
| 648 } | 648 }; |
| 649 | 649 |
| 650 /** | 650 /** |
| 651 * @param {!Array.<!Object>} serializedHistory | 651 * @param {!Array.<!Object>} serializedHistory |
| 652 * @return {!WebInspector.TabbedEditorContainer.History} | 652 * @return {!WebInspector.TabbedEditorContainer.History} |
| 653 */ | 653 */ |
| 654 WebInspector.TabbedEditorContainer.History.fromObject = function(serializedHisto
ry) | 654 WebInspector.TabbedEditorContainer.History.fromObject = function(serializedHisto
ry) |
| 655 { | 655 { |
| 656 var items = []; | 656 var items = []; |
| 657 for (var i = 0; i < serializedHistory.length; ++i) | 657 for (var i = 0; i < serializedHistory.length; ++i) |
| 658 items.push(WebInspector.TabbedEditorContainer.HistoryItem.fromObject(ser
ializedHistory[i])); | 658 items.push(WebInspector.TabbedEditorContainer.HistoryItem.fromObject(ser
ializedHistory[i])); |
| 659 return new WebInspector.TabbedEditorContainer.History(items); | 659 return new WebInspector.TabbedEditorContainer.History(items); |
| 660 } | 660 }; |
| 661 | 661 |
| 662 WebInspector.TabbedEditorContainer.History.prototype = { | 662 WebInspector.TabbedEditorContainer.History.prototype = { |
| 663 /** | 663 /** |
| 664 * @param {string} url | 664 * @param {string} url |
| 665 * @return {number} | 665 * @return {number} |
| 666 */ | 666 */ |
| 667 index: function(url) | 667 index: function(url) |
| 668 { | 668 { |
| 669 return this._itemsIndex.has(url) ? /** @type {number} */(this._itemsInde
x.get(url)) : -1; | 669 return this._itemsIndex.has(url) ? /** @type {number} */(this._itemsInde
x.get(url)) : -1; |
| 670 }, | 670 }, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 /** | 783 /** |
| 784 * @return {!Array.<string>} | 784 * @return {!Array.<string>} |
| 785 */ | 785 */ |
| 786 _urls: function() | 786 _urls: function() |
| 787 { | 787 { |
| 788 var result = []; | 788 var result = []; |
| 789 for (var i = 0; i < this._items.length; ++i) | 789 for (var i = 0; i < this._items.length; ++i) |
| 790 result.push(this._items[i].url); | 790 result.push(this._items[i].url); |
| 791 return result; | 791 return result; |
| 792 } | 792 } |
| 793 } | 793 }; |
| 794 | 794 |
| 795 /** | 795 /** |
| 796 * @constructor | 796 * @constructor |
| 797 * @implements {WebInspector.TabbedPaneTabDelegate} | 797 * @implements {WebInspector.TabbedPaneTabDelegate} |
| 798 * @param {!WebInspector.TabbedEditorContainer} editorContainer | 798 * @param {!WebInspector.TabbedEditorContainer} editorContainer |
| 799 */ | 799 */ |
| 800 WebInspector.EditorContainerTabDelegate = function(editorContainer) | 800 WebInspector.EditorContainerTabDelegate = function(editorContainer) |
| 801 { | 801 { |
| 802 this._editorContainer = editorContainer; | 802 this._editorContainer = editorContainer; |
| 803 } | 803 }; |
| 804 | 804 |
| 805 WebInspector.EditorContainerTabDelegate.prototype = { | 805 WebInspector.EditorContainerTabDelegate.prototype = { |
| 806 /** | 806 /** |
| 807 * @override | 807 * @override |
| 808 * @param {!WebInspector.TabbedPane} tabbedPane | 808 * @param {!WebInspector.TabbedPane} tabbedPane |
| 809 * @param {!Array.<string>} ids | 809 * @param {!Array.<string>} ids |
| 810 */ | 810 */ |
| 811 closeTabs: function(tabbedPane, ids) | 811 closeTabs: function(tabbedPane, ids) |
| 812 { | 812 { |
| 813 this._editorContainer._closeTabs(ids); | 813 this._editorContainer._closeTabs(ids); |
| 814 }, | 814 }, |
| 815 | 815 |
| 816 /** | 816 /** |
| 817 * @override | 817 * @override |
| 818 * @param {string} tabId | 818 * @param {string} tabId |
| 819 * @param {!WebInspector.ContextMenu} contextMenu | 819 * @param {!WebInspector.ContextMenu} contextMenu |
| 820 */ | 820 */ |
| 821 onContextMenu: function(tabId, contextMenu) | 821 onContextMenu: function(tabId, contextMenu) |
| 822 { | 822 { |
| 823 this._editorContainer._onContextMenu(tabId, contextMenu); | 823 this._editorContainer._onContextMenu(tabId, contextMenu); |
| 824 } | 824 } |
| 825 } | 825 }; |
| OLD | NEW |