Small changes to AdditiveTuple struct. r?SimonSapin draft
authorXidorn Quan <me@upsuper.org>
Fri, 05 May 2017 15:02:24 +1000
changeset 577628 c52463b5f75b85a4cf7aeae74a902216f6665bf4
parent 577627 7be683d4dd93afa57bc130664c41d2782f05b273
child 577629 0fb67f6606718b2efc177c9fcb3a86a07bbf203b
push id58742
push userxquan@mozilla.com
push dateMon, 15 May 2017 05:03:58 +0000
reviewersSimonSapin
milestone55.0a1
Small changes to AdditiveTuple struct. r?SimonSapin MozReview-Commit-ID: 14ap4HqR4jX
servo/components/style/counter_style/mod.rs
--- 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