Web Inspector: Network Tab - Sorting by Priority Column hides all rows in the datagri...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 06:35:04 +0000 (06:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 06:35:04 +0000 (06:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171312
<rdar://problem/31828554>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-04-25
Reviewed by Brian Burg.

* UserInterface/Models/Resource.js:
(WebInspector.Resource.comparePriority):
Provide a helper for compariting NetworkPriority enum values.

* UserInterface/Views/NetworkGridContentView.js:
(WebInspector.NetworkGridContentView):
(WebInspector.NetworkGridContentView.prototype.dataGridSortComparator):
* UserInterface/Views/NetworkTimelineView.js:
(WebInspector.NetworkTimelineView.prototype.dataGridSortComparator):
Custom sort handler for priority.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215793 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/Resource.js
Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js

index b808b6d..20d3bb4 100644 (file)
@@ -1,3 +1,22 @@
+2017-04-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Network Tab - Sorting by Priority Column hides all rows in the datagrid (uncaught exception)
+        https://bugs.webkit.org/show_bug.cgi?id=171312
+        <rdar://problem/31828554>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Models/Resource.js:
+        (WebInspector.Resource.comparePriority):
+        Provide a helper for compariting NetworkPriority enum values.
+
+        * UserInterface/Views/NetworkGridContentView.js:
+        (WebInspector.NetworkGridContentView):
+        (WebInspector.NetworkGridContentView.prototype.dataGridSortComparator):
+        * UserInterface/Views/NetworkTimelineView.js:
+        (WebInspector.NetworkTimelineView.prototype.dataGridSortComparator):
+        Custom sort handler for priority.
+
 2017-04-25  Nikita Vasilyev  <nvasilyev@apple.com>
 
         REGRESSION (r214863): Web Inspector: Uncaught Exception when losing focus from a selector field
index 5eff7ca..22aa88b 100644 (file)
@@ -169,6 +169,23 @@ WebInspector.Resource = class Resource extends WebInspector.SourceCode
         }
     }
 
+    static comparePriority(a, b)
+    {
+        console.assert(typeof a === "symbol");
+        console.assert(typeof b === "symbol");
+
+        const map = {
+            [WebInspector.Resource.NetworkPriority.Unknown]: 0,
+            [WebInspector.Resource.NetworkPriority.Low]: 1,
+            [WebInspector.Resource.NetworkPriority.Medium]: 2,
+            [WebInspector.Resource.NetworkPriority.High]: 3,
+        };
+
+        let aNum = map[a] || 0;
+        let bNum = map[b] || 0;
+        return aNum - bNum;
+    }
+
     static displayNameForPriority(priority)
     {
         switch (priority) {
index d59b4f2..eab529b 100644 (file)
@@ -117,6 +117,7 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
 
         this._dataGrid = new WebInspector.TimelineDataGrid(columns, this._contentTreeOutline);
         this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SelectedNodeChanged, this._dataGridNodeSelected, this);
+        this._dataGrid.sortDelegate = this;
         this._dataGrid.sortColumnIdentifier = "requestSent";
         this._dataGrid.sortOrder = WebInspector.DataGrid.SortOrder.Ascending;
         this._dataGrid.createSettings("network-grid-content-view");
@@ -267,6 +268,16 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
         this.reset();
     }
 
+    // TimelineDataGrid sort delegate
+
+    dataGridSortComparator(sortColumnIdentifier, sortDirection, node1, node2)
+    {
+        if (sortColumnIdentifier === "priority")
+            return WebInspector.Resource.comparePriority(node1.data.priority, node2.data.priority) * sortDirection;
+
+        return null;
+    }
+
     // Private
 
     _resourceCachingDisabledSettingChanged()
index 7015bf0..56d42e1 100644 (file)
@@ -190,15 +190,20 @@ WebInspector.NetworkTimelineView = class NetworkTimelineView extends WebInspecto
 
     dataGridSortComparator(sortColumnIdentifier, sortDirection, node1, node2)
     {
-        if (sortColumnIdentifier !== "name")
-            return null;
+        if (sortColumnIdentifier === "priority")
+            return WebInspector.Resource.comparePriority(node1.data.priority, node2.data.priority) * sortDirection;
+        
+        if (sortColumnIdentifier == "name") {
+            let displayName1 = node1.displayName();
+            let displayName2 = node2.displayName();
+
+            if (displayName1 !== displayName2)
+                return displayName1.localeCompare(displayName2) * sortDirection;
 
-        let displayName1 = node1.displayName();
-        let displayName2 = node2.displayName();
-        if (displayName1 !== displayName2)
-            return displayName1.localeCompare(displayName2) * sortDirection;
+            return node1.resource.url.localeCompare(node2.resource.url) * sortDirection;
+        }
 
-        return node1.resource.url.localeCompare(node2.resource.url) * sortDirection;
+        return null;
     }
 
     // Protected