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

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

Issue 333423005: [CSS Grid Layout] Implement 'justify-items' parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Applied suggested changes. Created 6 years, 6 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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 return true; 1192 return true;
1193 } 1193 }
1194 return false; 1194 return false;
1195 } 1195 }
1196 1196
1197 case CSSPropertyJustifySelf: 1197 case CSSPropertyJustifySelf:
1198 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 1198 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
1199 return false; 1199 return false;
1200 1200
1201 return parseItemPositionOverflowPosition(propId, important); 1201 return parseItemPositionOverflowPosition(propId, important);
1202
1203 case CSSPropertyJustifyItems:
1204 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
1205 return false;
1206
1207 if (parseLegacyPosition(propId, important))
1208 return true;
1209
1210 m_valueList->setCurrentIndex(0);
1211 return parseItemPositionOverflowPosition(propId, important);
1212
1202 case CSSPropertyGridAutoColumns: 1213 case CSSPropertyGridAutoColumns:
1203 case CSSPropertyGridAutoRows: 1214 case CSSPropertyGridAutoRows:
1204 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 1215 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
1205 return false; 1216 return false;
1206 parsedValue = parseGridTrackSize(*m_valueList); 1217 parsedValue = parseGridTrackSize(*m_valueList);
1207 break; 1218 break;
1208 1219
1209 case CSSPropertyGridTemplateColumns: 1220 case CSSPropertyGridTemplateColumns:
1210 case CSSPropertyGridTemplateRows: 1221 case CSSPropertyGridTemplateRows:
1211 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) 1222 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
(...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after
4119 } 4130 }
4120 default: 4131 default:
4121 return nullptr; 4132 return nullptr;
4122 } 4133 }
4123 4134
4124 if (hasRoundedInset) 4135 if (hasRoundedInset)
4125 return parseInsetRoundedCorners(shape, args); 4136 return parseInsetRoundedCorners(shape, args);
4126 return shape; 4137 return shape;
4127 } 4138 }
4128 4139
4140 static bool isBaselinePositionKeyword(CSSValueID id)
4141 {
4142 return id == CSSValueBaseline || id == CSSValueLastBaseline;
4143 }
4144
4129 static bool isItemPositionKeyword(CSSValueID id) 4145 static bool isItemPositionKeyword(CSSValueID id)
4130 { 4146 {
4131 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter 4147 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
4132 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart 4148 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle xStart
4133 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight; 4149 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight;
4134 } 4150 }
4135 4151
4152 bool CSSPropertyParser::parseLegacyPosition(CSSPropertyID propId, bool important )
4153 {
4154 // [ legacy && [ left | right | center ]
4155
4156 CSSParserValue* value = m_valueList->current();
4157 if (!value)
4158 return false;
4159
4160 if (value->id == CSSValueLegacy) {
4161 if (!(value = m_valueList->next()))
Julien - ping for review 2014/06/26 17:37:20 Nit: I would split this into 2 lines for readabili
jfernandez 2014/06/26 22:36:05 Done.
4162 return false;
4163 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->i d != CSSValueRight)
4164 return false;
4165 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value ->id == CSSValueRight) {
4166 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy )
4167 return false;
4168 } else {
4169 return false;
4170 }
4171
4172 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt);
4173 return !m_valueList->next();
4174 }
4175
4136 bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important) 4176 bool CSSPropertyParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important)
4137 { 4177 {
4138 // auto | baseline | stretch | [<item-position> && <overflow-position>? ] 4178 // auto | stretch | <baseline-position> | [<item-position> && <overflow-posi tion>? ]
4179 // <baseline-position> = baseline | last-baseline;
4139 // <item-position> = center | start | end | self-start | self-end | flex-sta rt | flex-end | left | right; 4180 // <item-position> = center | start | end | self-start | self-end | flex-sta rt | flex-end | left | right;
4140 // <overflow-position> = true | safe 4181 // <overflow-position> = true | safe
4141 4182
4142 CSSParserValue* value = m_valueList->current(); 4183 CSSParserValue* value = m_valueList->current();
4184 if (!value)
4185 return false;
4143 4186
4144 if (value->id == CSSValueAuto || value->id == CSSValueBaseline || value->id == CSSValueStretch) { 4187 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselineP ositionKeyword(value->id)) {
4145 if (m_valueList->next()) 4188 if (m_valueList->next())
4146 return false; 4189 return false;
4147 4190
4148 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant); 4191 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp ortant);
4149 return true; 4192 return true;
4150 } 4193 }
4151 4194
4152 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr; 4195 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr;
4153 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr; 4196 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr;
4154 if (isItemPositionKeyword(value->id)) { 4197 if (isItemPositionKeyword(value->id)) {
(...skipping 4262 matching lines...) Expand 10 before | Expand all | Expand 10 after
8417 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8460 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8418 if (!seenStroke) 8461 if (!seenStroke)
8419 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8462 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8420 if (!seenMarkers) 8463 if (!seenMarkers)
8421 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8464 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8422 8465
8423 return parsedValues.release(); 8466 return parsedValues.release();
8424 } 8467 }
8425 8468
8426 } // namespace WebCore 8469 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698