style: Add bindings for LengthPercentage, and use it for text-indent.

Which is the only property that uses LengthPercentage alone.

Differential Revision: https://phabricator.services.mozilla.com/D17737
This commit is contained in:
Emilio Cobos Álvarez 2019-01-26 11:00:06 +01:00
parent 207ff730c2
commit 15f503d000
3 changed files with 25 additions and 4 deletions

View file

@ -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 * 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` * 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; class nsAtom;
namespace mozilla { namespace mozilla {
namespace css { namespace css {
@ -27,7 +29,7 @@ namespaces = ["mozilla"]
[parse] [parse]
parse_deps = true parse_deps = true
include = ["cssparser"] include = ["cssparser", "style_traits"]
[struct] [struct]
derive_eq = true derive_eq = true
@ -71,3 +73,20 @@ include = [
"LengthPercentage", "LengthPercentage",
] ]
item_types = ["enums", "structs", "typedefs"] 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<typename T> inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const;
inline nscoord Resolve(nscoord aPercentageBasis) const;
template<typename T> inline nscoord ResolveWith(T aPercentageGetter) const;
"""

View file

@ -1389,7 +1389,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
"FlexBasis": impl_style_coord, "FlexBasis": impl_style_coord,
"Length": impl_absolute_length, "Length": impl_absolute_length,
"LengthOrNormal": impl_style_coord, "LengthOrNormal": impl_style_coord,
"LengthPercentage": impl_style_coord, "LengthPercentage": impl_simple,
"LengthPercentageOrAuto": impl_style_coord, "LengthPercentageOrAuto": impl_style_coord,
"LengthPercentageOrNone": impl_style_coord, "LengthPercentageOrNone": impl_style_coord,
"MaxLength": impl_style_coord, "MaxLength": impl_style_coord,

View file

@ -73,11 +73,12 @@ impl ToComputedValue for specified::Length {
/// https://drafts.csswg.org/css-values-4/#typedef-length-percentage /// https://drafts.csswg.org/css-values-4/#typedef-length-percentage
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Clone, Copy, Debug, MallocSizeOf, ToAnimatedZero)] #[derive(Clone, Copy, Debug, MallocSizeOf, ToAnimatedZero)]
#[repr(C)]
pub struct LengthPercentage { pub struct LengthPercentage {
#[animation(constant)]
pub clamping_mode: AllowedNumericType,
length: Length, length: Length,
percentage: Percentage, percentage: Percentage,
#[animation(constant)]
pub clamping_mode: AllowedNumericType,
/// Whether we specified a percentage or not. /// Whether we specified a percentage or not.
#[animation(constant)] #[animation(constant)]
pub has_percentage: bool, pub has_percentage: bool,
@ -678,6 +679,7 @@ impl NonNegativeLengthPercentage {
ToAnimatedValue, ToAnimatedValue,
ToAnimatedZero, ToAnimatedZero,
)] )]
#[repr(C)]
pub struct CSSPixelLength(CSSFloat); pub struct CSSPixelLength(CSSFloat);
impl CSSPixelLength { impl CSSPixelLength {