Changeset 64037 in webkit


Ignore:
Timestamp:
Jul 26, 2010 2:37:38 AM (14 years ago)
Author:
apavlov@chromium.org
Message:

2010-07-26 Alexander Pavlov <apavlov@chromium.org>

Reviewed by Joseph Pecoraro.

Inspector should remember resources sorting set by the user
https://bugs.webkit.org/show_bug.cgi?id=19208

Sorting options both for time and size graphs are memorized in a single property,
which makes them possible to retrieve in a single message (e.g. useful for remote debugging).

  • inspector/front-end/ResourcesPanel.js: (WebInspector.ResourcesPanel.prototype.populateSidebar): (WebInspector.ResourcesPanel.prototype._settingsLoaded): (WebInspector.ResourcesPanel.prototype._loadSortOptions): (WebInspector.ResourcesPanel.prototype._loadSortOptionForGraph): (WebInspector.ResourcesPanel.prototype._graphSelected): (WebInspector.ResourcesPanel.prototype._changeSortingFunction): (WebInspector.ResourcesPanel.prototype._selectedOptionNameForGraph): (WebInspector.ResourcesPanel.prototype._doChangeSortingFunction):
  • inspector/front-end/Settings.js: (WebInspector.populateApplicationSettings):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64034 r64037  
     12010-07-26  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by Joseph Pecoraro.
     4
     5        Inspector should remember resources sorting set by the user
     6        https://bugs.webkit.org/show_bug.cgi?id=19208
     7
     8        Sorting options both for time and size graphs are memorized in a single property,
     9        which makes them possible to retrieve in a single message (e.g. useful for remote debugging).
     10
     11        * inspector/front-end/ResourcesPanel.js:
     12        (WebInspector.ResourcesPanel.prototype.populateSidebar):
     13        (WebInspector.ResourcesPanel.prototype._settingsLoaded):
     14        (WebInspector.ResourcesPanel.prototype._loadSortOptions):
     15        (WebInspector.ResourcesPanel.prototype._loadSortOptionForGraph):
     16        (WebInspector.ResourcesPanel.prototype._graphSelected):
     17        (WebInspector.ResourcesPanel.prototype._changeSortingFunction):
     18        (WebInspector.ResourcesPanel.prototype._selectedOptionNameForGraph):
     19        (WebInspector.ResourcesPanel.prototype._doChangeSortingFunction):
     20        * inspector/front-end/Settings.js:
     21        (WebInspector.populateApplicationSettings):
     22
    1232010-07-25  Ryosuke Niwa  <rniwa@webkit.org>
    224
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r63741 r64037  
    8383    populateSidebar: function()
    8484    {
    85         var timeGraphItem = new WebInspector.SidebarTreeElement("resources-time-graph-sidebar-item", WebInspector.UIString("Time"));
    86         timeGraphItem.onselect = this._graphSelected.bind(this);
     85        this.timeGraphItem = new WebInspector.SidebarTreeElement("resources-time-graph-sidebar-item", WebInspector.UIString("Time"));
     86        this.timeGraphItem.onselect = this._graphSelected.bind(this);
    8787
    8888        var transferTimeCalculator = new WebInspector.ResourceTransferTimeCalculator();
    8989        var transferDurationCalculator = new WebInspector.ResourceTransferDurationCalculator();
    9090
    91         timeGraphItem.sortingOptions = [
    92             { name: WebInspector.UIString("Sort by Start Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingStartTime, calculator: transferTimeCalculator },
    93             { name: WebInspector.UIString("Sort by Response Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingResponseReceivedTime, calculator: transferTimeCalculator },
    94             { name: WebInspector.UIString("Sort by End Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingEndTime, calculator: transferTimeCalculator },
    95             { name: WebInspector.UIString("Sort by Duration"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingDuration, calculator: transferDurationCalculator },
    96             { name: WebInspector.UIString("Sort by Latency"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingLatency, calculator: transferDurationCalculator },
     91        this.timeGraphItem.sortingOptions = [
     92            { name: WebInspector.UIString("Sort by Start Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingStartTime, calculator: transferTimeCalculator, optionName: "startTime" },
     93            { name: WebInspector.UIString("Sort by Response Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingResponseReceivedTime, calculator: transferTimeCalculator, optionName: "responseTime" },
     94            { name: WebInspector.UIString("Sort by End Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingEndTime, calculator: transferTimeCalculator, optionName: "endTime" },
     95            { name: WebInspector.UIString("Sort by Duration"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingDuration, calculator: transferDurationCalculator, optionName: "duration" },
     96            { name: WebInspector.UIString("Sort by Latency"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingLatency, calculator: transferDurationCalculator, optionName: "latency" },
    9797        ];
    9898
    99         timeGraphItem.isBarOpaqueAtLeft = false;
    100         timeGraphItem.selectedSortingOptionIndex = 1;
     99        this.timeGraphItem.isBarOpaqueAtLeft = false;
     100        this.timeGraphItem.selectedSortingOptionIndex = 1;
    101101
    102102        this.sizeGraphItem = new WebInspector.SidebarTreeElement("resources-size-graph-sidebar-item", WebInspector.UIString("Size"));
     
    105105        var transferSizeCalculator = new WebInspector.ResourceTransferSizeCalculator();
    106106        this.sizeGraphItem.sortingOptions = [
    107             { name: WebInspector.UIString("Sort by Transfer Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize, calculator: transferSizeCalculator },
    108             { name: WebInspector.UIString("Sort by Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize, calculator: transferSizeCalculator },
     107            { name: WebInspector.UIString("Sort by Transfer Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize, calculator: transferSizeCalculator, optionName: "transferSize" },
     108            { name: WebInspector.UIString("Sort by Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize, calculator: transferSizeCalculator, optionName: "size" },
    109109        ];
    110110
     
    115115        this.sidebarTree.appendChild(this.graphsTreeElement);
    116116
    117         this.graphsTreeElement.appendChild(timeGraphItem);
     117        this.graphsTreeElement.appendChild(this.timeGraphItem);
    118118        this.graphsTreeElement.appendChild(this.sizeGraphItem);
    119119        this.graphsTreeElement.expand();
     
    161161        if (!WebInspector.applicationSettings.resourcesLargeRows)
    162162            this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows);
     163        this._loadSortOptions();
     164    },
     165
     166    _loadSortOptions: function()
     167    {
     168        var newOptions = WebInspector.applicationSettings.resourcesSortOptions;
     169        if (!newOptions)
     170            return;
     171
     172        this._loadSortOptionForGraph(this.timeGraphItem, newOptions.timeOption || "responseTime");
     173        this._loadSortOptionForGraph(this.sizeGraphItem, newOptions.sizeOption || "transferSize");
     174    },
     175
     176    _loadSortOptionForGraph: function(graphItem, newOptionName)
     177    {
     178        var sortingOptions = graphItem.sortingOptions;
     179        for (var i = 0; i < sortingOptions.length; ++i) {
     180            if (sortingOptions[i].optionName === newOptionName) {
     181                graphItem.selectedSortingOptionIndex = i;
     182                // Propagate the option change down to the currently selected option.
     183                if (this._lastSelectedGraphTreeElement === graphItem) {
     184                    this._lastSelectedGraphTreeElement = null;
     185                    this._graphSelected(graphItem);
     186                }
     187            }
     188        }
    163189    },
    164190
     
    619645            option.sortingFunction = sortingOption.sortingFunction;
    620646            option.calculator = sortingOption.calculator;
     647            option.optionName = sortingOption.optionName;
    621648            this.sortingSelectElement.appendChild(option);
    622649        }
    623650
    624651        this.sortingSelectElement.selectedIndex = treeElement.selectedSortingOptionIndex;
    625         this._changeSortingFunction();
     652        this._doChangeSortingFunction();
    626653
    627654        this.closeVisibleResource();
     
    659686    _changeSortingFunction: function()
    660687    {
    661         var selectedOption = this.sortingSelectElement[this.sortingSelectElement.selectedIndex];
     688        this._doChangeSortingFunction();
     689        WebInspector.applicationSettings.resourcesSortOptions = {timeOption: this._selectedOptionNameForGraph(this.timeGraphItem), sizeOption: this._selectedOptionNameForGraph(this.sizeGraphItem)};
     690    },
     691
     692    _selectedOptionNameForGraph: function(graphItem)
     693    {
     694        return graphItem.sortingOptions[graphItem.selectedSortingOptionIndex].optionName;
     695    },
     696
     697    _doChangeSortingFunction: function()
     698    {
     699        var selectedIndex = this.sortingSelectElement.selectedIndex;
     700        if (this._lastSelectedGraphTreeElement)
     701            this._lastSelectedGraphTreeElement.selectedSortingOptionIndex = selectedIndex;
     702        var selectedOption = this.sortingSelectElement[selectedIndex];
    662703        this.sortingFunction = selectedOption.sortingFunction;
    663704        this.calculator = this.summaryBar.calculator = selectedOption.calculator;
  • trunk/WebCore/inspector/front-end/Settings.js

    r63889 r64037  
    5959    WebInspector.applicationSettings.installSetting("resourceViewTab", "resource-view-tab", "content");
    6060    WebInspector.applicationSettings.installSetting("consoleHistory", "console-history", []);
     61    WebInspector.applicationSettings.installSetting("resourcesSortOptions", "resources-sort-options", {timeOption: "responseTime", sizeOption: "transferSize"});
    6162
    6263    WebInspector.applicationSettings.dispatchEventToListeners("loaded");
Note: See TracChangeset for help on using the changeset viewer.