Bladeren bron

LibWeb: Treat flex item's cyclic percentage cross size as auto

This fixes an issue where e.g `height: 100%` on a flex item whose
container has indefinite height was being resolved to 0. It now
correctly behaves the same as auto.
Andreas Kling 2 jaren geleden
bovenliggende
commit
1dc074fc18

+ 10 - 0
Tests/LibWeb/Layout/expected/flex-item-with-cyclic-percentage-height.txt

@@ -0,0 +1,10 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (1,1) content-size 798x39.46875 children: not-inline
+    BlockContainer <body> at (10,10) content-size 780x21.46875 children: not-inline
+      Box <div.flexrow> at (11,11) content-size 778x19.46875 flex-container(row) children: not-inline
+        Box <div.project> at (12,12) content-size 44.03125x17.46875 flex-container(column) flex-item children: not-inline
+          BlockContainer <(anonymous)> at (12,12) content-size 44.03125x17.46875 flex-item children: inline
+            line 0 width: 44.03125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+              frag 0 from TextNode start: 0, length: 6, rect: [12,12 44.03125x17.46875]
+                "pillow"
+            TextNode <#text>

+ 14 - 0
Tests/LibWeb/Layout/input/flex-item-with-cyclic-percentage-height.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html><html><head><style>
+    * {
+        border: 1px solid black;
+        font: 16px 'SerenitySans';
+    }
+    .project {
+        display: flex;
+        flex-direction: column;
+        height: 100%;
+    }
+    .flexrow {
+        display: flex;
+    }
+</style></head><body><div class="flexrow"><div class="project">pillow

+ 1 - 1
Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp

@@ -1103,7 +1103,7 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
         return;
     }
 
-    if (computed_cross_size(item.box).is_auto()) {
+    if (should_treat_cross_size_as_auto(item.box)) {
         // Item has automatic cross size, layout with "fit-content"
 
         CSSPixels fit_content_cross_size = 0;