From 94dd6e702fba6adc121716e671553b1ee5252155 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 27 Jan 2016 17:02:13 +0100 Subject: [PATCH] Bug 1240956 part 3 - [css-grid] Add a ParseGridTrackList convenience method. r=dholbert --- layout/style/nsCSSParser.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 93b03963ce73..85d84c20d51d 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -962,6 +962,8 @@ protected: // and alternating between that and . bool ParseGridTrackListWithFirstLineNames(nsCSSValue& aValue, const nsCSSValue& aFirstLineNames); + + bool ParseGridTrackList(nsCSSProperty aPropID); bool ParseGridTemplateColumnsRows(nsCSSProperty aPropID); // |aAreaIndices| is a lookup table to help us parse faster, @@ -8935,6 +8937,19 @@ CSSParserImpl::ParseGridTrackListRepeat(nsCSSValueList** aTailPtr) return true; } +bool +CSSParserImpl::ParseGridTrackList(nsCSSProperty aPropID) +{ + nsCSSValue value; + nsCSSValue firstLineNames; + if (ParseGridLineNames(firstLineNames) == CSSParseResult::Error || + !ParseGridTrackListWithFirstLineNames(value, firstLineNames)) { + return false; + } + AppendValue(aPropID, value); + return true; +} + bool CSSParserImpl::ParseGridTemplateColumnsRows(nsCSSProperty aPropID) { @@ -8960,13 +8975,7 @@ CSSParserImpl::ParseGridTemplateColumnsRows(nsCSSProperty aPropID) UngetToken(); } - nsCSSValue firstLineNames; - if (ParseGridLineNames(firstLineNames) == CSSParseResult::Error || - !ParseGridTrackListWithFirstLineNames(value, firstLineNames)) { - return false; - } - AppendValue(aPropID, value); - return true; + return ParseGridTrackList(aPropID); } bool @@ -9160,14 +9169,9 @@ CSSParserImpl::ParseGridTemplate() } // Parse an optional [ / ] as the columns value. if (ExpectSymbol('/', true)) { - nsCSSValue lineNames; - if (ParseGridLineNames(lineNames) == CSSParseResult::Error || - !ParseGridTrackListWithFirstLineNames(value, lineNames)) { - return false; - } - } else { - value.SetNoneValue(); // absent means 'none' + return ParseGridTrackList(eCSSProperty_grid_template_columns); } + value.SetNoneValue(); // absent means 'none' AppendValue(eCSSProperty_grid_template_columns, value); return true; }