implements nsStyleCoord type properties animatable

This commit is contained in:
Daisuke Akatsuka 2017-07-05 12:54:45 +09:00
parent 006037f798
commit 983361eb0f
4 changed files with 53 additions and 12 deletions

View file

@ -22,6 +22,7 @@ use values::computed::{MaxLength, MozLength};
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use values::generics::CounterStyleOrNone;
use values::generics::basic_shape::ShapeRadius;
use values::generics::gecko::ScrollSnapPoint;
use values::generics::grid::{TrackBreadth, TrackKeyword};
use values::specified::Percentage;
@ -368,6 +369,30 @@ impl GeckoStyleCoordConvertible for MaxLength {
}
}
impl GeckoStyleCoordConvertible for ScrollSnapPoint<LengthOrPercentage> {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
match self.repeated() {
None => coord.set_value(CoordDataValue::None),
Some(l) => l.to_gecko_style_coord(coord),
};
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::root::nsStyleUnit;
use values::generics::gecko::ScrollSnapPoint;
Some(
match coord.unit() {
nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None,
nsStyleUnit::eStyleUnit_Coord | nsStyleUnit::eStyleUnit_Percent =>
ScrollSnapPoint::Repeat(LengthOrPercentage::from_gecko_style_coord(coord)
.expect("coord could not convert to LengthOrPercentage")),
x => panic!("Unexpected unit {:?}", x)
}
)
}
}
/// Convert a given RGBA value to `nscolor`.
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
((rgba.alpha as u32) << 24) |