Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp

Issue 1702013003: [css-grid] Swap columns and rows in grid-template shorthand (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Swap columns and rows in tests under fast/repaint/ Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
index 04699821fd86048d37303e5eaafed4ebdaafd0fe..abb7cd7d838bc88b271b0412ff42f5119fd481f6 100644
--- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
@@ -1498,7 +1498,20 @@ bool CSSPropertyParser::parseGridGapShorthand(bool important)
return true;
}
-bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSSValue> templateColumns, bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateColumns(bool important)
+{
+ if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->current()) && m_valueList->next()))
+ return nullptr;
+ if (RefPtrWillBeRawPtr<CSSValue> columnsValue = parseGridTrackList()) {
+ if (m_valueList->current())
+ return nullptr;
+ return columnsValue;
+ }
+
+ return nullptr;
+}
+
+bool CSSPropertyParser::parseGridTemplateRowsAndAreasAndColumns(bool important)
{
NamedGridAreaMap gridAreaMap;
size_t rowCount = 0;
@@ -1507,10 +1520,10 @@ bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSeparated();
// At least template-areas strings must be defined.
- if (!m_valueList->current())
+ if (!m_valueList->current() || isForwardSlashOperator(m_valueList->current()))
return false;
- while (m_valueList->current()) {
+ while (m_valueList->current() && !isForwardSlashOperator(m_valueList->current())) {
// Handle leading <custom-ident>*.
if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdded ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : nullptr))
return false;
@@ -1521,7 +1534,7 @@ bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
++rowCount;
// Handle template-rows's track-size.
- if (m_valueList->current() && m_valueList->current()->m_unit != CSSParserValue::String) {
+ if (m_valueList->current() && !isForwardSlashOperator(m_valueList->current()) && m_valueList->current()->m_unit != CSSParserValue::String) {
RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList);
if (!value)
return false;
@@ -1536,16 +1549,22 @@ bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)->isGridLineNamesValue();
}
- // [<track-list> /]?
- if (templateColumns)
- addProperty(CSSPropertyGridTemplateColumns, templateColumns, important);
- else
- addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentifierValue(CSSValueNone), important);
+ RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr;
+ if (m_valueList->current()) {
+ ASSERT(isForwardSlashOperator(m_valueList->current()));
+ columnsValue = parseGridTemplateColumns(important);
+ if (!columnsValue)
+ return false;
+ // The template-columns <track-list> can't be 'none'.
+ if (columnsValue->isPrimitiveValue() && toCSSPrimitiveValue(*columnsValue).getValueID() == CSSValueNone)
+ return false;
+ }
+
+ addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
+ addProperty(CSSPropertyGridTemplateColumns, columnsValue ? columnsValue.release() : cssValuePool().createIdentifierValue(CSSValueNone), important);
- // [<line-names>? <string> [<track-size> <line-names>]? ]+
RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount);
addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important);
- addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
return true;
}
@@ -1572,37 +1591,29 @@ bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
return true;
}
- unsigned index = 0;
- RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr;
+ // 2- <grid-template-rows> / <grid-template-columns>
+ RefPtrWillBeRawPtr<CSSValue> rowsValue = nullptr;
if (firstValueIsNone) {
- columnsValue = cssValuePool().createIdentifierValue(CSSValueNone);
+ rowsValue = cssValuePool().createIdentifierValue(CSSValueNone);
} else {
- columnsValue = parseGridTrackList();
+ rowsValue = parseGridTrackList();
}
- // 2- <grid-template-columns> / <grid-template-columns> syntax.
- if (columnsValue) {
- if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->current()) && m_valueList->next()))
+ if (rowsValue) {
+ RefPtrWillBeRawPtr<CSSValue> columnsValue = parseGridTemplateColumns(important);
+ if (!columnsValue)
return false;
- index = m_valueList->currentIndex();
- if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) {
- if (m_valueList->current())
- return false;
- addProperty(CSSPropertyGridTemplateColumns, columnsValue, important);
- addProperty(CSSPropertyGridTemplateRows, rowsValue, important);
- addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifierValue(CSSValueNone), important);
- return true;
- }
- }
+ addProperty(CSSPropertyGridTemplateRows, rowsValue.release(), important);
+ addProperty(CSSPropertyGridTemplateColumns, columnsValue.release(), important);
+ addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifierValue(CSSValueNone), important);
+ return true;
+ }
- // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
- // The template-columns <track-list> can't be 'none'.
- if (firstValueIsNone)
- return false;
+ // 3- [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
// It requires to rewind parsing due to previous syntax failures.
- m_valueList->setCurrentIndex(index);
- return parseGridTemplateRowsAndAreas(columnsValue, important);
+ m_valueList->setCurrentIndex(0);
+ return parseGridTemplateRowsAndAreasAndColumns(important);
}
bool CSSPropertyParser::parseGridShorthand(bool important)
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698