mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
Support prefixed intrinsic size value for flex-basis.
auto() and zero() are used in the parser for flex shorthand property.
This commit is contained in:
parent
3a3bc03eb8
commit
d06af8971d
4 changed files with 38 additions and 16 deletions
|
@ -1090,6 +1090,23 @@
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct SpecifiedValue(pub ${length_type});
|
pub struct SpecifiedValue(pub ${length_type});
|
||||||
|
|
||||||
|
% if length_type == "MozLength":
|
||||||
|
impl SpecifiedValue {
|
||||||
|
/// Returns the `auto` value.
|
||||||
|
pub fn auto() -> Self {
|
||||||
|
use values::specified::length::LengthOrPercentageOrAuto;
|
||||||
|
SpecifiedValue(MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a value representing a `0` length.
|
||||||
|
pub fn zero() -> Self {
|
||||||
|
use values::specified::length::{LengthOrPercentageOrAuto, NoCalcLength};
|
||||||
|
SpecifiedValue(MozLength::LengthOrPercentageOrAuto(
|
||||||
|
LengthOrPercentageOrAuto::Length(NoCalcLength::zero())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
use values::computed::${length_type};
|
use values::computed::${length_type};
|
||||||
|
|
|
@ -134,18 +134,23 @@ ${helpers.predefined_type("order", "Integer", "0",
|
||||||
animation_value_type="ComputedValue",
|
animation_value_type="ComputedValue",
|
||||||
spec="https://drafts.csswg.org/css-flexbox/#order-property")}
|
spec="https://drafts.csswg.org/css-flexbox/#order-property")}
|
||||||
|
|
||||||
// FIXME: Gecko doesn't support content value yet.
|
% if product == "gecko":
|
||||||
// FIXME: This property should be animatable.
|
// FIXME: Gecko doesn't support content value yet.
|
||||||
${helpers.predefined_type("flex-basis",
|
${helpers.gecko_size_type("flex-basis", "MozLength", "auto()",
|
||||||
"LengthOrPercentageOrAuto" if product == "gecko" else
|
logical=False,
|
||||||
|
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
|
||||||
|
extra_prefixes="webkit",
|
||||||
|
animation_value_type="ComputedValue")}
|
||||||
|
% else:
|
||||||
|
// FIXME: This property should be animatable.
|
||||||
|
${helpers.predefined_type("flex-basis",
|
||||||
"LengthOrPercentageOrAutoOrContent",
|
"LengthOrPercentageOrAutoOrContent",
|
||||||
"computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else
|
|
||||||
"computed::LengthOrPercentageOrAutoOrContent::Auto",
|
"computed::LengthOrPercentageOrAutoOrContent::Auto",
|
||||||
"parse_non_negative",
|
"parse_non_negative",
|
||||||
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
|
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
|
||||||
extra_prefixes="webkit",
|
extra_prefixes="webkit",
|
||||||
animation_value_type="ComputedValue" if product == "gecko" else "none")}
|
animation_value_type="none")}
|
||||||
|
% endif
|
||||||
% for (size, logical) in ALL_SIZES:
|
% for (size, logical) in ALL_SIZES:
|
||||||
<%
|
<%
|
||||||
spec = "https://drafts.csswg.org/css-box/#propdef-%s"
|
spec = "https://drafts.csswg.org/css-box/#propdef-%s"
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if basis.is_none() {
|
if basis.is_none() {
|
||||||
if let Ok(value) = input.try(|input| longhands::flex_basis::parse(context, input)) {
|
if let Ok(value) = input.try(|input| longhands::flex_basis::parse_specified(context, input)) {
|
||||||
basis = Some(value);
|
basis = Some(value);
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -1904,14 +1904,14 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations:
|
||||||
use style::properties::{PropertyDeclaration, LonghandId};
|
use style::properties::{PropertyDeclaration, LonghandId};
|
||||||
use style::properties::longhands::height::SpecifiedValue as Height;
|
use style::properties::longhands::height::SpecifiedValue as Height;
|
||||||
use style::properties::longhands::width::SpecifiedValue as Width;
|
use style::properties::longhands::width::SpecifiedValue as Width;
|
||||||
use style::values::specified::{LengthOrPercentageOrAuto, MozLength};
|
use style::values::specified::LengthOrPercentageOrAuto;
|
||||||
|
|
||||||
let long = get_longhand_from_id!(property);
|
let long = get_longhand_from_id!(property);
|
||||||
let auto = LengthOrPercentageOrAuto::Auto;
|
let auto = LengthOrPercentageOrAuto::Auto;
|
||||||
|
|
||||||
let prop = match_wrap_declared! { long,
|
let prop = match_wrap_declared! { long,
|
||||||
Height => Height(MozLength::LengthOrPercentageOrAuto(auto)),
|
Height => Height::auto(),
|
||||||
Width => Width(MozLength::LengthOrPercentageOrAuto(auto)),
|
Width => Width::auto(),
|
||||||
MarginTop => auto,
|
MarginTop => auto,
|
||||||
MarginRight => auto,
|
MarginRight => auto,
|
||||||
MarginBottom => auto,
|
MarginBottom => auto,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue