mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add string support for list-style-type.
This commit is contained in:
parent
1df685dc40
commit
505809528c
4 changed files with 31 additions and 11 deletions
|
@ -3149,7 +3149,16 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T) {
|
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) {
|
pub fn copy_list_style_type_from(&mut self, other: &Self) {
|
||||||
|
|
|
@ -31,8 +31,9 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
||||||
animation_value_type="none",
|
animation_value_type="none",
|
||||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")}
|
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")}
|
||||||
% else:
|
% 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">
|
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type">
|
||||||
|
use cssparser;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use values::CustomIdent;
|
use values::CustomIdent;
|
||||||
|
@ -44,9 +45,12 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
use values::generics::CounterStyleOrNone;
|
use values::generics::CounterStyleOrNone;
|
||||||
|
|
||||||
/// <counter-style> | none
|
/// <counter-style> | <string> | none
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct T(pub CounterStyleOrNone);
|
pub enum T {
|
||||||
|
CounterStyle(CounterStyleOrNone),
|
||||||
|
String(String),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
|
@ -54,7 +58,10 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
||||||
|
|
||||||
impl ToCss for SpecifiedValue {
|
impl ToCss for SpecifiedValue {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&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.
|
/// attribute is considered here.
|
||||||
pub fn from_gecko_keyword(value: u32) -> Self {
|
pub fn from_gecko_keyword(value: u32) -> Self {
|
||||||
use gecko_bindings::structs;
|
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_
|
CounterStyleOrNone::None_
|
||||||
} else {
|
} else {
|
||||||
<%
|
<%
|
||||||
|
@ -86,16 +93,20 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
computed_value::T(CounterStyleOrNone::disc())
|
computed_value::T::CounterStyle(CounterStyleOrNone::disc())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||||
SpecifiedValue(CounterStyleOrNone::disc())
|
SpecifiedValue::CounterStyle(CounterStyleOrNone::disc())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||||
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())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
list_style_type::SpecifiedValue::none
|
list_style_type::SpecifiedValue::none
|
||||||
% else:
|
% else:
|
||||||
use values::generics::CounterStyleOrNone;
|
use values::generics::CounterStyleOrNone;
|
||||||
list_style_type::SpecifiedValue(CounterStyleOrNone::None_)
|
list_style_type::SpecifiedValue::CounterStyle(CounterStyleOrNone::None_)
|
||||||
% endif
|
% endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1844,7 +1844,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations:
|
||||||
},
|
},
|
||||||
FontStyle => longhands::font_style::computed_value::T::from_gecko_keyword(value).into(),
|
FontStyle => longhands::font_style::computed_value::T::from_gecko_keyword(value).into(),
|
||||||
FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value),
|
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),
|
MozMathVariant => longhands::_moz_math_variant::SpecifiedValue::from_gecko_keyword(value),
|
||||||
WhiteSpace => longhands::white_space::SpecifiedValue::from_gecko_keyword(value),
|
WhiteSpace => longhands::white_space::SpecifiedValue::from_gecko_keyword(value),
|
||||||
CaptionSide => longhands::caption_side::SpecifiedValue::from_gecko_keyword(value),
|
CaptionSide => longhands::caption_side::SpecifiedValue::from_gecko_keyword(value),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue