Title: [199747] trunk/Source/WebInspectorUI
Revision
199747
Author
timo...@apple.com
Date
2016-04-19 16:41:25 -0700 (Tue, 19 Apr 2016)

Log Message

Web Inspector: DataGrid should be virtualized so it only renders visible rows

https://bugs.webkit.org/show_bug.cgi?id=156663
rdar://problem/25765256

Reviewed by Joseph Pecoraro.

* UserInterface/Views/ComputedStyleDetailsPanel.js:
(WebInspector.ComputedStyleDetailsPanel.prototype.set containerRegions):
Call updateLayoutIfNeeded since we don't use views here.

* UserInterface/Views/ConsoleMessageView.js:
(WebInspector.ConsoleMessageView.prototype._formatParameterAsTable):
Set inline and variableHeightRows to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.

* UserInterface/Views/DOMTreeDataGrid.js:
(WebInspector.DOMTreeDataGrid):
Set inline to true, remove direct classList add.

* UserInterface/Views/DataGrid.css:
(.data-grid td):
(.data-grid table.data):
(.data-grid:not(.variable-height-rows) table.data):
(.data-grid:not(.variable-height-rows) table.data.odd-first-zebra-stripe):
(.data-grid.variable-height-rows table.data tr:nth-child(odd)):
(.data-grid.variable-height-rows table.data tr:nth-child(even)):
(.data-grid.variable-height-rows.odd-first-zebra-stripe table.data tr:nth-child(odd)):
(.data-grid.variable-height-rows.odd-first-zebra-stripe table.data tr:nth-child(even)):
(.data-grid.variable-height-rows table.data tr.filler):
Updated styles to support variable height rows directly and flipping the order of the stripes
when the virtual table starts at an odd row.

* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid): Added rowHeight and rows.
(WebInspector.DataGrid.prototype.get inline): Added.
(WebInspector.DataGrid.prototype.set inline): Added.
(WebInspector.DataGrid.prototype.get variableHeightRows): Added.
(WebInspector.DataGrid.prototype.set variableHeightRows): Added.
(WebInspector.DataGrid.prototype.layout): Call _updateVisibleRows.
(WebInspector.DataGrid.prototype._noteRowsChanged): Added.
(WebInspector.DataGrid.prototype._updateVisibleRows): Added.
(WebInspector.DataGrid.prototype._sortNodesCallback): Update to not use the DOM.
(WebInspector.DataGridNode.prototype.set hasChildren): Call needsLayout.
(WebInspector.DataGridNode.prototype.collapse): Call needsLayout.
(WebInspector.DataGridNode.prototype.expand): Call needsLayout.
(WebInspector.DataGridNode.prototype._attach): Call _noteRowsChanged.
(WebInspector.DataGridNode.prototype._detach): Call _noteRowsChanged.

* UserInterface/Views/DatabaseUserQuerySuccessView.js:
(WebInspector.DatabaseUserQuerySuccessView):
Set inline to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.

* UserInterface/Views/DetailsSection.css:
(.details-section > .content .data-grid td.value-column):
(.details-section > .content .data-grid table.data): Deleted.
(.details-section > .content .data-grid tr:nth-child(even)): Deleted.
(.details-section > .content .data-grid tr:nth-child(odd)): Deleted.
Now handled by DataGrid.css directly.

* UserInterface/Views/DetailsSectionDataGridRow.js:
(WebInspector.DetailsSectionDataGridRow.prototype.set dataGrid):
Set inline and variableHeightRows to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.

* UserInterface/Views/HeapSnapshotInstancesContentView.css:
(.heap-snapshot > .data-grid tr:matches(.selected, :hover) td .go-to-arrow):
(.heap-snapshot .icon):
Remove margin-top to fit inside 20px row instead of 21px.

* UserInterface/Views/IndexedDatabaseObjectStoreContentView.css:
(.content-view.indexed-database-object-store > .data-grid table.data): Deleted.
(.content-view.indexed-database-object-store > .data-grid table.data tr:nth-child(even)): Deleted.
(.content-view.indexed-database-object-store > .data-grid table.data tr:nth-child(odd)): Deleted.
(.content-view.indexed-database-object-store > .data-grid table.data tr.filler): Deleted.
Now handled by DataGrid.css directly.

* UserInterface/Views/IndexedDatabaseObjectStoreContentView.js:
(WebInspector.IndexedDatabaseObjectStoreContentView):
Set variableHeightRows to true.

* UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
(WebInspector.LayerTreeDetailsSidebarPanel.prototype._buildDataGridSection):
Set inline to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.

