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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/View.js

Issue 2867133002: DevTools: Let the drawer tabs be reordered (Closed)
Patch Set: Add test Created 3 years, 7 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 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 669 }
670 670
671 /** 671 /**
672 * @param {!UI.View} view 672 * @param {!UI.View} view
673 * @param {number=} index 673 * @param {number=} index
674 */ 674 */
675 _appendTab(view, index) { 675 _appendTab(view, index) {
676 this._tabbedPane.appendTab( 676 this._tabbedPane.appendTab(
677 view.viewId(), view.title(), new UI.ViewManager._ContainerWidget(view), undefined, false, 677 view.viewId(), view.title(), new UI.ViewManager._ContainerWidget(view), undefined, false,
678 view.isCloseable() || view.isTransient(), index); 678 view.isCloseable() || view.isTransient(), index);
679 if (view.isCloseable()) {
dgozman 2017/05/25 17:12:49 Let's move this persisting block to appendView ins
einbinder 2017/05/25 23:48:54 Done.
680 var tabs = this._closeableTabSetting.get();
681 var tabId = view.viewId();
682 if (!tabs[tabId]) {
683 tabs[tabId] = true;
684 this._closeableTabSetting.set(tabs);
685 }
686 }
687 this._persistTabOrder();
679 } 688 }
680 689
681 /** 690 /**
682 * @override 691 * @override
683 * @param {!UI.View} view 692 * @param {!UI.View} view
684 * @param {?UI.View=} insertBefore 693 * @param {?UI.View=} insertBefore
685 */ 694 */
686 appendView(view, insertBefore) { 695 appendView(view, insertBefore) {
687 if (this._tabbedPane.hasTab(view.viewId())) 696 if (this._tabbedPane.hasTab(view.viewId()))
688 return; 697 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 this._tabbedPane.closeTab(view.viewId()); 750 this._tabbedPane.closeTab(view.viewId());
742 } 751 }
743 752
744 /** 753 /**
745 * @param {!Common.Event} event 754 * @param {!Common.Event} event
746 */ 755 */
747 _tabSelected(event) { 756 _tabSelected(event) {
748 var tabId = /** @type {string} */ (event.data.tabId); 757 var tabId = /** @type {string} */ (event.data.tabId);
749 if (this._lastSelectedTabSetting && event.data['isUserGesture']) 758 if (this._lastSelectedTabSetting && event.data['isUserGesture'])
750 this._lastSelectedTabSetting.set(tabId); 759 this._lastSelectedTabSetting.set(tabId);
751 var view = this._views.get(tabId);
752 if (!view)
753 return;
754
755 if (view.isCloseable()) {
einbinder 2017/05/23 00:12:25 Tabs were persisted when they were selected, but i
756 var tabs = this._closeableTabSetting.get();
757 if (!tabs[tabId]) {
758 tabs[tabId] = true;
759 this._closeableTabSetting.set(tabs);
760 }
761 }
762 } 760 }
763 761
764 /** 762 /**
765 * @param {!Common.Event} event 763 * @param {!Common.Event} event
766 */ 764 */
767 _tabClosed(event) { 765 _tabClosed(event) {
768 var id = /** @type {string} */ (event.data['tabId']); 766 var id = /** @type {string} */ (event.data['tabId']);
769 var tabs = this._closeableTabSetting.get(); 767 var tabs = this._closeableTabSetting.get();
770 if (tabs[id]) { 768 if (tabs[id]) {
771 delete tabs[id]; 769 delete tabs[id];
772 this._closeableTabSetting.set(tabs); 770 this._closeableTabSetting.set(tabs);
773 } 771 }
774 } 772 }
775 773
776 /** 774 _persistTabOrder() {
777 * @param {!Common.Event} event
778 */
779 _persistTabOrder(event) {
780 var tabIds = this._tabbedPane.tabIds(); 775 var tabIds = this._tabbedPane.tabIds();
781 var tabOrders = {}; 776 var tabOrders = {};
782 for (var i = 0; i < tabIds.length; i++) 777 for (var i = 0; i < tabIds.length; i++)
783 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep; 778 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep;
784 this._tabOrderSetting.set(tabOrders); 779 this._tabOrderSetting.set(tabOrders);
785 } 780 }
786 }; 781 };
787 782
788 UI.ViewManager._TabbedLocation.orderStep = 10; // Keep in sync with descriptors . 783 UI.ViewManager._TabbedLocation.orderStep = 10; // Keep in sync with descriptors .
789 784
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 appendApplicableItems(locationName) { 859 appendApplicableItems(locationName) {
865 for (var view of this._manager._viewsForLocation(locationName)) 860 for (var view of this._manager._viewsForLocation(locationName))
866 this.appendView(view); 861 this.appendView(view);
867 } 862 }
868 }; 863 };
869 864
870 /** 865 /**
871 * @type {!UI.ViewManager} 866 * @type {!UI.ViewManager}
872 */ 867 */
873 UI.viewManager; 868 UI.viewManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698