Bug 1356162 part 1 - Make clip animatable. r?hiro draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Tue, 18 Apr 2017 14:30:15 +0900
changeset 566199 7573b5578247f2c4abaeca3162c662048a413fcd
parent 566156 8b854986038cf3f3f240697e27ef48ea65914c13
child 566200 4c688fa8765ae701646f741429914f48cb3c32ff
push id55134
push userbmo:mantaroh@gmail.com
push dateFri, 21 Apr 2017 04:23:59 +0000
reviewershiro
bugs1356162
milestone55.0a1
Bug 1356162 part 1 - Make clip animatable. r?hiro MozReview-Commit-ID: 3HGJJ5qeQvd
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhand/effects.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2981,16 +2981,60 @@ fn static_assert() {
         }
     }
 
     pub fn copy_clip_from(&mut self, other: &Self) {
         self.gecko.mClip = other.gecko.mClip;
         self.gecko.mClipFlags = other.gecko.mClipFlags;
     }
 
+    pub fn clone_clip(&self) -> longhands::clip::computed_value::T {
+        use gecko_bindings::structs::NS_STYLE_CLIP_AUTO;
+        use gecko_bindings::structs::NS_STYLE_CLIP_BOTTOM_AUTO;
+        use gecko_bindings::structs::NS_STYLE_CLIP_LEFT_AUTO;
+        use gecko_bindings::structs::NS_STYLE_CLIP_RIGHT_AUTO;
+        use gecko_bindings::structs::NS_STYLE_CLIP_TOP_AUTO;
+        use values::computed::{ClipRect, ClipRectOrAuto};
+        use values::Either;
+
+        if self.gecko.mClipFlags == NS_STYLE_CLIP_AUTO as u8 {
+            ClipRectOrAuto::auto()
+        } else {
+            let left = if self.gecko.mClipFlags & NS_STYLE_CLIP_LEFT_AUTO as u8 != 0 {
+                debug_assert!(self.gecko.mClip.x == 0);
+                None
+            } else {
+                Some(Au(self.gecko.mClip.x))
+            };
+
+            let top = if self.gecko.mClipFlags & NS_STYLE_CLIP_TOP_AUTO as u8 != 0 {
+                debug_assert!(self.gecko.mClip.y == 0);
+                None
+            } else {
+                Some(Au(self.gecko.mClip.y))
+            };
+
+            let bottom = if self.gecko.mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO as u8 != 0 {
+                debug_assert!(self.gecko.mClip.height == 1 << 30); // NS_MAXSIZE
+                None
+            } else {
+                Some(Au(self.gecko.mClip.y + self.gecko.mClip.height))
+            };
+
+            let right = if self.gecko.mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO as u8 != 0 {
+                debug_assert!(self.gecko.mClip.width == 1 << 30); // NS_MAXSIZE
+                None
+            } else {
+                Some(Au(self.gecko.mClip.x + self.gecko.mClip.width))
+            };
+
+            Either::First(ClipRect { top: top, right: right, bottom: bottom, left: left, })
+        }
+    }
+
     pub fn set_filter(&mut self, v: longhands::filter::computed_value::T) {
         use properties::longhands::filter::computed_value::Filter::*;
         use gecko_bindings::structs::nsCSSShadowArray;
         use gecko_bindings::structs::nsStyleFilter;
         use gecko_bindings::structs::NS_STYLE_FILTER_BLUR;
         use gecko_bindings::structs::NS_STYLE_FILTER_BRIGHTNESS;
         use gecko_bindings::structs::NS_STYLE_FILTER_CONTRAST;
         use gecko_bindings::structs::NS_STYLE_FILTER_GRAYSCALE;
--- a/servo/components/style/properties/longhand/effects.mako.rs
+++ b/servo/components/style/properties/longhand/effects.mako.rs
@@ -72,21 +72,20 @@
         }
     }
 
     pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<specified::Shadow, ()> {
         specified::Shadow::parse(context, input, false)
     }
 </%helpers:vector_longhand>
 
-// FIXME: This prop should be animatable
 ${helpers.predefined_type("clip",
                           "ClipRectOrAuto",
                           "computed::ClipRectOrAuto::auto()",
-                          animation_type="none",
+                          animation_type="normal",
                           boxed="True",
                           spec="https://drafts.fxtf.org/css-masking/#clip-property")}
 
 // FIXME: This prop should be animatable
 <%helpers:longhand name="filter" animation_type="none" extra_prefixes="webkit"
                    flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
                    spec="https://drafts.fxtf.org/filters/#propdef-filter">
     //pub use self::computed_value::T as SpecifiedValue;