mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add 'pad' descritor of @counter-style
This commit is contained in:
parent
6f79684468
commit
e27de3842d
2 changed files with 38 additions and 0 deletions
|
@ -145,6 +145,9 @@ counter_style_descriptors! {
|
|||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-range
|
||||
"range" range / eCSSCounterDesc_Range: Ranges =
|
||||
Ranges(Vec::new()); // Empty Vec represents 'auto'
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-pad
|
||||
"pad" pad / eCSSCounterDesc_Pad: Pad = Pad(0, Symbol::String("".to_owned()));
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-system
|
||||
|
@ -331,3 +334,27 @@ fn bound_to_css<W>(range: Option<i32>, dest: &mut W) -> fmt::Result where W: fmt
|
|||
dest.write_str("infinite")
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-pad
|
||||
#[derive(Debug)]
|
||||
pub struct Pad(pub u32, pub Symbol);
|
||||
|
||||
impl Parse for Pad {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
let pad_with = input.try(|input| Symbol::parse(context, input));
|
||||
let min_length = input.expect_integer()?;
|
||||
if min_length < 0 {
|
||||
return Err(())
|
||||
}
|
||||
let pad_with = pad_with.or_else(|()| Symbol::parse(context, input))?;
|
||||
Ok(Pad(min_length as u32, pad_with))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Pad {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
write!(dest, "{}", self.0)?;
|
||||
dest.write_char(' ')?;
|
||||
self.1.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,3 +210,14 @@ impl ToNsCssValue for counter_style::Ranges {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToNsCssValue for counter_style::Pad {
|
||||
fn convert(&self, _nscssvalue: &mut nsCSSValue) {
|
||||
let mut min_length = nsCSSValue::null();
|
||||
let mut pad_with = nsCSSValue::null();
|
||||
min_length.set_integer(self.0 as i32);
|
||||
pad_with.set_from(&self.1);
|
||||
// FIXME: add bindings for nsCSSValue::SetPairValue
|
||||
//nscssvalue.set_pair(min_length, pad_with);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue