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
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4506,16 +4506,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)
}