style: Change the parsing order of border shorthands.

It's not ambiguous, and <width> <style> <color> seems like a more common order.

This is just a minor perf tweak, as the CSS parser token cache will most often
kick in to avoid re-tokenizing values.

Also remove a redundant continue statement.

Differential Revision: https://phabricator.services.mozilla.com/D67224
This commit is contained in:
Emilio Cobos Álvarez 2020-03-17 21:48:33 +00:00
parent ccc41dd89d
commit ece146988c

View file

@ -70,11 +70,10 @@ pub fn parse_border<'i, 't>(
let mut width = None;
let mut any = false;
loop {
if color.is_none() {
if let Ok(value) = input.try(|i| Color::parse(context, i)) {
color = Some(value);
if width.is_none() {
if let Ok(value) = input.try(|i| BorderSideWidth::parse(context, i)) {
width = Some(value);
any = true;
continue
}
}
if style.is_none() {
@ -84,9 +83,9 @@ pub fn parse_border<'i, 't>(
continue
}
}
if width.is_none() {
if let Ok(value) = input.try(|i| BorderSideWidth::parse(context, i)) {
width = Some(value);
if color.is_none() {
if let Ok(value) = input.try(|i| Color::parse(context, i)) {
color = Some(value);
any = true;
continue
}