Title: [222001] trunk/Source/WebInspectorUI
Revision
222001
Author
commit-qu...@webkit.org
Date
2017-09-13 16:46:44 -0700 (Wed, 13 Sep 2017)

Log Message

Web Inspector: Sort by size issues with Cookies and ApplicationCache DataGrids
https://bugs.webkit.org/show_bug.cgi?id=176879
<rdar://problem/34237096>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2017-09-13
Reviewed by Matt Baker.

* UserInterface/Views/ApplicationCacheFrameContentView.js:
(WI.ApplicationCacheFrameContentView.prototype._sortDataGrid):
(WI.ApplicationCacheFrameContentView.prototype._populateDataGrid):
This uses very dumb DataGridNodes with a pure data object. In that
object `size` is a bytes string not a number. Include the number size
in this data object that can be used during sorting.

* UserInterface/Views/CookieStorageContentView.js:
(WI.CookieStorageContentView.prototype._rebuildTable):
Simplify creation. Also don't reset sort options. Note that here the
DataGridNodes have access to the Cookie object and can already sort size
using the cookie's size (a number) and not the data's size (string).

* UserInterface/Views/DataGrid.js:
(WI.DataGrid.prototype.sortNodes):
(WI.DataGrid.prototype._sortNodesCallback):
If sortNodes was called twice, it would defer the sort and actually
do the sort with the first comparator and not the latest, preferred
comparator. Make it use the latest comparator.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (222000 => 222001)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-09-13 23:38:05 UTC (rev 222000)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-09-13 23:46:44 UTC (rev 222001)
@@ -1,3 +1,31 @@
+2017-09-13  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Sort by size issues with Cookies and ApplicationCache DataGrids
+        https://bugs.webkit.org/show_bug.cgi?id=176879
+        <rdar://problem/34237096>
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Views/ApplicationCacheFrameContentView.js:
+        (WI.ApplicationCacheFrameContentView.prototype._sortDataGrid):
+        (WI.ApplicationCacheFrameContentView.prototype._populateDataGrid):
+        This uses very dumb DataGridNodes with a pure data object. In that
+        object `size` is a bytes string not a number. Include the number size
+        in this data object that can be used during sorting.
+
+        * UserInterface/Views/CookieStorageContentView.js:
+        (WI.CookieStorageContentView.prototype._rebuildTable):
+        Simplify creation. Also don't reset sort options. Note that here the
+        DataGridNodes have access to the Cookie object and can already sort size
+        using the cookie's size (a number) and not the data's size (string).
+
+        * UserInterface/Views/DataGrid.js:
+        (WI.DataGrid.prototype.sortNodes):
+        (WI.DataGrid.prototype._sortNodesCallback):
+        If sortNodes was called twice, it would defer the sort and actually
+        do the sort with the first comparator and not the latest, preferred
+        comparator. Make it use the latest comparator.
+
 2017-09-13  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Styles Redesign: display @media section headers

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ApplicationCacheFrameContentView.js (222000 => 222001)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ApplicationCacheFrameContentView.js	2017-09-13 23:38:05 UTC (rev 222000)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ApplicationCacheFrameContentView.js	2017-09-13 23:46:44 UTC (rev 222001)
@@ -188,7 +188,7 @@
         var comparator;
         switch (this._dataGrid.sortColumnIdentifier) {
             case "type": comparator = localeCompare.bind(this, "type"); break;
-            case "size": comparator = numberCompare.bind(this, "size"); break;
+            case "size": comparator = numberCompare.bind(this, "sizeNumber"); break;
             case "url":
             default: comparator = localeCompare.bind(this, "url"); break;
         }
@@ -204,7 +204,8 @@
             var data = {
                 url: resource.url,
                 type: resource.type,
-                size: Number.bytesToString(resource.size)
+                size: Number.bytesToString(resource.size),
+                sizeNumber: resource.size,
             };
             var node = new WI.DataGridNode(data);
             this._dataGrid.appendChild(node);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js (222000 => 222001)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js	2017-09-13 23:38:05 UTC (rev 222000)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js	2017-09-13 23:46:44 UTC (rev 222001)
@@ -115,6 +115,8 @@
             this._dataGrid = new WI.DataGrid(columns, null, this._deleteCallback.bind(this));
             this._dataGrid.columnChooserEnabled = true;
             this._dataGrid.addEventListener(WI.DataGrid.Event.SortChanged, this._sortDataGrid, this);
+            this._dataGrid.sortColumnIdentifier = "name";
+            this._dataGrid.createSettings("cookie-storage-content-view");
 
             this.addSubview(this._dataGrid);
             this._dataGrid.updateLayout();
@@ -126,14 +128,14 @@
         for (var cookie of this._cookies) {
             const checkmark = "\u2713";
             var data = {
-                "name": cookie.name,
-                "value": cookie.value,
-                "domain": cookie.domain || "",
-                "path": cookie.path || "",
-                "expires": "",
-                "size": Number.bytesToString(cookie.size),
-                "http": cookie.httpOnly ? checkmark : "",
-                "secure": cookie.secure ? checkmark : "",
+                name: cookie.name,
+                value: cookie.value,
+                domain: cookie.domain || "",
+                path: cookie.path || "",
+                expires: "",
+                size: Number.bytesToString(cookie.size),
+                http: cookie.httpOnly ? checkmark : "",
+                secure: cookie.secure ? checkmark : "",
             };
 
             if (cookie.type !== WI.CookieType.Request)
@@ -144,9 +146,6 @@
 
             this._dataGrid.appendChild(node);
         }
-
-        this._dataGrid.sortColumnIdentifier = "name";
-        this._dataGrid.createSettings("cookie-storage-content-view");
     }
 
     _filterCookies(cookies)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (222000 => 222001)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2017-09-13 23:38:05 UTC (rev 222000)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2017-09-13 23:46:44 UTC (rev 222001)
@@ -1284,10 +1284,16 @@
 
     sortNodes(comparator)
     {
+        // FIXME: This should use the layout loop and not its own requestAnimationFrame.
+        this._sortNodesComparator = comparator;
+
         if (this._sortNodesRequestId)
             return;
 
-        this._sortNodesRequestId = window.requestAnimationFrame(this._sortNodesCallback.bind(this, comparator));
+        this._sortNodesRequestId = window.requestAnimationFrame(() => {
+            if (this._sortNodesComparator)
+                this._sortNodesCallback(this._sortNodesComparator);
+        });
     }
 
     sortNodesImmediately(comparator)
@@ -1312,6 +1318,7 @@
         }
 
         this._sortNodesRequestId = undefined;
+        this._sortNodesComparator = null;
 
         if (this._editing) {
             this._sortAfterEditingCallback = this.sortNodes.bind(this, comparator);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to