diff options
-rw-r--r-- | components/layout/construct.rs | 8 | ||||
-rw-r--r-- | components/style/properties/longhand/list.mako.rs | 80 |
2 files changed, 7 insertions, 81 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 5cc982fcc3f..f9b2d61ab91 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -43,7 +43,7 @@ use std::marker::PhantomData; use std::mem; use std::sync::Arc; use std::sync::atomic::Ordering; -use style::computed_values::{caption_side, display, empty_cells, float, list_style_position}; +use style::computed_values::{caption_side, display, empty_cells, float, list_style_image, list_style_position}; use style::computed_values::content::ContentItem; use style::computed_values::position; use style::context::SharedStyleContext; @@ -1264,14 +1264,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> fn build_flow_for_list_item(&mut self, node: &ConcreteThreadSafeLayoutNode, flotation: float::T) -> ConstructionResult { let flotation = FloatKind::from_property(flotation); - let marker_fragments = match node.style(self.style_context()).get_list().list_style_image.0 { - Some(ref url) => { + let marker_fragments = match node.style(self.style_context()).get_list().list_style_image { + list_style_image::T::Url(ref url, ref _extra_data) => { let image_info = box ImageFragmentInfo::new(node, Some((*url).clone()), &self.layout_context.shared); vec![Fragment::new(node, SpecificFragmentInfo::Image(image_info), self.layout_context)] } - None => { + list_style_image::T::None => { match ListStyleTypeContent::from_list_style_type(node.style(self.style_context()) .get_list() .list_style_type) { diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 77e0af5797a..b8afa7e9249 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -26,83 +26,9 @@ ${helpers.single_keyword("list-style-type", """ gecko_constant_prefix="NS_STYLE_LIST_STYLE", animatable=False)} -<%helpers:longhand name="list-style-image" animatable="False"> - use cssparser::{ToCss, Token}; - use std::fmt; - use url::Url; - use values::LocalToCss; - use values::NoViewportPercentage; - - impl NoViewportPercentage for SpecifiedValue {} - - #[derive(Debug, Clone, PartialEq, Eq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub enum SpecifiedValue { - None, - Url(Url), - } - - impl ToCss for SpecifiedValue { - fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - match *self { - SpecifiedValue::None => dest.write_str("none"), - SpecifiedValue::Url(ref url) => url.to_css(dest), - } - } - } - - pub mod computed_value { - use cssparser::{ToCss, Token}; - use std::fmt; - use url::Url; - use values::LocalToCss; - - #[derive(Debug, Clone, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct T(pub Option<Url>); - - impl ToCss for T { - fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - match self.0 { - None => dest.write_str("none"), - Some(ref url) => url.to_css(dest), - } - } - } - } - - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - - #[inline] - fn to_computed_value(&self, _context: &Context) -> computed_value::T { - match *self { - SpecifiedValue::None => computed_value::T(None), - SpecifiedValue::Url(ref url) => computed_value::T(Some(url.clone())), - } - } - - #[inline] - fn from_computed_value(computed: &computed_value::T) -> Self { - match *computed { - computed_value::T(None) => SpecifiedValue::None, - computed_value::T(Some(ref url)) => SpecifiedValue::Url(url.clone()), - } - } - } - - pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { - if input.try(|input| input.expect_ident_matching("none")).is_ok() { - Ok(SpecifiedValue::None) - } else { - Ok(SpecifiedValue::Url(context.parse_url(&*try!(input.expect_url())))) - } - } - #[inline] - pub fn get_initial_value() -> computed_value::T { - computed_value::T(None) - } -</%helpers:longhand> +${helpers.predefined_type("list-style-image", "UrlOrNone", "computed_value::T::None", + needs_context=True, + animatable="False")} <%helpers:longhand name="quotes" animatable="False"> use std::borrow::Cow; |