Bug 1386963 - Part 2: make image-orientation animatable. r?hiro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 03 Aug 2017 22:15:55 +0900
changeset 620480 96c647e4e2ce529eabcff12ccd73f5892251d266
parent 620479 f919f37e9f5229f72901b538e45b9449daa5ef89
child 620481 4d8c9ee4797af3ce57dc43baac17daf4afddb819
push id72044
push userbmo:dakatsuka@mozilla.com
push dateThu, 03 Aug 2017 13:23:58 +0000
reviewershiro
bugs1386963
milestone57.0a1
Bug 1386963 - Part 2: make image-orientation animatable. r?hiro MozReview-Commit-ID: F2Pw7nlaH1n
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhand/inherited_box.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -4541,16 +4541,41 @@ fn static_assert() {
         unsafe {
             bindings::Gecko_CopyImageOrientationFrom(&mut self.gecko, &other.gecko);
         }
     }
 
     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>
 
 <%self:impl_trait style_struct_name="InheritedTable"
                   skip_longhands="border-spacing">
 
     pub fn set_border_spacing(&mut self, v: longhands::border_spacing::computed_value::T) {
         self.gecko.mBorderSpacingCol = v.horizontal.0;
         self.gecko.mBorderSpacingRow = v.vertical.0;
--- a/servo/components/style/properties/longhand/inherited_box.mako.rs
+++ b/servo/components/style/properties/longhand/inherited_box.mako.rs
@@ -54,17 +54,17 @@
                          extra_servo_values="pixelated crisp-edges",
                          custom_consts=image_rendering_custom_consts,
                          animation_value_type="discrete",
                          spec="https://drafts.csswg.org/css-images/#propdef-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;
     use style_traits::ToCss;
     use values::specified::Angle;
 
     no_viewport_percentage!(SpecifiedValue);