mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Don’t make up initial values not in spec for @counter-style descriptors
This commit is contained in:
parent
617e8e9768
commit
f93a9a4b10
2 changed files with 45 additions and 23 deletions
|
@ -58,10 +58,29 @@ impl<'a, 'b> AtRuleParser for CounterStyleRuleParser<'a, 'b> {
|
||||||
type AtRule = ();
|
type AtRule = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! accessor {
|
||||||
|
(#[$doc: meta] $name: tt $ident: ident: $ty: ty = !) => {
|
||||||
|
#[$doc]
|
||||||
|
pub fn $ident(&self) -> Option<&$ty> {
|
||||||
|
self.$ident.as_ref()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(#[$doc: meta] $name: tt $ident: ident: $ty: ty = $initial: expr) => {
|
||||||
|
#[$doc]
|
||||||
|
pub fn $ident(&self) -> Cow<$ty> {
|
||||||
|
if let Some(ref value) = self.$ident {
|
||||||
|
Cow::Borrowed(value)
|
||||||
|
} else {
|
||||||
|
Cow::Owned($initial)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! counter_style_descriptors {
|
macro_rules! counter_style_descriptors {
|
||||||
(
|
(
|
||||||
$( #[$doc: meta] $name: tt $ident: ident / $gecko_ident: ident: $ty: ty = $initial: expr; )+
|
$( #[$doc: meta] $name: tt $ident: ident / $gecko_ident: ident: $ty: ty = $initial: tt )+
|
||||||
) => {
|
) => {
|
||||||
/// An @counter-style rule
|
/// An @counter-style rule
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -84,14 +103,7 @@ macro_rules! counter_style_descriptors {
|
||||||
}
|
}
|
||||||
|
|
||||||
$(
|
$(
|
||||||
#[$doc]
|
accessor!(#[$doc] $name $ident: $ty = $initial);
|
||||||
pub fn $ident(&self) -> Cow<$ty> {
|
|
||||||
if let Some(ref value) = self.$ident {
|
|
||||||
Cow::Borrowed(value)
|
|
||||||
} else {
|
|
||||||
Cow::Owned($initial)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)+
|
)+
|
||||||
|
|
||||||
/// Convert to Gecko types
|
/// Convert to Gecko types
|
||||||
|
@ -147,31 +159,42 @@ macro_rules! counter_style_descriptors {
|
||||||
|
|
||||||
counter_style_descriptors! {
|
counter_style_descriptors! {
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-system
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-system
|
||||||
"system" system / eCSSCounterDesc_System: System = System::Symbolic;
|
"system" system / eCSSCounterDesc_System: System = {
|
||||||
|
System::Symbolic
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-negative
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-negative
|
||||||
"negative" negative / eCSSCounterDesc_Negative: Negative =
|
"negative" negative / eCSSCounterDesc_Negative: Negative = {
|
||||||
Negative(Symbol::String("-".to_owned()), None);
|
Negative(Symbol::String("-".to_owned()), None)
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-prefix
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-prefix
|
||||||
"prefix" prefix / eCSSCounterDesc_Prefix: Symbol = Symbol::String("".to_owned());
|
"prefix" prefix / eCSSCounterDesc_Prefix: Symbol = {
|
||||||
|
Symbol::String("".to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-suffix
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-suffix
|
||||||
"suffix" suffix / eCSSCounterDesc_Suffix: Symbol = Symbol::String(". ".to_owned());
|
"suffix" suffix / eCSSCounterDesc_Suffix: Symbol = {
|
||||||
|
Symbol::String(". ".to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-range
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-range
|
||||||
"range" range / eCSSCounterDesc_Range: Ranges =
|
"range" range / eCSSCounterDesc_Range: Ranges = {
|
||||||
Ranges(Vec::new()); // Empty Vec represents 'auto'
|
Ranges(Vec::new()) // Empty Vec represents 'auto'
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-pad
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-pad
|
||||||
"pad" pad / eCSSCounterDesc_Pad: Pad = Pad(0, Symbol::String("".to_owned()));
|
"pad" pad / eCSSCounterDesc_Pad: Pad = {
|
||||||
|
Pad(0, Symbol::String("".to_owned()))
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-fallback
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-fallback
|
||||||
"fallback" fallback / eCSSCounterDesc_Fallback: Fallback =
|
"fallback" fallback / eCSSCounterDesc_Fallback: Fallback = {
|
||||||
Fallback(CustomIdent(Atom::from("decimal")));
|
Fallback(CustomIdent(Atom::from("decimal")))
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-symbols
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-symbols
|
||||||
"symbols" symbols / eCSSCounterDesc_Symbols: Symbols = Symbols(Vec::new());
|
"symbols" symbols / eCSSCounterDesc_Symbols: Symbols = !
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-system
|
/// https://drafts.csswg.org/css-counter-styles/#counter-style-system
|
||||||
|
|
|
@ -230,8 +230,7 @@ impl ToNsCssValue for counter_style::Fallback {
|
||||||
|
|
||||||
impl ToNsCssValue for counter_style::Symbols {
|
impl ToNsCssValue for counter_style::Symbols {
|
||||||
fn convert(&self, _nscssvalue: &mut nsCSSValue) {
|
fn convert(&self, _nscssvalue: &mut nsCSSValue) {
|
||||||
if !self.0.is_empty() {
|
debug_assert!(!self.0.is_empty());
|
||||||
// FIXME: add bindings for nsCSSValueList
|
// FIXME: add bindings for nsCSSValueList
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue