Changeset 243180 in webkit
- Timestamp:
- Mar 19, 2019, 4:35:20 PM (7 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 13 edited
-
ChangeLog (modified) (1 diff)
-
Localizations/en.lproj/localizedStrings.js (modified) (1 diff)
-
UserInterface/Base/Setting.js (modified) (1 diff)
-
UserInterface/Base/URLUtilities.js (modified) (2 diffs)
-
UserInterface/Models/Resource.js (modified) (1 diff)
-
UserInterface/Protocol/InspectorFrontendAPI.js (modified) (1 diff)
-
UserInterface/Views/DetailsSection.css (modified) (1 diff)
-
UserInterface/Views/GeneralTreeElement.js (modified) (1 diff)
-
UserInterface/Views/NetworkTableContentView.js (modified) (8 diffs)
-
UserInterface/Views/ResourceTreeElement.js (modified) (4 diffs)
-
UserInterface/Views/SourceCodeTreeElement.js (modified) (1 diff)
-
UserInterface/Views/SourcesNavigationSidebarPanel.css (modified) (4 diffs)
-
UserInterface/Views/SourcesNavigationSidebarPanel.js (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r243166 r243180 1 2019-03-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Sources: provide option to group by path 4 https://bugs.webkit.org/show_bug.cgi?id=195203 5 <rdar://problem/27340680> 6 7 Reviewed by Timothy Hatcher. 8 9 Create top-level folders for each origin and nest all resources (in a folder chain) underneath. 10 11 * UserInterface/Views/SourcesNavigationSidebarPanel.js: 12 (WI.SourcesNavigationSidebarPanel): 13 (WI.SourcesNavigationSidebarPanel.prototype.closed): 14 (WI.SourcesNavigationSidebarPanel.prototype.treeElementForRepresentedObject.searchTreeOutline): Added. 15 (WI.SourcesNavigationSidebarPanel.prototype.treeElementForRepresentedObject): 16 (WI.SourcesNavigationSidebarPanel.prototype._compareTreeElements): 17 (WI.SourcesNavigationSidebarPanel.prototype._updateMainFrameTreeElement): 18 (WI.SourcesNavigationSidebarPanel.prototype._addResource): 19 (WI.SourcesNavigationSidebarPanel.prototype._addScript): 20 (WI.SourcesNavigationSidebarPanel.prototype._addWorkerTargetWithMainResource): 21 (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeMouseDown.addOption): Added. 22 (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeMouseDown): Added. 23 (WI.SourcesNavigationSidebarPanel.prototype._handleTreeSelectionDidChange): 24 (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeChanged): 25 (WI.SourcesNavigationSidebarPanel.prototype._handleFrameMainResourceDidChange): 26 (WI.SourcesNavigationSidebarPanel.prototype._handleMainFrameDidChange): 27 * UserInterface/Views/SourcesNavigationSidebarPanel.css: 28 (.sidebar > .panel.navigation.sources > .content): 29 (.sidebar > .panel.navigation.sources > .content > .details-section.paused-reason.collapsed > .header > .options,): 30 (.sidebar > .panel.navigation.sources > .content > .details-section.breakpoints > .header > .options .create-breakpoint): Added. 31 (.sidebar > .panel.navigation.sources > .content > .resources): Added. 32 (.sidebar > .panel.navigation.sources > .content .tree-outline.single-thread): Added. 33 (.sidebar > .panel.navigation.sources > .content .tree-outline.single-thread > .item.thread): Added. 34 (.sidebar > .panel.navigation.sources > .content > .details-section.scripts:not(.collapsed)): Deleted. 35 (.sidebar > .panel.navigation.sources > .content > .tree-outline.single-thread): Deleted. 36 (.sidebar > .panel.navigation.sources > .content > .tree-outline.single-thread > .item.thread): Deleted. 37 Drive-by: fix "No Filter Results" message view to not overlap eachother. 38 Drive-by: try to be more smart about what tree we focus when selecting a represented object. 39 40 * UserInterface/Views/ResourceTreeElement.js: 41 (WI.ResourceTreeElement): 42 (WI.ResourceTreeElement.prototype.get mainTitleText): 43 (WI.ResourceTreeElement.prototype._updateTitles): 44 * UserInterface/Base/URLUtilities.js: 45 (WI.displayNameForURL): 46 Provide a way for the display name to use a directory "/" instead of the last path component. 47 This is needed in cases where the loaded resource is an implicit "index.*". 48 49 * UserInterface/Views/GeneralTreeElement.js: 50 (WI.GeneralTreeElement.prototype.createFoldersAsNeededForSubpath): Added. 51 * UserInterface/Views/SourceCodeTreeElement.js: 52 (WI.SourceCodeTreeElement.prototype.createFoldersAsNeededForSubpath): Deleted. 53 54 * Localizations/en.lproj/localizedStrings.js: 55 * UserInterface/Models/Resource.js: 56 57 * UserInterface/Views/DetailsSection.css: 58 (.details-section > .header .go-to-arrow): 59 Drive-by: vertically center go-to-arrow. 60 61 * UserInterface/Protocol/InspectorFrontendAPI.js: 62 (InspectorFrontendAPI.contextMenuItemSelected): 63 64 * UserInterface/Base/Setting.js: 65 * UserInterface/Views/NetworkTableContentView.js: 66 (WI.NetworkTableContentView): 67 (WI.NetworkTableContentView.prototype.get filterNavigationItems): 68 (WI.NetworkTableContentView.prototype._populateNameCell): 69 (WI.NetworkTableContentView.prototype._generateSortComparator): 70 (WI.NetworkTableContentView.prototype._insertResourceAndReloadTable): 71 (WI.NetworkTableContentView.prototype._updateFilteredEntries): 72 (WI.NetworkTableContentView.prototype._handleGroupMediaRequestsByDOMNodeCheckedDidChange): Added. 73 (WI.NetworkTableContentView.prototype._handleGroupByDOMNodeCheckedDidChange): Deleted. 74 Rename the `groupByNode` setting to be more specific. 75 1 76 2019-03-19 Devin Rousso <drousso@apple.com> 2 77 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r243024 r243180 512 512 localizedStrings["Group by Event"] = "Group by Event"; 513 513 localizedStrings["Group by Node"] = "Group by Node"; 514 localizedStrings["Group by Path"] = "Group by Path"; 515 localizedStrings["Group by Type"] = "Group by Type"; 514 516 localizedStrings["Grouping Method"] = "Grouping Method"; 517 localizedStrings["Grouping Mode"] = "Grouping Mode"; 515 518 localizedStrings["HAR Export (%s)"] = "HAR Export (%s)"; 516 519 localizedStrings["HAR Import"] = "HAR Import"; -
trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js
r242741 r243180 135 135 enableControlFlowProfiler: new WI.Setting("enable-control-flow-profiler", false), 136 136 enableLineWrapping: new WI.Setting("enable-line-wrapping", false), 137 group ByDOMNode: new WI.Setting("group-by-dom-node",false),137 groupMediaRequestsByDOMNode: new WI.Setting("group-media-requests-by-dom-node", WI.Setting.migrateValue("group-by-dom-node") || false), 138 138 indentUnit: new WI.Setting("indent-unit", 4), 139 139 indentWithTabs: new WI.Setting("indent-with-tabs", false), -
trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js
r223856 r243180 215 215 } 216 216 217 WI.displayNameForURL = function(url, urlComponents )217 WI.displayNameForURL = function(url, urlComponents, options = {}) 218 218 { 219 219 if (url.startsWith("data:")) … … 229 229 displayName = urlComponents.lastPathComponent; 230 230 } 231 232 if (options.allowDirectoryAsName && (!displayName || urlComponents.path.endsWith(displayName + "/"))) 233 displayName = "/"; 231 234 232 235 return displayName || WI.displayNameForHost(urlComponents.host) || url; -
trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js
r243024 r243180 1182 1182 }; 1183 1183 1184 WI.Resource.GroupingMode = { 1185 Path: "group-resource-by-path", 1186 Type: "group-resource-by-type", 1187 }; 1188 WI.settings.resourceGroupingMode = new WI.Setting("resource-grouping-mode", WI.Resource.GroupingMode.Type); 1189 1184 1190 // This MIME Type map is private, use WI.Resource.typeFromMIMEType(). 1185 1191 WI.Resource._mimeTypeMap = { -
trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js
r242049 r243180 123 123 contextMenuItemSelected: function(id) 124 124 { 125 try { 126 WI.ContextMenu.contextMenuItemSelected(id); 127 } catch (e) { 128 console.error("Uncaught exception in inspector page under contextMenuItemSelected", e); 129 } 125 WI.ContextMenu.contextMenuItemSelected(id); 130 126 }, 131 127 -
trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSection.css
r242768 r243180 141 141 .details-section > .header .go-to-arrow { 142 142 width: 10px; 143 height: 1 2px;143 height: 15px; 144 144 -webkit-margin-start: 3px; 145 145 } -
trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTreeElement.js
r235095 r243180 192 192 } 193 193 194 createFoldersAsNeededForSubpath(subpath) 195 { 196 if (!subpath) 197 return this; 198 199 let components = subpath.split("/"); 200 if (components.length === 1) 201 return this; 202 203 if (!this._subpathFolderTreeElementMap) 204 this._subpathFolderTreeElementMap = new Map; 205 206 let currentPath = ""; 207 let currentFolderTreeElement = this; 208 209 for (let component of components) { 210 if (currentPath) 211 currentPath += "/"; 212 currentPath += component; 213 214 let cachedFolder = this._subpathFolderTreeElementMap.get(currentPath); 215 if (cachedFolder) { 216 currentFolderTreeElement = cachedFolder; 217 continue; 218 } 219 220 let newFolder = new WI.FolderTreeElement(component); 221 this._subpathFolderTreeElementMap.set(currentPath, newFolder); 222 223 let index = insertionIndexForObjectInListSortedByFunction(newFolder, currentFolderTreeElement.children, WI.ResourceTreeElement.compareFolderAndResourceTreeElements); 224 currentFolderTreeElement.insertChild(newFolder, index); 225 currentFolderTreeElement = newFolder; 226 } 227 228 return currentFolderTreeElement; 229 } 230 194 231 // Overrides from TreeElement (Private) 195 232 -
trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
r243004 r243180 89 89 90 90 if (WI.MediaInstrument.supported()) { 91 this._group ByDOMNodeNavigationItem = new WI.CheckboxNavigationItem("group-by-node", WI.UIString("Group Media Requests"), WI.settings.groupByDOMNode.value);92 this._group ByDOMNodeNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, this._handleGroupByDOMNodeCheckedDidChange, this);91 this._groupMediaRequestsByDOMNodeNavigationItem = new WI.CheckboxNavigationItem("group-media-requests", WI.UIString("Group Media Requests"), WI.settings.groupMediaRequestsByDOMNode.value); 92 this._groupMediaRequestsByDOMNodeNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, this._handleGroupMediaRequestsByDOMNodeCheckedDidChange, this); 93 93 } else 94 WI.settings.group ByDOMNode.value = false;94 WI.settings.groupMediaRequestsByDOMNode.value = false; 95 95 96 96 this._urlFilterSearchText = null; … … 247 247 let navigationItems = [this._urlFilterNavigationItem, this._typeFilterScopeBar]; 248 248 if (WI.MediaInstrument.supported()) 249 navigationItems.push(this._group ByDOMNodeNavigationItem);249 navigationItems.push(this._groupMediaRequestsByDOMNodeNavigationItem); 250 250 return navigationItems; 251 251 } … … 644 644 cell.classList.add(WI.ResourceTreeElement.ResourceIconStyleClassName); 645 645 646 if (WI.settings.group ByDOMNode.value && resource.initiatorNode) {646 if (WI.settings.groupMediaRequestsByDOMNode.value && resource.initiatorNode) { 647 647 let nodeEntry = this._domNodeEntries.get(resource.initiatorNode); 648 648 if (nodeEntry.initiatedResourceEntries.length > 1 || nodeEntry.domNode.domEvents.length) … … 1064 1064 // next to each other, as they will all effectively be sorted by the first resource. 1065 1065 let substitute = (entry, other) => { 1066 if (WI.settings.group ByDOMNode.value && entry.resource.initiatorNode) {1066 if (WI.settings.groupMediaRequestsByDOMNode.value && entry.resource.initiatorNode) { 1067 1067 let nodeEntry = this._domNodeEntries.get(entry.resource.initiatorNode); 1068 1068 if (!nodeEntry.initiatedResourceEntries.includes(other)) … … 1711 1711 this._tryLinkResourceToDOMNode(resourceEntry); 1712 1712 1713 if (WI.settings.group ByDOMNode.value && resource.initiatorNode) {1713 if (WI.settings.groupMediaRequestsByDOMNode.value && resource.initiatorNode) { 1714 1714 if (!this._entriesSortComparator) 1715 1715 this._generateSortComparator(); … … 1727 1727 1728 1728 if (this._passFilter(resourceEntry)) { 1729 if (WI.settings.group ByDOMNode.value)1729 if (WI.settings.groupMediaRequestsByDOMNode.value) 1730 1730 this._updateFilteredEntries(); 1731 1731 else … … 1898 1898 collection.filteredEntries = collection.entries.slice(); 1899 1899 1900 if (WI.settings.group ByDOMNode.value) {1900 if (WI.settings.groupMediaRequestsByDOMNode.value) { 1901 1901 for (let nodeEntry of this._domNodeEntries.values()) { 1902 1902 if (nodeEntry.initiatedResourceEntries.length < 2 && !nodeEntry.domNode.domEvents.length) … … 2004 2004 } 2005 2005 2006 _handleGroup ByDOMNodeCheckedDidChange(event)2007 { 2008 WI.settings.group ByDOMNode.value = this._groupByDOMNodeNavigationItem.checked;2009 2010 if (!WI.settings.group ByDOMNode.value) {2006 _handleGroupMediaRequestsByDOMNodeCheckedDidChange(event) 2007 { 2008 WI.settings.groupMediaRequestsByDOMNode.value = this._groupMediaRequestsByDOMNodeNavigationItem.checked; 2009 2010 if (!WI.settings.groupMediaRequestsByDOMNode.value) { 2011 2011 this._table.element.classList.remove("grouped"); 2012 2012 -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTreeElement.js
r236950 r243180 26 26 WI.ResourceTreeElement = class ResourceTreeElement extends WI.SourceCodeTreeElement 27 27 { 28 constructor(resource, representedObject )28 constructor(resource, representedObject, {allowDirectoryAsName, hideOrigin} = {}) 29 29 { 30 30 console.assert(resource instanceof WI.Resource); … … 33 33 const subtitle = null; 34 34 super(resource, ["resource", WI.ResourceTreeElement.ResourceIconStyleClassName, WI.Resource.classNameForResource(resource)], title, subtitle, representedObject || resource); 35 36 if (allowDirectoryAsName) 37 this._allowDirectoryAsName = allowDirectoryAsName; 38 if (hideOrigin) 39 this._hideOrigin = hideOrigin; 35 40 36 41 this._updateResource(resource); … … 136 141 get mainTitleText() 137 142 { 138 return WI.displayNameForURL(this._resource.url, this._resource.urlComponents); 143 return WI.displayNameForURL(this._resource.url, this._resource.urlComponents, { 144 allowDirectoryAsName: this._allowDirectoryAsName, 145 }); 139 146 } 140 147 … … 159 166 this.mainTitle = this.mainTitleText; 160 167 161 // Show the host as the subtitle if it is different from the main resource or if this is the main frame's main resource. 162 var subtitle = parentResourceHost !== urlComponents.host || frame && frame.isMainFrame() && isMainResource ? WI.displayNameForHost(urlComponents.host) : null; 163 this.subtitle = this.mainTitle !== subtitle ? subtitle : null; 168 if (!this._hideOrigin) { 169 // Show the host as the subtitle if it is different from the main resource or if this is the main frame's main resource. 170 var subtitle = parentResourceHost !== urlComponents.host || frame && frame.isMainFrame() && isMainResource ? WI.displayNameForHost(urlComponents.host) : null; 171 this.subtitle = this.mainTitle !== subtitle ? subtitle : null; 172 } 164 173 165 174 if (oldMainTitle !== this.mainTitle) -
trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTreeElement.js
r238859 r243180 131 131 // Protected 132 132 133 createFoldersAsNeededForSubpath(subpath)134 {135 if (!subpath)136 return this;137 138 var components = subpath.split("/");139 if (components.length === 1)140 return this;141 142 if (!this._subpathFolderTreeElementMap)143 this._subpathFolderTreeElementMap = {};144 145 var currentPath = "";146 var currentFolderTreeElement = this;147 148 for (var i = 0; i < components.length - 1; ++i) {149 var componentName = components[i];150 currentPath += (i ? "/" : "") + componentName;151 152 var cachedFolder = this._subpathFolderTreeElementMap[currentPath];153 if (cachedFolder) {154 currentFolderTreeElement = cachedFolder;155 continue;156 }157 158 var newFolder = new WI.FolderTreeElement(componentName);159 newFolder.__path = currentPath;160 this._subpathFolderTreeElementMap[currentPath] = newFolder;161 162 var index = insertionIndexForObjectInListSortedByFunction(newFolder, currentFolderTreeElement.children, WI.ResourceTreeElement.compareFolderAndResourceTreeElements);163 currentFolderTreeElement.insertChild(newFolder, index);164 currentFolderTreeElement = newFolder;165 }166 167 return currentFolderTreeElement;168 }169 170 133 descendantResourceTreeElementTypeDidChange(childTreeElement, oldType) 171 134 { -
trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.css
r242315 r243180 25 25 26 26 .sidebar > .panel.navigation.sources > .content { 27 display: flex; 28 flex-direction: column; 27 29 top: var(--navigation-bar-height); 28 30 } … … 74 76 75 77 .sidebar > .panel.navigation.sources > .content > .details-section.paused-reason.collapsed > .header > .options, 78 .sidebar > .panel.navigation.sources > .content > .details-section.breakpoints.collapsed > .header > .options, 76 79 .sidebar > .panel.navigation.sources > .content > .details-section > .content, 77 80 .sidebar > .panel.navigation.sources > .content > .details-section > .content > .group { … … 83 86 } 84 87 85 .sidebar > .panel.navigation.sources > .content > .details-section. scripts:not(.collapsed){86 border-bottom: none;88 .sidebar > .panel.navigation.sources > .content > .details-section.breakpoints > .header > .options .create-breakpoint { 89 width: 15px; 87 90 } 88 91 … … 91 94 } 92 95 93 .sidebar > .panel.navigation.sources > .content > .tree-outline.single-thread { 96 .sidebar > .panel.navigation.sources > .content > .resources { 97 position: relative; 98 height: 100%; 99 } 100 101 .sidebar > .panel.navigation.sources > .content .tree-outline.single-thread { 94 102 -webkit-margin-start: -10px; 95 103 } 96 104 97 .sidebar > .panel.navigation.sources > .content >.tree-outline.single-thread > .item.thread {105 .sidebar > .panel.navigation.sources > .content .tree-outline.single-thread > .item.thread { 98 106 display: none; 99 107 } -
trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js
r242937 r243180 31 31 super("sources", WI.UIString("Sources"), shouldAutoPruneStaleTopLevelResourceTreeElements); 32 32 33 this._workerTargetTreeElementMap = new Map; 34 this._mainFrameTreeElement = null; 35 this._extensionScriptsFolderTreeElement = null; 36 this._extraScriptsFolderTreeElement = null; 37 this._anonymousScriptsFolderTreeElement = null; 38 39 this._originTreeElementMap = new Map; 40 41 this._boundCompareTreeElements = this._compareTreeElements.bind(this); 42 33 43 this._debuggerNavigationBar = new WI.NavigationBar; 34 44 this.addSubview(this._debuggerNavigationBar); … … 176 186 this.contentView.element.insertBefore(breakpointsSection.element, this.contentView.element.firstChild); 177 187 178 this._resourcesTreeOutline = this.contentTreeOutline;179 this._resourcesTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._handleTreeSelectionDidChange, this);180 this._resourcesTreeOutline.includeSourceMapResourceChildren = true;181 182 188 this._resourcesNavigationBar = new WI.NavigationBar; 183 189 this.contentView.addSubview(this._resourcesNavigationBar); 184 this.contentView.element.insertBefore(this._resourcesNavigationBar.element, this._resourcesTreeOutline.element); 185 186 this._workerTargetTreeElementMap = new Map; 187 this._extensionScriptsFolderTreeElement = null; 188 this._extraScriptsFolderTreeElement = null; 189 this._anonymousScriptsFolderTreeElement = null; 190 this.contentView.element.insertBefore(this._resourcesNavigationBar.element, breakpointsSection.nextSibling); 191 192 this._resourcesNavigationBar.addNavigationItem(new WI.FlexibleSpaceNavigationItem); 190 193 191 194 const resourceTypeScopeItemPrefix = "sources-resource-type-"; … … 203 206 this._resourcesNavigationBar.addNavigationItem(this._resourceTypeScopeBar); 204 207 208 this._resourcesNavigationBar.addNavigationItem(new WI.FlexibleSpaceNavigationItem); 209 210 let resourceGroupingModeNavigationItem = new WI.ButtonNavigationItem("grouping-mode", WI.UIString("Grouping Mode"), "Images/Gear.svg", 15, 15); 211 resourceGroupingModeNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low; 212 resourceGroupingModeNavigationItem.element.addEventListener("mousedown", this._handleResourceGroupingModeMouseDown.bind(this)); 213 this._resourcesNavigationBar.addNavigationItem(resourceGroupingModeNavigationItem); 214 215 let resourcesContainer = this.contentView.element.insertBefore(document.createElement("div"), this._resourcesNavigationBar.element.nextSibling); 216 resourcesContainer.classList.add("resources"); 217 218 this._resourcesTreeOutline = this.contentTreeOutline; 219 this._resourcesTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._handleTreeSelectionDidChange, this); 220 this._resourcesTreeOutline.includeSourceMapResourceChildren = true; 221 resourcesContainer.appendChild(this._resourcesTreeOutline.element); 222 205 223 let onlyShowResourcesWithIssuesFilterFunction = (treeElement) => { 206 224 if (treeElement.treeOutline !== this._resourcesTreeOutline) … … 220 238 const activatedByDefault = false; 221 239 this.filterBar.addFilterBarButton("sources-only-show-resources-with-issues", onlyShowResourcesWithIssuesFilterFunction, activatedByDefault, WI.UIString("Only show resources with issues"), WI.UIString("Show all resources"), "Images/Errors.svg", 15, 15); 240 241 WI.settings.resourceGroupingMode.addEventListener(WI.Setting.Event.Changed, this._handleResourceGroupingModeChanged, this); 222 242 223 243 WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._handleFrameMainResourceDidChange, this); … … 282 302 WI.debuggerManager.addBreakpoint(WI.debuggerManager.assertionFailuresBreakpoint); 283 303 284 let mainFrame = WI.networkManager.mainFrame;285 if (mainFrame) {286 this._updateMainFrameTreeElement(mainFrame);287 this._addResourcesRecursivelyForFrame(mainFrame);288 }289 290 304 for (let target of WI.targets) 291 305 this._addTarget(target); … … 293 307 this._updateCallStackTreeOutline(); 294 308 295 for (let script of WI.debuggerManager.knownNonResourceScripts) { 296 this._addScript(script); 297 298 if (script.sourceMaps.length && WI.SourcesNavigationSidebarPanel.shouldPlaceResourcesAtTopLevel()) 299 this._resourcesTreeOutline.disclosureButtons = true; 300 } 309 this._handleResourceGroupingModeChanged(); 301 310 302 311 if (WI.domDebuggerManager.supported) { … … 348 357 closed() 349 358 { 359 WI.settings.resourceGroupingMode.removeEventListener(null, null, this); 350 360 WI.Frame.removeEventListener(null, null, this); 351 361 WI.Target.removeEventListener(null, null, this); … … 388 398 } 389 399 390 // The Frame is used as the representedObject instead of the main resource in our tree.391 400 if (representedObject instanceof WI.Resource && representedObject.parentFrame && representedObject.parentFrame.mainResource === representedObject) 392 401 representedObject = representedObject.parentFrame; … … 418 427 } 419 428 420 let treeElement = this._resourcesTreeOutline.findTreeElement(representedObject, isAncestor, getParent); 429 function searchTreeOutline(treeOutline, forceSearch) { 430 if (!treeOutline || (!treeOutline.selectedTreeElement && !forceSearch)) 431 return null; 432 return treeOutline.findTreeElement(representedObject, isAncestor, getParent); 433 } 434 let treeElement = searchTreeOutline(this._pauseReasonTreeOutline) || searchTreeOutline(this._callStackTreeOutline) || searchTreeOutline(this._breakpointsTreeOutline) || searchTreeOutline(this._resourcesTreeOutline, true); 421 435 if (treeElement) 422 436 return treeElement; … … 442 456 443 457 if (!this._anonymousScriptsFolderTreeElement.parent) { 444 let index = insertionIndexForObjectInListSortedByFunction(this._anonymousScriptsFolderTreeElement, this._resourcesTreeOutline.children, this._ compareTreeElements);458 let index = insertionIndexForObjectInListSortedByFunction(this._anonymousScriptsFolderTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); 445 459 this._resourcesTreeOutline.insertChild(this._anonymousScriptsFolderTreeElement, index); 446 460 } … … 485 499 if (treeElement instanceof WI.FolderTreeElement) 486 500 return false; 501 502 if (treeElement instanceof WI.IssueTreeElement) 503 treeElement = treeElement.parent; 487 504 488 505 function match() … … 528 545 _compareTreeElements(a, b) 529 546 { 530 // Always sort the main frame element first. 531 if (a instanceof WI.FrameTreeElement) 532 return -1; 533 if (b instanceof WI.FrameTreeElement) 534 return 1; 535 536 console.assert(a.mainTitle); 537 console.assert(b.mainTitle); 538 539 return (a.mainTitle || "").extendedLocaleCompare(b.mainTitle || ""); 547 const rankFunctions = [ 548 (treeElement) => treeElement === this._mainFrameTreeElement, 549 (treeElement) => treeElement instanceof WI.FrameTreeElement, 550 (treeElement) => { 551 return treeElement instanceof WI.FolderTreeElement 552 && treeElement !== this._extensionScriptsFolderTreeElement 553 && treeElement !== this._extraScriptsFolderTreeElement 554 && treeElement !== this._anonymousScriptsFolderTreeElement; 555 }, 556 (treeElement) => treeElement === this._extensionScriptsFolderTreeElement, 557 (treeElement) => treeElement === this._extraScriptsFolderTreeElement, 558 (treeElement) => treeElement === this._anonymousScriptsFolderTreeElement, 559 ]; 560 561 let aRank = rankFunctions.findIndex((rankFunction) => rankFunction(a)); 562 let bRank = rankFunctions.findIndex((rankFunction) => rankFunction(b)); 563 if (aRank >= 0 && bRank >= 0) { 564 if (aRank < bRank) 565 return -1; 566 if (bRank < aRank) 567 return 1; 568 } 569 570 return a.mainTitle.extendedLocaleCompare(b.mainTitle) || a.subtitle.extendedLocaleCompare(b.subtitle); 540 571 } 541 572 … … 545 576 this.contentBrowser.contentViewContainer.closeAllContentViews(); 546 577 578 let oldMainFrameTreeElement = this._mainFrameTreeElement; 547 579 if (this._mainFrameTreeElement) { 548 580 this._resourcesTreeOutline.removeChild(this._mainFrameTreeElement); … … 553 585 return; 554 586 555 this._mainFrameTreeElement = new WI.FrameTreeElement(mainFrame); 587 let resourceGroupingMode = WI.settings.resourceGroupingMode.value; 588 switch (resourceGroupingMode) { 589 case WI.Resource.GroupingMode.Path: 590 for (let treeElement of this._originTreeElementMap.values()) { 591 if (treeElement !== oldMainFrameTreeElement) 592 this._resourcesTreeOutline.removeChild(treeElement); 593 } 594 this._originTreeElementMap.clear(); 595 596 this._mainFrameTreeElement = new WI.FolderTreeElement(mainFrame.securityOrigin, mainFrame); 597 this._originTreeElementMap.set(mainFrame.securityOrigin, this._mainFrameTreeElement); 598 break; 599 600 default: 601 WI.reportInternalError("Unknown resource grouping mode", {"Resource Grouping Mode": WI.settings.resourceGroupingMode.value}); 602 // Fallthrough for default value. 603 604 case WI.Resource.GroupingMode.Type: 605 this._mainFrameTreeElement = new WI.FrameTreeElement(mainFrame); 606 break; 607 } 608 556 609 this._resourcesTreeOutline.insertChild(this._mainFrameTreeElement, 0); 557 610 … … 565 618 let treeElement = currentContentView ? this.treeElementForRepresentedObject(currentContentView.representedObject) : null; 566 619 if (!treeElement) 567 treeElement = this. _mainFrameTreeElement;620 treeElement = this.treeElementForRepresentedObject(WI.networkManager.mainFrame); 568 621 this.showDefaultContentViewForTreeElement(treeElement); 569 622 }); … … 601 654 _addResource(resource) 602 655 { 603 if (resource.type !== WI.Resource.Type.Document && resource.type !== WI.Resource.Type.Script) 604 return; 605 606 this._addBreakpointsForSourceCode(resource); 607 this._addIssuesForSourceCode(resource); 656 if (WI.settings.resourceGroupingMode.value === WI.Resource.GroupingMode.Path) { 657 if (!this._mainFrameTreeElement || this._resourcesTreeOutline.findTreeElement(resource)) 658 return; 659 660 let origin = null; 661 if (resource.urlComponents.scheme && resource.urlComponents.host) { 662 origin = resource.urlComponents.scheme + "://" + resource.urlComponents.host; 663 if (resource.urlComponents.port) 664 origin += ":" + resource.urlComponents.port; 665 } else 666 origin = resource.parentFrame.securityOrigin; 667 668 let frameTreeElement = this._originTreeElementMap.get(origin); 669 if (!frameTreeElement) { 670 frameTreeElement = new WI.FolderTreeElement(origin, origin === resource.parentFrame.securityOrigin ? resource.parentFrame : null); 671 this._originTreeElementMap.set(origin, frameTreeElement); 672 673 let index = insertionIndexForObjectInListSortedByFunction(frameTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); 674 this._resourcesTreeOutline.insertChild(frameTreeElement, index); 675 } 676 677 let subpath = resource.urlComponents.path; 678 if (subpath && subpath[0] === "/") 679 subpath = subpath.substring(1); 680 681 let parent = frameTreeElement.createFoldersAsNeededForSubpath(subpath); 682 if (resource instanceof WI.CSSStyleSheet) 683 parent.appendChild(new WI.CSSStyleSheetTreeElement(resource)); 684 else 685 parent.appendChild(new WI.ResourceTreeElement(resource, resource, {allowDirectoryAsName: true, hideOrigin: true})); 686 } 687 688 if (resource.type === WI.Resource.Type.Document || resource.type === WI.Resource.Type.Script) { 689 this._addBreakpointsForSourceCode(resource); 690 this._addIssuesForSourceCode(resource); 691 } 608 692 } 609 693 … … 643 727 return; 644 728 645 let insertIntoTopLevel = false; 646 let parentFolderTreeElement = null; 647 648 if (script.injected) { 649 if (!this._extensionScriptsFolderTreeElement) { 650 let collection = new WI.ScriptCollection; 651 this._extensionScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Extension Scripts"), collection); 652 } 653 654 parentFolderTreeElement = this._extensionScriptsFolderTreeElement; 729 let scriptTreeElement = new WI.ScriptTreeElement(script); 730 731 if (!script.injected && WI.SourcesNavigationSidebarPanel.shouldPlaceResourcesAtTopLevel()) { 732 let index = insertionIndexForObjectInListSortedByFunction(scriptTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); 733 this._resourcesTreeOutline.insertChild(scriptTreeElement, index); 655 734 } else { 656 if (WI.SourcesNavigationSidebarPanel.shouldPlaceResourcesAtTopLevel()) 657 insertIntoTopLevel = true; 658 else { 735 let parentFolderTreeElement = null; 736 737 if (script.injected) { 738 if (!this._extensionScriptsFolderTreeElement) { 739 let collection = new WI.ScriptCollection; 740 this._extensionScriptsFolderTreeElement = new WI.FolderTreeElement(WI.UIString("Extension Scripts"), collection); 741 } 742 743 parentFolderTreeElement = this._extensionScriptsFolderTreeElement; 744 } else { 659 745 if (!this._extraScriptsFolderTreeElement) { 660 746 let collection = new WI.ScriptCollection; … … 664 750 parentFolderTreeElement = this._extraScriptsFolderTreeElement; 665 751 } 666 } 667 668 if (parentFolderTreeElement) 669 parentFolderTreeElement.representedObject.add(script); 670 671 let scriptTreeElement = new WI.ScriptTreeElement(script); 672 673 if (insertIntoTopLevel) { 674 let index = insertionIndexForObjectInListSortedByFunction(scriptTreeElement, this._resourcesTreeOutline.children, this._compareTreeElements); 675 this._resourcesTreeOutline.insertChild(scriptTreeElement, index); 676 } else { 752 753 if (parentFolderTreeElement) 754 parentFolderTreeElement.representedObject.add(script); 755 677 756 if (!parentFolderTreeElement.parent) { 678 let index = insertionIndexForObjectInListSortedByFunction(parentFolderTreeElement, this._resourcesTreeOutline.children, this._ compareTreeElements);757 let index = insertionIndexForObjectInListSortedByFunction(parentFolderTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); 679 758 this._resourcesTreeOutline.insertChild(parentFolderTreeElement, index); 680 759 } … … 694 773 this._workerTargetTreeElementMap.set(target, targetTreeElement); 695 774 696 let index = insertionIndexForObjectInListSortedByFunction(targetTreeElement, this._resourcesTreeOutline.children, this._ compareTreeElements);775 let index = insertionIndexForObjectInListSortedByFunction(targetTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); 697 776 this._resourcesTreeOutline.insertChild(targetTreeElement, index); 698 777 } … … 1259 1338 } 1260 1339 1340 _handleResourceGroupingModeMouseDown(event) 1341 { 1342 if (this._ignoreResourceGroupingModeMouseDown) 1343 return; 1344 1345 this._ignoreResourceGroupingModeMouseDown = true; 1346 1347 let contextMenu = WI.ContextMenu.createFromEvent(event); 1348 contextMenu.addBeforeShowCallback(() => { 1349 this._ignoreResourceGroupingModeMouseDown = false; 1350 }); 1351 1352 function addOption(mode, label) { 1353 contextMenu.appendCheckboxItem(label, () => { 1354 WI.settings.resourceGroupingMode.value = mode; 1355 }, WI.settings.resourceGroupingMode.value === mode); 1356 } 1357 addOption(WI.Resource.GroupingMode.Path, WI.UIString("Group by Path")); 1358 addOption(WI.Resource.GroupingMode.Type, WI.UIString("Group by Type")); 1359 1360 contextMenu.show(); 1361 } 1362 1261 1363 _handleTreeSelectionDidChange(event) 1262 1364 { … … 1278 1380 || treeElement instanceof WI.ScriptTreeElement 1279 1381 || treeElement instanceof WI.CSSStyleSheetTreeElement) { 1280 WI.showRepresentedObject(treeElement.representedObject); 1382 let representedObject = treeElement.representedObject; 1383 if (representedObject instanceof WI.Collection || representedObject instanceof WI.SourceCode) 1384 WI.showRepresentedObject(representedObject); 1281 1385 return; 1282 1386 } … … 1388 1492 } 1389 1493 1494 _handleResourceGroupingModeChanged(event) 1495 { 1496 this._workerTargetTreeElementMap.clear(); 1497 this._mainFrameTreeElement = null; 1498 this._extensionScriptsFolderTreeElement = null; 1499 this._extraScriptsFolderTreeElement = null; 1500 this._anonymousScriptsFolderTreeElement = null; 1501 1502 this._originTreeElementMap.clear(); 1503 1504 this._resourcesTreeOutline.removeChildren(); 1505 1506 let mainFrame = WI.networkManager.mainFrame; 1507 if (mainFrame) { 1508 this._updateMainFrameTreeElement(mainFrame); 1509 this._addResourcesRecursivelyForFrame(mainFrame); 1510 } 1511 1512 for (let script of WI.debuggerManager.knownNonResourceScripts) { 1513 this._addScript(script); 1514 1515 if (script.sourceMaps.length && WI.SourcesNavigationSidebarPanel.shouldPlaceResourcesAtTopLevel()) 1516 this._resourcesTreeOutline.disclosureButtons = true; 1517 } 1518 } 1519 1390 1520 _handleFrameMainResourceDidChange(event) 1391 1521 { 1392 if (event.target.isMainFrame()) { 1393 this._updateMainFrameTreeElement(event.target); 1522 let frame = event.target; 1523 if (frame.isMainFrame()) { 1524 this._updateMainFrameTreeElement(frame); 1525 this._addResourcesRecursivelyForFrame(frame); 1394 1526 1395 1527 for (let domBreakpoint of WI.domDebuggerManager.domBreakpoints) … … 1411 1543 _handleMainFrameDidChange(event) 1412 1544 { 1413 this._updateMainFrameTreeElement(WI.networkManager.mainFrame); 1545 let mainFrame = WI.networkManager.mainFrame; 1546 this._updateMainFrameTreeElement(mainFrame); 1547 this._addResourcesRecursivelyForFrame(mainFrame); 1414 1548 } 1415 1549
Note:
See TracChangeset
for help on using the changeset viewer.