Web Inspector: Sources: the name of the file should not be used as a folder
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 18:00:43 +0000 (18:00 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 18:00:43 +0000 (18:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196064
<rdar://problem/49097710>

Reviewed by Timothy Hatcher.

* UserInterface/Views/GeneralTreeElement.js:
(WI.GeneralTreeElement.prototype.createFoldersAsNeededForSubpath):

* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel.prototype._addResource):
Drive-by: sort resources in each folder by name when grouping by path.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243300 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/GeneralTreeElement.js
Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js

index d92a734..3e9a09b 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-21  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Sources: the name of the file should not be used as a folder
+        https://bugs.webkit.org/show_bug.cgi?id=196064
+        <rdar://problem/49097710>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/GeneralTreeElement.js:
+        (WI.GeneralTreeElement.prototype.createFoldersAsNeededForSubpath):
+
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel.prototype._addResource):
+        Drive-by: sort resources in each folder by name when grouping by path.
+
 2019-03-20  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: rework how Canvas.enable/Canvas.disable is used so that events are not sent when the Canvas tab isn't enabled
index 31f1e30..c44d62c 100644 (file)
@@ -207,6 +207,9 @@ WI.GeneralTreeElement = class GeneralTreeElement extends WI.TreeElement
         let currentFolderTreeElement = this;
 
         for (let component of components) {
+            if (component === components.lastValue)
+                break;
+
             if (currentPath)
                 currentPath += "/";
             currentPath += component;
index 7223f70..42f091a 100644 (file)
@@ -682,15 +682,19 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
                 this._resourcesTreeOutline.insertChild(frameTreeElement, index);
             }
 
+            let resourceTreeElement = null;
+            if (resource instanceof WI.CSSStyleSheet)
+                resourceTreeElement = new WI.CSSStyleSheetTreeElement(resource);
+            else
+                resourceTreeElement = new WI.ResourceTreeElement(resource, resource, {allowDirectoryAsName: true, hideOrigin: true});
+
             let subpath = resource.urlComponents.path;
             if (subpath && subpath[0] === "/")
                 subpath = subpath.substring(1);
 
             let parent = frameTreeElement.createFoldersAsNeededForSubpath(subpath);
-            if (resource instanceof WI.CSSStyleSheet)
-                parent.appendChild(new WI.CSSStyleSheetTreeElement(resource));
-            else
-                parent.appendChild(new WI.ResourceTreeElement(resource, resource, {allowDirectoryAsName: true, hideOrigin: true}));
+            let index = insertionIndexForObjectInListSortedByFunction(resourceTreeElement, parent.children, this._boundCompareTreeElements);
+            parent.insertChild(resourceTreeElement, index);
         }
 
         if (resource.type === WI.Resource.Type.Document || resource.type === WI.Resource.Type.Script) {