From c5de3e56a25b137e1e58ca7bf61c755c51e254f0 Mon Sep 17 00:00:00 2001 From: Daisuke Akatsuka Date: Thu, 3 Aug 2017 22:34:14 +0900 Subject: [PATCH] make image-orientation animatable --- components/style/properties/gecko.mako.rs | 25 +++++++++++++++++++ .../properties/longhand/inherited_box.mako.rs | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 3bf4cb2c488..839fdeb1dc7 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -4546,6 +4546,31 @@ fn static_assert() { pub fn reset_image_orientation(&mut self, other: &Self) { self.copy_image_orientation_from(other) } + + pub fn clone_image_orientation(&self) -> longhands::image_orientation::computed_value::T { + use gecko_bindings::structs::{nsStyleImageOrientation_Bits, nsStyleImageOrientation_Angles}; + use properties::longhands::image_orientation::computed_value::{Orientation, T}; + + let gecko_orientation = self.gecko.mImageOrientation.mOrientation; + if gecko_orientation & nsStyleImageOrientation_Bits::FROM_IMAGE_MASK as u8 != 0 { + T::FromImage + } else { + const ANGLE0: u8 = nsStyleImageOrientation_Angles::ANGLE_0 as u8; + const ANGLE90: u8 = nsStyleImageOrientation_Angles::ANGLE_90 as u8; + const ANGLE180: u8 = nsStyleImageOrientation_Angles::ANGLE_180 as u8; + const ANGLE270: u8 = nsStyleImageOrientation_Angles::ANGLE_270 as u8; + + let flip = gecko_orientation & nsStyleImageOrientation_Bits::FLIP_MASK as u8 != 0; + let orientation = match gecko_orientation & nsStyleImageOrientation_Bits::ORIENTATION_MASK as u8 { + ANGLE0 => Orientation::Angle0, + ANGLE90 => Orientation::Angle90, + ANGLE180 => Orientation::Angle180, + ANGLE270 => Orientation::Angle270, + _ => unreachable!() + }; + T::AngleWithFlipped(orientation, flip) + } + } <%self:impl_trait style_struct_name="InheritedTable" diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index 2a8bff1a120..99d9216fce3 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -59,7 +59,7 @@ ${helpers.single_keyword("image-rendering", // Image Orientation <%helpers:longhand name="image-orientation" products="gecko" - animation_value_type="none" + animation_value_type="discrete" spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \ /// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation"> use std::fmt;