diff --git a/components/layout_2020/replaced.rs b/components/layout_2020/replaced.rs index f97093519f6..9feaae3e804 100644 --- a/components/layout_2020/replaced.rs +++ b/components/layout_2020/replaced.rs @@ -415,11 +415,20 @@ impl ReplacedContent { containing_block: &IndefiniteContainingBlock, style: &ComputedValues, ) -> Option { - style.preferred_aspect_ratio( - self.inline_size_over_block_size_intrinsic_ratio(style), - containing_block.try_into().ok().as_ref(), - containing_block.style.writing_mode, - ) + style + .preferred_aspect_ratio( + self.inline_size_over_block_size_intrinsic_ratio(style), + containing_block.try_into().ok().as_ref(), + containing_block.style.writing_mode, + ) + .or_else(|| { + matches!(self.kind, ReplacedContentKind::Video(_)).then(|| { + let size = Self::default_object_size(); + AspectRatio::from_content_ratio( + size.width.to_f32_px() / size.height.to_f32_px(), + ) + }) + }) } /// @@ -475,16 +484,7 @@ impl ReplacedContent { ) -> LogicalVec2 { let mode = style.writing_mode; let intrinsic_size = self.flow_relative_intrinsic_size(style); - let intrinsic_ratio = self - .preferred_aspect_ratio(&containing_block.into(), style) - .or_else(|| { - matches!(self.kind, ReplacedContentKind::Video(_)).then(|| { - let size = Self::default_object_size(); - AspectRatio::from_content_ratio( - size.width.to_f32_px() / size.height.to_f32_px(), - ) - }) - }); + let intrinsic_ratio = self.preferred_aspect_ratio(&containing_block.into(), style); let default_object_size = || LogicalVec2::from_physical_size(&Self::default_object_size(), mode); diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 0b6f327e8af..2933bbcf217 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -570555,6 +570555,13 @@ {} ] ], + "intrinsic-size-fallback-video.html": [ + "c9f2a0539147524c7e4945c6ea2ef0f05b07323f", + [ + null, + {} + ] + ], "keyword-sizes-for-intrinsic-contributions.tentative.html": [ "5f135d8181b023134eb24e5ec34957e3a25e6765", [ diff --git a/tests/wpt/meta/css/css-sizing/intrinsic-size-fallback-video.html.ini b/tests/wpt/meta/css/css-sizing/intrinsic-size-fallback-video.html.ini new file mode 100644 index 00000000000..c40155c3f9b --- /dev/null +++ b/tests/wpt/meta/css/css-sizing/intrinsic-size-fallback-video.html.ini @@ -0,0 +1,9 @@ +[intrinsic-size-fallback-video.html] + [.wrapper 1] + expected: FAIL + + [.wrapper 3] + expected: FAIL + + [.wrapper 4] + expected: FAIL diff --git a/tests/wpt/tests/css/css-sizing/intrinsic-size-fallback-video.html b/tests/wpt/tests/css/css-sizing/intrinsic-size-fallback-video.html new file mode 100644 index 00000000000..c9f2a053914 --- /dev/null +++ b/tests/wpt/tests/css/css-sizing/intrinsic-size-fallback-video.html @@ -0,0 +1,39 @@ + +CSS Sizing Test: intrinsic contribution of videos with fallback size + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + + +