mirror of
https://github.com/servo/servo.git
synced 2025-08-14 09:55:35 +01:00
style: Use NonNegative more in the border code.
This ended up not being so small of a patch as I'd have thought, since it propagated a bit. But most of it is mechanical. Interesting part is NonNegativeNumberOrPercentage and the actual uses of the NonNegative stuff and during parsing. This looks like it'd fix a few correctness issues during interpolation for all the types except for BorderRadius and co (which handled it manually). I should write tests for those in a different patch. Differential Revision: https://phabricator.services.mozilla.com/D14673
This commit is contained in:
parent
19035590ce
commit
ca1ad003bd
14 changed files with 161 additions and 106 deletions
|
@ -1687,8 +1687,8 @@ fn static_assert() {
|
|||
|
||||
pub fn clone_border_image_slice(&self) -> longhands::border_image_slice::computed_value::T {
|
||||
use crate::gecko_bindings::structs::NS_STYLE_BORDER_IMAGE_SLICE_FILL;
|
||||
use crate::values::computed::{BorderImageSlice, NumberOrPercentage};
|
||||
type NumberOrPercentageRect = crate::values::generics::rect::Rect<NumberOrPercentage>;
|
||||
use crate::values::computed::{BorderImageSlice, NonNegativeNumberOrPercentage};
|
||||
type NumberOrPercentageRect = crate::values::generics::rect::Rect<NonNegativeNumberOrPercentage>;
|
||||
|
||||
BorderImageSlice {
|
||||
offsets:
|
||||
|
|
|
@ -153,14 +153,15 @@ ${helpers.predefined_type(
|
|||
${helpers.predefined_type(
|
||||
"border-image-slice",
|
||||
"BorderImageSlice",
|
||||
initial_value="computed::NumberOrPercentage::Percentage(computed::Percentage(1.)).into()",
|
||||
initial_specified_value="specified::NumberOrPercentage::Percentage(specified::Percentage::new(1.)).into()",
|
||||
initial_value="computed::BorderImageSlice::hundred_percent()",
|
||||
initial_specified_value="specified::BorderImageSlice::hundred_percent()",
|
||||
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",
|
||||
animation_value_type="discrete",
|
||||
flags="APPLIES_TO_FIRST_LETTER",
|
||||
boxed=True,
|
||||
)}
|
||||
|
||||
// FIXME(emilio): Why does this live here? ;_;
|
||||
#[cfg(feature = "gecko")]
|
||||
impl crate::values::computed::BorderImageWidth {
|
||||
pub fn to_gecko_rect(&self, sides: &mut crate::gecko_bindings::structs::nsStyleSides) {
|
||||
|
@ -177,7 +178,7 @@ impl crate::values::computed::BorderImageWidth {
|
|||
l.to_gecko_style_coord(&mut sides.data_at_mut(${i}))
|
||||
},
|
||||
BorderImageSideWidth::Number(n) => {
|
||||
sides.data_at_mut(${i}).set_value(CoordDataValue::Factor(n))
|
||||
sides.data_at_mut(${i}).set_value(CoordDataValue::Factor(n.0))
|
||||
},
|
||||
}
|
||||
% endfor
|
||||
|
@ -191,6 +192,7 @@ impl crate::values::computed::BorderImageWidth {
|
|||
use crate::gecko::values::GeckoStyleCoordConvertible;
|
||||
use crate::values::computed::{LengthOrPercentage, Number};
|
||||
use crate::values::generics::border::BorderImageSideWidth;
|
||||
use crate::values::generics::NonNegative;
|
||||
|
||||
Some(
|
||||
crate::values::computed::BorderImageWidth::new(
|
||||
|
@ -201,13 +203,13 @@ impl crate::values::computed::BorderImageWidth {
|
|||
},
|
||||
eStyleUnit_Factor => {
|
||||
BorderImageSideWidth::Number(
|
||||
Number::from_gecko_style_coord(&sides.data_at(${i}))
|
||||
.expect("sides[${i}] could not convert to Number"))
|
||||
NonNegative(Number::from_gecko_style_coord(&sides.data_at(${i}))
|
||||
.expect("sides[${i}] could not convert to Number")))
|
||||
},
|
||||
_ => {
|
||||
BorderImageSideWidth::Length(
|
||||
LengthOrPercentage::from_gecko_style_coord(&sides.data_at(${i}))
|
||||
.expect("sides[${i}] could not convert to LengthOrPercentager"))
|
||||
NonNegative(LengthOrPercentage::from_gecko_style_coord(&sides.data_at(${i}))
|
||||
.expect("sides[${i}] could not convert to LengthOrPercentage")))
|
||||
},
|
||||
},
|
||||
% endfor
|
||||
|
|
|
@ -295,7 +295,7 @@ ${helpers.predefined_type(
|
|||
"-webkit-text-stroke-width",
|
||||
"BorderSideWidth",
|
||||
"crate::values::computed::NonNegativeLength::new(0.)",
|
||||
initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
|
||||
initial_specified_value="specified::BorderSideWidth::zero()",
|
||||
computed_type="crate::values::computed::NonNegativeLength",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.prefixes.webkit",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue