Skip to content

Commit

Permalink
Change predefined type of flex-basis / make gecko glue auto-generate
Browse files Browse the repository at this point in the history
Gecko doesn't support content value in flex-basis yet.
  • Loading branch information
canova committed Mar 10, 2017
1 parent 9e6fce4 commit aa5477b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
6 changes: 0 additions & 6 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -612,12 +612,6 @@ impl Debug for ${style_struct.gecko_struct_name} {
# These have unusual representations in gecko.
force_stub += ["list-style-type"]

# These are part of shorthands so we must include them in stylo builds,
# but we haven't implemented the stylo glue for the longhand
# so we generate a stub
force_stub += ["flex-basis", # position
]

# Types used with predefined_type()-defined properties that we can auto-generate.
predefined_types = {
"length::LengthOrAuto": impl_style_coord,
Expand Down
5 changes: 4 additions & 1 deletion components/style/properties/longhand/position.mako.rs
Expand Up @@ -195,13 +195,16 @@ ${helpers.predefined_type("flex-shrink", "Number",
}
</%helpers:longhand>

// FIXME: Gecko doesn't support content value yet.
// FIXME: This property should be animatable.
${helpers.predefined_type("flex-basis",
"LengthOrPercentageOrAuto" if product == "gecko" else
"LengthOrPercentageOrAutoOrContent",
"computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else
"computed::LengthOrPercentageOrAutoOrContent::Auto",
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
extra_prefixes="webkit",
animatable=False)}
animatable=True if product == "gecko" else False)}

% for (size, logical) in ALL_SIZES:
<%
Expand Down
26 changes: 22 additions & 4 deletions components/style/properties/shorthand/position.mako.rs
Expand Up @@ -49,7 +49,12 @@
<%helpers:shorthand name="flex" sub_properties="flex-grow flex-shrink flex-basis" extra_prefixes="webkit"
spec="https://drafts.csswg.org/css-flexbox/#flex-property">
use parser::Parse;
use values::specified::{Number, NoCalcLength, LengthOrPercentageOrAutoOrContent};
use values::specified::{Number, NoCalcLength};
% if product == "gecko":
use values::specified::LengthOrPercentageOrAuto;
% else:
use values::specified::LengthOrPercentageOrAutoOrContent;
% endif

pub fn parse_flexibility(input: &mut Parser)
-> Result<(Number, Option<Number>),()> {
Expand All @@ -67,7 +72,12 @@
return Ok(Longhands {
flex_grow: Number(0.0),
flex_shrink: Number(0.0),
flex_basis: LengthOrPercentageOrAutoOrContent::Auto
% if product == "gecko":
flex_basis: LengthOrPercentageOrAuto::Auto
% else:
flex_basis: LengthOrPercentageOrAutoOrContent::Auto
% endif

})
}
loop {
Expand All @@ -79,7 +89,11 @@
}
}
if basis.is_none() {
if let Ok(value) = input.try(|i| LengthOrPercentageOrAutoOrContent::parse(context, i)) {
% if product == "gecko":
if let Ok(value) = input.try(|i| LengthOrPercentageOrAuto::parse(context, i)) {
% else:
if let Ok(value) = input.try(|i| LengthOrPercentageOrAutoOrContent::parse(context, i)) {
% endif
basis = Some(value);
continue
}
Expand All @@ -93,7 +107,11 @@
Ok(Longhands {
flex_grow: grow.unwrap_or(Number(1.0)),
flex_shrink: shrink.unwrap_or(Number(1.0)),
flex_basis: basis.unwrap_or(LengthOrPercentageOrAutoOrContent::Length(NoCalcLength::zero()))
% if product == "gecko":
flex_basis: basis.unwrap_or(LengthOrPercentageOrAuto::Length(NoCalcLength::zero()))
% else:
flex_basis: basis.unwrap_or(LengthOrPercentageOrAutoOrContent::Length(NoCalcLength::zero()))
% endif
})
}

Expand Down

0 comments on commit aa5477b

Please sign in to comment.