style: Use alias for StyleFillRule.

This needs to update the "fill-rule" and "clip-rule" to use
predefined_type to avoid some compilation errors.

Differential Revision: https://phabricator.services.mozilla.com/D10142
This commit is contained in:
Boris Chiou 2018-10-31 10:57:48 +00:00 committed by Emilio Cobos Álvarez
parent cb2533d61a
commit c7027e2676
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
8 changed files with 25 additions and 25 deletions

View file

@ -649,7 +649,7 @@ pub mod basic_shape {
use gecko::values::GeckoStyleCoordConvertible; use gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::structs; use gecko_bindings::structs;
use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType, StyleFillRule}; use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType};
use gecko_bindings::structs::{StyleGeometryBox, StyleShapeSource, StyleShapeSourceType}; use gecko_bindings::structs::{StyleGeometryBox, StyleShapeSource, StyleShapeSourceType};
use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners}; use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners};
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue}; use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
@ -662,7 +662,7 @@ pub mod basic_shape {
use values::computed::position; use values::computed::position;
use values::computed::url::ComputedUrl; use values::computed::url::ComputedUrl;
use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon}; use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon};
use values::generics::basic_shape::{Circle, Ellipse, FillRule, Path, PolygonCoord}; use values::generics::basic_shape::{Circle, Ellipse, Path, PolygonCoord};
use values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource}; use values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
use values::generics::border::BorderRadius as GenericBorderRadius; use values::generics::border::BorderRadius as GenericBorderRadius;
use values::generics::rect::Rect; use values::generics::rect::Rect;
@ -693,12 +693,7 @@ pub mod basic_shape {
StyleShapeSourceType::URL | StyleShapeSourceType::Image => None, StyleShapeSourceType::URL | StyleShapeSourceType::Image => None,
StyleShapeSourceType::Path => { StyleShapeSourceType::Path => {
let path = self.to_svg_path().expect("expect an SVGPathData"); let path = self.to_svg_path().expect("expect an SVGPathData");
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }; let fill = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }.mFillRule;
let fill = if gecko_path.mFillRule == StyleFillRule::Evenodd {
FillRule::Evenodd
} else {
FillRule::Nonzero
};
Some(ShapeSource::Path(Path { fill, path })) Some(ShapeSource::Path(Path { fill, path }))
}, },
} }
@ -805,11 +800,6 @@ pub mod basic_shape {
position: (&other.mPosition).into(), position: (&other.mPosition).into(),
}), }),
StyleBasicShapeType::Polygon => { StyleBasicShapeType::Polygon => {
let fill_rule = if other.mFillRule == StyleFillRule::Evenodd {
FillRule::Evenodd
} else {
FillRule::Nonzero
};
let mut coords = Vec::with_capacity(other.mCoordinates.len() / 2); let mut coords = Vec::with_capacity(other.mCoordinates.len() / 2);
for i in 0..(other.mCoordinates.len() / 2) { for i in 0..(other.mCoordinates.len() / 2) {
let x = 2 * i; let x = 2 * i;
@ -828,7 +818,7 @@ pub mod basic_shape {
)) ))
} }
GenericBasicShape::Polygon(Polygon { GenericBasicShape::Polygon(Polygon {
fill: fill_rule, fill: other.mFillRule,
coordinates: coords, coordinates: coords,
}) })
}, },

View file

@ -298,6 +298,7 @@ class Longhand(object):
"ColumnCount", "ColumnCount",
"Contain", "Contain",
"Display", "Display",
"FillRule",
"Float", "Float",
"FontSizeAdjust", "FontSizeAdjust",
"FontStretch", "FontStretch",

View file

@ -1397,6 +1397,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
"length::LengthOrNormal": impl_style_coord, "length::LengthOrNormal": impl_style_coord,
"length::NonNegativeLengthOrAuto": impl_style_coord, "length::NonNegativeLengthOrAuto": impl_style_coord,
"length::NonNegativeLengthOrPercentageOrNormal": impl_style_coord, "length::NonNegativeLengthOrPercentageOrNormal": impl_style_coord,
"FillRule": impl_simple,
"FlexBasis": impl_style_coord, "FlexBasis": impl_style_coord,
"Length": impl_absolute_length, "Length": impl_absolute_length,
"LengthOrNormal": impl_style_coord, "LengthOrNormal": impl_style_coord,
@ -4953,8 +4954,7 @@ fn set_style_svg_path(
gecko_path.mPath.assign_from_iter_pod(iter); gecko_path.mPath.assign_from_iter_pod(iter);
// Setup fill-rule. // Setup fill-rule.
// unsafe: cbindgen ensures the representation is the same. gecko_path.mFillRule = fill;
gecko_path.mFillRule = unsafe { transmute(fill) };
} }
<%def name="impl_shape_source(ident, gecko_ffi_name)"> <%def name="impl_shape_source(ident, gecko_ffi_name)">
@ -5059,8 +5059,7 @@ fn set_style_svg_path(
coord.0.to_gecko_style_coord(&mut shape.mCoordinates[2 * i]); coord.0.to_gecko_style_coord(&mut shape.mCoordinates[2 * i]);
coord.1.to_gecko_style_coord(&mut shape.mCoordinates[2 * i + 1]); coord.1.to_gecko_style_coord(&mut shape.mCoordinates[2 * i + 1]);
} }
// unsafe: cbindgen ensures the representation is the same. shape.mFillRule = poly.fill;
shape.mFillRule = unsafe { transmute(poly.fill) };
} }
} }

View file

@ -55,10 +55,11 @@ ${helpers.predefined_type(
spec="https://www.w3.org/TR/SVG11/painting.html#FillOpacityProperty", spec="https://www.w3.org/TR/SVG11/painting.html#FillOpacityProperty",
)} )}
${helpers.single_keyword( ${helpers.predefined_type(
"fill-rule", "fill-rule",
"nonzero evenodd", "FillRule",
gecko_enum_prefix="StyleFillRule", "Default::default()",
needs_context=False,
products="gecko", products="gecko",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/painting.html#FillRuleProperty", spec="https://www.w3.org/TR/SVG11/painting.html#FillRuleProperty",
@ -142,11 +143,12 @@ ${helpers.predefined_type(
)} )}
// Section 14 - Clipping, Masking and Compositing // Section 14 - Clipping, Masking and Compositing
${helpers.single_keyword( ${helpers.predefined_type(
"clip-rule", "clip-rule",
"nonzero evenodd", "FillRule",
"Default::default()",
needs_context=False,
products="gecko", products="gecko",
gecko_enum_prefix="StyleFillRule",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/masking.html#ClipRuleProperty", spec="https://www.w3.org/TR/SVG11/masking.html#ClipRuleProperty",
)} )}

View file

@ -13,6 +13,9 @@ use values::computed::{Image, LengthOrPercentage};
use values::computed::url::ComputedUrl; use values::computed::url::ComputedUrl;
use values::generics::basic_shape as generic; use values::generics::basic_shape as generic;
/// A computed alias for FillRule.
pub use values::generics::basic_shape::FillRule;
/// A computed clipping shape. /// A computed clipping shape.
pub type ClippingShape = generic::ClippingShape<BasicShape, ComputedUrl>; pub type ClippingShape = generic::ClippingShape<BasicShape, ComputedUrl>;

View file

@ -36,6 +36,7 @@ pub use self::align::{AlignContent, AlignItems, JustifyContent, JustifyItems, Se
pub use self::align::{AlignSelf, JustifySelf}; pub use self::align::{AlignSelf, JustifySelf};
pub use self::angle::Angle; pub use self::angle::Angle;
pub use self::background::{BackgroundRepeat, BackgroundSize}; pub use self::background::{BackgroundRepeat, BackgroundSize};
pub use self::basic_shape::FillRule;
pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing}; pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing};
pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis, FontVariantAlternates, FontWeight}; pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis, FontVariantAlternates, FontWeight};

View file

@ -14,7 +14,7 @@ use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use values::computed::Percentage; use values::computed::Percentage;
use values::generics::basic_shape as generic; use values::generics::basic_shape as generic;
use values::generics::basic_shape::{FillRule, GeometryBox, Path, PolygonCoord}; use values::generics::basic_shape::{GeometryBox, Path, PolygonCoord};
use values::generics::basic_shape::{ShapeBox, ShapeSource}; use values::generics::basic_shape::{ShapeBox, ShapeSource};
use values::generics::rect::Rect; use values::generics::rect::Rect;
use values::specified::LengthOrPercentage; use values::specified::LengthOrPercentage;
@ -25,6 +25,9 @@ use values::specified::position::{HorizontalPosition, Position, PositionComponen
use values::specified::position::{Side, VerticalPosition}; use values::specified::position::{Side, VerticalPosition};
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
/// A specified alias for FillRule.
pub use values::generics::basic_shape::FillRule;
/// A specified clipping shape. /// A specified clipping shape.
pub type ClippingShape = generic::ClippingShape<BasicShape, SpecifiedUrl>; pub type ClippingShape = generic::ClippingShape<BasicShape, SpecifiedUrl>;

View file

@ -29,6 +29,7 @@ pub use self::align::{AlignContent, AlignItems, AlignSelf, ContentDistribution};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use self::align::{JustifyContent, JustifyItems, JustifySelf, SelfAlignment}; pub use self::align::{JustifyContent, JustifyItems, JustifySelf, SelfAlignment};
pub use self::background::{BackgroundRepeat, BackgroundSize}; pub use self::background::{BackgroundRepeat, BackgroundSize};
pub use self::basic_shape::FillRule;
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing}; pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing};