mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Expand and simplify a macro that's not very useful.
Skip whitespace upfront rather than on each individual branch. The only difference in behavior is that we would've consumed some extra whitespace in the error case, but I don't think that matters at all. We were consuming some extra whitespace as well after the close path command for example, which wasn't parsing anything. Differential Revision: https://phabricator.services.mozilla.com/D40539
This commit is contained in:
parent
2c17050819
commit
0e8b1853a7
1 changed files with 15 additions and 25 deletions
|
@ -631,30 +631,20 @@ impl<'a> PathParser<'a> {
|
|||
} else {
|
||||
IsAbsolute::No
|
||||
};
|
||||
macro_rules! parse_command {
|
||||
( $($($p:pat)|+ => $parse_func:ident,)* ) => {
|
||||
match command {
|
||||
$(
|
||||
$($p)|+ => {
|
||||
skip_wsp(&mut self.chars);
|
||||
self.$parse_func(abs)?;
|
||||
},
|
||||
)*
|
||||
_ => return Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
parse_command!(
|
||||
b'Z' | b'z' => parse_closepath,
|
||||
b'L' | b'l' => parse_lineto,
|
||||
b'H' | b'h' => parse_h_lineto,
|
||||
b'V' | b'v' => parse_v_lineto,
|
||||
b'C' | b'c' => parse_curveto,
|
||||
b'S' | b's' => parse_smooth_curveto,
|
||||
b'Q' | b'q' => parse_quadratic_bezier_curveto,
|
||||
b'T' | b't' => parse_smooth_quadratic_bezier_curveto,
|
||||
b'A' | b'a' => parse_elliptical_arc,
|
||||
);
|
||||
|
||||
skip_wsp(&mut self.chars);
|
||||
match command {
|
||||
b'Z' | b'z' => self.parse_closepath(),
|
||||
b'L' | b'l' => self.parse_lineto(abs),
|
||||
b'H' | b'h' => self.parse_h_lineto(abs),
|
||||
b'V' | b'v' => self.parse_v_lineto(abs),
|
||||
b'C' | b'c' => self.parse_curveto(abs),
|
||||
b'S' | b's' => self.parse_smooth_curveto(abs),
|
||||
b'Q' | b'q' => self.parse_quadratic_bezier_curveto(abs),
|
||||
b'T' | b't' => self.parse_smooth_quadratic_bezier_curveto(abs),
|
||||
b'A' | b'a' => self.parse_elliptical_arc(abs),
|
||||
_ => return Err(()),
|
||||
}?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -688,7 +678,7 @@ impl<'a> PathParser<'a> {
|
|||
}
|
||||
|
||||
/// Parse "closepath" command.
|
||||
fn parse_closepath(&mut self, _absolute: IsAbsolute) -> Result<(), ()> {
|
||||
fn parse_closepath(&mut self) -> Result<(), ()> {
|
||||
self.path.push(PathCommand::ClosePath);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue