mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
style: Get rid of parse_specified.
It has a single use, and I don't think we should use it in the future.
This commit is contained in:
parent
693c3dcfb2
commit
7adad61db8
3 changed files with 39 additions and 30 deletions
|
@ -402,14 +402,10 @@
|
||||||
% endif
|
% endif
|
||||||
}
|
}
|
||||||
% if not property.derived_from:
|
% if not property.derived_from:
|
||||||
pub fn parse_specified<'i, 't>(
|
pub fn parse_declared<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
% if property.boxed:
|
) -> Result<PropertyDeclaration, ParseError<'i>> {
|
||||||
) -> Result<Box<SpecifiedValue>, ParseError<'i>> {
|
|
||||||
% else:
|
|
||||||
) -> Result<SpecifiedValue, ParseError<'i>> {
|
|
||||||
% endif
|
|
||||||
% if property.allow_quirks:
|
% if property.allow_quirks:
|
||||||
parse_quirky(context, input, specified::AllowQuirks::Yes)
|
parse_quirky(context, input, specified::AllowQuirks::Yes)
|
||||||
% else:
|
% else:
|
||||||
|
@ -418,13 +414,6 @@
|
||||||
% if property.boxed:
|
% if property.boxed:
|
||||||
.map(Box::new)
|
.map(Box::new)
|
||||||
% endif
|
% endif
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_declared<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<PropertyDeclaration, ParseError<'i>> {
|
|
||||||
parse_specified(context, input)
|
|
||||||
.map(PropertyDeclaration::${property.camel_case})
|
.map(PropertyDeclaration::${property.camel_case})
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
@ -938,6 +927,8 @@
|
||||||
|
|
||||||
// Define property that supports prefixed intrinsic size keyword values for gecko.
|
// Define property that supports prefixed intrinsic size keyword values for gecko.
|
||||||
// E.g. -moz-max-content, -moz-min-content, etc.
|
// E.g. -moz-max-content, -moz-min-content, etc.
|
||||||
|
//
|
||||||
|
// FIXME(emilio): This feels a lot like a huge hack, get rid of this.
|
||||||
<%def name="gecko_size_type(name, length_type, initial_value, logical, **kwargs)">
|
<%def name="gecko_size_type(name, length_type, initial_value, logical, **kwargs)">
|
||||||
<%call expr="longhand(name,
|
<%call expr="longhand(name,
|
||||||
predefined_type=length_type,
|
predefined_type=length_type,
|
||||||
|
@ -982,20 +973,32 @@
|
||||||
use values::computed::${length_type};
|
use values::computed::${length_type};
|
||||||
${length_type}::${initial_value}
|
${length_type}::${initial_value}
|
||||||
}
|
}
|
||||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|
||||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
impl Parse for SpecifiedValue {
|
||||||
% if logical:
|
fn parse<'i, 't>(
|
||||||
let ret = ${length_type}::parse(context, input);
|
context: &ParserContext,
|
||||||
% else:
|
input: &mut Parser<'i, 't>,
|
||||||
let ret = ${length_type}::parse_quirky(context, input, AllowQuirks::Yes);
|
) -> Result<SpecifiedValue, ParseError<'i>> {
|
||||||
% endif
|
% if logical:
|
||||||
// Keyword values don't make sense in the block direction; don't parse them
|
let ret = ${length_type}::parse(context, input);
|
||||||
% if "block" in name:
|
% else:
|
||||||
if let Ok(${length_type}::ExtremumLength(..)) = ret {
|
let ret = ${length_type}::parse_quirky(context, input, AllowQuirks::Yes);
|
||||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
% endif
|
||||||
}
|
// Keyword values don't make sense in the block direction; don't parse them
|
||||||
% endif
|
% if "block" in name:
|
||||||
ret.map(SpecifiedValue)
|
if let Ok(${length_type}::ExtremumLength(..)) = ret {
|
||||||
|
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
ret.map(SpecifiedValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<SpecifiedValue, ParseError<'i>> {
|
||||||
|
SpecifiedValue::parse(context, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToComputedValue for SpecifiedValue {
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
|
|
@ -160,6 +160,11 @@ ${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(emilio): All the sizes stuff, and the MozLength values should be
|
||||||
|
// unified with Servo, or at least be less hacky.
|
||||||
|
//
|
||||||
|
// The block direction ones don't even accept extremum lengths during parsing,
|
||||||
|
// and should be converted to just LengthOrPercentage.
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
// FIXME: Gecko doesn't support content value yet.
|
// FIXME: Gecko doesn't support content value yet.
|
||||||
${helpers.gecko_size_type("flex-basis", "MozLength", "auto()",
|
${helpers.gecko_size_type("flex-basis", "MozLength", "auto()",
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
spec="https://drafts.csswg.org/css-flexbox/#flex-property">
|
spec="https://drafts.csswg.org/css-flexbox/#flex-property">
|
||||||
use parser::Parse;
|
use parser::Parse;
|
||||||
use values::specified::NonNegativeNumber;
|
use values::specified::NonNegativeNumber;
|
||||||
|
use properties::longhands::flex_basis::SpecifiedValue as FlexBasis;
|
||||||
|
|
||||||
fn parse_flexibility<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
fn parse_flexibility<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||||
-> Result<(NonNegativeNumber, Option<NonNegativeNumber>),ParseError<'i>> {
|
-> Result<(NonNegativeNumber, Option<NonNegativeNumber>),ParseError<'i>> {
|
||||||
|
@ -66,7 +67,7 @@
|
||||||
return Ok(expanded! {
|
return Ok(expanded! {
|
||||||
flex_grow: NonNegativeNumber::new(0.0),
|
flex_grow: NonNegativeNumber::new(0.0),
|
||||||
flex_shrink: NonNegativeNumber::new(0.0),
|
flex_shrink: NonNegativeNumber::new(0.0),
|
||||||
flex_basis: longhands::flex_basis::SpecifiedValue::auto(),
|
flex_basis: FlexBasis::auto(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
|
@ -78,7 +79,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if basis.is_none() {
|
if basis.is_none() {
|
||||||
if let Ok(value) = input.try(|input| longhands::flex_basis::parse_specified(context, input)) {
|
if let Ok(value) = input.try(|input| FlexBasis::parse(context, input)) {
|
||||||
basis = Some(value);
|
basis = Some(value);
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@
|
||||||
// browsers currently agree on using `0%`. This is a spec
|
// browsers currently agree on using `0%`. This is a spec
|
||||||
// change which hasn't been adopted by browsers:
|
// change which hasn't been adopted by browsers:
|
||||||
// https://github.com/w3c/csswg-drafts/commit/2c446befdf0f686217905bdd7c92409f6bd3921b
|
// https://github.com/w3c/csswg-drafts/commit/2c446befdf0f686217905bdd7c92409f6bd3921b
|
||||||
flex_basis: basis.unwrap_or(longhands::flex_basis::SpecifiedValue::zero_percent()),
|
flex_basis: basis.unwrap_or(FlexBasis::zero_percent()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue