Auto merge of #15710 - canaltinova:clip, r=emilio

Implement gecko glue for clip property

<!-- Please describe your changes on the following line: -->
Implemented gecko glue for clip property.

Clip property looks slightly different in gecko. `auto` top and left values are preserved as auto in [gecko](http://searchfox.org/mozilla-central/rev/39e4b25a076c59d2e7820297d62319f167871449/layout/style/nsRuleNode.cpp#10294,10316) but converted to 0 in [servo](https://dxr.mozilla.org/servo/rev/65624dbfc28442b58145215f524eb13aeb2cadf6/components/style/values/specified/mod.rs#942). Gecko is setting `NS_STYLE_CLIP_TOP_AUTO` and `NS_STYLE_CLIP_LEFT_AUTO` flags with that information. But I tried this property in stylo build and it is working correctly like this. It looks like it doesn't change the outcome of the property.
~Do we really need to set these flags?~
Manishearth and bz said that auto and 0 values are same.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1341728](https://bugzilla.mozilla.org/show_bug.cgi?id=1341728)

<!-- Either: -->
- [X] These changes do not require tests because this is stylo side change.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15710)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-02-24 07:44:48 -08:00 committed by GitHub
commit 050d9d9097
2 changed files with 43 additions and 2 deletions

View file

@ -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;

View file

@ -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")}