Title: [201140] branches/safari-602.1.32-branch/Source/WebInspectorUI
Revision
201140
Author
[email protected]
Date
2016-05-19 01:40:22 -0700 (Thu, 19 May 2016)

Log Message

Merge r200949. rdar://problem/26262219

Modified Paths

Diff

Modified: branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog (201139 => 201140)


--- branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog	2016-05-19 08:40:19 UTC (rev 201139)
+++ branches/safari-602.1.32-branch/Source/WebInspectorUI/ChangeLog	2016-05-19 08:40:22 UTC (rev 201140)
@@ -1,5 +1,28 @@
 2016-05-19  Babak Shafiei  <[email protected]>
 
+        Merge r200949. rdar://problem/26262219
+
+    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-19  Babak Shafiei  <[email protected]>
+
         Merge r200947. rdar://problem/26286090
 
     2016-05-14  Timothy Hatcher  <[email protected]>

Modified: branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (201139 => 201140)


--- branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-05-19 08:40:19 UTC (rev 201139)
+++ branches/safari-602.1.32-branch/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-05-19 08:40:22 UTC (rev 201140)
@@ -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()
@@ -2167,7 +2198,7 @@
 
         if (this.dataGrid) {
             this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Event.CollapsedNode, {dataGridNode: this});
-            this.dataGrid.needsLayout();
+            this.dataGrid._noteRowsChanged();
         }
     }
 
@@ -2217,7 +2248,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