Title: [273397] branches/safari-611-branch
Revision
273397
Author
repst...@apple.com
Date
2021-02-24 09:10:34 -0800 (Wed, 24 Feb 2021)

Log Message

Cherry-pick r273264. rdar://problem/74622873

    REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
    https://bugs.webkit.org/show_bug.cgi?id=222202
    <rdar://problem/74537782>

    Reviewed by Simon Fraser.

    PerformanceTests:

    New performance test for nested column flexboxes with percentage heights.

    * Layout/nested-column-flexboxes-relative-height.html: Added.

    Source/WebCore:

    The problem was that we were doing the initial layout for the children of the flex container twice in those cases where
    the child inline axis was not the main axis (for example with column flex containers in horizontal writing modes).
    Refactored the code (specially the way we clear overriding sizes) so that we only do it once. This saves tons of layouts
    in pages with nested column flexboxes with relative heights.

    No new tests as there is no change in functionality, we're removing duplicate extra layouts. We're however adding a new
    performance test for column flexboxes with percentage heights. With this patch we go from 3.5 layout/s to 145 layout/s
    which is ~4000% better.

    Inspired by Blink's crrev.com/c/1614058 by <cbiesin...@chromium.org>.

    * rendering/RenderFlexibleBox.cpp:
    (WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild): Do not unconditionally clear overriding sizes. Also removed
    relayoutChildren which is now unused. Do not layout the item, that should have been done in
    computeInnerFlexBaseSizeForChild() before. Added ASSERTs to verify that child's intrinsic main size was cached as
    a consequence of the previous layout.
    (WebCore::RenderFlexibleBox::constructFlexItem): Do not pass relayoutChildren to computeInnerFlexBaseSizeForChild. Also no
    need to update it after laying out the child.
    * rendering/RenderFlexibleBox.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273264 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/LayoutTests/TestExpectations (273396 => 273397)


--- branches/safari-611-branch/LayoutTests/TestExpectations	2021-02-24 17:10:31 UTC (rev 273396)
+++ branches/safari-611-branch/LayoutTests/TestExpectations	2021-02-24 17:10:34 UTC (rev 273397)
@@ -3920,7 +3920,7 @@
 
 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-012.html [ ImageOnlyFailure ]
 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-015.html [ ImageOnlyFailure ]
-webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-017.html [ ImageOnlyFailure ]
+webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-017.html [ Failure ]
 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-006.html [ ImageOnlyFailure ]
 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-007.html [ ImageOnlyFailure ]
 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-010.html [ ImageOnlyFailure ]

Modified: branches/safari-611-branch/PerformanceTests/ChangeLog (273396 => 273397)


--- branches/safari-611-branch/PerformanceTests/ChangeLog	2021-02-24 17:10:31 UTC (rev 273396)
+++ branches/safari-611-branch/PerformanceTests/ChangeLog	2021-02-24 17:10:34 UTC (rev 273397)
@@ -1,5 +1,57 @@
 2021-02-23  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r273264. rdar://problem/74622873
+
+    REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
+    https://bugs.webkit.org/show_bug.cgi?id=222202
+    <rdar://problem/74537782>
+    
+    Reviewed by Simon Fraser.
+    
+    PerformanceTests:
+    
+    New performance test for nested column flexboxes with percentage heights.
+    
+    * Layout/nested-column-flexboxes-relative-height.html: Added.
+    
+    Source/WebCore:
+    
+    The problem was that we were doing the initial layout for the children of the flex container twice in those cases where
+    the child inline axis was not the main axis (for example with column flex containers in horizontal writing modes).
+    Refactored the code (specially the way we clear overriding sizes) so that we only do it once. This saves tons of layouts
+    in pages with nested column flexboxes with relative heights.
+    
+    No new tests as there is no change in functionality, we're removing duplicate extra layouts. We're however adding a new
+    performance test for column flexboxes with percentage heights. With this patch we go from 3.5 layout/s to 145 layout/s
+    which is ~4000% better.
+    
+    Inspired by Blink's crrev.com/c/1614058 by <cbiesin...@chromium.org>.
+    
+    * rendering/RenderFlexibleBox.cpp:
+    (WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild): Do not unconditionally clear overriding sizes. Also removed
+    relayoutChildren which is now unused. Do not layout the item, that should have been done in
+    computeInnerFlexBaseSizeForChild() before. Added ASSERTs to verify that child's intrinsic main size was cached as
+    a consequence of the previous layout.
+    (WebCore::RenderFlexibleBox::constructFlexItem): Do not pass relayoutChildren to computeInnerFlexBaseSizeForChild. Also no
+    need to update it after laying out the child.
+    * rendering/RenderFlexibleBox.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-22  Sergio Villar Senin  <svil...@igalia.com>
+
+            REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
+            https://bugs.webkit.org/show_bug.cgi?id=222202
+            <rdar://problem/74537782>
+
+            Reviewed by Simon Fraser.
+
+            New performance test for nested column flexboxes with percentage heights.
+
+            * Layout/nested-column-flexboxes-relative-height.html: Added.
+
+2021-02-23  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r273122. rdar://problem/74623473
 
     MotionMark scores are super sensitive to a single long frame

