Title: [200949] trunk/Source/WebInspectorUI
Revision
200949
Author
[email protected]
Date
2016-05-16 11:04:25 -0700 (Mon, 16 May 2016)

Log Message

Web Inspector: DataGrid _updateVisibleRows dominates profiles of timeline recordings when data grid (Overview or TimelineDataGrids) is showing
https://bugs.webkit.org/show_bug.cgi?id=157664
rdar://problem/26262219

Reviewed by Joseph Pecoraro.

* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid): Added new members.
(WebInspector.DataGrid.prototype.layout): Reset _cachedScrollTop and _cachedScrollHeight on resize.
(WebInspector.DataGrid.prototype._noteScrollPositionChanged): Added.
(WebInspector.DataGrid.prototype._updateVisibleRows): Cache sizes and positions when possible.
(WebInspector.DataGridNode.prototype.set hidden): Added call to _noteRowsChanged.
(WebInspector.DataGridNode.prototype.collapse): Call _noteRowsChanged instead of needsLayout.
(WebInspector.DataGridNode.prototype.expand): Call _noteRowsChanged instead of needsLayout.
(WebInspector.DataGrid.prototype._updateFilter): Removed direct call to _updateVisibleRows, this is
better handled by DataGridNode's hidden setter.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (200948 => 200949)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-05-16 17:47:08 UTC (rev 200948)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-05-16 18:04:25 UTC (rev 200949)
@@ -1,5 +1,24 @@
 2016-05-14  Timothy Hatcher  <[email protected]>
 
+        Web Inspector: DataGrid _updateVisibleRows dominates profiles of timeline recordings when data grid (Overview or TimelineDataGrids) is showing
+        https://bugs.webkit.org/show_bug.cgi?id=157664
+        rdar://problem/26262219
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/DataGrid.js:
+        (WebInspector.DataGrid): Added new members.
+        (WebInspector.DataGrid.prototype.layout): Reset _cachedScrollTop and _cachedScrollHeight on resize.
+        (WebInspector.DataGrid.prototype._noteScrollPositionChanged): Added.
+        (WebInspector.DataGrid.prototype._updateVisibleRows): Cache sizes and positions when possible.
+        (WebInspector.DataGridNode.prototype.set hidden): Added call to _noteRowsChanged.
+        (WebInspector.DataGridNode.prototype.collapse): Call _noteRowsChanged instead of needsLayout.
+        (WebInspector.DataGridNode.prototype.expand): Call _noteRowsChanged instead of needsLayout.
+        (WebInspector.DataGrid.prototype._updateFilter): Removed direct call to _updateVisibleRows, this is
+        better handled by DataGridNode's hidden setter.
+
+2016-05-14  Timothy Hatcher  <[email protected]>
+
         Web Inspector: Many DataGrid instances do not save/restore their scroll position
         https://bugs.webkit.org/show_bug.cgi?id=157709
         rdar://problem/26286090

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (200948 => 200949)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-05-16 17:47:08 UTC (rev 200948)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-05-16 18:04:25 UTC (rev 200949)
@@ -53,6 +53,12 @@
         this.resizers = [];
         this._columnWidthsInitialized = false;
 
+        this._cachedScrollTop = NaN;
+        this._cachedScrollableOffsetHeight = NaN;
+        this._previousRevealedRowCount = NaN;
+        this._topDataTableMarginHeight = NaN;
+        this._bottomDataTableMarginHeight = NaN;
+
         this._filterText = "";
         this._filterDelegate = null;
 
@@ -72,7 +78,7 @@
         this._scrollContainerElement = document.createElement("div");
         this._scrollContainerElement.className = "data-container";
 
-        this._scrollListener = () => this.needsLayout();
+        this._scrollListener = () => this._noteScrollPositionChanged();
         this._updateScrollListeners();
 
         this._topDataTableMarginElement = this._scrollContainerElement.createChild("div");
@@ -797,9 +803,12 @@
             firstUpdate = true;
         }
 
-        if (layoutReason == WebInspector.View.LayoutReason.Resize || firstUpdate) {
+        if (layoutReason === WebInspector.View.LayoutReason.Resize || firstUpdate) {
             this._positionResizerElements();
             this._positionHeaderViews();
+
+            this._cachedScrollTop = NaN;
+            this._cachedScrollableOffsetHeight = NaN;
         }
 
         this._updateVisibleRows();
@@ -963,6 +972,13 @@
         this.needsLayout();
     }
 
