Title: [238203] trunk/Source/WebInspectorUI
Revision
238203
Author
mattba...@apple.com
Date
2018-11-14 14:54:18 -0800 (Wed, 14 Nov 2018)

Log Message

Web Inspector: Table should recalculate scrollable height when resized
https://bugs.webkit.org/show_bug.cgi?id=191328
<rdar://problem/45854412>

Reviewed by Devin Rousso.

* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.prototype._hideDetailView):
Force table columns to layout after hiding the detail view.

* UserInterface/Views/Table.js:
(WI.Table):
(WI.Table.prototype.showColumn):
Call `_resizeColumnsAndFiller` instead of `resize`. The latter also cleared
`_cachedWidth`, which isn't unnecessary since the width hasn't changed.

(WI.Table.prototype.layout):
previously `_resizeColumnsAndFiller` always occurred after `_updateVisibleRows`,
it was just a matter of whether the cached width and height were cleared first.
That now happens in `sizeDidChange`.

(WI.Table.prototype.sizeDidChange):
(WI.Table.prototype._updateVisibleRows):
(WI.Table.prototype.resize): Deleted.
Internally this cleared the cached width and height, which moved to `sizeDidChange`.
Externally this was used by NetworkTableContentView to force columns to
layout after hiding the details view. Calling `updateLayout` on the table
accomplishes the same thing using the standard View API.

(WI.Table.prototype._resizeColumnsAndFiller):
Only update the cached width, since the height will already have been
updated. The number of rows doesn't change during this method, so that
check was removed.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (238202 => 238203)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-11-14 22:39:25 UTC (rev 238202)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-11-14 22:54:18 UTC (rev 238203)
@@ -1,3 +1,39 @@
+2018-11-14  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: Table should recalculate scrollable height when resized
+        https://bugs.webkit.org/show_bug.cgi?id=191328
+        <rdar://problem/45854412>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/NetworkTableContentView.js:
+        (WI.NetworkTableContentView.prototype._hideDetailView):
+        Force table columns to layout after hiding the detail view.
+
+        * UserInterface/Views/Table.js:
+        (WI.Table):
+        (WI.Table.prototype.showColumn):
+        Call `_resizeColumnsAndFiller` instead of `resize`. The latter also cleared
+        `_cachedWidth`, which isn't unnecessary since the width hasn't changed.
+
+        (WI.Table.prototype.layout):
+        previously `_resizeColumnsAndFiller` always occurred after `_updateVisibleRows`,
+        it was just a matter of whether the cached width and height were cleared first.
+        That now happens in `sizeDidChange`.
+
+        (WI.Table.prototype.sizeDidChange):
+        (WI.Table.prototype._updateVisibleRows):
+        (WI.Table.prototype.resize): Deleted.
+        Internally this cleared the cached width and height, which moved to `sizeDidChange`.
+        Externally this was used by NetworkTableContentView to force columns to
+        layout after hiding the details view. Calling `updateLayout` on the table
+        accomplishes the same thing using the standard View API.
+
+        (WI.Table.prototype._resizeColumnsAndFiller):
+        Only update the cached width, since the height will already have been
+        updated. The number of rows doesn't change during this method, so that
+        check was removed.
+
 2018-11-14  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: REGRESSION(r236540): Debugger: breakpoints are sorted alphabetically instead of numerically

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js (238202 => 238203)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js	2018-11-14 22:39:25 UTC (rev 238202)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js	2018-11-14 22:54:18 UTC (rev 238203)
@@ -1297,7 +1297,7 @@
         this._detailView.hidden();
         this._detailView = null;
 
-        this._table.resize();
+        this._table.updateLayout(WI.View.LayoutReason.Resize);
         this._table.reloadVisibleColumnCells(this._waterfallColumn);
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Table.js (238202 => 238203)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Table.js	2018-11-14 22:39:25 UTC (rev 238202)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Table.js	2018-11-14 22:54:18 UTC (rev 238203)
@@ -109,7 +109,7 @@
         this._cachedWidth = NaN;
         this._cachedHeight = NaN;
         this._cachedScrollTop = NaN;
-        this._cachedScrollableHeight = NaN;
+        this._previousCachedWidth = NaN;
         this._previousRevealedRowCount = NaN;
         this._topSpacerHeight = NaN;
         this._bottomSpacerHeight = NaN;
@@ -244,14 +244,6 @@
         return this._selectedRows.has(rowIndex);
     }
 
-    resize()
-    {
-        this._cachedWidth = NaN;
-        this._cachedHeight = NaN;
-
-        this._resizeColumnsAndFiller();
-    }
-
     reloadData()
     {
         this._cachedRows.clear();
@@ -582,7 +574,7 @@
 
         // Re-layout all columns to make space.
         this._columnWidths = null;
-        this.resize();
+        this._resizeColumnsAndFiller();
 
         // Now populate only the new cells for this column.
         for (let cell of cellsToPopulate)
@@ -663,11 +655,16 @@
     layout()
     {
         this._updateVisibleRows();
+        this._resizeColumnsAndFiller();
+    }
 
-        if (this.layoutReason === WI.View.LayoutReason.Resize)
-            this.resize();
-        else
-            this._resizeColumnsAndFiller();
+    sizeDidChange()
+    {
+        super.sizeDidChange();
+
+        this._previousCachedWidth = this._cachedWidth;
+        this._cachedWidth = NaN;
+        this._cachedHeight = NaN;
     }
 
     // Resizer delegate
@@ -873,16 +870,9 @@
 
     _resizeColumnsAndFiller()
     {
-        let oldWidth = this._cachedWidth;
-        let oldHeight = this._cachedHeight;
-        let oldNumberOfRows = this._cachedNumberOfRows;
+        if (isNaN(this._cachedWidth) || !this._cachedWidth)
+            this._cachedWidth = Math.floor(this._scrollContainerElement.getBoundingClientRect().width);
 
-        if (isNaN(this._cachedWidth)) {
-            let boundingClientRect = this._scrollContainerElement.getBoundingClientRect();
-            this._cachedWidth = Math.floor(boundingClientRect.width);
-            this._cachedHeight = Math.floor(boundingClientRect.height);
-        }
-
         // Not visible yet.
         if (!this._cachedWidth)
             return;
@@ -890,19 +880,18 @@
         let availableWidth = this._cachedWidth;
         let availableHeight = this._cachedHeight;
 
-        let numberOfRows = this.numberOfRows;
-        this._cachedNumberOfRows = numberOfRows;
-
-        let contentHeight = numberOfRows * this._rowHeight;
+        let contentHeight = this.numberOfRows * this._rowHeight;
         this._fillerHeight = Math.max(availableHeight - contentHeight, 0);
 
         // No change to layout metrics so no resizing is needed.
-        if (this._columnWidths && availableWidth === oldWidth && availableWidth === oldHeight && numberOfRows === oldNumberOfRows) {
+        if (this._columnWidths && this._cachedWidth === this._previousCachedWidth) {
             this._updateFillerRowWithNewHeight();
             this._applyColumnWidthsToColumnsIfNeeded();
             return;
         }
 
+        this._previousCachedWidth = this._cachedWidth;
+
         let lockedWidth = 0;
         let lockedColumnCount = 0;
         let totalMinimumWidth = 0;
@@ -1094,11 +1083,11 @@
         if (isNaN(this._cachedScrollTop))
             this._cachedScrollTop = this._scrollContainerElement.scrollTop;
 
-        if (isNaN(this._cachedScrollableHeight) || !this._cachedScrollableHeight)
-            this._cachedScrollableHeight = this._scrollContainerElement.getBoundingClientRect().height;
+        if (isNaN(this._cachedHeight) || !this._cachedHeight)
+            this._cachedHeight = Math.floor(this._scrollContainerElement.getBoundingClientRect().height);
 
         let scrollTop = this._cachedScrollTop;
-        let scrollableOffsetHeight = this._cachedScrollableHeight;
+        let scrollableOffsetHeight = this._cachedHeight;
 
         let visibleRowCount = Math.ceil((scrollableOffsetHeight + (overflowPadding * 2)) / rowHeight);
         let currentTopMargin = this._topSpacerHeight;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to