mirror of
https://github.com/servo/servo.git
synced 2025-06-30 12:03:38 +01:00
style: Don't accept two trailing <line-names> in the grid/grid-template shorthands.
Differential Revision: https://phabricator.services.mozilla.com/D53909
This commit is contained in:
parent
5582de5d7e
commit
014c41f54a
1 changed files with 24 additions and 14 deletions
|
@ -301,27 +301,37 @@
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
let first_line_names = input.try(parse_line_names).unwrap_or_default();
|
let first_line_names = input.try(parse_line_names).unwrap_or_default();
|
||||||
if let Ok(mut string) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
if let Ok(string) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
||||||
let mut strings = vec![];
|
let mut strings = vec![];
|
||||||
let mut values = vec![];
|
let mut values = vec![];
|
||||||
let mut line_names = vec![];
|
let mut line_names = vec![];
|
||||||
let mut names = first_line_names;
|
line_names.push(first_line_names);
|
||||||
loop {
|
|
||||||
line_names.push(names);
|
|
||||||
strings.push(string);
|
strings.push(string);
|
||||||
|
loop {
|
||||||
let size = input.try(|i| TrackSize::parse(context, i)).unwrap_or_default();
|
let size = input.try(|i| TrackSize::parse(context, i)).unwrap_or_default();
|
||||||
values.push(TrackListValue::TrackSize(size));
|
values.push(TrackListValue::TrackSize(size));
|
||||||
names = input.try(parse_line_names).unwrap_or_default();
|
let mut names = input.try(parse_line_names).unwrap_or_default();
|
||||||
if let Ok(v) = input.try(parse_line_names) {
|
let more_names = input.try(parse_line_names);
|
||||||
|
|
||||||
|
match input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
||||||
|
Ok(string) => {
|
||||||
|
strings.push(string);
|
||||||
|
if let Ok(v) = more_names {
|
||||||
|
// We got `[names] [more_names] "string"` - merge the two name lists.
|
||||||
let mut names_vec = names.into_vec();
|
let mut names_vec = names.into_vec();
|
||||||
names_vec.extend(v.into_iter());
|
names_vec.extend(v.into_iter());
|
||||||
names = names_vec.into();
|
names = names_vec.into();
|
||||||
}
|
}
|
||||||
|
line_names.push(names);
|
||||||
string = match input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) {
|
},
|
||||||
Ok(s) => s,
|
Err(e) => {
|
||||||
_ => { // only the named area determines whether we should bail out
|
if more_names.is_ok() {
|
||||||
line_names.push(names.into());
|
// We've parsed `"string" [names] [more_names]` but then failed to parse another `"string"`.
|
||||||
|
// The grammar doesn't allow two trailing `<line-names>` so this is an invalid value.
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
|
// only the named area determines whether we should bail out
|
||||||
|
line_names.push(names);
|
||||||
break
|
break
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue