Changeset 49997 in webkit


Ignore:
Timestamp:
Oct 23, 2009 1:47:58 PM (15 years ago)
Author:
pfeldman@chromium.org
Message:

2009-10-23 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: pull basic sidebar implementation into the Panel.

https://bugs.webkit.org/show_bug.cgi?id=30720

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49996 r49997  
     12009-10-23  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: pull basic sidebar implementation into the Panel.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=30720
     8
     9        * inspector/front-end/Panel.js:
     10        (WebInspector.Panel):
     11        (WebInspector.Panel.prototype.jumpToPreviousSearchResult):
     12        (WebInspector.Panel.prototype.handleKeyEvent):
     13        (WebInspector.Panel.prototype._createSidebar):
     14        (WebInspector.Panel.prototype._startSidebarDragging):
     15        (WebInspector.Panel.prototype._sidebarDragging):
     16        (WebInspector.Panel.prototype._endSidebarDragging):
     17        (WebInspector.Panel.prototype._updateSidebarWidth):
     18        (WebInspector.Panel.prototype.setCenterViewWidth):
     19        * inspector/front-end/ProfilesPanel.js:
     20        (WebInspector.ProfilesPanel):
     21        (WebInspector.ProfilesPanel.prototype.setCenterViewWidth):
     22        * inspector/front-end/StoragePanel.js:
     23        (WebInspector.StoragePanel):
     24        (WebInspector.StoragePanel.prototype.setCenterViewWidth):
     25
    1262009-10-23  Jens Alfke  <snej@chromium.org>
    227
  • trunk/WebCore/inspector/front-end/Panel.js

    r47192 r49997  
    2727 */
    2828
    29 WebInspector.Panel = function()
     29WebInspector.Panel = function(createSidebar)
    3030{
    3131    WebInspector.View.call(this);
     32    if (createSidebar)
     33        this._createSidebar();
    3234
    3335    this.element.addStyleClass("panel");
     
    8385
    8486        WebInspector.currentFocusElement = document.getElementById("main-panels");
     87        this._updateSidebarWidth();
    8588    },
    8689
     
    268271        else
    269272            currentView.jumpToPreviousSearchResult();
     273    },
     274
     275    handleKeyEvent: function(event)
     276    {
     277        this.sidebarTree.handleKeyEvent(event);
     278    },
     279
     280    _createSidebar: function()
     281    {
     282        this.sidebarElement = document.createElement("div");
     283        this.sidebarElement.className = "sidebar";
     284        this.element.appendChild(this.sidebarElement);
     285
     286        this.sidebarResizeElement = document.createElement("div");
     287        this.sidebarResizeElement.className = "sidebar-resizer-vertical";
     288        this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false);
     289        this.element.appendChild(this.sidebarResizeElement);
     290
     291        this.sidebarTreeElement = document.createElement("ol");
     292        this.sidebarTreeElement.className = "sidebar-tree";
     293        this.sidebarElement.appendChild(this.sidebarTreeElement);
     294        this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
     295    },
     296
     297    _startSidebarDragging: function(event)
     298    {
     299        WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize");
     300    },
     301
     302    _sidebarDragging: function(event)
     303    {
     304        this._updateSidebarWidth(event.pageX);
     305
     306        event.preventDefault();
     307    },
     308
     309    _endSidebarDragging: function(event)
     310    {
     311        WebInspector.elementDragEnd(event);
     312    },
     313
     314    _updateSidebarWidth: function(width)
     315    {
     316        if (this.sidebarElement.offsetWidth <= 0) {
     317            // The stylesheet hasn't loaded yet or the window is closed,
     318            // so we can't calculate what is need. Return early.
     319            return;
     320        }
     321
     322        if (!("_currentSidebarWidth" in this))
     323            this._currentSidebarWidth = this.sidebarElement.offsetWidth;
     324
     325        if (typeof width === "undefined")
     326            width = this._currentSidebarWidth;
     327
     328        width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2);
     329
     330        this._currentSidebarWidth = width;
     331
     332        this.sidebarElement.style.width = width + "px";
     333        this.setMainViewWidth(width);
     334        this.sidebarResizeElement.style.left = (width - 3) + "px";
     335       
     336        var visibleView = this.visibleView;
     337        if (visibleView && "resize" in visibleView)
     338            visibleView.resize();
     339    },
     340   
     341    setMainViewWidth: function(width)
     342    {
     343        // Should be implemented by ancestors.
    270344    }
    271345}
  • trunk/WebCore/inspector/front-end/ProfilesPanel.js

    r49905 r49997  
    8686WebInspector.ProfilesPanel = function()
    8787{
    88     WebInspector.Panel.call(this);
     88    WebInspector.Panel.call(this, true);
    8989
    9090    this.element.addStyleClass("profiles");
     
    9999
    100100    this.element.appendChild(this.panelEnablerView.element);
    101 
    102     this.sidebarElement = document.createElement("div");
    103     this.sidebarElement.id = "profiles-sidebar";
    104     this.sidebarElement.className = "sidebar";
    105     this.element.appendChild(this.sidebarElement);
    106 
    107     this.sidebarResizeElement = document.createElement("div");
    108     this.sidebarResizeElement.className = "sidebar-resizer-vertical";
    109     this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false);
    110     this.element.appendChild(this.sidebarResizeElement);
    111 
    112     this.sidebarTreeElement = document.createElement("ol");
    113     this.sidebarTreeElement.className = "sidebar-tree";
    114     this.sidebarElement.appendChild(this.sidebarTreeElement);
    115     this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
    116101
    117102    this.profileViews = document.createElement("div");
     
    163148    {
    164149        WebInspector.Panel.prototype.show.call(this);
    165         this._updateSidebarWidth();
    166150        if (this._shouldPopulateProfiles)
    167151            this._populateProfiles();
     
    210194
    211195        this._updateInterface();
    212     },
    213 
    214     handleKeyEvent: function(event)
    215     {
    216         this.sidebarTree.handleKeyEvent(event);
    217196    },
    218197
     
    471450    },
    472451
    473     _startSidebarDragging: function(event)
    474     {
    475         WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize");
    476     },
    477 
    478     _sidebarDragging: function(event)
    479     {
    480         this._updateSidebarWidth(event.pageX);
    481 
    482         event.preventDefault();
    483     },
    484 
    485     _endSidebarDragging: function(event)
    486     {
    487         WebInspector.elementDragEnd(event);
    488     },
    489 
    490     _updateSidebarWidth: function(width)
    491     {
    492         if (this.sidebarElement.offsetWidth <= 0) {
    493             // The stylesheet hasn't loaded yet or the window is closed,
    494             // so we can't calculate what is need. Return early.
    495             return;
    496         }
    497 
    498         if (!("_currentSidebarWidth" in this))
    499             this._currentSidebarWidth = this.sidebarElement.offsetWidth;
    500 
    501         if (typeof width === "undefined")
    502             width = this._currentSidebarWidth;
    503 
    504         width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2);
    505 
    506         this._currentSidebarWidth = width;
    507 
    508         this.sidebarElement.style.width = width + "px";
     452    setMainViewWidth: function(width)
     453    {
    509454        this.profileViews.style.left = width + "px";
    510455        this.profileViewStatusBarItemsContainer.style.left = width + "px";
    511         this.sidebarResizeElement.style.left = (width - 3) + "px";
    512        
    513         var visibleView = this.visibleView;
    514         if (visibleView && "resize" in visibleView)
    515             visibleView.resize();
    516456    }
    517457}
  • trunk/WebCore/inspector/front-end/StoragePanel.js

    r49314 r49997  
    3030WebInspector.StoragePanel = function(database)
    3131{
    32     WebInspector.Panel.call(this);
    33 
    34     this.sidebarElement = document.createElement("div");
    35     this.sidebarElement.id = "storage-sidebar";
    36     this.sidebarElement.className = "sidebar";
    37     this.element.appendChild(this.sidebarElement);
    38 
    39     this.sidebarResizeElement = document.createElement("div");
    40     this.sidebarResizeElement.className = "sidebar-resizer-vertical";
    41     this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false);
    42     this.element.appendChild(this.sidebarResizeElement);
    43 
    44     this.sidebarTreeElement = document.createElement("ol");
    45     this.sidebarTreeElement.className = "sidebar-tree";
    46     this.sidebarElement.appendChild(this.sidebarTreeElement);
    47 
    48     this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
     32    WebInspector.Panel.call(this, true);
    4933
    5034    this.databasesListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("DATABASES"), {}, true);
     
    8569    {
    8670        return [this.storageViewStatusBarItemsContainer];
    87     },
    88 
    89     show: function()
    90     {
    91         WebInspector.Panel.prototype.show.call(this);
    92         this._updateSidebarWidth();
    9371    },
    9472
     
    417395    },
    418396
    419     _startSidebarDragging: function(event)
    420     {
    421         WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize");
    422     },
    423 
    424     _sidebarDragging: function(event)
    425     {
    426         this._updateSidebarWidth(event.pageX);
    427 
    428         event.preventDefault();
    429     },
    430 
    431     _endSidebarDragging: function(event)
    432     {
    433         WebInspector.elementDragEnd(event);
    434     },
    435 
    436     _updateSidebarWidth: function(width)
    437     {
    438         if (this.sidebarElement.offsetWidth <= 0) {
    439             // The stylesheet hasn't loaded yet or the window is closed,
    440             // so we can't calculate what is need. Return early.
    441             return;
    442         }
    443 
    444         if (!("_currentSidebarWidth" in this))
    445             this._currentSidebarWidth = this.sidebarElement.offsetWidth;
    446 
    447         if (typeof width === "undefined")
    448             width = this._currentSidebarWidth;
    449 
    450         width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2);
    451 
    452         this._currentSidebarWidth = width;
    453 
    454         this.sidebarElement.style.width = width + "px";
     397    setMainViewWidth: function(width)
     398    {
    455399        this.storageViews.style.left = width + "px";
    456400        this.storageViewStatusBarItemsContainer.style.left = width + "px";
    457         this.sidebarResizeElement.style.left = (width - 3) + "px";
    458        
    459         var visibleView = this.visibleView;
    460         if (visibleView && "resize" in visibleView)
    461             visibleView.resize();
    462401    }
    463402}
Note: See TracChangeset for help on using the changeset viewer.