mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Use a more consistent style for parsing functions.
This commit is contained in:
parent
39018f9339
commit
15c416b133
14 changed files with 126 additions and 69 deletions
|
@ -139,8 +139,10 @@ ${helpers.single_keyword("mask-origin",
|
|||
background_size::get_initial_value()
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue,ParseError<'i>> {
|
||||
pub fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<SpecifiedValue, ParseError<'i>> {
|
||||
background_size::parse(context, input)
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
|
@ -33,8 +33,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let mut background_color = None;
|
||||
|
||||
% for name in "image position_x position_y repeat size attachment origin clip".split():
|
||||
|
@ -200,8 +202,10 @@
|
|||
use values::specified::AllowQuirks;
|
||||
use values::specified::position::Position;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
// Vec grows from 0 to 4 by default on first push(). So allocate with
|
||||
// capacity 1, so in the common case of only one item we don't way
|
||||
// overallocate. Note that we always push at least one item if parsing
|
||||
|
|
|
@ -24,8 +24,10 @@ ${helpers.four_sides_shorthand(
|
|||
use values::generics::rect::Rect;
|
||||
use values::specified::{AllowQuirks, BorderSideWidth};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let rect = Rect::parse_with(context, input, |_, i| {
|
||||
BorderSideWidth::parse_quirky(context, i, AllowQuirks::Yes)
|
||||
})?;
|
||||
|
@ -48,10 +50,10 @@ ${helpers.four_sides_shorthand(
|
|||
</%helpers:shorthand>
|
||||
|
||||
|
||||
pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<(specified::Color,
|
||||
specified::BorderStyle,
|
||||
specified::BorderSideWidth), ParseError<'i>> {
|
||||
pub fn parse_border<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<(specified::Color, specified::BorderStyle, specified::BorderSideWidth), ParseError<'i>> {
|
||||
use values::specified::{Color, BorderStyle, BorderSideWidth};
|
||||
let _unused = context;
|
||||
let mut color = None;
|
||||
|
@ -106,8 +108,10 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
alias="${maybe_moz_logical_alias(product, (side, logical), '-moz-border-%s')}"
|
||||
spec="${spec}">
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let (color, style, width) = super::parse_border(context, input)?;
|
||||
Ok(expanded! {
|
||||
border_${to_rust_ident(side)}_color: color,
|
||||
|
@ -138,8 +142,10 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
for name in ['outset', 'repeat', 'slice', 'source', 'width'])}"
|
||||
spec="https://drafts.csswg.org/css-backgrounds/#border">
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
use properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
|
||||
use properties::longhands::{border_image_source, border_image_width};
|
||||
|
||||
|
@ -207,8 +213,10 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
use values::specified::border::BorderRadius;
|
||||
use parser::Parse;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let radii = BorderRadius::parse(context, input)?;
|
||||
Ok(expanded! {
|
||||
border_top_left_radius: radii.top_left,
|
||||
|
@ -242,8 +250,10 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|||
use properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
|
||||
use properties::longhands::{border_image_source, border_image_width};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
% for name in "outset repeat slice source width".split():
|
||||
let mut border_image_${name} = border_image_${name}::get_initial_specified_value();
|
||||
% endfor
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
use properties::longhands::overflow_x::SpecifiedValue;
|
||||
% endif
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
% if product == "gecko":
|
||||
let moz_kw_found = input.try(|input| {
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
|
@ -118,8 +120,10 @@ macro_rules! try_parse_one {
|
|||
use properties::longhands::transition_${prop};
|
||||
% endfor
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
struct SingleTransition {
|
||||
% for prop in "duration timing_function delay".split():
|
||||
transition_${prop}: transition_${prop}::SingleSpecifiedValue,
|
||||
|
@ -129,8 +133,10 @@ macro_rules! try_parse_one {
|
|||
transition_property: Option<transition_property::SingleSpecifiedValue>,
|
||||
}
|
||||
|
||||
fn parse_one_transition<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SingleTransition,ParseError<'i>> {
|
||||
fn parse_one_transition<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<SingleTransition,ParseError<'i>> {
|
||||
% for prop in "property duration timing_function delay".split():
|
||||
let mut ${prop} = None;
|
||||
% endfor
|
||||
|
@ -260,16 +266,20 @@ macro_rules! try_parse_one {
|
|||
use properties::longhands::animation_${prop};
|
||||
% endfor
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
struct SingleAnimation {
|
||||
% for prop in props:
|
||||
animation_${prop}: animation_${prop}::SingleSpecifiedValue,
|
||||
% endfor
|
||||
}
|
||||
|
||||
fn parse_one_animation<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SingleAnimation,ParseError<'i>> {
|
||||
fn parse_one_animation<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<SingleAnimation, ParseError<'i>> {
|
||||
% for prop in props:
|
||||
let mut ${prop} = None;
|
||||
% endfor
|
||||
|
@ -364,8 +374,10 @@ macro_rules! try_parse_one {
|
|||
spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type">
|
||||
use properties::longhands::scroll_snap_type_x;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let result = scroll_snap_type_x::parse(context, input)?;
|
||||
Ok(expanded! {
|
||||
scroll_snap_type_x: result,
|
||||
|
|
|
@ -11,9 +11,10 @@
|
|||
extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns">
|
||||
use properties::longhands::{column_count, column_width};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let mut column_count = None;
|
||||
let mut column_width = None;
|
||||
let mut autos = 0;
|
||||
|
@ -61,8 +62,10 @@
|
|||
use properties::longhands::{column_rule_width, column_rule_style};
|
||||
use properties::longhands::column_rule_color;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
% for name in "width style color".split():
|
||||
let mut column_rule_${name} = None;
|
||||
% endfor
|
||||
|
|
|
@ -42,8 +42,10 @@
|
|||
% endif
|
||||
use self::font_family::SpecifiedValue as FontFamily;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let mut nb_normals = 0;
|
||||
let mut style = None;
|
||||
let mut variant_caps = None;
|
||||
|
@ -262,8 +264,10 @@
|
|||
#[allow(unused_imports)]
|
||||
use values::specified::FontVariantLigatures;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
% for prop in sub_properties:
|
||||
let mut ${prop} = None;
|
||||
% endfor
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
spec="https://www.w3.org/TR/SVG2/painting.html#MarkerShorthand">
|
||||
use values::specified::UrlOrNone;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
use parser::Parse;
|
||||
let url = UrlOrNone::parse(context, input)?;
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
spec="https://drafts.csswg.org/css-text-decor-3/#text-emphasis-property">
|
||||
use properties::longhands::{text_emphasis_color, text_emphasis_style};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let mut color = None;
|
||||
let mut style = None;
|
||||
|
||||
|
@ -52,8 +54,10 @@
|
|||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke">
|
||||
use properties::longhands::{_webkit_text_stroke_color, _webkit_text_stroke_width};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let mut color = None;
|
||||
let mut width = None;
|
||||
loop {
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
use properties::longhands::{list_style_image, list_style_position, list_style_type};
|
||||
use values::{Either, None_};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
// `none` is ambiguous until we've finished parsing the shorthands, so we count the number
|
||||
// of times we see it.
|
||||
let mut nones = 0u8;
|
||||
|
|
|
@ -36,8 +36,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
% for name in "image mode position_x position_y size repeat origin clip composite".split():
|
||||
// Vec grows from 0 to 4 by default on first push(). So allocate
|
||||
// with capacity 1, so in the common case of only one item we don't
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
use values::specified;
|
||||
use parser::Parse;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let _unused = context;
|
||||
let mut color = None;
|
||||
let mut style = None;
|
||||
|
@ -64,8 +66,10 @@
|
|||
use values::specified::border::BorderRadius;
|
||||
use parser::Parse;
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let radii = BorderRadius::parse(context, input)?;
|
||||
Ok(expanded! {
|
||||
_moz_outline_radius_topleft: radii.top_left,
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
spec="https://drafts.csswg.org/css-flexbox/#flex-flow-property">
|
||||
use properties::longhands::{flex_direction, flex_wrap};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let mut direction = None;
|
||||
let mut wrap = None;
|
||||
loop {
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
use properties::longhands::text_decoration_line;
|
||||
% endif
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
% if product == "gecko":
|
||||
let (mut line, mut style, mut color, mut any) = (None, None, None, false);
|
||||
% else:
|
||||
|
|
|
@ -601,17 +601,20 @@ impl Length {
|
|||
|
||||
/// Parse a non-negative length
|
||||
#[inline]
|
||||
pub fn parse_non_negative<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Length, ParseError<'i>> {
|
||||
pub fn parse_non_negative<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_non_negative_quirky(context, input, AllowQuirks::No)
|
||||
}
|
||||
|
||||
/// Parse a non-negative length, allowing quirks.
|
||||
#[inline]
|
||||
pub fn parse_non_negative_quirky<'i, 't>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks)
|
||||
-> Result<Length, ParseError<'i>> {
|
||||
pub fn parse_non_negative_quirky<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_internal(context, input, AllowedNumericType::NonNegative, allow_quirks)
|
||||
}
|
||||
|
||||
|
@ -630,10 +633,11 @@ impl Parse for Length {
|
|||
|
||||
impl Length {
|
||||
/// Parses a length, with quirks.
|
||||
pub fn parse_quirky<'i, 't>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
pub fn parse_quirky<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
allow_quirks: AllowQuirks,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_internal(context, input, AllowedNumericType::All, allow_quirks)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue