mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +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",
|
animation_value_type="discrete",
|
||||||
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="discrete" boxed="True"
|
${helpers.predefined_type("list-style-type",
|
||||||
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type">
|
"ListStyleType",
|
||||||
use values::CustomIdent;
|
"computed::ListStyleType::disc()",
|
||||||
use values::generics::CounterStyleOrNone;
|
initial_specified_value="specified::ListStyleType::disc()",
|
||||||
|
animation_value_type="discrete",
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
boxed="True",
|
||||||
|
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")}
|
||||||
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>
|
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
${helpers.predefined_type("list-style-image",
|
${helpers.predefined_type("list-style-image",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//! `list` computed values.
|
//! `list` computed values.
|
||||||
|
|
||||||
pub use values::specified::list::{ListStyleImage, Quotes};
|
pub use values::specified::list::{ListStyleImage, Quotes};
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub use values::specified::list::ListStyleType;
|
||||||
|
|
||||||
impl Quotes {
|
impl Quotes {
|
||||||
/// Initial value for `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::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||||
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
|
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
|
||||||
pub use self::list::{ListStyleImage, Quotes};
|
pub use self::list::{ListStyleImage, Quotes};
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub use self::list::ListStyleType;
|
||||||
pub use self::outline::OutlineStyle;
|
pub use self::outline::OutlineStyle;
|
||||||
pub use self::percentage::Percentage;
|
pub use self::percentage::Percentage;
|
||||||
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
|
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
|
||||||
|
|
|
@ -9,8 +9,70 @@ use parser::{Parse, ParserContext};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
|
||||||
use values::{Either, None_};
|
use values::{Either, None_};
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
use values::CustomIdent;
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
use values::generics::CounterStyleOrNone;
|
||||||
use values::specified::UrlOrNone;
|
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.
|
/// Specified and computed `list-style-image` property.
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||||
pub struct ListStyleImage(pub UrlOrNone);
|
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::{NoCalcLength, ViewportPercentageLength};
|
||||||
pub use self::length::NonNegativeLengthOrPercentage;
|
pub use self::length::NonNegativeLengthOrPercentage;
|
||||||
pub use self::list::{ListStyleImage, Quotes};
|
pub use self::list::{ListStyleImage, Quotes};
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
pub use self::list::ListStyleType;
|
||||||
pub use self::outline::OutlineStyle;
|
pub use self::outline::OutlineStyle;
|
||||||
pub use self::rect::LengthOrNumberRect;
|
pub use self::rect::LengthOrNumberRect;
|
||||||
pub use self::percentage::Percentage;
|
pub use self::percentage::Percentage;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue