aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNazım Can Altınova <canaltinova@gmail.com>2017-02-23 21:02:08 +0300
committerNazım Can Altınova <canaltinova@gmail.com>2017-02-24 15:17:23 +0300
commitc3da55dd74afae9f474d2ea0a356cbd86552d61f (patch)
tree0a6782e3f0a0d6a0198489b2146d504e2ffdd1d5
parent65624dbfc28442b58145215f524eb13aeb2cadf6 (diff)
downloadservo-c3da55dd74afae9f474d2ea0a356cbd86552d61f.tar.gz
servo-c3da55dd74afae9f474d2ea0a356cbd86552d61f.zip
Implement gecko glue for clip property
-rw-r--r--components/style/properties/gecko.mako.rs44
-rw-r--r--components/style/properties/longhand/effects.mako.rs1
2 files changed, 43 insertions, 2 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 34f6981925b..aa18b5286ad 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -2308,7 +2308,7 @@ fn static_assert() {
</%self:impl_trait>
<%self:impl_trait style_struct_name="Effects"
- skip_longhands="box-shadow filter">
+ skip_longhands="box-shadow clip filter">
pub fn set_box_shadow(&mut self, v: longhands::box_shadow::computed_value::T) {
self.gecko.mBoxShadow.replace_with_new(v.0.len() as u32);
@@ -2353,6 +2353,48 @@ fn static_assert() {
longhands::box_shadow::computed_value::T(buf)
}
+ pub fn set_clip(&mut self, v: longhands::clip::computed_value::T) {
+ use gecko_bindings::structs::NS_STYLE_CLIP_AUTO;
+ use gecko_bindings::structs::NS_STYLE_CLIP_RECT;
+ use gecko_bindings::structs::NS_STYLE_CLIP_RIGHT_AUTO;
+ use gecko_bindings::structs::NS_STYLE_CLIP_BOTTOM_AUTO;
+ use values::Either;
+
+ match v {
+ Either::First(rect) => {
+ self.gecko.mClipFlags = NS_STYLE_CLIP_RECT as u8;
+ self.gecko.mClip.x = rect.left.0;
+ self.gecko.mClip.y = rect.top.0;
+
+ if let Some(bottom) = rect.bottom {
+ self.gecko.mClip.height = bottom.0 - self.gecko.mClip.y;
+ } else {
+ self.gecko.mClip.height = 1 << 30; // NS_MAXSIZE
+ self.gecko.mClipFlags |= NS_STYLE_CLIP_BOTTOM_AUTO as u8;
+ }
+
+ if let Some(right) = rect.right {
+ self.gecko.mClip.width = right.0 - self.gecko.mClip.x;
+ } else {
+ self.gecko.mClip.width = 1 << 30; // NS_MAXSIZE
+ self.gecko.mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO as u8;
+ }
+ },
+ Either::Second(_auto) => {
+ self.gecko.mClipFlags = NS_STYLE_CLIP_AUTO as u8;
+ self.gecko.mClip.x = 0;
+ self.gecko.mClip.y = 0;
+ self.gecko.mClip.width = 0;
+ self.gecko.mClip.height = 0;
+ }
+ }
+ }
+
+ pub fn copy_clip_from(&mut self, other: &Self) {
+ self.gecko.mClip = other.gecko.mClip;
+ self.gecko.mClipFlags = other.gecko.mClipFlags;
+ }
+
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 b5dbdf60dc8..a83c80d74f5 100644
--- a/components/style/properties/longhand/effects.mako.rs
+++ b/components/style/properties/longhand/effects.mako.rs
@@ -81,7 +81,6 @@ ${helpers.predefined_type("clip",
"ClipRectOrAuto",
"computed::ClipRectOrAuto::auto()",
animatable=False,
- products="servo",
boxed="True",
spec="https://drafts.fxtf.org/css-masking/#clip-property")}