mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fix parsing of 'subgrid' and 'none' keywords in grid-template
This commit is contained in:
parent
f7aac8d225
commit
ba6641de58
2 changed files with 26 additions and 4 deletions
|
@ -243,7 +243,7 @@
|
|||
use parser::Parse;
|
||||
use properties::longhands::grid_template_areas::TemplateAreas;
|
||||
use values::{Either, None_};
|
||||
use values::generics::grid::{TrackSize, TrackList, TrackListType, concat_serialize_idents};
|
||||
use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType, concat_serialize_idents};
|
||||
use values::specified::{GridTemplateComponent, GenericGridTemplateComponent};
|
||||
use values::specified::grid::parse_line_names;
|
||||
|
||||
|
@ -252,9 +252,31 @@
|
|||
-> Result<(GridTemplateComponent,
|
||||
GridTemplateComponent,
|
||||
Either<TemplateAreas, None_>), ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok((GenericGridTemplateComponent::None, GenericGridTemplateComponent::None, Either::Second(None_)))
|
||||
|
||||
// Other shorthand sub properties also parse `none` and `subgrid` keywords and this
|
||||
// shorthand should know after these keywords there is nothing to parse. Otherwise it
|
||||
// gets confused and rejects the sub properties that contains `none` or `subgrid`.
|
||||
<% keywords = {
|
||||
"none": "GenericGridTemplateComponent::None",
|
||||
"subgrid": "GenericGridTemplateComponent::Subgrid(LineNameList::default())"
|
||||
}
|
||||
%>
|
||||
% for keyword, rust_type in keywords.items():
|
||||
if let Ok(x) = input.try(|i| {
|
||||
if i.try(|i| i.expect_ident_matching("${keyword}")).is_ok() {
|
||||
if i.is_exhausted() {
|
||||
return Ok((${rust_type},
|
||||
${rust_type},
|
||||
Either::Second(None_)))
|
||||
} else {
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
Err(())
|
||||
}) {
|
||||
return Ok(x);
|
||||
}
|
||||
% endfor
|
||||
|
||||
let first_line_names = input.try(parse_line_names).unwrap_or(vec![]);
|
||||
if let Ok(s) = input.try(Parser::expect_string) {
|
||||
|
|
|
@ -583,7 +583,7 @@ impl<T: ToCss> ToCss for TrackList<T> {
|
|||
///
|
||||
/// `subgrid [ <line-names> | repeat(<positive-integer> | auto-fill, <line-names>+) ]+`
|
||||
/// Old spec: https://www.w3.org/TR/2015/WD-css-grid-1-20150917/#typedef-line-name-list
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug, Default)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct LineNameList {
|
||||
/// The optional `<line-name-list>`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue