diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2018-08-27 16:01:03 +0200 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2018-10-08 16:12:01 +0200 |
commit | bdd3e2c8353ccd58846b74238de6f4cee28d3c7d (patch) | |
tree | e14aaf396001253c413bf86db53de354ec4dffcc | |
parent | e1a031e447c5067a53e64c159ba97ec78b196051 (diff) | |
download | servo-bdd3e2c8353ccd58846b74238de6f4cee28d3c7d.tar.gz servo-bdd3e2c8353ccd58846b74238de6f4cee28d3c7d.zip |
layout: handle MediaFragmentInfo
-rw-r--r-- | components/layout/fragment.rs | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 65fd277fdde..dce5be4e403 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -31,9 +31,10 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId}; use net_traits::image::base::{Image, ImageMetadata}; use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder}; 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::{ + HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaData, HTMLMediaFrameSource, SVGSVGData, +}; use serde::ser::{Serialize, SerializeStruct, Serializer}; use servo_url::ServoUrl; use std::{f32, fmt}; @@ -182,6 +183,7 @@ pub enum SpecificFragmentInfo { Iframe(IframeFragmentInfo), Image(Box<ImageFragmentInfo>), + Media(Box<MediaFragmentInfo>), Canvas(Box<CanvasFragmentInfo>), Svg(Box<SvgFragmentInfo>), @@ -219,6 +221,7 @@ impl SpecificFragmentInfo { SpecificFragmentInfo::GeneratedContent(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::ScannedText(_) | SpecificFragmentInfo::Svg(_) | SpecificFragmentInfo::Table | @@ -242,6 +245,7 @@ impl SpecificFragmentInfo { pub fn get_type(&self) -> &'static str { match *self { SpecificFragmentInfo::Canvas(_) => "SpecificFragmentInfo::Canvas", + SpecificFragmentInfo::Media(_) => "SpecificFragmentInfo::Media", SpecificFragmentInfo::Generic => "SpecificFragmentInfo::Generic", SpecificFragmentInfo::GeneratedContent(_) => "SpecificFragmentInfo::GeneratedContent", 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)] pub struct SvgFragmentInfo { pub dom_width: Au, @@ -834,6 +859,7 @@ impl Fragment { ) -> QuantitiesIncludedInIntrinsicInlineSizes { match self.specific { SpecificFragmentInfo::Canvas(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::Generic | SpecificFragmentInfo::GeneratedContent(_) | SpecificFragmentInfo::Iframe(_) | @@ -978,6 +1004,13 @@ impl Fragment { } else { 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::Svg(ref info) => info.dom_width, @@ -1001,6 +1034,13 @@ impl Fragment { } else { 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::Svg(ref info) => info.dom_height, @@ -1014,6 +1054,7 @@ impl Fragment { match self.specific { SpecificFragmentInfo::Image(_) | SpecificFragmentInfo::Canvas(_) | + SpecificFragmentInfo::Media(_) | // TODO(stshine): According to the SVG spec, whether a SVG element has intrinsic // aspect ratio is determined by the `preserveAspectRatio` attribute. Since for // 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) }, SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Svg(_) => { @@ -2024,6 +2066,7 @@ impl Fragment { }, SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::InlineBlock(_) | SpecificFragmentInfo::InlineAbsoluteHypothetical(_) | @@ -2115,6 +2158,7 @@ impl Fragment { SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::InlineBlock(_) | SpecificFragmentInfo::InlineAbsoluteHypothetical(_) | SpecificFragmentInfo::InlineAbsolute(_) | @@ -2171,6 +2215,7 @@ impl Fragment { SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::Svg(_) => true, _ => false, } @@ -2202,6 +2247,7 @@ impl Fragment { SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::Svg(_) | SpecificFragmentInfo::Generic | SpecificFragmentInfo::GeneratedContent(_) => { @@ -2530,6 +2576,7 @@ impl Fragment { SpecificFragmentInfo::GeneratedContent(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::ScannedText(_) | SpecificFragmentInfo::Svg(_) | SpecificFragmentInfo::Table | @@ -3057,6 +3104,7 @@ impl Fragment { SpecificFragmentInfo::GeneratedContent(_) | SpecificFragmentInfo::Iframe(_) | SpecificFragmentInfo::Image(_) | + SpecificFragmentInfo::Media(_) | SpecificFragmentInfo::ScannedText(_) | SpecificFragmentInfo::TruncatedFragment(_) | SpecificFragmentInfo::Svg(_) | |