Make letter-spacing animatable.

From the spec: 'normal' value computes to zero.
This commit is contained in:
Hiroyuki Ikezoe 2017-04-06 08:30:11 +09:00
parent b89dc6a08c
commit b801e07ec5
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>
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
</%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 {