From ba34eacee0eb483d6b43dbcb0b74738670cca11b Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Fri, 21 Apr 2017 15:20:59 +0900 Subject: [PATCH] Make clip property animatable. --- components/style/properties/gecko.mako.rs | 44 +++++++++++++++++++ .../style/properties/longhand/effects.mako.rs | 3 +- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 87f5ad0d418..643f588c146 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2986,6 +2986,50 @@ fn static_assert() { 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; diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index efc7b48088e..16df2dc6eed 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -77,11 +77,10 @@ ${helpers.predefined_type("opacity", } -// 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")}