Added: branches/safari-611-branch/PerformanceTests/Layout/nested-column-flexboxes-relative-height.html (0 => 273397)


--- branches/safari-611-branch/PerformanceTests/Layout/nested-column-flexboxes-relative-height.html	                        (rev 0)
+++ branches/safari-611-branch/PerformanceTests/Layout/nested-column-flexboxes-relative-height.html	2021-02-24 17:10:34 UTC (rev 273397)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<head>
+<style>
+.flex {
+    display: flex;
+    flex-direction: column;
+    height: 100%;
+}
+</style>
+<script src=""
+<script>
+function startTest() {
+    document.body.offsetHeight;
+
+    var index = 0;
+    PerfTestRunner.measureRunsPerSecond({run: function() {
+        document.body.style.width = ++index % 2 ? "99%" : "98%";
+        document.body.offsetHeight;
+    }});
+}
+</script>
+</head>
+<body _onload_="startTest()">
+<div class="flex">
+    <div class="flex">
+        <div class="flex">
+            <div class="flex">
+                <div class="flex">
+                    <div class="flex">
+                        <div class="flex">
+                            <div class="flex">
+                                <div class="flex">
+                                    <div class="flex">
+                                        <div class="flex"></div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</body>

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (273396 => 273397)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-24 17:10:31 UTC (rev 273396)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-24 17:10:34 UTC (rev 273397)
@@ -1,5 +1,73 @@
 2021-02-23  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r273264. rdar://problem/74622873
+
+    REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
+    https://bugs.webkit.org/show_bug.cgi?id=222202
+    <rdar://problem/74537782>
+    
+    Reviewed by Simon Fraser.
+    
+    PerformanceTests:
+    
+    New performance test for nested column flexboxes with percentage heights.
+    
+    * Layout/nested-column-flexboxes-relative-height.html: Added.
+    
+    Source/WebCore:
+    
+    The problem was that we were doing the initial layout for the children of the flex container twice in those cases where
+    the child inline axis was not the main axis (for example with column flex containers in horizontal writing modes).
+    Refactored the code (specially the way we clear overriding sizes) so that we only do it once. This saves tons of layouts
+    in pages with nested column flexboxes with relative heights.
+    
+    No new tests as there is no change in functionality, we're removing duplicate extra layouts. We're however adding a new
+    performance test for column flexboxes with percentage heights. With this patch we go from 3.5 layout/s to 145 layout/s
+    which is ~4000% better.
+    
+    Inspired by Blink's crrev.com/c/1614058 by <cbiesin...@chromium.org>.
+    
+    * rendering/RenderFlexibleBox.cpp:
+    (WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild): Do not unconditionally clear overriding sizes. Also removed
+    relayoutChildren which is now unused. Do not layout the item, that should have been done in
+    computeInnerFlexBaseSizeForChild() before. Added ASSERTs to verify that child's intrinsic main size was cached as
+    a consequence of the previous layout.
+    (WebCore::RenderFlexibleBox::constructFlexItem): Do not pass relayoutChildren to computeInnerFlexBaseSizeForChild. Also no
+    need to update it after laying out the child.
+    * rendering/RenderFlexibleBox.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-22  Sergio Villar Senin  <svil...@igalia.com>
+
+            REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
+            https://bugs.webkit.org/show_bug.cgi?id=222202
+            <rdar://problem/74537782>
+
+            Reviewed by Simon Fraser.
+
+            The problem was that we were doing the initial layout for the children of the flex container twice in those cases where
+            the child inline axis was not the main axis (for example with column flex containers in horizontal writing modes).
+            Refactored the code (specially the way we clear overriding sizes) so that we only do it once. This saves tons of layouts
+            in pages with nested column flexboxes with relative heights.
+
+            No new tests as there is no change in functionality, we're removing duplicate extra layouts. We're however adding a new
+            performance test for column flexboxes with percentage heights. With this patch we go from 3.5 layout/s to 145 layout/s
+            which is ~4000% better.
+
+            Inspired by Blink's crrev.com/c/1614058 by <cbiesin...@chromium.org>.
+
+            * rendering/RenderFlexibleBox.cpp:
+            (WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild): Do not unconditionally clear overriding sizes. Also removed
+            relayoutChildren which is now unused. Do not layout the item, that should have been done in
+            computeInnerFlexBaseSizeForChild() before. Added ASSERTs to verify that child's intrinsic main size was cached as
+            a consequence of the previous layout.
+            (WebCore::RenderFlexibleBox::constructFlexItem): Do not pass relayoutChildren to computeInnerFlexBaseSizeForChild. Also no
+            need to update it after laying out the child.
+            * rendering/RenderFlexibleBox.h:
+
+2021-02-23  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r273220. rdar://problem/74623537
 
     [Paint Timing] Return early from contentful paint check when no contentful pixels/characters at all

