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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 case CSSPropertyRx: | 869 case CSSPropertyRx: |
870 case CSSPropertyRy: | 870 case CSSPropertyRy: |
871 case CSSPropertyScale: | 871 case CSSPropertyScale: |
872 case CSSPropertyTranslate: | 872 case CSSPropertyTranslate: |
873 case CSSPropertyCursor: | 873 case CSSPropertyCursor: |
874 case CSSPropertyTransformOrigin: | 874 case CSSPropertyTransformOrigin: |
875 case CSSPropertyContent: | 875 case CSSPropertyContent: |
876 case CSSPropertyListStyleImage: | 876 case CSSPropertyListStyleImage: |
877 case CSSPropertyListStyle: | 877 case CSSPropertyListStyle: |
878 case CSSPropertyPerspective: | 878 case CSSPropertyPerspective: |
| 879 case CSSPropertyScrollSnapCoordinate: |
| 880 case CSSPropertyScrollSnapPointsX: |
| 881 case CSSPropertyScrollSnapPointsY: |
879 validPrimitive = false; | 882 validPrimitive = false; |
880 break; | 883 break; |
881 | 884 |
882 case CSSPropertyScrollSnapPointsX: | |
883 case CSSPropertyScrollSnapPointsY: | |
884 parsedValue = parseScrollSnapPoints(); | |
885 break; | |
886 case CSSPropertyScrollSnapCoordinate: | |
887 parsedValue = parseScrollSnapCoordinate(); | |
888 break; | |
889 | |
890 default: | 885 default: |
891 // If you crash here, it's because you added a css property and are not
handling it | 886 // If you crash here, it's because you added a css property and are not
handling it |
892 // in either this switch statement or the one in CSSPropertyParser::pars
eSingleValue. | 887 // in either this switch statement or the one in CSSPropertyParser::pars
eSingleValue. |
893 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); | 888 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); |
894 return false; | 889 return false; |
895 } | 890 } |
896 | 891 |
897 if (validPrimitive) { | 892 if (validPrimitive) { |
898 parsedValue = parseValidPrimitive(id, value); | 893 parsedValue = parseValidPrimitive(id, value); |
899 m_valueList->next(); | 894 m_valueList->next(); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 break; | 1183 break; |
1189 } | 1184 } |
1190 default: { | 1185 default: { |
1191 return false; | 1186 return false; |
1192 } | 1187 } |
1193 } | 1188 } |
1194 | 1189 |
1195 return true; | 1190 return true; |
1196 } | 1191 } |
1197 | 1192 |
1198 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() | |
1199 { | |
1200 CSSParserValue* value = m_valueList->current(); | |
1201 | |
1202 if (value->id == CSSValueNone) { | |
1203 m_valueList->next(); | |
1204 return cssValuePool().createIdentifierValue(CSSValueNone); | |
1205 } | |
1206 | |
1207 if (value->m_unit == CSSParserValue::Function && value->function->id == CSSV
alueRepeat) { | |
1208 // The spec defines the following grammar: repeat( <length>) | |
1209 CSSParserValueList* arguments = value->function->args.get(); | |
1210 if (!arguments || arguments->size() != 1) | |
1211 return nullptr; | |
1212 | |
1213 CSSParserValue* repeatValue = arguments->valueAt(0); | |
1214 if (validUnit(repeatValue, FNonNeg | FLength | FPercent) && (m_parsedCal
culation || repeatValue->fValue > 0)) { | |
1215 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::crea
te(CSSValueRepeat); | |
1216 result->append(parseValidPrimitive(repeatValue->id, repeatValue)); | |
1217 m_valueList->next(); | |
1218 return result.release(); | |
1219 } | |
1220 } | |
1221 | |
1222 return nullptr; | |
1223 } | |
1224 | |
1225 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | |
1226 { | |
1227 if (m_valueList->current()->id == CSSValueNone) { | |
1228 m_valueList->next(); | |
1229 return cssValuePool().createIdentifierValue(CSSValueNone); | |
1230 } | |
1231 | |
1232 return parsePositionList(m_valueList); | |
1233 } | |
1234 | |
1235 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColor(const CSSParserVa
lue* value, bool acceptQuirkyColors) | 1193 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColor(const CSSParserVa
lue* value, bool acceptQuirkyColors) |
1236 { | 1194 { |
1237 CSSValueID id = value->id; | 1195 CSSValueID id = value->id; |
1238 if (isColorKeyword(id)) { | 1196 if (isColorKeyword(id)) { |
1239 if (!isValueAllowedInMode(id, m_context.mode())) | 1197 if (!isValueAllowedInMode(id, m_context.mode())) |
1240 return nullptr; | 1198 return nullptr; |
1241 if (id == CSSValueWebkitText && m_context.useCounter()) | 1199 if (id == CSSValueWebkitText && m_context.useCounter()) |
1242 m_context.useCounter()->count(UseCounter::WebkitTextInColorProperty)
; | 1200 m_context.useCounter()->count(UseCounter::WebkitTextInColorProperty)
; |
1243 return cssValuePool().createIdentifierValue(id); | 1201 return cssValuePool().createIdentifierValue(id); |
1244 } | 1202 } |
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3311 val = m_valueList->next(); | 3269 val = m_valueList->next(); |
3312 if (val) { | 3270 if (val) { |
3313 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); | 3271 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); |
3314 if (!mask) | 3272 if (!mask) |
3315 return nullptr; | 3273 return nullptr; |
3316 } | 3274 } |
3317 | 3275 |
3318 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); | 3276 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); |
3319 } | 3277 } |
3320 | 3278 |
3321 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue
List* valueList) | |
3322 { | |
3323 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | |
3324 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | |
3325 parseFillPosition(valueList, xValue, yValue); | |
3326 if (!xValue || !yValue) | |
3327 return nullptr; | |
3328 return CSSValuePair::create(xValue.release(), yValue.release(), CSSValuePair
::KeepIdenticalValues); | |
3329 } | |
3330 | |
3331 // Parses a list of comma separated positions. i.e., <position># | |
3332 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar
serValueList* valueList) | |
3333 { | |
3334 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara
ted(); | |
3335 while (true) { | |
3336 // parsePosition consumes values until it reaches a separator [,/], | |
3337 // an invalid token, or end of the list | |
3338 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); | |
3339 if (!position) | |
3340 return nullptr; | |
3341 positions->append(position); | |
3342 | |
3343 if (!valueList->current()) | |
3344 break; | |
3345 if (!consumeComma(valueList) || !valueList->current()) | |
3346 return nullptr; | |
3347 } | |
3348 | |
3349 return positions.release(); | |
3350 } | |
3351 | |
3352 class BorderImageParseContext { | 3279 class BorderImageParseContext { |
3353 STACK_ALLOCATED(); | 3280 STACK_ALLOCATED(); |
3354 public: | 3281 public: |
3355 BorderImageParseContext() | 3282 BorderImageParseContext() |
3356 : m_canAdvance(false) | 3283 : m_canAdvance(false) |
3357 , m_allowCommit(true) | 3284 , m_allowCommit(true) |
3358 , m_allowImage(true) | 3285 , m_allowImage(true) |
3359 , m_allowImageSlice(true) | 3286 , m_allowImageSlice(true) |
3360 , m_allowRepeat(true) | 3287 , m_allowRepeat(true) |
3361 , m_allowForwardSlashOperator(false) | 3288 , m_allowForwardSlashOperator(false) |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4692 ASSERT(!m_parsedCalculation); | 4619 ASSERT(!m_parsedCalculation); |
4693 m_parsedCalculation = CSSCalcValue::create(args, range); | 4620 m_parsedCalculation = CSSCalcValue::create(args, range); |
4694 | 4621 |
4695 if (!m_parsedCalculation) | 4622 if (!m_parsedCalculation) |
4696 return false; | 4623 return false; |
4697 | 4624 |
4698 return true; | 4625 return true; |
4699 } | 4626 } |
4700 | 4627 |
4701 } // namespace blink | 4628 } // namespace blink |
OLD | NEW |