Changeset 84161 in webkit


Ignore:
Timestamp:
Apr 18, 2011 10:51:06 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2011-04-18 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: group resources by type in the resources panel.
https://bugs.webkit.org/show_bug.cgi?id=58796

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84158 r84161  
     12011-04-18  Pavel Feldman  <pfeldman@google.com>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: group resources by type in the resources panel.
     6        https://bugs.webkit.org/show_bug.cgi?id=58796
     7
     8        * inspector/front-end/ResourcesPanel.js:
     9        (WebInspector.ResourcesPanel.prototype._frameAdded):
     10        (WebInspector.ResourcesPanel.prototype._resourceAdded):
     11        (WebInspector.BaseStorageTreeElement):
     12        (WebInspector.BaseStorageTreeElement.prototype.onattach):
     13        (WebInspector.StorageCategoryTreeElement):
     14        (WebInspector.FrameTreeElement):
     15        (WebInspector.FrameTreeElement.prototype.setTitles):
     16        (WebInspector.FrameTreeElement.prototype.set hovered):
     17        (WebInspector.FrameTreeElement.prototype.appendResource):
     18        (WebInspector.FrameTreeElement.prototype.appendChild):
     19        (WebInspector.FrameTreeElement.prototype._insertInPresentationOrder):
     20        (WebInspector.FrameTreeElement.prototype._insertInPresentationOrder.compare):
     21
    1222011-04-18  Timothy Hatcher  <timothy@apple.com>
    223
  • trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js

    r83969 r84161  
    202202        var frameTreeElement = this._treeElementForFrameId[frameId];
    203203        if (frameTreeElement) {
     204            // Maintain sorted order.
     205            frameTreeElement.parent.removeChild(frameTreeElement);
    204206            frameTreeElement.setTitles(title, subtitle);
     207            frameTreeElement.parent.appendChild(frameTreeElement);
    205208            return;
    206209        }
     
    214217        var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, title, subtitle);
    215218        this._treeElementForFrameId[frameId] = frameTreeElement;
    216 
    217         // Insert in the alphabetical order, first frames, then resources.
    218         var children = parentTreeElement.children;
    219         for (var i = 0; i < children.length; ++i) {
    220             var child = children[i];
    221             if (!(child instanceof WebInspector.FrameTreeElement)) {
    222                 parentTreeElement.insertChild(frameTreeElement, i);
    223                 return;
    224             }
    225             if (child.displayName.localeCompare(frameTreeElement.displayName) > 0) {
    226                 parentTreeElement.insertChild(frameTreeElement, i);
    227                 return;
    228             }
    229         }
    230219        parentTreeElement.appendChild(frameTreeElement);
    231220    },
     
    257246        }
    258247
    259         var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this, resource);
    260 
    261         // Insert in the alphabetical order, first frames, then resources. Document resource goes first.
    262         var children = frameTreeElement.children;
    263         var i;
    264         for (i = 0; i < children.length; ++i) {
    265             var child = children[i];
    266             if (!(child instanceof WebInspector.FrameResourceTreeElement))
    267                 continue;
    268 
    269             if (resource.type === WebInspector.Resource.Type.Document || (child._resource.type !== WebInspector.Resource.Type.Document && child._resource.displayName.localeCompare(resource.displayName) > 0))
    270                 break;
    271         }
    272         frameTreeElement.insertChild(resourceTreeElement, i);
    273         resourceTreeElement._populateRevisions();
     248        frameTreeElement.appendResource(resource);
    274249    },
    275250
     
    830805WebInspector.ResourcesPanel.prototype.__proto__ = WebInspector.Panel.prototype;
    831806
    832 WebInspector.BaseStorageTreeElement = function(storagePanel, representedObject, title, iconClasses, hasChildren)
     807WebInspector.BaseStorageTreeElement = function(storagePanel, representedObject, title, iconClasses, hasChildren, noIcon)
    833808{
    834809    TreeElement.call(this, "", representedObject, hasChildren);
     
    836811    this._titleText = title;
    837812    this._iconClasses = iconClasses;
     813    this._noIcon = noIcon;
    838814}
    839815
     
    851827        this.listItemElement.appendChild(selectionElement);
    852828
    853         this.imageElement = document.createElement("img");
    854         this.imageElement.className = "icon";
    855         this.listItemElement.appendChild(this.imageElement);
     829        if (!this._noIcon) {
     830            this.imageElement = document.createElement("img");
     831            this.imageElement.className = "icon";
     832            this.listItemElement.appendChild(this.imageElement);
     833        }
    856834
    857835        this.titleElement = document.createElement("div");
     
    899877WebInspector.BaseStorageTreeElement.prototype.__proto__ = TreeElement.prototype;
    900878
    901 WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClasses)
     879WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClasses, noIcon)
    902880{
    903     WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClasses, true);
     881    WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClasses, true, noIcon);
    904882    this._expandedSettingKey = "resources" + settingsKey + "Expanded";
    905883    WebInspector.settings.installApplicationSetting(this._expandedSettingKey, settingsKey === "Frames");
     
    943921    this._frameId = frameId;
    944922    this.setTitles(title, subtitle);
     923    this._categoryElements = {};
    945924}
    946925
     
    977956    setTitles: function(title, subtitle)
    978957    {
    979         this._displayName = "";
     958        this._displayName = title || "";
     959        if (subtitle)
     960            this._displayName += " (" + subtitle + ")";
     961
    980962        if (this.parent) {
    981963            this.titleElement.textContent = title || "";
    982             this._displayName = title || "";
    983964            if (subtitle) {
    984965                var subtitleElement = document.createElement("span");
    985966                subtitleElement.className = "base-storage-tree-element-subtitle";
    986967                subtitleElement.textContent = "(" + subtitle + ")";
    987                 this._displayName += " (" + subtitle + ")";
    988968                this.titleElement.appendChild(subtitleElement);
    989969            }
     
    1003983            DOMAgent.hideFrameHighlight();
    1004984        }
     985    },
     986
     987    appendResource: function(resource)
     988    {
     989        var categoryName = resource.category.name;
     990        var categoryElement = resource.category === WebInspector.resourceCategories.documents ? this : this._categoryElements[categoryName];
     991        if (!categoryElement) {
     992            categoryElement = new WebInspector.StorageCategoryTreeElement(this._storagePanel, resource.category.title, categoryName, null, true);
     993            this._categoryElements[resource.category.name] = categoryElement;
     994            this._insertInPresentationOrder(this, categoryElement);
     995        }
     996        var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this._storagePanel, resource);
     997        this._insertInPresentationOrder(categoryElement, resourceTreeElement);
     998        resourceTreeElement._populateRevisions();
     999    },
     1000
     1001    appendChild: function(treeElement)
     1002    {
     1003        this._insertInPresentationOrder(this, treeElement);
     1004    },
     1005
     1006    _insertInPresentationOrder: function(parentTreeElement, childTreeElement)
     1007    {
     1008        // Insert in the alphabetical order, first frames, then resources. Document resource goes last.
     1009        function typeWeight(treeElement)
     1010        {
     1011            if (treeElement instanceof WebInspector.StorageCategoryTreeElement)
     1012                return 2;
     1013            if (treeElement instanceof WebInspector.FrameTreeElement)
     1014                return 1;
     1015            return 3;
     1016        }
     1017
     1018        function compare(treeElement1, treeElement2)
     1019        {
     1020            var typeWeight1 = typeWeight(treeElement1);
     1021            var typeWeight2 = typeWeight(treeElement2);
     1022
     1023            var result;
     1024            if (typeWeight1 > typeWeight2)
     1025                result = 1;
     1026            else if (typeWeight1 < typeWeight2)
     1027                result = -1;
     1028            else {
     1029                var title1 = treeElement1.displayName || treeElement1.titleText;
     1030                var title2 = treeElement2.displayName || treeElement2.titleText;
     1031                result = title1.localeCompare(title2);
     1032            }
     1033            return result;           
     1034        }
     1035
     1036        var children = parentTreeElement.children;
     1037        var i;
     1038        for (i = 0; i < children.length; ++i) {
     1039            if (compare(childTreeElement, children[i]) < 0)
     1040                break;
     1041        }
     1042        parentTreeElement.insertChild(childTreeElement, i);
    10051043    }
    10061044}
     1045
    10071046WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
    10081047
Note: See TracChangeset for help on using the changeset viewer.