Changeset 175784 in webkit
- Timestamp:
- Nov 8, 2014 7:17:40 PM (9 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r175767 r175784 1 2014-11-08 Matt Baker <mattbaker@apple.com> 2 3 Web Inspector: decouple child element folderization logic from FrameTreeElement 4 https://bugs.webkit.org/show_bug.cgi?id=138364 5 6 Reviewed by Timothy Hatcher. 7 8 Created FolderizedTreeElement base class, which FrameTreeElement now inherits via SourceCodeTreeElement. 9 FolderizedTreeElement uses settings provided by derived classes for labeling subfolders and to determine 10 folder membership for child items. 11 12 * UserInterface/Base/Main.js: 13 (WebInspector.canArchiveMainFrame): 14 * UserInterface/Main.html: 15 * UserInterface/Models/LayoutTimelineRecord.js: 16 (WebInspector.LayoutTimelineRecord.displayNameForEventType): 17 (WebInspector.LayoutTimelineRecord.EventType.displayName): Deleted. 18 * UserInterface/Models/Resource.js: 19 (WebInspector.Resource): 20 (WebInspector.Resource.typeFromMIMEType): 21 (WebInspector.Resource.displayNameForType): 22 (WebInspector.Resource.prototype.get syntheticMIMEType): 23 (WebInspector.Resource.prototype.updateForResponse): 24 (WebInspector.Resource.Type.fromMIMEType): Deleted. 25 (WebInspector.Resource.Type.displayName): Deleted. 26 * UserInterface/Models/SourceMapResource.js: 27 (WebInspector.SourceMapResource): 28 * UserInterface/Views/FolderizedTreeElement.js: Added. 29 (WebInspector.FolderizedTreeElement): 30 (WebInspector.FolderizedTreeElement.prototype.get groupedIntoFolders): 31 (WebInspector.FolderizedTreeElement.prototype.set folderSettingsKey): 32 (WebInspector.FolderizedTreeElement.prototype.registerFolderizeSettings): 33 (WebInspector.FolderizedTreeElement.prototype.set removeChildren): 34 (WebInspector.FolderizedTreeElement.prototype.addChildForRepresentedObject): 35 (WebInspector.FolderizedTreeElement.prototype.addRepresentedObjectToNewChildQueue): 36 (WebInspector.FolderizedTreeElement.prototype.removeChildForRepresentedObject): 37 (WebInspector.FolderizedTreeElement.prototype.compareChildTreeElements): 38 (WebInspector.FolderizedTreeElement.prototype.updateParentStatus): 39 (WebInspector.FolderizedTreeElement.prototype._clearNewChildQueue): 40 (WebInspector.FolderizedTreeElement.prototype._populateFromNewChildQueue): 41 (WebInspector.FolderizedTreeElement.prototype._removeRepresentedObjectFromNewChildQueue): 42 (WebInspector.FolderizedTreeElement.prototype._addTreeElement): 43 (WebInspector.FolderizedTreeElement.prototype._compareTreeElementsByMainTitle): 44 (WebInspector.FolderizedTreeElement.prototype._insertFolderTreeElement): 45 (WebInspector.FolderizedTreeElement.prototype._insertChildTreeElement): 46 (WebInspector.FolderizedTreeElement.prototype._removeTreeElement): 47 (WebInspector.FolderizedTreeElement.prototype._parentTreeElementForRepresentedObject): 48 (WebInspector.FolderizedTreeElement.prototype._folderTreeElementExpandedStateChange): 49 (WebInspector.FolderizedTreeElement.prototype._settingsForRepresentedObject): 50 (WebInspector.FolderizedTreeElement.prototype._shouldGroupIntoFolders.pushCategory): 51 (WebInspector.FolderizedTreeElement.prototype._shouldGroupIntoFolders): 52 * UserInterface/Views/FrameTreeElement.js: 53 (.this): 54 (WebInspector.FrameTreeElement.prototype.updateSourceMapResources): 55 (WebInspector.FrameTreeElement.prototype.onattach): 56 (WebInspector.FrameTreeElement.prototype.ondetach): 57 (WebInspector.FrameTreeElement.prototype.compareChildTreeElements): 58 (WebInspector.FrameTreeElement.prototype.onpopulate): 59 (WebInspector.FrameTreeElement.prototype._mainResourceDidChange): 60 (WebInspector.FrameTreeElement.prototype._resourceWasAdded): 61 (WebInspector.FrameTreeElement.prototype._resourceWasRemoved): 62 (WebInspector.FrameTreeElement.prototype._childFrameWasAdded): 63 (WebInspector.FrameTreeElement.prototype._childFrameWasRemoved): 64 (WebInspector.FrameTreeElement.prototype._childContentFlowWasAdded): 65 (WebInspector.FrameTreeElement.prototype._childContentFlowWasRemoved): 66 (WebInspector.FrameTreeElement.prototype._rootDOMNodeInvalidated): 67 (WebInspector.FrameTreeElement): Deleted. 68 (WebInspector.FrameTreeElement.prototype.removeChildren): Deleted. 69 (WebInspector.FrameTreeElement.prototype._updateParentStatus): Deleted. 70 (WebInspector.FrameTreeElement.prototype._addRepresentedObjectToNewChildQueue): Deleted. 71 (WebInspector.FrameTreeElement.prototype._removeRepresentedObjectFromNewChildQueue): Deleted. 72 (WebInspector.FrameTreeElement.prototype._populateFromNewChildQueue): Deleted. 73 (WebInspector.FrameTreeElement.prototype._clearNewChildQueue): Deleted. 74 (WebInspector.FrameTreeElement.prototype._addChildForRepresentedObject): Deleted. 75 (WebInspector.FrameTreeElement.prototype._removeChildForRepresentedObject): Deleted. 76 (WebInspector.FrameTreeElement.prototype._addTreeElementForRepresentedObject): Deleted. 77 (WebInspector.FrameTreeElement.prototype._addTreeElement): Deleted. 78 (WebInspector.FrameTreeElement.prototype._compareTreeElementsByMainTitle): Deleted. 79 (WebInspector.FrameTreeElement.prototype._insertFolderTreeElement): Deleted. 80 (WebInspector.FrameTreeElement.prototype._compareResourceTreeElements): Deleted. 81 (WebInspector.FrameTreeElement.prototype._insertResourceTreeElement): Deleted. 82 (WebInspector.FrameTreeElement.prototype._removeTreeElement): Deleted. 83 (WebInspector.FrameTreeElement.prototype._folderNameForResourceType): Deleted. 84 (WebInspector.FrameTreeElement.prototype._parentTreeElementForRepresentedObject.createFolderTreeElement): Deleted. 85 (WebInspector.FrameTreeElement.prototype._parentTreeElementForRepresentedObject): Deleted. 86 (WebInspector.FrameTreeElement.prototype._folderTreeElementExpandedStateChange): Deleted. 87 (WebInspector.FrameTreeElement.prototype._shouldGroupIntoFolders.pushResourceType): Deleted. 88 (WebInspector.FrameTreeElement.prototype._shouldGroupIntoFolders.pushCategory): Deleted. 89 (WebInspector.FrameTreeElement.prototype._shouldGroupIntoFolders): Deleted. 90 * UserInterface/Views/LayoutTimelineDataGridNode.js: 91 (WebInspector.LayoutTimelineDataGridNode.prototype.createCellContent): 92 * UserInterface/Views/LayoutTimelineView.js: 93 (WebInspector.LayoutTimelineView): Deleted. 94 * UserInterface/Views/NetworkTimelineView.js: 95 (WebInspector.NetworkTimelineView): Deleted. 96 * UserInterface/Views/ResourceDetailsSidebarPanel.js: 97 (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshResourceType): 98 * UserInterface/Views/ResourceTimelineDataGridNode.js: 99 (WebInspector.ResourceTimelineDataGridNode.prototype.createCellContent): 100 * UserInterface/Views/SourceCodeTreeElement.js: 101 (WebInspector.SourceCodeTreeElement): 102 * UserInterface/Views/TimelineDataGrid.js: 103 (WebInspector.TimelineDataGrid.createColumnScopeBar): 104 * UserInterface/Views/TimelineRecordTreeElement.js: 105 (WebInspector.TimelineRecordTreeElement): 106 * WebInspectorUI.vcxproj/WebInspectorUI.vcxproj: 107 * WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters: 108 1 109 2014-11-07 Joseph Pecoraro <pecoraro@apple.com> 2 110 -
trunk/Source/WebInspectorUI/UserInterface/Base/Main.js
r175767 r175784 1864 1864 return false; 1865 1865 1866 return WebInspector.Resource. Type.fromMIMEType(WebInspector.frameResourceManager.mainFrame.mainResource.mimeType) === WebInspector.Resource.Type.Document;1866 return WebInspector.Resource.typeFromMIMEType(WebInspector.frameResourceManager.mainFrame.mainResource.mimeType) === WebInspector.Resource.Type.Document; 1867 1867 } 1868 1868 -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r175767 r175784 302 302 303 303 <script src="Views/DOMDetailsSidebarPanel.js"></script> 304 <script src="Views/FolderizedTreeElement.js"></script> 304 305 <script src="Views/SourceCodeTreeElement.js"></script> 305 306 <script src="Views/StorageTreeElement.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Models/LayoutTimelineRecord.js
r164918 r175784 50 50 }; 51 51 52 WebInspector.LayoutTimelineRecord. EventType.displayName = function(eventType)52 WebInspector.LayoutTimelineRecord.displayNameForEventType = function(eventType) 53 53 { 54 54 switch(eventType) { -
trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js
r175203 r175784 35 35 this._url = url; 36 36 this._mimeType = mimeType; 37 this._type = type || WebInspector.Resource. Type.fromMIMEType(mimeType);37 this._type = type || WebInspector.Resource.typeFromMIMEType(mimeType); 38 38 this._loaderIdentifier = loaderIdentifier || null; 39 39 this._requestIdentifier = requestIdentifier || null; … … 86 86 }; 87 87 88 // This MIME Type map is private, use WebInspector.Resource. Type.fromMIMEType().89 WebInspector.Resource. Type._mimeTypeMap = {88 // This MIME Type map is private, use WebInspector.Resource.typeFromMIMEType(). 89 WebInspector.Resource._mimeTypeMap = { 90 90 "text/html": WebInspector.Resource.Type.Document, 91 91 "text/xml": WebInspector.Resource.Type.Document, … … 127 127 }; 128 128 129 WebInspector.Resource. Type.fromMIMEType = function(mimeType)129 WebInspector.Resource.typeFromMIMEType = function(mimeType) 130 130 { 131 131 if (!mimeType) … … 134 134 mimeType = parseMIMEType(mimeType).type; 135 135 136 if (mimeType in WebInspector.Resource. Type._mimeTypeMap)137 return WebInspector.Resource. Type._mimeTypeMap[mimeType];136 if (mimeType in WebInspector.Resource._mimeTypeMap) 137 return WebInspector.Resource._mimeTypeMap[mimeType]; 138 138 139 139 if (mimeType.startsWith("image/")) … … 146 146 }; 147 147 148 WebInspector.Resource. Type.displayName = function(type, plural)148 WebInspector.Resource.displayNameForType = function(type, plural) 149 149 { 150 150 switch(type) { … … 236 236 237 237 // If the type matches the Resource.Type of the MIME-type, then return the actual MIME-type. 238 if (this._type === WebInspector.Resource. Type.fromMIMEType(this._mimeType))238 if (this._type === WebInspector.Resource.typeFromMIMEType(this._mimeType)) 239 239 return this._mimeType; 240 240 … … 498 498 this._url = url; 499 499 this._mimeType = mimeType; 500 this._type = type || WebInspector.Resource. Type.fromMIMEType(mimeType);500 this._type = type || WebInspector.Resource.typeFromMIMEType(mimeType); 501 501 this._statusCode = statusCode; 502 502 this._statusText = statusText; -
trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js
r170863 r175784 42 42 // Resource base-class to set _mimeType and _type. 43 43 this._mimeType = fileExtensionMIMEType || inheritedMIMEType || "text/javascript"; 44 this._type = WebInspector.Resource. Type.fromMIMEType(this._mimeType);44 this._type = WebInspector.Resource.typeFromMIMEType(this._mimeType); 45 45 46 46 // Mark the resource as loaded so it does not show a spinner in the sidebar. -
trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js
r173407 r175784 31 31 32 32 this._frame = frame; 33 this._newChildQueue = [];34 33 35 34 this._updateExpandedSetting(); … … 45 44 frame.domTree.addEventListener(WebInspector.DOMTree.Event.RootDOMNodeInvalidated, this._rootDOMNodeInvalidated, this); 46 45 47 if (this._frame.isMainFrame()) {46 if (this._frame.isMainFrame()) 48 47 this._downloadingPage = false; 49 WebInspector.notifications.addEventListener(WebInspector.Notification.PageArchiveStarted, this._pageArchiveStarted, this); 50 WebInspector.notifications.addEventListener(WebInspector.Notification.PageArchiveEnded, this._pageArchiveEnded, this); 48 49 this.shouldRefreshChildren = true; 50 this.folderSettingsKey = this._frame.url.hash; 51 52 this.registerFolderizeSettings("frames", WebInspector.UIString("Frames"), 53 function(representedObject) { return representedObject instanceof WebInspector.Frame; }, 54 function() { return this.frame.childFrames.length; }.bind(this), 55 WebInspector.FrameTreeElement 56 ); 57 58 this.registerFolderizeSettings("flows", WebInspector.UIString("Flows"), 59 function(representedObject) { return representedObject instanceof WebInspector.ContentFlow; }, 60 function() { return this.frame.domTree.flowsCount; }.bind(this), 61 WebInspector.ContentFlowTreeElement 62 ); 63 64 function makeValidateCallback(resourceType) { 65 return function(representedObject) { 66 return representedObject instanceof WebInspector.Resource && representedObject.type === resourceType; 67 }; 51 68 } 52 69 53 this._updateParentStatus(); 54 this.shouldRefreshChildren = true; 70 function makeChildCountCallback(frame, resourceType) { 71 return function() { 72 return frame.resourcesWithType(resourceType).length; 73 }; 74 } 75 76 for (var key in WebInspector.Resource.Type) { 77 var value = WebInspector.Resource.Type[key]; 78 var folderName = WebInspector.Resource.displayNameForType(value, true); 79 this.registerFolderizeSettings(key, folderName, 80 makeValidateCallback(value), 81 makeChildCountCallback(this.frame, value), 82 WebInspector.ResourceTreeElement 83 ); 84 } 85 86 this.updateParentStatus(); 55 87 }; 56 57 WebInspector.FrameTreeElement.MediumChildCountThreshold = 5;58 WebInspector.FrameTreeElement.LargeChildCountThreshold = 15;59 WebInspector.FrameTreeElement.NumberOfMediumCategoriesThreshold = 2;60 WebInspector.FrameTreeElement.NewChildQueueUpdateInterval = 500;61 88 62 89 WebInspector.FrameTreeElement.prototype = { 63 90 constructor: WebInspector.FrameTreeElement, 91 __proto__: WebInspector.ResourceTreeElement.prototype, 64 92 65 93 // Public … … 100 128 return; 101 129 102 this. _updateParentStatus();130 this.updateParentStatus(); 103 131 104 132 if (this.resource && this.resource.sourceMaps.length) … … 108 136 onattach: function() 109 137 { 110 // Frames handle their own SourceMapResources. 111 138 // Immediate superclasses are skipped, since Frames handle their own SourceMapResources. 112 139 WebInspector.GeneralTreeElement.prototype.onattach.call(this); 140 141 if (this._frame.isMainFrame()) { 142 WebInspector.notifications.addEventListener(WebInspector.Notification.PageArchiveStarted, this._pageArchiveStarted, this); 143 WebInspector.notifications.addEventListener(WebInspector.Notification.PageArchiveEnded, this._pageArchiveEnded, this); 144 } 145 }, 146 147 ondetach: function() 148 { 149 WebInspector.ResourceTreeElement.prototype.ondetach.call(this); 150 151 if (this._frame.isMainFrame()) { 152 WebInspector.notifications.removeEventListener(WebInspector.Notification.PageArchiveStarted, this._pageArchiveStarted, this); 153 WebInspector.notifications.removeEventListener(WebInspector.Notification.PageArchiveEnded, this._pageArchiveEnded, this); 154 } 155 }, 156 157 // Overrides from FolderizedTreeElement (Protected). 158 159 compareChildTreeElements: function(a, b) 160 { 161 if (a === b) 162 return 0; 163 164 var aIsResource = a instanceof WebInspector.ResourceTreeElement; 165 var bIsResource = b instanceof WebInspector.ResourceTreeElement; 166 167 if (aIsResource && bIsResource) 168 return WebInspector.ResourceTreeElement.compareResourceTreeElements(a, b); 169 170 if (!aIsResource && !bIsResource) { 171 // When both components are not resources then default to base class comparison. 172 return WebInspector.ResourceTreeElement.prototype.compareChildTreeElements.call(this, a, b); 173 } 174 175 // Non-resources should appear before the resources. 176 // FIXME: There should be a better way to group the elements by their type. 177 return aIsResource ? 1 : -1; 113 178 }, 114 179 … … 164 229 165 230 this.removeChildren(); 166 this._clearNewChildQueue();167 168 if (this._shouldGroupIntoFolders() && !this._groupedIntoFolders)169 this._groupedIntoFolders = true;170 231 171 232 for (var i = 0; i < this._frame.childFrames.length; ++i) 172 this. _addTreeElementForRepresentedObject(this._frame.childFrames[i]);233 this.addChildForRepresentedObject(this._frame.childFrames[i]); 173 234 174 235 for (var i = 0; i < this._frame.resources.length; ++i) 175 this. _addTreeElementForRepresentedObject(this._frame.resources[i]);236 this.addChildForRepresentedObject(this._frame.resources[i]); 176 237 177 238 var sourceMaps = this.resource && this.resource.sourceMaps; … … 179 240 var sourceMap = sourceMaps[i]; 180 241 for (var j = 0; j < sourceMap.resources.length; ++j) 181 this._addTreeElementForRepresentedObject(sourceMap.resources[j]);242 this.addChildForRepresentedObject(sourceMap.resources[j]); 182 243 } 183 244 184 245 var flowMap = this._frame.domTree.flowMap; 185 246 for (var flowKey in flowMap) 186 this. _addTreeElementForRepresentedObject(flowMap[flowKey]);247 this.addChildForRepresentedObject(flowMap[flowKey]); 187 248 }, 188 249 … … 199 260 if (this.hasChildren) 200 261 this._expandedSetting.value = false; 201 },202 203 removeChildren: function()204 {205 TreeElement.prototype.removeChildren.call(this);206 207 if (this._framesFolderTreeElement)208 this._framesFolderTreeElement.removeChildren();209 210 for (var type in this._resourceFoldersTypeMap)211 this._resourceFoldersTypeMap[type].removeChildren();212 213 delete this._resourceFoldersTypeMap;214 delete this._framesFolderTreeElement;215 262 }, 216 263 … … 226 273 }, 227 274 228 _updateParentStatus: function()229 {230 this.hasChildren = (this._frame.resources.length || this._frame.childFrames.length || (this.resource && this.resource.sourceMaps.length));231 if (!this.hasChildren)232 this.removeChildren();233 },234 235 275 _mainResourceDidChange: function(event) 236 276 { 237 277 this._updateResource(this._frame.mainResource); 238 this._updateParentStatus(); 239 240 this._groupedIntoFolders = false; 241 242 this._clearNewChildQueue(); 243 278 279 this.updateParentStatus(); 244 280 this.removeChildren(); 245 281 … … 256 292 _resourceWasAdded: function(event) 257 293 { 258 this. _addRepresentedObjectToNewChildQueue(event.data.resource);294 this.addRepresentedObjectToNewChildQueue(event.data.resource); 259 295 }, 260 296 261 297 _resourceWasRemoved: function(event) 262 298 { 263 this. _removeChildForRepresentedObject(event.data.resource);299 this.removeChildForRepresentedObject(event.data.resource); 264 300 }, 265 301 266 302 _childFrameWasAdded: function(event) 267 303 { 268 this. _addRepresentedObjectToNewChildQueue(event.data.childFrame);304 this.addRepresentedObjectToNewChildQueue(event.data.childFrame); 269 305 }, 270 306 271 307 _childFrameWasRemoved: function(event) 272 308 { 273 this. _removeChildForRepresentedObject(event.data.childFrame);309 this.removeChildForRepresentedObject(event.data.childFrame); 274 310 }, 275 311 276 312 _childContentFlowWasAdded: function(event) 277 313 { 278 this. _addRepresentedObjectToNewChildQueue(event.data.flow);314 this.addRepresentedObjectToNewChildQueue(event.data.flow); 279 315 }, 280 316 281 317 _childContentFlowWasRemoved: function(event) 282 318 { 283 this._removeChildForRepresentedObject(event.data.flow); 284 }, 285 286 _rootDOMNodeInvalidated: function() { 319 this.removeChildForRepresentedObject(event.data.flow); 320 }, 321 322 _rootDOMNodeInvalidated: function() 323 { 287 324 if (this.expanded) 288 325 this._frame.domTree.requestContentFlowList(); 289 },290 291 _addRepresentedObjectToNewChildQueue: function(representedObject)292 {293 // This queue reduces flashing as resources load and change folders when their type becomes known.294 295 this._newChildQueue.push(representedObject);296 if (!this._newChildQueueTimeoutIdentifier)297 this._newChildQueueTimeoutIdentifier = setTimeout(this._populateFromNewChildQueue.bind(this), WebInspector.FrameTreeElement.NewChildQueueUpdateInterval);298 },299 300 _removeRepresentedObjectFromNewChildQueue: function(representedObject)301 {302 this._newChildQueue.remove(representedObject);303 },304 305 _populateFromNewChildQueue: function()306 {307 if (!this.children.length) {308 this._updateParentStatus();309 this.shouldRefreshChildren = true;310 return;311 }312 313 for (var i = 0; i < this._newChildQueue.length; ++i)314 this._addChildForRepresentedObject(this._newChildQueue[i]);315 316 this._newChildQueue = [];317 this._newChildQueueTimeoutIdentifier = null;318 },319 320 _clearNewChildQueue: function()321 {322 this._newChildQueue = [];323 if (this._newChildQueueTimeoutIdentifier) {324 clearTimeout(this._newChildQueueTimeoutIdentifier);325 this._newChildQueueTimeoutIdentifier = null;326 }327 },328 329 _addChildForRepresentedObject: function(representedObject)330 {331 console.assert(representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.ContentFlow);332 if (!(representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.ContentFlow))333 return;334 335 this._updateParentStatus();336 337 if (!this.treeOutline) {338 // Just mark as needing to update to avoid doing work that might not be needed.339 this.shouldRefreshChildren = true;340 return;341 }342 343 if (this._shouldGroupIntoFolders() && !this._groupedIntoFolders) {344 // Mark as needing a refresh to rebuild the tree into folders.345 this._groupedIntoFolders = true;346 this.shouldRefreshChildren = true;347 return;348 }349 350 this._addTreeElementForRepresentedObject(representedObject);351 },352 353 _removeChildForRepresentedObject: function(representedObject)354 {355 console.assert(representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.ContentFlow);356 if (!(representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.ContentFlow))357 return;358 359 this._removeRepresentedObjectFromNewChildQueue(representedObject);360 361 this._updateParentStatus();362 363 if (!this.treeOutline) {364 // Just mark as needing to update to avoid doing work that might not be needed.365 this.shouldRefreshChildren = true;366 return;367 }368 369 // Find the tree element for the frame by using getCachedTreeElement370 // to only get the item if it has been created already.371 var childTreeElement = this.treeOutline.getCachedTreeElement(representedObject);372 if (!childTreeElement || !childTreeElement.parent)373 return;374 375 this._removeTreeElement(childTreeElement);376 },377 378 _addTreeElementForRepresentedObject: function(representedObject)379 {380 var childTreeElement = this.treeOutline.getCachedTreeElement(representedObject);381 if (!childTreeElement) {382 if (representedObject instanceof WebInspector.SourceMapResource)383 childTreeElement = new WebInspector.SourceMapResourceTreeElement(representedObject);384 else if (representedObject instanceof WebInspector.Resource)385 childTreeElement = new WebInspector.ResourceTreeElement(representedObject);386 else if (representedObject instanceof WebInspector.Frame)387 childTreeElement = new WebInspector.FrameTreeElement(representedObject);388 else if (representedObject instanceof WebInspector.ContentFlow)389 childTreeElement = new WebInspector.ContentFlowTreeElement(representedObject);390 }391 392 this._addTreeElement(childTreeElement);393 },394 395 _addTreeElement: function(childTreeElement)396 {397 console.assert(childTreeElement);398 if (!childTreeElement)399 return;400 401 var wasSelected = childTreeElement.selected;402 403 this._removeTreeElement(childTreeElement, true, true);404 405 var parentTreeElement = this._parentTreeElementForRepresentedObject(childTreeElement.representedObject);406 if (parentTreeElement !== this && !parentTreeElement.parent)407 this._insertFolderTreeElement(parentTreeElement);408 409 this._insertResourceTreeElement(parentTreeElement, childTreeElement);410 411 if (wasSelected)412 childTreeElement.revealAndSelect(true, false, true, true);413 },414 415 _compareTreeElementsByMainTitle: function(a, b)416 {417 return a.mainTitle.localeCompare(b.mainTitle);418 },419 420 _insertFolderTreeElement: function(folderTreeElement)421 {422 console.assert(this._groupedIntoFolders);423 console.assert(!folderTreeElement.parent);424 this.insertChild(folderTreeElement, insertionIndexForObjectInListSortedByFunction(folderTreeElement, this.children, this._compareTreeElementsByMainTitle));425 },426 427 _compareResourceTreeElements: function(a, b)428 {429 if (a === b)430 return 0;431 432 var aIsResource = a instanceof WebInspector.ResourceTreeElement;433 var bIsResource = b instanceof WebInspector.ResourceTreeElement;434 435 if (aIsResource && bIsResource)436 return WebInspector.ResourceTreeElement.compareResourceTreeElements(a, b);437 438 if (!aIsResource && !bIsResource) {439 // When both components are not resources then just compare the titles.440 return a.mainTitle.localeCompare(b.mainTitle);441 }442 443 // Non-resources should appear before the resources.444 // FIXME: There should be a better way to group the elements by their type.445 return aIsResource ? 1 : -1;446 },447 448 _insertResourceTreeElement: function(parentTreeElement, childTreeElement)449 {450 console.assert(!childTreeElement.parent);451 parentTreeElement.insertChild(childTreeElement, insertionIndexForObjectInListSortedByFunction(childTreeElement, parentTreeElement.children, this._compareResourceTreeElements));452 },453 454 _removeTreeElement: function(childTreeElement, suppressOnDeselect, suppressSelectSibling)455 {456 var oldParent = childTreeElement.parent;457 if (!oldParent)458 return;459 460 oldParent.removeChild(childTreeElement, suppressOnDeselect, suppressSelectSibling);461 462 if (oldParent === this)463 return;464 465 console.assert(oldParent instanceof WebInspector.FolderTreeElement);466 if (!(oldParent instanceof WebInspector.FolderTreeElement))467 return;468 469 // Remove the old parent folder if it is now empty.470 if (!oldParent.children.length)471 oldParent.parent.removeChild(oldParent);472 },473 474 _folderNameForResourceType: function(type)475 {476 return WebInspector.Resource.Type.displayName(type, true);477 },478 479 _parentTreeElementForRepresentedObject: function(representedObject)480 {481 if (!this._groupedIntoFolders)482 return this;483 484 function createFolderTreeElement(type, displayName)485 {486 var folderTreeElement = new WebInspector.FolderTreeElement(displayName);487 folderTreeElement._expandedSetting = new WebInspector.Setting(type + "-folder-expanded-" + this._frame.url.hash, false);488 if (folderTreeElement._expandedSetting.value)489 folderTreeElement.expand();490 folderTreeElement.onexpand = this._folderTreeElementExpandedStateChange.bind(this);491 folderTreeElement.oncollapse = this._folderTreeElementExpandedStateChange.bind(this);492 return folderTreeElement;493 }494 495 if (representedObject instanceof WebInspector.Frame) {496 if (!this._framesFolderTreeElement)497 this._framesFolderTreeElement = createFolderTreeElement.call(this, "frames", WebInspector.UIString("Frames"));498 return this._framesFolderTreeElement;499 }500 501 if (representedObject instanceof WebInspector.ContentFlow) {502 if (!this._flowsFolderTreeElement)503 this._flowsFolderTreeElement = createFolderTreeElement.call(this, "flows", WebInspector.UIString("Flows"));504 return this._flowsFolderTreeElement;505 }506 507 if (representedObject instanceof WebInspector.Resource) {508 var folderName = this._folderNameForResourceType(representedObject.type);509 if (!folderName)510 return this;511 512 if (!this._resourceFoldersTypeMap)513 this._resourceFoldersTypeMap = {};514 if (!this._resourceFoldersTypeMap[representedObject.type])515 this._resourceFoldersTypeMap[representedObject.type] = createFolderTreeElement.call(this, representedObject.type, folderName);516 return this._resourceFoldersTypeMap[representedObject.type];517 }518 519 console.error("Unknown representedObject: ", representedObject);520 return this;521 },522 523 _folderTreeElementExpandedStateChange: function(folderTreeElement)524 {525 console.assert(folderTreeElement._expandedSetting);526 folderTreeElement._expandedSetting.value = folderTreeElement.expanded;527 },528 529 _shouldGroupIntoFolders: function()530 {531 // Already grouped into folders, keep it that way.532 if (this._groupedIntoFolders)533 return true;534 535 // Resources and Frames are grouped into folders if one of two thresholds are met:536 // 1) Once the number of medium categories passes NumberOfMediumCategoriesThreshold.537 // 2) When there is a category that passes LargeChildCountThreshold and there are538 // any resources in another category.539 540 // Folders are avoided when there is only one category or most categories are small.541 542 var numberOfSmallCategories = 0;543 var numberOfMediumCategories = 0;544 var foundLargeCategory = false;545 var frame = this._frame;546 547 function pushResourceType(type) {548 // There are some other properties on WebInspector.Resource.Type that we need to skip, like private data and functions549 if (type.charAt(0) === "_")550 return false;551 552 // Only care about the values that are strings, not functions, etc.553 var typeValue = WebInspector.Resource.Type[type];554 if (typeof typeValue !== "string")555 return false;556 557 return pushCategory(frame.resourcesWithType(typeValue).length);558 }559 560 function pushCategory(resourceCount)561 {562 if (!resourceCount)563 return false;564 565 // If this type has any resources and there is a known large category, make folders.566 if (foundLargeCategory)567 return true;568 569 // If there are lots of this resource type, then count it as a large category.570 if (resourceCount >= WebInspector.FrameTreeElement.LargeChildCountThreshold) {571 // If we already have other resources in other small or medium categories, make folders.572 if (numberOfSmallCategories || numberOfMediumCategories)573 return true;574 575 foundLargeCategory = true;576 return false;577 }578 579 // Check if this is a medium category.580 if (resourceCount >= WebInspector.FrameTreeElement.MediumChildCountThreshold) {581 // If this is the medium category that puts us over the maximum allowed, make folders.582 return ++numberOfMediumCategories >= WebInspector.FrameTreeElement.NumberOfMediumCategoriesThreshold;583 }584 585 // This is a small category.586 ++numberOfSmallCategories;587 return false;588 }589 590 // Iterate over all the available resource types.591 return pushCategory(frame.childFrames.length) || pushCategory(frame.domTree.flowsCount) || Object.keys(WebInspector.Resource.Type).some(pushResourceType);592 326 }, 593 327 … … 634 368 } 635 369 }; 636 637 WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.ResourceTreeElement.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineDataGridNode.js
r164543 r175784 65 65 switch (columnIdentifier) { 66 66 case "eventType": 67 return WebInspector.LayoutTimelineRecord. EventType.displayName(value);67 return WebInspector.LayoutTimelineRecord.displayNameForEventType(value); 68 68 69 69 case "width": -
trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js
r172435 r175784 39 39 columns.eventType.title = WebInspector.UIString("Type"); 40 40 columns.eventType.width = "15%"; 41 columns.eventType.scopeBar = WebInspector.TimelineDataGrid.createColumnScopeBar("layout", WebInspector.LayoutTimelineRecord.EventType); 41 42 var typeToLabelMap = new Map; 43 for (var key in WebInspector.LayoutTimelineRecord.EventType) { 44 var value = WebInspector.LayoutTimelineRecord.EventType[key]; 45 typeToLabelMap.set(value, WebInspector.LayoutTimelineRecord.displayNameForEventType(value)); 46 } 47 48 columns.eventType.scopeBar = WebInspector.TimelineDataGrid.createColumnScopeBar("layout", typeToLabelMap); 42 49 columns.eventType.hidden = true; 43 50 -
trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js
r172435 r175784 42 42 columns.type.title = WebInspector.UIString("Type"); 43 43 columns.type.width = "8%"; 44 columns.type.scopeBar = WebInspector.TimelineDataGrid.createColumnScopeBar("network", WebInspector.Resource.Type); 44 45 var typeToLabelMap = new Map; 46 for (var key in WebInspector.Resource.Type) { 47 var value = WebInspector.Resource.Type[key]; 48 typeToLabelMap.set(value, WebInspector.Resource.displayNameForType(value, true)); 49 } 50 51 columns.type.scopeBar = WebInspector.TimelineDataGrid.createColumnScopeBar("network", typeToLabelMap); 45 52 46 53 columns.method.title = WebInspector.UIString("Method"); -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js
r175767 r175784 246 246 return; 247 247 248 this._typeResourceTypeRow.value = WebInspector.Resource. Type.displayName(this._resource.type);248 this._typeResourceTypeRow.value = WebInspector.Resource.displayNameForType(this._resource.type); 249 249 }, 250 250 -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js
r164543 r175784 128 128 129 129 case "type": 130 return WebInspector.Resource. Type.displayName(value);130 return WebInspector.Resource.displayNameForType(value); 131 131 132 132 case "statusCode": -
trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTreeElement.js
r164543 r175784 28 28 console.assert(sourceCode instanceof WebInspector.SourceCode); 29 29 30 WebInspector. GeneralTreeElement.call(this, classNames, title, subtitle, representedObject || sourceCode, hasChildren);30 WebInspector.FolderizedTreeElement.call(this, classNames, title, subtitle, representedObject || sourceCode, hasChildren); 31 31 32 32 this.small = true; … … 37 37 WebInspector.SourceCodeTreeElement.prototype = { 38 38 constructor: WebInspector.SourceCodeTreeElement, 39 __proto__: WebInspector.FolderizedTreeElement.prototype, 39 40 40 41 // Public … … 205 206 } 206 207 }; 207 208 WebInspector.SourceCodeTreeElement.prototype.__proto__ = WebInspector.GeneralTreeElement.prototype; -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js
r172334 r175784 78 78 prefix = prefix + "-timeline-data-grid-"; 79 79 80 var keys = Object.keys(dictionary).filter(function(key) { 81 return typeof dictionary[key] === "string" || dictionary[key] instanceof String; 82 }); 83 84 var scopeBarItems = keys.map(function(key) { 85 var value = dictionary[key]; 86 var id = prefix + value; 87 var label = dictionary.displayName(value, true); 80 var scopeBarItems = Object.keys(dictionary).map(function(key) { 81 var id = prefix + key; 82 var label = dictionary[key]; 88 83 var item = new WebInspector.ScopeBarItem(id, label); 89 item.value = value;84 item.value = key; 90 85 return item; 91 86 }); -
trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js
r171195 r175784 47 47 switch (timelineRecord.type) { 48 48 case WebInspector.TimelineRecord.Type.Layout: 49 title = WebInspector.LayoutTimelineRecord. EventType.displayName(timelineRecord.eventType);49 title = WebInspector.LayoutTimelineRecord.displayNameForEventType(timelineRecord.eventType); 50 50 51 51 switch (timelineRecord.eventType) { -
trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj
r175767 r175784 441 441 <None Include="..\UserInterface\FolderIcon.css" /> 442 442 <None Include="..\UserInterface\FolderTreeElement.js" /> 443 <None Include="..\UserInterface\FolderizedTreeElement.js" /> 443 444 <None Include="..\UserInterface\FontResourceContentView.css" /> 444 445 <None Include="..\UserInterface\FontResourceContentView.js" /> -
trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/WebInspectorUI.vcxproj.filters
r175767 r175784 511 511 <Filter>UserInterface</Filter> 512 512 </None> 513 <None Include="..\UserInterface\FolderizedTreeElement.js"> 514 <Filter>UserInterface</Filter> 515 </None> 513 516 <None Include="..\UserInterface\FontResourceContentView.css"> 514 517 <Filter>UserInterface</Filter>
Note: See TracChangeset
for help on using the changeset viewer.