mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
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:
parent
38d2ad9592
commit
41a41b3d8f
6 changed files with 32 additions and 4 deletions
|
@ -93,6 +93,7 @@ pub(crate) trait NodeExt<'dom>: 'dom + LayoutNode<'dom> {
|
||||||
fn as_image(self) -> Option<(Option<Arc<NetImage>>, PhysicalSize<f64>)>;
|
fn as_image(self) -> Option<(Option<Arc<NetImage>>, PhysicalSize<f64>)>;
|
||||||
fn as_canvas(self) -> Option<(CanvasInfo, PhysicalSize<f64>)>;
|
fn as_canvas(self) -> Option<(CanvasInfo, PhysicalSize<f64>)>;
|
||||||
fn as_iframe(self) -> Option<(PipelineId, BrowsingContextId)>;
|
fn as_iframe(self) -> Option<(PipelineId, BrowsingContextId)>;
|
||||||
|
fn as_video(self) -> Option<(webrender_api::ImageKey, PhysicalSize<f64>)>;
|
||||||
fn style(self, context: &LayoutContext) -> ServoArc<ComputedValues>;
|
fn style(self, context: &LayoutContext) -> ServoArc<ComputedValues>;
|
||||||
|
|
||||||
fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>>;
|
fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>>;
|
||||||
|
@ -125,6 +126,13 @@ where
|
||||||
Some((resource, PhysicalSize::new(width, height)))
|
Some((resource, PhysicalSize::new(width, height)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn as_video(self) -> Option<(webrender_api::ImageKey, PhysicalSize<f64>)> {
|
||||||
|
let node = self.to_threadsafe();
|
||||||
|
let frame_data = node.media_data()?.current_frame?;
|
||||||
|
let (width, height) = (frame_data.1 as f64, frame_data.2 as f64);
|
||||||
|
Some((frame_data.0, PhysicalSize::new(width, height)))
|
||||||
|
}
|
||||||
|
|
||||||
fn as_canvas(self) -> Option<(CanvasInfo, PhysicalSize<f64>)> {
|
fn as_canvas(self) -> Option<(CanvasInfo, PhysicalSize<f64>)> {
|
||||||
let node = self.to_threadsafe();
|
let node = self.to_threadsafe();
|
||||||
let canvas_data = node.canvas_data()?;
|
let canvas_data = node.canvas_data()?;
|
||||||
|
|
|
@ -117,11 +117,17 @@ pub(crate) struct IFrameInfo {
|
||||||
pub browsing_context_id: BrowsingContextId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub(crate) struct VideoInfo {
|
||||||
|
pub image_key: webrender_api::ImageKey,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub(crate) enum ReplacedContentKind {
|
pub(crate) enum ReplacedContentKind {
|
||||||
Image(Option<Arc<Image>>),
|
Image(Option<Arc<Image>>),
|
||||||
IFrame(IFrameInfo),
|
IFrame(IFrameInfo),
|
||||||
Canvas(CanvasInfo),
|
Canvas(CanvasInfo),
|
||||||
|
Video(VideoInfo),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReplacedContent {
|
impl ReplacedContent {
|
||||||
|
@ -145,6 +151,11 @@ impl ReplacedContent {
|
||||||
}),
|
}),
|
||||||
None,
|
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 {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -263,6 +274,15 @@ impl ReplacedContent {
|
||||||
})
|
})
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect(),
|
.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) => {
|
ReplacedContentKind::IFrame(iframe) => {
|
||||||
vec![Fragment::IFrame(IFrameFragment {
|
vec![Fragment::IFrame(IFrameFragment {
|
||||||
base: self.base_fragment_info.into(),
|
base: self.base_fragment_info.into(),
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[object-view-box-fit-cover-video.html]
|
||||||
|
expected: FAIL
|
|
@ -0,0 +1,2 @@
|
||||||
|
[object-view-box-writing-mode-video.html]
|
||||||
|
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
||||||
[video_dynamic_poster_absolute.htm]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[video_dynamic_poster_relative.htm]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue