Small changes to AdditiveTuple struct. r?SimonSapin
draft
Small changes to AdditiveTuple struct. r?SimonSapin
MozReview-Commit-ID: 14ap4HqR4jX
--- a/servo/components/style/counter_style/mod.rs
+++ b/servo/components/style/counter_style/mod.rs
@@ -531,56 +531,58 @@ impl ToCss for Symbols {
/// https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-additive-symbols
#[derive(Debug, Clone)]
pub struct AdditiveSymbols(pub Vec<AdditiveTuple>);
impl Parse for AdditiveSymbols {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let tuples = Vec::<AdditiveTuple>::parse(context, input)?;
// FIXME maybe? https://github.com/w3c/csswg-drafts/issues/1220
- if tuples.windows(2).any(|window| window[0].value <= window[1].value) {
+ if tuples.windows(2).any(|window| window[0].weight <= window[1].weight) {
return Err(())
}
Ok(AdditiveSymbols(tuples))
}
}
impl ToCss for AdditiveSymbols {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.0.to_css(dest)
}
}
/// <integer> && <symbol>
#[derive(Debug, Clone)]
pub struct AdditiveTuple {
- value: u32,
- symbol: Symbol,
+ /// <integer>
+ pub weight: u32,
+ /// <symbol>
+ pub symbol: Symbol,
}
impl OneOrMoreCommaSeparated for AdditiveTuple {}
impl Parse for AdditiveTuple {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let symbol = input.try(|input| Symbol::parse(context, input));
- let value = input.expect_integer()?;
- if value < 0 {
+ let weight = input.expect_integer()?;
+ if weight < 0 {
return Err(())
}
let symbol = symbol.or_else(|()| Symbol::parse(context, input))?;
Ok(AdditiveTuple {
- value: value as u32,
+ weight: weight as u32,
symbol: symbol,
})
}
}
impl ToCss for AdditiveTuple {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- write!(dest, "{} ", self.value)?;
+ write!(dest, "{} ", self.weight)?;
self.symbol.to_css(dest)
}
}
/// https://drafts.csswg.org/css-counter-styles/#counter-style-speak-as
#[derive(Debug, Clone)]
pub enum SpeakAs {
/// auto