Changeset 84161 in webkit
- Timestamp:
- Apr 18, 2011 10:51:06 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84158 r84161 1 2011-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 1 22 2011-04-18 Timothy Hatcher <timothy@apple.com> 2 23 -
trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js
r83969 r84161 202 202 var frameTreeElement = this._treeElementForFrameId[frameId]; 203 203 if (frameTreeElement) { 204 // Maintain sorted order. 205 frameTreeElement.parent.removeChild(frameTreeElement); 204 206 frameTreeElement.setTitles(title, subtitle); 207 frameTreeElement.parent.appendChild(frameTreeElement); 205 208 return; 206 209 } … … 214 217 var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, title, subtitle); 215 218 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 }230 219 parentTreeElement.appendChild(frameTreeElement); 231 220 }, … … 257 246 } 258 247 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); 274 249 }, 275 250 … … 830 805 WebInspector.ResourcesPanel.prototype.__proto__ = WebInspector.Panel.prototype; 831 806 832 WebInspector.BaseStorageTreeElement = function(storagePanel, representedObject, title, iconClasses, hasChildren )807 WebInspector.BaseStorageTreeElement = function(storagePanel, representedObject, title, iconClasses, hasChildren, noIcon) 833 808 { 834 809 TreeElement.call(this, "", representedObject, hasChildren); … … 836 811 this._titleText = title; 837 812 this._iconClasses = iconClasses; 813 this._noIcon = noIcon; 838 814 } 839 815 … … 851 827 this.listItemElement.appendChild(selectionElement); 852 828 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 } 856 834 857 835 this.titleElement = document.createElement("div"); … … 899 877 WebInspector.BaseStorageTreeElement.prototype.__proto__ = TreeElement.prototype; 900 878 901 WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClasses )879 WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClasses, noIcon) 902 880 { 903 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClasses, true );881 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClasses, true, noIcon); 904 882 this._expandedSettingKey = "resources" + settingsKey + "Expanded"; 905 883 WebInspector.settings.installApplicationSetting(this._expandedSettingKey, settingsKey === "Frames"); … … 943 921 this._frameId = frameId; 944 922 this.setTitles(title, subtitle); 923 this._categoryElements = {}; 945 924 } 946 925 … … 977 956 setTitles: function(title, subtitle) 978 957 { 979 this._displayName = ""; 958 this._displayName = title || ""; 959 if (subtitle) 960 this._displayName += " (" + subtitle + ")"; 961 980 962 if (this.parent) { 981 963 this.titleElement.textContent = title || ""; 982 this._displayName = title || "";983 964 if (subtitle) { 984 965 var subtitleElement = document.createElement("span"); 985 966 subtitleElement.className = "base-storage-tree-element-subtitle"; 986 967 subtitleElement.textContent = "(" + subtitle + ")"; 987 this._displayName += " (" + subtitle + ")";988 968 this.titleElement.appendChild(subtitleElement); 989 969 } … … 1003 983 DOMAgent.hideFrameHighlight(); 1004 984 } 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); 1005 1043 } 1006 1044 } 1045 1007 1046 WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 1008 1047
Note: See TracChangeset
for help on using the changeset viewer.