diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml index 25004b2def6..25f88f64b3a 100644 --- a/components/style/cbindgen.toml +++ b/components/style/cbindgen.toml @@ -7,6 +7,8 @@ autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated usi * a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate style -o layout/style/ServoStyleConsts.h` */ +#include "nsCoord.h" +#include "Units.h" class nsAtom; namespace mozilla { namespace css { @@ -27,7 +29,7 @@ namespaces = ["mozilla"] [parse] parse_deps = true -include = ["cssparser"] +include = ["cssparser", "style_traits"] [struct] derive_eq = true @@ -71,3 +73,20 @@ include = [ "LengthPercentage", ] item_types = ["enums", "structs", "typedefs"] + +[export.body] +"LengthPercentage" = """ + // Defined in nsStyleCoord.h + static inline StyleLengthPercentage Zero(); + inline bool HasPercent() const; + inline bool ConvertsToLength() const; + inline nscoord ToLength() const; + inline bool ConvertsToPercentage() const; + inline float ToPercentage() const; + inline CSSCoord LengthInCSSPixels() const; + inline float Percentage() const; + inline CSSCoord ResolveToCSSPixels(CSSCoord aPercentageBasisInCSSPixels) const; + template inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const; + inline nscoord Resolve(nscoord aPercentageBasis) const; + template inline nscoord ResolveWith(T aPercentageGetter) const; +""" diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2c25a2095af..970a807f0d9 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1389,7 +1389,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "FlexBasis": impl_style_coord, "Length": impl_absolute_length, "LengthOrNormal": impl_style_coord, - "LengthPercentage": impl_style_coord, + "LengthPercentage": impl_simple, "LengthPercentageOrAuto": impl_style_coord, "LengthPercentageOrNone": impl_style_coord, "MaxLength": impl_style_coord, diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 1fd42301e3b..ae585695506 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -73,11 +73,12 @@ impl ToComputedValue for specified::Length { /// https://drafts.csswg.org/css-values-4/#typedef-length-percentage #[allow(missing_docs)] #[derive(Clone, Copy, Debug, MallocSizeOf, ToAnimatedZero)] +#[repr(C)] pub struct LengthPercentage { - #[animation(constant)] - pub clamping_mode: AllowedNumericType, length: Length, percentage: Percentage, + #[animation(constant)] + pub clamping_mode: AllowedNumericType, /// Whether we specified a percentage or not. #[animation(constant)] pub has_percentage: bool, @@ -678,6 +679,7 @@ impl NonNegativeLengthPercentage { ToAnimatedValue, ToAnimatedZero, )] +#[repr(C)] pub struct CSSPixelLength(CSSFloat); impl CSSPixelLength {