Commit 910dfc55 authored by vsevik@chromium.org's avatar vsevik@chromium.org

DevTools: Do not save split view size on show mode changes.

BUG=348887
R=dgozman

Review URL: https://codereview.chromium.org/185943004

git-svn-id: svn://svn.chromium.org/blink/trunk@168608 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2fa86b98
...@@ -24,12 +24,14 @@ function test() ...@@ -24,12 +24,14 @@ function test()
delete settingValue.vertical.size; delete settingValue.vertical.size;
setting.set(settingValue); setting.set(settingValue);
forceSettingRead(panel._splitView);
panel._showRequest(request); panel._showRequest(request);
InspectorTest.addResult("Sidebar width: " + panel._splitView.sidebarElement().offsetWidth); InspectorTest.addResult("Sidebar width: " + panel._splitView.sidebarElement().offsetWidth);
panel._toggleGridMode(); panel._toggleGridMode();
settingValue.vertical.size = 242; settingValue.vertical.size = 242;
setting.set(settingValue); setting.set(settingValue);
forceSettingRead(panel._splitView);
panel._showRequest(request); panel._showRequest(request);
InspectorTest.addResult("Sidebar width: " + panel._splitView.sidebarElement().offsetWidth); InspectorTest.addResult("Sidebar width: " + panel._splitView.sidebarElement().offsetWidth);
panel._closeVisibleRequest(request); panel._closeVisibleRequest(request);
...@@ -39,6 +41,12 @@ function test() ...@@ -39,6 +41,12 @@ function test()
InspectorTest.completeTest(); InspectorTest.completeTest();
} }
function forceSettingRead(splitView)
{
splitView.setVertical(false);
splitView.setVertical(true);
}
} }
</script> </script>
</head> </head>
......
...@@ -68,11 +68,11 @@ WebInspector.SplitView = function(isVertical, secondIsSidebar, settingName, defa ...@@ -68,11 +68,11 @@ WebInspector.SplitView = function(isVertical, secondIsSidebar, settingName, defa
this._resizable = true; this._resizable = true;
this._useDip = !!useDip; this._useDip = !!useDip;
this._savedSidebarWidth = defaultSidebarWidth || 200; this._defaultSidebarWidth = defaultSidebarWidth || 200;
this._savedSidebarHeight = defaultSidebarHeight || this._savedSidebarWidth; this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWidth;
if (0 < this._savedSidebarWidth && this._savedSidebarWidth < 1 && if (0 < this._defaultSidebarWidth && this._defaultSidebarWidth < 1 &&
0 < this._savedSidebarHeight && this._savedSidebarHeight < 1) 0 < this._defaultSidebarHeight && this._defaultSidebarHeight < 1)
this._useFraction = true; this._useFraction = true;
this._settingName = settingName; this._settingName = settingName;
...@@ -136,6 +136,7 @@ WebInspector.SplitView.prototype = { ...@@ -136,6 +136,7 @@ WebInspector.SplitView.prototype = {
this.element.classList.add(this._isVertical ? "hbox" : "vbox"); this.element.classList.add(this._isVertical ? "hbox" : "vbox");
delete this._resizerElementSize; delete this._resizerElementSize;
this._sidebarSize = -1; this._sidebarSize = -1;
this._preferredSidebarSize = this._savedSidebarSize();
}, },
/** /**
...@@ -144,7 +145,7 @@ WebInspector.SplitView.prototype = { ...@@ -144,7 +145,7 @@ WebInspector.SplitView.prototype = {
_updateLayout: function(animate) _updateLayout: function(animate)
{ {
delete this._totalSize; // Lazy update. delete this._totalSize; // Lazy update.
this._innerSetSidebarSize(this._lastSidebarSize(), false, animate); this._innerSetSidebarSize(this._preferredSidebarSize, false, animate);
}, },
/** /**
...@@ -235,7 +236,7 @@ WebInspector.SplitView.prototype = { ...@@ -235,7 +236,7 @@ WebInspector.SplitView.prototype = {
*/ */
desiredSidebarSize: function() desiredSidebarSize: function()
{ {
return this._lastSidebarSize(); return this._preferredSidebarSize;
}, },
/** /**
...@@ -351,7 +352,7 @@ WebInspector.SplitView.prototype = { ...@@ -351,7 +352,7 @@ WebInspector.SplitView.prototype = {
setSidebarSize: function(size) setSidebarSize: function(size)
{ {
this._innerSetSidebarSize(size); this._innerSetSidebarSize(size);
this._saveSetting(); this._updatePreferredSidebarSize();
}, },
/** /**
...@@ -628,7 +629,6 @@ WebInspector.SplitView.prototype = { ...@@ -628,7 +629,6 @@ WebInspector.SplitView.prototype = {
if (!this._resizable) if (!this._resizable)
return false; return false;
this._saveSetting();
this._dragOffset = (this._secondIsSidebar ? this.totalSize() - this._sidebarSize : this._sidebarSize) - (this._isVertical ? event.pageX : event.pageY); this._dragOffset = (this._secondIsSidebar ? this.totalSize() - this._sidebarSize : this._sidebarSize) - (this._isVertical ? event.pageX : event.pageY);
return true; return true;
}, },
...@@ -650,7 +650,7 @@ WebInspector.SplitView.prototype = { ...@@ -650,7 +650,7 @@ WebInspector.SplitView.prototype = {
_endResizerDragging: function(event) _endResizerDragging: function(event)
{ {
delete this._dragOffset; delete this._dragOffset;
this._saveSetting(); this._updatePreferredSidebarSize();
}, },
hideDefaultResizer: function() hideDefaultResizer: function()
...@@ -728,12 +728,12 @@ WebInspector.SplitView.prototype = { ...@@ -728,12 +728,12 @@ WebInspector.SplitView.prototype = {
/** /**
* @return {number} * @return {number}
*/ */
_lastSidebarSize: function() _savedSidebarSize: function()
{ {
var settingForOrientation = this._settingForOrientation(); var settingForOrientation = this._settingForOrientation();
var size = settingForOrientation ? settingForOrientation.size : 0; var size = settingForOrientation ? settingForOrientation.size : 0;
if (!size) if (!size)
size = this._isVertical ? this._savedSidebarWidth : this._savedSidebarHeight; size = this._isVertical ? this._defaultSidebarWidth : this._defaultSidebarHeight;
if (this._useFraction) if (this._useFraction)
size *= this.totalSize(); size *= this.totalSize();
return size; return size;
...@@ -759,16 +759,15 @@ WebInspector.SplitView.prototype = { ...@@ -759,16 +759,15 @@ WebInspector.SplitView.prototype = {
return size; return size;
}, },
_saveSetting: function() _updatePreferredSidebarSize: function()
{ {
var size = this._sizeToSave(); this._preferredSidebarSize = this._sizeToSave();
this._saveSetting();
},
if (size !== -1) { _saveSetting: function()
if (this._isVertical) {
this._savedSidebarWidth = size; var size = this._preferredSidebarSize;
else
this._savedSidebarHeight = size;
}
var setting = this._setting(); var setting = this._setting();
if (!setting) if (!setting)
...@@ -793,7 +792,7 @@ WebInspector.SplitView.prototype = { ...@@ -793,7 +792,7 @@ WebInspector.SplitView.prototype = {
{ {
var data = /** @type {{from: number, to: number}} */ (event.data); var data = /** @type {{from: number, to: number}} */ (event.data);
this._innerSetSidebarSize(this.sidebarSize() * data.from / data.to, true); this._innerSetSidebarSize(this.sidebarSize() * data.from / data.to, true);
this._saveSetting(); this._updatePreferredSidebarSize();
}, },
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment