Bug 1353966 - Part 9: Implement discrete type animation for inherited box related properties. r?hiro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 19 May 2017 11:10:21 +0900
changeset 580999 267bfbe8e8249d0b02a8dc91429ddbe18df0c641
parent 580998 c473c77017af46fee515d601433744e1e92f186f
child 581000 0f24094cd5271fd975949bc6df1f7d5973d658b5
push id59742
push userbmo:dakatsuka@mozilla.com
push dateFri, 19 May 2017 06:56:54 +0000
reviewershiro
bugs1353966
milestone55.0a1
Bug 1353966 - Part 9: Implement discrete type animation for inherited box related properties. r?hiro In this patch, implement following inherited box related properties. * writing-mode * direction * text-orientation * color-adjust * image-rendering * image-orientation MozReview-Commit-ID: Grl4QmdYkH0
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
@@ -3805,16 +3805,44 @@ fn static_assert() {
         }
     }
 
     pub fn copy_image_orientation_from(&mut self, other: &Self) {
         unsafe {
             bindings::Gecko_CopyImageOrientationFrom(&mut self.gecko, &other.gecko);
         }
     }
+
+    pub fn clone_image_orientation(&self) -> longhands::image_orientation::computed_value::T {
+        use properties::longhands::image_orientation::computed_value::T;
+        use gecko_bindings::structs::root::{nsStyleImageOrientation_Bits, nsStyleImageOrientation_Angles};
+        use values::computed::Angle;
+
+        if self.gecko.mImageOrientation.mOrientation & nsStyleImageOrientation_Bits::FROM_IMAGE_MASK as u8 != 0 {
+            T::FromImage
+        } else {
+            let is_flipped =
+                self.gecko.mImageOrientation.mOrientation & nsStyleImageOrientation_Bits::FLIP_MASK as u8 != 0;
+            let orientation =
+                self.gecko.mImageOrientation.mOrientation & nsStyleImageOrientation_Bits::ORIENTATION_MASK as u8;
+            let angle =
+                if orientation == nsStyleImageOrientation_Angles::ANGLE_0 as u8 {
+                    Angle::Degree(0.0f32)
+                } else if orientation == nsStyleImageOrientation_Angles::ANGLE_90 as u8 {
+                    Angle::Degree(90.0f32)
+                } else if orientation == nsStyleImageOrientation_Angles::ANGLE_180 as u8 {
+                    Angle::Degree(180.0f32)
+                } else if orientation == nsStyleImageOrientation_Angles::ANGLE_270 as u8 {
+                    Angle::Degree(270.0f32)
+                } else {
+                    panic!("Found unexpected angle: {:?}", orientation)
+                };
+            T::AngleWithFlipped(angle, is_flipped)
+        }
+    }
 </%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
@@ -19,54 +19,54 @@
 ${helpers.single_keyword("writing-mode",
                          "horizontal-tb vertical-rl vertical-lr",
                          extra_gecko_values="sideways-rl sideways-lr",
                          extra_gecko_aliases="lr=horizontal-tb lr-tb=horizontal-tb \
                                               rl=horizontal-tb rl-tb=horizontal-tb \
                                               tb=vertical-rl   tb-rl=vertical-rl",
                          experimental=True,
                          need_clone=True,
-                         animation_value_type="none",
+                         animation_value_type="discrete",
                          spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")}
 
-${helpers.single_keyword("direction", "ltr rtl", need_clone=True, animation_value_type="none",
+${helpers.single_keyword("direction", "ltr rtl", need_clone=True, animation_value_type="discrete",
                          spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction",
                          needs_conversion=True)}
 
 ${helpers.single_keyword("text-orientation",
                          "mixed upright sideways",
                          extra_gecko_aliases="sideways-right=sideways",
                          products="gecko",
                          need_clone=True,
-                         animation_value_type="none",
+                         animation_value_type="discrete",
                          spec="https://drafts.csswg.org/css-writing-modes/#propdef-text-orientation")}
 
 // CSS Color Module Level 4
 // https://drafts.csswg.org/css-color/
 ${helpers.single_keyword("color-adjust",
                          "economy exact", products="gecko",
-                         animation_value_type="none",
+                         animation_value_type="discrete",
                          spec="https://drafts.csswg.org/css-color/#propdef-color-adjust")}
 
 <% image_rendering_custom_consts = { "crisp-edges": "CRISPEDGES",
                                      "-moz-crisp-edges": "CRISPEDGES" } %>
 // According to to CSS-IMAGES-3, `optimizespeed` and `optimizequality` are synonyms for `auto`
 // And, firefox doesn't support `pixelated` yet (https://bugzilla.mozilla.org/show_bug.cgi?id=856337)
 ${helpers.single_keyword("image-rendering",
                          "auto",
                          extra_gecko_values="optimizespeed optimizequality -moz-crisp-edges",
                          extra_servo_values="pixelated crisp-edges",
                          custom_consts=image_rendering_custom_consts,
-                         animation_value_type="none",
+                         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;
 
     use values::HasViewportPercentage;
     no_viewport_percentage!(SpecifiedValue);