Title: [272160] branches/safari-611-branch
Revision
272160
Author
[email protected]
Date
2021-02-01 12:11:51 -0800 (Mon, 01 Feb 2021)

Log Message

Cherry-pick r272054. rdar://problem/73838900

    [css-flexbox] REGRESSION(r266695): content inside a `<button>` inside a flex container has a height of `0` without a declared `min-height`
    https://bugs.webkit.org/show_bug.cgi?id=220946

    Reviewed by Zalan Bujtas.

    Source/WebCore:

    Test: css3/flexbox/percentage-descendants-of-skipped-flex-item.html

    r252620 added an optimization which saves layouts for flexbox containers' descendants with percentage heights.
    That optimization relies on a hash map of percentage height descendants that is filled in with calls to
    addPercentHeightDescendant().

    FlexibleBoxImpl's like RenderButton might wrap their children in anonymous blocks. Those anonymous blocks are
    skipped for percentage height calculations in RenderBox::computePercentageLogicalHeight() and thus
    addPercentHeightDescendant() is never called for them. This means that hasPercentageHeightDescendants() would
    always wrongly return false for a child of a <button> with a percentage height.

    * rendering/RenderFlexibleBox.cpp:
    (WebCore::RenderFlexibleBox::childHasPercentHeightDescendants const): Renamed from hasPercentHeightDescendants in
    order not to clash with RenderBlock method. It now also checks whether flex items skipped from percentage
    height calculations are the containing blocks of any percentage height descendant of the flex container
    (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
    (WebCore::RenderFlexibleBox::hasPercentHeightDescendants const): Deleted.
    * rendering/RenderFlexibleBox.h:

    LayoutTests:

    * css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html: Added.
    * css3/flexbox/percentage-descendants-of-skipped-flex-item.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/LayoutTests/ChangeLog (272159 => 272160)


--- branches/safari-611-branch/LayoutTests/ChangeLog	2021-02-01 20:11:48 UTC (rev 272159)
+++ branches/safari-611-branch/LayoutTests/ChangeLog	2021-02-01 20:11:51 UTC (rev 272160)
@@ -1,5 +1,52 @@
 2021-02-01  Alan Coon  <[email protected]>
 
+        Cherry-pick r272054. rdar://problem/73838900
+
+    [css-flexbox] REGRESSION(r266695): content inside a `<button>` inside a flex container has a height of `0` without a declared `min-height`
+    https://bugs.webkit.org/show_bug.cgi?id=220946
+    
+    Reviewed by Zalan Bujtas.
+    
+    Source/WebCore:
+    
+    Test: css3/flexbox/percentage-descendants-of-skipped-flex-item.html
+    
+    r252620 added an optimization which saves layouts for flexbox containers' descendants with percentage heights.
+    That optimization relies on a hash map of percentage height descendants that is filled in with calls to
+    addPercentHeightDescendant().
+    
+    FlexibleBoxImpl's like RenderButton might wrap their children in anonymous blocks. Those anonymous blocks are
+    skipped for percentage height calculations in RenderBox::computePercentageLogicalHeight() and thus
+    addPercentHeightDescendant() is never called for them. This means that hasPercentageHeightDescendants() would
+    always wrongly return false for a child of a <button> with a percentage height.
+    
+    * rendering/RenderFlexibleBox.cpp:
+    (WebCore::RenderFlexibleBox::childHasPercentHeightDescendants const): Renamed from hasPercentHeightDescendants in
+    order not to clash with RenderBlock method. It now also checks whether flex items skipped from percentage
+    height calculations are the containing blocks of any percentage height descendant of the flex container
+    (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+    (WebCore::RenderFlexibleBox::hasPercentHeightDescendants const): Deleted.
+    * rendering/RenderFlexibleBox.h:
+    
+    LayoutTests:
+    
+    * css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html: Added.
+    * css3/flexbox/percentage-descendants-of-skipped-flex-item.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272054 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-28  Sergio Villar Senin  <[email protected]>
+
+            [css-flexbox] REGRESSION(r266695): content inside a `<button>` inside a flex container has a height of `0` without a declared `min-height`
+            https://bugs.webkit.org/show_bug.cgi?id=220946
+
+            Reviewed by Zalan Bujtas.
+
+            * css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html: Added.
+            * css3/flexbox/percentage-descendants-of-skipped-flex-item.html: Added.
+
+2021-02-01  Alan Coon  <[email protected]>
+
         Cherry-pick r272043. rdar://problem/73838798
 
     [ Big Sur ] media/media-source/media-source-webm-init-inside-segment.html is failing

Added: branches/safari-611-branch/LayoutTests/css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html (0 => 272160)


--- branches/safari-611-branch/LayoutTests/css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html	                        (rev 0)
+++ branches/safari-611-branch/LayoutTests/css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html	2021-02-01 20:11:51 UTC (rev 272160)
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<button style="width: 200px; height: 100px;">
+    <div style="width: 200px; height: 100%; background-color: green;"></div>
+</button>

Added: branches/safari-611-branch/LayoutTests/css3/flexbox/percentage-descendants-of-skipped-flex-item.html (0 => 272160)


--- branches/safari-611-branch/LayoutTests/css3/flexbox/percentage-descendants-of-skipped-flex-item.html	                        (rev 0)
+++ branches/safari-611-branch/LayoutTests/css3/flexbox/percentage-descendants-of-skipped-flex-item.html	2021-02-01 20:11:51 UTC (rev 272160)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link href="" rel="stylesheet">
+<style>
+.flexbox {
+    width: 200px;
+    height: 200px;
+}
+</style>
+<div class="flexbox column">
+    <div style="height: 50%;">
+        <button style="width: 200px; height: 100%;">
+            <div style="width: 200px; height: 100%; background-color: green;"></div>
+        </button>
+    </div>
+</div>

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (272159 => 272160)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-01 20:11:48 UTC (rev 272159)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-01 20:11:51 UTC (rev 272160)
@@ -1,5 +1,68 @@
 2021-02-01  Alan Coon  <[email protected]>
 
+        Cherry-pick r272054. rdar://problem/73838900
+
+    [css-flexbox] REGRESSION(r266695): content inside a `<button>` inside a flex container has a height of `0` without a declared `min-height`
+    https://bugs.webkit.org/show_bug.cgi?id=220946
+    
+    Reviewed by Zalan Bujtas.
+    
+    Source/WebCore:
+    
+    Test: css3/flexbox/percentage-descendants-of-skipped-flex-item.html
+    
+    r252620 added an optimization which saves layouts for flexbox containers' descendants with percentage heights.
+    That optimization relies on a hash map of percentage height descendants that is filled in with calls to
+    addPercentHeightDescendant().
+    
+    FlexibleBoxImpl's like RenderButton might wrap their children in anonymous blocks. Those anonymous blocks are
+    skipped for percentage height calculations in RenderBox::computePercentageLogicalHeight() and thus
+    addPercentHeightDescendant() is never called for them. This means that hasPercentageHeightDescendants() would
+    always wrongly return false for a child of a <button> with a percentage height.
+    
+    * rendering/RenderFlexibleBox.cpp:
+    (WebCore::RenderFlexibleBox::childHasPercentHeightDescendants const): Renamed from hasPercentHeightDescendants in
+    order not to clash with RenderBlock method. It now also checks whether flex items skipped from percentage
+    height calculations are the containing blocks of any percentage height descendant of the flex container
+    (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+    (WebCore::RenderFlexibleBox::hasPercentHeightDescendants const): Deleted.
+    * rendering/RenderFlexibleBox.h:
+    
+    LayoutTests:
+    
+    * css3/flexbox/percentage-descendants-of-skipped-flex-item-expected.html: Added.
+    * css3/flexbox/percentage-descendants-of-skipped-flex-item.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272054 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-28  Sergio Villar Senin  <[email protected]>
+
+            [css-flexbox] REGRESSION(r266695): content inside a `<button>` inside a flex container has a height of `0` without a declared `min-height`
+            https://bugs.webkit.org/show_bug.cgi?id=220946
+
+            Reviewed by Zalan Bujtas.
+
+            Test: css3/flexbox/percentage-descendants-of-skipped-flex-item.html
+
+            r252620 added an optimization which saves layouts for flexbox containers' descendants with percentage heights.
+            That optimization relies on a hash map of percentage height descendants that is filled in with calls to
+            addPercentHeightDescendant().
+
+            FlexibleBoxImpl's like RenderButton might wrap their children in anonymous blocks. Those anonymous blocks are
+            skipped for percentage height calculations in RenderBox::computePercentageLogicalHeight() and thus
+            addPercentHeightDescendant() is never called for them. This means that hasPercentageHeightDescendants() would
+            always wrongly return false for a child of a <button> with a percentage height.
+
+            * rendering/RenderFlexibleBox.cpp:
+            (WebCore::RenderFlexibleBox::childHasPercentHeightDescendants const): Renamed from hasPercentHeightDescendants in
+            order not to clash with RenderBlock method. It now also checks whether flex items skipped from percentage
+            height calculations are the containing blocks of any percentage height descendant of the flex container
+            (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+            (WebCore::RenderFlexibleBox::hasPercentHeightDescendants const): Deleted.
+            * rendering/RenderFlexibleBox.h:
+
+2021-02-01  Alan Coon  <[email protected]>
+
         Cherry-pick r272043. rdar://problem/73838798
 
     [ Big Sur ] media/media-source/media-source-webm-init-inside-segment.html is failing

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


--- branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-02-01 20:11:48 UTC (rev 272159)
+++ branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-02-01 20:11:51 UTC (rev 272160)
@@ -1623,12 +1623,26 @@
     return child.style().overflowX();
 }
 
-bool RenderFlexibleBox::hasPercentHeightDescendants(const RenderBox& renderer) const
+bool RenderFlexibleBox::childHasPercentHeightDescendants(const RenderBox& renderer) const
 {
-    // FIXME: This function can be removed soon after webkit.org/b/204318 is fixed. 
+    // FIXME: This function can be removed soon after webkit.org/b/204318 is fixed. Evaluate whether the
+    // skipContainingBlockForPercentHeightCalculation() check below should be moved to the caller in that case.
     if (!is<RenderBlock>(renderer))
         return false;
     auto& renderBlock = downcast<RenderBlock>(renderer);
+
+    // FlexibleBoxImpl's like RenderButton might wrap their children in anonymous blocks. Those anonymous blocks are
+    // skipped for percentage height calculations in RenderBox::computePercentageLogicalHeight() and thus
+    // addPercentHeightDescendant() is never called for them. This means that this method would always wrongly
+    // return false for a child of a <button> with a percentage height.
+    if (hasPercentHeightDescendants() && skipContainingBlockForPercentHeightCalculation(renderer, isHorizontalWritingMode() != renderer.isHorizontalWritingMode())) {
+        auto& descendants = *percentHeightDescendants();
+        for (auto* descendant : descendants) {
+            if (renderBlock.isContainingBlockAncestorFor(*descendant))
+                return true;
+        }
+    }
+
     if (!renderBlock.hasPercentHeightDescendants())
         return false;
 
@@ -1686,7 +1700,7 @@
         // We may have already forced relayout for orthogonal flowing children in
         // computeInnerFlexBaseSizeForChild.
         bool forceChildRelayout = relayoutChildren && !m_relaidOutChildren.contains(&child);
-        if (!forceChildRelayout && hasPercentHeightDescendants(child)) {
+        if (!forceChildRelayout && childHasPercentHeightDescendants(child)) {
             // Have to force another relayout even though the child is sized
             // correctly, because its descendants are not sized correctly yet. Our
             // previous layout of the child was done without an override height set.

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


--- branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.h	2021-02-01 20:11:48 UTC (rev 272159)
+++ branches/safari-611-branch/Source/WebCore/rendering/RenderFlexibleBox.h	2021-02-01 20:11:51 UTC (rev 272160)
@@ -191,7 +191,7 @@
     void appendChildFrameRects(ChildFrameRects&);
     void repaintChildrenDuringLayoutIfMoved(const ChildFrameRects&);
 
-    bool hasPercentHeightDescendants(const RenderBox&) const;
+    bool childHasPercentHeightDescendants(const RenderBox&) const;
 
     enum class GapType { BetweenLines, BetweenItems };
     LayoutUnit computeGap(GapType) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to