+    _noteScrollPositionChanged()
+    {
+        this._cachedScrollTop = NaN;
+
+        this.needsLayout();
+    }
+
     _updateVisibleRows()
     {
         if (this._inline || this._variableHeightRows) {
@@ -987,36 +1003,49 @@
 
         let rowHeight = this.rowHeight;
         let updateOffsetThreshold = rowHeight * 5;
+        let overflowPadding = updateOffsetThreshold * 3;
 
-        let revealedRows = this._rows.filter((row) => row.revealed && !row.hidden);
+        if (isNaN(this._cachedScrollTop))
+            this._cachedScrollTop = this._scrollContainerElement.scrollTop;
 
-        let scrollTop = this._scrollContainerElement.scrollTop;
-        let scrollHeight = this._scrollContainerElement.offsetHeight;
+        if (isNaN(this._cachedScrollableOffsetHeight))
+            this._cachedScrollableOffsetHeight = this._scrollContainerElement.offsetHeight;
 
-        let currentTopMargin = this._topDataTableMarginElement.offsetHeight;
-        let currentBottomMargin = this._bottomDataTableMarginElement.offsetHeight;
-        let currentTableBottom = currentTopMargin + this._dataTableElement.offsetHeight;
+        let scrollTop = this._cachedScrollTop;
+        let scrollableOffsetHeight = this._cachedScrollableOffsetHeight;
 
+        let visibleRowCount = Math.ceil((scrollableOffsetHeight + (overflowPadding * 2)) / rowHeight);
+
+        let currentTopMargin = this._topDataTableMarginHeight;
+        let currentBottomMargin = this._bottomDataTableMarginHeight;
+        let currentTableBottom = currentTopMargin + (visibleRowCount * rowHeight);
+
         let belowTopThreshold = !currentTopMargin || scrollTop > currentTopMargin + updateOffsetThreshold;
-        let aboveBottomThreshold = !currentBottomMargin || scrollTop + scrollHeight < currentTableBottom - updateOffsetThreshold;
+        let aboveBottomThreshold = !currentBottomMargin || scrollTop + scrollableOffsetHeight < currentTableBottom - updateOffsetThreshold;
 
-        if (belowTopThreshold && aboveBottomThreshold && this._previousRevealedRowCount === revealedRows.length)
+        if (belowTopThreshold && aboveBottomThreshold && !isNaN(this._previousRevealedRowCount))
             return;
 
+        let revealedRows = this._rows.filter((row) => row.revealed && !row.hidden);
+
         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 bottomHiddenRowCount = Math.max(0, this._previousRevealedRowCount - topHiddenRowCount - visibleRowCount);
 
         let marginTop = topHiddenRowCount * rowHeight;
         let marginBottom = bottomHiddenRowCount * rowHeight;
 
-        this._topDataTableMarginElement.style.height = marginTop + "px";
-        this._bottomDataTableMarginElement.style.height = marginBottom + "px";
+        if (this._topDataTableMarginHeight !== marginTop) {
+            this._topDataTableMarginHeight = marginTop;
+            this._topDataTableMarginElement.style.height = marginTop + "px";
+        }
 
+        if (this._bottomDataTableMarginElement !== marginBottom) {
+            this._bottomDataTableMarginHeight = marginBottom;
+            this._bottomDataTableMarginElement.style.height = marginBottom + "px";
+        }
+
         this._dataTableElement.classList.toggle("odd-first-zebra-stripe", !!(topHiddenRowCount % 2));
 
         this.dataTableBodyElement.removeChildren();
@@ -1723,7 +1752,6 @@
         if (!filterDidModifyNode)
             return;
 
-        this._updateVisibleRows();
         this.dispatchEventToListeners(WebInspector.DataGrid.Event.FilterDidChange);
     }
 };
@@ -1796,6 +1824,9 @@
         this._hidden = x;
         if (this._element)
             this._element.classList.toggle("hidden", this._hidden);
+
+        if (this.dataGrid)
+            this.dataGrid._noteRowsChanged();
     }
 
     get selectable()
@@ -2170,7 +2201,7 @@
 
         if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Event.CollapsedNode, {dataGridNode: this});
-            this.dataGrid.needsLayout();
+            this.dataGrid._noteRowsChanged();
         }
     }
 
@@ -2220,7 +2251,7 @@
 
         if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Event.ExpandedNode, {dataGridNode: this});
-            this.dataGrid.needsLayout();
+            this.dataGrid._noteRowsChanged();
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to