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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 case CSSPropertyMarkerEnd: | 1083 case CSSPropertyMarkerEnd: |
1084 case CSSPropertyFlex: | 1084 case CSSPropertyFlex: |
1085 case CSSPropertyFlexBasis: | 1085 case CSSPropertyFlexBasis: |
1086 case CSSPropertyFlexGrow: | 1086 case CSSPropertyFlexGrow: |
1087 case CSSPropertyFlexShrink: | 1087 case CSSPropertyFlexShrink: |
1088 case CSSPropertyFlexFlow: | 1088 case CSSPropertyFlexFlow: |
1089 case CSSPropertyStrokeDasharray: | 1089 case CSSPropertyStrokeDasharray: |
1090 case CSSPropertyWebkitColumnRule: | 1090 case CSSPropertyWebkitColumnRule: |
1091 case CSSPropertyWebkitColumnRuleColor: | 1091 case CSSPropertyWebkitColumnRuleColor: |
1092 case CSSPropertyWebkitColumnRuleWidth: | 1092 case CSSPropertyWebkitColumnRuleWidth: |
| 1093 case CSSPropertyClipPath: |
| 1094 case CSSPropertyFilter: |
| 1095 case CSSPropertyMask: |
| 1096 case CSSPropertyStrokeOpacity: |
| 1097 case CSSPropertyFillOpacity: |
| 1098 case CSSPropertyStopOpacity: |
| 1099 case CSSPropertyFloodOpacity: |
| 1100 case CSSPropertyBaselineShift: |
| 1101 case CSSPropertyStrokeMiterlimit: |
| 1102 case CSSPropertyStrokeWidth: |
| 1103 case CSSPropertyStrokeDashoffset: |
| 1104 case CSSPropertyCx: |
| 1105 case CSSPropertyCy: |
| 1106 case CSSPropertyX: |
| 1107 case CSSPropertyY: |
| 1108 case CSSPropertyR: |
| 1109 case CSSPropertyRx: |
| 1110 case CSSPropertyRy: |
1093 validPrimitive = false; | 1111 validPrimitive = false; |
1094 break; | 1112 break; |
1095 | 1113 |
1096 case CSSPropertyScrollSnapPointsX: | 1114 case CSSPropertyScrollSnapPointsX: |
1097 case CSSPropertyScrollSnapPointsY: | 1115 case CSSPropertyScrollSnapPointsY: |
1098 parsedValue = parseScrollSnapPoints(); | 1116 parsedValue = parseScrollSnapPoints(); |
1099 break; | 1117 break; |
1100 case CSSPropertyScrollSnapCoordinate: | 1118 case CSSPropertyScrollSnapCoordinate: |
1101 parsedValue = parseScrollSnapCoordinate(); | 1119 parsedValue = parseScrollSnapCoordinate(); |
1102 break; | 1120 break; |
1103 case CSSPropertyScrollSnapDestination: | 1121 case CSSPropertyScrollSnapDestination: |
1104 parsedValue = parsePosition(m_valueList); | 1122 parsedValue = parsePosition(m_valueList); |
1105 break; | 1123 break; |
1106 | 1124 |
1107 default: | 1125 default: |
1108 return parseSVGValue(propId, important); | 1126 // If you crash here, it's because you added a css property and are not
handling it |
| 1127 // in either this switch statement or the one in CSSPropertyParser::pars
eSingleValue. |
| 1128 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); |
| 1129 return false; |
1109 } | 1130 } |
1110 | 1131 |
1111 if (validPrimitive) { | 1132 if (validPrimitive) { |
1112 parsedValue = parseValidPrimitive(id, value); | 1133 parsedValue = parseValidPrimitive(id, value); |
1113 m_valueList->next(); | 1134 m_valueList->next(); |
1114 } | 1135 } |
1115 ASSERT(!m_parsedCalculation); | 1136 ASSERT(!m_parsedCalculation); |
1116 if (parsedValue) { | 1137 if (parsedValue) { |
1117 if (!m_valueList->current() || inShorthand()) { | 1138 if (!m_valueList->current() || inShorthand()) { |
1118 addProperty(propId, parsedValue.release(), important); | 1139 addProperty(propId, parsedValue.release(), important); |
(...skipping 4167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5286 return CSSValueInvalid; | 5307 return CSSValueInvalid; |
5287 | 5308 |
5288 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); | 5309 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); |
5289 } | 5310 } |
5290 | 5311 |
5291 bool CSSPropertyParser::isSystemColor(CSSValueID id) | 5312 bool CSSPropertyParser::isSystemColor(CSSValueID id) |
5292 { | 5313 { |
5293 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; | 5314 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; |
5294 } | 5315 } |
5295 | 5316 |
5296 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) | |
5297 { | |
5298 CSSParserValue* value = m_valueList->current(); | |
5299 ASSERT(value); | |
5300 | |
5301 CSSValueID id = value->id; | |
5302 | |
5303 bool validPrimitive = false; | |
5304 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | |
5305 | |
5306 switch (propId) { | |
5307 /* The comment to the right defines all valid value of these | |
5308 * properties as defined in SVG 1.1, Appendix N. Property index */ | |
5309 case CSSPropertyBaselineShift: | |
5310 // baseline | super | sub | <percentage> | <length> | inherit | |
5311 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | |
5312 validPrimitive = true; | |
5313 else | |
5314 validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMo
de); | |
5315 break; | |
5316 | |
5317 case CSSPropertyClipPath: | |
5318 case CSSPropertyFilter: | |
5319 case CSSPropertyMask: | |
5320 if (id == CSSValueNone) { | |
5321 validPrimitive = true; | |
5322 } else if (value->m_unit == CSSParserValue::URI) { | |
5323 parsedValue = CSSURIValue::create(value->string); | |
5324 if (parsedValue) | |
5325 m_valueList->next(); | |
5326 } | |
5327 break; | |
5328 | |
5329 case CSSPropertyStrokeMiterlimit: // <miterlimit> | inherit | |
5330 validPrimitive = validUnit(value, FNumber | FNonNeg, SVGAttributeMode); | |
5331 break; | |
5332 | |
5333 case CSSPropertyStrokeOpacity: // <opacity-value> | inherit | |
5334 case CSSPropertyFillOpacity: | |
5335 case CSSPropertyStopOpacity: | |
5336 case CSSPropertyFloodOpacity: | |
5337 validPrimitive = validUnit(value, FNumber | FPercent, SVGAttributeMode); | |
5338 break; | |
5339 | |
5340 /* Start of supported CSS properties with validation. This is needed for par
seShortHand to work | |
5341 * correctly and allows optimization in applyRule(..) | |
5342 */ | |
5343 | |
5344 case CSSPropertyStrokeWidth: // <length> | inherit | |
5345 case CSSPropertyStrokeDashoffset: | |
5346 case CSSPropertyCx: | |
5347 case CSSPropertyCy: | |
5348 case CSSPropertyX: | |
5349 case CSSPropertyY: | |
5350 case CSSPropertyR: | |
5351 case CSSPropertyRx: | |
5352 case CSSPropertyRy: | |
5353 validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMode); | |
5354 break; | |
5355 | |
5356 default: | |
5357 // If you crash here, it's because you added a css property and are not
handling it | |
5358 // in either this switch statement or the one in CSSPropertyParser::pars
eValue | |
5359 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); | |
5360 return false; | |
5361 } | |
5362 | |
5363 if (validPrimitive) { | |
5364 if (id) | |
5365 parsedValue = CSSPrimitiveValue::createIdentifier(id); | |
5366 else if (value->m_unit == CSSParserValue::String) | |
5367 parsedValue = CSSStringValue::create(value->string); | |
5368 else if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->
unit() <= CSSPrimitiveValue::UnitType::Kilohertz) | |
5369 parsedValue = CSSPrimitiveValue::create(value->fValue, value->unit()
); | |
5370 else if (value->unit() == CSSPrimitiveValue::UnitType::Rems || value->un
it() == CSSPrimitiveValue::UnitType::Chs) | |
5371 parsedValue = CSSPrimitiveValue::create(value->fValue, value->unit()
); | |
5372 else if (value->unit() == CSSPrimitiveValue::UnitType::QuirkyEms) | |
5373 parsedValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveV
alue::UnitType::QuirkyEms); | |
5374 if (isCalculation(value)) { | |
5375 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri
mitiveValue here, ie | |
5376 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea
se()); | |
5377 m_parsedCalculation.release(); | |
5378 parsedValue = nullptr; | |
5379 } | |
5380 m_valueList->next(); | |
5381 } | |
5382 if (!parsedValue || (m_valueList->current() && !inShorthand())) | |
5383 return false; | |
5384 | |
5385 addProperty(propId, parsedValue.release(), important); | |
5386 return true; | |
5387 } | |
5388 | |
5389 } // namespace blink | 5317 } // namespace blink |
OLD | NEW |