Treat video elements as replaced content and render the current frame. (#31412)

* Treat video elements as replaced content and render the current frame.

* Update test results.
This commit is contained in:
Josh Matthews 2024-02-23 12:34:08 -05:00 committed by GitHub
parent 38d2ad9592
commit 41a41b3d8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 4 deletions

View file

@ -117,11 +117,17 @@ pub(crate) struct IFrameInfo {
pub browsing_context_id: BrowsingContextId,
}
#[derive(Debug, Serialize)]
pub(crate) struct VideoInfo {
pub image_key: webrender_api::ImageKey,
}
#[derive(Debug, Serialize)]
pub(crate) enum ReplacedContentKind {
Image(Option<Arc<Image>>),
IFrame(IFrameInfo),
Canvas(CanvasInfo),
Video(VideoInfo),
}
impl ReplacedContent {
@ -145,6 +151,11 @@ impl ReplacedContent {
}),
None,
)
} else if let Some((image_key, intrinsic_size_in_dots)) = element.as_video() {
(
ReplacedContentKind::Video(VideoInfo { image_key }),
Some(intrinsic_size_in_dots),
)
} else {
return None;
}
@ -263,6 +274,15 @@ impl ReplacedContent {
})
.into_iter()
.collect(),
ReplacedContentKind::Video(video) => vec![Fragment::Image(ImageFragment {
base: self.base_fragment_info.into(),
style: style.clone(),
rect: LogicalRect {
start_corner: LogicalVec2::zero(),
size: size.into(),
},
image_key: video.image_key,
})],
ReplacedContentKind::IFrame(iframe) => {
vec![Fragment::IFrame(IFrameFragment {
base: self.base_fragment_info.into(),