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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 } else { 1491 } else {
1492 rowGap = columnGap; 1492 rowGap = columnGap;
1493 } 1493 }
1494 1494
1495 addProperty(CSSPropertyGridColumnGap, columnGap, important); 1495 addProperty(CSSPropertyGridColumnGap, columnGap, important);
1496 addProperty(CSSPropertyGridRowGap, rowGap, important); 1496 addProperty(CSSPropertyGridRowGap, rowGap, important);
1497 1497
1498 return true; 1498 return true;
1499 } 1499 }
1500 1500
1501 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS Value> templateColumns, bool important) 1501 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateColumns(boo l important)
1502 {
1503 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->current( )) && m_valueList->next()))
1504 return nullptr;
1505 if (RefPtrWillBeRawPtr<CSSValue> columnsValue = parseGridTrackList()) {
1506 if (m_valueList->current())
1507 return nullptr;
1508 return columnsValue;
1509 }
1510
1511 return nullptr;
1512 }
1513
1514 bool CSSPropertyParser::parseGridTemplateRowsAndAreasAndColumns(bool important)
1502 { 1515 {
1503 NamedGridAreaMap gridAreaMap; 1516 NamedGridAreaMap gridAreaMap;
1504 size_t rowCount = 0; 1517 size_t rowCount = 0;
1505 size_t columnCount = 0; 1518 size_t columnCount = 0;
1506 bool trailingIdentWasAdded = false; 1519 bool trailingIdentWasAdded = false;
1507 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated(); 1520 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated();
1508 1521
1509 // At least template-areas strings must be defined. 1522 // At least template-areas strings must be defined.
1510 if (!m_valueList->current()) 1523 if (!m_valueList->current() || isForwardSlashOperator(m_valueList->current() ))
1511 return false; 1524 return false;
1512 1525
1513 while (m_valueList->current()) { 1526 while (m_valueList->current() && !isForwardSlashOperator(m_valueList->curren t())) {
1514 // Handle leading <custom-ident>*. 1527 // Handle leading <custom-ident>*.
1515 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n ullptr)) 1528 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n ullptr))
1516 return false; 1529 return false;
1517 1530
1518 // Handle a template-area's row. 1531 // Handle a template-area's row.
1519 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 1532 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
1520 return false; 1533 return false;
1521 ++rowCount; 1534 ++rowCount;
1522 1535
1523 // Handle template-rows's track-size. 1536 // Handle template-rows's track-size.
1524 if (m_valueList->current() && m_valueList->current()->m_unit != CSSParse rValue::String) { 1537 if (m_valueList->current() && !isForwardSlashOperator(m_valueList->curre nt()) && m_valueList->current()->m_unit != CSSParserValue::String) {
1525 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 1538 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList );
1526 if (!value) 1539 if (!value)
1527 return false; 1540 return false;
1528 templateRows->append(value); 1541 templateRows->append(value);
1529 } else { 1542 } else {
1530 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); 1543 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to));
1531 } 1544 }
1532 1545
1533 // This will handle the trailing/leading <custom-ident>* in the grammar. 1546 // This will handle the trailing/leading <custom-ident>* in the grammar.
1534 if (!parseGridLineNames(*m_valueList, *templateRows)) 1547 if (!parseGridLineNames(*m_valueList, *templateRows))
1535 return false; 1548 return false;
1536 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)-> isGridLineNamesValue(); 1549 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)-> isGridLineNamesValue();
1537 } 1550 }
1538 1551
1539 // [<track-list> /]? 1552 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr;
1540 if (templateColumns) 1553 if (m_valueList->current()) {
1541 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); 1554 ASSERT(isForwardSlashOperator(m_valueList->current()));
1542 else 1555 columnsValue = parseGridTemplateColumns(important);
1543 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important); 1556 if (!columnsValue)
1557 return false;
1558 // The template-columns <track-list> can't be 'none'.
1559 if (columnsValue->isPrimitiveValue() && toCSSPrimitiveValue(*columnsValu e).getValueID() == CSSValueNone)
1560 return false;
1561 }
1544 1562
1545 // [<line-names>? <string> [<track-size> <line-names>]? ]+ 1563 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
1564 addProperty(CSSPropertyGridTemplateColumns, columnsValue ? columnsValue.rele ase() : cssValuePool().createIdentifierValue(CSSValueNone), important);
1565
1546 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea te(gridAreaMap, rowCount, columnCount); 1566 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea te(gridAreaMap, rowCount, columnCount);
1547 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important ); 1567 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important );
1548 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
1549 1568
1550 return true; 1569 return true;
1551 } 1570 }
1552 1571
1553 1572
1554 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) 1573 bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
1555 { 1574 {
1556 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 1575 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
1557 1576
1558 ShorthandScope scope(this, CSSPropertyGridTemplate); 1577 ShorthandScope scope(this, CSSPropertyGridTemplate);
1559 ASSERT(gridTemplateShorthand().length() == 3); 1578 ASSERT(gridTemplateShorthand().length() == 3);
1560 1579
1561 // At least "none" must be defined. 1580 // At least "none" must be defined.
1562 if (!m_valueList->current()) 1581 if (!m_valueList->current())
1563 return false; 1582 return false;
1564 1583
1565 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; 1584 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone;
1566 1585
1567 // 1- 'none' case. 1586 // 1- 'none' case.
1568 if (firstValueIsNone && !m_valueList->next()) { 1587 if (firstValueIsNone && !m_valueList->next()) {
1569 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important); 1588 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important);
1570 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important); 1589 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important);
1571 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important); 1590 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important);
1572 return true; 1591 return true;
1573 } 1592 }
1574 1593
1575 unsigned index = 0; 1594 // 2- <grid-template-rows> / <grid-template-columns>
1576 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr; 1595 RefPtrWillBeRawPtr<CSSValue> rowsValue = nullptr;
1577 if (firstValueIsNone) { 1596 if (firstValueIsNone) {
1578 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); 1597 rowsValue = cssValuePool().createIdentifierValue(CSSValueNone);
1579 } else { 1598 } else {
1580 columnsValue = parseGridTrackList(); 1599 rowsValue = parseGridTrackList();
1581 } 1600 }
1582 1601
1583 // 2- <grid-template-columns> / <grid-template-columns> syntax. 1602 if (rowsValue) {
1584 if (columnsValue) { 1603 RefPtrWillBeRawPtr<CSSValue> columnsValue = parseGridTemplateColumns(imp ortant);
1585 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next())) 1604 if (!columnsValue)
1586 return false; 1605 return false;
1587 index = m_valueList->currentIndex(); 1606
1588 if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) { 1607 addProperty(CSSPropertyGridTemplateRows, rowsValue.release(), important) ;
1589 if (m_valueList->current()) 1608 addProperty(CSSPropertyGridTemplateColumns, columnsValue.release(), impo rtant);
1590 return false; 1609 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important);
1591 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important) ; 1610 return true;
1592 addProperty(CSSPropertyGridTemplateRows, rowsValue, important);
1593 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important);
1594 return true;
1595 }
1596 } 1611 }
1597 1612
1598 1613 // 3- [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
1599 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
1600 // The template-columns <track-list> can't be 'none'.
1601 if (firstValueIsNone)
1602 return false;
1603 // It requires to rewind parsing due to previous syntax failures. 1614 // It requires to rewind parsing due to previous syntax failures.
1604 m_valueList->setCurrentIndex(index); 1615 m_valueList->setCurrentIndex(0);
1605 return parseGridTemplateRowsAndAreas(columnsValue, important); 1616 return parseGridTemplateRowsAndAreasAndColumns(important);
1606 } 1617 }
1607 1618
1608 bool CSSPropertyParser::parseGridShorthand(bool important) 1619 bool CSSPropertyParser::parseGridShorthand(bool important)
1609 { 1620 {
1610 ShorthandScope scope(this, CSSPropertyGrid); 1621 ShorthandScope scope(this, CSSPropertyGrid);
1611 ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8); 1622 ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8);
1612 1623
1613 // 1- <grid-template> 1624 // 1- <grid-template>
1614 if (parseGridTemplateShorthand(important)) { 1625 if (parseGridTemplateShorthand(important)) {
1615 // It can only be specified the explicit or the implicit grid properties in a single grid declaration. 1626 // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 ASSERT(!m_parsedCalculation); 3212 ASSERT(!m_parsedCalculation);
3202 m_parsedCalculation = CSSCalcValue::create(args, range); 3213 m_parsedCalculation = CSSCalcValue::create(args, range);
3203 3214
3204 if (!m_parsedCalculation) 3215 if (!m_parsedCalculation)
3205 return false; 3216 return false;
3206 3217
3207 return true; 3218 return true;
3208 } 3219 }
3209 3220
3210 } // namespace blink 3221 } // namespace blink
OLDNEW
« 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