Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js

Issue 2444223002: [Devtools] Cleanup DataGrid's typecast and identifier naming (Closed)
Patch Set: changes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js b/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js
index 33213c072d4c6792654db981877f66dee33339de..873d565e156b96a517f866ea2f063bc44bc3d073 100644
--- a/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js
+++ b/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js
@@ -186,11 +186,11 @@ WebInspector.ApplicationCacheItemsView.prototype = {
_createDataGrid: function()
{
- var columns = [
- {title: WebInspector.UIString("Resource"), sort: WebInspector.DataGrid.Order.Ascending, sortable: true},
- {title: WebInspector.UIString("Type"), sortable: true},
- {title: WebInspector.UIString("Size"), align: WebInspector.DataGrid.Align.Right, sortable: true}
- ];
+ var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([
+ {id: "resource", title: WebInspector.UIString("Resource"), sort: WebInspector.DataGrid.Order.Ascending, sortable: true},
+ {id: "type", title: WebInspector.UIString("Type"), sortable: true},
+ {id: "size", title: WebInspector.UIString("Size"), align: WebInspector.DataGrid.Align.Right, sortable: true}
+ ]);
this._dataGrid = new WebInspector.DataGrid(columns);
this._dataGrid.asWidget().show(this.element);
this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._populateDataGrid, this);
@@ -211,10 +211,10 @@ WebInspector.ApplicationCacheItemsView.prototype = {
}
var comparator;
- switch (parseInt(this._dataGrid.sortColumnIdentifier(), 10)) {
- case 0: comparator = localeCompare.bind(null, "name"); break;
- case 1: comparator = localeCompare.bind(null, "type"); break;
- case 2: comparator = numberCompare.bind(null, "size"); break;
+ switch (this._dataGrid.sortColumnId()) {
+ case "resource": comparator = localeCompare.bind(null, "url"); break;
+ case "type": comparator = localeCompare.bind(null, "type"); break;
+ case "size": comparator = numberCompare.bind(null, "size"); break;
default: localeCompare.bind(null, "resource"); // FIXME: comparator = ?
}
@@ -225,9 +225,9 @@ WebInspector.ApplicationCacheItemsView.prototype = {
for (var i = 0; i < this._resources.length; ++i) {
var data = {};
var resource = this._resources[i];
- data[0] = resource.url;
- data[1] = resource.type;
- data[2] = Number.bytesToString(resource.size);
+ data.resource = resource.url;
+ data.type = resource.type;
+ data.size = Number.bytesToString(resource.size);
var node = new WebInspector.DataGridNode(data);
node.resource = resource;
node.selectable = true;

Powered by Google App Engine
This is Rietveld 408576698