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

Side by Side Diff: Source/devtools/front_end/SplitView.js

Issue 185943004: DevTools: Do not save split view size on show mode changes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 this._sidebarView.show(this.element); 61 this._sidebarView.show(this.element);
62 this._mainView.show(this.element); 62 this._mainView.show(this.element);
63 } 63 }
64 64
65 this._onDragStartBound = this._onDragStart.bind(this); 65 this._onDragStartBound = this._onDragStart.bind(this);
66 this._resizerElements = []; 66 this._resizerElements = [];
67 67
68 this._resizable = true; 68 this._resizable = true;
69 this._useDip = !!useDip; 69 this._useDip = !!useDip;
70 70
71 this._savedSidebarWidth = defaultSidebarWidth || 200; 71 this._defaultSidebarWidth = defaultSidebarWidth || 200;
72 this._savedSidebarHeight = defaultSidebarHeight || this._savedSidebarWidth; 72 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid th;
73 73
74 if (0 < this._savedSidebarWidth && this._savedSidebarWidth < 1 && 74 if (0 < this._defaultSidebarWidth && this._defaultSidebarWidth < 1 &&
75 0 < this._savedSidebarHeight && this._savedSidebarHeight < 1) 75 0 < this._defaultSidebarHeight && this._defaultSidebarHeight < 1)
76 this._useFraction = true; 76 this._useFraction = true;
77 77
78 this._settingName = settingName; 78 this._settingName = settingName;
79 79
80 this.setSecondIsSidebar(secondIsSidebar); 80 this.setSecondIsSidebar(secondIsSidebar);
81 81
82 this._innerSetVertical(isVertical); 82 this._innerSetVertical(isVertical);
83 this._showMode = WebInspector.SplitView.ShowMode.Both; 83 this._showMode = WebInspector.SplitView.ShowMode.Both;
84 84
85 // Should be called after isVertical has the right value. 85 // Should be called after isVertical has the right value.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 /** 129 /**
130 * @param {boolean} isVertical 130 * @param {boolean} isVertical
131 */ 131 */
132 _innerSetVertical: function(isVertical) 132 _innerSetVertical: function(isVertical)
133 { 133 {
134 this.element.classList.remove(this._isVertical ? "hbox" : "vbox"); 134 this.element.classList.remove(this._isVertical ? "hbox" : "vbox");
135 this._isVertical = isVertical; 135 this._isVertical = isVertical;
136 this.element.classList.add(this._isVertical ? "hbox" : "vbox"); 136 this.element.classList.add(this._isVertical ? "hbox" : "vbox");
137 delete this._resizerElementSize; 137 delete this._resizerElementSize;
138 this._sidebarSize = -1; 138 this._sidebarSize = -1;
139 this._preferredSidebarSize = this._savedSidebarSize();
139 }, 140 },
140 141
141 /** 142 /**
142 * @param {boolean=} animate 143 * @param {boolean=} animate
143 */ 144 */
144 _updateLayout: function(animate) 145 _updateLayout: function(animate)
145 { 146 {
146 delete this._totalSize; // Lazy update. 147 delete this._totalSize; // Lazy update.
147 this._innerSetSidebarSize(this._lastSidebarSize(), false, animate); 148 this._innerSetSidebarSize(this._preferredSidebarSize, false, animate);
148 }, 149 },
149 150
150 /** 151 /**
151 * @return {!Element} 152 * @return {!Element}
152 */ 153 */
153 mainElement: function() 154 mainElement: function()
154 { 155 {
155 return this._mainElement; 156 return this._mainElement;
156 }, 157 },
157 158
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return this._isVertical ? 229 return this._isVertical ?
229 (this._secondIsSidebar ? "right" : "left") : 230 (this._secondIsSidebar ? "right" : "left") :
230 (this._secondIsSidebar ? "bottom" : "top"); 231 (this._secondIsSidebar ? "bottom" : "top");
231 }, 232 },
232 233
233 /** 234 /**
234 * @return {number} 235 * @return {number}
235 */ 236 */
236 desiredSidebarSize: function() 237 desiredSidebarSize: function()
237 { 238 {
238 return this._lastSidebarSize(); 239 return this._preferredSidebarSize;
239 }, 240 },
240 241
241 /** 242 /**
242 * @return {!Element} 243 * @return {!Element}
243 */ 244 */
244 resizerElement: function() 245 resizerElement: function()
245 { 246 {
246 return this._resizerElement; 247 return this._resizerElement;
247 }, 248 },
248 249
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 this._resizable = resizable; 345 this._resizable = resizable;
345 this._resizerElement.enableStyleClass("hidden", !resizable); 346 this._resizerElement.enableStyleClass("hidden", !resizable);
346 }, 347 },
347 348
348 /** 349 /**
349 * @param {number} size 350 * @param {number} size
350 */ 351 */
351 setSidebarSize: function(size) 352 setSidebarSize: function(size)
352 { 353 {
353 this._innerSetSidebarSize(size); 354 this._innerSetSidebarSize(size);
354 this._saveSetting(); 355 this._saveSizeToSetting();
355 }, 356 },
356 357
357 /** 358 /**
358 * @return {number} 359 * @return {number}
359 */ 360 */
360 sidebarSize: function() 361 sidebarSize: function()
361 { 362 {
362 return Math.max(0, this._sidebarSize); 363 return Math.max(0, this._sidebarSize);
363 }, 364 },
364 365
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 622
622 /** 623 /**
623 * @param {!MouseEvent} event 624 * @param {!MouseEvent} event
624 * @return {boolean} 625 * @return {boolean}
625 */ 626 */
626 _startResizerDragging: function(event) 627 _startResizerDragging: function(event)
627 { 628 {
628 if (!this._resizable) 629 if (!this._resizable)
629 return false; 630 return false;
630 631
631 this._saveSetting(); 632 this._saveSizeToSetting();
dgozman 2014/03/05 17:52:53 We agreed this is not needed.
632 this._dragOffset = (this._secondIsSidebar ? this.totalSize() - this._sid ebarSize : this._sidebarSize) - (this._isVertical ? event.pageX : event.pageY); 633 this._dragOffset = (this._secondIsSidebar ? this.totalSize() - this._sid ebarSize : this._sidebarSize) - (this._isVertical ? event.pageX : event.pageY);
633 return true; 634 return true;
634 }, 635 },
635 636
636 /** 637 /**
637 * @param {!MouseEvent} event 638 * @param {!MouseEvent} event
638 */ 639 */
639 _resizerDragging: function(event) 640 _resizerDragging: function(event)
640 { 641 {
641 var newOffset = (this._isVertical ? event.pageX : event.pageY) + this._d ragOffset; 642 var newOffset = (this._isVertical ? event.pageX : event.pageY) + this._d ragOffset;
642 var newSize = (this._secondIsSidebar ? this.totalSize() - newOffset : ne wOffset); 643 var newSize = (this._secondIsSidebar ? this.totalSize() - newOffset : ne wOffset);
643 this.setSidebarSize(newSize); 644 this.setSidebarSize(newSize);
644 event.preventDefault(); 645 event.preventDefault();
645 }, 646 },
646 647
647 /** 648 /**
648 * @param {!MouseEvent} event 649 * @param {!MouseEvent} event
649 */ 650 */
650 _endResizerDragging: function(event) 651 _endResizerDragging: function(event)
651 { 652 {
652 delete this._dragOffset; 653 delete this._dragOffset;
653 this._saveSetting(); 654 this._saveSizeToSetting();
654 }, 655 },
655 656
656 hideDefaultResizer: function() 657 hideDefaultResizer: function()
657 { 658 {
658 this.element.classList.add("split-view-no-resizer"); 659 this.element.classList.add("split-view-no-resizer");
659 }, 660 },
660 661
661 /** 662 /**
662 * @param {!Element} resizerElement 663 * @param {!Element} resizerElement
663 */ 664 */
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 */ 722 */
722 _settingForOrientation: function() 723 _settingForOrientation: function()
723 { 724 {
724 var state = this._setting() ? this._setting().get() : {}; 725 var state = this._setting() ? this._setting().get() : {};
725 return this._isVertical ? state.vertical : state.horizontal; 726 return this._isVertical ? state.vertical : state.horizontal;
726 }, 727 },
727 728
728 /** 729 /**
729 * @return {number} 730 * @return {number}
730 */ 731 */
731 _lastSidebarSize: function() 732 _savedSidebarSize: function()
732 { 733 {
733 var settingForOrientation = this._settingForOrientation(); 734 var settingForOrientation = this._settingForOrientation();
734 var size = settingForOrientation ? settingForOrientation.size : 0; 735 var size = settingForOrientation ? settingForOrientation.size : 0;
735 if (!size) 736 if (!size)
736 size = this._isVertical ? this._savedSidebarWidth : this._savedSide barHeight; 737 size = this._isVertical ? this._defaultSidebarWidth : this._default SidebarHeight;
737 if (this._useFraction) 738 if (this._useFraction)
738 size *= this.totalSize(); 739 size *= this.totalSize();
739 return size; 740 return size;
740 }, 741 },
741 742
742 /** 743 /**
743 * @return {string} 744 * @return {string}
744 */ 745 */
745 _savedShowMode: function() 746 _savedShowMode: function()
746 { 747 {
747 var orientationState = this._settingForOrientation(); 748 var orientationState = this._settingForOrientation();
748 return orientationState ? orientationState.showMode : ""; 749 return orientationState ? orientationState.showMode : "";
749 }, 750 },
750 751
751 _sizeToSave: function() 752 _sizeToSave: function()
752 { 753 {
753 var size = this._sidebarSize; 754 var size = this._sidebarSize;
754 if (size < 0) 755 if (size < 0)
755 return -1; 756 return -1;
756 757
757 if (this._useFraction) 758 if (this._useFraction)
758 size /= this.totalSize(); 759 size /= this.totalSize();
759 return size; 760 return size;
760 }, 761 },
761 762
763 _saveSizeToSetting: function()
dgozman 2014/03/05 17:52:53 Consider renaming to setPreferredSidebarSize.
764 {
765 this._preferredSidebarSize = this._sizeToSave();
766 this._saveSetting();
767 },
768
762 _saveSetting: function() 769 _saveSetting: function()
763 { 770 {
764 var size = this._sizeToSave(); 771 var size = this._preferredSidebarSize;
765
766 if (size !== -1) {
767 if (this._isVertical)
768 this._savedSidebarWidth = size;
769 else
770 this._savedSidebarHeight = size;
771 }
772 772
773 var setting = this._setting(); 773 var setting = this._setting();
774 if (!setting) 774 if (!setting)
775 return; 775 return;
776 var state = setting.get(); 776 var state = setting.get();
777 var orientationState = (this._isVertical ? state.vertical : state.horizo ntal) || {}; 777 var orientationState = (this._isVertical ? state.vertical : state.horizo ntal) || {};
778 if (size !== -1) 778 if (size !== -1)
779 orientationState.size = size; 779 orientationState.size = size;
780 if (this._shouldSaveShowMode) 780 if (this._shouldSaveShowMode)
781 orientationState.showMode = this._showMode; 781 orientationState.showMode = this._showMode;
782 if (this._isVertical) 782 if (this._isVertical)
783 state.vertical = orientationState; 783 state.vertical = orientationState;
784 else 784 else
785 state.horizontal = orientationState; 785 state.horizontal = orientationState;
786 setting.set(state); 786 setting.set(state);
787 }, 787 },
788 788
789 /** 789 /**
790 * @param {!WebInspector.Event} event 790 * @param {!WebInspector.Event} event
791 */ 791 */
792 _onZoomChanged: function(event) 792 _onZoomChanged: function(event)
793 { 793 {
794 var data = /** @type {{from: number, to: number}} */ (event.data); 794 var data = /** @type {{from: number, to: number}} */ (event.data);
795 this._innerSetSidebarSize(this.sidebarSize() * data.from / data.to, true ); 795 this._innerSetSidebarSize(this.sidebarSize() * data.from / data.to, true );
796 this._saveSetting(); 796 this._saveSizeToSetting();
797 }, 797 },
798 798
799 /** 799 /**
800 * @param {string} title 800 * @param {string} title
801 * @param {string} className 801 * @param {string} className
802 * @return {!WebInspector.StatusBarButton} 802 * @return {!WebInspector.StatusBarButton}
803 */ 803 */
804 createShowHideSidebarButton: function(title, className) 804 createShowHideSidebarButton: function(title, className)
805 { 805 {
806 console.assert(this.isVertical(), "Buttons for split view with horizonta l split are not supported yet."); 806 console.assert(this.isVertical(), "Buttons for split view with horizonta l split are not supported yet.");
(...skipping 22 matching lines...) Expand all
829 _updateShowHideSidebarButton: function() 829 _updateShowHideSidebarButton: function()
830 { 830 {
831 if (!this._showHideSidebarButton) 831 if (!this._showHideSidebarButton)
832 return; 832 return;
833 this._showHideSidebarButton.state = this._isShowingOne === this.isSideba rSecond() ? "left" : "right"; 833 this._showHideSidebarButton.state = this._isShowingOne === this.isSideba rSecond() ? "left" : "right";
834 this._showHideSidebarButton.title = this._isShowingOne ? WebInspector.UI String("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hid e %s", this._showHideSidebarButtonTitle); 834 this._showHideSidebarButton.title = this._isShowingOne ? WebInspector.UI String("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hid e %s", this._showHideSidebarButtonTitle);
835 }, 835 },
836 836
837 __proto__: WebInspector.View.prototype 837 __proto__: WebInspector.View.prototype
838 } 838 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698