mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:07:35 +00:00
LibWeb: Set flex-basis
to 0%
when omitted from flex
shorthand
This doesn't match the spec, *but* matches what other engines do, and it turns out this is required for web compat. (It fixes the menu on MDN.)
This commit is contained in:
parent
dd2080c55f
commit
102b8d717f
3 changed files with 59 additions and 4 deletions
|
@ -0,0 +1,29 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (1,1) content-size 798x126 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (10,10) content-size 780x108 children: not-inline
|
||||||
|
Box <div.flex> 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 <div.item.one> 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 <div.flex> 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 <div.item.two> 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>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<!doctype html><style>
|
||||||
|
* { border: 1px solid black; }
|
||||||
|
html { background: white; }
|
||||||
|
.flex {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
background: pink;
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
|
.item {
|
||||||
|
display: flex;
|
||||||
|
background: orange;
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
.one {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.two {
|
||||||
|
flex: 1 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="flex">hello<div class="item one">friends</div></div>
|
||||||
|
<div class="flex">hello<div class="item two">friends</div></div>
|
|
@ -5669,8 +5669,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_value(Vector<ComponentValue> cons
|
||||||
case PropertyID::FlexGrow: {
|
case PropertyID::FlexGrow: {
|
||||||
// NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%.
|
// 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
|
// https://github.com/w3c/csswg-drafts/issues/5742
|
||||||
// (flex-basis takes `<length>`, not `<number>`, so the 0 is a Length.)
|
auto flex_basis = TRY(PercentageStyleValue::create(Percentage(0)));
|
||||||
auto flex_basis = TRY(LengthStyleValue::create(Length::make_px(0)));
|
|
||||||
auto one = TRY(NumberStyleValue::create(1));
|
auto one = TRY(NumberStyleValue::create(1));
|
||||||
return FlexStyleValue::create(*value, one, flex_basis);
|
return FlexStyleValue::create(*value, one, flex_basis);
|
||||||
}
|
}
|
||||||
|
@ -5732,8 +5731,11 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_value(Vector<ComponentValue> cons
|
||||||
flex_grow = TRY(property_initial_value(m_context.realm(), PropertyID::FlexGrow));
|
flex_grow = TRY(property_initial_value(m_context.realm(), PropertyID::FlexGrow));
|
||||||
if (!flex_shrink)
|
if (!flex_shrink)
|
||||||
flex_shrink = TRY(property_initial_value(m_context.realm(), PropertyID::FlexShrink));
|
flex_shrink = TRY(property_initial_value(m_context.realm(), PropertyID::FlexShrink));
|
||||||
if (!flex_basis)
|
if (!flex_basis) {
|
||||||
flex_basis = TRY(property_initial_value(m_context.realm(), PropertyID::FlexBasis));
|
// 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());
|
return FlexStyleValue::create(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue