diff options
author | Nazım Can Altınova <canaltinova@gmail.com> | 2016-11-03 19:35:00 +0300 |
---|---|---|
committer | Nazım Can Altınova <canaltinova@gmail.com> | 2016-11-06 20:08:27 +0300 |
commit | 6014c0c8edc7363ddaf2abc79e98a81237ce79d8 (patch) | |
tree | 4d1839b7e4007f8a368a17ac2bb5c570640117d6 | |
parent | 8387d7e8b6fbebf2fa8aa00212a59e4fc6665dbb (diff) | |
download | servo-6014c0c8edc7363ddaf2abc79e98a81237ce79d8.tar.gz servo-6014c0c8edc7363ddaf2abc79e98a81237ce79d8.zip |
Implement gecko glue for border-image-slice
-rw-r--r-- | components/style/properties/gecko.mako.rs | 33 | ||||
-rw-r--r-- | components/style/properties/longhand/border.mako.rs | 2 |
2 files changed, 33 insertions, 2 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 287dfe7d20d..f1bbfe8fe35 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -641,7 +641,7 @@ fn static_assert() { for x in CORNERS]) %> <%self:impl_trait style_struct_name="Border" skip_longhands="${skip_border_longhands} border-image-source border-image-outset - border-image-repeat border-image-width" + border-image-repeat border-image-width border-image-slice" skip_additionals="*"> % for side in SIDES: @@ -751,6 +751,37 @@ fn static_assert() { .copy_from(&other.gecko.mBorderImageWidth.data_at(${side.index})); % endfor } + + pub fn set_border_image_slice(&mut self, v: longhands::border_image_slice::computed_value::T) { + use gecko_bindings::structs::{NS_STYLE_BORDER_IMAGE_SLICE_NOFILL, NS_STYLE_BORDER_IMAGE_SLICE_FILL}; + use properties::longhands::border_image_slice::computed_value::PercentageOrNumber; + + for (i, corner) in v.corners.iter().enumerate() { + match *corner { + PercentageOrNumber::Percentage(p) => { + self.gecko.mBorderImageSlice.data_at_mut(i).set_value(CoordDataValue::Percent(p.0)) + }, + PercentageOrNumber::Number(n) => { + self.gecko.mBorderImageSlice.data_at_mut(i).set_value(CoordDataValue::Factor(n)) + }, + } + } + + let fill = if v.fill { + NS_STYLE_BORDER_IMAGE_SLICE_FILL + } else { + NS_STYLE_BORDER_IMAGE_SLICE_NOFILL + }; + self.gecko.mBorderImageFill = fill as u8; + } + + pub fn copy_border_image_slice_from(&mut self, other: &Self) { + for i in 0..4 { + self.gecko.mBorderImageSlice.data_at_mut(i) + .copy_from(&other.gecko.mBorderImageSlice.data_at(i)); + } + self.gecko.mBorderImageFill = other.gecko.mBorderImageFill; + } </%self:impl_trait> <% skip_margin_longhands = " ".join(["margin-%s" % x.ident for x in SIDES]) %> diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index 597a5c2fda8..0d98a0c1600 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -579,7 +579,7 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box", </%helpers:longhand> // https://drafts.csswg.org/css-backgrounds-3/#border-image-slice -<%helpers:longhand name="border-image-slice" products="none" animatable="False"> +<%helpers:longhand name="border-image-slice" products="gecko" animatable="False"> use cssparser::ToCss; use std::fmt; use values::LocalToCss; |