- Revision
- 199974
- Author
- mattba...@apple.com
- Date
- 2016-04-24 20:09:18 -0700 (Sun, 24 Apr 2016)
Log Message
Web Inspector: Can't sort by name/source code location columns in Timeline data grids
https://bugs.webkit.org/show_bug.cgi?id=156965
<rdar://problem/25898716>
Reviewed by Timothy Hatcher.
Add support for sorting SourceCodeLocation objects to TimelineDataGrid,
and include a grid delegate so that views can extend sorting logic for
other document fragment columns.
* UserInterface/Views/NetworkTimelineView.js:
(WebInspector.NetworkTimelineView):
(WebInspector.NetworkTimelineView.prototype.dataGridSortComparator):
Sort "name" column by display name first, then resource URL.
* UserInterface/Views/ScriptDetailsTimelineView.js:
(WebInspector.ScriptDetailsTimelineView):
(WebInspector.ScriptDetailsTimelineView.prototype.dataGridSortComparator):
Sort "name" column by display name first, then subtitle.
* UserInterface/Views/ScriptTimelineDataGridNode.js:
(WebInspector.ScriptTimelineDataGridNode.prototype.get subtitle):
Make subtitle accessible externally for sorting.
(WebInspector.ScriptTimelineDataGridNode.prototype._createNameCellDocumentFragment):
(WebInspector.ScriptTimelineDataGridNode):
* UserInterface/Views/TimelineDataGrid.js:
(WebInspector.TimelineDataGrid):
(WebInspector.TimelineDataGrid.prototype.get sortDelegate):
(WebInspector.TimelineDataGrid.prototype.set sortDelegate):
Fire a SortChanged event if the delegate changed and the grid is sorted.
(WebInspector.TimelineDataGrid.prototype._sort):
If a sort delegate exists, and it returns a numeric value, skip the
default compare.
(WebInspector.TimelineDataGrid.prototype._sortComparator):
Add support for sorting SourceCodeLocation columns.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (199973 => 199974)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-04-25 01:40:20 UTC (rev 199973)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-04-25 03:09:18 UTC (rev 199974)
@@ -1,5 +1,45 @@
2016-04-24 Matt Baker <mattba...@apple.com>
+ Web Inspector: Can't sort by name/source code location columns in Timeline data grids
+ https://bugs.webkit.org/show_bug.cgi?id=156965
+ <rdar://problem/25898716>
+
+ Reviewed by Timothy Hatcher.
+
+ Add support for sorting SourceCodeLocation objects to TimelineDataGrid,
+ and include a grid delegate so that views can extend sorting logic for
+ other document fragment columns.
+
+ * UserInterface/Views/NetworkTimelineView.js:
+ (WebInspector.NetworkTimelineView):
+ (WebInspector.NetworkTimelineView.prototype.dataGridSortComparator):
+ Sort "name" column by display name first, then resource URL.
+
+ * UserInterface/Views/ScriptDetailsTimelineView.js:
+ (WebInspector.ScriptDetailsTimelineView):
+ (WebInspector.ScriptDetailsTimelineView.prototype.dataGridSortComparator):
+ Sort "name" column by display name first, then subtitle.
+
+ * UserInterface/Views/ScriptTimelineDataGridNode.js:
+ (WebInspector.ScriptTimelineDataGridNode.prototype.get subtitle):
+ Make subtitle accessible externally for sorting.
+ (WebInspector.ScriptTimelineDataGridNode.prototype._createNameCellDocumentFragment):
+ (WebInspector.ScriptTimelineDataGridNode):
+
+ * UserInterface/Views/TimelineDataGrid.js:
+ (WebInspector.TimelineDataGrid):
+ (WebInspector.TimelineDataGrid.prototype.get sortDelegate):
+ (WebInspector.TimelineDataGrid.prototype.set sortDelegate):
+ Fire a SortChanged event if the delegate changed and the grid is sorted.
+ (WebInspector.TimelineDataGrid.prototype._sort):
+ If a sort delegate exists, and it returns a numeric value, skip the
+ default compare.
+
+ (WebInspector.TimelineDataGrid.prototype._sortComparator):
+ Add support for sorting SourceCodeLocation columns.
+
+2016-04-24 Matt Baker <mattba...@apple.com>
+
Web Inspector: Error when selecting a bar in the Frames timeline
https://bugs.webkit.org/show_bug.cgi?id=156960
<rdar://problem/25897955>
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js (199973 => 199974)
--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js 2016-04-25 01:40:20 UTC (rev 199973)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js 2016-04-25 03:09:18 UTC (rev 199974)
@@ -90,6 +90,7 @@
this._dataGrid = new WebInspector.TimelineDataGrid(columns);
this._dataGrid.addEventListener(WebInspector.TimelineDataGrid.Event.FiltersDidChange, this._dataGridFiltersDidChange, this);
this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SelectedNodeChanged, this._dataGridNodeSelected, this);
+ this._dataGrid.sortDelegate = this;
this._dataGrid.sortColumnIdentifierSetting = new WebInspector.Setting("network-timeline-view-sort", "requestSent");
this._dataGrid.sortOrderSetting = new WebInspector.Setting("network-timeline-view-sort-order", WebInspector.DataGrid.SortOrder.Ascending);
@@ -152,6 +153,21 @@
this._pendingRecords = [];
}
+ // TimelineDataGrid sort delegate
+
+ dataGridSortComparator(sortColumnIdentifier, sortDirection, node1, node2)
+ {
+ if (sortColumnIdentifier !== "name")
+ return null;
+
+ 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;
+ }
+
// Protected
canShowContentViewForTreeElement(treeElement)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js (199973 => 199974)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js 2016-04-25 01:40:20 UTC (rev 199973)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js 2016-04-25 03:09:18 UTC (rev 199974)
@@ -74,6 +74,7 @@
this._dataGrid = new WebInspector.ScriptTimelineDataGrid(columns);
this._dataGrid.addEventListener(WebInspector.TimelineDataGrid.Event.FiltersDidChange, this._dataGridFiltersDidChange, this);
this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SelectedNodeChanged, this._dataGridNodeSelected, this);
+ this._dataGrid.sortDelegate = this;
this._dataGrid.sortColumnIdentifierSetting = new WebInspector.Setting("script-timeline-view-sort", "startTime");
this._dataGrid.sortOrderSetting = new WebInspector.Setting("script-timeline-view-sort-order", WebInspector.DataGrid.SortOrder.Ascending);
@@ -145,6 +146,21 @@
this._pendingRecords = [];
}
+ // TimelineDataGrid sort delegate
+
+ dataGridSortComparator(sortColumnIdentifier, sortDirection, node1, node2)
+ {
+ if (sortColumnIdentifier !== "name")
+ return null;
+
+ let displayName1 = node1.displayName();
+ let displayName2 = node2.displayName();
+ if (displayName1 !== displayName2)
+ return displayName1.localeCompare(displayName2) * sortDirection;
+
+ return node1.subtitle.localeCompare(node2.subtitle) * sortDirection;
+ }
+
// Protected
dataGridNodePathComponentSelected(event)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js (199973 => 199974)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js 2016-04-25 01:40:20 UTC (rev 199973)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js 2016-04-25 03:09:18 UTC (rev 199974)
@@ -87,6 +87,24 @@
return this._cachedData;
}
+ get subtitle()
+ {
+ if (this._subtitle !== undefined)
+ return this._subtitle;
+
+ this._subtitle = "";
+
+ if (this._record.eventType === WebInspector.ScriptTimelineRecord.EventType.TimerInstalled) {
+ let timeoutString = Number.secondsToString(this._record.details.timeout / 1000);
+ if (this._record.details.repeating)
+ this._subtitle = WebInspector.UIString("%s interval").format(timeoutString);
+ else
+ this._subtitle = WebInspector.UIString("%s delay").format(timeoutString);
+ }
+
+ return this._subtitle;
+ }
+
updateRangeTimes(startTime, endTime)
{
var oldRangeStartTime = this._rangeStartTime;
@@ -145,16 +163,11 @@
let fragment = document.createDocumentFragment();
fragment.append(this.displayName());
- if (this._record.eventType === WebInspector.ScriptTimelineRecord.EventType.TimerInstalled) {
+ if (this.subtitle) {
let subtitleElement = document.createElement("span");
subtitleElement.classList.add("subtitle");
+ subtitleElement.textContent = this.subtitle;
fragment.append(subtitleElement);
-
- let timeoutString = Number.secondsToString(this._record.details.timeout / 1000);
- if (this._record.details.repeating)
- subtitleElement.textContent = WebInspector.UIString("%s interval").format(timeoutString);
- else
- subtitleElement.textContent = WebInspector.UIString("%s delay").format(timeoutString);
}
return fragment;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js (199973 => 199974)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js 2016-04-25 01:40:20 UTC (rev 199973)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js 2016-04-25 03:09:18 UTC (rev 199974)
@@ -35,6 +35,7 @@
this.element.classList.add("timeline");
this._filterableColumns = [];
+ this._sortDelegate = null;
// Check if any of the cells can be filtered.
for (var [identifier, column] of this.columns) {
@@ -79,6 +80,23 @@
// Public
+ get sortDelegate()
+ {
+ return this._sortDelegate;
+ }
+
+ set sortDelegate(delegate)
+ {
+ delegate = delegate || null;
+ if (this._sortDelegate === delegate)
+ return;
+
+ this._sortDelegate = delegate;
+
+ if (this.sortOrder !== WebInspector.DataGrid.SortOrder.Indeterminate)
+ this.dispatchEventToListeners(WebInspector.DataGrid.Event.SortChanged);
+ }
+
reset()
{
// May be overridden by subclasses. If so, they should call the superclass.
@@ -282,6 +300,9 @@
_sort()
{
+ if (!this.children.length)
+ return;
+
let sortColumnIdentifier = this.sortColumnIdentifier;
if (!sortColumnIdentifier)
return;
@@ -357,6 +378,12 @@
var sortDirection = this.sortOrder === WebInspector.DataGrid.SortOrder.Ascending ? 1 : -1;
+ if (this._sortDelegate && typeof this._sortDelegate.dataGridSortComparator === "function") {
+ let result = this._sortDelegate.dataGridSortComparator(sortColumnIdentifier, sortDirection, node1, node2);
+ if (typeof result === "number")
+ return result;
+ }
+
var value1 = node1.data[sortColumnIdentifier];
var value2 = node2.data[sortColumnIdentifier];
@@ -384,6 +411,11 @@
value2 = value2 ? value2.displayName || "" : "";
}
+ if (value1 instanceof WebInspector.SourceCodeLocation || value2 instanceof WebInspector.SourceCodeLocation) {
+ value1 = value1 ? value1.displayLocationString() || "" : "";
+ value2 = value2 ? value2.displayLocationString() || "" : "";
+ }
+
// For everything else (mostly booleans).
return (value1 < value2 ? -1 : (value1 > value2 ? 1 : 0)) * sortDirection;
}