diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-04-02 13:36:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 13:36:01 -0400 |
commit | a208d4246cf0e02a1a22196f26692bd29fb35011 (patch) | |
tree | 91a8d818406a68d9fd76902e3e0d82ad48258a8d | |
parent | 39018f933997e266e11968d82f556af15c5321d8 (diff) | |
parent | 15c416b133d21c07881e544e7abb068d0cbf1ff0 (diff) | |
download | servo-a208d4246cf0e02a1a22196f26692bd29fb35011.tar.gz servo-a208d4246cf0e02a1a22196f26692bd29fb35011.zip |
Auto merge of #20501 - emilio:parsing-style, r=nox
style: Use a more consistent style for parsing functions.
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20501)
<!-- Reviewable:end -->
14 files changed, 126 insertions, 69 deletions
diff --git a/components/style/properties/longhand/svg.mako.rs b/components/style/properties/longhand/svg.mako.rs index 691b6870421..bea30301eb2 100644 --- a/components/style/properties/longhand/svg.mako.rs +++ b/components/style/properties/longhand/svg.mako.rs @@ -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> diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index 8fd2101ecec..b16c9918a24 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -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 diff --git a/components/style/properties/shorthand/border.mako.rs b/components/style/properties/shorthand/border.mako.rs index ec462510bf7..da3f8abbf33 100644 --- a/components/style/properties/shorthand/border.mako.rs +++ b/components/style/properties/shorthand/border.mako.rs @@ -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 diff --git a/components/style/properties/shorthand/box.mako.rs b/components/style/properties/shorthand/box.mako.rs index e9c87dca6aa..7f2fe128eb2 100644 --- a/components/style/properties/shorthand/box.mako.rs +++ b/components/style/properties/shorthand/box.mako.rs @@ -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, diff --git a/components/style/properties/shorthand/column.mako.rs b/components/style/properties/shorthand/column.mako.rs index a382850b672..cdd05dc786b 100644 --- a/components/style/properties/shorthand/column.mako.rs +++ b/components/style/properties/shorthand/column.mako.rs @@ -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 diff --git a/components/style/properties/shorthand/font.mako.rs b/components/style/properties/shorthand/font.mako.rs index c2f8a09a6b0..cc3cd819cf2 100644 --- a/components/style/properties/shorthand/font.mako.rs +++ b/components/style/properties/shorthand/font.mako.rs @@ -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 diff --git a/components/style/properties/shorthand/inherited_svg.mako.rs b/components/style/properties/shorthand/inherited_svg.mako.rs index 1742ef28ed7..0984e879369 100644 --- a/components/style/properties/shorthand/inherited_svg.mako.rs +++ b/components/style/properties/shorthand/inherited_svg.mako.rs @@ -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)?; diff --git a/components/style/properties/shorthand/inherited_text.mako.rs b/components/style/properties/shorthand/inherited_text.mako.rs index 95850f5c043..98ded998bb1 100644 --- a/components/style/properties/shorthand/inherited_text.mako.rs +++ b/components/style/properties/shorthand/inherited_text.mako.rs @@ -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 { diff --git a/components/style/properties/shorthand/list.mako.rs b/components/style/properties/shorthand/list.mako.rs index 2468433e9b0..d7b723adf62 100644 --- a/components/style/properties/shorthand/list.mako.rs +++ b/components/style/properties/shorthand/list.mako.rs @@ -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; diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthand/mask.mako.rs index 483ce9b50f8..d38eedb5854 100644 --- a/components/style/properties/shorthand/mask.mako.rs +++ b/components/style/properties/shorthand/mask.mako.rs @@ -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 diff --git a/components/style/properties/shorthand/outline.mako.rs b/components/style/properties/shorthand/outline.mako.rs index 95d6b0be28a..d2f04466629 100644 --- a/components/style/properties/shorthand/outline.mako.rs +++ b/components/style/properties/shorthand/outline.mako.rs @@ -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, diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthand/position.mako.rs index 971f74ddb8f..2c58895c9d0 100644 --- a/components/style/properties/shorthand/position.mako.rs +++ b/components/style/properties/shorthand/position.mako.rs @@ -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 { diff --git a/components/style/properties/shorthand/text.mako.rs b/components/style/properties/shorthand/text.mako.rs index c53f1b8b27e..18a0786494d 100644 --- a/components/style/properties/shorthand/text.mako.rs +++ b/components/style/properties/shorthand/text.mako.rs @@ -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: diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index e3325794ab2..830c0828ecd 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -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) } } |