* UserInterface/Views/LogContentView.css:
(.console-item .data-grid table.data): Deleted.
(.console-item .data-grid table.data tr:nth-child(even)): Deleted.
Now handled by DataGrid.css directly.

* UserInterface/Views/NetworkGridContentView.css:
(.content-view.network-grid > .data-grid td): Deleted.
(.content-view.network-grid > .data-grid table.data): Deleted.
Now handled by DataGrid.css directly.

* UserInterface/Views/ProbeSetDataGrid.js:
(WebInspector.ProbeSetDataGrid):
Set inline to true, remove direct classList add.

* UserInterface/Views/ProfileView.css:
(.profile > .data-grid td .icon):
(.profile > .data-grid tr:matches(.selected, :hover) .go-to-arrow):
Remove margin-top to fit inside 20px row instead of 21px.

* UserInterface/Views/TimelineRecordingContentView.css:
(.content-view.timeline-recording > .content-browser > .content-view-container > .timeline-view > .data-grid td): Deleted.
(.content-view.timeline-recording > .content-browser > .content-view-container > .timeline-view > .data-grid table.data): Deleted.
Now handled by DataGrid.css directly.

* UserInterface/Views/Variables.css:
(:root): Added zebra stripe colors.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (199746 => 199747)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-04-19 23:41:25 UTC (rev 199747)
@@ -1,3 +1,115 @@
+2016-04-18  Timothy Hatcher  <timo...@apple.com>
+
+        Web Inspector: DataGrid should be virtualized so it only renders visible rows
+
+        https://bugs.webkit.org/show_bug.cgi?id=156663
+        rdar://problem/25765256
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/ComputedStyleDetailsPanel.js:
+        (WebInspector.ComputedStyleDetailsPanel.prototype.set containerRegions):
+        Call updateLayoutIfNeeded since we don't use views here.
+
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WebInspector.ConsoleMessageView.prototype._formatParameterAsTable):
+        Set inline and variableHeightRows to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.
+
+        * UserInterface/Views/DOMTreeDataGrid.js:
+        (WebInspector.DOMTreeDataGrid):
+        Set inline to true, remove direct classList add.
+
+        * UserInterface/Views/DataGrid.css:
+        (.data-grid td):
+        (.data-grid table.data):
+        (.data-grid:not(.variable-height-rows) table.data):
+        (.data-grid:not(.variable-height-rows) table.data.odd-first-zebra-stripe):
+        (.data-grid.variable-height-rows table.data tr:nth-child(odd)):
+        (.data-grid.variable-height-rows table.data tr:nth-child(even)):
+        (.data-grid.variable-height-rows.odd-first-zebra-stripe table.data tr:nth-child(odd)):
+        (.data-grid.variable-height-rows.odd-first-zebra-stripe table.data tr:nth-child(even)):
+        (.data-grid.variable-height-rows table.data tr.filler):
+        Updated styles to support variable height rows directly and flipping the order of the stripes
+        when the virtual table starts at an odd row.
+
+        * UserInterface/Views/DataGrid.js:
+        (WebInspector.DataGrid): Added rowHeight and rows.
+        (WebInspector.DataGrid.prototype.get inline): Added.
+        (WebInspector.DataGrid.prototype.set inline): Added.
+        (WebInspector.DataGrid.prototype.get variableHeightRows): Added.
+        (WebInspector.DataGrid.prototype.set variableHeightRows): Added.
+        (WebInspector.DataGrid.prototype.layout): Call _updateVisibleRows.
+        (WebInspector.DataGrid.prototype._noteRowsChanged): Added.
+        (WebInspector.DataGrid.prototype._updateVisibleRows): Added.
+        (WebInspector.DataGrid.prototype._sortNodesCallback): Update to not use the DOM.
+        (WebInspector.DataGridNode.prototype.set hasChildren): Call needsLayout.
+        (WebInspector.DataGridNode.prototype.collapse): Call needsLayout.
+        (WebInspector.DataGridNode.prototype.expand): Call needsLayout.
+        (WebInspector.DataGridNode.prototype._attach): Call _noteRowsChanged.
+        (WebInspector.DataGridNode.prototype._detach): Call _noteRowsChanged.
+
+        * UserInterface/Views/DatabaseUserQuerySuccessView.js:
+        (WebInspector.DatabaseUserQuerySuccessView):
+        Set inline to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.
+
+        * UserInterface/Views/DetailsSection.css:
+        (.details-section > .content .data-grid td.value-column):
+        (.details-section > .content .data-grid table.data): Deleted.
+        (.details-section > .content .data-grid tr:nth-child(even)): Deleted.
+        (.details-section > .content .data-grid tr:nth-child(odd)): Deleted.
+        Now handled by DataGrid.css directly.
+
+        * UserInterface/Views/DetailsSectionDataGridRow.js:
+        (WebInspector.DetailsSectionDataGridRow.prototype.set dataGrid):
+        Set inline and variableHeightRows to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.
+
+        * UserInterface/Views/HeapSnapshotInstancesContentView.css:
+        (.heap-snapshot > .data-grid tr:matches(.selected, :hover) td .go-to-arrow):
+        (.heap-snapshot .icon):
+        Remove margin-top to fit inside 20px row instead of 21px.
+
+        * UserInterface/Views/IndexedDatabaseObjectStoreContentView.css:
+        (.content-view.indexed-database-object-store > .data-grid table.data): Deleted.
+        (.content-view.indexed-database-object-store > .data-grid table.data tr:nth-child(even)): Deleted.
+        (.content-view.indexed-database-object-store > .data-grid table.data tr:nth-child(odd)): Deleted.
+        (.content-view.indexed-database-object-store > .data-grid table.data tr.filler): Deleted.
+        Now handled by DataGrid.css directly.
+
+        * UserInterface/Views/IndexedDatabaseObjectStoreContentView.js:
+        (WebInspector.IndexedDatabaseObjectStoreContentView):
+        Set variableHeightRows to true.
+
+        * UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
+        (WebInspector.LayerTreeDetailsSidebarPanel.prototype._buildDataGridSection):
+        Set inline to true, remove direct classList add. Call updateLayoutIfNeeded since we don't use views here.
+
+        * UserInterface/Views/LogContentView.css:
+        (.console-item .data-grid table.data): Deleted.
+        (.console-item .data-grid table.data tr:nth-child(even)): Deleted.
+        Now handled by DataGrid.css directly.
+
+        * UserInterface/Views/NetworkGridContentView.css:
+        (.content-view.network-grid > .data-grid td): Deleted.
+        (.content-view.network-grid > .data-grid table.data): Deleted.
+        Now handled by DataGrid.css directly.
+
+        * UserInterface/Views/ProbeSetDataGrid.js:
+        (WebInspector.ProbeSetDataGrid):
+        Set inline to true, remove direct classList add.
+
+        * UserInterface/Views/ProfileView.css:
+        (.profile > .data-grid td .icon):
+        (.profile > .data-grid tr:matches(.selected, :hover) .go-to-arrow):
+        Remove margin-top to fit inside 20px row instead of 21px.
+
+        * UserInterface/Views/TimelineRecordingContentView.css:
+        (.content-view.timeline-recording > .content-browser > .content-view-container > .timeline-view > .data-grid td): Deleted.
+        (.content-view.timeline-recording > .content-browser > .content-view-container > .timeline-view > .data-grid table.data): Deleted.
+        Now handled by DataGrid.css directly.
+
+        * UserInterface/Views/Variables.css:
+        (:root): Added zebra stripe colors.
+
 2016-04-19  Joseph Pecoraro  <pecor...@apple.com>
 
         REGRESSION (r199635) Web Inspector: Percentages in Heap Allocations view are too large

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleDetailsPanel.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleDetailsPanel.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleDetailsPanel.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -147,6 +147,8 @@
             this._containerRegionsDataGrid.appendChild(new WebInspector.DOMTreeDataGridNode(regionNode));
 
         this._containerRegionsFlowSection.element.classList.remove("hidden");
