- Revision
- 202009
- Author
- mattba...@apple.com
- Date
- 2016-06-13 15:41:54 -0700 (Mon, 13 Jun 2016)
Log Message
Web Inspector: Add ability to show/hide DataGird columns
https://bugs.webkit.org/show_bug.cgi?id=158676
<rdar://problem/26761573>
Reviewed by Timothy Hatcher.
Make it possible to show/hide grid columns using the grid header
context menu. This patch enables the new behavior for most of the
timeline grids.
* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid):
(WebInspector.DataGrid.prototype.get identifier):
(WebInspector.DataGrid.prototype.set identifier):
An identifier for the grid instance, for managing per-grid settings.
Setting the id causes settings to be created, and their values to be
applied to the grid.
(WebInspector.DataGrid.prototype.get columnChooserEnabled):
(WebInspector.DataGrid.prototype.set columnChooserEnabled):
Enable showing/hiding columns via the grid header.
(WebInspector.DataGrid.prototype.insertColumn):
(WebInspector.DataGrid.prototype.showColumn):
Set column visibility and hidden column setting, then perform layout.
(WebInspector.DataGrid.prototype._collapseColumnGroupWithCell):
(WebInspector.DataGrid.prototype._contextMenuInHeader):
Create column chooser menu items if necessary.
(WebInspector.DataGrid.prototype._showColumn): Deleted.
(WebInspector.DataGrid.prototype._hideColumn): Deleted.
Replaced by `showColumn`.
* UserInterface/Views/LayoutTimelineView.js:
(WebInspector.LayoutTimelineView):
Always show "type" and "name" columns.
* UserInterface/Views/NetworkTimelineView.js:
(WebInspector.NetworkTimelineView):
* UserInterface/Views/RenderingFrameTimelineView.js:
(WebInspector.RenderingFrameTimelineView):
* UserInterface/Views/ScriptDetailsTimelineView.js:
(WebInspector.ScriptDetailsTimelineView):
Always show "name" column.
* UserInterface/Views/TimelineDataGrid.js:
(WebInspector.TimelineDataGrid):
Enable column chooser.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (202008 => 202009)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-06-13 22:41:54 UTC (rev 202009)
@@ -1,3 +1,55 @@
+2016-06-13 Matt Baker <mattba...@apple.com>
+
+ Web Inspector: Add ability to show/hide DataGird columns
+ https://bugs.webkit.org/show_bug.cgi?id=158676
+ <rdar://problem/26761573>
+
+ Reviewed by Timothy Hatcher.
+
+ Make it possible to show/hide grid columns using the grid header
+ context menu. This patch enables the new behavior for most of the
+ timeline grids.
+
+ * UserInterface/Views/DataGrid.js:
+ (WebInspector.DataGrid):
+ (WebInspector.DataGrid.prototype.get identifier):
+ (WebInspector.DataGrid.prototype.set identifier):
+ An identifier for the grid instance, for managing per-grid settings.
+ Setting the id causes settings to be created, and their values to be
+ applied to the grid.
+
+ (WebInspector.DataGrid.prototype.get columnChooserEnabled):
+ (WebInspector.DataGrid.prototype.set columnChooserEnabled):
+ Enable showing/hiding columns via the grid header.
+
+ (WebInspector.DataGrid.prototype.insertColumn):
+ (WebInspector.DataGrid.prototype.showColumn):
+ Set column visibility and hidden column setting, then perform layout.
+
+ (WebInspector.DataGrid.prototype._collapseColumnGroupWithCell):
+ (WebInspector.DataGrid.prototype._contextMenuInHeader):
+ Create column chooser menu items if necessary.
+
+ (WebInspector.DataGrid.prototype._showColumn): Deleted.
+ (WebInspector.DataGrid.prototype._hideColumn): Deleted.
+ Replaced by `showColumn`.
+
+ * UserInterface/Views/LayoutTimelineView.js:
+ (WebInspector.LayoutTimelineView):
+ Always show "type" and "name" columns.
+
+ * UserInterface/Views/NetworkTimelineView.js:
+ (WebInspector.NetworkTimelineView):
+ * UserInterface/Views/RenderingFrameTimelineView.js:
+ (WebInspector.RenderingFrameTimelineView):
+ * UserInterface/Views/ScriptDetailsTimelineView.js:
+ (WebInspector.ScriptDetailsTimelineView):
+ Always show "name" column.
+
+ * UserInterface/Views/TimelineDataGrid.js:
+ (WebInspector.TimelineDataGrid):
+ Enable column chooser.
+
2016-06-10 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: <template> content should not be hidden as Shadow Content
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (202008 => 202009)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2016-06-13 22:41:54 UTC (rev 202009)
@@ -32,10 +32,12 @@
this.columns = new Map;
this.orderedColumns = [];
+ this._identifier = null;
this._sortColumnIdentifier = null;
this._sortColumnIdentifierSetting = null;
this._sortOrder = WebInspector.DataGrid.SortOrder.Indeterminate;
this._sortOrderSetting = null;
+ this._hiddenColumnSetting = null;
this._rows = [];
@@ -206,6 +208,30 @@
return dataGrid;
}
+ get identifier() { return this._identifier; }
+
+ set identifier(x)
+ {
+ console.assert(x && typeof x === "string");
+
+ if (this._identifier === x)
+ return;
+
+ this._identifier = x;
+
+ // FIXME: Add sortColumnIdentifierSetting and sortOrderSetting as part of <webkit.org/b/158675>.
+ this._hiddenColumnSetting = new WebInspector.Setting(this._identifier + "-hidden-columns", []);
+
+ if (!this.columns)
+ return;
+
+ for (let columnIdentifier of this._hiddenColumnSetting.value)
+ this.showColumn(columnIdentifier, false);
+ }
+
+ get columnChooserEnabled() { return this._columnChooserEnabled; }
+ set columnChooserEnabled(x) { this._columnChooserEnabled = x; }
+
get refreshCallback()
{
return this._refreshCallback;
@@ -733,8 +759,7 @@
listeners.install();
- if (column["hidden"])
- this._hideColumn(columnIdentifier);
+ this.showColumn(columnIdentifier, !column.hidden);
}
removeColumn(columnIdentifier)
@@ -873,20 +898,29 @@
return !this.columns.get(columnIdentifier)["hidden"];
}
- _showColumn(columnIdentifier)
+ showColumn(columnIdentifier, visible)
{
- this.columns.get(columnIdentifier)["hidden"] = false;
- }
+ let column = this.columns.get(columnIdentifier);
+ console.assert(column, "Missing column info for identifier: " + columnIdentifier);
- _hideColumn(columnIdentifier)
- {
- var column = this.columns.get(columnIdentifier);
- column["hidden"] = true;
+ if (!column || visible === !column.hidden)
+ return;
- var columnElement = column["element"];
- columnElement.style.width = 0;
+ column.element.style.width = visible ? column.width : 0;
+ column.hidden = !visible;
+ if (this._hiddenColumnSetting) {
+ let hiddenColumns = this._hiddenColumnSetting.value.slice();
+ if (column.hidden)
+ hiddenColumns.push(columnIdentifier);
+ else
+ hiddenColumns.remove(columnIdentifier);
+
+ this._hiddenColumnSetting.value = hiddenColumns;
+ }
+
this._columnWidthsInitialized = false;
+ this.updateLayout();
}
get scrollContainer()
@@ -1488,10 +1522,9 @@
this.willToggleColumnGroup(cell.collapsesGroup, columnsWillCollapse);
- var showOrHide = columnsWillCollapse ? this._hideColumn : this._showColumn;
for (var [identifier, column] of this.columns) {
if (column["group"] === cell.collapsesGroup)
- showOrHide.call(this, identifier);
+ this.showColumn(identifier, !columnsWillCollapse);
}
var collapserButton = cell.querySelector(".collapser-button");
@@ -1551,22 +1584,48 @@
if (this._hasCopyableData())
contextMenu.appendItem(WebInspector.UIString("Copy Table"), this._copyTable.bind(this));
- let cell = event.target.enclosingNodeOrSelfWithNodeName("th");
- if (cell && cell.columnIdentifier && cell.classList.contains(WebInspector.DataGrid.SortableColumnStyleClassName)) {
+ let headerCellElement = event.target.enclosingNodeOrSelfWithNodeName("th");
+ if (!headerCellElement)
+ return;
+
+ let columnIdentifier = headerCellElement.columnIdentifier;
+ let column = this.columns.get(columnIdentifier);
+ console.assert(column, "Missing column info for identifier: " + columnIdentifier);
+ if (!column)
+ return;
+
+ if (column.sortable) {
contextMenu.appendSeparator();
- if (this.sortColumnIdentifier !== cell.columnIdentifier || this.sortOrder !== WebInspector.DataGrid.SortOrder.Ascending) {
+ if (this.sortColumnIdentifier !== columnIdentifier || this.sortOrder !== WebInspector.DataGrid.SortOrder.Ascending) {
contextMenu.appendItem(WebInspector.UIString("Sort Ascending"), () => {
- this._selectSortColumnAndSetOrder(cell.columnIdentifier, WebInspector.DataGrid.SortOrder.Ascending);
+ this._selectSortColumnAndSetOrder(columnIdentifier, WebInspector.DataGrid.SortOrder.Ascending);
});
}
- if (this.sortColumnIdentifier !== cell.columnIdentifier || this.sortOrder !== WebInspector.DataGrid.SortOrder.Descending) {
+ if (this.sortColumnIdentifier !== columnIdentifier || this.sortOrder !== WebInspector.DataGrid.SortOrder.Descending) {
contextMenu.appendItem(WebInspector.UIString("Sort Descending"), () => {
- this._selectSortColumnAndSetOrder(cell.columnIdentifier, WebInspector.DataGrid.SortOrder.Descending);
+ this._selectSortColumnAndSetOrder(columnIdentifier, WebInspector.DataGrid.SortOrder.Descending);
});
}
}
+
+ if (!this._columnChooserEnabled)
+ return;
+
+ let didAddSeparator = false;
+
+ for (let [identifier, columnInfo] of this.columns) {
+ if (columnInfo.locked)
+ continue;
+
+ if (!didAddSeparator) {
+ contextMenu.appendSeparator();
+ didAddSeparator = true;
+ }
+
+ contextMenu.appendCheckboxItem(columnInfo.title, () => { this.showColumn(identifier, columnInfo.hidden); }, !columnInfo.hidden);
+ }
}
_contextMenuInDataTable(event)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js (202008 => 202009)
--- trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js 2016-06-13 22:41:54 UTC (rev 202009)
@@ -44,9 +44,11 @@
columns.type.scopeBar = WebInspector.TimelineDataGrid.createColumnScopeBar("layout", typeToLabelMap);
columns.type.hidden = true;
+ columns.type.locked = true;
columns.name.disclosure = true;
columns.name.icon = true;
+ columns.name.locked = true;
this._scopeBar = columns.type.scopeBar;
@@ -75,6 +77,9 @@
this.setupDataGrid(this._dataGrid);
+ this._dataGrid.identifier = "layout-timeline-view";
+
+ // FIXME: Remove once <webkit.org/b/158675> is fixed.
this._dataGrid.sortColumnIdentifierSetting = new WebInspector.Setting("layout-timeline-view-sort", "startTime");
this._dataGrid.sortOrderSetting = new WebInspector.Setting("layout-timeline-view-sort-order", WebInspector.DataGrid.SortOrder.Ascending);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js (202008 => 202009)
--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js 2016-06-13 22:41:54 UTC (rev 202009)
@@ -36,6 +36,7 @@
columns.name.title = WebInspector.UIString("Name");
columns.name.icon = true;
columns.name.width = "10%";
+ columns.name.locked = true;
columns.domain.title = WebInspector.UIString("Domain");
columns.domain.width = "10%";
@@ -88,7 +89,10 @@
columns[column].sortable = true;
this._dataGrid = new WebInspector.TimelineDataGrid(columns);
+ this._dataGrid.identifier = "network-timeline-view";
this._dataGrid.sortDelegate = this;
+
+ // FIXME: Remove once <webkit.org/b/158675> is fixed.
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);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js (202008 => 202009)
--- trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js 2016-06-13 22:41:54 UTC (rev 202009)
@@ -46,6 +46,7 @@
columns.name.width = "20%";
columns.name.icon = true;
columns.name.disclosure = true;
+ columns.name.locked = true;
columns.totalTime.title = WebInspector.UIString("Total Time");
columns.totalTime.width = "15%";
@@ -77,6 +78,9 @@
columns[column].sortable = true;
this._dataGrid = new WebInspector.TimelineDataGrid(columns);
+ this._dataGrid.identifier = "rendering-frame-timeline-view";
+
+ // FIXME: Remove once <webkit.org/b/158675> is fixed.
this._dataGrid.sortColumnIdentifierSetting = new WebInspector.Setting("rendering-frame-timeline-view-sort", "startTime");
this._dataGrid.sortOrderSetting = new WebInspector.Setting("rendering-frame-timeline-view-sort-order", WebInspector.DataGrid.SortOrder.Ascending);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js (202008 => 202009)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptDetailsTimelineView.js 2016-06-13 22:41:54 UTC (rev 202009)
@@ -37,6 +37,7 @@
columns.name.width = "10%";
columns.name.icon = true;
columns.name.disclosure = true;
+ columns.name.locked = true;
columns.location.title = WebInspector.UIString("Location");
columns.location.icon = true;
@@ -72,7 +73,10 @@
columns[column].sortable = true;
this._dataGrid = new WebInspector.ScriptTimelineDataGrid(columns);
+ this._dataGrid.identifier = "script-timeline-view";
this._dataGrid.sortDelegate = this;
+
+ // FIXME: Remove once <webkit.org/b/158675> is fixed.
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);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js (202008 => 202009)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js 2016-06-13 22:25:52 UTC (rev 202008)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js 2016-06-13 22:41:54 UTC (rev 202009)
@@ -58,6 +58,8 @@
this.addEventListener(WebInspector.DataGrid.Event.SortChanged, this._sort, this);
window.addEventListener("resize", this);
+
+ this.columnChooserEnabled = true;
}
static createColumnScopeBar(prefix, map)