diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2290825d525..cc89db5e087 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3149,7 +3149,16 @@ fn static_assert() { } pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T) { - v.0.to_gecko_value(&mut self.gecko.mCounterStyle); + use gecko_bindings::bindings::Gecko_SetCounterStyleToString; + use nsstring::{nsACString, nsCString}; + use self::longhands::list_style_type::computed_value::T; + match v { + T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle), + T::String(s) => unsafe { + Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle, + &nsCString::from(s) as &nsACString) + } + } } pub fn copy_list_style_type_from(&mut self, other: &Self) { diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 90d9a9e3f67..7ec59f29e14 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -31,8 +31,9 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu animation_value_type="none", spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")} % else: - <%helpers:longhand name="list-style-type" animation_value_type="none" + <%helpers:longhand name="list-style-type" animation_value_type="none" boxed="True" spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type"> + use cssparser; use std::fmt; use style_traits::ToCss; use values::CustomIdent; @@ -44,9 +45,12 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu pub mod computed_value { use values::generics::CounterStyleOrNone; - /// | none + /// | | none #[derive(Debug, Clone, PartialEq, Eq)] - pub struct T(pub CounterStyleOrNone); + pub enum T { + CounterStyle(CounterStyleOrNone), + String(String), + } } impl ComputedValueAsSpecified for SpecifiedValue {} @@ -54,7 +58,10 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu impl ToCss for SpecifiedValue { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - self.0.to_css(dest) + match *self { + SpecifiedValue::CounterStyle(ref s) => s.to_css(dest), + SpecifiedValue::String(ref s) => cssparser::serialize_string(s, dest) + } } } @@ -67,7 +74,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu /// attribute is considered here. pub fn from_gecko_keyword(value: u32) -> Self { use gecko_bindings::structs; - SpecifiedValue(if value == structs::NS_STYLE_LIST_STYLE_NONE { + SpecifiedValue::CounterStyle(if value == structs::NS_STYLE_LIST_STYLE_NONE { CounterStyleOrNone::None_ } else { <% @@ -86,16 +93,20 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu #[inline] pub fn get_initial_value() -> computed_value::T { - computed_value::T(CounterStyleOrNone::disc()) + computed_value::T::CounterStyle(CounterStyleOrNone::disc()) } #[inline] pub fn get_initial_specified_value() -> SpecifiedValue { - SpecifiedValue(CounterStyleOrNone::disc()) + SpecifiedValue::CounterStyle(CounterStyleOrNone::disc()) } pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - CounterStyleOrNone::parse(context, input).map(SpecifiedValue) + Ok(if let Ok(style) = input.try(|i| CounterStyleOrNone::parse(context, i)) { + SpecifiedValue::CounterStyle(style) + } else { + SpecifiedValue::String(input.expect_string()?.into_owned()) + }) } % endif diff --git a/components/style/properties/shorthand/list.mako.rs b/components/style/properties/shorthand/list.mako.rs index 2aa0f2a6c82..cb7cc858160 100644 --- a/components/style/properties/shorthand/list.mako.rs +++ b/components/style/properties/shorthand/list.mako.rs @@ -61,7 +61,7 @@ list_style_type::SpecifiedValue::none % else: use values::generics::CounterStyleOrNone; - list_style_type::SpecifiedValue(CounterStyleOrNone::None_) + list_style_type::SpecifiedValue::CounterStyle(CounterStyleOrNone::None_) % endif } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 55bfc2baec8..820c5f43695 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1844,7 +1844,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations: }, FontStyle => longhands::font_style::computed_value::T::from_gecko_keyword(value).into(), FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value), - ListStyleType => longhands::list_style_type::SpecifiedValue::from_gecko_keyword(value), + ListStyleType => Box::new(longhands::list_style_type::SpecifiedValue::from_gecko_keyword(value)), MozMathVariant => longhands::_moz_math_variant::SpecifiedValue::from_gecko_keyword(value), WhiteSpace => longhands::white_space::SpecifiedValue::from_gecko_keyword(value), CaptionSide => longhands::caption_side::SpecifiedValue::from_gecko_keyword(value),