| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 var shouldFocus = this.element.hasFocus(); | 435 var shouldFocus = this.element.hasFocus(); |
| 436 this.setDefaultFocusedElement(null); | 436 this.setDefaultFocusedElement(null); |
| 437 this._view[UI.View._widgetSymbol] = widget; | 437 this._view[UI.View._widgetSymbol] = widget; |
| 438 widget.show(this.element); | 438 widget.show(this.element); |
| 439 if (shouldFocus) | 439 if (shouldFocus) |
| 440 widget.focus(); | 440 widget.focus(); |
| 441 })); | 441 })); |
| 442 this._materializePromise = Promise.all(promises); | 442 this._materializePromise = Promise.all(promises); |
| 443 return this._materializePromise; | 443 return this._materializePromise; |
| 444 } | 444 } |
| 445 |
| 446 /** |
| 447 * @override |
| 448 */ |
| 449 wasShown() { |
| 450 this._materialize(); |
| 451 } |
| 445 }; | 452 }; |
| 446 | 453 |
| 447 /** | 454 /** |
| 448 * @unrestricted | 455 * @unrestricted |
| 449 */ | 456 */ |
| 450 UI.ViewManager._ExpandableContainerWidget = class extends UI.VBox { | 457 UI.ViewManager._ExpandableContainerWidget = class extends UI.VBox { |
| 451 /** | 458 /** |
| 452 * @param {!UI.View} view | 459 * @param {!UI.View} view |
| 453 */ | 460 */ |
| 454 constructor(view) { | 461 constructor(view) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 /** | 709 /** |
| 703 * @override | 710 * @override |
| 704 * @param {!UI.View} view | 711 * @param {!UI.View} view |
| 705 * @param {?UI.View=} insertBefore | 712 * @param {?UI.View=} insertBefore |
| 706 * @return {!Promise} | 713 * @return {!Promise} |
| 707 */ | 714 */ |
| 708 showView(view, insertBefore) { | 715 showView(view, insertBefore) { |
| 709 this.appendView(view, insertBefore); | 716 this.appendView(view, insertBefore); |
| 710 this._tabbedPane.selectTab(view.viewId()); | 717 this._tabbedPane.selectTab(view.viewId()); |
| 711 this._tabbedPane.focus(); | 718 this._tabbedPane.focus(); |
| 712 return this._materializeWidget(view); | 719 var widget = /** @type {!UI.ViewManager._ContainerWidget} */ (this._tabbedPa
ne.tabView(view.viewId())); |
| 720 return widget._materialize(); |
| 713 } | 721 } |
| 714 | 722 |
| 715 /** | 723 /** |
| 716 * @param {!UI.View} view | 724 * @param {!UI.View} view |
| 717 * @override | 725 * @override |
| 718 */ | 726 */ |
| 719 removeView(view) { | 727 removeView(view) { |
| 720 if (!this._tabbedPane.hasTab(view.viewId())) | 728 if (!this._tabbedPane.hasTab(view.viewId())) |
| 721 return; | 729 return; |
| 722 | 730 |
| 723 delete view[UI.ViewManager._Location.symbol]; | 731 delete view[UI.ViewManager._Location.symbol]; |
| 724 this._manager._views.delete(view.viewId()); | 732 this._manager._views.delete(view.viewId()); |
| 725 this._views.delete(view.viewId()); | 733 this._views.delete(view.viewId()); |
| 726 this._tabbedPane.closeTab(view.viewId()); | 734 this._tabbedPane.closeTab(view.viewId()); |
| 727 } | 735 } |
| 728 | 736 |
| 729 /** | 737 /** |
| 730 * @param {!Common.Event} event | 738 * @param {!Common.Event} event |
| 731 */ | 739 */ |
| 732 _tabSelected(event) { | 740 _tabSelected(event) { |
| 733 var tabId = /** @type {string} */ (event.data.tabId); | 741 var tabId = /** @type {string} */ (event.data.tabId); |
| 734 if (this._lastSelectedTabSetting && event.data['isUserGesture']) | 742 if (this._lastSelectedTabSetting && event.data['isUserGesture']) |
| 735 this._lastSelectedTabSetting.set(tabId); | 743 this._lastSelectedTabSetting.set(tabId); |
| 736 var view = this._views.get(tabId); | 744 var view = this._views.get(tabId); |
| 737 if (!view) | 745 if (!view) |
| 738 return; | 746 return; |
| 739 | 747 |
| 740 this._materializeWidget(view); | |
| 741 | |
| 742 if (view.isCloseable()) { | 748 if (view.isCloseable()) { |
| 743 var tabs = this._closeableTabSetting.get(); | 749 var tabs = this._closeableTabSetting.get(); |
| 744 if (!tabs[tabId]) { | 750 if (!tabs[tabId]) { |
| 745 tabs[tabId] = true; | 751 tabs[tabId] = true; |
| 746 this._closeableTabSetting.set(tabs); | 752 this._closeableTabSetting.set(tabs); |
| 747 } | 753 } |
| 748 } | 754 } |
| 749 } | 755 } |
| 750 | 756 |
| 751 /** | 757 /** |
| 752 * @param {!Common.Event} event | 758 * @param {!Common.Event} event |
| 753 */ | 759 */ |
| 754 _tabClosed(event) { | 760 _tabClosed(event) { |
| 755 var id = /** @type {string} */ (event.data['tabId']); | 761 var id = /** @type {string} */ (event.data['tabId']); |
| 756 var tabs = this._closeableTabSetting.get(); | 762 var tabs = this._closeableTabSetting.get(); |
| 757 if (tabs[id]) { | 763 if (tabs[id]) { |
| 758 delete tabs[id]; | 764 delete tabs[id]; |
| 759 this._closeableTabSetting.set(tabs); | 765 this._closeableTabSetting.set(tabs); |
| 760 } | 766 } |
| 761 } | 767 } |
| 762 | 768 |
| 763 /** | 769 /** |
| 764 * @param {!UI.View} view | |
| 765 * @return {!Promise} | |
| 766 */ | |
| 767 _materializeWidget(view) { | |
| 768 var widget = /** @type {!UI.ViewManager._ContainerWidget} */ (this._tabbedPa
ne.tabView(view.viewId())); | |
| 769 return widget._materialize(); | |
| 770 } | |
| 771 | |
| 772 /** | |
| 773 * @param {!Common.Event} event | 770 * @param {!Common.Event} event |
| 774 */ | 771 */ |
| 775 _persistTabOrder(event) { | 772 _persistTabOrder(event) { |
| 776 var tabIds = this._tabbedPane.tabIds(); | 773 var tabIds = this._tabbedPane.tabIds(); |
| 777 var tabOrders = {}; | 774 var tabOrders = {}; |
| 778 for (var i = 0; i < tabIds.length; i++) | 775 for (var i = 0; i < tabIds.length; i++) |
| 779 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep; | 776 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep; |
| 780 this._tabOrderSetting.set(tabOrders); | 777 this._tabOrderSetting.set(tabOrders); |
| 781 } | 778 } |
| 782 }; | 779 }; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 appendApplicableItems(locationName) { | 857 appendApplicableItems(locationName) { |
| 861 for (var view of this._manager._viewsForLocation(locationName)) | 858 for (var view of this._manager._viewsForLocation(locationName)) |
| 862 this.appendView(view); | 859 this.appendView(view); |
| 863 } | 860 } |
| 864 }; | 861 }; |
| 865 | 862 |
| 866 /** | 863 /** |
| 867 * @type {!UI.ViewManager} | 864 * @type {!UI.ViewManager} |
| 868 */ | 865 */ |
| 869 UI.viewManager; | 866 UI.viewManager; |
| OLD | NEW |