Title: [295094] trunk
Revision
295094
Author
za...@apple.com
Date
2022-06-01 10:26:14 -0700 (Wed, 01 Jun 2022)

Log Message

Spacing after some posts is too large on Dead by Daylight forums
https://bugs.webkit.org/show_bug.cgi?id=241104
<rdar://88110302>

Reviewed by Antti Koivisto.

Do not cross containing block boundary while resolving fill-available. If the containing block does not specify the constraint value for the fill-available descendant, we should just return "can't resolve" instead of climbing the containing block tree and potentially hit the ICB as the first container with fixed height(width).

* LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height-expected.html: Added.
* LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height.html: Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::isOrthogonal):
(WebCore::RenderBox::computeIntrinsicLogicalContentHeightUsing const):

Canonical link: https://commits.webkit.org/251189@main

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height-expected.html (0 => 295094)


--- trunk/LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height-expected.html	2022-06-01 17:26:14 UTC (rev 295094)
@@ -0,0 +1,8 @@
+<style>
+div {
+  width: 100px;
+  height: 100px;
+  background-color: green;
+}
+</style>
+<div></div>

Added: trunk/LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height.html (0 => 295094)


--- trunk/LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/fill-available-with-no-specified-containing-block-height.html	2022-06-01 17:26:14 UTC (rev 295094)
@@ -0,0 +1,21 @@
+<style>
+.container {
+  width: 100px;
+  background-color: red;
+}
+
+.fill {
+  height: -webkit-fill-available;
+}
+
+.overflow-sibling {
+  width: 100px;
+  height: 100px;
+  background-color: green;
+}
+</style>
+<!-- PASS if no red -->
+<div class=container>
+  <div class=fill></div>
+  <div class=overflow-sibling></div>
+</div>

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (295093 => 295094)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2022-06-01 17:04:02 UTC (rev 295093)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2022-06-01 17:26:14 UTC (rev 295094)
@@ -3259,6 +3259,11 @@
     return std::nullopt;
 }
 
+static inline bool isOrthogonal(const RenderBox& renderer, const RenderElement& ancestor)
+{
+    return renderer.isHorizontalWritingMode() != ancestor.isHorizontalWritingMode();
+}
+
 std::optional<LayoutUnit> RenderBox::computeIntrinsicLogicalContentHeightUsing(Length logicalHeightLength, std::optional<LayoutUnit> intrinsicContentHeight, LayoutUnit borderAndPadding) const
 {
     // FIXME: The CSS sizing spec is considering changing what min-content/max-content should resolve to.
@@ -3266,10 +3271,33 @@
     if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent() || logicalHeightLength.isFitContent() || logicalHeightLength.isLegacyIntrinsic()) {
         if (intrinsicContentHeight)
             return adjustIntrinsicLogicalHeightForBoxSizing(intrinsicContentHeight.value());
-        return std::nullopt;
+        return { };
     }
-    if (logicalHeightLength.isFillAvailable())
-        return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadding) - borderAndPadding;
+    if (logicalHeightLength.isFillAvailable()) {
+        auto* containingBlock = this->containingBlock();
+
+        auto canResolveAvailableSpace = [&] {
+            // FIXME: We need to find a way to say: yes, the constraint value is set and we can resolve height against it.
+            // Until then, this is mostly just guesswork.
+            if (!containingBlock)
+                return false;
+            auto containingBlockHasSpecifiedSpace = [&] {
+                auto isOrthogonal = WebCore::isOrthogonal(*this, *containingBlock);
+                auto& style = containingBlock->style();
+                if ((!isOrthogonal && style.height().isSpecified()) || (isOrthogonal && style.width().isSpecified()))
+                    return true;
+                if (containingBlock->isOutOfFlowPositioned()) {
+                    if ((!isOrthogonal && !style.top().isAuto() && !style.bottom().isAuto()) || (isOrthogonal && !style.left().isAuto() && !style.right().isAuto()))
+                        return true;
+                }
+                return false;
+            };
+            return containingBlockHasSpecifiedSpace() || containingBlock->hasOverridingLogicalHeight();
+        };
+        if (canResolveAvailableSpace())
+            return containingBlock->availableLogicalHeight(ExcludeMarginBorderPadding) - borderAndPadding;
+        return { };
+    }
     ASSERT_NOT_REACHED();
     return 0_lu;
 }
@@ -3630,12 +3658,6 @@
     return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing(style().logicalHeight(), heightType), std::nullopt);
 }
 
-// FIXME: evaluate whether this should be a method of RenderObject instead.
-static inline bool isOrthogonal(const RenderObject& renderer, const RenderObject& ancestor)
-{
-    return renderer.isHorizontalWritingMode() != ancestor.isHorizontalWritingMode();
-}
-
 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogicalHeightType heightType) const
 {
     // We need to stop here, since we don't want to increase the height of the table
@@ -3819,7 +3841,7 @@
     if (!logicalLeft.isAuto() || !logicalRight.isAuto())
         return;
 
-    RenderObject* parent = child->parent();
+    auto* parent = child->parent();
     TextDirection parentDirection = parent->style().direction();
 
     // This method is using enclosingBox() which is wrong for absolutely
@@ -4256,7 +4278,7 @@
     if (!logicalTop.isAuto() || !logicalBottom.isAuto())
         return;
     
-    RenderObject* parent = child->parent();
+    auto* parent = child->parent();
 
     // The static positions from the child's layer are relative to the container block's coordinate space (which is determined
     // by the writing mode and text direction), meaning that for orthogonal flows the logical top of the child (which depends on
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to