Chromium Code Reviews| Index: Source/devtools/front_end/SplitView.js |
| diff --git a/Source/devtools/front_end/SplitView.js b/Source/devtools/front_end/SplitView.js |
| index 333f8c31f679ac3f18da9ac8634f287781be09c4..e96fb730e6a80374b3153a63078c1d942ca7c423 100644 |
| --- a/Source/devtools/front_end/SplitView.js |
| +++ b/Source/devtools/front_end/SplitView.js |
| @@ -95,6 +95,8 @@ WebInspector.SplitView.Events = { |
| ShowModeChanged: "ShowModeChanged" |
| } |
| +WebInspector.SplitView.MinPadding = 20; |
| + |
| WebInspector.SplitView.prototype = { |
| /** |
| * @return {boolean} |
| @@ -132,6 +134,7 @@ WebInspector.SplitView.prototype = { |
| if (this._shouldSaveShowMode) |
| this._restoreAndApplyShowModeFromSettings(); |
| this._updateShowHideSidebarButton(); |
| + this.invalidateMinimumSize(); |
| for (var i = 0; i < this._resizerElements.length; ++i) { |
| this._resizerElements[i].classList.toggle("ew-resizer-widget", this._isVertical); |
| @@ -370,6 +373,7 @@ WebInspector.SplitView.prototype = { |
| this._saveShowModeToSettings(); |
| this._updateShowHideSidebarButton(); |
| this.dispatchEventToListeners(WebInspector.SplitView.Events.ShowModeChanged, showMode); |
| + this.invalidateMinimumSize(); |
| }, |
| /** |
| @@ -514,52 +518,29 @@ WebInspector.SplitView.prototype = { |
| }, |
| /** |
| - * @param {number=} minWidth |
| - * @param {number=} minHeight |
| - */ |
| - setSidebarElementConstraints: function(minWidth, minHeight) |
| - { |
| - if (typeof minWidth === "number") |
| - this._minimumSidebarWidth = minWidth; |
| - if (typeof minHeight === "number") |
| - this._minimumSidebarHeight = minHeight; |
| - }, |
| - |
| - /** |
| - * @param {number=} minWidth |
| - * @param {number=} minHeight |
| - */ |
| - setMainElementConstraints: function(minWidth, minHeight) |
| - { |
| - if (typeof minWidth === "number") |
| - this._minimumMainWidth = minWidth; |
| - if (typeof minHeight === "number") |
| - this._minimumMainHeight = minHeight; |
| - }, |
| - |
| - /** |
| * @param {number} sidebarSize |
| * @return {number} |
| */ |
| _applyConstraints: function(sidebarSize) |
| { |
| - const minPadding = 20; |
| var totalSize = this.totalSize(); |
| - var minimumSiderbarSizeContraint = this.isVertical() ? this._minimumSidebarWidth : this._minimumSidebarHeight; |
| - var from = minimumSiderbarSizeContraint || 0; |
| - if (typeof minimumSiderbarSizeContraint !== "number") |
| - from = Math.max(from, minPadding); |
| - var minimumMainSizeConstraint = this.isVertical() ? this._minimumMainWidth : this._minimumMainHeight; |
| - var minMainSize = minimumMainSizeConstraint || 0; |
| - if (typeof minimumMainSizeConstraint !== "number") |
| - minMainSize = Math.max(minMainSize, minPadding); |
| + var size = this._sidebarView.minimumSize(); |
| + var from = this.isVertical() ? size.width : size.height; |
| + if (!from) |
| + from = WebInspector.SplitView.MinPadding; |
| + |
| + size = this._mainView.minimumSize(); |
| + var minMainSize = this.isVertical() ? size.width : size.height; |
| + if (!minMainSize) |
| + minMainSize = WebInspector.SplitView.MinPadding; |
| var to = totalSize - minMainSize; |
| if (from <= to) |
| return Number.constrain(sidebarSize, from, to); |
| - return -1; |
|
pfeldman
2014/03/14 06:23:10
This -1 was used for the case when _applyConstrain
dgozman
2014/03/14 15:55:15
I've removed check for this in _innerSetSidebarSiz
|
| + // If we don't have enough space (which is a very rare case), prioritize main view. |
| + return Math.max(0, to); |
| }, |
| wasShown: function() |
| @@ -573,6 +554,25 @@ WebInspector.SplitView.prototype = { |
| }, |
| /** |
| + * @return {!Size} |
| + */ |
| + calculateMinimumSize: function() |
| + { |
| + if (this._showMode === WebInspector.SplitView.ShowMode.OnlyMain) |
| + return this._mainView.minimumSize(); |
| + if (this._showMode === WebInspector.SplitView.ShowMode.OnlySidebar) |
| + return this._sidebarView.minimumSize(); |
| + |
| + var mainSize = this._mainView.minimumSize(); |
| + var sidebarSize = this._sidebarView.minimumSize(); |
| + var min = WebInspector.SplitView.MinPadding; |
| + if (this._isVertical) |
| + return new Size((mainSize.width || min) + (sidebarSize.width || min), Math.max(mainSize.height, sidebarSize.height)); |
| + else |
| + return new Size(Math.max(mainSize.width, sidebarSize.width), (mainSize.height || min) + (sidebarSize.height || min)); |
| + }, |
| + |
| + /** |
| * @param {!MouseEvent} event |
| * @return {boolean} |
| */ |