Skip to content

Commit

Permalink
style: Add bindings for LengthPercentage, and use it for text-indent.
Browse files Browse the repository at this point in the history
Which is the only property that uses LengthPercentage alone.

Differential Revision: https://phabricator.services.mozilla.com/D17737
  • Loading branch information
emilio committed Feb 10, 2019
1 parent 207ff73 commit 15f503d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
21 changes: 20 additions & 1 deletion components/style/cbindgen.toml
Expand Up @@ -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 {
Expand All @@ -27,7 +29,7 @@ namespaces = ["mozilla"]

[parse]
parse_deps = true
include = ["cssparser"]
include = ["cssparser", "style_traits"]

[struct]
derive_eq = true
Expand Down Expand Up @@ -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<typename T> inline CSSCoord ResolveToCSSPixelsWith(T aPercentageGetter) const;
inline nscoord Resolve(nscoord aPercentageBasis) const;
template<typename T> inline nscoord ResolveWith(T aPercentageGetter) const;
"""
2 changes: 1 addition & 1 deletion components/style/properties/gecko.mako.rs
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions components/style/values/computed/length.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -678,6 +679,7 @@ impl NonNegativeLengthPercentage {
ToAnimatedValue,
ToAnimatedZero,
)]
#[repr(C)]
pub struct CSSPixelLength(CSSFloat);

impl CSSPixelLength {
Expand Down

0 comments on commit 15f503d

Please sign in to comment.