Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @interface | 5 * @interface |
| 6 */ | 6 */ |
| 7 UI.View = function() {}; | 7 UI.View = function() {}; |
| 8 | 8 |
| 9 UI.View.prototype = { | 9 UI.View.prototype = { |
| 10 /** | 10 /** |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 | 571 |
| 572 super(manager, tabbedPane, revealCallback); | 572 super(manager, tabbedPane, revealCallback); |
| 573 this._tabbedPane = tabbedPane; | 573 this._tabbedPane = tabbedPane; |
| 574 this._allowReorder = allowReorder; | 574 this._allowReorder = allowReorder; |
| 575 | 575 |
| 576 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this); | 576 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this); |
| 577 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC losed, this); | 577 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC losed, this); |
| 578 this._closeableTabSetting = Common.settings.createSetting(location + '-close ableTabs', {}); | 578 this._closeableTabSetting = Common.settings.createSetting(location + '-close ableTabs', {}); |
| 579 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder' , {}); | 579 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder' , {}); |
| 580 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this ._persistTabOrder, this); | 580 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this ._persistTabOrder, this); |
| 581 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabsShown, this._tabs Shown, this); | |
| 581 if (restoreSelection) | 582 if (restoreSelection) |
| 582 this._lastSelectedTabSetting = Common.settings.createSetting(location + '- selectedTab', ''); | 583 this._lastSelectedTabSetting = Common.settings.createSetting(location + '- selectedTab', ''); |
| 583 this._defaultTab = defaultTab; | 584 this._defaultTab = defaultTab; |
| 584 | 585 |
| 585 /** @type {!Map.<string, !UI.View>} */ | 586 /** @type {!Map.<string, !UI.View>} */ |
| 586 this._views = new Map(); | 587 this._views = new Map(); |
| 587 | 588 |
| 588 if (location) | 589 if (location) |
| 589 this.appendApplicableItems(location); | 590 this.appendApplicableItems(location); |
| 590 } | 591 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 * @param {!Common.Event} event | 731 * @param {!Common.Event} event |
| 731 */ | 732 */ |
| 732 _tabSelected(event) { | 733 _tabSelected(event) { |
| 733 var tabId = /** @type {string} */ (event.data.tabId); | 734 var tabId = /** @type {string} */ (event.data.tabId); |
| 734 if (this._lastSelectedTabSetting && event.data['isUserGesture']) | 735 if (this._lastSelectedTabSetting && event.data['isUserGesture']) |
| 735 this._lastSelectedTabSetting.set(tabId); | 736 this._lastSelectedTabSetting.set(tabId); |
| 736 var view = this._views.get(tabId); | 737 var view = this._views.get(tabId); |
| 737 if (!view) | 738 if (!view) |
| 738 return; | 739 return; |
| 739 | 740 |
| 740 this._materializeWidget(view); | 741 if (this._tabbedPane.isShowing()) |
| 742 this._materializeWidget(view); | |
| 741 | 743 |
| 742 if (view.isCloseable()) { | 744 if (view.isCloseable()) { |
| 743 var tabs = this._closeableTabSetting.get(); | 745 var tabs = this._closeableTabSetting.get(); |
| 744 if (!tabs[tabId]) { | 746 if (!tabs[tabId]) { |
| 745 tabs[tabId] = true; | 747 tabs[tabId] = true; |
| 746 this._closeableTabSetting.set(tabs); | 748 this._closeableTabSetting.set(tabs); |
| 747 } | 749 } |
| 748 } | 750 } |
| 749 } | 751 } |
| 750 | 752 |
| 751 /** | 753 /** |
| 752 * @param {!Common.Event} event | 754 * @param {!Common.Event} event |
| 753 */ | 755 */ |
| 756 _tabsShown(event) { | |
|
dgozman
2017/01/10 21:51:45
We can instead materialize when our wrapper (UI.Vi
luoe
2017/01/10 23:15:17
Brilliant idea
| |
| 757 var view = event.data ? this._views.get(event.data.id) : null; | |
| 758 if (!view) | |
| 759 return; | |
| 760 this._materializeWidget(view); | |
| 761 } | |
| 762 | |
| 763 /** | |
| 764 * @param {!Common.Event} event | |
| 765 */ | |
| 754 _tabClosed(event) { | 766 _tabClosed(event) { |
| 755 var id = /** @type {string} */ (event.data['tabId']); | 767 var id = /** @type {string} */ (event.data['tabId']); |
| 756 var tabs = this._closeableTabSetting.get(); | 768 var tabs = this._closeableTabSetting.get(); |
| 757 if (tabs[id]) { | 769 if (tabs[id]) { |
| 758 delete tabs[id]; | 770 delete tabs[id]; |
| 759 this._closeableTabSetting.set(tabs); | 771 this._closeableTabSetting.set(tabs); |
| 760 } | 772 } |
| 761 } | 773 } |
| 762 | 774 |
| 763 /** | 775 /** |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 appendApplicableItems(locationName) { | 872 appendApplicableItems(locationName) { |
| 861 for (var view of this._manager._viewsForLocation(locationName)) | 873 for (var view of this._manager._viewsForLocation(locationName)) |
| 862 this.appendView(view); | 874 this.appendView(view); |
| 863 } | 875 } |
| 864 }; | 876 }; |
| 865 | 877 |
| 866 /** | 878 /** |
| 867 * @type {!UI.ViewManager} | 879 * @type {!UI.ViewManager} |
| 868 */ | 880 */ |
| 869 UI.viewManager; | 881 UI.viewManager; |
| OLD | NEW |