Changeset 50033 in webkit


Ignore:
Timestamp:
Oct 24, 2009 4:08:09 PM (14 years ago)
Author:
timothy@apple.com
Message:

Make resizing the Web Inspector's Elements panel sidebar work again.
Also makes Resources panel use the sidebar code in Panel.

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

Reviewed by Pavel Feldman.

  • inspector/front-end/Panel.js:

(WebInspector.Panel): Don't create the sidebar with an argument.
(WebInspector.Panel.prototype.show): Call updateSidebarWidth.
(WebInspector.Panel.prototype.handleKeyEvent): Call handleSidebarKeyEvent.
(WebInspector.Panel.prototype.handleSidebarKeyEvent): Added.
(WebInspector.Panel.prototype.createSidebar): Renamed from _createSidebar.
(WebInspector.Panel.prototype._sidebarDragging): Call updateSidebarWidth.
(WebInspector.Panel.prototype.updateSidebarWidth): Renamed from _updateSidebarWidth.
(WebInspector.Panel.prototype.setSidebarWidth): Added. Called by updateSidebarWidth.
(WebInspector.Panel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.

  • inspector/front-end/ProfilesPanel.js:

(WebInspector.ProfilesPanel): Call createSidebar.
(WebInspector.ProfilesPanel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.

  • inspector/front-end/ResourcesPanel.js:

(WebInspector.ResourcesPanel.prototype.show): Remove call to _updateSidebarWidth.
(WebInspector.ResourcesPanel.prototype.showResource): Call updateSidebarWidth
(WebInspector.ResourcesPanel.prototype.closeVisibleResource): Ditto.
(WebInspector.ResourcesPanel.prototype.setSidebarWidth): Added.
(WebInspector.ResourcesPanel.prototype.updateMainViewWidth): Added.

  • inspector/front-end/StoragePanel.js:

(WebInspector.StoragePanel): Call createSidebar.
(WebInspector.StoragePanel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.

  • inspector/front-end/TimelinePanel.js:

(WebInspector.TimelinePanel): Call createSidebar.
(WebInspector.TimelinePanel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.

Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50032 r50033  
     12009-10-24  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make resizing the Web Inspector's Elements panel sidebar work again.
     4        Also makes Resources panel use the sidebar code in Panel.
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=30742
     7
     8        Reviewed by Pavel Feldman.
     9
     10        * inspector/front-end/Panel.js:
     11        (WebInspector.Panel): Don't create the sidebar with an argument.
     12        (WebInspector.Panel.prototype.show): Call updateSidebarWidth.
     13        (WebInspector.Panel.prototype.handleKeyEvent): Call handleSidebarKeyEvent.
     14        (WebInspector.Panel.prototype.handleSidebarKeyEvent): Added.
     15        (WebInspector.Panel.prototype.createSidebar): Renamed from _createSidebar.
     16        (WebInspector.Panel.prototype._sidebarDragging): Call updateSidebarWidth.
     17        (WebInspector.Panel.prototype.updateSidebarWidth): Renamed from _updateSidebarWidth.
     18        (WebInspector.Panel.prototype.setSidebarWidth): Added. Called by updateSidebarWidth.
     19        (WebInspector.Panel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.
     20        * inspector/front-end/ProfilesPanel.js:
     21        (WebInspector.ProfilesPanel): Call createSidebar.
     22        (WebInspector.ProfilesPanel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.
     23        * inspector/front-end/ResourcesPanel.js:
     24        (WebInspector.ResourcesPanel.prototype.show): Remove call to _updateSidebarWidth.
     25        (WebInspector.ResourcesPanel.prototype.showResource): Call updateSidebarWidth
     26        (WebInspector.ResourcesPanel.prototype.closeVisibleResource): Ditto.
     27        (WebInspector.ResourcesPanel.prototype.setSidebarWidth): Added.
     28        (WebInspector.ResourcesPanel.prototype.updateMainViewWidth): Added.
     29        * inspector/front-end/StoragePanel.js:
     30        (WebInspector.StoragePanel): Call createSidebar.
     31        (WebInspector.StoragePanel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.
     32        * inspector/front-end/TimelinePanel.js:
     33        (WebInspector.TimelinePanel): Call createSidebar.
     34        (WebInspector.TimelinePanel.prototype.updateMainViewWidth): Renamed from setMainViewWidth.
     35
    1362009-10-24  Timothy Hatcher  <timothy@apple.com>
    237
  • trunk/WebCore/inspector/front-end/Panel.js

    r49997 r50033  
    2727 */
    2828
    29 WebInspector.Panel = function(createSidebar)
     29WebInspector.Panel = function()
    3030{
    3131    WebInspector.View.call(this);
    32     if (createSidebar)
    33         this._createSidebar();
    3432
    3533    this.element.addStyleClass("panel");
     
    8583
    8684        WebInspector.currentFocusElement = document.getElementById("main-panels");
    87         this._updateSidebarWidth();
     85
     86        this.updateSidebarWidth();
    8887    },
    8988
     
    275274    handleKeyEvent: function(event)
    276275    {
    277         this.sidebarTree.handleKeyEvent(event);
    278     },
    279 
    280     _createSidebar: function()
    281     {
     276        this.handleSidebarKeyEvent(event);
     277    },
     278
     279    handleSidebarKeyEvent: function(event)
     280    {
     281        if (this.hasSidebar && this.sidebarTree)
     282            this.sidebarTree.handleKeyEvent(event);
     283    },
     284
     285    createSidebar: function(parentElement, resizerParentElement)
     286    {
     287        if (this.hasSidebar)
     288            return;
     289
     290        if (!parentElement)
     291            parentElement = this.element;
     292
     293        if (!resizerParentElement)
     294            resizerParentElement = parentElement;
     295
     296        this.hasSidebar = true;
     297
    282298        this.sidebarElement = document.createElement("div");
    283299        this.sidebarElement.className = "sidebar";
    284         this.element.appendChild(this.sidebarElement);
     300        parentElement.appendChild(this.sidebarElement);
    285301
    286302        this.sidebarResizeElement = document.createElement("div");
    287303        this.sidebarResizeElement.className = "sidebar-resizer-vertical";
    288304        this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false);
    289         this.element.appendChild(this.sidebarResizeElement);
     305        resizerParentElement.appendChild(this.sidebarResizeElement);
    290306
    291307        this.sidebarTreeElement = document.createElement("ol");
    292308        this.sidebarTreeElement.className = "sidebar-tree";
    293309        this.sidebarElement.appendChild(this.sidebarTreeElement);
     310
    294311        this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
    295312    },
     
    302319    _sidebarDragging: function(event)
    303320    {
    304         this._updateSidebarWidth(event.pageX);
     321        this.updateSidebarWidth(event.pageX);
    305322
    306323        event.preventDefault();
     
    312329    },
    313330
    314     _updateSidebarWidth: function(width)
    315     {
     331    updateSidebarWidth: function(width)
     332    {
     333        if (!this.hasSidebar)
     334            return;
     335
    316336        if (this.sidebarElement.offsetWidth <= 0) {
    317337            // The stylesheet hasn't loaded yet or the window is closed,
     
    329349
    330350        this._currentSidebarWidth = width;
    331 
    332         this.sidebarElement.style.width = width + "px";
    333         this.setMainViewWidth(width);
    334         this.sidebarResizeElement.style.left = (width - 3) + "px";
    335        
     351        this.setSidebarWidth(width);
     352
     353        this.updateMainViewWidth(width);
     354
    336355        var visibleView = this.visibleView;
    337356        if (visibleView && "resize" in visibleView)
    338357            visibleView.resize();
    339358    },
    340    
    341     setMainViewWidth: function(width)
     359
     360    setSidebarWidth: function(width)
     361    {
     362        this.sidebarElement.style.width = width + "px";
     363        this.sidebarResizeElement.style.left = (width - 3) + "px";
     364    },
     365
     366    updateMainViewWidth: function(width)
    342367    {
    343368        // Should be implemented by ancestors.
  • trunk/WebCore/inspector/front-end/ProfilesPanel.js

    r49997 r50033  
    8686WebInspector.ProfilesPanel = function()
    8787{
    88     WebInspector.Panel.call(this, true);
     88    WebInspector.Panel.call(this);
     89
     90    this.createSidebar();
    8991
    9092    this.element.addStyleClass("profiles");
     
    450452    },
    451453
    452     setMainViewWidth: function(width)
     454    updateMainViewWidth: function(width)
    453455    {
    454456        this.profileViews.style.left = width + "px";
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r50021 r50033  
    4747    this.element.appendChild(this.containerElement);
    4848
    49     this.sidebarElement = document.createElement("div");
     49    this.createSidebar(this.containerElement, this.element);
     50
    5051    this.sidebarElement.id = "resources-sidebar";
    51     this.sidebarElement.className = "sidebar";
    52     this.containerElement.appendChild(this.sidebarElement);
    53 
    54     this.sidebarResizeElement = document.createElement("div");
    55     this.sidebarResizeElement.className = "sidebar-resizer-vertical";
    56     this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDragging.bind(this), false);
    57     this.element.appendChild(this.sidebarResizeElement);
    5852
    5953    this.containerContentElement = document.createElement("div");
     
    8074    this.dividersLabelBarElement.id = "resources-dividers-label-bar";
    8175    this.containerContentElement.appendChild(this.dividersLabelBarElement);
    82 
    83     this.sidebarTreeElement = document.createElement("ol");
    84     this.sidebarTreeElement.className = "sidebar-tree";
    85     this.sidebarElement.appendChild(this.sidebarTreeElement);
    86 
    87     this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
    8876
    8977    var timeGraphItem = new WebInspector.SidebarTreeElement("resources-time-graph-sidebar-item", WebInspector.UIString("Time"));
     
    285273
    286274        this._updateDividersLabelBarPosition();
    287         this._updateSidebarWidth();
    288275        this.refreshIfNeeded();
    289276
     
    676663        this.visibleResource = resource;
    677664
    678         this._updateSidebarWidth();
     665        this.updateSidebarWidth();
    679666    },
    680667
     
    698685            this._lastSelectedGraphTreeElement.select(true);
    699686
    700         this._updateSidebarWidth();
     687        this.updateSidebarWidth();
    701688    },
    702689
     
    725712        view.setupSourceFrameIfNeeded();
    726713        return view.sourceFrame;
    727     },
    728 
    729     handleKeyEvent: function(event)
    730     {
    731         this.sidebarTree.handleKeyEvent(event);
    732714    },
    733715
     
    927909    },
    928910
    929     _startSidebarDragging: function(event)
    930     {
    931         WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize");
    932     },
    933 
    934     _sidebarDragging: function(event)
    935     {
    936         this._updateSidebarWidth(event.pageX);
    937 
    938         event.preventDefault();
    939     },
    940 
    941     _endSidebarDragging: function(event)
    942     {
    943         WebInspector.elementDragEnd(event);
    944     },
    945 
    946     _updateSidebarWidth: function(width)
    947     {
    948         if (this.sidebarElement.offsetWidth <= 0) {
    949             // The stylesheet hasn't loaded yet or the window is closed,
    950             // so we can't calculate what is need. Return early.
    951             return;
    952         }
    953 
    954         if (!("_currentSidebarWidth" in this))
    955             this._currentSidebarWidth = this.sidebarElement.offsetWidth;
    956 
    957         if (typeof width === "undefined")
    958             width = this._currentSidebarWidth;
    959 
    960         width = Number.constrain(width, Preferences.minSidebarWidth, window.innerWidth / 2);
    961 
    962         this._currentSidebarWidth = width;
    963 
     911    setSidebarWidth: function(width)
     912    {
    964913        if (this.visibleResource) {
    965914            this.containerElement.style.width = width + "px";
     
    970919        }
    971920
     921        this.sidebarResizeElement.style.left = (width - 3) + "px";
     922    },
     923
     924    updateMainViewWidth: function(width)
     925    {
    972926        this.containerContentElement.style.left = width + "px";
    973927        this.viewsContainerElement.style.left = width + "px";
    974         this.sidebarResizeElement.style.left = (width - 3) + "px";
    975928
    976929        this._updateGraphDividersIfNeeded();
    977 
    978         var visibleView = this.visibleView;
    979         if (visibleView && "resize" in visibleView)
    980             visibleView.resize();
    981930    },
    982931
  • trunk/WebCore/inspector/front-end/StoragePanel.js

    r49997 r50033  
    3030WebInspector.StoragePanel = function(database)
    3131{
    32     WebInspector.Panel.call(this, true);
     32    WebInspector.Panel.call(this);
     33
     34    this.createSidebar();
    3335
    3436    this.databasesListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("DATABASES"), {}, true);
     
    110112        if (this.sidebarTree.selectedTreeElement)
    111113            this.sidebarTree.selectedTreeElement.deselect();
    112     },
    113 
    114     handleKeyEvent: function(event)
    115     {
    116         this.sidebarTree.handleKeyEvent(event);
    117114    },
    118115
     
    395392    },
    396393
    397     setMainViewWidth: function(width)
     394    updateMainViewWidth: function(width)
    398395    {
    399396        this.storageViews.style.left = width + "px";
  • trunk/WebCore/inspector/front-end/TimelinePanel.js

    r50015 r50033  
    3131WebInspector.TimelinePanel = function()
    3232{
    33     WebInspector.Panel.call(this, true);
     33    WebInspector.Panel.call(this);
     34
     35    this.createSidebar();
    3436
    3537    this.element.addStyleClass("timeline");
     
    5860    {
    5961        return [this.toggleTimelineButton.element];
    60     },
    61 
    62     handleKeyEvent: function(event)
    63     {
    64         this.sidebarTree.handleKeyEvent(event);
    6562    },
    6663
     
    9895    },
    9996
    100     setMainViewWidth: function(width)
     97    updateMainViewWidth: function(width)
    10198    {
    10299        this.timelineView.style.left = width + "px";
Note: See TracChangeset for help on using the changeset viewer.