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

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

Issue 636993002: [CSS Grid Layout] Upgrade justify-content parsing to CSS3 Box Alignment spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline some tests expectations. Created 6 years, 1 month 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 | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleAdjuster.cpp » ('j') | 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 15 matching lines...) Expand all
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/css/parser/CSSPropertyParser.h" 28 #include "core/css/parser/CSSPropertyParser.h"
29 29
30 // FIXME: Way too many! 30 // FIXME: Way too many!
31 #include "core/CSSValueKeywords.h" 31 #include "core/CSSValueKeywords.h"
32 #include "core/StylePropertyShorthand.h" 32 #include "core/StylePropertyShorthand.h"
33 #include "core/css/CSSBasicShapes.h" 33 #include "core/css/CSSBasicShapes.h"
34 #include "core/css/CSSBorderImage.h" 34 #include "core/css/CSSBorderImage.h"
35 #include "core/css/CSSCanvasValue.h" 35 #include "core/css/CSSCanvasValue.h"
36 #include "core/css/CSSContentDistributionValue.h"
36 #include "core/css/CSSCrossfadeValue.h" 37 #include "core/css/CSSCrossfadeValue.h"
37 #include "core/css/CSSCursorImageValue.h" 38 #include "core/css/CSSCursorImageValue.h"
38 #include "core/css/CSSFontFaceSrcValue.h" 39 #include "core/css/CSSFontFaceSrcValue.h"
39 #include "core/css/CSSFontFeatureValue.h" 40 #include "core/css/CSSFontFeatureValue.h"
40 #include "core/css/CSSFunctionValue.h" 41 #include "core/css/CSSFunctionValue.h"
41 #include "core/css/CSSGradientValue.h" 42 #include "core/css/CSSGradientValue.h"
42 #include "core/css/CSSGridLineNamesValue.h" 43 #include "core/css/CSSGridLineNamesValue.h"
43 #include "core/css/CSSGridTemplateAreasValue.h" 44 #include "core/css/CSSGridTemplateAreasValue.h"
44 #include "core/css/CSSImageSetValue.h" 45 #include "core/css/CSSImageSetValue.h"
45 #include "core/css/CSSImageValue.h" 46 #include "core/css/CSSImageValue.h"
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 case CSSPropertyWebkitTransitionDuration: 1196 case CSSPropertyWebkitTransitionDuration:
1196 case CSSPropertyWebkitTransitionTimingFunction: 1197 case CSSPropertyWebkitTransitionTimingFunction:
1197 case CSSPropertyWebkitTransitionProperty: { 1198 case CSSPropertyWebkitTransitionProperty: {
1198 if (RefPtrWillBeRawPtr<CSSValueList> val = parseAnimationPropertyList(pr opId)) { 1199 if (RefPtrWillBeRawPtr<CSSValueList> val = parseAnimationPropertyList(pr opId)) {
1199 addPropertyWithPrefixingVariant(propId, val.release(), important); 1200 addPropertyWithPrefixingVariant(propId, val.release(), important);
1200 return true; 1201 return true;
1201 } 1202 }
1202 return false; 1203 return false;
1203 } 1204 }
1204 1205
1206 case CSSPropertyJustifyContent:
1207 parsedValue = parseContentDistributionOverflowPosition();
1208 break;
1205 case CSSPropertyJustifySelf: 1209 case CSSPropertyJustifySelf:
1206 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 1210 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
1207 return parseItemPositionOverflowPosition(propId, important); 1211 return parseItemPositionOverflowPosition(propId, important);
1208 case CSSPropertyJustifyItems: 1212 case CSSPropertyJustifyItems:
1209 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 1213 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
1210 1214
1211 if (parseLegacyPosition(propId, important)) 1215 if (parseLegacyPosition(propId, important))
1212 return true; 1216 return true;
1213 1217
1214 m_valueList->setCurrentIndex(0); 1218 m_valueList->setCurrentIndex(0);
(...skipping 2807 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 } 4026 }
4023 default: 4027 default:
4024 return nullptr; 4028 return nullptr;
4025 } 4029 }
4026 4030
4027 if (hasRoundedInset) 4031 if (hasRoundedInset)
4028 return parseInsetRoundedCorners(shape, args); 4032 return parseInsetRoundedCorners(shape, args);
4029 return shape; 4033 return shape;
4030 } 4034 }
4031 4035
4036 static bool isContentDistributionKeyword(CSSValueID id)
4037 {
4038 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround
4039 || id == CSSValueSpaceEvenly || id == CSSValueStretch;
4040 }
4041
4042 static bool isContentPositionKeyword(CSSValueID id)
4043 {
4044 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
4045 || id == CSSValueFlexStart || id == CSSValueFlexEnd
4046 || id == CSSValueLeft || id == CSSValueRight;
4047 }
4048
4032 static bool isBaselinePositionKeyword(CSSValueID id) 4049 static bool isBaselinePositionKeyword(CSSValueID id)
4033 { 4050 {
4034 return id == CSSValueBaseline || id == CSSValueLastBaseline; 4051 return id == CSSValueBaseline || id == CSSValueLastBaseline;
4035 } 4052 }
4036 4053
4054 static bool isAlignmentOverflowKeyword(CSSValueID id)
4055 {
4056 return id == CSSValueTrue || id == CSSValueSafe;
4057 }
4058
4037 static bool isItemPositionKeyword(CSSValueID id) 4059 static bool isItemPositionKeyword(CSSValueID id)
4038 { 4060 {
4039 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter 4061 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
4040 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart 4062 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart
4041 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight; 4063 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight;
4042 } 4064 }
4043 4065
4044 bool CSSPropertyParser::parseLegacyPosition(CSSPropertyID propId, bool important ) 4066 bool CSSPropertyParser::parseLegacyPosition(CSSPropertyID propId, bool important )
4045 { 4067 {
4046 // [ legacy && [ left | right | center ] 4068 // [ legacy && [ left | right | center ]
(...skipping 12 matching lines...) Expand all
4059 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy ) 4081 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy )
4060 return false; 4082 return false;
4061 } else { 4083 } else {
4062 return false; 4084 return false;
4063 } 4085 }
4064 4086
4065 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt); 4087 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt);
4066 return !m_valueList->next(); 4088 return !m_valueList->next();
4067 } 4089 }
4068 4090
4091 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver flowPosition()
4092 {
4093 // auto | <baseline-position> | [ <content-distribution>? && <content-positi on>? ]! && <overflow-position>?
4094 // <baseline-position> = baseline | last-baseline;
4095 // <content-distribution> = space-between | space-around | space-evenly | st retch;
4096 // <content-position> = center | start | end | flex-start | flex-end | left | right;
4097 // <overflow-position> = true | safe
4098
4099 // auto | <baseline-position>
4100 CSSParserValue* value = m_valueList->current();
4101 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) {
4102 m_valueList->next();
4103 return CSSContentDistributionValue::create(CSSValueInvalid, value->id, C SSValueInvalid);
4104 }
4105
4106 CSSValueID distribution = CSSValueInvalid;
4107 CSSValueID position = CSSValueInvalid;
4108 CSSValueID overflow = CSSValueInvalid;
4109 if (isAlignmentOverflowKeyword(value->id)) {
4110 overflow = value->id;
4111 value = m_valueList->next();
4112 }
4113 if (value && isContentDistributionKeyword(value->id)) {
4114 distribution = value->id;
4115 value = m_valueList->next();
4116 }
4117 if (value && isContentPositionKeyword(value->id)) {
4118 position = value->id;
4119 value = m_valueList->next();
4120 }
4121 if (value) {
4122 if (overflow != CSSValueInvalid || !isAlignmentOverflowKeyword(value->id ))
4123 return nullptr;
4124 overflow = value->id;
4125 }
4126
4127 // The grammar states that we should have at least <content-distribution> or
4128 // <content-position> ([ <content-distribution>? && <content-position>? ]!).
4129 if (m_valueList->next() || (position == CSSValueInvalid && distribution == C SSValueInvalid))
4130 return nullptr;
4131
4132 return CSSContentDistributionValue::create(distribution, position, overflow) ;
4133 }
4134
4069 bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important) 4135 bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important)
4070 { 4136 {
4071 // auto | stretch | <baseline-position> | [<item-position> && <overflow-posi tion>? ] 4137 // auto | stretch | <baseline-position> | [<item-position> && <overflow-posi tion>? ]
4072 // <baseline-position> = baseline | last-baseline; 4138 // <baseline-position> = baseline | last-baseline;
4073 // <item-position> = center | start | end | self-start | self-end | flex-sta rt | flex-end | left | right; 4139 // <item-position> = center | start | end | self-start | self-end | flex-sta rt | flex-end | left | right;
4074 // <overflow-position> = true | safe 4140 // <overflow-position> = true | safe
4075 4141
4076 CSSParserValue* value = m_valueList->current(); 4142 CSSParserValue* value = m_valueList->current();
4077 if (!value) 4143 if (!value)
4078 return false; 4144 return false;
4079 4145
4080 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselineP ositionKeyword(value->id)) { 4146 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselineP ositionKeyword(value->id)) {
4081 if (m_valueList->next()) 4147 if (m_valueList->next())
4082 return false; 4148 return false;
4083 4149
4084 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); 4150 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
4085 return true; 4151 return true;
4086 } 4152 }
4087 4153
4088 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr; 4154 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr;
4089 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr; 4155 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr;
4090 if (isItemPositionKeyword(value->id)) { 4156 if (isItemPositionKeyword(value->id)) {
4091 position = cssValuePool().createIdentifierValue(value->id); 4157 position = cssValuePool().createIdentifierValue(value->id);
4092 value = m_valueList->next(); 4158 value = m_valueList->next();
4093 if (value) { 4159 if (value) {
4094 if (value->id == CSSValueTrue || value->id == CSSValueSafe) 4160 if (isAlignmentOverflowKeyword(value->id))
4095 overflowAlignmentKeyword = cssValuePool().createIdentifierValue( value->id); 4161 overflowAlignmentKeyword = cssValuePool().createIdentifierValue( value->id);
4096 else 4162 else
4097 return false; 4163 return false;
4098 } 4164 }
4099 } else if (value->id == CSSValueTrue || value->id == CSSValueSafe) { 4165 } else if (isAlignmentOverflowKeyword(value->id)) {
4100 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->i d); 4166 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->i d);
4101 value = m_valueList->next(); 4167 value = m_valueList->next();
4102 if (value && isItemPositionKeyword(value->id)) 4168 if (value && isItemPositionKeyword(value->id))
4103 position = cssValuePool().createIdentifierValue(value->id); 4169 position = cssValuePool().createIdentifierValue(value->id);
4104 else 4170 else
4105 return false; 4171 return false;
4106 } else { 4172 } else {
4107 return false; 4173 return false;
4108 } 4174 }
4109 4175
(...skipping 4238 matching lines...) Expand 10 before | Expand all | Expand 10 after
8348 return nullptr; 8414 return nullptr;
8349 a = args->next(); 8415 a = args->next();
8350 8416
8351 argNumber++; 8417 argNumber++;
8352 } 8418 }
8353 8419
8354 return transformValue.release(); 8420 return transformValue.release();
8355 } 8421 }
8356 8422
8357 } // namespace blink 8423 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/StyleAdjuster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698