Commit a403bc44 authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe
Browse files

servo: Merge #16278 - Make letter-spacing animatable (from...

servo: Merge #16278 - Make letter-spacing animatable (from hiikezoe:make-letter-spacing-animatable); r=emilio

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. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: c41ade06eb2ef815de41407a411bd7f3b9af61f8

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : d33bb06b1f3fc6a93799581ef48097b526c34428
parent adb8a3db
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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>

    pub fn set_word_spacing(&mut self, v: longhands::word_spacing::computed_value::T) {
+24 −2
Original line number Diff line number Diff line
@@ -404,8 +404,7 @@ ${helpers.single_keyword("text-align-last",
    % endif
</%helpers:longhand>

// FIXME: This prop should be animatable.
<%helpers:longhand name="letter-spacing" boxed="True" animatable="False"
<%helpers:longhand name="letter-spacing" boxed="True" animatable="True"
                   spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing">
    use std::fmt;
    use style_traits::ToCss;
@@ -438,9 +437,32 @@ ${helpers.single_keyword("text-align-last",

    pub mod computed_value {
        use app_units::Au;
        use properties::animated_properties::Interpolate;

        #[derive(Debug, Clone, PartialEq)]
        #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
        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 {