+
+        this._containerRegionsDataGrid.updateLayoutIfNeeded();
     }
 
     cssStyleDeclarationTextEditorShowProperty(property, showSource)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -804,9 +804,13 @@
         // FIXME: Should we output something extra if the preview is lossless?
 
         var dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, flatValues);
-        dataGrid.element.classList.add("inline");
+        dataGrid.inline = true;
+        dataGrid.variableHeightRows = true;
+
         element.appendChild(dataGrid.element);
 
+        dataGrid.updateLayoutIfNeeded();
+
         return element;
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeDataGrid.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeDataGrid.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeDataGrid.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -34,8 +34,10 @@
 
         this._previousHoveredElement = null;
 
-        this.element.classList.add("inline", "dom-tree-data-grid");
+        this.inline = true;
 
+        this.element.classList.add("dom-tree-data-grid");
+
         this.element.addEventListener("mousemove", this._onmousemove.bind(this), false);
         this.element.addEventListener("mouseout", this._onmouseout.bind(this), false);
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -109,18 +109,23 @@
 }
 
 .data-grid table.data {
-    position: absolute;
+    position: relative;
     left: 0;
-    top: 0;
     right: 0;
-    bottom: 0;
     height: 100%;
     border-top: 0 none transparent;
-    background-image: linear-gradient(to bottom, white, white 50%, hsl(214, 41%, 96%) 50%, hsl(214, 41%, 96%));
-    background-size: 100% 42px;
     table-layout: fixed;
 }
 
+.data-grid:not(.variable-height-rows) table.data {
+    background-image: linear-gradient(to bottom, var(--even-zebra-stripe-row-background-color), var(--even-zebra-stripe-row-background-color) 50%, var(--odd-zebra-stripe-row-background-color) 50%, var(--odd-zebra-stripe-row-background-color));
+    background-size: 100% 40px;
+}
+
+.data-grid:not(.variable-height-rows) table.data.odd-first-zebra-stripe {
+    background-image: linear-gradient(to bottom, var(--odd-zebra-stripe-row-background-color), var(--odd-zebra-stripe-row-background-color) 50%, var(--even-zebra-stripe-row-background-color) 50%, var(--even-zebra-stripe-row-background-color));
+}
+
 .data-grid.inline table.data {
     position: static;
 }
@@ -133,10 +138,31 @@
     display: table-row;
 }
 
+.data-grid.variable-height-rows table.data tr:nth-child(odd) {
+    background-color: var(--odd-zebra-stripe-row-background-color);
+}
+
+.data-grid.variable-height-rows table.data tr:nth-child(even) {
+    background-color: var(--even-zebra-stripe-row-background-color);
+}
+
+.data-grid.variable-height-rows.odd-first-zebra-stripe table.data tr:nth-child(odd) {
+    background-color: var(--even-zebra-stripe-row-background-color);
+}
+
+.data-grid.variable-height-rows.odd-first-zebra-stripe table.data tr:nth-child(even) {
+    background-color: var(--odd-zebra-stripe-row-background-color);
+}
+
+.data-grid.variable-height-rows table.data tr.filler {
+ /* FIXME: This should show an alternating stripe, but it needs to know if the last row is even or odd. */
+    background-color: var(--even-zebra-stripe-row-background-color);
+}
+
 .data-grid td {
     vertical-align: top;
-    height: 12px;
-    line-height: 17px;
+    height: 16px;
+    line-height: 16px;
     padding: 2px 6px;
     white-space: nowrap;
     overflow: hidden;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -37,6 +37,8 @@
         this._sortOrder = WebInspector.DataGrid.SortOrder.Indeterminate;
         this._sortOrderSetting = null;
 
+        this._rows = [];
+
         this.children = [];
         this.selectedNode = null;
         this.expandNodesWhenArrowing = false;
@@ -47,6 +49,7 @@
         this.selected = false;
         this.dataGrid = this;
         this.indentWidth = 15;
+        this.rowHeight = 20;
         this.resizers = [];
         this._columnWidthsInitialized = false;
 
@@ -66,9 +69,15 @@
         this._scrollContainerElement = document.createElement("div");
         this._scrollContainerElement.className = "data-container";
 
-        this._dataTableElement = this._scrollContainerElement.createChild("table");
-        this._dataTableElement.className = "data";
+        this._scrollListener = () => this.needsLayout();
+        this._scrollContainerElement.addEventListener("scroll", this._scrollListener);
 
+        this._topDataTableMarginElement = this._scrollContainerElement.createChild("div");
+
+        this._dataTableElement = this._scrollContainerElement.createChild("table", "data");
+
+        this._bottomDataTableMarginElement = this._scrollContainerElement.createChild("div");
+
         this._dataTableElement.addEventListener("mousedown", this._mouseDownInDataTable.bind(this));
         this._dataTableElement.addEventListener("click", this._clickInDataTable.bind(this));
         this._dataTableElement.addEventListener("contextmenu", this._contextMenuInDataTable.bind(this), true);
@@ -79,6 +88,7 @@
             this._dataTableElement.addEventListener("dblclick", this._ondblclick.bind(this), false);
             this._editCallback = editCallback;
         }
+
         if (deleteCallback)
             this._deleteCallback = deleteCallback;
 
@@ -87,9 +97,9 @@
 
         // This element is used by DataGridNodes to manipulate table rows and cells.
         this.dataTableBodyElement = this._dataTableElement.createChild("tbody");
-        this._fillerRowElement = this.dataTableBodyElement.createChild("tr");
-        this._fillerRowElement.className = "filler";
 
+        this._fillerRowElement = this.dataTableBodyElement.createChild("tr", "filler");
+
         this.element.appendChild(this._headerTableElement);
         this.element.appendChild(this._scrollContainerElement);
 
@@ -237,6 +247,40 @@
             this.sortColumnIdentifier = this._sortColumnIdentifierSetting.value;
     }
 
+    get inline() { return this._inline; }
+
+    set inline(x)
+    {
+        if (this._inline === x)
+            return;
+
+        this._inline = x || false;
+
+        this._element.classList.toggle("inline", this._inline);
+
+        if (this._inline || this._variableHeightRows)
+            this._scrollContainerElement.removeEventListener("scroll", this._scrollListener);
+        else
+            this._scrollContainerElement.addEventListener("scroll", this._scrollListener);
+    }
+
+    get variableHeightRows() { return this._variableHeightRows; }
+
+    set variableHeightRows(x)
+    {
+        if (this._variableHeightRows === x)
+            return;
+
+        this._variableHeightRows = x || false;
+
+        this._element.classList.toggle("variable-height-rows", this._variableHeightRows);
+
+        if (this._inline || this._variableHeightRows)
+            this._scrollContainerElement.removeEventListener("scroll", this._scrollListener);
+        else
+            this._scrollContainerElement.addEventListener("scroll", this._scrollListener);
+    }
+
     _updateSortedColumn(oldSortColumnIdentifier)
     {
         if (this._sortColumnIdentifierSetting)
@@ -506,11 +550,9 @@
         if (column["collapsesGroup"]) {
             console.assert(column["group"] !== column["collapsesGroup"]);
 
-            var dividerElement = headerCellElement.createChild("div");
-            dividerElement.className = "divider";
+            var dividerElement = headerCellElement.createChild("div", "divider");
 
-            var collapseDiv = headerCellElement.createChild("div");
-            collapseDiv.className = "collapser-button";
+            var collapseDiv = headerCellElement.createChild("div", "collapser-button");
             collapseDiv.title = this._collapserButtonCollapseColumnsToolTip();
             listeners.register(collapseDiv, "mouseover", this._mouseoverColumnCollapser);
             listeners.register(collapseDiv, "mouseout", this._mouseoutColumnCollapser);
@@ -638,6 +680,8 @@
             this._positionResizerElements();
             this._positionHeaderViews();
         }
+
+        this._updateVisibleRows();
     }
 
     columnWidthsMap()
@@ -791,6 +835,81 @@
         }
     }
 