Modified: branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.cpp (273396 => 273397)


--- branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-02-24 17:10:31 UTC (rev 273396)
+++ branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-02-24 17:10:34 UTC (rev 273397)
@@ -863,10 +863,8 @@
 }
 
     
-LayoutUnit RenderFlexibleBox::computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding, bool relayoutChildren)
+LayoutUnit RenderFlexibleBox::computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding)
 {
-    child.clearOverridingContentSize();
-    
     Length flexBasis = flexBasisForChild(child);
     if (childMainSizeIsDefinite(child, flexBasis))
         return std::max(0_lu, computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis).value());
@@ -876,18 +874,11 @@
         return adjustChildSizeForAspectRatioCrossAxisMinAndMax(child, computeMainSizeFromAspectRatioUsing(child, crossSizeLength));
     }
 
-    // The flex basis is indefinite (=auto), so we need to compute the actual
-    // width of the child. For the logical width axis we just use the preferred
-    // width; for the height we need to lay out the child.
+    // The flex basis is indefinite (=auto), so we need to compute the actual width of the child.
     LayoutUnit mainAxisExtent;
     if (!mainAxisIsChildInlineAxis(child)) {
-        updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child);
-        if (child.needsLayout() || relayoutChildren || !m_intrinsicSizeAlongMainAxis.contains(&child)) {
-            if (!child.needsLayout())
-                child.setChildNeedsLayout(MarkOnlyThis);
-            child.layoutIfNeeded();
-            cacheChildMainSize(child);
-        }
+        ASSERT(!child.needsLayout());
+        ASSERT(m_intrinsicSizeAlongMainAxis.contains(&child));
         mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child);
     } else {
         // We don't need to add scrollbarLogicalWidth here because the preferred
@@ -1236,6 +1227,7 @@
 
 FlexItem RenderFlexibleBox::constructFlexItem(RenderBox& child, bool relayoutChildren)
 {
+    child.clearOverridingContentSize();
     if (childHasIntrinsicMainAxisSize(child)) {
         // If this condition is true, then computeMainAxisExtentForChild will call
         // child.intrinsicContentLogicalHeight() and child.scrollbarLogicalHeight(),
@@ -1254,13 +1246,12 @@
             child.setChildNeedsLayout(MarkOnlyThis);
             child.layoutIfNeeded();
             cacheChildMainSize(child);
-            relayoutChildren = false;
             child.clearOverridingContainingBlockContentSize();
         }
     }
     
     LayoutUnit borderAndPadding = isHorizontalFlow() ? child.horizontalBorderAndPaddingExtent() : child.verticalBorderAndPaddingExtent();
-    LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding, relayoutChildren);
+    LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding);
     LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(child, childInnerFlexBaseSize);
     LayoutUnit margin = isHorizontalFlow() ? child.horizontalMarginExtent() : child.verticalMarginExtent();
     return FlexItem(child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin);

Modified: branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.h (273396 => 273397)


--- branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.h	2021-02-24 17:10:31 UTC (rev 273396)
+++ branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.h	2021-02-24 17:10:34 UTC (rev 273397)
@@ -143,7 +143,7 @@
     bool useChildAspectRatio(const RenderBox& child) const;
     LayoutUnit computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const;
     void setFlowAwareLocationForChild(RenderBox& child, const LayoutPoint&);
-    LayoutUnit computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding, bool relayoutChildren);
+    LayoutUnit computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding);
     void adjustAlignmentForChild(RenderBox& child, LayoutUnit);
     ItemPosition alignmentForChild(const RenderBox& child) const;
     bool childMainSizeIsDefinite(const RenderBox&, const Length& flexBasis) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to