Skip to content

Commit

Permalink
Implement gecko glue for border-image-slice
Browse files Browse the repository at this point in the history
  • Loading branch information
canova committed Nov 6, 2016
1 parent 8387d7e commit 6014c0c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion components/style/properties/gecko.mako.rs
Expand Up @@ -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:
Expand Down Expand Up @@ -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]) %>
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhand/border.mako.rs
Expand Up @@ -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;
Expand Down

0 comments on commit 6014c0c

Please sign in to comment.