+    _noteRowsChanged()
+    {
+        this._previousRevealedRowCount = NaN;
+
+        this.needsLayout();
+    }
+
+    _updateVisibleRows()
+    {
+        if (this._inline || this._variableHeightRows) {
+            // Inline DataGrids always show all their rows, so we can't virtualize them.
+            // In general, inline DataGrids usually have a small number of rows.
+
+            // FIXME: This is a slow path for variable height rows that is similar to the old
+            // non-virtualized DataGrid. Ideally we would track row height per-DataGridNode
+            // and then we could virtualize even those cases. Currently variable height row
+            // DataGrids don't usually have many rows, other than IndexedDB.
+
+            let nextElement = this.dataTableBodyElement.lastChild;
+            for (let i = this._rows.length - 1; i >= 0; --i) {
+                let rowElement = this._rows[i].element;
+                if (rowElement.nextSibling !== nextElement)
+                    this.dataTableBodyElement.insertBefore(rowElement, nextElement);
+                nextElement = rowElement;
+            }
+
+            return;
+        }
+
+        let rowHeight = this.rowHeight;
+        let updateOffsetThreshold = rowHeight * 5;
+
+        let revealedRows = this._rows.filter((row) => row.revealed);
+
+        let scrollTop = this._scrollContainerElement.scrollTop;
+        let scrollHeight = this._scrollContainerElement.offsetHeight;
+
+        let currentTopMargin = this._topDataTableMarginElement.offsetHeight;
+        let currentBottomMargin = this._bottomDataTableMarginElement.offsetHeight;
+        let currentTableBottom = currentTopMargin + this._dataTableElement.offsetHeight;
+
+        let belowTopThreshold = !currentTopMargin || scrollTop > currentTopMargin + updateOffsetThreshold;
+        let aboveBottomThreshold = !currentBottomMargin || scrollTop + scrollHeight < currentTableBottom - updateOffsetThreshold;
+
+        if (belowTopThreshold && aboveBottomThreshold && this._previousRevealedRowCount === revealedRows.length)
+            return;
+
+        this._previousRevealedRowCount = revealedRows.length;
+
+        let overflowPadding = updateOffsetThreshold * 3;
+
+        let topHiddenRowCount = Math.max(0, Math.floor((scrollTop - overflowPadding) / rowHeight));
+        let visibleRowCount = Math.ceil((scrollHeight + (overflowPadding * 2)) / rowHeight);
+        let bottomHiddenRowCount = Math.max(0, revealedRows.length - topHiddenRowCount - visibleRowCount);
+
+        let marginTop = topHiddenRowCount * rowHeight;
+        let marginBottom = bottomHiddenRowCount * rowHeight;
+
+        this._topDataTableMarginElement.style.height = marginTop + "px";
+        this._bottomDataTableMarginElement.style.height = marginBottom + "px";
+
+        this._dataTableElement.classList.toggle("odd-first-zebra-stripe", !!(topHiddenRowCount % 2));
+
+        this.dataTableBodyElement.removeChildren();
+
+        for (let i = topHiddenRowCount; i < topHiddenRowCount + visibleRowCount; ++i) {
+            let rowDataGridNode = revealedRows[i];
+            if (!rowDataGridNode)
+                continue;
+            this.dataTableBodyElement.appendChild(rowDataGridNode.element);
+        }
+
+        this.dataTableBodyElement.appendChild(this._fillerRowElement);
+    }
+
     addPlaceholderNode()
     {
         if (this.placeholderNode)
@@ -938,10 +1057,10 @@
 
     _sortNodesCallback(comparator)
     {
-        function comparatorWrapper(aRow, bRow)
+        function comparatorWrapper(aNode, bNode)
         {
-            var aNode = aRow._dataGridNode;
-            var bNode = bRow._dataGridNode;
+            console.assert(!aNode.hasChildren, "This sort method can't be used with parent nodes, children will be displayed out of order.");
+            console.assert(!bNode.hasChildren, "This sort method can't be used with parent nodes, children will be displayed out of order.");
 
             if (aNode.isPlaceholderNode)
                 return 1;
@@ -959,29 +1078,23 @@
             return;
         }
 
-        var tbody = this.dataTableBodyElement;
-        var childNodes = tbody.childNodes;
-        var fillerRowElement = tbody.lastChild;
+        this._rows.sort(comparatorWrapper.bind(this));
+        this._noteRowsChanged();
 
-        var sortedRowElements = Array.prototype.slice.call(childNodes, 0, childNodes.length - 1);
-        sortedRowElements.sort(comparatorWrapper.bind(this));
-
-        tbody.removeChildren();
-
-        var previousSiblingNode = null;
-        for (var rowElement of sortedRowElements) {
-            var node = rowElement._dataGridNode;
+        let previousSiblingNode = null;
+        for (let node of this._rows) {
             node.previousSibling = previousSiblingNode;
             if (previousSiblingNode)
                 previousSiblingNode.nextSibling = node;
-            tbody.appendChild(rowElement);
             previousSiblingNode = node;
         }
 
         if (previousSiblingNode)
             previousSiblingNode.nextSibling = null;
 
-        tbody.appendChild(fillerRowElement); // We expect to find a filler row when attaching nodes.
+        // A sortable data grid might not be added to a view, so it needs its layout updated here.
+        if (!this.parentView)
+            this.updateLayoutIfNeeded();
     }
 
     _toggledSortOrder()
@@ -1625,16 +1738,12 @@
         if (!this._element)
             return;
 
-        if (this._hasChildren)
-        {
+        if (this._hasChildren) {
             this._element.classList.add("parent");
             if (this.expanded)
                 this._element.classList.add("expanded");
-        }
-        else
-        {
+        } else
             this._element.classList.remove("parent", "expanded");
-        }
     }
 
     get hasChildren()
@@ -1838,8 +1947,10 @@
 
         this.dispatchEventToListeners("collapsed");
 
-        if (this.dataGrid)
+        if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Event.CollapsedNode, {dataGridNode: this});
+            this.dataGrid.needsLayout();
+        }
     }
 
     collapseRecursively()
@@ -1886,8 +1997,10 @@
 
         this.dispatchEventToListeners("expanded");
 
-        if (this.dataGrid)
+        if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Event.ExpandedNode, {dataGridNode: this});
+            this.dataGrid.needsLayout();
+        }
     }
 
     expandRecursively()
@@ -2055,27 +2168,28 @@
 
         this._attached = true;
 
