Auto merge of #16278 - hiikezoe:make-letter-spacing-animatable, r=emilio

Make letter-spacing animatable.

This is a PR of https://bugzilla.mozilla.org/show_bug.cgi?id=1353921

From the spec: 'normal' value computes to zero.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] There are tests for these changes in web-platform-test (web-animations/animation-model/animation-types/interpolation-per-property.html)

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16278)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-05 18:58:35 -05:00 committed by GitHub
commit c41ade06eb
2 changed files with 33 additions and 2 deletions

View file

@ -2882,6 +2882,15 @@ fn static_assert() {
} }
} }
pub fn clone_letter_spacing(&self) -> longhands::letter_spacing::computed_value::T {
use properties::longhands::letter_spacing::computed_value::T;
match self.gecko.mLetterSpacing.as_value() {
CoordDataValue::Normal => T(None),
CoordDataValue::Coord(coord) => T(Some(Au(coord))),
_ => unreachable!("Unexpected computed value for letter-spacing"),
}
}
<%call expr="impl_coord_copy('letter_spacing', 'mLetterSpacing')"></%call> <%call expr="impl_coord_copy('letter_spacing', 'mLetterSpacing')"></%call>
pub fn set_word_spacing(&mut self, v: longhands::word_spacing::computed_value::T) { pub fn set_word_spacing(&mut self, v: longhands::word_spacing::computed_value::T) {

View file

@ -404,8 +404,7 @@ ${helpers.single_keyword("text-align-last",
% endif % endif
</%helpers:longhand> </%helpers:longhand>
// FIXME: This prop should be animatable. <%helpers:longhand name="letter-spacing" boxed="True" animatable="True"
<%helpers:longhand name="letter-spacing" boxed="True" animatable="False"
spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing"> spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -438,9 +437,32 @@ ${helpers.single_keyword("text-align-last",
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
use properties::animated_properties::Interpolate;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Option<Au>); pub struct T(pub Option<Au>);
impl Interpolate for T {
#[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (self, other) {
(&T(Some(ref this)), &T(Some(ref other))) => {
Ok(T(this.interpolate(other, progress).ok()))
},
(&T(Some(ref this)), &T(None)) => {
Ok(T(this.interpolate(&Au(0), progress).ok()))
},
(&T(None), &T(Some(ref other))) => {
Ok(T(Au(0).interpolate(other, progress).ok()))
},
(&T(None), &T(None)) => {
Ok(T(None))
},
}
}
}
} }
impl ToCss for computed_value::T { impl ToCss for computed_value::T {