From fd3b99027a16b00d93ebea90103ba5e6ff024870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Mon, 3 Jul 2017 11:41:03 -0700 Subject: [PATCH] Prevent parsing 'none' keyword in grid-template's columns part --- .../style/properties/shorthand/position.mako.rs | 13 ++++++------- components/style/values/specified/grid.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthand/position.mako.rs index 4207a07ca03..248127a7aa4 100644 --- a/components/style/properties/shorthand/position.mako.rs +++ b/components/style/properties/shorthand/position.mako.rs @@ -241,7 +241,6 @@ disable_when_testing="True" products="gecko"> use parser::Parse; - use properties::longhands::grid_template_rows; use properties::longhands::grid_template_areas::TemplateAreas; use values::{Either, None_}; use values::generics::grid::{TrackSize, TrackList, TrackListType, concat_serialize_idents}; @@ -297,7 +296,7 @@ }; let template_cols = if input.try(|i| i.expect_delim('/')).is_ok() { - let value = GridTemplateComponent::parse(context, input)?; + let value = GridTemplateComponent::parse_without_none(context, input)?; if let GenericGridTemplateComponent::TrackList(ref list) = value { if list.list_type != TrackListType::Explicit { return Err(StyleParseError::UnspecifiedError.into()) @@ -312,12 +311,12 @@ Ok((GenericGridTemplateComponent::TrackList(template_rows), template_cols, Either::First(template_areas))) } else { - let mut template_rows = grid_template_rows::parse(context, input)?; + let mut template_rows = GridTemplateComponent::parse(context, input)?; if let GenericGridTemplateComponent::TrackList(ref mut list) = template_rows { list.line_names[0] = first_line_names; // won't panic } - Ok((template_rows, grid_template_rows::parse(context, input)?, Either::Second(None_))) + Ok((template_rows, GridTemplateComponent::parse(context, input)?, Either::Second(None_))) } } @@ -401,8 +400,8 @@ spec="https://drafts.csswg.org/css-grid/#propdef-grid" disable_when_testing="True" products="gecko"> + use parser::Parse; use properties::longhands::{grid_auto_columns, grid_auto_rows, grid_auto_flow}; - use properties::longhands::{grid_template_columns, grid_template_rows}; use properties::longhands::grid_auto_flow::computed_value::{AutoFlow, T as SpecifiedAutoFlow}; use values::{Either, None_}; use values::generics::grid::GridTemplateComponent; @@ -447,7 +446,7 @@ temp_rows = rows; temp_cols = cols; temp_areas = areas; - } else if let Ok(rows) = input.try(|i| grid_template_rows::parse(context, i)) { + } else if let Ok(rows) = input.try(|i| GridTemplateComponent::parse(context, i)) { temp_rows = rows; input.expect_delim('/')?; flow = parse_auto_flow(input, false)?; @@ -456,7 +455,7 @@ flow = parse_auto_flow(input, true)?; auto_rows = input.try(|i| grid_auto_rows::parse(context, i)).unwrap_or_default(); input.expect_delim('/')?; - temp_cols = grid_template_columns::parse(context, input)?; + temp_cols = GridTemplateComponent::parse(context, input)?; } Ok(expanded! { diff --git a/components/style/values/specified/grid.rs b/components/style/values/specified/grid.rs index 1be04015792..50d88fee175 100644 --- a/components/style/values/specified/grid.rs +++ b/components/style/values/specified/grid.rs @@ -366,6 +366,14 @@ impl Parse for GridTemplateComponent { // FIXME: Derive Par return Ok(GridTemplateComponent::None) } + Self::parse_without_none(context, input) + } +} + +impl GridTemplateComponent { + /// Parses a `GridTemplateComponent` except `none` keyword. + pub fn parse_without_none<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) + -> Result> { if let Ok(t) = input.try(|i| TrackList::parse(context, i)) { return Ok(GridTemplateComponent::TrackList(t)) }