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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "core/css/CSSPathValue.h" | 44 #include "core/css/CSSPathValue.h" |
45 #include "core/css/CSSPrimitiveValueMappings.h" | 45 #include "core/css/CSSPrimitiveValueMappings.h" |
46 #include "core/css/CSSProperty.h" | 46 #include "core/css/CSSProperty.h" |
47 #include "core/css/CSSPropertyMetadata.h" | 47 #include "core/css/CSSPropertyMetadata.h" |
48 #include "core/css/CSSReflectValue.h" | 48 #include "core/css/CSSReflectValue.h" |
49 #include "core/css/CSSSVGDocumentValue.h" | 49 #include "core/css/CSSSVGDocumentValue.h" |
50 #include "core/css/CSSShadowValue.h" | 50 #include "core/css/CSSShadowValue.h" |
51 #include "core/css/CSSTimingFunctionValue.h" | 51 #include "core/css/CSSTimingFunctionValue.h" |
52 #include "core/css/CSSUnicodeRangeValue.h" | 52 #include "core/css/CSSUnicodeRangeValue.h" |
53 #include "core/css/CSSValuePool.h" | 53 #include "core/css/CSSValuePool.h" |
54 #include "core/css/CSSVariableValue.h" | |
54 #include "core/css/Counter.h" | 55 #include "core/css/Counter.h" |
55 #include "core/css/HashTools.h" | 56 #include "core/css/HashTools.h" |
56 #include "core/css/Pair.h" | 57 #include "core/css/Pair.h" |
57 #include "core/css/Rect.h" | 58 #include "core/css/Rect.h" |
58 #include "core/css/parser/CSSParserFastPaths.h" | 59 #include "core/css/parser/CSSParserFastPaths.h" |
59 #include "core/css/parser/CSSParserValues.h" | 60 #include "core/css/parser/CSSParserValues.h" |
60 #include "core/frame/UseCounter.h" | 61 #include "core/frame/UseCounter.h" |
61 #include "core/layout/LayoutTheme.h" | 62 #include "core/layout/LayoutTheme.h" |
62 #include "core/style/GridCoordinate.h" | 63 #include "core/style/GridCoordinate.h" |
63 #include "core/svg/SVGPathUtilities.h" | 64 #include "core/svg/SVGPathUtilities.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 break; | 207 break; |
207 case CalcAngle: | 208 case CalcAngle: |
208 b = (unitflags & FAngle); | 209 b = (unitflags & FAngle); |
209 break; | 210 break; |
210 case CalcTime: | 211 case CalcTime: |
211 b = (unitflags & FTime); | 212 b = (unitflags & FTime); |
212 break; | 213 break; |
213 case CalcFrequency: | 214 case CalcFrequency: |
214 b = (unitflags & FFrequency); | 215 b = (unitflags & FFrequency); |
215 break; | 216 break; |
217 case CalcVariable: | |
218 b = true; | |
219 break; | |
216 case CalcOther: | 220 case CalcOther: |
217 break; | 221 break; |
218 } | 222 } |
219 if (!b || releaseCalc == ReleaseParsedCalcValue) | 223 if (!b || releaseCalc == ReleaseParsedCalcValue) |
220 m_parsedCalculation.release(); | 224 m_parsedCalculation.release(); |
221 return b; | 225 return b; |
222 } | 226 } |
223 | 227 |
224 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value, Units unitflags, CSSParserMode cssParserMode) | 228 inline bool CSSPropertyParser::shouldAcceptUnitLessValues(CSSParserValue* value, Units unitflags, CSSParserMode cssParserMode) |
225 { | 229 { |
226 // Quirks mode for certain properties and presentation attributes accept uni t-less values for certain units. | 230 // Quirks mode for certain properties and presentation attributes accept uni t-less values for certain units. |
227 return (unitflags & (FLength | FAngle)) | 231 return (unitflags & (FLength | FAngle)) |
228 && (!value->fValue // 0 can always be unitless. | 232 && (!value->fValue // 0 can always be unitless. |
229 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and SVG attribute values can always be unitless. | 233 || isUnitLessLengthParsingEnabledForMode(cssParserMode) // HTML and SVG attribute values can always be unitless. |
230 || (cssParserMode == HTMLQuirksMode && (unitflags & FUnitlessQuirk)) ); | 234 || (cssParserMode == HTMLQuirksMode && (unitflags & FUnitlessQuirk)) ); |
231 } | 235 } |
232 | 236 |
233 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) | 237 bool CSSPropertyParser::validUnit(CSSParserValue* value, Units unitflags, CSSPar serMode cssParserMode, ReleaseParsedCalcValueCondition releaseCalc) |
234 { | 238 { |
235 if (isCalculation(value)) | 239 if (isCalculation(value)) |
236 return validCalculationUnit(value, unitflags, releaseCalc); | 240 return validCalculationUnit(value, unitflags, releaseCalc); |
237 | 241 |
242 if (RuntimeEnabledFeatures::cssVariablesEnabled() && isVariableReference(val ue)) | |
243 return true; | |
244 | |
238 if (unitflags & FNonNeg && value->fValue < 0) | 245 if (unitflags & FNonNeg && value->fValue < 0) |
239 return false; | 246 return false; |
240 switch (value->unit) { | 247 switch (value->unit) { |
241 case CSSPrimitiveValue::CSS_NUMBER: | 248 case CSSPrimitiveValue::CSS_NUMBER: |
242 if (unitflags & FNumber) | 249 if (unitflags & FNumber) |
243 return true; | 250 return true; |
244 if (shouldAcceptUnitLessValues(value, unitflags, cssParserMode)) { | 251 if (shouldAcceptUnitLessValues(value, unitflags, cssParserMode)) { |
245 value->unit = (unitflags & FLength) ? CSSPrimitiveValue::CSS_PX : CS SPrimitiveValue::CSS_DEG; | 252 value->unit = (unitflags & FLength) ? CSSPrimitiveValue::CSS_PX : CS SPrimitiveValue::CSS_DEG; |
246 return true; | 253 return true; |
247 } | 254 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 return false; | 294 return false; |
288 } | 295 } |
289 } | 296 } |
290 | 297 |
291 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveNume ricValue(CSSParserValue* value) | 298 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveNume ricValue(CSSParserValue* value) |
292 { | 299 { |
293 if (m_parsedCalculation) { | 300 if (m_parsedCalculation) { |
294 ASSERT(isCalculation(value)); | 301 ASSERT(isCalculation(value)); |
295 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 302 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
296 } | 303 } |
304 if (isVariableReference(value)) | |
305 return createPrimitiveVariableReferenceValue(value); | |
297 | 306 |
298 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPr imitiveValue::CSS_KHZ) | 307 ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPr imitiveValue::CSS_KHZ) |
299 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrim itiveValue::CSS_CHS) | 308 || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrim itiveValue::CSS_CHS) |
300 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimit iveValue::CSS_VMAX) | 309 || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimit iveValue::CSS_VMAX) |
301 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim itiveValue::CSS_DPCM)); | 310 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim itiveValue::CSS_DPCM)); |
302 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal ue::UnitType>(value->unit)); | 311 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal ue::UnitType>(value->unit)); |
303 } | 312 } |
304 | 313 |
314 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveVariableReferenceValue(CSSParserValue* value) | |
315 { | |
316 ASSERT(value->unit == CSSParserValue::VariableValue); | |
317 return CSSPrimitiveValue::create(value->variableData); | |
318 } | |
319 | |
305 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveStringValue(CSSParserValue* value) | 320 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveStringValue(CSSParserValue* value) |
306 { | 321 { |
307 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); | 322 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); |
308 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG); | 323 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG); |
309 } | 324 } |
310 | 325 |
311 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value) | 326 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value) |
312 { | 327 { |
313 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); | 328 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); |
314 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT); | 329 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) | 400 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) |
386 return createPrimitiveNumericValue(value); | 401 return createPrimitiveNumericValue(value); |
387 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV alue::CSS_VMAX) | 402 if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveV alue::CSS_VMAX) |
388 return createPrimitiveNumericValue(value); | 403 return createPrimitiveNumericValue(value); |
389 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) | 404 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) |
390 return createPrimitiveNumericValue(value); | 405 return createPrimitiveNumericValue(value); |
391 if (value->unit == CSSPrimitiveValue::CSS_QEM) | 406 if (value->unit == CSSPrimitiveValue::CSS_QEM) |
392 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); | 407 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); |
393 if (isCalculation(value)) | 408 if (isCalculation(value)) |
394 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 409 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
410 if (isVariableReference(value)) | |
411 return createPrimitiveVariableReferenceValue(value); | |
395 | 412 |
396 return nullptr; | 413 return nullptr; |
397 } | 414 } |
398 | 415 |
399 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe fPtrWillBeRawPtr<CSSValue> prpValue, bool important) | 416 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe fPtrWillBeRawPtr<CSSValue> prpValue, bool important) |
400 { | 417 { |
401 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 418 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
402 unsigned shorthandLength = shorthand.length(); | 419 unsigned shorthandLength = shorthand.length(); |
403 if (!shorthandLength) { | 420 if (!shorthandLength) { |
404 addProperty(propId, prpValue, important); | 421 addProperty(propId, prpValue, important); |
(...skipping 29 matching lines...) Expand all Loading... | |
434 return false; | 451 return false; |
435 addExpandedPropertyForValue(propId, cssValuePool().createExplicitInitial Value(), important); | 452 addExpandedPropertyForValue(propId, cssValuePool().createExplicitInitial Value(), important); |
436 return true; | 453 return true; |
437 } else if (id == CSSValueUnset) { | 454 } else if (id == CSSValueUnset) { |
438 if (m_valueList->size() != 1) | 455 if (m_valueList->size() != 1) |
439 return false; | 456 return false; |
440 addExpandedPropertyForValue(propId, cssValuePool().createUnsetValue(), i mportant); | 457 addExpandedPropertyForValue(propId, cssValuePool().createUnsetValue(), i mportant); |
441 return true; | 458 return true; |
442 } | 459 } |
443 | 460 |
461 | |
444 int num = inShorthand() ? 1 : m_valueList->size(); | 462 int num = inShorthand() ? 1 : m_valueList->size(); |
445 | 463 |
464 if (RuntimeEnabledFeatures::cssVariablesEnabled() && isVariableReference(val ue)) { | |
465 // We don't expand the shorthand here because crazypants. | |
466 m_parsedProperties.append(CSSProperty(propId, createPrimitiveVariableRef erenceValue(value), important, false, 0, m_implicitShorthand)); | |
alancutter (OOO until 2018)
2015/06/26 06:56:07
Is this the only call to createPrimitiveVariableRe
| |
467 m_valueList->next(); | |
468 return true; | |
469 } | |
470 | |
446 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { | 471 if (CSSParserFastPaths::isKeywordPropertyID(propId)) { |
447 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 472 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
448 return false; | 473 return false; |
449 if (m_valueList->next() && !inShorthand()) | 474 if (m_valueList->next() && !inShorthand()) |
450 return false; | 475 return false; |
451 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; | 476 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; |
452 return true; | 477 return true; |
453 } | 478 } |
454 | 479 |
455 bool validPrimitive = false; | 480 bool validPrimitive = false; |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1556 | 1581 |
1557 // Properties below are validated inside parseViewportProperty, because we | 1582 // Properties below are validated inside parseViewportProperty, because we |
1558 // check for parser state. We need to invalidate if someone adds them outsid e | 1583 // check for parser state. We need to invalidate if someone adds them outsid e |
1559 // a @viewport rule. | 1584 // a @viewport rule. |
1560 case CSSPropertyMaxZoom: | 1585 case CSSPropertyMaxZoom: |
1561 case CSSPropertyMinZoom: | 1586 case CSSPropertyMinZoom: |
1562 case CSSPropertyOrientation: | 1587 case CSSPropertyOrientation: |
1563 case CSSPropertyUserZoom: | 1588 case CSSPropertyUserZoom: |
1564 validPrimitive = false; | 1589 validPrimitive = false; |
1565 break; | 1590 break; |
1566 | |
1567 case CSSPropertyScrollSnapPointsX: | 1591 case CSSPropertyScrollSnapPointsX: |
1568 case CSSPropertyScrollSnapPointsY: | 1592 case CSSPropertyScrollSnapPointsY: |
1569 parsedValue = parseScrollSnapPoints(); | 1593 parsedValue = parseScrollSnapPoints(); |
1570 break; | 1594 break; |
1571 case CSSPropertyScrollSnapCoordinate: | 1595 case CSSPropertyScrollSnapCoordinate: |
1572 parsedValue = parseScrollSnapCoordinate(); | 1596 parsedValue = parseScrollSnapCoordinate(); |
1573 break; | 1597 break; |
1574 case CSSPropertyScrollSnapDestination: | 1598 case CSSPropertyScrollSnapDestination: |
1575 parsedValue = parsePosition(m_valueList); | 1599 parsedValue = parsePosition(m_valueList); |
1576 break; | |
alancutter (OOO until 2018)
2015/06/26 06:56:08
Accidental removal?
| |
1577 | |
1578 default: | 1600 default: |
1579 return parseSVGValue(propId, important); | 1601 return parseSVGValue(propId, important); |
1580 } | 1602 } |
1581 | 1603 |
1582 if (validPrimitive) { | 1604 if (validPrimitive) { |
1583 parsedValue = parseValidPrimitive(id, value); | 1605 parsedValue = parseValidPrimitive(id, value); |
1584 m_valueList->next(); | 1606 m_valueList->next(); |
1585 } | 1607 } |
1586 ASSERT(!m_parsedCalculation); | 1608 ASSERT(!m_parsedCalculation); |
1587 if (parsedValue) { | 1609 if (parsedValue) { |
(...skipping 3348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4936 } | 4958 } |
4937 | 4959 |
4938 | 4960 |
4939 bool CSSPropertyParser::isCalculation(CSSParserValue* value) | 4961 bool CSSPropertyParser::isCalculation(CSSParserValue* value) |
4940 { | 4962 { |
4941 return (value->unit == CSSParserValue::Function) | 4963 return (value->unit == CSSParserValue::Function) |
4942 && (value->function->id == CSSValueCalc | 4964 && (value->function->id == CSSValueCalc |
4943 || value->function->id == CSSValueWebkitCalc); | 4965 || value->function->id == CSSValueWebkitCalc); |
4944 } | 4966 } |
4945 | 4967 |
4968 bool CSSPropertyParser::isVariableReference(CSSParserValue* value) | |
4969 { | |
4970 return value->unit == CSSParserValue::VariableValue; | |
4971 } | |
4972 | |
4946 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 4973 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
4947 { | 4974 { |
4948 bool isPercent; | 4975 bool isPercent; |
4949 double value; | 4976 double value; |
4950 | 4977 |
4951 if (m_parsedCalculation) { | 4978 if (m_parsedCalculation) { |
4952 isPercent = m_parsedCalculation->category() == CalcPercent; | 4979 isPercent = m_parsedCalculation->category() == CalcPercent; |
4953 value = m_parsedCalculation->doubleValue(); | 4980 value = m_parsedCalculation->doubleValue(); |
4954 m_parsedCalculation.release(); | 4981 m_parsedCalculation.release(); |
4955 } else { | 4982 } else { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5304 return nullptr; | 5331 return nullptr; |
5305 } | 5332 } |
5306 | 5333 |
5307 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() | 5334 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() |
5308 { | 5335 { |
5309 // box-reflect: <direction> <offset> <mask> | 5336 // box-reflect: <direction> <offset> <mask> |
5310 | 5337 |
5311 // Direction comes first. | 5338 // Direction comes first. |
5312 CSSParserValue* val = m_valueList->current(); | 5339 CSSParserValue* val = m_valueList->current(); |
5313 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; | 5340 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; |
5314 switch (val->id) { | 5341 if (isVariableReference(val)) { |
5315 case CSSValueAbove: | 5342 direction = createPrimitiveVariableReferenceValue(val); |
5316 case CSSValueBelow: | 5343 } else { |
5317 case CSSValueLeft: | 5344 switch (val->id) { |
5318 case CSSValueRight: | 5345 case CSSValueAbove: |
5319 direction = cssValuePool().createIdentifierValue(val->id); | 5346 case CSSValueBelow: |
5320 break; | 5347 case CSSValueLeft: |
5321 default: | 5348 case CSSValueRight: |
5322 return nullptr; | 5349 direction = cssValuePool().createIdentifierValue(val->id); |
5350 break; | |
5351 default: | |
5352 return nullptr; | |
5353 } | |
5323 } | 5354 } |
5324 | 5355 |
5325 // The offset comes next. | 5356 // The offset comes next. |
5326 val = m_valueList->next(); | 5357 val = m_valueList->next(); |
5327 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; | 5358 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; |
5328 if (!val) | 5359 if (!val) |
5329 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); | 5360 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); |
5330 else { | 5361 else { |
5331 if (!validUnit(val, FLength | FPercent)) | 5362 if (!validUnit(val, FLength | FPercent)) |
5332 return nullptr; | 5363 return nullptr; |
(...skipping 2239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7572 | 7603 |
7573 // If just one value is supplied, the second value | 7604 // If just one value is supplied, the second value |
7574 // is implicitly initialized with the first value. | 7605 // is implicitly initialized with the first value. |
7575 if (numValues == 1) | 7606 if (numValues == 1) |
7576 m_valueList->previous(); | 7607 m_valueList->previous(); |
7577 | 7608 |
7578 return parseViewportProperty(second, important); | 7609 return parseViewportProperty(second, important); |
7579 } | 7610 } |
7580 | 7611 |
7581 template <typename CharacterType> | 7612 template <typename CharacterType> |
7613 static bool isVariableDefinition(const CharacterType* propertyName, unsigned len gth) | |
7614 { | |
7615 return (length >= 2 && propertyName[0] == '-' && propertyName[1] == '-'); | |
7616 } | |
7617 | |
7618 template <typename CharacterType> | |
7582 static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName, unsigned length) | 7619 static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName, unsigned length) |
7583 { | 7620 { |
7584 char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character | 7621 char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character |
7585 | 7622 |
7586 for (unsigned i = 0; i != length; ++i) { | 7623 for (unsigned i = 0; i != length; ++i) { |
7587 CharacterType c = propertyName[i]; | 7624 CharacterType c = propertyName[i]; |
7588 if (c == 0 || c >= 0x7F) | 7625 if (c == 0 || c >= 0x7F) { |
7626 if (isVariableDefinition(propertyName, length)) | |
7627 return CSSPropertyVariable; | |
7589 return CSSPropertyInvalid; // illegal character | 7628 return CSSPropertyInvalid; // illegal character |
7629 } | |
7590 buffer[i] = toASCIILower(c); | 7630 buffer[i] = toASCIILower(c); |
7591 } | 7631 } |
7592 buffer[length] = '\0'; | 7632 buffer[length] = '\0'; |
7593 | 7633 |
7594 const char* name = buffer; | 7634 const char* name = buffer; |
7595 const Property* hashTableEntry = findProperty(name, length); | 7635 const Property* hashTableEntry = findProperty(name, length); |
7596 if (!hashTableEntry) | 7636 if (!hashTableEntry) { |
7637 if (isVariableDefinition(propertyName, length)) | |
7638 return CSSPropertyVariable; | |
7597 return CSSPropertyInvalid; | 7639 return CSSPropertyInvalid; |
7640 } | |
7598 CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id); | 7641 CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id); |
7599 if (!CSSPropertyMetadata::isEnabledProperty(property)) | 7642 if (!CSSPropertyMetadata::isEnabledProperty(property)) |
7600 return CSSPropertyInvalid; | 7643 return CSSPropertyInvalid; |
7601 return property; | 7644 return property; |
7602 } | 7645 } |
7603 | 7646 |
7604 CSSPropertyID unresolvedCSSPropertyID(const String& string) | 7647 CSSPropertyID unresolvedCSSPropertyID(const String& string) |
7605 { | 7648 { |
7606 unsigned length = string.length(); | 7649 unsigned length = string.length(); |
7607 | 7650 |
7608 if (!length) | 7651 if (!length) |
7609 return CSSPropertyInvalid; | 7652 return CSSPropertyInvalid; |
7610 if (length > maxCSSPropertyNameLength) | 7653 if (length > maxCSSPropertyNameLength) { |
7654 if (string.is8Bit() ? isVariableDefinition(string.characters8(), length) : isVariableDefinition(string.characters16(), length)) | |
7655 return CSSPropertyVariable; | |
7611 return CSSPropertyInvalid; | 7656 return CSSPropertyInvalid; |
7657 } | |
7612 | 7658 |
7613 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); | 7659 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); |
7614 } | 7660 } |
7615 | 7661 |
7616 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString& string) | 7662 CSSPropertyID unresolvedCSSPropertyID(const CSSParserString& string) |
7617 { | 7663 { |
7618 unsigned length = string.length(); | 7664 unsigned length = string.length(); |
7619 | 7665 |
7620 if (!length) | 7666 if (!length) |
7621 return CSSPropertyInvalid; | 7667 return CSSPropertyInvalid; |
7622 if (length > maxCSSPropertyNameLength) | 7668 if (length > maxCSSPropertyNameLength) { |
7669 if (string.is8Bit() ? isVariableDefinition(string.characters8(), length) : isVariableDefinition(string.characters16(), length)) | |
7670 return CSSPropertyVariable; | |
7623 return CSSPropertyInvalid; | 7671 return CSSPropertyInvalid; |
7672 } | |
7624 | 7673 |
7625 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); | 7674 return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), lengt h) : unresolvedCSSPropertyID(string.characters16(), length); |
7626 } | 7675 } |
7627 | 7676 |
7628 template <typename CharacterType> | 7677 template <typename CharacterType> |
7629 static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned length) | 7678 static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned length) |
7630 { | 7679 { |
7631 char buffer[maxCSSValueKeywordLength + 1]; // 1 for null character | 7680 char buffer[maxCSSValueKeywordLength + 1]; // 1 for null character |
7632 | 7681 |
7633 for (unsigned i = 0; i != length; ++i) { | 7682 for (unsigned i = 0; i != length; ++i) { |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8246 } | 8295 } |
8247 } | 8296 } |
8248 | 8297 |
8249 if (!list->length()) | 8298 if (!list->length()) |
8250 return nullptr; | 8299 return nullptr; |
8251 | 8300 |
8252 return list.release(); | 8301 return list.release(); |
8253 } | 8302 } |
8254 | 8303 |
8255 } // namespace blink | 8304 } // namespace blink |
OLD | NEW |