Bladeren bron

LibWeb: Accept fit-content as a value for min-width and max-width

This starts working immediately in BFC thanks to calculate_inner_width
being used for width constraints. :^)
Andreas Kling 2 jaren geleden
bovenliggende
commit
8ba7bd1b67

+ 15 - 0
Tests/LibWeb/Layout/expected/block-and-inline/block-with-fit-content-width-constraints.txt

@@ -0,0 +1,15 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (1,1) content-size 798x56.9375 [BFC] children: not-inline
+    BlockContainer <body> at (10,10) content-size 780x38.9375 children: not-inline
+      BlockContainer <div.box> at (11,11) content-size 138.28125x17.46875 children: inline
+        line 0 width: 138.28125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+          frag 0 from TextNode start: 0, length: 18, rect: [11,11 138.28125x17.46875]
+            "Well hello friends"
+        TextNode <#text>
+      BlockContainer <div.box2> at (11,30.46875) content-size 138.28125x17.46875 children: inline
+        line 0 width: 138.28125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+          frag 0 from TextNode start: 0, length: 18, rect: [11,30.46875 138.28125x17.46875]
+            "Well hello friends"
+        TextNode <#text>
+      BlockContainer <(anonymous)> at (10,48.9375) content-size 780x0 children: inline
+        TextNode <#text>

+ 13 - 0
Tests/LibWeb/Layout/input/block-and-inline/block-with-fit-content-width-constraints.html

@@ -0,0 +1,13 @@
+<!doctype html><style>
+* { border: 1px solid black; }
+.box {
+    background: orange;
+    min-width: fit-content;
+    width: 10px;
+}
+.box2 {
+    background: pink;
+    max-width: fit-content;
+    width: 1000px;
+}
+</style><div class="box">Well hello friends</div><div class="box2">Well hello friends</div>

+ 2 - 0
Userland/Libraries/LibWeb/CSS/Properties.json

@@ -1235,6 +1235,7 @@
       "percentage [0,∞]"
     ],
     "valid-identifiers": [
+      "fit-content",
       "none"
     ],
     "quirks": [
@@ -1265,6 +1266,7 @@
     ],
     "valid-identifiers": [
       "auto",
+      "fit-content",
       "none"
     ],
     "quirks": [