mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add function to parse <line-names>
This commit is contained in:
parent
5d1e02760b
commit
53c7b0ac15
1 changed files with 20 additions and 2 deletions
|
@ -9,7 +9,7 @@ use parser::{Parse, ParserContext};
|
|||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::{CSSFloat, HasViewportPercentage};
|
||||
use values::{CSSFloat, CustomIdent, HasViewportPercentage};
|
||||
use values::computed::{ComputedValueAsSpecified, Context, ToComputedValue};
|
||||
use values::specified::LengthOrPercentage;
|
||||
|
||||
|
@ -18,7 +18,6 @@ use values::specified::LengthOrPercentage;
|
|||
/// A `<grid-line>` type.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-grid/#typedef-grid-row-start-grid-line
|
||||
#[allow(missing_docs)]
|
||||
pub struct GridLine {
|
||||
/// Flag to check whether it's a `span` keyword.
|
||||
pub is_span: bool,
|
||||
|
@ -306,3 +305,22 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse the grid line names into a vector of owned strings.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-grid/#typedef-line-names
|
||||
pub fn parse_line_names(input: &mut Parser) -> Result<Vec<String>, ()> {
|
||||
input.expect_square_bracket_block()?;
|
||||
input.parse_nested_block(|input| {
|
||||
let mut values = vec![];
|
||||
while let Ok(ident) = input.try(|i| i.expect_ident()) {
|
||||
if CustomIdent::from_ident((&*ident).into(), &["span"]).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
|
||||
values.push(ident.into_owned());
|
||||
}
|
||||
|
||||
Ok(values)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue