Bug 1371115 - Part 4: implements nsStyleCounterData type properties animatable. r?hiro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Wed, 28 Jun 2017 10:23:38 +0900
changeset 601112 d45b6c4d74df17c4c16bec30ec20525045e7c238
parent 601111 8285e6415e561402adf006a162e92ecf5300d9cd
child 601113 bee531993f17e67bdbc9266dd60a46d9351e4416
push id65962
push userbmo:dakatsuka@mozilla.com
push dateWed, 28 Jun 2017 01:27:06 +0000
reviewershiro
bugs1371115
milestone56.0a1
Bug 1371115 - Part 4: implements nsStyleCounterData type properties animatable. r?hiro In this patch, implements following properties: * counter-increment * counter-reset MozReview-Commit-ID: CNdkYoOjGIt
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhand/counters.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4435,16 +4435,27 @@ clip-path
             }
         }
 
         pub fn copy_counter_${counter_property.lower()}_from(&mut self, other: &Self) {
             unsafe {
                 bindings::Gecko_CopyCounter${counter_property}sFrom(&mut self.gecko, &other.gecko)
             }
         }
+
+        pub fn clone_counter_${counter_property.lower()}(&self) -> longhands::counter_increment::computed_value::T {
+            use values::CustomIdent;
+            use gecko_string_cache::Atom;
+
+            longhands::counter_increment::computed_value::T(
+                self.gecko.m${counter_property}s.iter().map(|ref gecko_counter| {
+                    (CustomIdent(Atom::from(gecko_counter.mCounter.to_string())), gecko_counter.mValue)
+                }).collect()
+            )
+        }
     % endfor
 </%self:impl_trait>
 
 <%self:impl_trait style_struct_name="UI" skip_longhands="-moz-force-broken-image-icon">
     ${impl_simple_type_with_conversion("_moz_force_broken_image_icon", "mForceBrokenImageIcon")}
 </%self:impl_trait>
 
 <%self:impl_trait style_struct_name="XUL"
--- a/servo/components/style/properties/longhand/counters.mako.rs
+++ b/servo/components/style/properties/longhand/counters.mako.rs
@@ -228,17 +228,17 @@
         }
         if content.is_empty() {
             return Err(StyleParseError::UnspecifiedError.into());
         }
         Ok(SpecifiedValue::Items(content))
     }
 </%helpers:longhand>
 
-<%helpers:longhand name="counter-increment" animation_value_type="none"
+<%helpers:longhand name="counter-increment" animation_value_type="discrete"
                    spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment">
     use std::fmt;
     use style_traits::ToCss;
     use values::CustomIdent;
 
     #[derive(Debug, Clone, PartialEq)]
     pub struct SpecifiedValue(pub Vec<(CustomIdent, specified::Integer)>);
 
@@ -345,17 +345,17 @@
         if !counters.is_empty() {
             Ok(SpecifiedValue(counters))
         } else {
             Err(StyleParseError::UnspecifiedError.into())
         }
     }
 </%helpers:longhand>
 
-<%helpers:longhand name="counter-reset" animation_value_type="none"
+<%helpers:longhand name="counter-reset" animation_value_type="discrete"
                    spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-reset">
     pub use super::counter_increment::{SpecifiedValue, computed_value, get_initial_value};
     use super::counter_increment::parse_common;
 
     pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
                          -> Result<SpecifiedValue,ParseError<'i>> {
         parse_common(context, 0, input)
     }