mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
LibWeb: Don't use stretch-fit width for inline boxes with aspect ratio
This commit is contained in:
parent
1cfd8b3ac0
commit
ead341738e
|
@ -1,8 +1,8 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x33 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x17 children: inline
|
||||
frag 0 from Box start: 0, length: 0, rect: [8,8 784x17] baseline: 13.296875
|
||||
Box <div.inline-flex.aspect-ratio> at (8,8) content-size 784x17 flex-container(row) [FFC] children: not-inline
|
||||
frag 0 from Box start: 0, length: 0, rect: [8,8 10x10.3125] baseline: 13.296875
|
||||
Box <div.inline-flex.aspect-ratio> at (8,8) content-size 10x10.3125 flex-container(row) [FFC] children: not-inline
|
||||
BlockContainer <div.img-wrapper> at (8,8) content-size 10x17 flex-item [BFC] children: inline
|
||||
frag 0 from ImageBox start: 0, length: 0, rect: [8,11 10x10] baseline: 10
|
||||
ImageBox <img> at (8,11) content-size 10x10 children: not-inline
|
||||
|
@ -10,6 +10,6 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
|||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x33]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x17]
|
||||
PaintableBox (Box<DIV>.inline-flex.aspect-ratio) [8,8 784x17]
|
||||
PaintableBox (Box<DIV>.inline-flex.aspect-ratio) [8,8 10x10.3125] overflow: [8,8 10x17]
|
||||
PaintableWithLines (BlockContainer<DIV>.img-wrapper) [8,8 10x17]
|
||||
ImagePaintable (ImageBox<IMG>) [8,11 10x10]
|
||||
|
|
|
@ -1978,7 +1978,30 @@ bool box_is_sized_as_replaced_element(Box const& box)
|
|||
// replaced element with a natural aspect ratio and no natural size in that axis, see e.g. CSS2 §10
|
||||
// and CSS Flexible Box Model Level 1 §9.2.
|
||||
// https://www.w3.org/TR/css-sizing-4/#aspect-ratio-automatic
|
||||
return is<ReplacedBox>(box) || box.has_preferred_aspect_ratio();
|
||||
if (is<ReplacedBox>(box))
|
||||
return true;
|
||||
|
||||
if (box.has_preferred_aspect_ratio()) {
|
||||
// From CSS2:
|
||||
// If height and width both have computed values of auto and the element has an intrinsic ratio but no intrinsic height or width,
|
||||
// then the used value of width is undefined in CSS 2.
|
||||
// However, it is suggested that, if the containing block’s width does not itself depend on the replaced element’s width,
|
||||
// then the used value of width is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
|
||||
|
||||
// AD-HOC: For inline-level boxes, we don't want to end up in a situation where we apply stretch-fit sizing,
|
||||
// since that would not match other browsers. Because of that, we specifically reject this case here
|
||||
// instead of allowing it to proceed.
|
||||
if (box.display().is_inline_outside()
|
||||
&& box.computed_values().height().is_auto()
|
||||
&& box.computed_values().width().is_auto()
|
||||
&& !box.has_natural_width()
|
||||
&& !box.has_natural_height()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FormattingContext::should_treat_max_width_as_none(Box const& box, AvailableSize const& available_width) const
|
||||
|
|
Loading…
Reference in a new issue