mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Stylo: add -moz-border-*-colors support
In Gecko, we use double pointers to nsBorderColors to store -moz-border-*-colors. We can simplify the implementation of computed value in Servo by using Option<Vec>. As to passing computed values from Servo to Gecko, we might need to use some binding functions (pre-added in the same Gecko bug, see Bug 1348173). Note that we added -moz-border-*-colors as sub_properties of the 'border' shorthand, so we can make the 'border' shorthand reset -moz-border-*-colors (See Gecko Bug 482692). However, since they are Gecko only non-standard properties, we should skip these sub_properties while doing unit testing in Servo. The test part should be convered by Stylo/Gecko already. A bit refactoring of replacing all ["top", "right", "bottom", "left"] with PHYSICAL_SIDES is included in this patch, since we've already had PHYSICAL_SIDES for a while.
This commit is contained in:
parent
3f3f780ae5
commit
13f6cf6e3a
4 changed files with 182 additions and 7 deletions
|
@ -827,9 +827,13 @@ fn static_assert() {
|
|||
for y in ["color", "style", "width"]] +
|
||||
["border-{0}-radius".format(x.ident.replace("_", "-"))
|
||||
for x in CORNERS]) %>
|
||||
|
||||
<% skip_moz_border_color_longhands = " ".join("-moz-border-{0}-colors".format(x.ident)
|
||||
for x in SIDES) %>
|
||||
<%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-slice"
|
||||
border-image-repeat border-image-width border-image-slice
|
||||
${skip_moz_border_color_longhands}"
|
||||
skip_additionals="*">
|
||||
|
||||
% for side in SIDES:
|
||||
|
@ -880,6 +884,42 @@ fn static_assert() {
|
|||
pub fn border_${side.ident}_has_nonzero_width(&self) -> bool {
|
||||
self.gecko.mComputedBorder.${side.ident} != 0
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set__moz_border_${side.ident}_colors(&mut self,
|
||||
v: longhands::_moz_border_${side.ident}_colors::computed_value::T) {
|
||||
match v.0 {
|
||||
None => {
|
||||
unsafe {
|
||||
bindings::Gecko_ClearMozBorderColors(&mut self.gecko,
|
||||
structs::Side::eSide${to_camel_case(side.ident)});
|
||||
}
|
||||
},
|
||||
Some(ref colors) => {
|
||||
unsafe {
|
||||
bindings::Gecko_EnsureMozBorderColors(&mut self.gecko);
|
||||
bindings::Gecko_ClearMozBorderColors(&mut self.gecko,
|
||||
structs::Side::eSide${to_camel_case(side.ident)});
|
||||
}
|
||||
for color in colors {
|
||||
let c = color_to_nscolor_zero_currentcolor(*color);
|
||||
unsafe {
|
||||
bindings::Gecko_AppendMozBorderColors(&mut self.gecko,
|
||||
structs::Side::eSide${to_camel_case(side.ident)},
|
||||
c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn copy__moz_border_${side.ident}_colors_from(&mut self, other: &Self) {
|
||||
unsafe {
|
||||
bindings::Gecko_CopyMozBorderColors(&mut self.gecko, &other.gecko,
|
||||
structs::Side::eSide${to_camel_case(side.ident)});
|
||||
}
|
||||
}
|
||||
% endfor
|
||||
|
||||
% for corner in CORNERS:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue