mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
layout: handle MediaFragmentInfo
This commit is contained in:
parent
e1a031e447
commit
bdd3e2c835
1 changed files with 50 additions and 2 deletions
|
@ -31,9 +31,10 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use net_traits::image::base::{Image, ImageMetadata};
|
use net_traits::image::base::{Image, ImageMetadata};
|
||||||
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||||
use range::*;
|
use range::*;
|
||||||
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource};
|
|
||||||
use script_layout_interface::SVGSVGData;
|
|
||||||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||||
|
use script_layout_interface::{
|
||||||
|
HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaData, HTMLMediaFrameSource, SVGSVGData,
|
||||||
|
};
|
||||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::{f32, fmt};
|
use std::{f32, fmt};
|
||||||
|
@ -182,6 +183,7 @@ pub enum SpecificFragmentInfo {
|
||||||
|
|
||||||
Iframe(IframeFragmentInfo),
|
Iframe(IframeFragmentInfo),
|
||||||
Image(Box<ImageFragmentInfo>),
|
Image(Box<ImageFragmentInfo>),
|
||||||
|
Media(Box<MediaFragmentInfo>),
|
||||||
Canvas(Box<CanvasFragmentInfo>),
|
Canvas(Box<CanvasFragmentInfo>),
|
||||||
Svg(Box<SvgFragmentInfo>),
|
Svg(Box<SvgFragmentInfo>),
|
||||||
|
|
||||||
|
@ -219,6 +221,7 @@ impl SpecificFragmentInfo {
|
||||||
SpecificFragmentInfo::GeneratedContent(_) |
|
SpecificFragmentInfo::GeneratedContent(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::ScannedText(_) |
|
SpecificFragmentInfo::ScannedText(_) |
|
||||||
SpecificFragmentInfo::Svg(_) |
|
SpecificFragmentInfo::Svg(_) |
|
||||||
SpecificFragmentInfo::Table |
|
SpecificFragmentInfo::Table |
|
||||||
|
@ -242,6 +245,7 @@ impl SpecificFragmentInfo {
|
||||||
pub fn get_type(&self) -> &'static str {
|
pub fn get_type(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
SpecificFragmentInfo::Canvas(_) => "SpecificFragmentInfo::Canvas",
|
SpecificFragmentInfo::Canvas(_) => "SpecificFragmentInfo::Canvas",
|
||||||
|
SpecificFragmentInfo::Media(_) => "SpecificFragmentInfo::Media",
|
||||||
SpecificFragmentInfo::Generic => "SpecificFragmentInfo::Generic",
|
SpecificFragmentInfo::Generic => "SpecificFragmentInfo::Generic",
|
||||||
SpecificFragmentInfo::GeneratedContent(_) => "SpecificFragmentInfo::GeneratedContent",
|
SpecificFragmentInfo::GeneratedContent(_) => "SpecificFragmentInfo::GeneratedContent",
|
||||||
SpecificFragmentInfo::Iframe(_) => "SpecificFragmentInfo::Iframe",
|
SpecificFragmentInfo::Iframe(_) => "SpecificFragmentInfo::Iframe",
|
||||||
|
@ -364,6 +368,27 @@ impl CanvasFragmentInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct MediaFragmentInfo {
|
||||||
|
pub frame_source: Box<HTMLMediaFrameSource>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
impl Clone for MediaFragmentInfo {
|
||||||
|
fn clone(&self) -> MediaFragmentInfo {
|
||||||
|
MediaFragmentInfo {
|
||||||
|
frame_source: self.frame_source.clone_boxed(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MediaFragmentInfo {
|
||||||
|
pub fn new(data: HTMLMediaData) -> MediaFragmentInfo {
|
||||||
|
MediaFragmentInfo {
|
||||||
|
frame_source: data.frame_source,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SvgFragmentInfo {
|
pub struct SvgFragmentInfo {
|
||||||
pub dom_width: Au,
|
pub dom_width: Au,
|
||||||
|
@ -834,6 +859,7 @@ impl Fragment {
|
||||||
) -> QuantitiesIncludedInIntrinsicInlineSizes {
|
) -> QuantitiesIncludedInIntrinsicInlineSizes {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::Generic |
|
SpecificFragmentInfo::Generic |
|
||||||
SpecificFragmentInfo::GeneratedContent(_) |
|
SpecificFragmentInfo::GeneratedContent(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
|
@ -978,6 +1004,13 @@ impl Fragment {
|
||||||
} else {
|
} else {
|
||||||
Au(0)
|
Au(0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
SpecificFragmentInfo::Media(ref info) => {
|
||||||
|
if let Some((_, width, _)) = info.frame_source.get_current_frame() {
|
||||||
|
Au::from_px(width as i32)
|
||||||
|
} else {
|
||||||
|
Au(0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
SpecificFragmentInfo::Canvas(ref info) => info.dom_width,
|
SpecificFragmentInfo::Canvas(ref info) => info.dom_width,
|
||||||
SpecificFragmentInfo::Svg(ref info) => info.dom_width,
|
SpecificFragmentInfo::Svg(ref info) => info.dom_width,
|
||||||
|
@ -1001,6 +1034,13 @@ impl Fragment {
|
||||||
} else {
|
} else {
|
||||||
Au(0)
|
Au(0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
SpecificFragmentInfo::Media(ref info) => {
|
||||||
|
if let Some((_, _, height)) = info.frame_source.get_current_frame() {
|
||||||
|
Au::from_px(height as i32)
|
||||||
|
} else {
|
||||||
|
Au(0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
SpecificFragmentInfo::Canvas(ref info) => info.dom_height,
|
SpecificFragmentInfo::Canvas(ref info) => info.dom_height,
|
||||||
SpecificFragmentInfo::Svg(ref info) => info.dom_height,
|
SpecificFragmentInfo::Svg(ref info) => info.dom_height,
|
||||||
|
@ -1014,6 +1054,7 @@ impl Fragment {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
// TODO(stshine): According to the SVG spec, whether a SVG element has intrinsic
|
// TODO(stshine): According to the SVG spec, whether a SVG element has intrinsic
|
||||||
// aspect ratio is determined by the `preserveAspectRatio` attribute. Since for
|
// aspect ratio is determined by the `preserveAspectRatio` attribute. Since for
|
||||||
// now SVG is far from implemented, we simply choose the default behavior that
|
// now SVG is far from implemented, we simply choose the default behavior that
|
||||||
|
@ -1549,6 +1590,7 @@ impl Fragment {
|
||||||
result.union_block(&block_flow.base.intrinsic_inline_sizes)
|
result.union_block(&block_flow.base.intrinsic_inline_sizes)
|
||||||
},
|
},
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Svg(_) => {
|
SpecificFragmentInfo::Svg(_) => {
|
||||||
|
@ -2024,6 +2066,7 @@ impl Fragment {
|
||||||
},
|
},
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::InlineBlock(_) |
|
SpecificFragmentInfo::InlineBlock(_) |
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(_) |
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(_) |
|
||||||
|
@ -2115,6 +2158,7 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::InlineBlock(_) |
|
SpecificFragmentInfo::InlineBlock(_) |
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(_) |
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(_) |
|
||||||
SpecificFragmentInfo::InlineAbsolute(_) |
|
SpecificFragmentInfo::InlineAbsolute(_) |
|
||||||
|
@ -2171,6 +2215,7 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::Svg(_) => true,
|
SpecificFragmentInfo::Svg(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -2202,6 +2247,7 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
SpecificFragmentInfo::Canvas(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::Svg(_) |
|
SpecificFragmentInfo::Svg(_) |
|
||||||
SpecificFragmentInfo::Generic |
|
SpecificFragmentInfo::Generic |
|
||||||
SpecificFragmentInfo::GeneratedContent(_) => {
|
SpecificFragmentInfo::GeneratedContent(_) => {
|
||||||
|
@ -2530,6 +2576,7 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::GeneratedContent(_) |
|
SpecificFragmentInfo::GeneratedContent(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::ScannedText(_) |
|
SpecificFragmentInfo::ScannedText(_) |
|
||||||
SpecificFragmentInfo::Svg(_) |
|
SpecificFragmentInfo::Svg(_) |
|
||||||
SpecificFragmentInfo::Table |
|
SpecificFragmentInfo::Table |
|
||||||
|
@ -3057,6 +3104,7 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::GeneratedContent(_) |
|
SpecificFragmentInfo::GeneratedContent(_) |
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
SpecificFragmentInfo::Iframe(_) |
|
||||||
SpecificFragmentInfo::Image(_) |
|
SpecificFragmentInfo::Image(_) |
|
||||||
|
SpecificFragmentInfo::Media(_) |
|
||||||
SpecificFragmentInfo::ScannedText(_) |
|
SpecificFragmentInfo::ScannedText(_) |
|
||||||
SpecificFragmentInfo::TruncatedFragment(_) |
|
SpecificFragmentInfo::TruncatedFragment(_) |
|
||||||
SpecificFragmentInfo::Svg(_) |
|
SpecificFragmentInfo::Svg(_) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue