Changeset 142452 in webkit


Ignore:
Timestamp:
Feb 11, 2013 4:15:58 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Allow SplitView to keep the sidebar size as a fraction of the container size
https://bugs.webkit.org/show_bug.cgi?id=109414

Patch by Vladislav Kaznacheev <kaznacheev@chromium.org> on 2013-02-11
Reviewed by Vsevolod Vlasov.

SplitView now interprets defaultSidebarWidth and defaultSidebarHeight values between 0 and 1 as
fractions of the total container size. The sidebar then will grow or shrink along with the container.
When the sidebar is resized manually the updated ratio is stored in the settings.

  • inspector/front-end/SplitView.js:

(WebInspector.SplitView):
(WebInspector.SplitView.prototype._removeAllLayoutProperties):
(WebInspector.SplitView.prototype._updateTotalSize):
(WebInspector.SplitView.prototype._innerSetSidebarSize):
(WebInspector.SplitView.prototype._saveSidebarSize):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142450 r142452  
     12013-02-11  Vladislav Kaznacheev  <kaznacheev@chromium.org>
     2
     3        Web Inspector: Allow SplitView to keep the sidebar size as a fraction of the container size
     4        https://bugs.webkit.org/show_bug.cgi?id=109414
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        SplitView now interprets defaultSidebarWidth and defaultSidebarHeight values between 0 and 1 as
     9        fractions of the total container size. The sidebar then will grow or shrink along with the container.
     10        When the sidebar is resized manually the updated ratio is stored in the settings.
     11
     12        * inspector/front-end/SplitView.js:
     13        (WebInspector.SplitView):
     14        (WebInspector.SplitView.prototype._removeAllLayoutProperties):
     15        (WebInspector.SplitView.prototype._updateTotalSize):
     16        (WebInspector.SplitView.prototype._innerSetSidebarSize):
     17        (WebInspector.SplitView.prototype._saveSidebarSize):
     18
    1192013-02-11  Pavel Feldman  <pfeldman@chromium.org>
    220
  • trunk/Source/WebCore/inspector/front-end/SplitView.js

    r140333 r142452  
    5353    this._savedSidebarHeight = defaultSidebarHeight || this._savedSidebarWidth;
    5454
     55    if (0 < this._savedSidebarWidth && this._savedSidebarWidth < 1 &&
     56        0 < this._savedSidebarHeight && this._savedSidebarHeight < 1)
     57        this._useFraction = true;
     58   
    5559    this._sidebarSizeSettingName = sidebarSizeSettingName;
    5660
     
    218222        this._resizerElement.style.removeProperty("top");
    219223        this._resizerElement.style.removeProperty("bottom");
     224
     225        this._resizerElement.style.removeProperty("margin-left");
     226        this._resizerElement.style.removeProperty("margin-right");
     227        this._resizerElement.style.removeProperty("margin-top");
     228        this._resizerElement.style.removeProperty("margin-bottom");
    220229    },
    221230
     
    280289    {
    281290        this._totalSize = this._isVertical ? this.element.offsetWidth : this.element.offsetHeight;
    282     },
    283  
     291        if (this._useFraction)
     292            this._sidebarSize = this._lastSidebarSize();
     293    },
     294
    284295    /**
    285296     * @param {number} size
     
    291302
    292303        this._removeAllLayoutProperties();
     304
     305        var sizeValue;
     306        if (this._useFraction)
     307            sizeValue = (size / this._totalSize) * 100 + "%";
     308        else
     309            sizeValue = size + "px";
    293310
    294311        if (this._isVertical) {
    295312            var resizerWidth = this._resizerElement.offsetWidth;
    296313            if (this._secondIsSidebar) {
    297                 this._firstElement.style.right = size + "px";
    298                 this._secondElement.style.width = size + "px";
    299                 this._resizerElement.style.right = size - resizerWidth / 2 + "px";
     314                this._firstElement.style.right = sizeValue;
     315                this._secondElement.style.width = sizeValue;
     316                this._resizerElement.style.right = sizeValue;
     317                this._resizerElement.style.marginRight = -resizerWidth / 2 + "px";
    300318            } else {
    301                 this._firstElement.style.width = size + "px";
    302                 this._secondElement.style.left = size + "px";
    303                 this._resizerElement.style.left = size - resizerWidth / 2 + "px";
     319                this._firstElement.style.width = sizeValue;
     320                this._secondElement.style.left = sizeValue;
     321                this._resizerElement.style.left = sizeValue;
     322                this._resizerElement.style.marginLeft = -resizerWidth / 2 + "px";
    304323            }
    305324        } else {
    306325            var resizerHeight = this._resizerElement.offsetHeight;
    307            
     326
    308327            if (this._secondIsSidebar) {
    309                 this._firstElement.style.bottom = size + "px";
    310                 this._secondElement.style.height = size + "px";
    311                 this._resizerElement.style.bottom = size - resizerHeight / 2 + "px";
     328                this._firstElement.style.bottom = sizeValue;
     329                this._secondElement.style.height = sizeValue;
     330                this._resizerElement.style.bottom = sizeValue;
     331                this._resizerElement.style.marginBottom = -resizerHeight / 2 + "px";
    312332            } else {
    313                 this._firstElement.style.height = size + "px";
    314                 this._secondElement.style.top = size + "px";
    315                 this._resizerElement.style.top = size - resizerHeight / 2 + "px";
     333                this._firstElement.style.height = sizeValue;
     334                this._secondElement.style.top = sizeValue;
     335                this._resizerElement.style.top = sizeValue;
     336                this._resizerElement.style.marginTop = -resizerHeight / 2 + "px";
    316337            }
    317338        }
     
    415436        var sizeSetting = this._sizeSetting();
    416437        var size = sizeSetting ? sizeSetting.get() : 0;
    417         return size || (this._isVertical ? this._savedSidebarWidth : this._savedSidebarHeight);
     438        if (!size)
     439             size = this._isVertical ? this._savedSidebarWidth : this._savedSidebarHeight;
     440        if (this._useFraction)
     441            size *= this._totalSize;
     442        return size;
    418443    },
    419444
     
    423448    _saveSidebarSize: function(size)
    424449    {
     450        if (this._useFraction)
     451            size /= this._totalSize;
     452
    425453        if (this._isVertical)
    426454            this._savedSidebarWidth = size;
Note: See TracChangeset for help on using the changeset viewer.