-        var nextElement = null;
+        let insertionIndex = -1;
 
         if (!this.isPlaceholderNode) {
             var previousGridNode = this.traversePreviousNode(true, true);
-            if (previousGridNode && previousGridNode.element.parentNode)
-                nextElement = previousGridNode.element.nextSibling;
-            else if (!previousGridNode)
-                nextElement = this.dataGrid.dataTableBodyElement.firstChild;
+            insertionIndex = this.dataGrid._rows.indexOf(previousGridNode);
+            if (insertionIndex === -1)
+                insertionIndex = 0;
+            else
+                insertionIndex++;
         }
 
-        // If there is no next grid node, then append before the last child since the last child is the filler row.
-        console.assert(this.dataGrid.dataTableBodyElement.lastChild.classList.contains("filler"));
+        if (insertionIndex === -1)
+            this.dataGrid._rows.push(this);
+        else
+            this.dataGrid._rows.insertAtIndex(this, insertionIndex);
 
-        if (!nextElement)
-            nextElement = this.dataGrid.dataTableBodyElement.lastChild;
+        this.dataGrid._noteRowsChanged();
 
-        this.dataGrid.dataTableBodyElement.insertBefore(this.element, nextElement);
-
-        if (this.expanded)
+        if (this.expanded) {
             for (var i = 0; i < this.children.length; ++i)
                 this.children[i]._attach();
+        }
     }
 
     _detach()
@@ -2085,8 +2199,8 @@
 
         this._attached = false;
 
-        if (this._element && this._element.parentNode)
-            this._element.parentNode.removeChild(this._element);
+        this.dataGrid._rows.remove(this, true);
+        this.dataGrid._noteRowsChanged();
 
         for (var i = 0; i < this.children.length; ++i)
             this.children[i]._detach();

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DatabaseUserQuerySuccessView.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DatabaseUserQuerySuccessView.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DatabaseUserQuerySuccessView.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -31,8 +31,11 @@
 
         this._dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, values);
         if (this._dataGrid) {
-            this._dataGrid.element.classList.add("inline");
+            this._dataGrid.inline = true;
+
             this.resultElement.appendChild(this._dataGrid.element);
+
+            this._dataGrid.updateLayoutIfNeeded();
         } else {
             this.resultElement.classList.add("no-results");
             this.resultElement.textContent = WebInspector.UIString("Query returned no results.");

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSection.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSection.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSection.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -262,22 +262,12 @@
     border-bottom: none;
 }
 
-.details-section > .content .data-grid table.data {
-    background-image: none;
-}
-
-.details-section > .content .data-grid tr:nth-child(even) {
-    background-color: white;
-}
-
-.details-section > .content .data-grid tr:nth-child(odd) {
-    background-color: hsl(214, 41%, 96%);
-}
-
 .details-section > .content .data-grid td.value-column {
     height: auto;
     line-height: initial;
     white-space: normal;
+    padding-top: 4px;
+    padding-bottom: 4px;
 }
 
 .details-section > .content .data-grid td.value-column > div {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSectionDataGridRow.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSectionDataGridRow.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DetailsSectionDataGridRow.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -49,10 +49,13 @@
         this._dataGrid = dataGrid || null;
 
         if (dataGrid) {
-            dataGrid.element.classList.add("inline");
+            dataGrid.inline = true;
+            dataGrid.variableHeightRows = true;
 
             this.hideEmptyMessage();
             this.element.appendChild(dataGrid.element);
+
+            dataGrid.updateLayoutIfNeeded();
         } else
             this.showEmptyMessage();
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -65,7 +65,6 @@
     position: relative;
     width: 16px;
     height: 16px;
-    margin-top: 1px;
     margin-left: 2px;
 }
 
@@ -78,7 +77,6 @@
     position: relative;
     width: 16px;
     height: 16px;
-    margin-top: 1px;
     margin-right: 4px;
     content: url(../Images/TypeUndefined.svg);
 }
@@ -122,8 +120,7 @@
 .heap-snapshot > .data-grid td .formatted-node-preview,
 .heap-snapshot > .data-grid td .object-preview {
     text-indent: 0; /* Do not inherit the DataGrid's indent. */
-    display: inline-block;
-    height: 16px;
+    line-height: initial;
 }
 
 .heap-snapshot-instance-popover-content > .title {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -31,23 +31,6 @@
     bottom: 0;
 }
 
