OLD | NEW |
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 { | 252 { |
253 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); | 253 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); |
254 | 254 |
255 // Note: m_parsedCalculation is used to pass the calc value to validUnit and
then cleared at the end of this function. | 255 // Note: m_parsedCalculation is used to pass the calc value to validUnit and
then cleared at the end of this function. |
256 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller
s. | 256 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller
s. |
257 ASSERT(!m_parsedCalculation); | 257 ASSERT(!m_parsedCalculation); |
258 | 258 |
259 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 259 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
260 | 260 |
261 switch (propId) { | 261 switch (propId) { |
262 case CSSPropertyJustifySelf: | |
263 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
264 parsedValue = parseItemPositionOverflowPosition(); | |
265 break; | |
266 case CSSPropertyJustifyItems: | |
267 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
268 | |
269 if ((parsedValue = parseLegacyPosition())) | |
270 break; | |
271 | |
272 m_valueList->setCurrentIndex(0); | |
273 parsedValue = parseItemPositionOverflowPosition(); | |
274 break; | |
275 case CSSPropertyGridAutoFlow: | 262 case CSSPropertyGridAutoFlow: |
276 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 263 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
277 parsedValue = parseGridAutoFlow(*m_valueList); | 264 parsedValue = parseGridAutoFlow(*m_valueList); |
278 break; | 265 break; |
279 case CSSPropertyGridAutoColumns: | 266 case CSSPropertyGridAutoColumns: |
280 case CSSPropertyGridAutoRows: | 267 case CSSPropertyGridAutoRows: |
281 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 268 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
282 parsedValue = parseGridTrackSize(*m_valueList); | 269 parsedValue = parseGridTrackSize(*m_valueList); |
283 break; | 270 break; |
284 | 271 |
285 case CSSPropertyGridTemplateColumns: | 272 case CSSPropertyGridTemplateColumns: |
286 case CSSPropertyGridTemplateRows: | 273 case CSSPropertyGridTemplateRows: |
287 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 274 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
288 parsedValue = parseGridTrackList(); | 275 parsedValue = parseGridTrackList(); |
289 break; | 276 break; |
290 | 277 |
291 case CSSPropertyGridColumnEnd: | 278 case CSSPropertyGridColumnEnd: |
292 case CSSPropertyGridColumnStart: | 279 case CSSPropertyGridColumnStart: |
293 case CSSPropertyGridRowEnd: | 280 case CSSPropertyGridRowEnd: |
294 case CSSPropertyGridRowStart: | 281 case CSSPropertyGridRowStart: |
295 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 282 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
296 parsedValue = parseGridPosition(); | 283 parsedValue = parseGridPosition(); |
297 break; | 284 break; |
298 | 285 |
299 case CSSPropertyGridTemplateAreas: | 286 case CSSPropertyGridTemplateAreas: |
300 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 287 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
301 parsedValue = parseGridTemplateAreas(); | 288 parsedValue = parseGridTemplateAreas(); |
302 break; | 289 break; |
303 | 290 |
304 break; | |
305 | |
306 case CSSPropertyAlignSelf: | |
307 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
308 parsedValue = parseItemPositionOverflowPosition(); | |
309 break; | |
310 | |
311 case CSSPropertyAlignItems: | |
312 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
313 parsedValue = parseItemPositionOverflowPosition(); | |
314 break; | |
315 | |
316 // Everything else is handled in CSSPropertyParser.cpp | 291 // Everything else is handled in CSSPropertyParser.cpp |
317 default: | 292 default: |
318 return nullptr; | 293 return nullptr; |
319 } | 294 } |
320 | 295 |
321 ASSERT(!m_parsedCalculation); | 296 ASSERT(!m_parsedCalculation); |
322 if (parsedValue) { | 297 if (parsedValue) { |
323 if (!m_valueList->current() || inShorthand()) | 298 if (!m_valueList->current() || inShorthand()) |
324 return parsedValue.release(); | 299 return parsedValue.release(); |
325 } | 300 } |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 default: | 1109 default: |
1135 return parsedValues; | 1110 return parsedValues; |
1136 } | 1111 } |
1137 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); | 1112 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); |
1138 list.next(); | 1113 list.next(); |
1139 } | 1114 } |
1140 | 1115 |
1141 return parsedValues; | 1116 return parsedValues; |
1142 } | 1117 } |
1143 | 1118 |
1144 static bool isBaselinePositionKeyword(CSSValueID id) | |
1145 { | |
1146 return id == CSSValueBaseline || id == CSSValueLastBaseline; | |
1147 } | |
1148 | |
1149 static bool isAlignmentOverflowKeyword(CSSValueID id) | |
1150 { | |
1151 return id == CSSValueUnsafe || id == CSSValueSafe; | |
1152 } | |
1153 | |
1154 static bool isItemPositionKeyword(CSSValueID id) | |
1155 { | |
1156 return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter | |
1157 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle
xStart | |
1158 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight; | |
1159 } | |
1160 | |
1161 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseLegacyPosition() | |
1162 { | |
1163 // [ legacy && [ left | right | center ] | |
1164 | |
1165 CSSParserValue* value = m_valueList->current(); | |
1166 ASSERT(value); | |
1167 | |
1168 if (value->id == CSSValueLegacy) { | |
1169 value = m_valueList->next(); | |
1170 if (!value) | |
1171 return nullptr; | |
1172 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->i
d != CSSValueRight) | |
1173 return nullptr; | |
1174 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value
->id == CSSValueRight) { | |
1175 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) | |
1176 return nullptr; | |
1177 } else { | |
1178 return nullptr; | |
1179 } | |
1180 | |
1181 m_valueList->next(); | |
1182 return CSSValuePair::create(cssValuePool().createIdentifierValue(CSSValueLeg
acy), cssValuePool().createIdentifierValue(value->id), CSSValuePair::DropIdentic
alValues); | |
1183 } | |
1184 | |
1185 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseItemPositionOverflowPos
ition() | |
1186 { | |
1187 // auto | stretch | <baseline-position> | [<item-position> && <overflow-posi
tion>? ] | |
1188 // <baseline-position> = baseline | last-baseline; | |
1189 // <item-position> = center | start | end | self-start | self-end | flex-sta
rt | flex-end | left | right; | |
1190 // <overflow-position> = unsafe | safe | |
1191 | |
1192 CSSParserValue* value = m_valueList->current(); | |
1193 ASSERT(value); | |
1194 | |
1195 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselineP
ositionKeyword(value->id)) { | |
1196 m_valueList->next(); | |
1197 return cssValuePool().createIdentifierValue(value->id); | |
1198 } | |
1199 | |
1200 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr; | |
1201 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr; | |
1202 if (isItemPositionKeyword(value->id)) { | |
1203 position = cssValuePool().createIdentifierValue(value->id); | |
1204 value = m_valueList->next(); | |
1205 if (value) { | |
1206 if (isAlignmentOverflowKeyword(value->id)) | |
1207 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(
value->id); | |
1208 else | |
1209 return nullptr; | |
1210 } | |
1211 } else if (isAlignmentOverflowKeyword(value->id)) { | |
1212 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->i
d); | |
1213 value = m_valueList->next(); | |
1214 if (value && isItemPositionKeyword(value->id)) | |
1215 position = cssValuePool().createIdentifierValue(value->id); | |
1216 else | |
1217 return nullptr; | |
1218 } else { | |
1219 return nullptr; | |
1220 } | |
1221 | |
1222 m_valueList->next(); | |
1223 | |
1224 ASSERT(position); | |
1225 if (overflowAlignmentKeyword) | |
1226 return CSSValuePair::create(position, overflowAlignmentKeyword, CSSValue
Pair::DropIdenticalValues); | |
1227 return position.release(); | |
1228 } | |
1229 | |
1230 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) | 1119 bool CSSPropertyParser::parseCalculation(CSSParserValue* value, ValueRange range
) |
1231 { | 1120 { |
1232 ASSERT(isCalculation(value)); | 1121 ASSERT(isCalculation(value)); |
1233 | 1122 |
1234 CSSParserTokenRange args = value->calcFunction->args; | 1123 CSSParserTokenRange args = value->calcFunction->args; |
1235 | 1124 |
1236 ASSERT(!m_parsedCalculation); | 1125 ASSERT(!m_parsedCalculation); |
1237 m_parsedCalculation = CSSCalcValue::create(args, range); | 1126 m_parsedCalculation = CSSCalcValue::create(args, range); |
1238 | 1127 |
1239 if (!m_parsedCalculation) | 1128 if (!m_parsedCalculation) |
1240 return false; | 1129 return false; |
1241 | 1130 |
1242 return true; | 1131 return true; |
1243 } | 1132 } |
1244 | 1133 |
1245 } // namespace blink | 1134 } // namespace blink |
OLD | NEW |