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

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: Fixed compilation error in debug. 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 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after
3591 3596
3592 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax. 3597 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
3593 // The template-columns <track-list> can't be 'none'. 3598 // The template-columns <track-list> can't be 'none'.
3594 if (firstValueIsNone) 3599 if (firstValueIsNone)
3595 return false; 3600 return false;
3596 // It requires to rewind parsing due to previous syntax failures. 3601 // It requires to rewind parsing due to previous syntax failures.
3597 m_valueList->setCurrentIndex(index); 3602 m_valueList->setCurrentIndex(index);
3598 return parseGridTemplateRowsAndAreas(columnsValue, important); 3603 return parseGridTemplateRowsAndAreas(columnsValue, important);
3599 } 3604 }
3600 3605
3606 bool CSSPropertyParser::parseGridShorthand(bool important)
3607 {
3608 ShorthandScope scope(this, CSSPropertyGrid);
3609 ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 4);
3610
3611 // 1- <grid-template>
3612 if (parseGridTemplateShorthand(important)) {
3613 // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
3614 // The sub-properties not specified are set to their initial value, as n ormal for shorthands.
3615 addProperty(CSSPropertyGridAutoFlow, cssValuePool().createImplicitInitia lValue(), important);
3616 addProperty(CSSPropertyGridAutoColumns, cssValuePool().createImplicitIni tialValue(), important);
3617 addProperty(CSSPropertyGridAutoRows, cssValuePool().createImplicitInitia lValue(), important);
3618 return true;
3619 }
3620
3621 // Need to rewind parsing to explore the alternative syntax of this shorthan d.
3622 m_valueList->setCurrentIndex(0);
3623
3624 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ]
3625 CSSValueID id = m_valueList->current()->id;
3626 if (id != CSSValueRow && id != CSSValueColumn && id != CSSValueNone)
3627 return false;
3628
3629 RefPtrWillBeRawPtr<CSSValue> autoFlowValue = cssValuePool().createIdentifier Value(id);
3630 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = nullptr;
3631 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr;
3632
3633 if (m_valueList->next()) {
3634 autoColumnsValue = parseGridTrackSize(*m_valueList);
3635 if (!autoColumnsValue)
3636 return false;
3637 if (m_valueList->current()) {
3638 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next())
3639 return false;
3640 autoRowsValue = parseGridTrackSize(*m_valueList);
3641 if (!autoRowsValue)
3642 return false;
3643 }
3644 if (m_valueList->current())
3645 return false;
3646 } else {
3647 // Other omitted values are set to their initial values.
3648 autoColumnsValue = cssValuePool().createImplicitInitialValue();
3649 autoRowsValue = cssValuePool().createImplicitInitialValue();
3650 }
3651
3652 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns.
3653 if (!autoRowsValue)
3654 autoRowsValue = autoColumnsValue;
3655
3656 addProperty(CSSPropertyGridAutoFlow, autoFlowValue, important);
3657 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important);
3658 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important);
3659
3660 // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
3661 // The sub-properties not specified are set to their initial value, as norma l for shorthands.
3662 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important);
3663 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important);
3664 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important);
3665
3666 return true;
3667 }
3668
3601 bool CSSPropertyParser::parseGridAreaShorthand(bool important) 3669 bool CSSPropertyParser::parseGridAreaShorthand(bool important)
3602 { 3670 {
3603 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3671 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3604 3672
3605 ShorthandScope scope(this, CSSPropertyGridArea); 3673 ShorthandScope scope(this, CSSPropertyGridArea);
3606 const StylePropertyShorthand& shorthand = gridAreaShorthand(); 3674 const StylePropertyShorthand& shorthand = gridAreaShorthand();
3607 ASSERT_UNUSED(shorthand, shorthand.length() == 4); 3675 ASSERT_UNUSED(shorthand, shorthand.length() == 4);
3608 3676
3609 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); 3677 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition();
3610 if (!rowStartValue) 3678 if (!rowStartValue)
(...skipping 4844 matching lines...) Expand 10 before | Expand all | Expand 10 after
8455 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8523 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8456 if (!seenStroke) 8524 if (!seenStroke)
8457 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8525 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8458 if (!seenMarkers) 8526 if (!seenMarkers)
8459 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8527 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8460 8528
8461 return parsedValues.release(); 8529 return parsedValues.release();
8462 } 8530 }
8463 8531
8464 } // namespace WebCore 8532 } // 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