Truly independent web browser
LibWeb: Size ratio-only images from available inline space
sideshowbarker2fe8080a3c1c
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rsindex 8d7f4771390..8b0132518be 100644--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs@@ -1332,8 +1332,9 @@ impl<'pass> FlexFormattingContext<'pass> {cells.content_block_size,)} else {- sizing.calculate_max_content_inline_size(+ sizing.calculate_max_content_inline_size_with_available_space(sizing_context::SizedBox::new(node, &self.flex_item_details[index].cells),+ self.available_space_for_items.unwrap().space.inline_size,constraints,)}diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 5fdab561e8b..68224ad0dcc 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -85,6 +85,7 @@ pub(crate) struct ReplacedIntrinsicSize {#[derive(Clone, Copy, Debug, Default)]pub(super) struct ReplacedMaxContentSizeLimits {pub(super) definite_size_in_ratio_determining_axis: Option<CssPixels>,+ pub(super) stretch_fit_inline_size: Option<CssPixels>,pub(super) minimum_inline_size: Option<CssPixels>,pub(super) minimum_block_size: Option<CssPixels>,}diff --git a/Libraries/LibWeb/Rust/src/layout/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rsindex cbbf0db79af..15619ada798 100644--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs@@ -1418,10 +1418,6 @@ impl<'pass> NodeFacts<'pass> {self.replaced_content().default_preferred_height}- pub(crate) fn initial_containing_block_inline_size(&self) -> crate::layout::CssPixels {- self.pass.initial_containing_block_inline_size- }-pub(crate) fn is_scroll_container(&self) -> bool {kind_and_style_make_scroll_container(self.data().kind.get(), self.computed_values_view_if_styled())}diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex 54039f6eebc..e6937e439c4 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -572,11 +572,6 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {// If it has a preferred aspect ratio:if facts.has_preferred_aspect_ratio() {if let Some(size) = constraints.definite_size_in_ratio_determining_axis {- // If the available space is definite in the inline axis, use the stretch fit into that size for the inline size- // and calculate the block size using the aspect ratio.- //- // NB: This helper is only for the max-content size, which has no definite available inline size. Callers may- // still know a definite used size in the opposite axis when the box lacks a natural size in that axis.return Some(if is_inline_axis {self.content_inline_size_from_aspect_ratio(sized, size)} else {@@ -584,6 +579,34 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {});}+ if is_inline_axis && let Some(height) = natural_size.height {+ let height = constraints+ .minimum_block_size+ .map_or(height, |minimum| height.max(minimum));+ let width = self.content_inline_size_from_aspect_ratio(sized, height);+ return Some(+ constraints+ .minimum_inline_size+ .map_or(width, |minimum| width.max(minimum)),+ );+ }++ // If the available space is definite in the inline axis, use the stretch fit into that size for the inline+ // size and calculate the block size using the aspect ratio.+ if let Some(inline_size) = constraints.stretch_fit_inline_size {+ let inline_size = constraints+ .minimum_inline_size+ .map_or(inline_size, |minimum| inline_size.max(minimum));+ let inline_size = constraints.minimum_block_size.map_or(inline_size, |minimum| {+ inline_size.max(self.content_inline_size_from_aspect_ratio(sized, minimum))+ });+ return Some(if is_inline_axis {+ inline_size+ } else {+ self.content_block_size_from_aspect_ratio(sized, inline_size)+ });+ }+let style = self.style(node);// Otherwise if the box has a <length> as its computed value for min-width or min-height, use that size and// calculate the other dimension using the aspect ratio; if both dimensions have a <length> minimum, choose the@@ -629,17 +652,23 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {(Some(inline), Some(block)) => Some(inline.max(block)),(Some(inline), None) => Some(inline),(None, Some(block)) => Some(block),- (None, None) => Some(if is_inline_axis {- // Otherwise use an inline size matching the corresponding dimension of the initial containing block and calculate- // the other dimension using the aspect ratio.+ (None, None) => {+ // Otherwise use an inline size matching the corresponding dimension of the initial containing block+ // and calculate the other dimension using the aspect ratio.//- // NOTE: This author-controllable behavior is made possible by the new auto value for the min size properties.- // This is believed to be a better behavior, but it is not yet clear if it is Web-compatible, so please- // send feedback to the CSSWG if there are any problems.- facts.initial_containing_block_inline_size()- } else {- self.content_block_size_from_aspect_ratio(sized, facts.initial_containing_block_inline_size())- }),+ // AD-HOC: Use zero for intrinsic contributions, so ratio-only images don't expand shrink-to-fit+ // containers to the viewport. Percentage inline sizes use the default size for compatibility.+ let inline_size = if style.width().contains_percentage() {+ self.default_replaced_size(SizingAxis::Inline)+ } else {+ CssPixels::default()+ };+ Some(if is_inline_axis {+ inline_size+ } else {+ self.content_block_size_from_aspect_ratio(sized, inline_size)+ })+ }};}@@ -2889,6 +2918,29 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {)}+ pub(crate) fn calculate_max_content_inline_size_with_available_space(+ &self,+ sized: SizedBox<'_>,+ available: AvailableSize,+ constraints: ContainingBlockConstraints,+ ) -> CssPixels {+ if self.facts(sized.node).is_replaced_box()+ && let AvailableSize::Definite(basis) = available+ && let Some(answer) = self.max_content_inline_size_answered_without_measuring_content(+ sized,+ constraints,+ self.definite_block_size_of_replaced_box_in_held_metrics(sized),+ Some(self.stretch_fit_inner_size(sized, SizingAxis::Inline, basis, constraints)),+ )+ {+ let answer =+ self.with_transferred_limits(sized, answer, IntrinsicSizeCacheKind::MaxContentInline, constraints);+ self.charge_content_sizing_scope_with(sized.node, answer.dependencies);+ return answer.size;+ }+ self.calculate_max_content_inline_size(sized, constraints)+ }+fn definite_block_size_of_replaced_box_in_held_metrics(&self, sized: SizedBox<'_>) -> Option<CssPixels> {let node = sized.node;if !self.facts(node).is_replaced_box() {@@ -2948,7 +3000,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {self.min_content_inline_size_answered_without_measuring_content(sized, constraints, block_size)}IntrinsicSizeCacheKind::MaxContentInline => {- self.max_content_inline_size_answered_without_measuring_content(sized, constraints, block_size)+ self.max_content_inline_size_answered_without_measuring_content(sized, constraints, block_size, None)}IntrinsicSizeCacheKind::MaxContentBlock => {unreachable!("content inline size kind must use the inline axis")@@ -3096,6 +3148,14 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {if let Some(width) = auto_size.width {return answered_from_style(width);}+ if facts.is_replaced_box() && facts.has_preferred_aspect_ratio() && auto_size.height.is_some() {+ return self.max_content_inline_size_answered_without_measuring_content(+ sized,+ constraints,+ block_size,+ None,+ );+ }if facts.is_replaced_box()&& !facts.has_preferred_aspect_ratio()&& let Some(fallback) = self.max_content_size_for_replaced_element_without_natural_size(@@ -3115,6 +3175,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {sized: SizedBox<'_>,constraints: ContainingBlockConstraints,block_size: Option<CssPixels>,+ stretch_fit_inline_size: Option<CssPixels>,) -> Option<ContentInlineSizeAnswer> {let node = sized.node;let facts = self.facts(node);@@ -3215,6 +3276,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {);let replaced_constraints = formatting_context::ReplacedMaxContentSizeLimits {definite_size_in_ratio_determining_axis: definite_block_size,+ stretch_fit_inline_size,minimum_inline_size: definite_minimum_inline_size,minimum_block_size: definite_minimum_block_size,};@@ -4066,7 +4128,11 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {// max-content size) (i.e. max(min-content size, min(max-content size, stretch-fit size))).if let AvailableSize::Definite(basis) = available_space.inline_size {let stretch = self.stretch_fit_inner_size(sized, SizingAxis::Inline, basis, constraints);- let max_content = self.calculate_max_content_inline_size(sized, constraints);+ let max_content = self.calculate_max_content_inline_size_with_available_space(+ sized,+ available_space.inline_size,+ constraints,+ );if max_content <= stretch {return max_content;}@@ -4369,7 +4435,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {constraints,))} else if preferred_size.is_max_content() {- Some(self.calculate_max_content_inline_size(sized, constraints))+ Some(self.calculate_max_content_inline_size_with_available_space(sized, available, constraints))} else if preferred_size.is_min_content() {Some(self.calculate_min_content_inline_size(sized, constraints))} else {diff --git a/Tests/LibWeb/Layout/expected/grid/ratio-only-replaced-item-size-transfer-matrix.txt b/Tests/LibWeb/Layout/expected/grid/ratio-only-replaced-item-size-transfer-matrix.txtindex 120d9f5ffd5..0daf2763f53 100644--- a/Tests/LibWeb/Layout/expected/grid/ratio-only-replaced-item-size-transfer-matrix.txt+++ b/Tests/LibWeb/Layout/expected/grid/ratio-only-replaced-item-size-transfer-matrix.txt@@ -1,6 +1,6 @@-Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline overflow: [0,0 800x929]- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 929 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 913 0+0+8] children: not-inline+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline overflow: [0,0 800x897]+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 897 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 881 0+0+8] children: not-inlineBox <div> at [8,8] [0+0+0 64 0+0+720] [0+0+0 16 0+0+0] [GFC] children: not-inlineImageBox <img.cyclic-preferred> at [8,8] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] children: not-inline(SVG-as-image isolated context)@@ -91,30 +91,30 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenViewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inlineSVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inlineSVGGeometryBox <rect> at [0,0] [0+0+0 2 0+0+0] [0+0+0 1 0+0+0] children: not-inline- Box <div> at [8,753] [0+0+0 84 0+0+700] [0+0+0 52 0+0+0] [GFC] children: not-inline- ImageBox <img.border-box-maximum> at [18,763] [0+10+0 64 0+10+0] [0+10+0 32 0+10+0] children: not-inline+ Box <div> at [8,753] [0+0+0 20 0+0+764] [0+0+0 20 0+0+0] [GFC] children: not-inline+ ImageBox <img.border-box-maximum> at [18,763] [0+10+0 0 0+10+0] [0+10+0 0 0+10+0] children: not-inline(SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 64 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 64 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[32 0 0 32 0 0] [SVG] children: not-inline+ Viewport <#document> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] viewport-transform=[0 0 0 0 0 0] [SVG] children: not-inlineSVGGeometryBox <rect> at [0,0] [0+0+0 2 0+0+0] [0+0+0 1 0+0+0] children: not-inline- Box <div.definite-height> at [8,805] [0+0+0 100 0+0+684] [0+0+0 100 0+0+0] [GFC] children: not-inline- ImageBox <img.percentage-maximum> at [8,805] [0+0+0 100 0+0+0] [0+0+0 50 0+0+50] children: not-inline+ Box <div.definite-height> at [8,773] [0+0+0 0 0+0+784] [0+0+0 100 0+0+0] [GFC] children: not-inline+ ImageBox <img.percentage-maximum> at [8,773] [0+0+0 0 0+0+0] [0+0+0 0 0+0+100] children: not-inline(SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 50 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 50 0+0+0] viewport-transform=[50 0 0 50 0 0] [SVG] children: not-inline+ Viewport <#document> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] viewport-transform=[0 0 0 0 0 0] [SVG] children: not-inlineSVGGeometryBox <rect> at [0,0] [0+0+0 2 0+0+0] [0+0+0 1 0+0+0] children: not-inline- Box <div.available-width> at [8,905] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [GFC] children: not-inline- ImageBox <img.cyclic-preferred> at [8,905] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] children: not-inline+ Box <div.available-width> at [8,873] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [GFC] children: not-inline+ ImageBox <img.cyclic-preferred> at [8,873] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] children: not-inline(SVG-as-image isolated context)Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inlineSVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] viewport-transform=[16 0 0 16 0 0] [SVG] children: not-inlineSVGGeometryBox <rect> at [0,0] [0+0+0 2 0+0+0] [0+0+0 1 0+0+0] children: not-inline- Box <div.available-width> at [8,921] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [GFC] children: not-inline- ImageBox <img.cyclic-zero-minimum> at [8,921] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ Box <div.available-width> at [8,889] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.cyclic-zero-minimum> at [8,889] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline(SVG-as-image isolated context)Viewport <#document> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inlineSVGSVGBox <svg> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] viewport-transform=[0 0 0 0 0 0] [SVG] children: not-inlineSVGGeometryBox <rect> at [0,0] [0+0+0 2 0+0+0] [0+0+0 1 0+0+0] children: not-inlineSC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x929] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x897] (z-index: auto)diff --git a/Tests/LibWeb/Layout/expected/grid/replaced-item-preferred-ratio-source-matrix.txt b/Tests/LibWeb/Layout/expected/grid/replaced-item-preferred-ratio-source-matrix.txtindex f3c65944103..c4e8e9d3b95 100644--- a/Tests/LibWeb/Layout/expected/grid/replaced-item-preferred-ratio-source-matrix.txt+++ b/Tests/LibWeb/Layout/expected/grid/replaced-item-preferred-ratio-source-matrix.txt@@ -1,116 +1,116 @@-Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline overflow: [0,0 808x2020]- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 2020 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 2004 0+0+8] children: not-inline- Box <div> at [8,8] [0+0+0 64 0+0+720] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img> at [8,8] [0+0+0 64 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[16 0 0 16 0 8] [SVG] children: not-inline- Box <div> at [8,40] [0+0+0 64 0+0+720] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio> at [8,40] [0+0+0 64 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,72] [0+0+0 64 0+0+720] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.calculated-maximum> at [8,72] [0+0+0 64 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,104] [0+0+0 800 0+0+-16] [0+0+0 400 0+0+0] [GFC] children: not-inline- ImageBox <img.unconstrained> at [8,104] [0+0+0 800 0+0+0] [0+0+0 400 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[16 0 0 16 0 8] [SVG] children: not-inline- Box <div> at [8,504] [0+0+0 800 0+0+-16] [0+0+0 400 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.unconstrained> at [8,504] [0+0+0 800 0+0+0] [0+0+0 400 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,904] [0+0+0 200 0+0+584] [0+0+0 100 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.minimum-only> at [8,904] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1004] [0+0+0 220 0+0+564] [0+0+0 120 0+0+0] [GFC] children: not-inline- ImageBox <img.border-box-minimum-only> at [18,1014] [0+10+0 200 0+10+0] [0+10+0 100 0+10+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[16 0 0 16 0 8] [SVG] children: not-inline- Box <div> at [8,1124] [0+0+0 240 0+0+544] [0+0+0 120 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.border-box-minimum-only> at [18,1134] [0+10+0 220 0+10+0] [0+10+0 100 0+10+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div.definite-height> at [8,1244] [0+0+0 200 0+0+584] [0+0+0 200 0+0+0] [GFC] children: not-inline- ImageBox <img.percentage-minimum-only> at [8,1244] [0+0+0 200 0+0+0] [0+0+0 100 0+0+100] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[16 0 0 16 0 8] [SVG] children: not-inline- Box <div.definite-height> at [8,1444] [0+0+0 200 0+0+584] [0+0+0 200 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.percentage-minimum-only> at [8,1444] [0+0+0 200 0+0+0] [0+0+0 100 0+0+100] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1644] [0+0+0 200 0+0+584] [0+0+0 100 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.conflicting-heights> at [8,1644] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1744] [0+0+0 300 0+0+484] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img.cyclic-zero-minimum> at [8,1744] [0+0+0 300 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1776] [0+0+0 300 0+0+484] [0+0+0 2 0+0+0] [GFC] children: not-inline- ImageBox <img.cyclic-calculated-minimum> at [8,1776] [0+0+0 300 0+0+0] [0+0+0 2 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1778] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.cyclic-zero-minimum> at [8,1778] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1778] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.cyclic-zero-minimum.unconstrained> at [8,1778] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1778] [0+0+0 10 0+0+774] [0+0+0 2 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.cyclic-calculated-minimum> at [8,1778] [0+0+0 15 0+0+0] [0+0+0 2 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1780] [0+0+0 64 0+0+720] [0+0+0 16 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.cyclic-preferred> at [8,1780] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1796] [0+0+0 200 0+0+584] [0+0+0 100 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.cyclic-maximum> at [8,1796] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1896] [0+0+0 20 0+0+764] [0+0+0 20 0+0+0] [GFC] children: not-inline- ImageBox <img.css-ratio.border-box-cyclic-minimum> at [18,1906] [0+10+0 0 0+10+0] [0+10+0 0 0+10+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline- Box <div> at [8,1916] [0+0+0 32 0+0+752] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img.css-override> at [8,1916] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[16 0 0 16 0 8] [SVG] children: not-inline- Box <div> at [8,1948] [0+0+0 64 0+0+720] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img.css-auto-with-ratio> at [8,1948] [0+0+0 64 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[16 0 0 16 0 8] [SVG] children: not-inline- Box <div> at [8,1980] [0+0+0 32 0+0+752] [0+0+0 32 0+0+0] [GFC] children: not-inline- ImageBox <img.css-auto-with-ratio> at [8,1980] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] children: not-inline- (SVG-as-image isolated context)- Viewport <#document> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- SVGSVGBox <svg> at [0,0] [0+0+0 32 0+0+0] [0+0+0 32 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline overflow: [0,0 800x1028]+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 1028 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 1012 0+0+8] children: not-inline+ Box <div> at [8,8] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inline+ Box <div> at [8,8] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,8] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.calculated-maximum> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,8] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.unconstrained> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inline+ Box <div> at [8,8] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.unconstrained> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,8] [0+0+0 200 0+0+584] [0+0+0 100 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.minimum-only> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,108] [0+0+0 220 0+0+564] [0+0+0 120 0+0+0] [GFC] children: not-inline+ ImageBox <img.border-box-minimum-only> at [18,118] [0+10+0 200 0+10+0] [0+10+0 100 0+10+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inline+ Box <div> at [8,228] [0+0+0 240 0+0+544] [0+0+0 120 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.border-box-minimum-only> at [18,238] [0+10+0 220 0+10+0] [0+10+0 100 0+10+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div.definite-height> at [8,348] [0+0+0 200 0+0+584] [0+0+0 200 0+0+0] [GFC] children: not-inline+ ImageBox <img.percentage-minimum-only> at [8,348] [0+0+0 200 0+0+0] [0+0+0 100 0+0+100] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inline+ Box <div.definite-height> at [8,548] [0+0+0 200 0+0+584] [0+0+0 200 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.percentage-minimum-only> at [8,548] [0+0+0 200 0+0+0] [0+0+0 100 0+0+100] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,748] [0+0+0 200 0+0+584] [0+0+0 100 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.conflicting-heights> at [8,748] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,848] [0+0+0 300 0+0+484] [0+0+0 32 0+0+0] [GFC] children: not-inline+ ImageBox <img.cyclic-zero-minimum> at [8,848] [0+0+0 300 0+0+0] [0+0+0 32 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,880] [0+0+0 300 0+0+484] [0+0+0 2 0+0+0] [GFC] children: not-inline+ ImageBox <img.cyclic-calculated-minimum> at [8,880] [0+0+0 300 0+0+0] [0+0+0 2 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,882] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.cyclic-zero-minimum> at [8,882] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,882] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.cyclic-zero-minimum.unconstrained> at [8,882] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,882] [0+0+0 10 0+0+774] [0+0+0 2 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.cyclic-calculated-minimum> at [8,882] [0+0+0 15 0+0+0] [0+0+0 2 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,884] [0+0+0 64 0+0+720] [0+0+0 16 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.cyclic-preferred> at [8,884] [0+0+0 32 0+0+0] [0+0+0 16 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,900] [0+0+0 200 0+0+584] [0+0+0 100 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.cyclic-maximum> at [8,900] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,1000] [0+0+0 20 0+0+764] [0+0+0 20 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-ratio.border-box-cyclic-minimum> at [18,1010] [0+10+0 0 0+10+0] [0+10+0 0 0+10+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline+ Box <div> at [8,1020] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-override> at [8,1020] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inline+ Box <div> at [8,1020] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-auto-with-ratio> at [8,1020] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[100 0 0 100 0 0] [SVG] children: not-inline+ Box <div> at [8,1020] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [GFC] children: not-inline+ ImageBox <img.css-auto-with-ratio> at [8,1020] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline+ (SVG-as-image isolated context)+ Viewport <#document> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline+ SVGSVGBox <svg> at [0,0] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inlineSC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x2020] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x1028] (z-index: auto)diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-sizing/replaced-aspect-ratio-stretch-fit-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-sizing/replaced-aspect-ratio-stretch-fit-001.htmlnew file mode 100644index 00000000000..445d88c6638--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-sizing/replaced-aspect-ratio-stretch-fit-001.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<meta name="assert" content="Checks that a replaced element, with an aspect ratio, applies min/max block lengths for stretch-fit sizing.">+<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-sizes">+<link rel="match" href="../../../../expected/wpt-import/css/css-sizing/../reference/ref-filled-green-100px-square-only.html">+<p>Test passes if there is a filled green square.</p>+<div style="width: 50px;">+ <svg viewBox="0 0 2 1" style="background: green; max-width: 100px; min-height: 100px;"></svg>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-sizing/replaced-aspect-ratio-stretch-fit-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-sizing/replaced-aspect-ratio-stretch-fit-002.htmlnew file mode 100644index 00000000000..73d16954b3e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-sizing/replaced-aspect-ratio-stretch-fit-002.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<meta name="assert" content="Checks that a replaced element, with an aspect ratio, applies min/max block lengths for stretch-fit sizing.">+<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-sizes">+<link rel="match" href="../../../../expected/wpt-import/css/css-sizing/../reference/ref-filled-green-100px-square-only.html">+<p>Test passes if there is a filled green square.</p>+<div style="width: 50px;">+ <svg viewBox="0 0 1 1" style="background: green; min-height: 100px;"></svg>+</div>diff --git a/Tests/LibWeb/Text/expected/css/ratio-only-image-available-size.txt b/Tests/LibWeb/Text/expected/css/ratio-only-image-available-size.txtnew file mode 100644index 00000000000..359246acfa3--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/ratio-only-image-available-size.txt@@ -0,0 +1,6 @@+block: 200x100+edges: 180x100+row: 200x100+column: 200x100+minimum: 240x120+percentage: 150x75diff --git a/Tests/LibWeb/Text/expected/css/ratio-only-image-stretch-fit-minimum.txt b/Tests/LibWeb/Text/expected/css/ratio-only-image-stretch-fit-minimum.txtnew file mode 100644index 00000000000..73b4a3c8eeb--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/ratio-only-image-stretch-fit-minimum.txt@@ -0,0 +1,10 @@+transferred block minimum: 200x100+inline minimum: 250x125+both minima: 250x125+percentage block minimum: 200x100+border box minimum: 180x100+maximum width control: 100x100+specified width control: 100x100+maximum height control: 200x100+larger space control: 300x150+row flex shrinking control: 100x100diff --git a/Tests/LibWeb/Text/expected/css/svg-image-natural-height-intrinsic-width.txt b/Tests/LibWeb/Text/expected/css/svg-image-natural-height-intrinsic-width.txtnew file mode 100644index 00000000000..086c99c8bb5--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/svg-image-natural-height-intrinsic-width.txt@@ -0,0 +1,14 @@+inline-block: container 120, image 120x60+column-flex: container 120, image 120x60+max-content-grid: container 120, image 120x60+column smaller minimum: container 120, image 120x60+column larger minimum: container 200, image 200x100+column block minimum: container 160, image 160x80+grid block minimum: container 160, image 160x80+smaller minimum: container 120, image 120x60+larger minimum: container 200, image 200x100+block minimum: container 160, image 160x80+maximum: container 80, image 80x40+preferred ratio: container 180, image 180x60+definite space: container 200, image 120x60+small definite space: container 80, image 120x60diff --git a/Tests/LibWeb/Text/expected/css/svg-image-without-natural-width-in-shrink-to-fit-column-flex.txt b/Tests/LibWeb/Text/expected/css/svg-image-without-natural-width-in-shrink-to-fit-column-flex.txtnew file mode 100644index 00000000000..b39eefeccb8--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/svg-image-without-natural-width-in-shrink-to-fit-column-flex.txt@@ -0,0 +1,2 @@+in a shrink-to-fit column flex container: 0x0+in a shrink-to-fit block: 0x0diff --git a/Tests/LibWeb/Text/input/css/ratio-only-image-available-size.html b/Tests/LibWeb/Text/input/css/ratio-only-image-available-size.htmlnew file mode 100644index 00000000000..17b66e55860--- /dev/null+++ b/Tests/LibWeb/Text/input/css/ratio-only-image-available-size.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ .container { width: 200px; }+ .flex { display: flex; }+ .column { flex-direction: column; align-items: start; }+ img { width: fit-content; }+ .edges { margin: 10px; border: 5px solid; padding: 5px; }+ .minimum { min-height: 120px; }+ .intrinsic { display: grid; width: max-content; grid-template-columns: max-content; }+ .percentage { width: 50%; }+</style>+<div class="container"><img id="block"></div>+<div class="container"><img id="edges" class="edges"></div>+<div class="container flex"><img id="row"></div>+<div class="container flex column"><img id="column"></div>+<div class="container"><img id="minimum" class="minimum"></div>+<div class="intrinsic"><img id="percentage" class="percentage"></div>+<script>+ asyncTest(done => {+ const images = [...document.querySelectorAll("img")];+ const source = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 1'%3E%3C/svg%3E";+ Promise.all(images.map(image => {+ image.src = source;+ return image.decode();+ })).then(() => {+ for (const image of images) {+ const rect = image.getBoundingClientRect();+ println(`${image.id}: ${rect.width}x${rect.height}`);+ }+ done();+ });+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/ratio-only-image-stretch-fit-minimum.html b/Tests/LibWeb/Text/input/css/ratio-only-image-stretch-fit-minimum.htmlnew file mode 100644index 00000000000..196a770bbf1--- /dev/null+++ b/Tests/LibWeb/Text/input/css/ratio-only-image-stretch-fit-minimum.html@@ -0,0 +1,29 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ const source = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 1'%3E%3C/svg%3E";+ for (const [label, containerStyle, imageStyle] of [+ ["transferred block minimum", "display:grid;justify-items:start", "width:max-content;min-height:100px"],+ ["inline minimum", "display:grid;justify-items:start", "width:max-content;min-width:250px"],+ ["both minima", "display:grid;justify-items:start", "width:max-content;min-width:250px;min-height:100px"],+ ["percentage block minimum", "display:grid;justify-items:start;height:200px", "width:max-content;min-height:50%"],+ ["border box minimum", "display:grid;justify-items:start", "width:max-content;min-height:100px;box-sizing:border-box;border:10px solid"],+ ["maximum width control", "display:grid;justify-items:start", "width:max-content;min-height:100px;max-width:100px"],+ ["specified width control", "display:grid;justify-items:start", "width:100px;min-height:100px"],+ ["maximum height control", "display:grid;justify-items:start", "width:max-content;min-height:100px;max-height:80px"],+ ["larger space control", "display:grid;justify-items:start;width:300px", "width:max-content;min-height:100px"],+ ["row flex shrinking control", "display:flex", "min-width:0;min-height:100px"],+ ]) {+ const container = document.body.appendChild(document.createElement("div"));+ container.style.cssText = "width:100px;" + containerStyle;+ const image = container.appendChild(document.createElement("img"));+ image.style.cssText = imageStyle;+ image.src = source;+ await image.decode();+ const rect = image.getBoundingClientRect();+ println(`${label}: ${rect.width}x${rect.height}`);+ container.remove();+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/svg-image-natural-height-intrinsic-width.html b/Tests/LibWeb/Text/input/css/svg-image-natural-height-intrinsic-width.htmlnew file mode 100644index 00000000000..d13449d852b--- /dev/null+++ b/Tests/LibWeb/Text/input/css/svg-image-natural-height-intrinsic-width.html@@ -0,0 +1,34 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ asyncTest(async done => {+ const source = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='60' viewBox='0 0 2 1'%3E%3C/svg%3E";+ for (const [label, containerStyle, imageStyle] of [+ ["inline-block", "display:inline-block", ""],+ ["column-flex", "display:inline-flex;flex-direction:column;align-items:start", ""],+ ["max-content-grid", "display:grid;width:max-content;grid-template-columns:max-content", ""],+ ["column smaller minimum", "display:inline-flex;flex-direction:column;align-items:start", "min-width:40px"],+ ["column larger minimum", "display:inline-flex;flex-direction:column;align-items:start", "min-width:200px"],+ ["column block minimum", "display:inline-flex;flex-direction:column;align-items:start", "min-height:80px"],+ ["grid block minimum", "display:grid;width:max-content;grid-template-columns:max-content", "min-height:80px"],+ ["smaller minimum", "display:inline-block", "min-width:40px"],+ ["larger minimum", "display:inline-block", "min-width:200px"],+ ["block minimum", "display:inline-block", "min-height:80px"],+ ["maximum", "display:inline-block", "max-width:80px"],+ ["preferred ratio", "display:inline-block", "aspect-ratio:3"],+ ["definite space", "width:200px", "width:fit-content"],+ ["small definite space", "width:80px", "width:fit-content"],+ ]) {+ const container = document.body.appendChild(document.createElement("div"));+ container.style.cssText = containerStyle;+ const image = container.appendChild(document.createElement("img"));+ image.style.cssText = imageStyle;+ image.src = source;+ await image.decode();+ const rect = image.getBoundingClientRect();+ println(`${label}: container ${container.getBoundingClientRect().width}, image ${rect.width}x${rect.height}`);+ container.remove();+ }+ done();+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/svg-image-without-natural-width-in-shrink-to-fit-column-flex.html b/Tests/LibWeb/Text/input/css/svg-image-without-natural-width-in-shrink-to-fit-column-flex.htmlnew file mode 100644index 00000000000..6e26da5e05f--- /dev/null+++ b/Tests/LibWeb/Text/input/css/svg-image-without-natural-width-in-shrink-to-fit-column-flex.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ .column {+ display: inline-flex;+ flex-direction: column;+ }+ .block {+ display: inline-block;+ }+</style>+<!-- An SVG with a viewBox but no width or height has an aspect ratio, but no natural width. -->+<div class="column"><img id="in-column-flex" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 449 163'%3E%3Crect width='449' height='163' fill='navy'/%3E%3C/svg%3E"></div>+<div class="block"><img id="in-block" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 449 163'%3E%3Crect width='449' height='163' fill='navy'/%3E%3C/svg%3E"></div>+<script>+ asyncTest(done => {+ window.addEventListener("load", () => {+ const size = id => {+ const rect = document.getElementById(id).getBoundingClientRect();+ return `${Math.round(rect.width)}x${Math.round(rect.height)}`;+ };+ println(`in a shrink-to-fit column flex container: ${size("in-column-flex")}`);+ println(`in a shrink-to-fit block: ${size("in-block")}`);+ done();+ });+ });+</script>