mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #17021 - servo:grid, r=nox
Stylo: Wrap up grid Adds the final piece for grid (`grid-template` and `grid` shorthands), fixes #15307 <!-- 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/17021) <!-- Reviewable:end -->
This commit is contained in:
commit
9e7f02ba77
3 changed files with 289 additions and 9 deletions
|
@ -76,21 +76,35 @@ impl Parse for GridLine {
|
|||
return Ok(grid_line)
|
||||
}
|
||||
|
||||
// <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]
|
||||
// This <grid-line> horror is simply,
|
||||
// [ span? && [ <custom-ident> || <integer> ] ]
|
||||
// And, for some magical reason, "span" should be the first or last value and not in-between.
|
||||
let mut val_before_span = false;
|
||||
|
||||
for _ in 0..3 { // Maximum possible entities for <grid-line>
|
||||
if input.try(|i| i.expect_ident_matching("span")).is_ok() {
|
||||
if grid_line.is_span || grid_line.line_num.is_some() || grid_line.ident.is_some() {
|
||||
return Err(()) // span (if specified) should be first
|
||||
}
|
||||
grid_line.is_span = true; // span (if specified) should be first
|
||||
} else if let Ok(i) = input.try(|i| Integer::parse(context, i)) {
|
||||
if i.value() == 0 || grid_line.line_num.is_some() {
|
||||
if grid_line.is_span {
|
||||
return Err(())
|
||||
}
|
||||
|
||||
if grid_line.line_num.is_some() || grid_line.ident.is_some() {
|
||||
val_before_span = true;
|
||||
}
|
||||
|
||||
grid_line.is_span = true;
|
||||
} else if let Ok(i) = input.try(|i| Integer::parse(context, i)) {
|
||||
if i.value() == 0 || val_before_span || grid_line.line_num.is_some() {
|
||||
return Err(())
|
||||
}
|
||||
|
||||
grid_line.line_num = Some(i);
|
||||
} else if let Ok(name) = input.try(|i| i.expect_ident()) {
|
||||
if grid_line.ident.is_some() || CustomIdent::from_ident((&*name).into(), &[]).is_err() {
|
||||
if val_before_span || grid_line.ident.is_some() ||
|
||||
CustomIdent::from_ident((&*name).into(), &[]).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
|
||||
grid_line.ident = Some(name.into_owned());
|
||||
} else {
|
||||
break
|
||||
|
@ -292,8 +306,10 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
|||
}
|
||||
}
|
||||
|
||||
fn concat_serialize_idents<W>(prefix: &str, suffix: &str,
|
||||
slice: &[String], sep: &str, dest: &mut W) -> fmt::Result
|
||||
/// Helper function for serializing identifiers with a prefix and suffix, used
|
||||
/// for serializing <line-names> (in grid).
|
||||
pub fn concat_serialize_idents<W>(prefix: &str, suffix: &str,
|
||||
slice: &[String], sep: &str, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write
|
||||
{
|
||||
if let Some((ref first, rest)) = slice.split_first() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue