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

Unified 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: Comments addressed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/InspectedPagePlaceholder.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/SplitView.js
diff --git a/Source/devtools/front_end/SplitView.js b/Source/devtools/front_end/SplitView.js
index dd61510f43e0e7ead60ab156b2d5818252a4bcc6..1e6ca155c7eb35ee274eab008e8b4c480ef37285 100644
--- a/Source/devtools/front_end/SplitView.js
+++ b/Source/devtools/front_end/SplitView.js
@@ -68,11 +68,11 @@ WebInspector.SplitView = function(isVertical, secondIsSidebar, settingName, defa
this._resizable = true;
this._useDip = !!useDip;
- this._savedSidebarWidth = defaultSidebarWidth || 200;
- this._savedSidebarHeight = defaultSidebarHeight || this._savedSidebarWidth;
+ this._defaultSidebarWidth = defaultSidebarWidth || 200;
+ this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWidth;
- if (0 < this._savedSidebarWidth && this._savedSidebarWidth < 1 &&
- 0 < this._savedSidebarHeight && this._savedSidebarHeight < 1)
+ if (0 < this._defaultSidebarWidth && this._defaultSidebarWidth < 1 &&
+ 0 < this._defaultSidebarHeight && this._defaultSidebarHeight < 1)
this._useFraction = true;
this._settingName = settingName;
@@ -136,6 +136,9 @@ WebInspector.SplitView.prototype = {
this.element.classList.add(this._isVertical ? "hbox" : "vbox");
delete this._resizerElementSize;
this._sidebarSize = -1;
+ this._restoreSidebarSizeFromSettings();
+ if (this._shouldSaveShowMode)
+ this._restoreAndApplyShowModeFromSettings();
},
/**
@@ -144,7 +147,7 @@ WebInspector.SplitView.prototype = {
_updateLayout: function(animate)
{
delete this._totalSize; // Lazy update.
- this._innerSetSidebarSize(this._lastSidebarSize(), false, animate);
+ this._innerSetSidebarSize(this._preferredSidebarSize(), false, animate);
},
/**
@@ -174,18 +177,7 @@ WebInspector.SplitView.prototype = {
enableShowModeSaving: function()
{
this._shouldSaveShowMode = true;
- var savedShowMode = this._savedShowMode();
- switch (savedShowMode) {
- case WebInspector.SplitView.ShowMode.Both:
- this.showBoth();
- break;
- case WebInspector.SplitView.ShowMode.OnlyMain:
- this.hideSidebar();
- break;
- case WebInspector.SplitView.ShowMode.OnlySidebar:
- this.hideMain();
- break;
- }
+ this._restoreAndApplyShowModeFromSettings();
},
/**
@@ -233,9 +225,9 @@ WebInspector.SplitView.prototype = {
/**
* @return {number}
*/
- desiredSidebarSize: function()
+ preferredSidebarSize: function()
{
- return this._lastSidebarSize();
+ return this._preferredSidebarSize();
},
/**
@@ -351,7 +343,7 @@ WebInspector.SplitView.prototype = {
setSidebarSize: function(size)
{
this._innerSetSidebarSize(size);
- this._saveSetting();
+ this._saveSidebarSizeToSettings();
},
/**
@@ -378,7 +370,7 @@ WebInspector.SplitView.prototype = {
_updateShowMode: function(showMode)
{
this._showMode = showMode;
- this._saveSetting();
+ this._saveShowModeToSettings();
this._updateShowHideSidebarButton();
this.dispatchEventToListeners(WebInspector.SplitView.Events.ShowModeChanged, showMode);
},
@@ -605,6 +597,7 @@ WebInspector.SplitView.prototype = {
{
if (this._useDip)
WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.ZoomChanged, this._onZoomChanged, this);
+ this._restoreSidebarSizeFromSettings();
dgozman 2014/03/07 11:32:53 Remove this.
this._updateLayout();
},
@@ -628,7 +621,6 @@ WebInspector.SplitView.prototype = {
if (!this._resizable)
return false;
- this._saveSetting();
this._dragOffset = (this._secondIsSidebar ? this.totalSize() - this._sidebarSize : this._sidebarSize) - (this._isVertical ? event.pageX : event.pageY);
return true;
},
@@ -650,7 +642,7 @@ WebInspector.SplitView.prototype = {
_endResizerDragging: function(event)
{
delete this._dragOffset;
- this._saveSetting();
+ this._saveSidebarSizeToSettings();
},
hideDefaultResizer: function()
@@ -728,57 +720,72 @@ WebInspector.SplitView.prototype = {
/**
* @return {number}
*/
- _lastSidebarSize: function()
+ _preferredSidebarSize: function()
{
- var settingForOrientation = this._settingForOrientation();
- var size = settingForOrientation ? settingForOrientation.size : 0;
- if (!size)
- size = this._isVertical ? this._savedSidebarWidth : this._savedSidebarHeight;
+ var size = this._savedSidebarSize;
if (this._useFraction)
size *= this.totalSize();
return size;
},
- /**
- * @return {string}
- */
- _savedShowMode: function()
+ _restoreSidebarSizeFromSettings: function()
+ {
+ var settingForOrientation = this._settingForOrientation();
+ var size = settingForOrientation ? settingForOrientation.size : 0;
+ if (!size)
+ size = this._isVertical ? this._defaultSidebarWidth : this._defaultSidebarHeight;
+ this._savedSidebarSize = size;
+ },
+
+ _restoreAndApplyShowModeFromSettings: function()
{
var orientationState = this._settingForOrientation();
- return orientationState ? orientationState.showMode : "";
+ this._savedShowMode = orientationState ? orientationState.showMode : WebInspector.SplitView.ShowMode.Both;
+ this._showMode = this._savedShowMode;
+
+ switch (this._savedShowMode) {
+ case WebInspector.SplitView.ShowMode.Both:
+ this.showBoth();
+ break;
+ case WebInspector.SplitView.ShowMode.OnlyMain:
+ this.hideSidebar();
+ break;
+ case WebInspector.SplitView.ShowMode.OnlySidebar:
+ this.hideMain();
+ break;
+ }
},
- _sizeToSave: function()
+ _saveSidebarSizeToSettings: function()
{
- var size = this._sidebarSize;
- if (size < 0)
- return -1;
+ if (this._sidebarSize < 0)
+ return;
+ var size = this._sidebarSize;
if (this._useFraction)
size /= this.totalSize();
- return size;
+ this._savedSidebarSize = size;
+ this._saveSetting();
},
- _saveSetting: function()
+ _saveShowModeToSettings: function()
{
- var size = this._sizeToSave();
-
- if (size !== -1) {
- if (this._isVertical)
- this._savedSidebarWidth = size;
- else
- this._savedSidebarHeight = size;
- }
+ this._savedShowMode = this._showMode;
+ this._saveSetting();
+ },
+ _saveSetting: function()
+ {
var setting = this._setting();
if (!setting)
return;
var state = setting.get();
var orientationState = (this._isVertical ? state.vertical : state.horizontal) || {};
- if (size !== -1)
- orientationState.size = size;
+
+ orientationState.size = this._savedSidebarSize;
if (this._shouldSaveShowMode)
- orientationState.showMode = this._showMode;
+ orientationState.showMode = this._savedShowMode;
+
if (this._isVertical)
state.vertical = orientationState;
else
@@ -793,7 +800,7 @@ WebInspector.SplitView.prototype = {
{
var data = /** @type {{from: number, to: number}} */ (event.data);
this._innerSetSidebarSize(this.sidebarSize() * data.from / data.to, true);
- this._saveSetting();
+ this._saveSidebarSizeToSettings();
},
/**
« no previous file with comments | « Source/devtools/front_end/InspectedPagePlaceholder.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698