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

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 176853007: [CSS Grid Layout] Implementation of the grid shorthand. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: The grid shorthand property should not be exposed. Created 6 years, 8 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
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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 1270 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
1271 return false; 1271 return false;
1272 parsedValue = parseGridTemplateAreas(); 1272 parsedValue = parseGridTemplateAreas();
1273 break; 1273 break;
1274 1274
1275 case CSSPropertyGridTemplate: 1275 case CSSPropertyGridTemplate:
1276 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 1276 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
1277 return false; 1277 return false;
1278 return parseGridTemplateShorthand(important); 1278 return parseGridTemplateShorthand(important);
1279 1279
1280 case CSSPropertyGrid:
1281 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
1282 return false;
1283 return parseGridShorthand(important);
1284
1280 case CSSPropertyWebkitMarginCollapse: { 1285 case CSSPropertyWebkitMarginCollapse: {
1281 if (num == 1) { 1286 if (num == 1) {
1282 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1287 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1283 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) 1288 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant))
1284 return false; 1289 return false;
1285 CSSValue* value = m_parsedProperties.last().value(); 1290 CSSValue* value = m_parsedProperties.last().value();
1286 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); 1291 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important);
1287 return true; 1292 return true;
1288 } 1293 }
1289 else if (num == 2) { 1294 else if (num == 2) {
(...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 3597
3593 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax. 3598 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
3594 // The template-columns <track-list> can't be 'none'. 3599 // The template-columns <track-list> can't be 'none'.
3595 if (firstValueIsNone) 3600 if (firstValueIsNone)
3596 return false; 3601 return false;
3597 // It requires to rewind parsing due to previous syntax failures. 3602 // It requires to rewind parsing due to previous syntax failures.
3598 m_valueList->setCurrentIndex(index); 3603 m_valueList->setCurrentIndex(index);
3599 return parseGridTemplateRowsAndAreas(columnsValue, important); 3604 return parseGridTemplateRowsAndAreas(columnsValue, important);
3600 } 3605 }
3601 3606
3607 bool CSSPropertyParser::parseGridShorthand(bool important)
3608 {
3609 ShorthandScope scope(this, CSSPropertyGrid);
3610 const StylePropertyShorthand& shorthand = shorthandForProperty(CSSPropertyGr id);
3611 ASSERT_UNUSED(shorthand, shorthand.length() == 4);
Julien - ping for review 2014/04/03 21:14:30 Can't we just do: ASSERT(shorthandForProperty(CSS
jfernandez 2014/04/04 15:09:35 Done.
3612
3613 // 1- <grid-template>
3614 if (parseGridTemplateShorthand(important)) {
3615 // Default values for the implicit grid properties.
3616 addProperty(CSSPropertyGridAutoFlow, cssValuePool().createIdentifierValu e(CSSValueNone), important);
3617 addProperty(CSSPropertyGridAutoColumns, cssValuePool().createIdentifierV alue(CSSValueAuto), important);
3618 addProperty(CSSPropertyGridAutoRows, cssValuePool().createIdentifierValu e(CSSValueAuto), important);
3619 return true;
3620 }
3621
3622 // Need to rewind parsing to explore the alternative syntax of this shorthan d.
3623 m_valueList->setCurrentIndex(0);
3624
3625 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ]
3626 CSSValueID id = m_valueList->current()->id;
3627 if (id != CSSValueRow && id != CSSValueColumn && id != CSSValueNone)
3628 return false;
3629
3630 RefPtrWillBeRawPtr<CSSValue> autoFlowValue = cssValuePool().createIdentifier Value(id);
3631 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = cssValuePool().createIdentif ierValue(CSSValueAuto);
Julien - ping for review 2014/04/03 21:14:30 I would rather leave both auto*Value to nullptr an
jfernandez 2014/04/04 15:09:35 Done.
3632 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr;
3633
3634 if (m_valueList->next()) {
3635 autoColumnsValue = parseGridTrackSize(*m_valueList);
3636 if (!autoColumnsValue)
3637 return false;
3638 if (m_valueList->current()) {
3639 if (!(isForwardSlashOperator(m_valueList->current()) && m_valueList- >next()))
Julien - ping for review 2014/04/03 21:14:30 Let's avoid !(... && ...) by expanding it.
jfernandez 2014/04/04 15:09:35 Done.
3640 return false;
3641 autoRowsValue = parseGridTrackSize(*m_valueList);
3642 if (!autoRowsValue)
3643 return false;
3644 }
3645 if (m_valueList->current())
3646 return false;
3647 }
3648 addProperty(CSSPropertyGridAutoFlow, autoFlowValue, important);
3649 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important);
3650 if (autoRowsValue)
3651 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important);
3652 else
3653 addProperty(CSSPropertyGridAutoRows, autoColumnsValue, important);
3654
3655 // Default values for the explicit grid properties.
Julien - ping for review 2014/04/03 21:14:30 You should quote the specification here or give a
jfernandez 2014/04/04 15:09:35 Done.
3656 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentifierV alue(CSSValueNone), important);
3657 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifierValu e(CSSValueNone), important);
3658 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifierVal ue(CSSValueNone), important);
3659
3660 return true;
3661 }
3662
3602 bool CSSPropertyParser::parseGridAreaShorthand(bool important) 3663 bool CSSPropertyParser::parseGridAreaShorthand(bool important)
3603 { 3664 {
3604 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3665 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3605 3666
3606 ShorthandScope scope(this, CSSPropertyGridArea); 3667 ShorthandScope scope(this, CSSPropertyGridArea);
3607 const StylePropertyShorthand& shorthand = gridAreaShorthand(); 3668 const StylePropertyShorthand& shorthand = gridAreaShorthand();
3608 ASSERT_UNUSED(shorthand, shorthand.length() == 4); 3669 ASSERT_UNUSED(shorthand, shorthand.length() == 4);
3609 3670
3610 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); 3671 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition();
3611 if (!rowStartValue) 3672 if (!rowStartValue)
(...skipping 4844 matching lines...) Expand 10 before | Expand all | Expand 10 after
8456 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8517 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8457 if (!seenStroke) 8518 if (!seenStroke)
8458 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8519 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8459 if (!seenMarkers) 8520 if (!seenMarkers)
8460 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8521 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8461 8522
8462 return parsedValues.release(); 8523 return parsedValues.release();
8463 } 8524 }
8464 8525
8465 } // namespace WebCore 8526 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698