diff --git a/Tests/LibWeb/Layout/expected/flex/flex-shorthand-flex-basis-zero-percent.txt b/Tests/LibWeb/Layout/expected/flex/flex-shorthand-flex-basis-zero-percent.txt new file mode 100644 index 0000000000..a225a4bfde --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex/flex-shorthand-flex-basis-zero-percent.txt @@ -0,0 +1,29 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x126 [BFC] children: not-inline + BlockContainer at (10,10) content-size 780x108 children: not-inline + Box at (11,11) content-size 500x52 flex-container(row) [FFC] children: not-inline + BlockContainer <(anonymous)> at (11,11) content-size 36.84375x52 flex-item [BFC] children: inline + line 0 width: 36.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 5, rect: [11,11 36.84375x17.46875] + "hello" + TextNode <#text> + Box at (48.84375,12) content-size 461.15625x50 flex-container(row) flex-item [FFC] children: not-inline + BlockContainer <(anonymous)> at (48.84375,12) content-size 55.359375x50 flex-item [BFC] children: inline + line 0 width: 55.359375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 7, rect: [48.84375,12 55.359375x17.46875] + "friends" + TextNode <#text> + BlockContainer <(anonymous)> at (10,64) content-size 780x0 children: inline + TextNode <#text> + Box at (11,65) content-size 500x52 flex-container(row) [FFC] children: not-inline + BlockContainer <(anonymous)> at (11,65) content-size 36.84375x52 flex-item [BFC] children: inline + line 0 width: 36.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 5, rect: [11,65 36.84375x17.46875] + "hello" + TextNode <#text> + Box at (48.84375,66) content-size 461.15625x50 flex-container(row) flex-item [FFC] children: not-inline + BlockContainer <(anonymous)> at (48.84375,66) content-size 55.359375x50 flex-item [BFC] children: inline + line 0 width: 55.359375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 7, rect: [48.84375,66 55.359375x17.46875] + "friends" + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/flex/flex-shorthand-flex-basis-zero-percent.html b/Tests/LibWeb/Layout/input/flex/flex-shorthand-flex-basis-zero-percent.html new file mode 100644 index 0000000000..c2743c97ff --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex/flex-shorthand-flex-basis-zero-percent.html @@ -0,0 +1,24 @@ + +
hello
friends
+
hello
friends
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index ee59ee62b8..6f9fc622d4 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5669,8 +5669,7 @@ ErrorOr> Parser::parse_flex_value(Vector cons case PropertyID::FlexGrow: { // NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%. // https://github.com/w3c/csswg-drafts/issues/5742 - // (flex-basis takes ``, not ``, so the 0 is a Length.) - auto flex_basis = TRY(LengthStyleValue::create(Length::make_px(0))); + auto flex_basis = TRY(PercentageStyleValue::create(Percentage(0))); auto one = TRY(NumberStyleValue::create(1)); return FlexStyleValue::create(*value, one, flex_basis); } @@ -5732,8 +5731,11 @@ ErrorOr> Parser::parse_flex_value(Vector cons flex_grow = TRY(property_initial_value(m_context.realm(), PropertyID::FlexGrow)); if (!flex_shrink) flex_shrink = TRY(property_initial_value(m_context.realm(), PropertyID::FlexShrink)); - if (!flex_basis) - flex_basis = TRY(property_initial_value(m_context.realm(), PropertyID::FlexBasis)); + if (!flex_basis) { + // NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%. + // https://github.com/w3c/csswg-drafts/issues/5742 + flex_basis = TRY(PercentageStyleValue::create(Percentage(0))); + } return FlexStyleValue::create(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull()); }