-.content-view.indexed-database-object-store > .data-grid table.data {
-    background-image: none;
-}
-
-.content-view.indexed-database-object-store > .data-grid table.data tr:nth-child(even) {
-    background-color: white;
-}
-
-.content-view.indexed-database-object-store > .data-grid table.data tr:nth-child(odd) {
-    background-color: hsl(214, 41%, 96%);
-}
-
-.content-view.indexed-database-object-store > .data-grid table.data tr.filler {
- /* FIXME: This should show an alternating stripe, but I couldn't make it work. */
-    background-color: white;
-}
-
 .content-view.indexed-database-object-store > .data-grid tr.selected {
     background-color: hsl(210, 90%, 90%) !important;
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -68,6 +68,7 @@
         }
 
         this._dataGrid = new WebInspector.DataGrid(columnInfo);
+        this._dataGrid.variableHeightRows = true;
         this._dataGrid.scrollContainer.addEventListener("scroll", this._dataGridScrolled.bind(this));
         this.addSubview(this._dataGrid);
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -138,6 +138,7 @@
         columns.memory.width = "70px";
 
         this._dataGrid = new WebInspector.DataGrid(columns);
+        this._dataGrid.inline = true;
         this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SortChanged, this._sortDataGrid, this);
         this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SelectedNodeChanged, this._selectedDataGridNodeChanged, this);
 
@@ -145,7 +146,6 @@
         this.sortOrderSetting = new WebInspector.Setting("layer-tree-details-sidebar-panel-sort-order", WebInspector.DataGrid.SortOrder.Descending);
 
         var element = this._dataGrid.element;
-        element.classList.add("inline");
         element.addEventListener("focus", this._dataGridGainedFocus.bind(this), false);
         element.addEventListener("blur", this._dataGridLostFocus.bind(this), false);
         element.addEventListener("click", this._dataGridWasClicked.bind(this), false);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -117,15 +117,6 @@
     background-color: hsl(210, 90%, 90%) !important;
 }
 
-.console-item .data-grid table.data {
-    background-image: none;
-    background-color: white;
-}
-
-.console-item .data-grid table.data tr:nth-child(even) {
-    background-color: hsl(214, 41%, 96%);
-}
-
 .console-item .data-grid tr.selected {
     background-color: hsl(210, 0%, 90%) !important;
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -34,13 +34,3 @@
 .content-view.network-grid > .data-grid th {
     border-top: none;
 }
-
-.content-view.network-grid > .data-grid td {
-    height: 16px;
-    line-height: 16px;
-}
-
-.content-view.network-grid > .data-grid table.data {
-    background-image: linear-gradient(to bottom, white, white 50%, hsl(0, 0%, 95%) 50%, hsl(0, 0%, 95%));
-    background-size: 100% 40px;
-}

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProbeSetDataGrid.js (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ProbeSetDataGrid.js	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProbeSetDataGrid.js	2016-04-19 23:41:25 UTC (rev 199747)
@@ -40,7 +40,7 @@
 
         this.probeSet = probeSet;
 
-        this.element.classList.add("inline");
+        this.inline = true;
 
         this._frameNodes = new Map;
         this._lastUpdatedFrame = null;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProfileView.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ProfileView.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProfileView.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -39,7 +39,6 @@
     position: relative;
     width: 16px;
     height: 16px;
-    margin-top: 1px;
     margin-right: 3px;
 }
 
@@ -77,7 +76,6 @@
     position: relative;
     width: 16px;
     height: 16px;
-    margin-top: 1px;
     margin-left: 2px;
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -61,13 +61,3 @@
 .content-view.timeline-recording > .content-browser > .navigation-bar > .item.scope-bar.default-item-selected > .multiple .arrows {
     color: black;
 }
-
-.content-view.timeline-recording > .content-browser > .content-view-container > .timeline-view > .data-grid td {
-    height: 16px;
-    line-height: 16px;
-}
-
-.content-view.timeline-recording > .content-browser > .content-view-container > .timeline-view > .data-grid table.data {
-    background-image: linear-gradient(to bottom, white, white 50%, hsl(0, 0%, 95%) 50%, hsl(0, 0%, 95%));
-    background-size: 100% 40px;
-}

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Variables.css (199746 => 199747)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Variables.css	2016-04-19 23:36:20 UTC (rev 199746)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Variables.css	2016-04-19 23:41:25 UTC (rev 199747)
@@ -70,6 +70,9 @@
     --memory-extra-fill-color: hsl(211, 53%, 70%);
     --memory-extra-stroke-color: hsl(211, 53%, 55%);
 
+    --even-zebra-stripe-row-background-color: white;
+    --odd-zebra-stripe-row-background-color: hsl(0, 0%, 95%);
+
     --toolbar-height: 36px;
     --tab-bar-height: 24px;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to