Skip to content

Commit

Permalink
Auto merge of #16278 - hiikezoe:make-letter-spacing-animatable, r=emilio
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo committed Apr 5, 2017
2 parents b89dc6a + b801e07 commit c41ade0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
9 changes: 9 additions & 0 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -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) {
Expand Down
26 changes: 24 additions & 2 deletions components/style/properties/longhand/inherited_text.mako.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c41ade0

Please sign in to comment.