mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
parent
54f8cc37c5
commit
214b423bbd
5 changed files with 75 additions and 63 deletions
|
@ -30,69 +30,13 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
|
|||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")}
|
||||
% else:
|
||||
<%helpers:longhand name="list-style-type" animation_value_type="discrete" boxed="True"
|
||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type">
|
||||
use values::CustomIdent;
|
||||
use values::generics::CounterStyleOrNone;
|
||||
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
|
||||
pub mod computed_value {
|
||||
use values::generics::CounterStyleOrNone;
|
||||
|
||||
/// <counter-style> | <string> | none
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum T {
|
||||
CounterStyle(CounterStyleOrNone),
|
||||
String(String),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl SpecifiedValue {
|
||||
/// Convert from gecko keyword to list-style-type.
|
||||
///
|
||||
/// This should only be used for mapping type attribute to
|
||||
/// list-style-type, and thus only values possible in that
|
||||
/// attribute is considered here.
|
||||
pub fn from_gecko_keyword(value: u32) -> Self {
|
||||
use gecko_bindings::structs;
|
||||
SpecifiedValue::CounterStyle(if value == structs::NS_STYLE_LIST_STYLE_NONE {
|
||||
CounterStyleOrNone::None
|
||||
} else {
|
||||
<%
|
||||
values = """disc circle square decimal lower-roman
|
||||
upper-roman lower-alpha upper-alpha""".split()
|
||||
%>
|
||||
CounterStyleOrNone::Name(CustomIdent(match value {
|
||||
% for style in values:
|
||||
structs::NS_STYLE_LIST_STYLE_${style.replace('-', '_').upper()} => atom!("${style}"),
|
||||
% endfor
|
||||
_ => unreachable!("Unknown counter style keyword value"),
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T::CounterStyle(CounterStyleOrNone::disc())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
SpecifiedValue::CounterStyle(CounterStyleOrNone::disc())
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
Ok(if let Ok(style) = input.try(|i| CounterStyleOrNone::parse(context, i)) {
|
||||
SpecifiedValue::CounterStyle(style)
|
||||
} else {
|
||||
SpecifiedValue::String(input.expect_string()?.as_ref().to_owned())
|
||||
})
|
||||
}
|
||||
</%helpers:longhand>
|
||||
${helpers.predefined_type("list-style-type",
|
||||
"ListStyleType",
|
||||
"computed::ListStyleType::disc()",
|
||||
initial_specified_value="specified::ListStyleType::disc()",
|
||||
animation_value_type="discrete",
|
||||
boxed="True",
|
||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")}
|
||||
% endif
|
||||
|
||||
${helpers.predefined_type("list-style-image",
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
//! `list` computed values.
|
||||
|
||||
pub use values::specified::list::{ListStyleImage, Quotes};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use values::specified::list::ListStyleType;
|
||||
|
||||
impl Quotes {
|
||||
/// Initial value for `quotes`.
|
||||
|
|
|
@ -55,6 +55,8 @@ pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNone, LengthOrNum
|
|||
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
|
||||
pub use self::list::{ListStyleImage, Quotes};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use self::list::ListStyleType;
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::percentage::Percentage;
|
||||
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
|
||||
|
|
|
@ -9,8 +9,70 @@ use parser::{Parse, ParserContext};
|
|||
use std::fmt;
|
||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::{Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::CustomIdent;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::generics::CounterStyleOrNone;
|
||||
use values::specified::UrlOrNone;
|
||||
|
||||
/// Specified and computed `list-style-type` property.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum ListStyleType {
|
||||
/// <counter-style> | none
|
||||
CounterStyle(CounterStyleOrNone),
|
||||
/// <string>
|
||||
String(String),
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl ListStyleType {
|
||||
/// Initial specified value for `list-style-type`.
|
||||
#[inline]
|
||||
pub fn disc() -> Self {
|
||||
ListStyleType::CounterStyle(CounterStyleOrNone::disc())
|
||||
}
|
||||
|
||||
/// Convert from gecko keyword to list-style-type.
|
||||
///
|
||||
/// This should only be used for mapping type attribute to
|
||||
/// list-style-type, and thus only values possible in that
|
||||
/// attribute is considered here.
|
||||
pub fn from_gecko_keyword(value: u32) -> Self {
|
||||
use gecko_bindings::structs;
|
||||
|
||||
let counter_style = if value == structs::NS_STYLE_LIST_STYLE_NONE {
|
||||
CounterStyleOrNone::None
|
||||
} else {
|
||||
CounterStyleOrNone::Name(CustomIdent(match value {
|
||||
structs::NS_STYLE_LIST_STYLE_DISC => atom!("disc"),
|
||||
structs::NS_STYLE_LIST_STYLE_CIRCLE => atom!("circle"),
|
||||
structs::NS_STYLE_LIST_STYLE_SQUARE => atom!("square"),
|
||||
structs::NS_STYLE_LIST_STYLE_DECIMAL => atom!("decimal"),
|
||||
structs::NS_STYLE_LIST_STYLE_LOWER_ROMAN => atom!("lower-roman"),
|
||||
structs::NS_STYLE_LIST_STYLE_UPPER_ROMAN => atom!("upper-roman"),
|
||||
structs::NS_STYLE_LIST_STYLE_LOWER_ALPHA => atom!("lower-alpha"),
|
||||
structs::NS_STYLE_LIST_STYLE_UPPER_ALPHA => atom!("upper-alpha"),
|
||||
_ => unreachable!("Unknown counter style keyword value"),
|
||||
}))
|
||||
};
|
||||
|
||||
ListStyleType::CounterStyle(counter_style)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl Parse for ListStyleType {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<ListStyleType, ParseError<'i>> {
|
||||
Ok(if let Ok(style) = input.try(|i| CounterStyleOrNone::parse(context, i)) {
|
||||
ListStyleType::CounterStyle(style)
|
||||
} else {
|
||||
ListStyleType::String(input.expect_string()?.as_ref().to_owned())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Specified and computed `list-style-image` property.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
pub struct ListStyleImage(pub UrlOrNone);
|
||||
|
|
|
@ -50,6 +50,8 @@ pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
|
|||
pub use self::length::{NoCalcLength, ViewportPercentageLength};
|
||||
pub use self::length::NonNegativeLengthOrPercentage;
|
||||
pub use self::list::{ListStyleImage, Quotes};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use self::list::ListStyleType;
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::rect::LengthOrNumberRect;
|
||||
pub use self::percentage::Percentage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue