| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 template <unsigned N> | 68 template <unsigned N> |
| 69 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) | 69 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) |
| 70 { | 70 { |
| 71 unsigned length = N - 1; // Ignore the trailing null character | 71 unsigned length = N - 1; // Ignore the trailing null character |
| 72 if (a.length() != length) | 72 if (a.length() != length) |
| 73 return false; | 73 return false; |
| 74 | 74 |
| 75 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF
::equalIgnoringCase(b, a.characters16(), length); | 75 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF
::equalIgnoringCase(b, a.characters16(), length); |
| 76 } | 76 } |
| 77 | 77 |
| 78 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRe
fPtrWillBeRawPtr<CSSPrimitiveValue> first, PassRefPtrWillBeRawPtr<CSSPrimitiveVa
lue> second, Pair::IdenticalValuesPolicy identicalValuesPolicy = Pair::DropIdent
icalValues) | 78 static PassRefPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRefPtr<CSSPrim
itiveValue> first, PassRefPtr<CSSPrimitiveValue> second, Pair::IdenticalValuesPo
licy identicalValuesPolicy = Pair::DropIdenticalValues) |
| 79 { | 79 { |
| 80 return cssValuePool().createValue(Pair::create(first, second, identicalValue
sPolicy)); | 80 return cssValuePool().createValue(Pair::create(first, second, identicalValue
sPolicy)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, | 83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, |
| 84 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP
roperties, | 84 const CSSParserContext& context, Vector<CSSProperty, 256>& parsedProperties, |
| 85 StyleRule::Type ruleType) | 85 StyleRule::Type ruleType) |
| 86 : m_valueList(valueList) | 86 : m_valueList(valueList) |
| 87 , m_context(context) | 87 , m_context(context) |
| 88 , m_parsedProperties(parsedProperties) | 88 , m_parsedProperties(parsedProperties) |
| 89 , m_ruleType(ruleType) | 89 , m_ruleType(ruleType) |
| 90 , m_inParseShorthand(0) | 90 , m_inParseShorthand(0) |
| 91 , m_currentShorthand(CSSPropertyInvalid) | 91 , m_currentShorthand(CSSPropertyInvalid) |
| 92 , m_implicitShorthand(false) | 92 , m_implicitShorthand(false) |
| 93 { | 93 { |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant, | 96 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant, |
| 97 CSSParserValueList* valueList, const CSSParserContext& context, | 97 CSSParserValueList* valueList, const CSSParserContext& context, |
| 98 WillBeHeapVector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleTy
pe) | 98 Vector<CSSProperty, 256>& parsedProperties, StyleRule::Type ruleType) |
| 99 { | 99 { |
| 100 int parsedPropertiesSize = parsedProperties.size(); | 100 int parsedPropertiesSize = parsedProperties.size(); |
| 101 | 101 |
| 102 CSSPropertyParser parser(valueList, context, parsedProperties, ruleType); | 102 CSSPropertyParser parser(valueList, context, parsedProperties, ruleType); |
| 103 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); | 103 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); |
| 104 bool parseSuccess; | 104 bool parseSuccess; |
| 105 | 105 |
| 106 if (ruleType == StyleRule::Viewport) { | 106 if (ruleType == StyleRule::Viewport) { |
| 107 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee
tBehavior(context.mode())) | 107 parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUAShee
tBehavior(context.mode())) |
| 108 && parser.parseViewportProperty(resolvedProperty, important); | 108 && parser.parseViewportProperty(resolvedProperty, important); |
| 109 } else if (ruleType == StyleRule::FontFace) { | 109 } else if (ruleType == StyleRule::FontFace) { |
| 110 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); | 110 parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty); |
| 111 } else { | 111 } else { |
| 112 parseSuccess = parser.parseValue(unresolvedProperty, important); | 112 parseSuccess = parser.parseValue(unresolvedProperty, important); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // This doesn't count UA style sheets | 115 // This doesn't count UA style sheets |
| 116 if (parseSuccess && context.useCounter()) | 116 if (parseSuccess && context.useCounter()) |
| 117 context.useCounter()->count(context, unresolvedProperty); | 117 context.useCounter()->count(context, unresolvedProperty); |
| 118 | 118 |
| 119 if (!parseSuccess) | 119 if (!parseSuccess) |
| 120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties
Size); | 120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties
Size); |
| 121 | 121 |
| 122 return parseSuccess; | 122 return parseSuccess; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr
<CSSValue> value, bool important, bool implicit) | 125 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> v
alue, bool important, bool implicit) |
| 126 { | 126 { |
| 127 ASSERT(!isPropertyAlias(propId)); | 127 ASSERT(!isPropertyAlias(propId)); |
| 128 | 128 |
| 129 int shorthandIndex = 0; | 129 int shorthandIndex = 0; |
| 130 bool setFromShorthand = false; | 130 bool setFromShorthand = false; |
| 131 | 131 |
| 132 if (m_currentShorthand) { | 132 if (m_currentShorthand) { |
| 133 Vector<StylePropertyShorthand, 4> shorthands; | 133 Vector<StylePropertyShorthand, 4> shorthands; |
| 134 getMatchingShorthandsForLonghand(propId, &shorthands); | 134 getMatchingShorthandsForLonghand(propId, &shorthands); |
| 135 // Viewport descriptors have width and height as shorthands, but it does
n't | 135 // Viewport descriptors have width and height as shorthands, but it does
n't |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 return unitflags & FAngle; | 286 return unitflags & FAngle; |
| 287 case CSSPrimitiveValue::UnitType::DotsPerPixel: | 287 case CSSPrimitiveValue::UnitType::DotsPerPixel: |
| 288 case CSSPrimitiveValue::UnitType::DotsPerInch: | 288 case CSSPrimitiveValue::UnitType::DotsPerInch: |
| 289 case CSSPrimitiveValue::UnitType::DotsPerCentimeter: | 289 case CSSPrimitiveValue::UnitType::DotsPerCentimeter: |
| 290 return unitflags & FResolution; | 290 return unitflags & FResolution; |
| 291 default: | 291 default: |
| 292 return false; | 292 return false; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveNume
ricValue(CSSParserValue* value) | 296 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveNumericValue(CSS
ParserValue* value) |
| 297 { | 297 { |
| 298 if (m_parsedCalculation) { | 298 if (m_parsedCalculation) { |
| 299 ASSERT(isCalculation(value)); | 299 ASSERT(isCalculation(value)); |
| 300 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 300 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 ASSERT((value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit(
) <= CSSPrimitiveValue::UnitType::Kilohertz) | 303 ASSERT((value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit(
) <= CSSPrimitiveValue::UnitType::Kilohertz) |
| 304 || (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit()
<= CSSPrimitiveValue::UnitType::Chs) | 304 || (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit()
<= CSSPrimitiveValue::UnitType::Chs) |
| 305 || (value->unit() >= CSSPrimitiveValue::UnitType::ViewportWidth && value
->unit() <= CSSPrimitiveValue::UnitType::ViewportMax) | 305 || (value->unit() >= CSSPrimitiveValue::UnitType::ViewportWidth && value
->unit() <= CSSPrimitiveValue::UnitType::ViewportMax) |
| 306 || (value->unit() >= CSSPrimitiveValue::UnitType::DotsPerPixel && value-
>unit() <= CSSPrimitiveValue::UnitType::DotsPerCentimeter)); | 306 || (value->unit() >= CSSPrimitiveValue::UnitType::DotsPerPixel && value-
>unit() <= CSSPrimitiveValue::UnitType::DotsPerCentimeter)); |
| 307 return cssValuePool().createValue(value->fValue, value->unit()); | 307 return cssValuePool().createValue(value->fValue, value->unit()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveStringValue(CSSParserValue* value) | 310 inline PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveStringVal
ue(CSSParserValue* value) |
| 311 { | 311 { |
| 312 ASSERT(value->unit() == CSSPrimitiveValue::UnitType::String || value->m_unit
== CSSParserValue::Identifier); | 312 ASSERT(value->unit() == CSSPrimitiveValue::UnitType::String || value->m_unit
== CSSParserValue::Identifier); |
| 313 return cssValuePool().createValue(value->string, CSSPrimitiveValue::UnitType
::String); | 313 return cssValuePool().createValue(value->string, CSSPrimitiveValue::UnitType
::String); |
| 314 } | 314 } |
| 315 | 315 |
| 316 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveCustomIdentValue(CSSParserValue* value) | 316 inline PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimitiveCustomIde
ntValue(CSSParserValue* value) |
| 317 { | 317 { |
| 318 ASSERT(value->unit() == CSSPrimitiveValue::UnitType::String || value->m_unit
== CSSParserValue::Identifier); | 318 ASSERT(value->unit() == CSSPrimitiveValue::UnitType::String || value->m_unit
== CSSParserValue::Identifier); |
| 319 return cssValuePool().createValue(value->string, CSSPrimitiveValue::UnitType
::CustomIdentifier); | 319 return cssValuePool().createValue(value->string, CSSPrimitiveValue::UnitType
::CustomIdentifier); |
| 320 } | 320 } |
| 321 | 321 |
| 322 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi
thReferrer(const String& rawValue, const KURL& url) | 322 inline PassRefPtr<CSSValue> CSSPropertyParser::createCSSImageValueWithReferrer(c
onst String& rawValue, const KURL& url) |
| 323 { | 323 { |
| 324 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur
l); | 324 RefPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, url); |
| 325 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); | 325 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); |
| 326 return imageValue; | 326 return imageValue; |
| 327 } | 327 } |
| 328 | 328 |
| 329 static inline bool isComma(CSSParserValue* value) | 329 static inline bool isComma(CSSParserValue* value) |
| 330 { | 330 { |
| 331 ASSERT(value); | 331 ASSERT(value); |
| 332 return value->m_unit == CSSParserValue::Operator && value->iValue == ','; | 332 return value->m_unit == CSSParserValue::Operator && value->iValue == ','; |
| 333 } | 333 } |
| 334 | 334 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 break; | 394 break; |
| 395 default: | 395 default: |
| 396 break; | 396 break; |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 return true; | 399 return true; |
| 400 } | 400 } |
| 401 return validUnit(value, FLength | FPercent | FNonNeg | unitless); | 401 return validUnit(value, FLength | FPercent | FNonNeg | unitless); |
| 402 } | 402 } |
| 403 | 403 |
| 404 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr
imitive(CSSValueID identifier, CSSParserValue* value) | 404 inline PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPrimitive(CSSV
alueID identifier, CSSParserValue* value) |
| 405 { | 405 { |
| 406 if (identifier) | 406 if (identifier) |
| 407 return cssValuePool().createIdentifierValue(identifier); | 407 return cssValuePool().createIdentifierValue(identifier); |
| 408 if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit() <=
CSSPrimitiveValue::UnitType::Kilohertz) | 408 if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit() <=
CSSPrimitiveValue::UnitType::Kilohertz) |
| 409 return createPrimitiveNumericValue(value); | 409 return createPrimitiveNumericValue(value); |
| 410 if (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit() <=
CSSPrimitiveValue::UnitType::Chs) | 410 if (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit() <=
CSSPrimitiveValue::UnitType::Chs) |
| 411 return createPrimitiveNumericValue(value); | 411 return createPrimitiveNumericValue(value); |
| 412 if (value->unit() >= CSSPrimitiveValue::UnitType::ViewportWidth && value->un
it() <= CSSPrimitiveValue::UnitType::ViewportMax) | 412 if (value->unit() >= CSSPrimitiveValue::UnitType::ViewportWidth && value->un
it() <= CSSPrimitiveValue::UnitType::ViewportMax) |
| 413 return createPrimitiveNumericValue(value); | 413 return createPrimitiveNumericValue(value); |
| 414 if (value->unit() >= CSSPrimitiveValue::UnitType::DotsPerPixel && value->uni
t() <= CSSPrimitiveValue::UnitType::DotsPerCentimeter) | 414 if (value->unit() >= CSSPrimitiveValue::UnitType::DotsPerPixel && value->uni
t() <= CSSPrimitiveValue::UnitType::DotsPerCentimeter) |
| 415 return createPrimitiveNumericValue(value); | 415 return createPrimitiveNumericValue(value); |
| 416 if (value->unit() == CSSPrimitiveValue::UnitType::QuirkyEms) | 416 if (value->unit() == CSSPrimitiveValue::UnitType::QuirkyEms) |
| 417 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::UnitType::Ems); | 417 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::UnitType::Ems); |
| 418 if (isCalculation(value)) | 418 if (isCalculation(value)) |
| 419 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 419 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
| 420 | 420 |
| 421 return nullptr; | 421 return nullptr; |
| 422 } | 422 } |
| 423 | 423 |
| 424 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtrWillBeRawPtr<CSSValue> prpValue, bool important) | 424 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtr<CSSValue> prpValue, bool important) |
| 425 { | 425 { |
| 426 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 426 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
| 427 unsigned shorthandLength = shorthand.length(); | 427 unsigned shorthandLength = shorthand.length(); |
| 428 if (!shorthandLength) { | 428 if (!shorthandLength) { |
| 429 addProperty(propId, prpValue, important); | 429 addProperty(propId, prpValue, important); |
| 430 return; | 430 return; |
| 431 } | 431 } |
| 432 | 432 |
| 433 RefPtrWillBeRawPtr<CSSValue> value = prpValue; | 433 RefPtr<CSSValue> value = prpValue; |
| 434 ShorthandScope scope(this, propId); | 434 ShorthandScope scope(this, propId); |
| 435 const CSSPropertyID* longhands = shorthand.properties(); | 435 const CSSPropertyID* longhands = shorthand.properties(); |
| 436 for (unsigned i = 0; i < shorthandLength; ++i) | 436 for (unsigned i = 0; i < shorthandLength; ++i) |
| 437 addProperty(longhands[i], value, important); | 437 addProperty(longhands[i], value, important); |
| 438 } | 438 } |
| 439 | 439 |
| 440 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant) | 440 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant) |
| 441 { | 441 { |
| 442 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); | 442 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); |
| 443 | 443 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 470 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 470 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
| 471 return false; | 471 return false; |
| 472 if (m_valueList->next() && !inShorthand()) | 472 if (m_valueList->next() && !inShorthand()) |
| 473 return false; | 473 return false; |
| 474 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; | 474 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; |
| 475 return true; | 475 return true; |
| 476 } | 476 } |
| 477 | 477 |
| 478 bool validPrimitive = false; | 478 bool validPrimitive = false; |
| 479 Units unitless = FUnknown; | 479 Units unitless = FUnknown; |
| 480 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 480 RefPtr<CSSValue> parsedValue = nullptr; |
| 481 | 481 |
| 482 switch (propId) { | 482 switch (propId) { |
| 483 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] | 483 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] |
| 484 parsedValue = parseSize(); | 484 parsedValue = parseSize(); |
| 485 break; | 485 break; |
| 486 case CSSPropertyQuotes: // [<string> <string>]+ | none | 486 case CSSPropertyQuotes: // [<string> <string>]+ | none |
| 487 if (id == CSSValueNone) | 487 if (id == CSSValueNone) |
| 488 validPrimitive = true; | 488 validPrimitive = true; |
| 489 else | 489 else |
| 490 parsedValue = parseQuotes(); | 490 parsedValue = parseQuotes(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 502 break; | 502 break; |
| 503 | 503 |
| 504 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work | 504 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work |
| 505 * correctly and allows optimization in blink::applyRule(..) | 505 * correctly and allows optimization in blink::applyRule(..) |
| 506 */ | 506 */ |
| 507 case CSSPropertyOverflow: { | 507 case CSSPropertyOverflow: { |
| 508 ShorthandScope scope(this, propId); | 508 ShorthandScope scope(this, propId); |
| 509 if (!parseValue(CSSPropertyOverflowY, important) || m_valueList->current
()) | 509 if (!parseValue(CSSPropertyOverflowY, important) || m_valueList->current
()) |
| 510 return false; | 510 return false; |
| 511 | 511 |
| 512 RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr; | 512 RefPtr<CSSValue> overflowXValue = nullptr; |
| 513 | 513 |
| 514 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been | 514 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been |
| 515 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement | 515 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement |
| 516 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but | 516 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but |
| 517 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. | 517 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. |
| 518 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | 518 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) |
| 519 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); | 519 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); |
| 520 else | 520 else |
| 521 overflowXValue = m_parsedProperties.last().value(); | 521 overflowXValue = m_parsedProperties.last().value(); |
| 522 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); | 522 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 break; | 585 break; |
| 586 | 586 |
| 587 case CSSPropertyCursor: { | 587 case CSSPropertyCursor: { |
| 588 // Grammar defined by CSS3 UI and modified by CSS4 images: | 588 // Grammar defined by CSS3 UI and modified by CSS4 images: |
| 589 // [ [<image> [<x> <y>]?,]* | 589 // [ [<image> [<x> <y>]?,]* |
| 590 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | | 590 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | |
| 591 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | 591 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | |
| 592 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | | 592 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | |
| 593 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | | 593 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | |
| 594 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit | 594 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit |
| 595 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | 595 RefPtr<CSSValueList> list = nullptr; |
| 596 while (value) { | 596 while (value) { |
| 597 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | 597 RefPtr<CSSValue> image = nullptr; |
| 598 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { | 598 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 599 String uri = value->string; | 599 String uri = value->string; |
| 600 if (!uri.isNull()) | 600 if (!uri.isNull()) |
| 601 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); | 601 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); |
| 602 } else if (value->m_unit == CSSParserValue::Function && value->funct
ion->id == CSSValueWebkitImageSet) { | 602 } else if (value->m_unit == CSSParserValue::Function && value->funct
ion->id == CSSValueWebkitImageSet) { |
| 603 image = parseImageSet(m_valueList); | 603 image = parseImageSet(m_valueList); |
| 604 if (!image) | 604 if (!image) |
| 605 break; | 605 break; |
| 606 } else | 606 } else |
| 607 break; | 607 break; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 case CSSPropertyWebkitMaskImage: | 685 case CSSPropertyWebkitMaskImage: |
| 686 case CSSPropertyWebkitMaskOrigin: | 686 case CSSPropertyWebkitMaskOrigin: |
| 687 case CSSPropertyWebkitMaskPosition: | 687 case CSSPropertyWebkitMaskPosition: |
| 688 case CSSPropertyWebkitMaskPositionX: | 688 case CSSPropertyWebkitMaskPositionX: |
| 689 case CSSPropertyWebkitMaskPositionY: | 689 case CSSPropertyWebkitMaskPositionY: |
| 690 case CSSPropertyWebkitMaskSize: | 690 case CSSPropertyWebkitMaskSize: |
| 691 case CSSPropertyWebkitMaskRepeat: | 691 case CSSPropertyWebkitMaskRepeat: |
| 692 case CSSPropertyWebkitMaskRepeatX: | 692 case CSSPropertyWebkitMaskRepeatX: |
| 693 case CSSPropertyWebkitMaskRepeatY: | 693 case CSSPropertyWebkitMaskRepeatY: |
| 694 { | 694 { |
| 695 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; | 695 RefPtr<CSSValue> val1 = nullptr; |
| 696 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; | 696 RefPtr<CSSValue> val2 = nullptr; |
| 697 CSSPropertyID propId1, propId2; | 697 CSSPropertyID propId1, propId2; |
| 698 bool result = false; | 698 bool result = false; |
| 699 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2))
{ | 699 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2))
{ |
| 700 if (propId == CSSPropertyBackgroundPosition || | 700 if (propId == CSSPropertyBackgroundPosition || |
| 701 propId == CSSPropertyBackgroundRepeat || | 701 propId == CSSPropertyBackgroundRepeat || |
| 702 propId == CSSPropertyWebkitMaskPosition || | 702 propId == CSSPropertyWebkitMaskPosition || |
| 703 propId == CSSPropertyWebkitMaskRepeat) { | 703 propId == CSSPropertyWebkitMaskRepeat) { |
| 704 ShorthandScope scope(this, propId); | 704 ShorthandScope scope(this, propId); |
| 705 addProperty(propId1, val1.release(), important); | 705 addProperty(propId1, val1.release(), important); |
| 706 if (val2) | 706 if (val2) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 case CSSPropertyUnicodeRange: | 917 case CSSPropertyUnicodeRange: |
| 918 /* @font-face only descriptors */ | 918 /* @font-face only descriptors */ |
| 919 break; | 919 break; |
| 920 | 920 |
| 921 /* CSS3 properties */ | 921 /* CSS3 properties */ |
| 922 | 922 |
| 923 case CSSPropertyBorderImage: | 923 case CSSPropertyBorderImage: |
| 924 case CSSPropertyWebkitMaskBoxImage: | 924 case CSSPropertyWebkitMaskBoxImage: |
| 925 return parseBorderImageShorthand(propId, important); | 925 return parseBorderImageShorthand(propId, important); |
| 926 case CSSPropertyWebkitBorderImage: { | 926 case CSSPropertyWebkitBorderImage: { |
| 927 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { | 927 if (RefPtr<CSSValue> result = parseBorderImage(propId)) { |
| 928 addProperty(propId, result, important); | 928 addProperty(propId, result, important); |
| 929 return true; | 929 return true; |
| 930 } | 930 } |
| 931 return false; | 931 return false; |
| 932 } | 932 } |
| 933 | 933 |
| 934 case CSSPropertyBorderImageOutset: | 934 case CSSPropertyBorderImageOutset: |
| 935 case CSSPropertyWebkitMaskBoxImageOutset: { | 935 case CSSPropertyWebkitMaskBoxImageOutset: { |
| 936 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 936 RefPtr<CSSPrimitiveValue> result = nullptr; |
| 937 if (parseBorderImageOutset(result)) { | 937 if (parseBorderImageOutset(result)) { |
| 938 addProperty(propId, result, important); | 938 addProperty(propId, result, important); |
| 939 return true; | 939 return true; |
| 940 } | 940 } |
| 941 break; | 941 break; |
| 942 } | 942 } |
| 943 case CSSPropertyBorderImageRepeat: | 943 case CSSPropertyBorderImageRepeat: |
| 944 case CSSPropertyWebkitMaskBoxImageRepeat: { | 944 case CSSPropertyWebkitMaskBoxImageRepeat: { |
| 945 RefPtrWillBeRawPtr<CSSValue> result = nullptr; | 945 RefPtr<CSSValue> result = nullptr; |
| 946 if (parseBorderImageRepeat(result)) { | 946 if (parseBorderImageRepeat(result)) { |
| 947 addProperty(propId, result, important); | 947 addProperty(propId, result, important); |
| 948 return true; | 948 return true; |
| 949 } | 949 } |
| 950 break; | 950 break; |
| 951 } | 951 } |
| 952 case CSSPropertyBorderImageSlice: | 952 case CSSPropertyBorderImageSlice: |
| 953 case CSSPropertyWebkitMaskBoxImageSlice: { | 953 case CSSPropertyWebkitMaskBoxImageSlice: { |
| 954 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr; | 954 RefPtr<CSSBorderImageSliceValue> result = nullptr; |
| 955 if (parseBorderImageSlice(propId, result)) { | 955 if (parseBorderImageSlice(propId, result)) { |
| 956 addProperty(propId, result, important); | 956 addProperty(propId, result, important); |
| 957 return true; | 957 return true; |
| 958 } | 958 } |
| 959 break; | 959 break; |
| 960 } | 960 } |
| 961 case CSSPropertyBorderImageWidth: | 961 case CSSPropertyBorderImageWidth: |
| 962 case CSSPropertyWebkitMaskBoxImageWidth: { | 962 case CSSPropertyWebkitMaskBoxImageWidth: { |
| 963 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 963 RefPtr<CSSPrimitiveValue> result = nullptr; |
| 964 if (parseBorderImageWidth(result)) { | 964 if (parseBorderImageWidth(result)) { |
| 965 addProperty(propId, result, important); | 965 addProperty(propId, result, important); |
| 966 return true; | 966 return true; |
| 967 } | 967 } |
| 968 break; | 968 break; |
| 969 } | 969 } |
| 970 case CSSPropertyBorderTopRightRadius: | 970 case CSSPropertyBorderTopRightRadius: |
| 971 case CSSPropertyBorderTopLeftRadius: | 971 case CSSPropertyBorderTopLeftRadius: |
| 972 case CSSPropertyBorderBottomLeftRadius: | 972 case CSSPropertyBorderBottomLeftRadius: |
| 973 case CSSPropertyBorderBottomRightRadius: { | 973 case CSSPropertyBorderBottomRightRadius: { |
| 974 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); | 974 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); |
| 975 if (!validPrimitive) | 975 if (!validPrimitive) |
| 976 return false; | 976 return false; |
| 977 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = createPrimitiveNume
ricValue(value); | 977 RefPtr<CSSPrimitiveValue> parsedValue1 = createPrimitiveNumericValue(val
ue); |
| 978 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = nullptr; | 978 RefPtr<CSSPrimitiveValue> parsedValue2 = nullptr; |
| 979 value = m_valueList->next(); | 979 value = m_valueList->next(); |
| 980 if (value) { | 980 if (value) { |
| 981 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); | 981 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); |
| 982 if (!validPrimitive) | 982 if (!validPrimitive) |
| 983 return false; | 983 return false; |
| 984 parsedValue2 = createPrimitiveNumericValue(value); | 984 parsedValue2 = createPrimitiveNumericValue(value); |
| 985 } else | 985 } else |
| 986 parsedValue2 = parsedValue1; | 986 parsedValue2 = parsedValue1; |
| 987 | 987 |
| 988 if (m_valueList->next()) | 988 if (m_valueList->next()) |
| 989 return false; | 989 return false; |
| 990 addProperty(propId, createPrimitiveValuePair(parsedValue1.release(), par
sedValue2.release()), important); | 990 addProperty(propId, createPrimitiveValuePair(parsedValue1.release(), par
sedValue2.release()), important); |
| 991 return true; | 991 return true; |
| 992 } | 992 } |
| 993 case CSSPropertyTabSize: | 993 case CSSPropertyTabSize: |
| 994 // May be specified as a unit-less non-negative integer or length indica
ting number of space characters. | 994 // May be specified as a unit-less non-negative integer or length indica
ting number of space characters. |
| 995 validPrimitive = validUnit(value, FInteger | FLength | FNonNeg); | 995 validPrimitive = validUnit(value, FInteger | FLength | FNonNeg); |
| 996 break; | 996 break; |
| 997 case CSSPropertyBorderRadius: | 997 case CSSPropertyBorderRadius: |
| 998 case CSSPropertyAliasWebkitBorderRadius: | 998 case CSSPropertyAliasWebkitBorderRadius: |
| 999 return parseBorderRadius(unresolvedProperty, important); | 999 return parseBorderRadius(unresolvedProperty, important); |
| 1000 case CSSPropertyOutlineOffset: | 1000 case CSSPropertyOutlineOffset: |
| 1001 validPrimitive = validUnit(value, FLength); | 1001 validPrimitive = validUnit(value, FLength); |
| 1002 break; | 1002 break; |
| 1003 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 | 1003 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 |
| 1004 case CSSPropertyBoxShadow: | 1004 case CSSPropertyBoxShadow: |
| 1005 if (id == CSSValueNone) | 1005 if (id == CSSValueNone) |
| 1006 validPrimitive = true; | 1006 validPrimitive = true; |
| 1007 else { | 1007 else { |
| 1008 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(m_val
ueList, propId); | 1008 RefPtr<CSSValueList> shadowValueList = parseShadow(m_valueList, prop
Id); |
| 1009 if (shadowValueList) { | 1009 if (shadowValueList) { |
| 1010 addProperty(propId, shadowValueList.release(), important); | 1010 addProperty(propId, shadowValueList.release(), important); |
| 1011 m_valueList->next(); | 1011 m_valueList->next(); |
| 1012 return true; | 1012 return true; |
| 1013 } | 1013 } |
| 1014 return false; | 1014 return false; |
| 1015 } | 1015 } |
| 1016 break; | 1016 break; |
| 1017 case CSSPropertyWebkitBoxReflect: | 1017 case CSSPropertyWebkitBoxReflect: |
| 1018 if (id == CSSValueNone) | 1018 if (id == CSSValueNone) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1031 case CSSPropertyWebkitBoxFlexGroup: | 1031 case CSSPropertyWebkitBoxFlexGroup: |
| 1032 validPrimitive = validUnit(value, FInteger | FNonNeg); | 1032 validPrimitive = validUnit(value, FInteger | FNonNeg); |
| 1033 break; | 1033 break; |
| 1034 case CSSPropertyWebkitBoxOrdinalGroup: | 1034 case CSSPropertyWebkitBoxOrdinalGroup: |
| 1035 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; | 1035 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; |
| 1036 break; | 1036 break; |
| 1037 case CSSPropertyWebkitFilter: | 1037 case CSSPropertyWebkitFilter: |
| 1038 if (id == CSSValueNone) | 1038 if (id == CSSValueNone) |
| 1039 validPrimitive = true; | 1039 validPrimitive = true; |
| 1040 else { | 1040 else { |
| 1041 RefPtrWillBeRawPtr<CSSValue> val = parseFilter(); | 1041 RefPtr<CSSValue> val = parseFilter(); |
| 1042 if (val) { | 1042 if (val) { |
| 1043 addProperty(propId, val, important); | 1043 addProperty(propId, val, important); |
| 1044 return true; | 1044 return true; |
| 1045 } | 1045 } |
| 1046 return false; | 1046 return false; |
| 1047 } | 1047 } |
| 1048 break; | 1048 break; |
| 1049 case CSSPropertyFlex: { | 1049 case CSSPropertyFlex: { |
| 1050 ShorthandScope scope(this, propId); | 1050 ShorthandScope scope(this, propId); |
| 1051 if (id == CSSValueNone) { | 1051 if (id == CSSValueNone) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1070 case CSSPropertyOrder: | 1070 case CSSPropertyOrder: |
| 1071 validPrimitive = validUnit(value, FInteger); | 1071 validPrimitive = validUnit(value, FInteger); |
| 1072 break; | 1072 break; |
| 1073 case CSSPropertyTransform: | 1073 case CSSPropertyTransform: |
| 1074 if (id == CSSValueNone) | 1074 if (id == CSSValueNone) |
| 1075 validPrimitive = true; | 1075 validPrimitive = true; |
| 1076 else | 1076 else |
| 1077 parsedValue = parseTransform(unresolvedProperty == CSSPropertyAliasW
ebkitTransform); | 1077 parsedValue = parseTransform(unresolvedProperty == CSSPropertyAliasW
ebkitTransform); |
| 1078 break; | 1078 break; |
| 1079 case CSSPropertyTransformOrigin: { | 1079 case CSSPropertyTransformOrigin: { |
| 1080 RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin(); | 1080 RefPtr<CSSValueList> list = parseTransformOrigin(); |
| 1081 if (!list) | 1081 if (!list) |
| 1082 return false; | 1082 return false; |
| 1083 // These values are added to match gecko serialization. | 1083 // These values are added to match gecko serialization. |
| 1084 if (list->length() == 1) | 1084 if (list->length() == 1) |
| 1085 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::UnitT
ype::Percentage)); | 1085 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::UnitT
ype::Percentage)); |
| 1086 if (list->length() == 2) | 1086 if (list->length() == 2) |
| 1087 list->append(cssValuePool().createValue(0, CSSPrimitiveValue::UnitTy
pe::Pixels)); | 1087 list->append(cssValuePool().createValue(0, CSSPrimitiveValue::UnitTy
pe::Pixels)); |
| 1088 addProperty(propId, list.release(), important); | 1088 addProperty(propId, list.release(), important); |
| 1089 return true; | 1089 return true; |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 case CSSPropertyTranslate: { | 1092 case CSSPropertyTranslate: { |
| 1093 // translate : [ <length> | <percentage> ] [[ <length> | <percentage> ]
<length>? ]? | 1093 // translate : [ <length> | <percentage> ] [[ <length> | <percentage> ]
<length>? ]? |
| 1094 // defaults to 0 on all axis, note that the last value CANNOT be a perce
ntage | 1094 // defaults to 0 on all axis, note that the last value CANNOT be a perce
ntage |
| 1095 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled(
)); | 1095 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled(
)); |
| 1096 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparat
ed(); | 1096 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 1097 if (!validUnit(value, FLength | FPercent)) | 1097 if (!validUnit(value, FLength | FPercent)) |
| 1098 return false; | 1098 return false; |
| 1099 | 1099 |
| 1100 list->append(createPrimitiveNumericValue(value)); | 1100 list->append(createPrimitiveNumericValue(value)); |
| 1101 value = m_valueList->next(); | 1101 value = m_valueList->next(); |
| 1102 | 1102 |
| 1103 if (value) { | 1103 if (value) { |
| 1104 if (!validUnit(value, FLength | FPercent)) | 1104 if (!validUnit(value, FLength | FPercent)) |
| 1105 return false; | 1105 return false; |
| 1106 | 1106 |
| 1107 list->append(createPrimitiveNumericValue(value)); | 1107 list->append(createPrimitiveNumericValue(value)); |
| 1108 value = m_valueList->next(); | 1108 value = m_valueList->next(); |
| 1109 | 1109 |
| 1110 if (value) { | 1110 if (value) { |
| 1111 if (!validUnit(value, FLength)) | 1111 if (!validUnit(value, FLength)) |
| 1112 return false; | 1112 return false; |
| 1113 | 1113 |
| 1114 list->append(createPrimitiveNumericValue(value)); | 1114 list->append(createPrimitiveNumericValue(value)); |
| 1115 value = m_valueList->next(); | 1115 value = m_valueList->next(); |
| 1116 } | 1116 } |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 parsedValue = list.release(); | 1119 parsedValue = list.release(); |
| 1120 break; | 1120 break; |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 case CSSPropertyRotate: { // rotate : <angle> <number>{3}? defaults to a 0 0
1 | 1123 case CSSPropertyRotate: { // rotate : <angle> <number>{3}? defaults to a 0 0
1 |
| 1124 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled(
)); | 1124 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled(
)); |
| 1125 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparat
ed(); | 1125 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 1126 | 1126 |
| 1127 if (!validUnit(value, FAngle)) | 1127 if (!validUnit(value, FAngle)) |
| 1128 return false; | 1128 return false; |
| 1129 list->append(createPrimitiveNumericValue(value)); | 1129 list->append(createPrimitiveNumericValue(value)); |
| 1130 value = m_valueList->next(); | 1130 value = m_valueList->next(); |
| 1131 | 1131 |
| 1132 if (!value) { | 1132 if (!value) { |
| 1133 parsedValue = list.release(); | 1133 parsedValue = list.release(); |
| 1134 break; | 1134 break; |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation | 1137 for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation |
| 1138 if (!value || !validUnit(value, FNumber)) | 1138 if (!value || !validUnit(value, FNumber)) |
| 1139 return false; | 1139 return false; |
| 1140 list->append(createPrimitiveNumericValue(value)); | 1140 list->append(createPrimitiveNumericValue(value)); |
| 1141 value = m_valueList->next(); | 1141 value = m_valueList->next(); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 parsedValue = list.release(); | 1144 parsedValue = list.release(); |
| 1145 break; | 1145 break; |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 case CSSPropertyScale: { // scale: <number>{1,3}, default scale for all axis
is 1 | 1148 case CSSPropertyScale: { // scale: <number>{1,3}, default scale for all axis
is 1 |
| 1149 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled(
)); | 1149 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled(
)); |
| 1150 RefPtrWillBeRawPtr<CSSValueList> scaleList = CSSValueList::createSpaceSe
parated(); | 1150 RefPtr<CSSValueList> scaleList = CSSValueList::createSpaceSeparated(); |
| 1151 | 1151 |
| 1152 for (unsigned i = 0; value && i < 3; i++) { // up to 3 dimensions of sca
le | 1152 for (unsigned i = 0; value && i < 3; i++) { // up to 3 dimensions of sca
le |
| 1153 if (!validUnit(value, FNumber)) | 1153 if (!validUnit(value, FNumber)) |
| 1154 return false; | 1154 return false; |
| 1155 scaleList->append(createPrimitiveNumericValue(value)); | 1155 scaleList->append(createPrimitiveNumericValue(value)); |
| 1156 value = m_valueList->next(); | 1156 value = m_valueList->next(); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 parsedValue = scaleList.release(); | 1159 parsedValue = scaleList.release(); |
| 1160 break; | 1160 break; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1181 } else if (validUnit(value, FLength) && (m_parsedCalculation || value->f
Value > 0)) { | 1181 } else if (validUnit(value, FLength) && (m_parsedCalculation || value->f
Value > 0)) { |
| 1182 validPrimitive = true; | 1182 validPrimitive = true; |
| 1183 } else if (unresolvedProperty == CSSPropertyAliasWebkitPerspective && va
lidUnit(value, FNumber) && value->fValue > 0) { | 1183 } else if (unresolvedProperty == CSSPropertyAliasWebkitPerspective && va
lidUnit(value, FNumber) && value->fValue > 0) { |
| 1184 value->setUnit(CSSPrimitiveValue::UnitType::Pixels); | 1184 value->setUnit(CSSPrimitiveValue::UnitType::Pixels); |
| 1185 validPrimitive = true; | 1185 validPrimitive = true; |
| 1186 } else { | 1186 } else { |
| 1187 return false; | 1187 return false; |
| 1188 } | 1188 } |
| 1189 break; | 1189 break; |
| 1190 case CSSPropertyPerspectiveOrigin: { | 1190 case CSSPropertyPerspectiveOrigin: { |
| 1191 RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin(); | 1191 RefPtr<CSSValueList> list = parseTransformOrigin(); |
| 1192 if (!list || list->length() == 3) | 1192 if (!list || list->length() == 3) |
| 1193 return false; | 1193 return false; |
| 1194 // This values are added to match gecko serialization. | 1194 // This values are added to match gecko serialization. |
| 1195 if (list->length() == 1) | 1195 if (list->length() == 1) |
| 1196 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::UnitT
ype::Percentage)); | 1196 list->append(cssValuePool().createValue(50, CSSPrimitiveValue::UnitT
ype::Percentage)); |
| 1197 addProperty(propId, list.release(), important); | 1197 addProperty(propId, list.release(), important); |
| 1198 return true; | 1198 return true; |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 case CSSPropertyMotion: | 1201 case CSSPropertyMotion: |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 ASSERT(!m_parsedCalculation); | 1563 ASSERT(!m_parsedCalculation); |
| 1564 if (parsedValue) { | 1564 if (parsedValue) { |
| 1565 if (!m_valueList->current() || inShorthand()) { | 1565 if (!m_valueList->current() || inShorthand()) { |
| 1566 addProperty(propId, parsedValue.release(), important); | 1566 addProperty(propId, parsedValue.release(), important); |
| 1567 return true; | 1567 return true; |
| 1568 } | 1568 } |
| 1569 } | 1569 } |
| 1570 return false; | 1570 return false; |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 void CSSPropertyParser::addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRef
PtrWillBeRawPtr<CSSValue> rval) | 1573 void CSSPropertyParser::addFillValue(RefPtr<CSSValue>& lval, PassRefPtr<CSSValue
> rval) |
| 1574 { | 1574 { |
| 1575 if (lval) { | 1575 if (lval) { |
| 1576 if (lval->isBaseValueList()) | 1576 if (lval->isBaseValueList()) |
| 1577 toCSSValueList(lval.get())->append(rval); | 1577 toCSSValueList(lval.get())->append(rval); |
| 1578 else { | 1578 else { |
| 1579 PassRefPtrWillBeRawPtr<CSSValue> oldlVal(lval.release()); | 1579 PassRefPtr<CSSValue> oldlVal(lval.release()); |
| 1580 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm
aSeparated(); | 1580 PassRefPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
| 1581 list->append(oldlVal); | 1581 list->append(oldlVal); |
| 1582 list->append(rval); | 1582 list->append(rval); |
| 1583 lval = list; | 1583 lval = list; |
| 1584 } | 1584 } |
| 1585 } | 1585 } |
| 1586 else | 1586 else |
| 1587 lval = rval; | 1587 lval = rval; |
| 1588 } | 1588 } |
| 1589 | 1589 |
| 1590 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtrWillBeRawPtr<
CSSValue>& cssValue) | 1590 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtr<CSSValue>& c
ssValue) |
| 1591 { | 1591 { |
| 1592 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi
ngBox | 1592 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi
ngBox |
| 1593 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW
ebkitText) { | 1593 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW
ebkitText) { |
| 1594 cssValue = cssValuePool().createIdentifierValue(parserValue->id); | 1594 cssValue = cssValuePool().createIdentifierValue(parserValue->id); |
| 1595 return true; | 1595 return true; |
| 1596 } | 1596 } |
| 1597 return false; | 1597 return false; |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 const int cMaxFillProperties = 9; | 1600 const int cMaxFillProperties = 9; |
| 1601 | 1601 |
| 1602 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper
tyID* properties, int numProperties, bool important) | 1602 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper
tyID* properties, int numProperties, bool important) |
| 1603 { | 1603 { |
| 1604 ASSERT(numProperties <= cMaxFillProperties); | 1604 ASSERT(numProperties <= cMaxFillProperties); |
| 1605 if (numProperties > cMaxFillProperties) | 1605 if (numProperties > cMaxFillProperties) |
| 1606 return false; | 1606 return false; |
| 1607 | 1607 |
| 1608 ShorthandScope scope(this, propId); | 1608 ShorthandScope scope(this, propId); |
| 1609 | 1609 |
| 1610 bool parsedProperty[cMaxFillProperties] = { false }; | 1610 bool parsedProperty[cMaxFillProperties] = { false }; |
| 1611 RefPtrWillBeRawPtr<CSSValue> values[cMaxFillProperties]; | 1611 RefPtr<CSSValue> values[cMaxFillProperties]; |
| 1612 #if ENABLE(OILPAN) | 1612 #if ENABLE(OILPAN) |
| 1613 // Zero initialize the array of raw pointers. | 1613 // Zero initialize the array of raw pointers. |
| 1614 memset(&values, 0, sizeof(values)); | 1614 memset(&values, 0, sizeof(values)); |
| 1615 #endif | 1615 #endif |
| 1616 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; | 1616 RefPtr<CSSValue> clipValue = nullptr; |
| 1617 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; | 1617 RefPtr<CSSValue> positionYValue = nullptr; |
| 1618 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; | 1618 RefPtr<CSSValue> repeatYValue = nullptr; |
| 1619 bool foundClip = false; | 1619 bool foundClip = false; |
| 1620 int i; | 1620 int i; |
| 1621 bool foundPositionCSSProperty = false; | 1621 bool foundPositionCSSProperty = false; |
| 1622 | 1622 |
| 1623 while (m_valueList->current()) { | 1623 while (m_valueList->current()) { |
| 1624 CSSParserValue* val = m_valueList->current(); | 1624 CSSParserValue* val = m_valueList->current(); |
| 1625 if (isComma(val)) { | 1625 if (isComma(val)) { |
| 1626 // We hit the end. Fill in all remaining values with the initial va
lue. | 1626 // We hit the end. Fill in all remaining values with the initial va
lue. |
| 1627 m_valueList->next(); | 1627 m_valueList->next(); |
| 1628 for (i = 0; i < numProperties; ++i) { | 1628 for (i = 0; i < numProperties; ++i) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1657 foundPositionCSSProperty = false; | 1657 foundPositionCSSProperty = false; |
| 1658 bool found = false; | 1658 bool found = false; |
| 1659 for (i = 0; !found && i < numProperties; ++i) { | 1659 for (i = 0; !found && i < numProperties; ++i) { |
| 1660 | 1660 |
| 1661 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou
ndSize && properties[i] != CSSPropertyWebkitMaskSize)) | 1661 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou
ndSize && properties[i] != CSSPropertyWebkitMaskSize)) |
| 1662 continue; | 1662 continue; |
| 1663 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro
undSize || properties[i] == CSSPropertyWebkitMaskSize)) | 1663 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro
undSize || properties[i] == CSSPropertyWebkitMaskSize)) |
| 1664 continue; | 1664 continue; |
| 1665 | 1665 |
| 1666 if (!parsedProperty[i]) { | 1666 if (!parsedProperty[i]) { |
| 1667 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; | 1667 RefPtr<CSSValue> val1 = nullptr; |
| 1668 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; | 1668 RefPtr<CSSValue> val2 = nullptr; |
| 1669 CSSPropertyID propId1, propId2; | 1669 CSSPropertyID propId1, propId2; |
| 1670 CSSParserValue* parserValue = m_valueList->current(); | 1670 CSSParserValue* parserValue = m_valueList->current(); |
| 1671 // parseFillProperty() may modify m_implicitShorthand, so we MUS
T reset it | 1671 // parseFillProperty() may modify m_implicitShorthand, so we MUS
T reset it |
| 1672 // before EACH return below. | 1672 // before EACH return below. |
| 1673 if (parserValue && parseFillProperty(properties[i], propId1, pro
pId2, val1, val2)) { | 1673 if (parserValue && parseFillProperty(properties[i], propId1, pro
pId2, val1, val2)) { |
| 1674 parsedProperty[i] = found = true; | 1674 parsedProperty[i] = found = true; |
| 1675 addFillValue(values[i], val1.release()); | 1675 addFillValue(values[i], val1.release()); |
| 1676 if (properties[i] == CSSPropertyBackgroundPosition || proper
ties[i] == CSSPropertyWebkitMaskPosition) | 1676 if (properties[i] == CSSPropertyBackgroundPosition || proper
ties[i] == CSSPropertyWebkitMaskPosition) |
| 1677 addFillValue(positionYValue, val2.release()); | 1677 addFillValue(positionYValue, val2.release()); |
| 1678 if (properties[i] == CSSPropertyBackgroundRepeat || properti
es[i] == CSSPropertyWebkitMaskRepeat) | 1678 if (properties[i] == CSSPropertyBackgroundRepeat || properti
es[i] == CSSPropertyWebkitMaskRepeat) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 | 1774 |
| 1775 // The list of properties in the shorthand should be the same | 1775 // The list of properties in the shorthand should be the same |
| 1776 // length as the list with animation name in last position, even though they
are | 1776 // length as the list with animation name in last position, even though they
are |
| 1777 // in a different order. | 1777 // in a different order. |
| 1778 ASSERT(numProperties == animationProperties.length()); | 1778 ASSERT(numProperties == animationProperties.length()); |
| 1779 ASSERT(numProperties == animationShorthand().length()); | 1779 ASSERT(numProperties == animationShorthand().length()); |
| 1780 | 1780 |
| 1781 ShorthandScope scope(this, CSSPropertyAnimation); | 1781 ShorthandScope scope(this, CSSPropertyAnimation); |
| 1782 | 1782 |
| 1783 bool parsedProperty[numProperties] = { false }; | 1783 bool parsedProperty[numProperties] = { false }; |
| 1784 RefPtrWillBeRawPtr<CSSValueList> values[numProperties]; | 1784 RefPtr<CSSValueList> values[numProperties]; |
| 1785 for (size_t i = 0; i < numProperties; ++i) | 1785 for (size_t i = 0; i < numProperties; ++i) |
| 1786 values[i] = CSSValueList::createCommaSeparated(); | 1786 values[i] = CSSValueList::createCommaSeparated(); |
| 1787 | 1787 |
| 1788 while (m_valueList->current()) { | 1788 while (m_valueList->current()) { |
| 1789 if (consumeComma(m_valueList)) { | 1789 if (consumeComma(m_valueList)) { |
| 1790 // We hit the end. Fill in all remaining values with the initial val
ue. | 1790 // We hit the end. Fill in all remaining values with the initial val
ue. |
| 1791 for (size_t i = 0; i < numProperties; ++i) { | 1791 for (size_t i = 0; i < numProperties; ++i) { |
| 1792 if (!parsedProperty[i]) | 1792 if (!parsedProperty[i]) |
| 1793 values[i]->append(cssValuePool().createImplicitInitialValue(
)); | 1793 values[i]->append(cssValuePool().createImplicitInitialValue(
)); |
| 1794 parsedProperty[i] = false; | 1794 parsedProperty[i] = false; |
| 1795 } | 1795 } |
| 1796 if (!m_valueList->current()) | 1796 if (!m_valueList->current()) |
| 1797 break; | 1797 break; |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 bool found = false; | 1800 bool found = false; |
| 1801 for (size_t i = 0; i < numProperties; ++i) { | 1801 for (size_t i = 0; i < numProperties; ++i) { |
| 1802 if (parsedProperty[i]) | 1802 if (parsedProperty[i]) |
| 1803 continue; | 1803 continue; |
| 1804 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(animat
ionProperties.properties()[i], useLegacyparsing)) { | 1804 if (RefPtr<CSSValue> val = parseAnimationProperty(animationPropertie
s.properties()[i], useLegacyparsing)) { |
| 1805 parsedProperty[i] = found = true; | 1805 parsedProperty[i] = found = true; |
| 1806 values[i]->append(val.release()); | 1806 values[i]->append(val.release()); |
| 1807 break; | 1807 break; |
| 1808 } | 1808 } |
| 1809 } | 1809 } |
| 1810 | 1810 |
| 1811 // if we didn't find at least one match, this is an | 1811 // if we didn't find at least one match, this is an |
| 1812 // invalid shorthand and we have to ignore it | 1812 // invalid shorthand and we have to ignore it |
| 1813 if (!found) | 1813 if (!found) |
| 1814 return false; | 1814 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1827 | 1827 |
| 1828 bool CSSPropertyParser::parseTransitionShorthand(bool important) | 1828 bool CSSPropertyParser::parseTransitionShorthand(bool important) |
| 1829 { | 1829 { |
| 1830 const unsigned numProperties = 4; | 1830 const unsigned numProperties = 4; |
| 1831 const StylePropertyShorthand& shorthand = transitionShorthandForParsing(); | 1831 const StylePropertyShorthand& shorthand = transitionShorthandForParsing(); |
| 1832 ASSERT(numProperties == shorthand.length()); | 1832 ASSERT(numProperties == shorthand.length()); |
| 1833 | 1833 |
| 1834 ShorthandScope scope(this, CSSPropertyTransition); | 1834 ShorthandScope scope(this, CSSPropertyTransition); |
| 1835 | 1835 |
| 1836 bool parsedProperty[numProperties] = { false }; | 1836 bool parsedProperty[numProperties] = { false }; |
| 1837 RefPtrWillBeRawPtr<CSSValueList> values[numProperties]; | 1837 RefPtr<CSSValueList> values[numProperties]; |
| 1838 for (size_t i = 0; i < numProperties; ++i) | 1838 for (size_t i = 0; i < numProperties; ++i) |
| 1839 values[i] = CSSValueList::createCommaSeparated(); | 1839 values[i] = CSSValueList::createCommaSeparated(); |
| 1840 | 1840 |
| 1841 while (m_valueList->current()) { | 1841 while (m_valueList->current()) { |
| 1842 if (consumeComma(m_valueList)) { | 1842 if (consumeComma(m_valueList)) { |
| 1843 // We hit the end. Fill in all remaining values with the initial val
ue. | 1843 // We hit the end. Fill in all remaining values with the initial val
ue. |
| 1844 for (size_t i = 0; i < numProperties; ++i) { | 1844 for (size_t i = 0; i < numProperties; ++i) { |
| 1845 if (!parsedProperty[i]) | 1845 if (!parsedProperty[i]) |
| 1846 values[i]->append(cssValuePool().createImplicitInitialValue(
)); | 1846 values[i]->append(cssValuePool().createImplicitInitialValue(
)); |
| 1847 parsedProperty[i] = false; | 1847 parsedProperty[i] = false; |
| 1848 } | 1848 } |
| 1849 if (!m_valueList->current()) | 1849 if (!m_valueList->current()) |
| 1850 break; | 1850 break; |
| 1851 } | 1851 } |
| 1852 | 1852 |
| 1853 bool found = false; | 1853 bool found = false; |
| 1854 for (size_t i = 0; i < numProperties; ++i) { | 1854 for (size_t i = 0; i < numProperties; ++i) { |
| 1855 if (parsedProperty[i]) | 1855 if (parsedProperty[i]) |
| 1856 continue; | 1856 continue; |
| 1857 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(shorth
and.properties()[i], false)) { | 1857 if (RefPtr<CSSValue> val = parseAnimationProperty(shorthand.properti
es()[i], false)) { |
| 1858 parsedProperty[i] = found = true; | 1858 parsedProperty[i] = found = true; |
| 1859 values[i]->append(val.release()); | 1859 values[i]->append(val.release()); |
| 1860 break; | 1860 break; |
| 1861 } | 1861 } |
| 1862 } | 1862 } |
| 1863 | 1863 |
| 1864 // if we didn't find at least one match, this is an | 1864 // if we didn't find at least one match, this is an |
| 1865 // invalid shorthand and we have to ignore it | 1865 // invalid shorthand and we have to ignore it |
| 1866 if (!found) | 1866 if (!found) |
| 1867 return false; | 1867 return false; |
| 1868 } | 1868 } |
| 1869 | 1869 |
| 1870 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); | 1870 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); |
| 1871 if (!isValidTransitionPropertyList(values[3].get())) | 1871 if (!isValidTransitionPropertyList(values[3].get())) |
| 1872 return false; | 1872 return false; |
| 1873 | 1873 |
| 1874 // Fill in any remaining properties with the initial value and add | 1874 // Fill in any remaining properties with the initial value and add |
| 1875 for (size_t i = 0; i < numProperties; ++i) { | 1875 for (size_t i = 0; i < numProperties; ++i) { |
| 1876 if (!parsedProperty[i]) | 1876 if (!parsedProperty[i]) |
| 1877 values[i]->append(cssValuePool().createImplicitInitialValue()); | 1877 values[i]->append(cssValuePool().createImplicitInitialValue()); |
| 1878 addProperty(shorthand.properties()[i], values[i].release(), important); | 1878 addProperty(shorthand.properties()[i], values[i].release(), important); |
| 1879 } | 1879 } |
| 1880 | 1880 |
| 1881 return true; | 1881 return true; |
| 1882 } | 1882 } |
| 1883 | 1883 |
| 1884 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() | 1884 PassRefPtr<CSSValue> CSSPropertyParser::parseColumnWidth() |
| 1885 { | 1885 { |
| 1886 CSSParserValue* value = m_valueList->current(); | 1886 CSSParserValue* value = m_valueList->current(); |
| 1887 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | 1887 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in |
| 1888 // the 'columns' shorthand property. | 1888 // the 'columns' shorthand property. |
| 1889 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { | 1889 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { |
| 1890 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | 1890 RefPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value); |
| 1891 m_valueList->next(); | 1891 m_valueList->next(); |
| 1892 return parsedValue; | 1892 return parsedValue; |
| 1893 } | 1893 } |
| 1894 return nullptr; | 1894 return nullptr; |
| 1895 } | 1895 } |
| 1896 | 1896 |
| 1897 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() | 1897 PassRefPtr<CSSValue> CSSPropertyParser::parseColumnCount() |
| 1898 { | 1898 { |
| 1899 CSSParserValue* value = m_valueList->current(); | 1899 CSSParserValue* value = m_valueList->current(); |
| 1900 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { | 1900 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { |
| 1901 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | 1901 RefPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value); |
| 1902 m_valueList->next(); | 1902 m_valueList->next(); |
| 1903 return parsedValue; | 1903 return parsedValue; |
| 1904 } | 1904 } |
| 1905 return nullptr; | 1905 return nullptr; |
| 1906 } | 1906 } |
| 1907 | 1907 |
| 1908 bool CSSPropertyParser::parseColumnsShorthand(bool important) | 1908 bool CSSPropertyParser::parseColumnsShorthand(bool important) |
| 1909 { | 1909 { |
| 1910 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; | 1910 RefPtr<CSSValue> columnWidth = nullptr; |
| 1911 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; | 1911 RefPtr<CSSValue> columnCount = nullptr; |
| 1912 bool hasPendingExplicitAuto = false; | 1912 bool hasPendingExplicitAuto = false; |
| 1913 | 1913 |
| 1914 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | 1914 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { |
| 1915 if (propertiesParsed >= 2) | 1915 if (propertiesParsed >= 2) |
| 1916 return false; // Too many values for this shorthand. Invalid declara
tion. | 1916 return false; // Too many values for this shorthand. Invalid declara
tion. |
| 1917 if (!propertiesParsed && value->id == CSSValueAuto) { | 1917 if (!propertiesParsed && value->id == CSSValueAuto) { |
| 1918 // 'auto' is a valid value for any of the two longhands, and at this
point we | 1918 // 'auto' is a valid value for any of the two longhands, and at this
point we |
| 1919 // don't know which one(s) it is meant for. We need to see if there
are other | 1919 // don't know which one(s) it is meant for. We need to see if there
are other |
| 1920 // values first. | 1920 // values first. |
| 1921 m_valueList->next(); | 1921 m_valueList->next(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 break; | 2058 break; |
| 2059 } | 2059 } |
| 2060 default: { | 2060 default: { |
| 2061 return false; | 2061 return false; |
| 2062 } | 2062 } |
| 2063 } | 2063 } |
| 2064 | 2064 |
| 2065 return true; | 2065 return true; |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() | 2068 PassRefPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() |
| 2069 { | 2069 { |
| 2070 CSSParserValue* value = m_valueList->current(); | 2070 CSSParserValue* value = m_valueList->current(); |
| 2071 | 2071 |
| 2072 if (value->id == CSSValueNone) { | 2072 if (value->id == CSSValueNone) { |
| 2073 m_valueList->next(); | 2073 m_valueList->next(); |
| 2074 return cssValuePool().createIdentifierValue(CSSValueNone); | 2074 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 2075 } | 2075 } |
| 2076 | 2076 |
| 2077 if (value->m_unit == CSSParserValue::Function && value->function->id == CSSV
alueRepeat) { | 2077 if (value->m_unit == CSSParserValue::Function && value->function->id == CSSV
alueRepeat) { |
| 2078 // The spec defines the following grammar: repeat( <length>) | 2078 // The spec defines the following grammar: repeat( <length>) |
| 2079 CSSParserValueList* arguments = value->function->args.get(); | 2079 CSSParserValueList* arguments = value->function->args.get(); |
| 2080 if (!arguments || arguments->size() != 1) | 2080 if (!arguments || arguments->size() != 1) |
| 2081 return nullptr; | 2081 return nullptr; |
| 2082 | 2082 |
| 2083 CSSParserValue* repeatValue = arguments->valueAt(0); | 2083 CSSParserValue* repeatValue = arguments->valueAt(0); |
| 2084 if (validUnit(repeatValue, FNonNeg | FLength | FPercent) && (m_parsedCal
culation || repeatValue->fValue > 0)) { | 2084 if (validUnit(repeatValue, FNonNeg | FLength | FPercent) && (m_parsedCal
culation || repeatValue->fValue > 0)) { |
| 2085 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::crea
te(CSSValueRepeat); | 2085 RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueR
epeat); |
| 2086 result->append(parseValidPrimitive(repeatValue->id, repeatValue)); | 2086 result->append(parseValidPrimitive(repeatValue->id, repeatValue)); |
| 2087 m_valueList->next(); | 2087 m_valueList->next(); |
| 2088 return result.release(); | 2088 return result.release(); |
| 2089 } | 2089 } |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 return nullptr; | 2092 return nullptr; |
| 2093 } | 2093 } |
| 2094 | 2094 |
| 2095 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | 2095 PassRefPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() |
| 2096 { | 2096 { |
| 2097 if (m_valueList->current()->id == CSSValueNone) { | 2097 if (m_valueList->current()->id == CSSValueNone) { |
| 2098 m_valueList->next(); | 2098 m_valueList->next(); |
| 2099 return cssValuePool().createIdentifierValue(CSSValueNone); | 2099 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 2100 } | 2100 } |
| 2101 | 2101 |
| 2102 return parsePositionList(m_valueList); | 2102 return parsePositionList(m_valueList); |
| 2103 } | 2103 } |
| 2104 | 2104 |
| 2105 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() | 2105 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() |
| 2106 { | 2106 { |
| 2107 CSSParserValue* value = m_valueList->current(); | 2107 CSSParserValue* value = m_valueList->current(); |
| 2108 m_valueList->next(); | 2108 m_valueList->next(); |
| 2109 ASSERT(value); | 2109 ASSERT(value); |
| 2110 | 2110 |
| 2111 if (value->id == CSSValueAuto) | 2111 if (value->id == CSSValueAuto) |
| 2112 return cssValuePool().createIdentifierValue(value->id); | 2112 return cssValuePool().createIdentifierValue(value->id); |
| 2113 if (value->m_unit == CSSParserValue::Identifier) | 2113 if (value->m_unit == CSSParserValue::Identifier) |
| 2114 return createPrimitiveCustomIdentValue(value); | 2114 return createPrimitiveCustomIdentValue(value); |
| 2115 return nullptr; | 2115 return nullptr; |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] | 2118 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] |
| 2119 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseSize() | 2119 PassRefPtr<CSSValueList> CSSPropertyParser::parseSize() |
| 2120 { | 2120 { |
| 2121 CSSParserValue* value = m_valueList->current(); | 2121 CSSParserValue* value = m_valueList->current(); |
| 2122 ASSERT(value); | 2122 ASSERT(value); |
| 2123 | 2123 |
| 2124 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 2124 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); |
| 2125 | 2125 |
| 2126 // First parameter. | 2126 // First parameter. |
| 2127 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); | 2127 SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value,
None); |
| 2128 if (paramType == None) | 2128 if (paramType == None) |
| 2129 return nullptr; | 2129 return nullptr; |
| 2130 value = m_valueList->next(); | 2130 value = m_valueList->next(); |
| 2131 | 2131 |
| 2132 // Second parameter, if any. | 2132 // Second parameter, if any. |
| 2133 if (value) { | 2133 if (value) { |
| 2134 paramType = parseSizeParameter(parsedValues.get(), value, paramType); | 2134 paramType = parseSizeParameter(parsedValues.get(), value, paramType); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 parsedValues->append(createPrimitiveNumericValue(value)); | 2175 parsedValues->append(createPrimitiveNumericValue(value)); |
| 2176 return Length; | 2176 return Length; |
| 2177 } | 2177 } |
| 2178 return None; | 2178 return None; |
| 2179 default: | 2179 default: |
| 2180 return None; | 2180 return None; |
| 2181 } | 2181 } |
| 2182 } | 2182 } |
| 2183 | 2183 |
| 2184 // [ <string> <string> ]+ | none, but none is handled in parseValue | 2184 // [ <string> <string> ]+ | none, but none is handled in parseValue |
| 2185 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() | 2185 PassRefPtr<CSSValue> CSSPropertyParser::parseQuotes() |
| 2186 { | 2186 { |
| 2187 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 2187 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); |
| 2188 while (CSSParserValue* val = m_valueList->current()) { | 2188 while (CSSParserValue* val = m_valueList->current()) { |
| 2189 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2189 RefPtr<CSSValue> parsedValue = nullptr; |
| 2190 if (val->unit() != CSSPrimitiveValue::UnitType::String) | 2190 if (val->unit() != CSSPrimitiveValue::UnitType::String) |
| 2191 return nullptr; | 2191 return nullptr; |
| 2192 parsedValue = createPrimitiveStringValue(val); | 2192 parsedValue = createPrimitiveStringValue(val); |
| 2193 values->append(parsedValue.release()); | 2193 values->append(parsedValue.release()); |
| 2194 m_valueList->next(); | 2194 m_valueList->next(); |
| 2195 } | 2195 } |
| 2196 if (values->length() && values->length() % 2 == 0) | 2196 if (values->length() && values->length() % 2 == 0) |
| 2197 return values.release(); | 2197 return values.release(); |
| 2198 return nullptr; | 2198 return nullptr; |
| 2199 } | 2199 } |
| 2200 | 2200 |
| 2201 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit | 2201 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit |
| 2202 // in CSS 2.1 this got somewhat reduced: | 2202 // in CSS 2.1 this got somewhat reduced: |
| 2203 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 2203 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
| 2204 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 2204 PassRefPtr<CSSValueList> CSSPropertyParser::parseContent() |
| 2205 { | 2205 { |
| 2206 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 2206 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); |
| 2207 | 2207 |
| 2208 while (CSSParserValue* val = m_valueList->current()) { | 2208 while (CSSParserValue* val = m_valueList->current()) { |
| 2209 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2209 RefPtr<CSSValue> parsedValue = nullptr; |
| 2210 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { | 2210 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 2211 // url | 2211 // url |
| 2212 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); | 2212 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); |
| 2213 } else if (val->m_unit == CSSParserValue::Function) { | 2213 } else if (val->m_unit == CSSParserValue::Function) { |
| 2214 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) | 2214 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) |
| 2215 CSSParserValueList* args = val->function->args.get(); | 2215 CSSParserValueList* args = val->function->args.get(); |
| 2216 if (!args) | 2216 if (!args) |
| 2217 return nullptr; | 2217 return nullptr; |
| 2218 if (val->function->id == CSSValueAttr) { | 2218 if (val->function->id == CSSValueAttr) { |
| 2219 parsedValue = parseAttr(args); | 2219 parsedValue = parseAttr(args); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2244 } | 2244 } |
| 2245 if (!parsedValue) | 2245 if (!parsedValue) |
| 2246 return nullptr; | 2246 return nullptr; |
| 2247 values->append(parsedValue.release()); | 2247 values->append(parsedValue.release()); |
| 2248 m_valueList->next(); | 2248 m_valueList->next(); |
| 2249 } | 2249 } |
| 2250 | 2250 |
| 2251 return values.release(); | 2251 return values.release(); |
| 2252 } | 2252 } |
| 2253 | 2253 |
| 2254 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList
* args) | 2254 PassRefPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList* args) |
| 2255 { | 2255 { |
| 2256 if (args->size() != 1) | 2256 if (args->size() != 1) |
| 2257 return nullptr; | 2257 return nullptr; |
| 2258 | 2258 |
| 2259 CSSParserValue* a = args->current(); | 2259 CSSParserValue* a = args->current(); |
| 2260 | 2260 |
| 2261 if (a->m_unit != CSSParserValue::Identifier) | 2261 if (a->m_unit != CSSParserValue::Identifier) |
| 2262 return nullptr; | 2262 return nullptr; |
| 2263 | 2263 |
| 2264 String attrName = a->string; | 2264 String attrName = a->string; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 // '-internal-inactive-list-box-selection' | 2315 // '-internal-inactive-list-box-selection' |
| 2316 // '-internal-inactive-list-box-selection-text' | 2316 // '-internal-inactive-list-box-selection-text' |
| 2317 // '-webkit-focus-ring-color' | 2317 // '-webkit-focus-ring-color' |
| 2318 // '-webkit-text' | 2318 // '-webkit-text' |
| 2319 // | 2319 // |
| 2320 return (id >= CSSValueAqua && id <= CSSValueWebkitText) | 2320 return (id >= CSSValueAqua && id <= CSSValueWebkitText) |
| 2321 || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen) | 2321 || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen) |
| 2322 || id == CSSValueMenu; | 2322 || id == CSSValueMenu; |
| 2323 } | 2323 } |
| 2324 | 2324 |
| 2325 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(const CS
SParserValue* value, bool acceptQuirkyColors) | 2325 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(const CSSParserValue
* value, bool acceptQuirkyColors) |
| 2326 { | 2326 { |
| 2327 CSSValueID id = value->id; | 2327 CSSValueID id = value->id; |
| 2328 if (isColorKeyword(id)) { | 2328 if (isColorKeyword(id)) { |
| 2329 if (!isValueAllowedInMode(id, m_context.mode())) | 2329 if (!isValueAllowedInMode(id, m_context.mode())) |
| 2330 return nullptr; | 2330 return nullptr; |
| 2331 return cssValuePool().createIdentifierValue(id); | 2331 return cssValuePool().createIdentifierValue(id); |
| 2332 } | 2332 } |
| 2333 RGBA32 c = Color::transparent; | 2333 RGBA32 c = Color::transparent; |
| 2334 if (!parseColorFromValue(value, c, acceptQuirkyColors)) | 2334 if (!parseColorFromValue(value, c, acceptQuirkyColors)) |
| 2335 return nullptr; | 2335 return nullptr; |
| 2336 return cssValuePool().createColorValue(c); | 2336 return cssValuePool().createColorValue(c); |
| 2337 } | 2337 } |
| 2338 | 2338 |
| 2339 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) | 2339 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtr<CSS
Value>& value) |
| 2340 { | 2340 { |
| 2341 if (valueList->current()->id == CSSValueNone) { | 2341 if (valueList->current()->id == CSSValueNone) { |
| 2342 value = cssValuePool().createIdentifierValue(CSSValueNone); | 2342 value = cssValuePool().createIdentifierValue(CSSValueNone); |
| 2343 return true; | 2343 return true; |
| 2344 } | 2344 } |
| 2345 if (valueList->current()->unit() == CSSPrimitiveValue::UnitType::URI) { | 2345 if (valueList->current()->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 2346 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); | 2346 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); |
| 2347 return true; | 2347 return true; |
| 2348 } | 2348 } |
| 2349 | 2349 |
| 2350 if (isGeneratedImageValue(valueList->current())) | 2350 if (isGeneratedImageValue(valueList->current())) |
| 2351 return parseGeneratedImage(valueList, value); | 2351 return parseGeneratedImage(valueList, value); |
| 2352 | 2352 |
| 2353 if (valueList->current()->m_unit == CSSParserValue::Function && valueList->c
urrent()->function->id == CSSValueWebkitImageSet) { | 2353 if (valueList->current()->m_unit == CSSParserValue::Function && valueList->c
urrent()->function->id == CSSValueWebkitImageSet) { |
| 2354 value = parseImageSet(m_valueList); | 2354 value = parseImageSet(m_valueList); |
| 2355 if (value) | 2355 if (value) |
| 2356 return true; | 2356 return true; |
| 2357 } | 2357 } |
| 2358 | 2358 |
| 2359 return false; | 2359 return false; |
| 2360 } | 2360 } |
| 2361 | 2361 |
| 2362 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser
ValueList* valueList) | 2362 PassRefPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParserValueList* v
alueList) |
| 2363 { | 2363 { |
| 2364 int id = valueList->current()->id; | 2364 int id = valueList->current()->id; |
| 2365 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { | 2365 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { |
| 2366 int percent = 0; | 2366 int percent = 0; |
| 2367 if (id == CSSValueRight) | 2367 if (id == CSSValueRight) |
| 2368 percent = 100; | 2368 percent = 100; |
| 2369 else if (id == CSSValueCenter) | 2369 else if (id == CSSValueCenter) |
| 2370 percent = 50; | 2370 percent = 50; |
| 2371 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); | 2371 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); |
| 2372 } | 2372 } |
| 2373 if (validUnit(valueList->current(), FPercent | FLength)) | 2373 if (validUnit(valueList->current(), FPercent | FLength)) |
| 2374 return createPrimitiveNumericValue(valueList->current()); | 2374 return createPrimitiveNumericValue(valueList->current()); |
| 2375 return nullptr; | 2375 return nullptr; |
| 2376 } | 2376 } |
| 2377 | 2377 |
| 2378 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser
ValueList* valueList) | 2378 PassRefPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParserValueList* v
alueList) |
| 2379 { | 2379 { |
| 2380 int id = valueList->current()->id; | 2380 int id = valueList->current()->id; |
| 2381 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { | 2381 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { |
| 2382 int percent = 0; | 2382 int percent = 0; |
| 2383 if (id == CSSValueBottom) | 2383 if (id == CSSValueBottom) |
| 2384 percent = 100; | 2384 percent = 100; |
| 2385 else if (id == CSSValueCenter) | 2385 else if (id == CSSValueCenter) |
| 2386 percent = 50; | 2386 percent = 50; |
| 2387 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); | 2387 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); |
| 2388 } | 2388 } |
| 2389 if (validUnit(valueList->current(), FPercent | FLength)) | 2389 if (validUnit(valueList->current(), FPercent | FLength)) |
| 2390 return createPrimitiveNumericValue(valueList->current()); | 2390 return createPrimitiveNumericValue(valueList->current()); |
| 2391 return nullptr; | 2391 return nullptr; |
| 2392 } | 2392 } |
| 2393 | 2393 |
| 2394 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseFillPositionCo
mponent(CSSParserValueList* valueList, unsigned& cumulativeFlags, FillPositionFl
ag& individualFlag, FillPositionParsingMode parsingMode, Units unitless) | 2394 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseFillPositionComponent(CSSP
arserValueList* valueList, unsigned& cumulativeFlags, FillPositionFlag& individu
alFlag, FillPositionParsingMode parsingMode, Units unitless) |
| 2395 { | 2395 { |
| 2396 CSSValueID id = valueList->current()->id; | 2396 CSSValueID id = valueList->current()->id; |
| 2397 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { | 2397 if (id == CSSValueLeft || id == CSSValueTop || id == CSSValueRight || id ==
CSSValueBottom || id == CSSValueCenter) { |
| 2398 int percent = 0; | 2398 int percent = 0; |
| 2399 if (id == CSSValueLeft || id == CSSValueRight) { | 2399 if (id == CSSValueLeft || id == CSSValueRight) { |
| 2400 if (cumulativeFlags & XFillPosition) | 2400 if (cumulativeFlags & XFillPosition) |
| 2401 return nullptr; | 2401 return nullptr; |
| 2402 cumulativeFlags |= XFillPosition; | 2402 cumulativeFlags |= XFillPosition; |
| 2403 individualFlag = XFillPosition; | 2403 individualFlag = XFillPosition; |
| 2404 if (id == CSSValueRight) | 2404 if (id == CSSValueRight) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 return true; | 2449 return true; |
| 2450 | 2450 |
| 2451 return false; | 2451 return false; |
| 2452 } | 2452 } |
| 2453 | 2453 |
| 2454 static bool isFillPositionKeyword(CSSValueID value) | 2454 static bool isFillPositionKeyword(CSSValueID value) |
| 2455 { | 2455 { |
| 2456 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot
tom || value == CSSValueRight || value == CSSValueCenter; | 2456 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot
tom || value == CSSValueRight || value == CSSValueCenter; |
| 2457 } | 2457 } |
| 2458 | 2458 |
| 2459 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass
RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue2) | 2459 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList,
RefPtr<CSSValue>& value1, RefPtr<CSSValue>& value2, PassRefPtr<CSSPrimitiveValue
> parsedValue1, PassRefPtr<CSSPrimitiveValue> parsedValue2) |
| 2460 { | 2460 { |
| 2461 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce
ntage> | <length> ] | 2461 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce
ntage> | <length> ] |
| 2462 // In the case of 4 values <position> requires the second value to be a leng
th or a percentage. | 2462 // In the case of 4 values <position> requires the second value to be a leng
th or a percentage. |
| 2463 if (isFillPositionKeyword(parsedValue2->getValueID())) | 2463 if (isFillPositionKeyword(parsedValue2->getValueID())) |
| 2464 return; | 2464 return; |
| 2465 | 2465 |
| 2466 unsigned cumulativeFlags = 0; | 2466 unsigned cumulativeFlags = 0; |
| 2467 FillPositionFlag value3Flag = InvalidFillPosition; | 2467 FillPositionFlag value3Flag = InvalidFillPosition; |
| 2468 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va
lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); | 2468 RefPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(valueList, cum
ulativeFlags, value3Flag, ResolveValuesAsKeyword); |
| 2469 if (!value3) | 2469 if (!value3) |
| 2470 return; | 2470 return; |
| 2471 | 2471 |
| 2472 CSSValueID ident1 = parsedValue1->getValueID(); | 2472 CSSValueID ident1 = parsedValue1->getValueID(); |
| 2473 CSSValueID ident3 = value3->getValueID(); | 2473 CSSValueID ident3 = value3->getValueID(); |
| 2474 | 2474 |
| 2475 if (ident1 == CSSValueCenter) | 2475 if (ident1 == CSSValueCenter) |
| 2476 return; | 2476 return; |
| 2477 | 2477 |
| 2478 if (!isFillPositionKeyword(ident3) || ident3 == CSSValueCenter) | 2478 if (!isFillPositionKeyword(ident3) || ident3 == CSSValueCenter) |
| 2479 return; | 2479 return; |
| 2480 | 2480 |
| 2481 // We need to check if the values are not conflicting, e.g. they are not on
the same edge. It is | 2481 // We need to check if the values are not conflicting, e.g. they are not on
the same edge. It is |
| 2482 // needed as the second call to parseFillPositionComponent was on purpose no
t checking it. In the | 2482 // needed as the second call to parseFillPositionComponent was on purpose no
t checking it. In the |
| 2483 // case of two values top 20px is invalid but in the case of 4 values it bec
omes valid. | 2483 // case of two values top 20px is invalid but in the case of 4 values it bec
omes valid. |
| 2484 if (isValueConflictingWithCurrentEdge(ident1, ident3)) | 2484 if (isValueConflictingWithCurrentEdge(ident1, ident3)) |
| 2485 return; | 2485 return; |
| 2486 | 2486 |
| 2487 valueList->next(); | 2487 valueList->next(); |
| 2488 | 2488 |
| 2489 cumulativeFlags = 0; | 2489 cumulativeFlags = 0; |
| 2490 FillPositionFlag value4Flag = InvalidFillPosition; | 2490 FillPositionFlag value4Flag = InvalidFillPosition; |
| 2491 RefPtrWillBeRawPtr<CSSPrimitiveValue> value4 = parseFillPositionComponent(va
lueList, cumulativeFlags, value4Flag, ResolveValuesAsKeyword); | 2491 RefPtr<CSSPrimitiveValue> value4 = parseFillPositionComponent(valueList, cum
ulativeFlags, value4Flag, ResolveValuesAsKeyword); |
| 2492 if (!value4) | 2492 if (!value4) |
| 2493 return; | 2493 return; |
| 2494 | 2494 |
| 2495 // 4th value must be a length or a percentage. | 2495 // 4th value must be a length or a percentage. |
| 2496 if (isFillPositionKeyword(value4->getValueID())) | 2496 if (isFillPositionKeyword(value4->getValueID())) |
| 2497 return; | 2497 return; |
| 2498 | 2498 |
| 2499 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); | 2499 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); |
| 2500 value2 = createPrimitiveValuePair(value3, value4); | 2500 value2 = createPrimitiveValuePair(value3, value4); |
| 2501 | 2501 |
| 2502 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) | 2502 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) |
| 2503 value1.swap(value2); | 2503 value1.swap(value2); |
| 2504 | 2504 |
| 2505 valueList->next(); | 2505 valueList->next(); |
| 2506 } | 2506 } |
| 2507 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass
RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue2) | 2507 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList,
RefPtr<CSSValue>& value1, RefPtr<CSSValue>& value2, PassRefPtr<CSSPrimitiveValue
> parsedValue1, PassRefPtr<CSSPrimitiveValue> parsedValue2) |
| 2508 { | 2508 { |
| 2509 unsigned cumulativeFlags = 0; | 2509 unsigned cumulativeFlags = 0; |
| 2510 FillPositionFlag value3Flag = InvalidFillPosition; | 2510 FillPositionFlag value3Flag = InvalidFillPosition; |
| 2511 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va
lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); | 2511 RefPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(valueList, cum
ulativeFlags, value3Flag, ResolveValuesAsKeyword); |
| 2512 | 2512 |
| 2513 // value3 is not an expected value, we return. | 2513 // value3 is not an expected value, we return. |
| 2514 if (!value3) | 2514 if (!value3) |
| 2515 return; | 2515 return; |
| 2516 | 2516 |
| 2517 valueList->next(); | 2517 valueList->next(); |
| 2518 | 2518 |
| 2519 bool swapNeeded = false; | 2519 bool swapNeeded = false; |
| 2520 CSSValueID ident1 = parsedValue1->getValueID(); | 2520 CSSValueID ident1 = parsedValue1->getValueID(); |
| 2521 CSSValueID ident2 = parsedValue2->getValueID(); | 2521 CSSValueID ident2 = parsedValue2->getValueID(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2545 return; | 2545 return; |
| 2546 | 2546 |
| 2547 secondPositionKeyword = CSSValueTop; | 2547 secondPositionKeyword = CSSValueTop; |
| 2548 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) { | 2548 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) { |
| 2549 secondPositionKeyword = CSSValueLeft; | 2549 secondPositionKeyword = CSSValueLeft; |
| 2550 swapNeeded = true; | 2550 swapNeeded = true; |
| 2551 } | 2551 } |
| 2552 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); | 2552 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); |
| 2553 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s
econdPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitTyp
e::Percentage)); | 2553 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s
econdPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitTyp
e::Percentage)); |
| 2554 } else { | 2554 } else { |
| 2555 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPositionValue = nullptr; | 2555 RefPtr<CSSPrimitiveValue> firstPositionValue = nullptr; |
| 2556 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPositionValue = nullptr; | 2556 RefPtr<CSSPrimitiveValue> secondPositionValue = nullptr; |
| 2557 | 2557 |
| 2558 if (isFillPositionKeyword(ident2)) { | 2558 if (isFillPositionKeyword(ident2)) { |
| 2559 // To match CSS grammar, we should only accept: [ center | left | ri
ght | bottom | top ] [ left | right | top | bottom ] [ <percentage> | <length> ]
. | 2559 // To match CSS grammar, we should only accept: [ center | left | ri
ght | bottom | top ] [ left | right | top | bottom ] [ <percentage> | <length> ]
. |
| 2560 ASSERT(ident2 != CSSValueCenter); | 2560 ASSERT(ident2 != CSSValueCenter); |
| 2561 | 2561 |
| 2562 if (isFillPositionKeyword(ident3)) | 2562 if (isFillPositionKeyword(ident3)) |
| 2563 return; | 2563 return; |
| 2564 | 2564 |
| 2565 secondPositionValue = value3; | 2565 secondPositionValue = value3; |
| 2566 secondPositionKeyword = ident2; | 2566 secondPositionKeyword = ident2; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2593 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); | 2593 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); |
| 2594 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); | 2594 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); |
| 2595 #endif | 2595 #endif |
| 2596 } | 2596 } |
| 2597 | 2597 |
| 2598 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) | 2598 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) |
| 2599 { | 2599 { |
| 2600 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); | 2600 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); |
| 2601 } | 2601 } |
| 2602 | 2602 |
| 2603 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl
ess) | 2603 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtr<
CSSValue>& value1, RefPtr<CSSValue>& value2, Units unitless) |
| 2604 { | 2604 { |
| 2605 unsigned numberOfValues = 0; | 2605 unsigned numberOfValues = 0; |
| 2606 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { | 2606 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { |
| 2607 CSSParserValue* current = valueList->valueAt(i); | 2607 CSSParserValue* current = valueList->valueAt(i); |
| 2608 if (!current || isComma(current) || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) | 2608 if (!current || isComma(current) || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) |
| 2609 break; | 2609 break; |
| 2610 } | 2610 } |
| 2611 | 2611 |
| 2612 if (numberOfValues > 4) | 2612 if (numberOfValues > 4) |
| 2613 return; | 2613 return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2640 // a valid start for <position>. | 2640 // a valid start for <position>. |
| 2641 cumulativeFlags = AmbiguousFillPosition; | 2641 cumulativeFlags = AmbiguousFillPosition; |
| 2642 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag,
ResolveValuesAsKeyword); | 2642 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag,
ResolveValuesAsKeyword); |
| 2643 if (value2) | 2643 if (value2) |
| 2644 valueList->next(); | 2644 valueList->next(); |
| 2645 else { | 2645 else { |
| 2646 value1.clear(); | 2646 value1.clear(); |
| 2647 return; | 2647 return; |
| 2648 } | 2648 } |
| 2649 | 2649 |
| 2650 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val
ue1.get()); | 2650 RefPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(value1.get()); |
| 2651 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val
ue2.get()); | 2651 RefPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(value2.get()); |
| 2652 | 2652 |
| 2653 value1.clear(); | 2653 value1.clear(); |
| 2654 value2.clear(); | 2654 value2.clear(); |
| 2655 | 2655 |
| 2656 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. | 2656 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. |
| 2657 if (parsedValue2->getValueID() == CSSValueCenter) | 2657 if (parsedValue2->getValueID() == CSSValueCenter) |
| 2658 return; | 2658 return; |
| 2659 | 2659 |
| 2660 if (numberOfValues == 3) | 2660 if (numberOfValues == 3) |
| 2661 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 2661 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); |
| 2662 else | 2662 else |
| 2663 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 2663 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); |
| 2664 } | 2664 } |
| 2665 | 2665 |
| 2666 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Unit
s unitless) | 2666 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
RefPtr<CSSValue>& value1, RefPtr<CSSValue>& value2, Units unitless) |
| 2667 { | 2667 { |
| 2668 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. | 2668 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. |
| 2669 unsigned cumulativeFlags = 0; | 2669 unsigned cumulativeFlags = 0; |
| 2670 FillPositionFlag value1Flag = InvalidFillPosition; | 2670 FillPositionFlag value1Flag = InvalidFillPosition; |
| 2671 FillPositionFlag value2Flag = InvalidFillPosition; | 2671 FillPositionFlag value2Flag = InvalidFillPosition; |
| 2672 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); | 2672 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); |
| 2673 if (!value1) | 2673 if (!value1) |
| 2674 return; | 2674 return; |
| 2675 | 2675 |
| 2676 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we | 2676 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2699 // is simply 50%. This is our default. | 2699 // is simply 50%. This is our default. |
| 2700 // For keywords, the keyword was either an x-keyword (left/right), a y-k
eyword (top/bottom), or an ambiguous keyword (center). | 2700 // For keywords, the keyword was either an x-keyword (left/right), a y-k
eyword (top/bottom), or an ambiguous keyword (center). |
| 2701 // For left/right/center, the default of 50% in the y is still correct. | 2701 // For left/right/center, the default of 50% in the y is still correct. |
| 2702 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Per
centage); | 2702 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Per
centage); |
| 2703 } | 2703 } |
| 2704 | 2704 |
| 2705 if (value1Flag == YFillPosition || value2Flag == XFillPosition) | 2705 if (value1Flag == YFillPosition || value2Flag == XFillPosition) |
| 2706 value1.swap(value2); | 2706 value1.swap(value2); |
| 2707 } | 2707 } |
| 2708 | 2708 |
| 2709 void CSSPropertyParser::parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>& value1, Re
fPtrWillBeRawPtr<CSSValue>& value2) | 2709 void CSSPropertyParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValu
e>& value2) |
| 2710 { | 2710 { |
| 2711 CSSValueID id = m_valueList->current()->id; | 2711 CSSValueID id = m_valueList->current()->id; |
| 2712 if (id == CSSValueRepeatX) { | 2712 if (id == CSSValueRepeatX) { |
| 2713 m_implicitShorthand = true; | 2713 m_implicitShorthand = true; |
| 2714 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); | 2714 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); |
| 2715 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); | 2715 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); |
| 2716 m_valueList->next(); | 2716 m_valueList->next(); |
| 2717 return; | 2717 return; |
| 2718 } | 2718 } |
| 2719 if (id == CSSValueRepeatY) { | 2719 if (id == CSSValueRepeatY) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2740 m_valueList->next(); | 2740 m_valueList->next(); |
| 2741 return; | 2741 return; |
| 2742 } | 2742 } |
| 2743 } | 2743 } |
| 2744 | 2744 |
| 2745 // If only one value was specified, value2 is the same as value1. | 2745 // If only one value was specified, value2 is the same as value1. |
| 2746 m_implicitShorthand = true; | 2746 m_implicitShorthand = true; |
| 2747 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get
())->getValueID()); | 2747 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get
())->getValueID()); |
| 2748 } | 2748 } |
| 2749 | 2749 |
| 2750 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillSize(CSSPropertyID
unresolvedProperty) | 2750 PassRefPtr<CSSValue> CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedPr
operty) |
| 2751 { | 2751 { |
| 2752 CSSParserValue* value = m_valueList->current(); | 2752 CSSParserValue* value = m_valueList->current(); |
| 2753 m_valueList->next(); | 2753 m_valueList->next(); |
| 2754 | 2754 |
| 2755 if (value->id == CSSValueContain || value->id == CSSValueCover) | 2755 if (value->id == CSSValueContain || value->id == CSSValueCover) |
| 2756 return cssValuePool().createIdentifierValue(value->id); | 2756 return cssValuePool().createIdentifierValue(value->id); |
| 2757 | 2757 |
| 2758 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr; | 2758 RefPtr<CSSPrimitiveValue> parsedValue1 = nullptr; |
| 2759 | 2759 |
| 2760 if (value->id == CSSValueAuto) | 2760 if (value->id == CSSValueAuto) |
| 2761 parsedValue1 = cssValuePool().createIdentifierValue(CSSValueAuto); | 2761 parsedValue1 = cssValuePool().createIdentifierValue(CSSValueAuto); |
| 2762 else { | 2762 else { |
| 2763 if (!validUnit(value, FLength | FPercent)) | 2763 if (!validUnit(value, FLength | FPercent)) |
| 2764 return nullptr; | 2764 return nullptr; |
| 2765 parsedValue1 = createPrimitiveNumericValue(value); | 2765 parsedValue1 = createPrimitiveNumericValue(value); |
| 2766 } | 2766 } |
| 2767 | 2767 |
| 2768 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = nullptr; | 2768 RefPtr<CSSPrimitiveValue> parsedValue2 = nullptr; |
| 2769 value = m_valueList->current(); | 2769 value = m_valueList->current(); |
| 2770 if (value) { | 2770 if (value) { |
| 2771 if (value->id == CSSValueAuto) { | 2771 if (value->id == CSSValueAuto) { |
| 2772 // `auto' is the default | 2772 // `auto' is the default |
| 2773 m_valueList->next(); | 2773 m_valueList->next(); |
| 2774 } else if (validUnit(value, FLength | FPercent)) { | 2774 } else if (validUnit(value, FLength | FPercent)) { |
| 2775 parsedValue2 = createPrimitiveNumericValue(value); | 2775 parsedValue2 = createPrimitiveNumericValue(value); |
| 2776 m_valueList->next(); | 2776 m_valueList->next(); |
| 2777 } | 2777 } |
| 2778 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { | 2778 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { |
| 2779 // For backwards compatibility we set the second value to the first if i
t is omitted. | 2779 // For backwards compatibility we set the second value to the first if i
t is omitted. |
| 2780 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match | 2780 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match |
| 2781 // the real property. | 2781 // the real property. |
| 2782 parsedValue2 = parsedValue1; | 2782 parsedValue2 = parsedValue1; |
| 2783 } | 2783 } |
| 2784 | 2784 |
| 2785 if (!parsedValue2) | 2785 if (!parsedValue2) |
| 2786 return parsedValue1; | 2786 return parsedValue1; |
| 2787 | 2787 |
| 2788 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
(), Pair::KeepIdenticalValues); | 2788 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
(), Pair::KeepIdenticalValues); |
| 2789 } | 2789 } |
| 2790 | 2790 |
| 2791 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, | 2791 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, |
| 2792 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa
lue2) | 2792 RefPtr<CSSValue>& retValue1, RefPtr<CSSValue>& retValue2) |
| 2793 { | 2793 { |
| 2794 // We initially store the first value in value/value2, and only create | 2794 // We initially store the first value in value/value2, and only create |
| 2795 // CSSValueLists if we have more values. | 2795 // CSSValueLists if we have more values. |
| 2796 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | 2796 RefPtr<CSSValueList> values = nullptr; |
| 2797 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; | 2797 RefPtr<CSSValueList> values2 = nullptr; |
| 2798 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 2798 RefPtr<CSSValue> value = nullptr; |
| 2799 RefPtrWillBeRawPtr<CSSValue> value2 = nullptr; | 2799 RefPtr<CSSValue> value2 = nullptr; |
| 2800 | 2800 |
| 2801 retValue1 = retValue2 = nullptr; | 2801 retValue1 = retValue2 = nullptr; |
| 2802 propId1 = resolveCSSPropertyID(propId); | 2802 propId1 = resolveCSSPropertyID(propId); |
| 2803 propId2 = propId1; | 2803 propId2 = propId1; |
| 2804 if (propId == CSSPropertyBackgroundPosition) { | 2804 if (propId == CSSPropertyBackgroundPosition) { |
| 2805 propId1 = CSSPropertyBackgroundPositionX; | 2805 propId1 = CSSPropertyBackgroundPositionX; |
| 2806 propId2 = CSSPropertyBackgroundPositionY; | 2806 propId2 = CSSPropertyBackgroundPositionY; |
| 2807 } else if (propId == CSSPropertyWebkitMaskPosition) { | 2807 } else if (propId == CSSPropertyWebkitMaskPosition) { |
| 2808 propId1 = CSSPropertyWebkitMaskPositionX; | 2808 propId1 = CSSPropertyWebkitMaskPositionX; |
| 2809 propId2 = CSSPropertyWebkitMaskPositionY; | 2809 propId2 = CSSPropertyWebkitMaskPositionY; |
| 2810 } else if (propId == CSSPropertyBackgroundRepeat) { | 2810 } else if (propId == CSSPropertyBackgroundRepeat) { |
| 2811 propId1 = CSSPropertyBackgroundRepeatX; | 2811 propId1 = CSSPropertyBackgroundRepeatX; |
| 2812 propId2 = CSSPropertyBackgroundRepeatY; | 2812 propId2 = CSSPropertyBackgroundRepeatY; |
| 2813 } else if (propId == CSSPropertyWebkitMaskRepeat) { | 2813 } else if (propId == CSSPropertyWebkitMaskRepeat) { |
| 2814 propId1 = CSSPropertyWebkitMaskRepeatX; | 2814 propId1 = CSSPropertyWebkitMaskRepeatX; |
| 2815 propId2 = CSSPropertyWebkitMaskRepeatY; | 2815 propId2 = CSSPropertyWebkitMaskRepeatY; |
| 2816 } | 2816 } |
| 2817 | 2817 |
| 2818 while (true) { | 2818 while (true) { |
| 2819 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; | 2819 RefPtr<CSSValue> currValue = nullptr; |
| 2820 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; | 2820 RefPtr<CSSValue> currValue2 = nullptr; |
| 2821 | 2821 |
| 2822 Units unitless = FUnknown; | 2822 Units unitless = FUnknown; |
| 2823 CSSParserValue* val = m_valueList->current(); | 2823 CSSParserValue* val = m_valueList->current(); |
| 2824 ASSERT(val); | 2824 ASSERT(val); |
| 2825 | 2825 |
| 2826 switch (propId) { | 2826 switch (propId) { |
| 2827 case CSSPropertyBackgroundColor: | 2827 case CSSPropertyBackgroundColor: |
| 2828 currValue = parseColor(val); | 2828 currValue = parseColor(val); |
| 2829 if (currValue) | 2829 if (currValue) |
| 2830 m_valueList->next(); | 2830 m_valueList->next(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2972 } | 2972 } |
| 2973 } else { | 2973 } else { |
| 2974 ASSERT(value); | 2974 ASSERT(value); |
| 2975 retValue1 = value.release(); | 2975 retValue1 = value.release(); |
| 2976 retValue2 = value2.release(); | 2976 retValue2 = value2.release(); |
| 2977 } | 2977 } |
| 2978 | 2978 |
| 2979 return true; | 2979 return true; |
| 2980 } | 2980 } |
| 2981 | 2981 |
| 2982 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() | 2982 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() |
| 2983 { | 2983 { |
| 2984 CSSParserValue* value = m_valueList->current(); | 2984 CSSParserValue* value = m_valueList->current(); |
| 2985 if (validUnit(value, FTime)) | 2985 if (validUnit(value, FTime)) |
| 2986 return createPrimitiveNumericValue(value); | 2986 return createPrimitiveNumericValue(value); |
| 2987 return nullptr; | 2987 return nullptr; |
| 2988 } | 2988 } |
| 2989 | 2989 |
| 2990 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() | 2990 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() |
| 2991 { | 2991 { |
| 2992 CSSParserValue* value = m_valueList->current(); | 2992 CSSParserValue* value = m_valueList->current(); |
| 2993 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) | 2993 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) |
| 2994 return cssValuePool().createIdentifierValue(value->id); | 2994 return cssValuePool().createIdentifierValue(value->id); |
| 2995 return nullptr; | 2995 return nullptr; |
| 2996 } | 2996 } |
| 2997 | 2997 |
| 2998 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() | 2998 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() |
| 2999 { | 2999 { |
| 3000 CSSParserValue* value = m_valueList->current(); | 3000 CSSParserValue* value = m_valueList->current(); |
| 3001 if (validUnit(value, FTime | FNonNeg)) | 3001 if (validUnit(value, FTime | FNonNeg)) |
| 3002 return createPrimitiveNumericValue(value); | 3002 return createPrimitiveNumericValue(value); |
| 3003 return nullptr; | 3003 return nullptr; |
| 3004 } | 3004 } |
| 3005 | 3005 |
| 3006 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() | 3006 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() |
| 3007 { | 3007 { |
| 3008 CSSParserValue* value = m_valueList->current(); | 3008 CSSParserValue* value = m_valueList->current(); |
| 3009 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) | 3009 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) |
| 3010 return cssValuePool().createIdentifierValue(value->id); | 3010 return cssValuePool().createIdentifierValue(value->id); |
| 3011 return nullptr; | 3011 return nullptr; |
| 3012 } | 3012 } |
| 3013 | 3013 |
| 3014 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount
() | 3014 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount() |
| 3015 { | 3015 { |
| 3016 CSSParserValue* value = m_valueList->current(); | 3016 CSSParserValue* value = m_valueList->current(); |
| 3017 if (value->id == CSSValueInfinite) | 3017 if (value->id == CSSValueInfinite) |
| 3018 return cssValuePool().createIdentifierValue(value->id); | 3018 return cssValuePool().createIdentifierValue(value->id); |
| 3019 if (validUnit(value, FNumber | FNonNeg)) | 3019 if (validUnit(value, FNumber | FNonNeg)) |
| 3020 return createPrimitiveNumericValue(value); | 3020 return createPrimitiveNumericValue(value); |
| 3021 return nullptr; | 3021 return nullptr; |
| 3022 } | 3022 } |
| 3023 | 3023 |
| 3024 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo
wQuotedName) | 3024 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allowQuotedName) |
| 3025 { | 3025 { |
| 3026 CSSParserValue* value = m_valueList->current(); | 3026 CSSParserValue* value = m_valueList->current(); |
| 3027 | 3027 |
| 3028 if (value->id == CSSValueNone) | 3028 if (value->id == CSSValueNone) |
| 3029 return cssValuePool().createIdentifierValue(CSSValueNone); | 3029 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 3030 | 3030 |
| 3031 if (value->m_unit == CSSParserValue::Identifier) | 3031 if (value->m_unit == CSSParserValue::Identifier) |
| 3032 return createPrimitiveCustomIdentValue(value); | 3032 return createPrimitiveCustomIdentValue(value); |
| 3033 | 3033 |
| 3034 if (allowQuotedName && value->unit() == CSSPrimitiveValue::UnitType::String)
{ | 3034 if (allowQuotedName && value->unit() == CSSPrimitiveValue::UnitType::String)
{ |
| 3035 // Legacy support for strings in prefixed animations | 3035 // Legacy support for strings in prefixed animations |
| 3036 if (m_context.useCounter()) | 3036 if (m_context.useCounter()) |
| 3037 m_context.useCounter()->count(UseCounter::QuotedAnimationName); | 3037 m_context.useCounter()->count(UseCounter::QuotedAnimationName); |
| 3038 if (equalIgnoringCase(value->string, "none")) | 3038 if (equalIgnoringCase(value->string, "none")) |
| 3039 return cssValuePool().createIdentifierValue(CSSValueNone); | 3039 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 3040 return createPrimitiveCustomIdentValue(value); | 3040 return createPrimitiveCustomIdentValue(value); |
| 3041 } | 3041 } |
| 3042 | 3042 |
| 3043 return nullptr; | 3043 return nullptr; |
| 3044 } | 3044 } |
| 3045 | 3045 |
| 3046 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() | 3046 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() |
| 3047 { | 3047 { |
| 3048 CSSParserValue* value = m_valueList->current(); | 3048 CSSParserValue* value = m_valueList->current(); |
| 3049 if (value->id == CSSValueRunning || value->id == CSSValuePaused) | 3049 if (value->id == CSSValueRunning || value->id == CSSValuePaused) |
| 3050 return cssValuePool().createIdentifierValue(value->id); | 3050 return cssValuePool().createIdentifierValue(value->id); |
| 3051 return nullptr; | 3051 return nullptr; |
| 3052 } | 3052 } |
| 3053 | 3053 |
| 3054 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() | 3054 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() |
| 3055 { | 3055 { |
| 3056 CSSParserValue* value = m_valueList->current(); | 3056 CSSParserValue* value = m_valueList->current(); |
| 3057 if (value->m_unit != CSSParserValue::Identifier) | 3057 if (value->m_unit != CSSParserValue::Identifier) |
| 3058 return nullptr; | 3058 return nullptr; |
| 3059 CSSPropertyID property = unresolvedCSSPropertyID(value->string); | 3059 CSSPropertyID property = unresolvedCSSPropertyID(value->string); |
| 3060 if (property) { | 3060 if (property) { |
| 3061 ASSERT(CSSPropertyMetadata::isEnabledProperty(property)); | 3061 ASSERT(CSSPropertyMetadata::isEnabledProperty(property)); |
| 3062 return cssValuePool().createIdentifierValue(property); | 3062 return cssValuePool().createIdentifierValue(property); |
| 3063 } | 3063 } |
| 3064 if (value->id == CSSValueNone) | 3064 if (value->id == CSSValueNone) |
| 3065 return cssValuePool().createIdentifierValue(CSSValueNone); | 3065 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 3066 if (value->id == CSSValueInitial || value->id == CSSValueInherit) | 3066 if (value->id == CSSValueInitial || value->id == CSSValueInherit) |
| 3067 return nullptr; | 3067 return nullptr; |
| 3068 return createPrimitiveCustomIdentValue(value); | 3068 return createPrimitiveCustomIdentValue(value); |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 bool CSSPropertyParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*&
args, double& result) | 3071 bool CSSPropertyParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*&
args, double& result) |
| 3072 { | 3072 { |
| 3073 CSSParserValue* v = args->current(); | 3073 CSSParserValue* v = args->current(); |
| 3074 if (!validUnit(v, FNumber)) | 3074 if (!validUnit(v, FNumber)) |
| 3075 return false; | 3075 return false; |
| 3076 result = v->fValue; | 3076 result = v->fValue; |
| 3077 v = args->next(); | 3077 v = args->next(); |
| 3078 if (!v) | 3078 if (!v) |
| 3079 // The last number in the function has no comma after it, so we're done. | 3079 // The last number in the function has no comma after it, so we're done. |
| 3080 return true; | 3080 return true; |
| 3081 return consumeComma(args); | 3081 return consumeComma(args); |
| 3082 } | 3082 } |
| 3083 | 3083 |
| 3084 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
() | 3084 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction() |
| 3085 { | 3085 { |
| 3086 CSSParserValue* value = m_valueList->current(); | 3086 CSSParserValue* value = m_valueList->current(); |
| 3087 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut | 3087 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut |
| 3088 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd | 3088 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd |
| 3089 || value->id == CSSValueStepMiddle) | 3089 || value->id == CSSValueStepMiddle) |
| 3090 return cssValuePool().createIdentifierValue(value->id); | 3090 return cssValuePool().createIdentifierValue(value->id); |
| 3091 | 3091 |
| 3092 // We must be a function. | 3092 // We must be a function. |
| 3093 if (value->m_unit != CSSParserValue::Function) | 3093 if (value->m_unit != CSSParserValue::Function) |
| 3094 return nullptr; | 3094 return nullptr; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 return nullptr; | 3155 return nullptr; |
| 3156 if (!parseCubicBezierTimingFunctionValue(args, y2)) | 3156 if (!parseCubicBezierTimingFunctionValue(args, y2)) |
| 3157 return nullptr; | 3157 return nullptr; |
| 3158 | 3158 |
| 3159 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); | 3159 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); |
| 3160 } | 3160 } |
| 3161 | 3161 |
| 3162 return nullptr; | 3162 return nullptr; |
| 3163 } | 3163 } |
| 3164 | 3164 |
| 3165 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPr
opertyID propId, bool useLegacyParsing) | 3165 PassRefPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPropertyID pro
pId, bool useLegacyParsing) |
| 3166 { | 3166 { |
| 3167 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 3167 RefPtr<CSSValue> value = nullptr; |
| 3168 switch (propId) { | 3168 switch (propId) { |
| 3169 case CSSPropertyAnimationDelay: | 3169 case CSSPropertyAnimationDelay: |
| 3170 case CSSPropertyTransitionDelay: | 3170 case CSSPropertyTransitionDelay: |
| 3171 value = parseAnimationDelay(); | 3171 value = parseAnimationDelay(); |
| 3172 break; | 3172 break; |
| 3173 case CSSPropertyAnimationDirection: | 3173 case CSSPropertyAnimationDirection: |
| 3174 value = parseAnimationDirection(); | 3174 value = parseAnimationDirection(); |
| 3175 break; | 3175 break; |
| 3176 case CSSPropertyAnimationDuration: | 3176 case CSSPropertyAnimationDuration: |
| 3177 case CSSPropertyTransitionDuration: | 3177 case CSSPropertyTransitionDuration: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3199 default: | 3199 default: |
| 3200 ASSERT_NOT_REACHED(); | 3200 ASSERT_NOT_REACHED(); |
| 3201 return nullptr; | 3201 return nullptr; |
| 3202 } | 3202 } |
| 3203 | 3203 |
| 3204 if (value) | 3204 if (value) |
| 3205 m_valueList->next(); | 3205 m_valueList->next(); |
| 3206 return value.release(); | 3206 return value.release(); |
| 3207 } | 3207 } |
| 3208 | 3208 |
| 3209 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi
st(CSSPropertyID propId, bool useLegacyParsing) | 3209 PassRefPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyList(CSSProper
tyID propId, bool useLegacyParsing) |
| 3210 { | 3210 { |
| 3211 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 3211 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
| 3212 while (true) { | 3212 while (true) { |
| 3213 RefPtrWillBeRawPtr<CSSValue> value = parseAnimationProperty(propId, useL
egacyParsing); | 3213 RefPtr<CSSValue> value = parseAnimationProperty(propId, useLegacyParsing
); |
| 3214 if (!value) | 3214 if (!value) |
| 3215 return nullptr; | 3215 return nullptr; |
| 3216 list->append(value.release()); | 3216 list->append(value.release()); |
| 3217 if (!m_valueList->current()) | 3217 if (!m_valueList->current()) |
| 3218 break; | 3218 break; |
| 3219 if (!consumeComma(m_valueList) || !m_valueList->current()) | 3219 if (!consumeComma(m_valueList) || !m_valueList->current()) |
| 3220 return nullptr; | 3220 return nullptr; |
| 3221 } | 3221 } |
| 3222 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis
t(list.get())) | 3222 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis
t(list.get())) |
| 3223 return nullptr; | 3223 return nullptr; |
| 3224 ASSERT(list->length()); | 3224 ASSERT(list->length()); |
| 3225 return list.release(); | 3225 return list.release(); |
| 3226 } | 3226 } |
| 3227 | 3227 |
| 3228 static inline bool isCSSWideKeyword(const CSSParserValue& value) | 3228 static inline bool isCSSWideKeyword(const CSSParserValue& value) |
| 3229 { | 3229 { |
| 3230 return value.id == CSSValueInitial || value.id == CSSValueInherit || value.i
d == CSSValueUnset || value.id == CSSValueDefault; | 3230 return value.id == CSSValueInitial || value.id == CSSValueInherit || value.i
d == CSSValueUnset || value.id == CSSValueDefault; |
| 3231 } | 3231 } |
| 3232 | 3232 |
| 3233 static inline bool isValidCustomIdentForGridPositions(const CSSParserValue& valu
e) | 3233 static inline bool isValidCustomIdentForGridPositions(const CSSParserValue& valu
e) |
| 3234 { | 3234 { |
| 3235 // FIXME: we need a more general solution for <custom-ident> in all properti
es. | 3235 // FIXME: we need a more general solution for <custom-ident> in all properti
es. |
| 3236 return value.m_unit == CSSParserValue::Identifier && value.id != CSSValueSpa
n && value.id != CSSValueAuto && !isCSSWideKeyword(value); | 3236 return value.m_unit == CSSParserValue::Identifier && value.id != CSSValueSpa
n && value.id != CSSValueAuto && !isCSSWideKeyword(value); |
| 3237 } | 3237 } |
| 3238 | 3238 |
| 3239 // The function parses [ <integer> || <custom-ident> ] in <grid-line> (which can
be stand alone or with 'span'). | 3239 // The function parses [ <integer> || <custom-ident> ] in <grid-line> (which can
be stand alone or with 'span'). |
| 3240 bool CSSPropertyParser::parseIntegerOrCustomIdentFromGridPosition(RefPtrWillBeRa
wPtr<CSSPrimitiveValue>& numericValue, RefPtrWillBeRawPtr<CSSPrimitiveValue>& gr
idLineName) | 3240 bool CSSPropertyParser::parseIntegerOrCustomIdentFromGridPosition(RefPtr<CSSPrim
itiveValue>& numericValue, RefPtr<CSSPrimitiveValue>& gridLineName) |
| 3241 { | 3241 { |
| 3242 CSSParserValue* value = m_valueList->current(); | 3242 CSSParserValue* value = m_valueList->current(); |
| 3243 if (validUnit(value, FInteger) && value->fValue) { | 3243 if (validUnit(value, FInteger) && value->fValue) { |
| 3244 numericValue = createPrimitiveNumericValue(value); | 3244 numericValue = createPrimitiveNumericValue(value); |
| 3245 value = m_valueList->next(); | 3245 value = m_valueList->next(); |
| 3246 if (value && isValidCustomIdentForGridPositions(*value)) { | 3246 if (value && isValidCustomIdentForGridPositions(*value)) { |
| 3247 gridLineName = createPrimitiveCustomIdentValue(m_valueList->current(
)); | 3247 gridLineName = createPrimitiveCustomIdentValue(m_valueList->current(
)); |
| 3248 m_valueList->next(); | 3248 m_valueList->next(); |
| 3249 } | 3249 } |
| 3250 return true; | 3250 return true; |
| 3251 } | 3251 } |
| 3252 | 3252 |
| 3253 if (isValidCustomIdentForGridPositions(*value)) { | 3253 if (isValidCustomIdentForGridPositions(*value)) { |
| 3254 gridLineName = createPrimitiveCustomIdentValue(m_valueList->current()); | 3254 gridLineName = createPrimitiveCustomIdentValue(m_valueList->current()); |
| 3255 value = m_valueList->next(); | 3255 value = m_valueList->next(); |
| 3256 if (value && validUnit(value, FInteger) && value->fValue) { | 3256 if (value && validUnit(value, FInteger) && value->fValue) { |
| 3257 numericValue = createPrimitiveNumericValue(value); | 3257 numericValue = createPrimitiveNumericValue(value); |
| 3258 m_valueList->next(); | 3258 m_valueList->next(); |
| 3259 } | 3259 } |
| 3260 return true; | 3260 return true; |
| 3261 } | 3261 } |
| 3262 | 3262 |
| 3263 return false; | 3263 return false; |
| 3264 } | 3264 } |
| 3265 | 3265 |
| 3266 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition() | 3266 PassRefPtr<CSSValue> CSSPropertyParser::parseGridPosition() |
| 3267 { | 3267 { |
| 3268 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3268 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3269 | 3269 |
| 3270 CSSParserValue* value = m_valueList->current(); | 3270 CSSParserValue* value = m_valueList->current(); |
| 3271 if (value->id == CSSValueAuto) { | 3271 if (value->id == CSSValueAuto) { |
| 3272 m_valueList->next(); | 3272 m_valueList->next(); |
| 3273 return cssValuePool().createIdentifierValue(CSSValueAuto); | 3273 return cssValuePool().createIdentifierValue(CSSValueAuto); |
| 3274 } | 3274 } |
| 3275 | 3275 |
| 3276 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr; | 3276 RefPtr<CSSPrimitiveValue> numericValue = nullptr; |
| 3277 RefPtrWillBeRawPtr<CSSPrimitiveValue> gridLineName = nullptr; | 3277 RefPtr<CSSPrimitiveValue> gridLineName = nullptr; |
| 3278 bool hasSeenSpanKeyword = false; | 3278 bool hasSeenSpanKeyword = false; |
| 3279 | 3279 |
| 3280 if (parseIntegerOrCustomIdentFromGridPosition(numericValue, gridLineName)) { | 3280 if (parseIntegerOrCustomIdentFromGridPosition(numericValue, gridLineName)) { |
| 3281 value = m_valueList->current(); | 3281 value = m_valueList->current(); |
| 3282 if (value && value->id == CSSValueSpan) { | 3282 if (value && value->id == CSSValueSpan) { |
| 3283 hasSeenSpanKeyword = true; | 3283 hasSeenSpanKeyword = true; |
| 3284 m_valueList->next(); | 3284 m_valueList->next(); |
| 3285 } | 3285 } |
| 3286 } else if (value->id == CSSValueSpan) { | 3286 } else if (value->id == CSSValueSpan) { |
| 3287 hasSeenSpanKeyword = true; | 3287 hasSeenSpanKeyword = true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3301 return nullptr; | 3301 return nullptr; |
| 3302 | 3302 |
| 3303 // Negative numbers are not allowed for span (but are for <integer>). | 3303 // Negative numbers are not allowed for span (but are for <integer>). |
| 3304 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) | 3304 if (hasSeenSpanKeyword && numericValue && numericValue->getIntValue() < 0) |
| 3305 return nullptr; | 3305 return nullptr; |
| 3306 | 3306 |
| 3307 // For the <custom-ident> case. | 3307 // For the <custom-ident> case. |
| 3308 if (gridLineName && !numericValue && !hasSeenSpanKeyword) | 3308 if (gridLineName && !numericValue && !hasSeenSpanKeyword) |
| 3309 return cssValuePool().createValue(gridLineName->getStringValue(), CSSPri
mitiveValue::UnitType::CustomIdentifier); | 3309 return cssValuePool().createValue(gridLineName->getStringValue(), CSSPri
mitiveValue::UnitType::CustomIdentifier); |
| 3310 | 3310 |
| 3311 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 3311 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); |
| 3312 if (hasSeenSpanKeyword) | 3312 if (hasSeenSpanKeyword) |
| 3313 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); | 3313 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); |
| 3314 if (numericValue) | 3314 if (numericValue) |
| 3315 values->append(numericValue.release()); | 3315 values->append(numericValue.release()); |
| 3316 if (gridLineName) | 3316 if (gridLineName) |
| 3317 values->append(gridLineName.release()); | 3317 values->append(gridLineName.release()); |
| 3318 ASSERT(values->length()); | 3318 ASSERT(values->length()); |
| 3319 return values.release(); | 3319 return values.release(); |
| 3320 } | 3320 } |
| 3321 | 3321 |
| 3322 static PassRefPtrWillBeRawPtr<CSSValue> gridMissingGridPositionValue(CSSValue* v
alue) | 3322 static PassRefPtr<CSSValue> gridMissingGridPositionValue(CSSValue* value) |
| 3323 { | 3323 { |
| 3324 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isCustomIdent()
) | 3324 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isCustomIdent()
) |
| 3325 return value; | 3325 return value; |
| 3326 | 3326 |
| 3327 return cssValuePool().createIdentifierValue(CSSValueAuto); | 3327 return cssValuePool().createIdentifierValue(CSSValueAuto); |
| 3328 } | 3328 } |
| 3329 | 3329 |
| 3330 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId
, bool important) | 3330 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId
, bool important) |
| 3331 { | 3331 { |
| 3332 ShorthandScope scope(this, shorthandId); | 3332 ShorthandScope scope(this, shorthandId); |
| 3333 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); | 3333 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); |
| 3334 ASSERT(shorthand.length() == 2); | 3334 ASSERT(shorthand.length() == 2); |
| 3335 | 3335 |
| 3336 RefPtrWillBeRawPtr<CSSValue> startValue = parseGridPosition(); | 3336 RefPtr<CSSValue> startValue = parseGridPosition(); |
| 3337 if (!startValue) | 3337 if (!startValue) |
| 3338 return false; | 3338 return false; |
| 3339 | 3339 |
| 3340 RefPtrWillBeRawPtr<CSSValue> endValue = nullptr; | 3340 RefPtr<CSSValue> endValue = nullptr; |
| 3341 if (m_valueList->current()) { | 3341 if (m_valueList->current()) { |
| 3342 if (!isForwardSlashOperator(m_valueList->current())) | 3342 if (!isForwardSlashOperator(m_valueList->current())) |
| 3343 return false; | 3343 return false; |
| 3344 | 3344 |
| 3345 if (!m_valueList->next()) | 3345 if (!m_valueList->next()) |
| 3346 return false; | 3346 return false; |
| 3347 | 3347 |
| 3348 endValue = parseGridPosition(); | 3348 endValue = parseGridPosition(); |
| 3349 if (!endValue || m_valueList->current()) | 3349 if (!endValue || m_valueList->current()) |
| 3350 return false; | 3350 return false; |
| 3351 } else { | 3351 } else { |
| 3352 endValue = gridMissingGridPositionValue(startValue.get()); | 3352 endValue = gridMissingGridPositionValue(startValue.get()); |
| 3353 } | 3353 } |
| 3354 | 3354 |
| 3355 addProperty(shorthand.properties()[0], startValue, important); | 3355 addProperty(shorthand.properties()[0], startValue, important); |
| 3356 addProperty(shorthand.properties()[1], endValue, important); | 3356 addProperty(shorthand.properties()[1], endValue, important); |
| 3357 return true; | 3357 return true; |
| 3358 } | 3358 } |
| 3359 | 3359 |
| 3360 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
Value> templateColumns, bool important) | 3360 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtr<CSSValue> templ
ateColumns, bool important) |
| 3361 { | 3361 { |
| 3362 NamedGridAreaMap gridAreaMap; | 3362 NamedGridAreaMap gridAreaMap; |
| 3363 size_t rowCount = 0; | 3363 size_t rowCount = 0; |
| 3364 size_t columnCount = 0; | 3364 size_t columnCount = 0; |
| 3365 bool trailingIdentWasAdded = false; | 3365 bool trailingIdentWasAdded = false; |
| 3366 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep
arated(); | 3366 RefPtr<CSSValueList> templateRows = CSSValueList::createSpaceSeparated(); |
| 3367 | 3367 |
| 3368 // At least template-areas strings must be defined. | 3368 // At least template-areas strings must be defined. |
| 3369 if (!m_valueList->current()) | 3369 if (!m_valueList->current()) |
| 3370 return false; | 3370 return false; |
| 3371 | 3371 |
| 3372 while (m_valueList->current()) { | 3372 while (m_valueList->current()) { |
| 3373 // Handle leading <custom-ident>*. | 3373 // Handle leading <custom-ident>*. |
| 3374 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd
ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n
ullptr)) | 3374 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd
ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n
ullptr)) |
| 3375 return false; | 3375 return false; |
| 3376 | 3376 |
| 3377 // Handle a template-area's row. | 3377 // Handle a template-area's row. |
| 3378 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | 3378 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) |
| 3379 return false; | 3379 return false; |
| 3380 ++rowCount; | 3380 ++rowCount; |
| 3381 | 3381 |
| 3382 // Handle template-rows's track-size. | 3382 // Handle template-rows's track-size. |
| 3383 if (m_valueList->current() && m_valueList->current()->unit() != CSSPrimi
tiveValue::UnitType::String) { | 3383 if (m_valueList->current() && m_valueList->current()->unit() != CSSPrimi
tiveValue::UnitType::String) { |
| 3384 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList
); | 3384 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); |
| 3385 if (!value) | 3385 if (!value) |
| 3386 return false; | 3386 return false; |
| 3387 templateRows->append(value); | 3387 templateRows->append(value); |
| 3388 } else { | 3388 } else { |
| 3389 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu
to)); | 3389 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu
to)); |
| 3390 } | 3390 } |
| 3391 | 3391 |
| 3392 // This will handle the trailing/leading <custom-ident>* in the grammar. | 3392 // This will handle the trailing/leading <custom-ident>* in the grammar. |
| 3393 if (!parseGridLineNames(*m_valueList, *templateRows)) | 3393 if (!parseGridLineNames(*m_valueList, *templateRows)) |
| 3394 return false; | 3394 return false; |
| 3395 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)->
isGridLineNamesValue(); | 3395 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)->
isGridLineNamesValue(); |
| 3396 } | 3396 } |
| 3397 | 3397 |
| 3398 // [<track-list> /]? | 3398 // [<track-list> /]? |
| 3399 if (templateColumns) | 3399 if (templateColumns) |
| 3400 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); | 3400 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); |
| 3401 else | 3401 else |
| 3402 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti
fierValue(CSSValueNone), important); | 3402 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti
fierValue(CSSValueNone), important); |
| 3403 | 3403 |
| 3404 // [<line-names>? <string> [<track-size> <line-names>]? ]+ | 3404 // [<line-names>? <string> [<track-size> <line-names>]? ]+ |
| 3405 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea
te(gridAreaMap, rowCount, columnCount); | 3405 RefPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::create(gridAreaM
ap, rowCount, columnCount); |
| 3406 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important
); | 3406 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important
); |
| 3407 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); | 3407 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); |
| 3408 | 3408 |
| 3409 return true; | 3409 return true; |
| 3410 } | 3410 } |
| 3411 | 3411 |
| 3412 | 3412 |
| 3413 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) | 3413 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) |
| 3414 { | 3414 { |
| 3415 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3415 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3416 | 3416 |
| 3417 ShorthandScope scope(this, CSSPropertyGridTemplate); | 3417 ShorthandScope scope(this, CSSPropertyGridTemplate); |
| 3418 ASSERT(gridTemplateShorthand().length() == 3); | 3418 ASSERT(gridTemplateShorthand().length() == 3); |
| 3419 | 3419 |
| 3420 // At least "none" must be defined. | 3420 // At least "none" must be defined. |
| 3421 if (!m_valueList->current()) | 3421 if (!m_valueList->current()) |
| 3422 return false; | 3422 return false; |
| 3423 | 3423 |
| 3424 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; | 3424 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; |
| 3425 | 3425 |
| 3426 // 1- 'none' case. | 3426 // 1- 'none' case. |
| 3427 if (firstValueIsNone && !m_valueList->next()) { | 3427 if (firstValueIsNone && !m_valueList->next()) { |
| 3428 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif
ierValue(CSSValueNone), important); | 3428 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif
ierValue(CSSValueNone), important); |
| 3429 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier
Value(CSSValueNone), important); | 3429 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier
Value(CSSValueNone), important); |
| 3430 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie
rValue(CSSValueNone), important); | 3430 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie
rValue(CSSValueNone), important); |
| 3431 return true; | 3431 return true; |
| 3432 } | 3432 } |
| 3433 | 3433 |
| 3434 unsigned index = 0; | 3434 unsigned index = 0; |
| 3435 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr; | 3435 RefPtr<CSSValue> columnsValue = nullptr; |
| 3436 if (firstValueIsNone) { | 3436 if (firstValueIsNone) { |
| 3437 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); | 3437 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); |
| 3438 } else { | 3438 } else { |
| 3439 columnsValue = parseGridTrackList(); | 3439 columnsValue = parseGridTrackList(); |
| 3440 } | 3440 } |
| 3441 | 3441 |
| 3442 // 2- <grid-template-columns> / <grid-template-columns> syntax. | 3442 // 2- <grid-template-columns> / <grid-template-columns> syntax. |
| 3443 if (columnsValue) { | 3443 if (columnsValue) { |
| 3444 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr
ent()) && m_valueList->next())) | 3444 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr
ent()) && m_valueList->next())) |
| 3445 return false; | 3445 return false; |
| 3446 index = m_valueList->currentIndex(); | 3446 index = m_valueList->currentIndex(); |
| 3447 if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) { | 3447 if (RefPtr<CSSValue> rowsValue = parseGridTrackList()) { |
| 3448 if (m_valueList->current()) | 3448 if (m_valueList->current()) |
| 3449 return false; | 3449 return false; |
| 3450 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important)
; | 3450 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important)
; |
| 3451 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); | 3451 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); |
| 3452 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent
ifierValue(CSSValueNone), important); | 3452 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent
ifierValue(CSSValueNone), important); |
| 3453 return true; | 3453 return true; |
| 3454 } | 3454 } |
| 3455 } | 3455 } |
| 3456 | 3456 |
| 3457 | 3457 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3479 return true; | 3479 return true; |
| 3480 } | 3480 } |
| 3481 | 3481 |
| 3482 // Need to rewind parsing to explore the alternative syntax of this shorthan
d. | 3482 // Need to rewind parsing to explore the alternative syntax of this shorthan
d. |
| 3483 m_valueList->setCurrentIndex(0); | 3483 m_valueList->setCurrentIndex(0); |
| 3484 | 3484 |
| 3485 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] | 3485 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] |
| 3486 if (!parseValue(CSSPropertyGridAutoFlow, important)) | 3486 if (!parseValue(CSSPropertyGridAutoFlow, important)) |
| 3487 return false; | 3487 return false; |
| 3488 | 3488 |
| 3489 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = nullptr; | 3489 RefPtr<CSSValue> autoColumnsValue = nullptr; |
| 3490 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr; | 3490 RefPtr<CSSValue> autoRowsValue = nullptr; |
| 3491 | 3491 |
| 3492 if (m_valueList->current()) { | 3492 if (m_valueList->current()) { |
| 3493 autoColumnsValue = parseGridTrackSize(*m_valueList); | 3493 autoColumnsValue = parseGridTrackSize(*m_valueList); |
| 3494 if (!autoColumnsValue) | 3494 if (!autoColumnsValue) |
| 3495 return false; | 3495 return false; |
| 3496 if (m_valueList->current()) { | 3496 if (m_valueList->current()) { |
| 3497 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList-
>next()) | 3497 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList-
>next()) |
| 3498 return false; | 3498 return false; |
| 3499 autoRowsValue = parseGridTrackSize(*m_valueList); | 3499 autoRowsValue = parseGridTrackSize(*m_valueList); |
| 3500 if (!autoRowsValue) | 3500 if (!autoRowsValue) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3525 } | 3525 } |
| 3526 | 3526 |
| 3527 bool CSSPropertyParser::parseGridAreaShorthand(bool important) | 3527 bool CSSPropertyParser::parseGridAreaShorthand(bool important) |
| 3528 { | 3528 { |
| 3529 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3529 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3530 | 3530 |
| 3531 ShorthandScope scope(this, CSSPropertyGridArea); | 3531 ShorthandScope scope(this, CSSPropertyGridArea); |
| 3532 const StylePropertyShorthand& shorthand = gridAreaShorthand(); | 3532 const StylePropertyShorthand& shorthand = gridAreaShorthand(); |
| 3533 ASSERT_UNUSED(shorthand, shorthand.length() == 4); | 3533 ASSERT_UNUSED(shorthand, shorthand.length() == 4); |
| 3534 | 3534 |
| 3535 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); | 3535 RefPtr<CSSValue> rowStartValue = parseGridPosition(); |
| 3536 if (!rowStartValue) | 3536 if (!rowStartValue) |
| 3537 return false; | 3537 return false; |
| 3538 | 3538 |
| 3539 RefPtrWillBeRawPtr<CSSValue> columnStartValue = nullptr; | 3539 RefPtr<CSSValue> columnStartValue = nullptr; |
| 3540 if (!parseSingleGridAreaLonghand(columnStartValue)) | 3540 if (!parseSingleGridAreaLonghand(columnStartValue)) |
| 3541 return false; | 3541 return false; |
| 3542 | 3542 |
| 3543 RefPtrWillBeRawPtr<CSSValue> rowEndValue = nullptr; | 3543 RefPtr<CSSValue> rowEndValue = nullptr; |
| 3544 if (!parseSingleGridAreaLonghand(rowEndValue)) | 3544 if (!parseSingleGridAreaLonghand(rowEndValue)) |
| 3545 return false; | 3545 return false; |
| 3546 | 3546 |
| 3547 RefPtrWillBeRawPtr<CSSValue> columnEndValue = nullptr; | 3547 RefPtr<CSSValue> columnEndValue = nullptr; |
| 3548 if (!parseSingleGridAreaLonghand(columnEndValue)) | 3548 if (!parseSingleGridAreaLonghand(columnEndValue)) |
| 3549 return false; | 3549 return false; |
| 3550 | 3550 |
| 3551 if (!columnStartValue) | 3551 if (!columnStartValue) |
| 3552 columnStartValue = gridMissingGridPositionValue(rowStartValue.get()); | 3552 columnStartValue = gridMissingGridPositionValue(rowStartValue.get()); |
| 3553 | 3553 |
| 3554 if (!rowEndValue) | 3554 if (!rowEndValue) |
| 3555 rowEndValue = gridMissingGridPositionValue(rowStartValue.get()); | 3555 rowEndValue = gridMissingGridPositionValue(rowStartValue.get()); |
| 3556 | 3556 |
| 3557 if (!columnEndValue) | 3557 if (!columnEndValue) |
| 3558 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); | 3558 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); |
| 3559 | 3559 |
| 3560 addProperty(CSSPropertyGridRowStart, rowStartValue, important); | 3560 addProperty(CSSPropertyGridRowStart, rowStartValue, important); |
| 3561 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); | 3561 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); |
| 3562 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); | 3562 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); |
| 3563 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); | 3563 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); |
| 3564 return true; | 3564 return true; |
| 3565 } | 3565 } |
| 3566 | 3566 |
| 3567 bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtrWillBeRawPtr<CSSValue>
& property) | 3567 bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtr<CSSValue>& property) |
| 3568 { | 3568 { |
| 3569 if (!m_valueList->current()) | 3569 if (!m_valueList->current()) |
| 3570 return true; | 3570 return true; |
| 3571 | 3571 |
| 3572 if (!isForwardSlashOperator(m_valueList->current())) | 3572 if (!isForwardSlashOperator(m_valueList->current())) |
| 3573 return false; | 3573 return false; |
| 3574 | 3574 |
| 3575 if (!m_valueList->next()) | 3575 if (!m_valueList->next()) |
| 3576 return false; | 3576 return false; |
| 3577 | 3577 |
| 3578 property = parseGridPosition(); | 3578 property = parseGridPosition(); |
| 3579 return true; | 3579 return true; |
| 3580 } | 3580 } |
| 3581 | 3581 |
| 3582 static inline bool isClosingBracket(const CSSParserValue& value) | 3582 static inline bool isClosingBracket(const CSSParserValue& value) |
| 3583 { | 3583 { |
| 3584 return value.m_unit == CSSParserValue::Operator && value.iValue == ']'; | 3584 return value.m_unit == CSSParserValue::Operator && value.iValue == ']'; |
| 3585 } | 3585 } |
| 3586 | 3586 |
| 3587 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal
ueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames) | 3587 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal
ueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames) |
| 3588 { | 3588 { |
| 3589 if (!inputList.current() || inputList.current()->m_unit != CSSParserValue::O
perator || inputList.current()->iValue != '[') | 3589 if (!inputList.current() || inputList.current()->m_unit != CSSParserValue::O
perator || inputList.current()->iValue != '[') |
| 3590 return true; | 3590 return true; |
| 3591 | 3591 |
| 3592 // Skip '[' | 3592 // Skip '[' |
| 3593 inputList.next(); | 3593 inputList.next(); |
| 3594 | 3594 |
| 3595 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = previousNamedAreaTrail
ingLineNames; | 3595 RefPtr<CSSGridLineNamesValue> lineNames = previousNamedAreaTrailingLineNames
; |
| 3596 if (!lineNames) | 3596 if (!lineNames) |
| 3597 lineNames = CSSGridLineNamesValue::create(); | 3597 lineNames = CSSGridLineNamesValue::create(); |
| 3598 | 3598 |
| 3599 while (CSSParserValue* identValue = inputList.current()) { | 3599 while (CSSParserValue* identValue = inputList.current()) { |
| 3600 if (isClosingBracket(*identValue)) | 3600 if (isClosingBracket(*identValue)) |
| 3601 break; | 3601 break; |
| 3602 | 3602 |
| 3603 if (!isValidCustomIdentForGridPositions(*identValue)) | 3603 if (!isValidCustomIdentForGridPositions(*identValue)) |
| 3604 return false; | 3604 return false; |
| 3605 | 3605 |
| 3606 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId
entValue(identValue); | 3606 RefPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomIdentValue(ide
ntValue); |
| 3607 lineNames->append(lineName.release()); | 3607 lineNames->append(lineName.release()); |
| 3608 inputList.next(); | 3608 inputList.next(); |
| 3609 } | 3609 } |
| 3610 | 3610 |
| 3611 if (!inputList.current() || !isClosingBracket(*inputList.current())) | 3611 if (!inputList.current() || !isClosingBracket(*inputList.current())) |
| 3612 return false; | 3612 return false; |
| 3613 | 3613 |
| 3614 if (!previousNamedAreaTrailingLineNames) | 3614 if (!previousNamedAreaTrailingLineNames) |
| 3615 valueList.append(lineNames.release()); | 3615 valueList.append(lineNames.release()); |
| 3616 | 3616 |
| 3617 // Consume ']' | 3617 // Consume ']' |
| 3618 inputList.next(); | 3618 inputList.next(); |
| 3619 return true; | 3619 return true; |
| 3620 } | 3620 } |
| 3621 | 3621 |
| 3622 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList() | 3622 PassRefPtr<CSSValue> CSSPropertyParser::parseGridTrackList() |
| 3623 { | 3623 { |
| 3624 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3624 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3625 | 3625 |
| 3626 CSSParserValue* value = m_valueList->current(); | 3626 CSSParserValue* value = m_valueList->current(); |
| 3627 if (value->id == CSSValueNone) { | 3627 if (value->id == CSSValueNone) { |
| 3628 m_valueList->next(); | 3628 m_valueList->next(); |
| 3629 return cssValuePool().createIdentifierValue(CSSValueNone); | 3629 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 3630 } | 3630 } |
| 3631 | 3631 |
| 3632 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 3632 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); |
| 3633 // Handle leading <custom-ident>*. | 3633 // Handle leading <custom-ident>*. |
| 3634 if (!parseGridLineNames(*m_valueList, *values)) | 3634 if (!parseGridLineNames(*m_valueList, *values)) |
| 3635 return nullptr; | 3635 return nullptr; |
| 3636 | 3636 |
| 3637 bool seenTrackSizeOrRepeatFunction = false; | 3637 bool seenTrackSizeOrRepeatFunction = false; |
| 3638 while (CSSParserValue* currentValue = m_valueList->current()) { | 3638 while (CSSParserValue* currentValue = m_valueList->current()) { |
| 3639 if (isForwardSlashOperator(currentValue)) | 3639 if (isForwardSlashOperator(currentValue)) |
| 3640 break; | 3640 break; |
| 3641 if (currentValue->m_unit == CSSParserValue::Function && currentValue->fu
nction->id == CSSValueRepeat) { | 3641 if (currentValue->m_unit == CSSParserValue::Function && currentValue->fu
nction->id == CSSValueRepeat) { |
| 3642 if (!parseGridTrackRepeatFunction(*values)) | 3642 if (!parseGridTrackRepeatFunction(*values)) |
| 3643 return nullptr; | 3643 return nullptr; |
| 3644 seenTrackSizeOrRepeatFunction = true; | 3644 seenTrackSizeOrRepeatFunction = true; |
| 3645 } else { | 3645 } else { |
| 3646 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList
); | 3646 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); |
| 3647 if (!value) | 3647 if (!value) |
| 3648 return nullptr; | 3648 return nullptr; |
| 3649 values->append(value); | 3649 values->append(value); |
| 3650 seenTrackSizeOrRepeatFunction = true; | 3650 seenTrackSizeOrRepeatFunction = true; |
| 3651 } | 3651 } |
| 3652 // This will handle the trailing <custom-ident>* in the grammar. | 3652 // This will handle the trailing <custom-ident>* in the grammar. |
| 3653 if (!parseGridLineNames(*m_valueList, *values)) | 3653 if (!parseGridLineNames(*m_valueList, *values)) |
| 3654 return nullptr; | 3654 return nullptr; |
| 3655 } | 3655 } |
| 3656 | 3656 |
| 3657 // We should have found a <track-size> or else it is not a valid <track-list
> | 3657 // We should have found a <track-size> or else it is not a valid <track-list
> |
| 3658 if (!seenTrackSizeOrRepeatFunction) | 3658 if (!seenTrackSizeOrRepeatFunction) |
| 3659 return nullptr; | 3659 return nullptr; |
| 3660 | 3660 |
| 3661 return values; | 3661 return values; |
| 3662 } | 3662 } |
| 3663 | 3663 |
| 3664 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list) | 3664 bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list) |
| 3665 { | 3665 { |
| 3666 CSSParserValueList* arguments = m_valueList->current()->function->args.get()
; | 3666 CSSParserValueList* arguments = m_valueList->current()->function->args.get()
; |
| 3667 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0),
FPositiveInteger) || !isComma(arguments->valueAt(1))) | 3667 if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0),
FPositiveInteger) || !isComma(arguments->valueAt(1))) |
| 3668 return false; | 3668 return false; |
| 3669 | 3669 |
| 3670 ASSERT(arguments->valueAt(0)->fValue > 0); | 3670 ASSERT(arguments->valueAt(0)->fValue > 0); |
| 3671 size_t repetitions = clampTo<size_t>(arguments->valueAt(0)->fValue, 0, kGrid
MaxTracks); | 3671 size_t repetitions = clampTo<size_t>(arguments->valueAt(0)->fValue, 0, kGrid
MaxTracks); |
| 3672 | 3672 |
| 3673 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS
eparated(); | 3673 RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated(); |
| 3674 arguments->next(); // Skip the repetition count. | 3674 arguments->next(); // Skip the repetition count. |
| 3675 arguments->next(); // Skip the comma. | 3675 arguments->next(); // Skip the comma. |
| 3676 | 3676 |
| 3677 // Handle leading <custom-ident>*. | 3677 // Handle leading <custom-ident>*. |
| 3678 if (!parseGridLineNames(*arguments, *repeatedValues)) | 3678 if (!parseGridLineNames(*arguments, *repeatedValues)) |
| 3679 return false; | 3679 return false; |
| 3680 | 3680 |
| 3681 size_t numberOfTracks = 0; | 3681 size_t numberOfTracks = 0; |
| 3682 while (arguments->current()) { | 3682 while (arguments->current()) { |
| 3683 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); | 3683 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); |
| 3684 if (!trackSize) | 3684 if (!trackSize) |
| 3685 return false; | 3685 return false; |
| 3686 | 3686 |
| 3687 repeatedValues->append(trackSize); | 3687 repeatedValues->append(trackSize); |
| 3688 ++numberOfTracks; | 3688 ++numberOfTracks; |
| 3689 | 3689 |
| 3690 // This takes care of any trailing <custom-ident>* in the grammar. | 3690 // This takes care of any trailing <custom-ident>* in the grammar. |
| 3691 if (!parseGridLineNames(*arguments, *repeatedValues)) | 3691 if (!parseGridLineNames(*arguments, *repeatedValues)) |
| 3692 return false; | 3692 return false; |
| 3693 } | 3693 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3704 for (size_t j = 0; j < repeatedValues->length(); ++j) | 3704 for (size_t j = 0; j < repeatedValues->length(); ++j) |
| 3705 list.append(repeatedValues->item(j)); | 3705 list.append(repeatedValues->item(j)); |
| 3706 } | 3706 } |
| 3707 | 3707 |
| 3708 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. | 3708 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. |
| 3709 m_valueList->next(); | 3709 m_valueList->next(); |
| 3710 return true; | 3710 return true; |
| 3711 } | 3711 } |
| 3712 | 3712 |
| 3713 | 3713 |
| 3714 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParser
ValueList& inputList) | 3714 PassRefPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParserValueList& i
nputList) |
| 3715 { | 3715 { |
| 3716 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3716 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3717 | 3717 |
| 3718 CSSParserValue* currentValue = inputList.current(); | 3718 CSSParserValue* currentValue = inputList.current(); |
| 3719 inputList.next(); | 3719 inputList.next(); |
| 3720 | 3720 |
| 3721 if (currentValue->id == CSSValueAuto) | 3721 if (currentValue->id == CSSValueAuto) |
| 3722 return cssValuePool().createIdentifierValue(CSSValueAuto); | 3722 return cssValuePool().createIdentifierValue(CSSValueAuto); |
| 3723 | 3723 |
| 3724 if (currentValue->m_unit == CSSParserValue::Function && currentValue->functi
on->id == CSSValueMinmax) { | 3724 if (currentValue->m_unit == CSSParserValue::Function && currentValue->functi
on->id == CSSValueMinmax) { |
| 3725 // The spec defines the following grammar: minmax( <track-breadth> , <tr
ack-breadth> ) | 3725 // The spec defines the following grammar: minmax( <track-breadth> , <tr
ack-breadth> ) |
| 3726 CSSParserValueList* arguments = currentValue->function->args.get(); | 3726 CSSParserValueList* arguments = currentValue->function->args.get(); |
| 3727 if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(
1))) | 3727 if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(
1))) |
| 3728 return nullptr; | 3728 return nullptr; |
| 3729 | 3729 |
| 3730 RefPtrWillBeRawPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth
(arguments->valueAt(0)); | 3730 RefPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth(arguments->
valueAt(0)); |
| 3731 if (!minTrackBreadth) | 3731 if (!minTrackBreadth) |
| 3732 return nullptr; | 3732 return nullptr; |
| 3733 | 3733 |
| 3734 RefPtrWillBeRawPtr<CSSPrimitiveValue> maxTrackBreadth = parseGridBreadth
(arguments->valueAt(2)); | 3734 RefPtr<CSSPrimitiveValue> maxTrackBreadth = parseGridBreadth(arguments->
valueAt(2)); |
| 3735 if (!maxTrackBreadth) | 3735 if (!maxTrackBreadth) |
| 3736 return nullptr; | 3736 return nullptr; |
| 3737 | 3737 |
| 3738 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C
SSValueMinmax); | 3738 RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueMinma
x); |
| 3739 result->append(minTrackBreadth); | 3739 result->append(minTrackBreadth); |
| 3740 result->append(maxTrackBreadth); | 3740 result->append(maxTrackBreadth); |
| 3741 return result.release(); | 3741 return result.release(); |
| 3742 } | 3742 } |
| 3743 | 3743 |
| 3744 return parseGridBreadth(currentValue); | 3744 return parseGridBreadth(currentValue); |
| 3745 } | 3745 } |
| 3746 | 3746 |
| 3747 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseGridBreadth(CS
SParserValue* currentValue) | 3747 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseGridBreadth(CSSParserValue
* currentValue) |
| 3748 { | 3748 { |
| 3749 if (currentValue->id == CSSValueMinContent || currentValue->id == CSSValueMa
xContent || currentValue->id == CSSValueAuto) | 3749 if (currentValue->id == CSSValueMinContent || currentValue->id == CSSValueMa
xContent || currentValue->id == CSSValueAuto) |
| 3750 return cssValuePool().createIdentifierValue(currentValue->id); | 3750 return cssValuePool().createIdentifierValue(currentValue->id); |
| 3751 | 3751 |
| 3752 if (currentValue->unit() == CSSPrimitiveValue::UnitType::Fraction) { | 3752 if (currentValue->unit() == CSSPrimitiveValue::UnitType::Fraction) { |
| 3753 double flexValue = currentValue->fValue; | 3753 double flexValue = currentValue->fValue; |
| 3754 | 3754 |
| 3755 // Fractional unit is a non-negative dimension. | 3755 // Fractional unit is a non-negative dimension. |
| 3756 if (flexValue <= 0) | 3756 if (flexValue <= 0) |
| 3757 return nullptr; | 3757 return nullptr; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3858 | 3858 |
| 3859 ++gridCoordinate.rows.resolvedFinalPosition; | 3859 ++gridCoordinate.rows.resolvedFinalPosition; |
| 3860 } | 3860 } |
| 3861 currentCol = lookAheadCol; | 3861 currentCol = lookAheadCol; |
| 3862 } | 3862 } |
| 3863 | 3863 |
| 3864 m_valueList->next(); | 3864 m_valueList->next(); |
| 3865 return true; | 3865 return true; |
| 3866 } | 3866 } |
| 3867 | 3867 |
| 3868 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() | 3868 PassRefPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() |
| 3869 { | 3869 { |
| 3870 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { | 3870 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { |
| 3871 m_valueList->next(); | 3871 m_valueList->next(); |
| 3872 return cssValuePool().createIdentifierValue(CSSValueNone); | 3872 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 3873 } | 3873 } |
| 3874 | 3874 |
| 3875 NamedGridAreaMap gridAreaMap; | 3875 NamedGridAreaMap gridAreaMap; |
| 3876 size_t rowCount = 0; | 3876 size_t rowCount = 0; |
| 3877 size_t columnCount = 0; | 3877 size_t columnCount = 0; |
| 3878 | 3878 |
| 3879 while (m_valueList->current()) { | 3879 while (m_valueList->current()) { |
| 3880 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | 3880 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) |
| 3881 return nullptr; | 3881 return nullptr; |
| 3882 ++rowCount; | 3882 ++rowCount; |
| 3883 } | 3883 } |
| 3884 | 3884 |
| 3885 if (!rowCount || !columnCount) | 3885 if (!rowCount || !columnCount) |
| 3886 return nullptr; | 3886 return nullptr; |
| 3887 | 3887 |
| 3888 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; | 3888 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; |
| 3889 } | 3889 } |
| 3890 | 3890 |
| 3891 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV
alueList& list) | 3891 PassRefPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserValueList& li
st) |
| 3892 { | 3892 { |
| 3893 // [ row | column ] || dense | 3893 // [ row | column ] || dense |
| 3894 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3894 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3895 | 3895 |
| 3896 CSSParserValue* value = list.current(); | 3896 CSSParserValue* value = list.current(); |
| 3897 if (!value) | 3897 if (!value) |
| 3898 return nullptr; | 3898 return nullptr; |
| 3899 | 3899 |
| 3900 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 3900 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); |
| 3901 | 3901 |
| 3902 // First parameter. | 3902 // First parameter. |
| 3903 CSSValueID firstId = value->id; | 3903 CSSValueID firstId = value->id; |
| 3904 if (firstId != CSSValueRow && firstId != CSSValueColumn && firstId != CSSVal
ueDense) | 3904 if (firstId != CSSValueRow && firstId != CSSValueColumn && firstId != CSSVal
ueDense) |
| 3905 return nullptr; | 3905 return nullptr; |
| 3906 parsedValues->append(cssValuePool().createIdentifierValue(firstId)); | 3906 parsedValues->append(cssValuePool().createIdentifierValue(firstId)); |
| 3907 | 3907 |
| 3908 // Second parameter, if any. | 3908 // Second parameter, if any. |
| 3909 value = list.next(); | 3909 value = list.next(); |
| 3910 if (value) { | 3910 if (value) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3921 default: | 3921 default: |
| 3922 return parsedValues; | 3922 return parsedValues; |
| 3923 } | 3923 } |
| 3924 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); | 3924 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); |
| 3925 list.next(); | 3925 list.next(); |
| 3926 } | 3926 } |
| 3927 | 3927 |
| 3928 return parsedValues; | 3928 return parsedValues; |
| 3929 } | 3929 } |
| 3930 | 3930 |
| 3931 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
rValueList* args, bool counters) | 3931 PassRefPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParserValueList*
args, bool counters) |
| 3932 { | 3932 { |
| 3933 unsigned numArgs = args->size(); | 3933 unsigned numArgs = args->size(); |
| 3934 if (counters && numArgs != 3 && numArgs != 5) | 3934 if (counters && numArgs != 3 && numArgs != 5) |
| 3935 return nullptr; | 3935 return nullptr; |
| 3936 if (!counters && numArgs != 1 && numArgs != 3) | 3936 if (!counters && numArgs != 1 && numArgs != 3) |
| 3937 return nullptr; | 3937 return nullptr; |
| 3938 | 3938 |
| 3939 CSSParserValue* i = args->current(); | 3939 CSSParserValue* i = args->current(); |
| 3940 if (i->m_unit != CSSParserValue::Identifier) | 3940 if (i->m_unit != CSSParserValue::Identifier) |
| 3941 return nullptr; | 3941 return nullptr; |
| 3942 RefPtrWillBeRawPtr<CSSPrimitiveValue> identifier = createPrimitiveCustomIden
tValue(i); | 3942 RefPtr<CSSPrimitiveValue> identifier = createPrimitiveCustomIdentValue(i); |
| 3943 | 3943 |
| 3944 RefPtrWillBeRawPtr<CSSPrimitiveValue> separator = nullptr; | 3944 RefPtr<CSSPrimitiveValue> separator = nullptr; |
| 3945 if (!counters) | 3945 if (!counters) |
| 3946 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::Unit
Type::CustomIdentifier); | 3946 separator = cssValuePool().createValue(String(), CSSPrimitiveValue::Unit
Type::CustomIdentifier); |
| 3947 else { | 3947 else { |
| 3948 args->next(); | 3948 args->next(); |
| 3949 if (!consumeComma(args)) | 3949 if (!consumeComma(args)) |
| 3950 return nullptr; | 3950 return nullptr; |
| 3951 | 3951 |
| 3952 i = args->current(); | 3952 i = args->current(); |
| 3953 if (i->unit() != CSSPrimitiveValue::UnitType::String) | 3953 if (i->unit() != CSSPrimitiveValue::UnitType::String) |
| 3954 return nullptr; | 3954 return nullptr; |
| 3955 | 3955 |
| 3956 separator = createPrimitiveCustomIdentValue(i); | 3956 separator = createPrimitiveCustomIdentValue(i); |
| 3957 } | 3957 } |
| 3958 | 3958 |
| 3959 RefPtrWillBeRawPtr<CSSPrimitiveValue> listStyle = nullptr; | 3959 RefPtr<CSSPrimitiveValue> listStyle = nullptr; |
| 3960 i = args->next(); | 3960 i = args->next(); |
| 3961 if (!i) // Make the list style default decimal | 3961 if (!i) // Make the list style default decimal |
| 3962 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); | 3962 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); |
| 3963 else { | 3963 else { |
| 3964 if (!consumeComma(args)) | 3964 if (!consumeComma(args)) |
| 3965 return nullptr; | 3965 return nullptr; |
| 3966 | 3966 |
| 3967 i = args->current(); | 3967 i = args->current(); |
| 3968 if (i->m_unit != CSSParserValue::Identifier) | 3968 if (i->m_unit != CSSParserValue::Identifier) |
| 3969 return nullptr; | 3969 return nullptr; |
| 3970 | 3970 |
| 3971 CSSValueID listStyleID = CSSValueInvalid; | 3971 CSSValueID listStyleID = CSSValueInvalid; |
| 3972 if (i->id == CSSValueNone || (i->id >= CSSValueDisc && i->id <= CSSValue
KatakanaIroha)) | 3972 if (i->id == CSSValueNone || (i->id >= CSSValueDisc && i->id <= CSSValue
KatakanaIroha)) |
| 3973 listStyleID = i->id; | 3973 listStyleID = i->id; |
| 3974 else | 3974 else |
| 3975 return nullptr; | 3975 return nullptr; |
| 3976 | 3976 |
| 3977 listStyle = cssValuePool().createIdentifierValue(listStyleID); | 3977 listStyle = cssValuePool().createIdentifierValue(listStyleID); |
| 3978 } | 3978 } |
| 3979 | 3979 |
| 3980 return CSSCounterValue::create(identifier.release(), listStyle.release(), se
parator.release()); | 3980 return CSSCounterValue::create(identifier.release(), listStyle.release(), se
parator.release()); |
| 3981 } | 3981 } |
| 3982 | 3982 |
| 3983 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseClipShape() | 3983 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseClipShape() |
| 3984 { | 3984 { |
| 3985 CSSParserValue* value = m_valueList->current(); | 3985 CSSParserValue* value = m_valueList->current(); |
| 3986 CSSParserValueList* args = value->function->args.get(); | 3986 CSSParserValueList* args = value->function->args.get(); |
| 3987 | 3987 |
| 3988 if (value->function->id != CSSValueRect || !args) | 3988 if (value->function->id != CSSValueRect || !args) |
| 3989 return nullptr; | 3989 return nullptr; |
| 3990 | 3990 |
| 3991 // rect(t, r, b, l) || rect(t r b l) | 3991 // rect(t, r, b, l) || rect(t r b l) |
| 3992 if (args->size() != 4 && args->size() != 7) | 3992 if (args->size() != 4 && args->size() != 7) |
| 3993 return nullptr; | 3993 return nullptr; |
| 3994 RefPtrWillBeRawPtr<Rect> rect = Rect::create(); | 3994 RefPtr<Rect> rect = Rect::create(); |
| 3995 int i = 0; | 3995 int i = 0; |
| 3996 CSSParserValue* a = args->current(); | 3996 CSSParserValue* a = args->current(); |
| 3997 while (a) { | 3997 while (a) { |
| 3998 if (a->id != CSSValueAuto && !validUnit(a, FLength | FUnitlessQuirk)) | 3998 if (a->id != CSSValueAuto && !validUnit(a, FLength | FUnitlessQuirk)) |
| 3999 return nullptr; | 3999 return nullptr; |
| 4000 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ? | 4000 RefPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ? |
| 4001 cssValuePool().createIdentifierValue(CSSValueAuto) : | 4001 cssValuePool().createIdentifierValue(CSSValueAuto) : |
| 4002 createPrimitiveNumericValue(a); | 4002 createPrimitiveNumericValue(a); |
| 4003 if (i == 0) | 4003 if (i == 0) |
| 4004 rect->setTop(length); | 4004 rect->setTop(length); |
| 4005 else if (i == 1) | 4005 else if (i == 1) |
| 4006 rect->setRight(length); | 4006 rect->setRight(length); |
| 4007 else if (i == 2) | 4007 else if (i == 2) |
| 4008 rect->setBottom(length); | 4008 rect->setBottom(length); |
| 4009 else | 4009 else |
| 4010 rect->setLeft(length); | 4010 rect->setLeft(length); |
| 4011 a = args->next(); | 4011 a = args->next(); |
| 4012 if (a && args->size() == 7) { | 4012 if (a && args->size() == 7) { |
| 4013 if (!consumeComma(args)) | 4013 if (!consumeComma(args)) |
| 4014 return nullptr; | 4014 return nullptr; |
| 4015 a = args->current(); | 4015 a = args->current(); |
| 4016 } | 4016 } |
| 4017 i++; | 4017 i++; |
| 4018 } | 4018 } |
| 4019 m_valueList->next(); | 4019 m_valueList->next(); |
| 4020 return cssValuePool().createValue(rect.release()); | 4020 return cssValuePool().createValue(rect.release()); |
| 4021 } | 4021 } |
| 4022 | 4022 |
| 4023 static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]) | 4023 static void completeBorderRadii(RefPtr<CSSPrimitiveValue> radii[4]) |
| 4024 { | 4024 { |
| 4025 if (radii[3]) | 4025 if (radii[3]) |
| 4026 return; | 4026 return; |
| 4027 if (!radii[2]) { | 4027 if (!radii[2]) { |
| 4028 if (!radii[1]) | 4028 if (!radii[1]) |
| 4029 radii[1] = radii[0]; | 4029 radii[1] = radii[0]; |
| 4030 radii[2] = radii[0]; | 4030 radii[2] = radii[0]; |
| 4031 } | 4031 } |
| 4032 radii[3] = radii[1]; | 4032 radii[3] = radii[1]; |
| 4033 } | 4033 } |
| 4034 | 4034 |
| 4035 // FIXME: This should be refactored with parseBorderRadius. | 4035 // FIXME: This should be refactored with parseBorderRadius. |
| 4036 // parseBorderRadius contains support for some legacy radius construction. | 4036 // parseBorderRadius contains support for some legacy radius construction. |
| 4037 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseInsetRoundedCorner
s(PassRefPtrWillBeRawPtr<CSSBasicShapeInset> shape, CSSParserValueList* args) | 4037 PassRefPtr<CSSBasicShape> CSSPropertyParser::parseInsetRoundedCorners(PassRefPtr
<CSSBasicShapeInset> shape, CSSParserValueList* args) |
| 4038 { | 4038 { |
| 4039 CSSParserValue* argument = args->next(); | 4039 CSSParserValue* argument = args->next(); |
| 4040 | 4040 |
| 4041 if (!argument) | 4041 if (!argument) |
| 4042 return nullptr; | 4042 return nullptr; |
| 4043 | 4043 |
| 4044 Vector<CSSParserValue*> radiusArguments; | 4044 Vector<CSSParserValue*> radiusArguments; |
| 4045 while (argument) { | 4045 while (argument) { |
| 4046 radiusArguments.append(argument); | 4046 radiusArguments.append(argument); |
| 4047 argument = args->next(); | 4047 argument = args->next(); |
| 4048 } | 4048 } |
| 4049 | 4049 |
| 4050 unsigned num = radiusArguments.size(); | 4050 unsigned num = radiusArguments.size(); |
| 4051 if (!num || num > 9) | 4051 if (!num || num > 9) |
| 4052 return nullptr; | 4052 return nullptr; |
| 4053 | 4053 |
| 4054 // FIXME: Refactor completeBorderRadii and the array | 4054 // FIXME: Refactor completeBorderRadii and the array |
| 4055 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | 4055 RefPtr<CSSPrimitiveValue> radii[2][4]; |
| 4056 #if ENABLE(OILPAN) | 4056 #if ENABLE(OILPAN) |
| 4057 // Zero initialize the array of raw pointers. | 4057 // Zero initialize the array of raw pointers. |
| 4058 memset(&radii, 0, sizeof(radii)); | 4058 memset(&radii, 0, sizeof(radii)); |
| 4059 #endif | 4059 #endif |
| 4060 | 4060 |
| 4061 unsigned indexAfterSlash = 0; | 4061 unsigned indexAfterSlash = 0; |
| 4062 for (unsigned i = 0; i < num; ++i) { | 4062 for (unsigned i = 0; i < num; ++i) { |
| 4063 CSSParserValue* value = radiusArguments.at(i); | 4063 CSSParserValue* value = radiusArguments.at(i); |
| 4064 if (value->m_unit == CSSParserValue::Operator) { | 4064 if (value->m_unit == CSSParserValue::Operator) { |
| 4065 if (value->iValue != '/') | 4065 if (value->iValue != '/') |
| 4066 return nullptr; | 4066 return nullptr; |
| 4067 | 4067 |
| 4068 if (!i || indexAfterSlash || i + 1 == num) | 4068 if (!i || indexAfterSlash || i + 1 == num) |
| 4069 return nullptr; | 4069 return nullptr; |
| 4070 | 4070 |
| 4071 indexAfterSlash = i + 1; | 4071 indexAfterSlash = i + 1; |
| 4072 completeBorderRadii(radii[0]); | 4072 completeBorderRadii(radii[0]); |
| 4073 continue; | 4073 continue; |
| 4074 } | 4074 } |
| 4075 | 4075 |
| 4076 if (i - indexAfterSlash >= 4) | 4076 if (i - indexAfterSlash >= 4) |
| 4077 return nullptr; | 4077 return nullptr; |
| 4078 | 4078 |
| 4079 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 4079 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
| 4080 return nullptr; | 4080 return nullptr; |
| 4081 | 4081 |
| 4082 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal
ue(value); | 4082 RefPtr<CSSPrimitiveValue> radius = createPrimitiveNumericValue(value); |
| 4083 | 4083 |
| 4084 if (!indexAfterSlash) | 4084 if (!indexAfterSlash) |
| 4085 radii[0][i] = radius; | 4085 radii[0][i] = radius; |
| 4086 else | 4086 else |
| 4087 radii[1][i - indexAfterSlash] = radius.release(); | 4087 radii[1][i - indexAfterSlash] = radius.release(); |
| 4088 } | 4088 } |
| 4089 | 4089 |
| 4090 if (!indexAfterSlash) { | 4090 if (!indexAfterSlash) { |
| 4091 completeBorderRadii(radii[0]); | 4091 completeBorderRadii(radii[0]); |
| 4092 for (unsigned i = 0; i < 4; ++i) | 4092 for (unsigned i = 0; i < 4; ++i) |
| 4093 radii[1][i] = radii[0][i]; | 4093 radii[1][i] = radii[0][i]; |
| 4094 } else { | 4094 } else { |
| 4095 completeBorderRadii(radii[1]); | 4095 completeBorderRadii(radii[1]); |
| 4096 } | 4096 } |
| 4097 shape->setTopLeftRadius(createPrimitiveValuePair(radii[0][0].release(), radi
i[1][0].release())); | 4097 shape->setTopLeftRadius(createPrimitiveValuePair(radii[0][0].release(), radi
i[1][0].release())); |
| 4098 shape->setTopRightRadius(createPrimitiveValuePair(radii[0][1].release(), rad
ii[1][1].release())); | 4098 shape->setTopRightRadius(createPrimitiveValuePair(radii[0][1].release(), rad
ii[1][1].release())); |
| 4099 shape->setBottomRightRadius(createPrimitiveValuePair(radii[0][2].release(),
radii[1][2].release())); | 4099 shape->setBottomRightRadius(createPrimitiveValuePair(radii[0][2].release(),
radii[1][2].release())); |
| 4100 shape->setBottomLeftRadius(createPrimitiveValuePair(radii[0][3].release(), r
adii[1][3].release())); | 4100 shape->setBottomLeftRadius(createPrimitiveValuePair(radii[0][3].release(), r
adii[1][3].release())); |
| 4101 | 4101 |
| 4102 return shape; | 4102 return shape; |
| 4103 } | 4103 } |
| 4104 | 4104 |
| 4105 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS
SParserValueList* args) | 4105 PassRefPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CSSParserValue
List* args) |
| 4106 { | 4106 { |
| 4107 ASSERT(args); | 4107 ASSERT(args); |
| 4108 | 4108 |
| 4109 RefPtrWillBeRawPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create(); | 4109 RefPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create(); |
| 4110 | 4110 |
| 4111 CSSParserValue* argument = args->current(); | 4111 CSSParserValue* argument = args->current(); |
| 4112 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; | 4112 WillBeHeapVector<RefPtr<CSSPrimitiveValue>> widthArguments; |
| 4113 bool hasRoundedInset = false; | 4113 bool hasRoundedInset = false; |
| 4114 | 4114 |
| 4115 while (argument) { | 4115 while (argument) { |
| 4116 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS
SValueRound) { | 4116 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS
SValueRound) { |
| 4117 hasRoundedInset = true; | 4117 hasRoundedInset = true; |
| 4118 break; | 4118 break; |
| 4119 } | 4119 } |
| 4120 | 4120 |
| 4121 Units unitFlags = FLength | FPercent; | 4121 Units unitFlags = FLength | FPercent; |
| 4122 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) | 4122 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4199 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) | 4199 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) |
| 4200 return false; | 4200 return false; |
| 4201 } else { | 4201 } else { |
| 4202 return false; | 4202 return false; |
| 4203 } | 4203 } |
| 4204 | 4204 |
| 4205 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier
Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa
nt); | 4205 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier
Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa
nt); |
| 4206 return !m_valueList->next(); | 4206 return !m_valueList->next(); |
| 4207 } | 4207 } |
| 4208 | 4208 |
| 4209 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver
flowPosition() | 4209 PassRefPtr<CSSValue> CSSPropertyParser::parseContentDistributionOverflowPosition
() |
| 4210 { | 4210 { |
| 4211 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] | 4211 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] |
| 4212 // <baseline-position> = baseline | last-baseline; | 4212 // <baseline-position> = baseline | last-baseline; |
| 4213 // <content-distribution> = space-between | space-around | space-evenly | st
retch; | 4213 // <content-distribution> = space-between | space-around | space-evenly | st
retch; |
| 4214 // <content-position> = center | start | end | flex-start | flex-end | left
| right; | 4214 // <content-position> = center | start | end | flex-start | flex-end | left
| right; |
| 4215 // <overflow-position> = true | safe | 4215 // <overflow-position> = true | safe |
| 4216 | 4216 |
| 4217 // auto | <baseline-position> | 4217 // auto | <baseline-position> |
| 4218 CSSParserValue* value = m_valueList->current(); | 4218 CSSParserValue* value = m_valueList->current(); |
| 4219 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { | 4219 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4266 ASSERT(value); | 4266 ASSERT(value); |
| 4267 | 4267 |
| 4268 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselineP
ositionKeyword(value->id)) { | 4268 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselineP
ositionKeyword(value->id)) { |
| 4269 if (m_valueList->next()) | 4269 if (m_valueList->next()) |
| 4270 return false; | 4270 return false; |
| 4271 | 4271 |
| 4272 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); | 4272 addProperty(propId, cssValuePool().createIdentifierValue(value->id), imp
ortant); |
| 4273 return true; | 4273 return true; |
| 4274 } | 4274 } |
| 4275 | 4275 |
| 4276 RefPtrWillBeRawPtr<CSSPrimitiveValue> position = nullptr; | 4276 RefPtr<CSSPrimitiveValue> position = nullptr; |
| 4277 RefPtrWillBeRawPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr; | 4277 RefPtr<CSSPrimitiveValue> overflowAlignmentKeyword = nullptr; |
| 4278 if (isItemPositionKeyword(value->id)) { | 4278 if (isItemPositionKeyword(value->id)) { |
| 4279 position = cssValuePool().createIdentifierValue(value->id); | 4279 position = cssValuePool().createIdentifierValue(value->id); |
| 4280 value = m_valueList->next(); | 4280 value = m_valueList->next(); |
| 4281 if (value) { | 4281 if (value) { |
| 4282 if (isAlignmentOverflowKeyword(value->id)) | 4282 if (isAlignmentOverflowKeyword(value->id)) |
| 4283 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(
value->id); | 4283 overflowAlignmentKeyword = cssValuePool().createIdentifierValue(
value->id); |
| 4284 else | 4284 else |
| 4285 return false; | 4285 return false; |
| 4286 } | 4286 } |
| 4287 } else if (isAlignmentOverflowKeyword(value->id)) { | 4287 } else if (isAlignmentOverflowKeyword(value->id)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4300 | 4300 |
| 4301 ASSERT(position); | 4301 ASSERT(position); |
| 4302 if (overflowAlignmentKeyword) | 4302 if (overflowAlignmentKeyword) |
| 4303 addProperty(propId, createPrimitiveValuePair(position, overflowAlignment
Keyword), important); | 4303 addProperty(propId, createPrimitiveValuePair(position, overflowAlignment
Keyword), important); |
| 4304 else | 4304 else |
| 4305 addProperty(propId, position.release(), important); | 4305 addProperty(propId, position.release(), important); |
| 4306 | 4306 |
| 4307 return true; | 4307 return true; |
| 4308 } | 4308 } |
| 4309 | 4309 |
| 4310 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) | 4310 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CSSParserValue
* value) |
| 4311 { | 4311 { |
| 4312 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) | 4312 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) |
| 4313 return cssValuePool().createIdentifierValue(value->id); | 4313 return cssValuePool().createIdentifierValue(value->id); |
| 4314 | 4314 |
| 4315 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 4315 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
| 4316 return nullptr; | 4316 return nullptr; |
| 4317 | 4317 |
| 4318 return createPrimitiveNumericValue(value); | 4318 return createPrimitiveNumericValue(value); |
| 4319 } | 4319 } |
| 4320 | 4320 |
| 4321 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeCircle(C
SSParserValueList* args) | 4321 PassRefPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeCircle(CSSParserValu
eList* args) |
| 4322 { | 4322 { |
| 4323 ASSERT(args); | 4323 ASSERT(args); |
| 4324 | 4324 |
| 4325 // circle(radius) | 4325 // circle(radius) |
| 4326 // circle(radius at <position>) | 4326 // circle(radius at <position>) |
| 4327 // circle(at <position>) | 4327 // circle(at <position>) |
| 4328 // where position defines centerX and centerY using a CSS <position> data ty
pe. | 4328 // where position defines centerX and centerY using a CSS <position> data ty
pe. |
| 4329 RefPtrWillBeRawPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(
); | 4329 RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create(); |
| 4330 | 4330 |
| 4331 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | 4331 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { |
| 4332 // The call to parseFillPosition below should consume all of the | 4332 // The call to parseFillPosition below should consume all of the |
| 4333 // arguments except the first two. Thus, and index greater than one | 4333 // arguments except the first two. Thus, and index greater than one |
| 4334 // indicates an invalid production. | 4334 // indicates an invalid production. |
| 4335 if (args->currentIndex() > 1) | 4335 if (args->currentIndex() > 1) |
| 4336 return nullptr; | 4336 return nullptr; |
| 4337 | 4337 |
| 4338 if (!args->currentIndex() && argument->id != CSSValueAt) { | 4338 if (!args->currentIndex() && argument->id != CSSValueAt) { |
| 4339 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | 4339 if (RefPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) { |
| 4340 shape->setRadius(radius); | 4340 shape->setRadius(radius); |
| 4341 continue; | 4341 continue; |
| 4342 } | 4342 } |
| 4343 | 4343 |
| 4344 return nullptr; | 4344 return nullptr; |
| 4345 } | 4345 } |
| 4346 | 4346 |
| 4347 if (argument->id == CSSValueAt && args->next()) { | 4347 if (argument->id == CSSValueAt && args->next()) { |
| 4348 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 4348 RefPtr<CSSValue> centerX = nullptr; |
| 4349 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 4349 RefPtr<CSSValue> centerY = nullptr; |
| 4350 parseFillPosition(args, centerX, centerY); | 4350 parseFillPosition(args, centerX, centerY); |
| 4351 if (centerX && centerY && !args->current()) { | 4351 if (centerX && centerY && !args->current()) { |
| 4352 ASSERT(centerX->isPrimitiveValue()); | 4352 ASSERT(centerX->isPrimitiveValue()); |
| 4353 ASSERT(centerY->isPrimitiveValue()); | 4353 ASSERT(centerY->isPrimitiveValue()); |
| 4354 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | 4354 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); |
| 4355 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | 4355 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); |
| 4356 } else { | 4356 } else { |
| 4357 return nullptr; | 4357 return nullptr; |
| 4358 } | 4358 } |
| 4359 } else { | 4359 } else { |
| 4360 return nullptr; | 4360 return nullptr; |
| 4361 } | 4361 } |
| 4362 } | 4362 } |
| 4363 | 4363 |
| 4364 return shape; | 4364 return shape; |
| 4365 } | 4365 } |
| 4366 | 4366 |
| 4367 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeEllipse(
CSSParserValueList* args) | 4367 PassRefPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeEllipse(CSSParserVal
ueList* args) |
| 4368 { | 4368 { |
| 4369 ASSERT(args); | 4369 ASSERT(args); |
| 4370 | 4370 |
| 4371 // ellipse(radiusX) | 4371 // ellipse(radiusX) |
| 4372 // ellipse(radiusX at <position>) | 4372 // ellipse(radiusX at <position>) |
| 4373 // ellipse(radiusX radiusY) | 4373 // ellipse(radiusX radiusY) |
| 4374 // ellipse(radiusX radiusY at <position>) | 4374 // ellipse(radiusX radiusY at <position>) |
| 4375 // ellipse(at <position>) | 4375 // ellipse(at <position>) |
| 4376 // where position defines centerX and centerY using a CSS <position> data ty
pe. | 4376 // where position defines centerX and centerY using a CSS <position> data ty
pe. |
| 4377 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::creat
e(); | 4377 RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create(); |
| 4378 | 4378 |
| 4379 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { | 4379 for (CSSParserValue* argument = args->current(); argument; argument = args->
next()) { |
| 4380 // The call to parseFillPosition below should consume all of the | 4380 // The call to parseFillPosition below should consume all of the |
| 4381 // arguments except the first three. Thus, an index greater than two | 4381 // arguments except the first three. Thus, an index greater than two |
| 4382 // indicates an invalid production. | 4382 // indicates an invalid production. |
| 4383 if (args->currentIndex() > 2) | 4383 if (args->currentIndex() > 2) |
| 4384 return nullptr; | 4384 return nullptr; |
| 4385 | 4385 |
| 4386 if (args->currentIndex() < 2 && argument->id != CSSValueAt) { | 4386 if (args->currentIndex() < 2 && argument->id != CSSValueAt) { |
| 4387 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | 4387 if (RefPtr<CSSPrimitiveValue> radius = parseShapeRadius(argument)) { |
| 4388 if (!shape->radiusX()) | 4388 if (!shape->radiusX()) |
| 4389 shape->setRadiusX(radius); | 4389 shape->setRadiusX(radius); |
| 4390 else | 4390 else |
| 4391 shape->setRadiusY(radius); | 4391 shape->setRadiusY(radius); |
| 4392 continue; | 4392 continue; |
| 4393 } | 4393 } |
| 4394 | 4394 |
| 4395 return nullptr; | 4395 return nullptr; |
| 4396 } | 4396 } |
| 4397 | 4397 |
| 4398 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) | 4398 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) |
| 4399 return nullptr; | 4399 return nullptr; |
| 4400 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 4400 RefPtr<CSSValue> centerX = nullptr; |
| 4401 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 4401 RefPtr<CSSValue> centerY = nullptr; |
| 4402 parseFillPosition(args, centerX, centerY); | 4402 parseFillPosition(args, centerX, centerY); |
| 4403 if (!centerX || !centerY || args->current()) | 4403 if (!centerX || !centerY || args->current()) |
| 4404 return nullptr; | 4404 return nullptr; |
| 4405 | 4405 |
| 4406 ASSERT(centerX->isPrimitiveValue()); | 4406 ASSERT(centerX->isPrimitiveValue()); |
| 4407 ASSERT(centerY->isPrimitiveValue()); | 4407 ASSERT(centerY->isPrimitiveValue()); |
| 4408 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | 4408 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); |
| 4409 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | 4409 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); |
| 4410 } | 4410 } |
| 4411 | 4411 |
| 4412 return shape; | 4412 return shape; |
| 4413 } | 4413 } |
| 4414 | 4414 |
| 4415 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) | 4415 PassRefPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(CSSParserVal
ueList* args) |
| 4416 { | 4416 { |
| 4417 ASSERT(args); | 4417 ASSERT(args); |
| 4418 | 4418 |
| 4419 unsigned size = args->size(); | 4419 unsigned size = args->size(); |
| 4420 if (!size) | 4420 if (!size) |
| 4421 return nullptr; | 4421 return nullptr; |
| 4422 | 4422 |
| 4423 RefPtrWillBeRawPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::creat
e(); | 4423 RefPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::create(); |
| 4424 | 4424 |
| 4425 CSSParserValue* argument = args->current(); | 4425 CSSParserValue* argument = args->current(); |
| 4426 if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { | 4426 if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) { |
| 4427 shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE
_NONZERO); | 4427 shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE
_NONZERO); |
| 4428 args->next(); | 4428 args->next(); |
| 4429 | 4429 |
| 4430 if (!consumeComma(args)) | 4430 if (!consumeComma(args)) |
| 4431 return nullptr; | 4431 return nullptr; |
| 4432 | 4432 |
| 4433 size -= 2; | 4433 size -= 2; |
| 4434 } | 4434 } |
| 4435 | 4435 |
| 4436 // <length> <length>, ... <length> <length> -> each pair has 3 elements exce
pt the last one | 4436 // <length> <length>, ... <length> <length> -> each pair has 3 elements exce
pt the last one |
| 4437 if (!size || (size % 3) - 2) | 4437 if (!size || (size % 3) - 2) |
| 4438 return nullptr; | 4438 return nullptr; |
| 4439 | 4439 |
| 4440 while (true) { | 4440 while (true) { |
| 4441 CSSParserValue* argumentX = args->current(); | 4441 CSSParserValue* argumentX = args->current(); |
| 4442 if (!argumentX || !validUnit(argumentX, FLength | FPercent)) | 4442 if (!argumentX || !validUnit(argumentX, FLength | FPercent)) |
| 4443 return nullptr; | 4443 return nullptr; |
| 4444 RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericVa
lue(argumentX); | 4444 RefPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericValue(argument
X); |
| 4445 | 4445 |
| 4446 CSSParserValue* argumentY = args->next(); | 4446 CSSParserValue* argumentY = args->next(); |
| 4447 if (!argumentY || !validUnit(argumentY, FLength | FPercent)) | 4447 if (!argumentY || !validUnit(argumentY, FLength | FPercent)) |
| 4448 return nullptr; | 4448 return nullptr; |
| 4449 RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericVa
lue(argumentY); | 4449 RefPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericValue(argument
Y); |
| 4450 | 4450 |
| 4451 shape->appendPoint(xLength.release(), yLength.release()); | 4451 shape->appendPoint(xLength.release(), yLength.release()); |
| 4452 | 4452 |
| 4453 if (!args->next()) | 4453 if (!args->next()) |
| 4454 break; | 4454 break; |
| 4455 if (!consumeComma(args)) | 4455 if (!consumeComma(args)) |
| 4456 return nullptr; | 4456 return nullptr; |
| 4457 } | 4457 } |
| 4458 | 4458 |
| 4459 return shape; | 4459 return shape; |
| 4460 } | 4460 } |
| 4461 | 4461 |
| 4462 static bool isBoxValue(CSSValueID valueId) | 4462 static bool isBoxValue(CSSValueID valueId) |
| 4463 { | 4463 { |
| 4464 switch (valueId) { | 4464 switch (valueId) { |
| 4465 case CSSValueContentBox: | 4465 case CSSValueContentBox: |
| 4466 case CSSValuePaddingBox: | 4466 case CSSValuePaddingBox: |
| 4467 case CSSValueBorderBox: | 4467 case CSSValueBorderBox: |
| 4468 case CSSValueMarginBox: | 4468 case CSSValueMarginBox: |
| 4469 return true; | 4469 return true; |
| 4470 default: | 4470 default: |
| 4471 break; | 4471 break; |
| 4472 } | 4472 } |
| 4473 | 4473 |
| 4474 return false; | 4474 return false; |
| 4475 } | 4475 } |
| 4476 | 4476 |
| 4477 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
tyID propId) | 4477 PassRefPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSPropertyID propId) |
| 4478 { | 4478 { |
| 4479 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; | 4479 RefPtr<CSSValue> imageValue = nullptr; |
| 4480 if (parseFillImage(m_valueList, imageValue)) { | 4480 if (parseFillImage(m_valueList, imageValue)) { |
| 4481 m_valueList->next(); | 4481 m_valueList->next(); |
| 4482 return imageValue.release(); | 4482 return imageValue.release(); |
| 4483 } | 4483 } |
| 4484 | 4484 |
| 4485 return parseBasicShapeAndOrBox(); | 4485 return parseBasicShapeAndOrBox(); |
| 4486 } | 4486 } |
| 4487 | 4487 |
| 4488 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() | 4488 PassRefPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() |
| 4489 { | 4489 { |
| 4490 CSSParserValue* value = m_valueList->current(); | 4490 CSSParserValue* value = m_valueList->current(); |
| 4491 | 4491 |
| 4492 bool shapeFound = false; | 4492 bool shapeFound = false; |
| 4493 bool boxFound = false; | 4493 bool boxFound = false; |
| 4494 CSSValueID valueId; | 4494 CSSValueID valueId; |
| 4495 | 4495 |
| 4496 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 4496 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 4497 for (unsigned i = 0; i < 2; ++i) { | 4497 for (unsigned i = 0; i < 2; ++i) { |
| 4498 if (!value) | 4498 if (!value) |
| 4499 break; | 4499 break; |
| 4500 valueId = value->id; | 4500 valueId = value->id; |
| 4501 if (value->m_unit == CSSParserValue::Function && !shapeFound) { | 4501 if (value->m_unit == CSSParserValue::Function && !shapeFound) { |
| 4502 // parseBasicShape already asks for the next value list item. | 4502 // parseBasicShape already asks for the next value list item. |
| 4503 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = parseBasicShape()
; | 4503 RefPtr<CSSPrimitiveValue> shapeValue = parseBasicShape(); |
| 4504 if (!shapeValue) | 4504 if (!shapeValue) |
| 4505 return nullptr; | 4505 return nullptr; |
| 4506 list->append(shapeValue.release()); | 4506 list->append(shapeValue.release()); |
| 4507 shapeFound = true; | 4507 shapeFound = true; |
| 4508 } else if (isBoxValue(valueId) && !boxFound) { | 4508 } else if (isBoxValue(valueId) && !boxFound) { |
| 4509 list->append(parseValidPrimitive(valueId, value)); | 4509 list->append(parseValidPrimitive(valueId, value)); |
| 4510 boxFound = true; | 4510 boxFound = true; |
| 4511 m_valueList->next(); | 4511 m_valueList->next(); |
| 4512 } else { | 4512 } else { |
| 4513 return nullptr; | 4513 return nullptr; |
| 4514 } | 4514 } |
| 4515 | 4515 |
| 4516 value = m_valueList->current(); | 4516 value = m_valueList->current(); |
| 4517 } | 4517 } |
| 4518 | 4518 |
| 4519 if (m_valueList->current()) | 4519 if (m_valueList->current()) |
| 4520 return nullptr; | 4520 return nullptr; |
| 4521 return list.release(); | 4521 return list.release(); |
| 4522 } | 4522 } |
| 4523 | 4523 |
| 4524 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseBasicShape() | 4524 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseBasicShape() |
| 4525 { | 4525 { |
| 4526 CSSParserValue* value = m_valueList->current(); | 4526 CSSParserValue* value = m_valueList->current(); |
| 4527 ASSERT(value->m_unit == CSSParserValue::Function); | 4527 ASSERT(value->m_unit == CSSParserValue::Function); |
| 4528 CSSParserValueList* args = value->function->args.get(); | 4528 CSSParserValueList* args = value->function->args.get(); |
| 4529 | 4529 |
| 4530 if (!args) | 4530 if (!args) |
| 4531 return nullptr; | 4531 return nullptr; |
| 4532 | 4532 |
| 4533 RefPtrWillBeRawPtr<CSSBasicShape> shape = nullptr; | 4533 RefPtr<CSSBasicShape> shape = nullptr; |
| 4534 if (value->function->id == CSSValueCircle) | 4534 if (value->function->id == CSSValueCircle) |
| 4535 shape = parseBasicShapeCircle(args); | 4535 shape = parseBasicShapeCircle(args); |
| 4536 else if (value->function->id == CSSValueEllipse) | 4536 else if (value->function->id == CSSValueEllipse) |
| 4537 shape = parseBasicShapeEllipse(args); | 4537 shape = parseBasicShapeEllipse(args); |
| 4538 else if (value->function->id == CSSValuePolygon) | 4538 else if (value->function->id == CSSValuePolygon) |
| 4539 shape = parseBasicShapePolygon(args); | 4539 shape = parseBasicShapePolygon(args); |
| 4540 else if (value->function->id == CSSValueInset) | 4540 else if (value->function->id == CSSValueInset) |
| 4541 shape = parseBasicShapeInset(args); | 4541 shape = parseBasicShapeInset(args); |
| 4542 | 4542 |
| 4543 if (!shape) | 4543 if (!shape) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4601 | 4601 |
| 4602 value = m_valueList->current(); | 4602 value = m_valueList->current(); |
| 4603 if (!value) | 4603 if (!value) |
| 4604 return false; | 4604 return false; |
| 4605 | 4605 |
| 4606 if (isForwardSlashOperator(value)) { | 4606 if (isForwardSlashOperator(value)) { |
| 4607 // The line-height property. | 4607 // The line-height property. |
| 4608 value = m_valueList->next(); | 4608 value = m_valueList->next(); |
| 4609 if (!value) | 4609 if (!value) |
| 4610 return false; | 4610 return false; |
| 4611 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); | 4611 RefPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); |
| 4612 if (!lineHeight) | 4612 if (!lineHeight) |
| 4613 return false; | 4613 return false; |
| 4614 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); | 4614 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); |
| 4615 } else { | 4615 } else { |
| 4616 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important, true); | 4616 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important, true); |
| 4617 } | 4617 } |
| 4618 | 4618 |
| 4619 // Font family must come now. | 4619 // Font family must come now. |
| 4620 RefPtrWillBeRawPtr<CSSValue> parsedFamilyValue = parseFontFamily(); | 4620 RefPtr<CSSValue> parsedFamilyValue = parseFontFamily(); |
| 4621 if (!parsedFamilyValue) | 4621 if (!parsedFamilyValue) |
| 4622 return false; | 4622 return false; |
| 4623 | 4623 |
| 4624 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); | 4624 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); |
| 4625 | 4625 |
| 4626 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that | 4626 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that |
| 4627 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values | 4627 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values |
| 4628 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. | 4628 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. |
| 4629 if (m_valueList->current()) | 4629 if (m_valueList->current()) |
| 4630 return false; | 4630 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4642 FontStyle fontStyle = FontStyleNormal; | 4642 FontStyle fontStyle = FontStyleNormal; |
| 4643 FontWeight fontWeight = FontWeightNormal; | 4643 FontWeight fontWeight = FontWeightNormal; |
| 4644 float fontSize = 0; | 4644 float fontSize = 0; |
| 4645 AtomicString fontFamily; | 4645 AtomicString fontFamily; |
| 4646 LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz
e, fontFamily); | 4646 LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz
e, fontFamily); |
| 4647 | 4647 |
| 4648 ShorthandScope scope(this, CSSPropertyFont); | 4648 ShorthandScope scope(this, CSSPropertyFont); |
| 4649 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontS
tyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important); | 4649 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontS
tyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important); |
| 4650 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i
mportant); | 4650 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i
mportant); |
| 4651 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri
mitiveValue::UnitType::Pixels), important); | 4651 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri
mitiveValue::UnitType::Pixels), important); |
| 4652 RefPtrWillBeRawPtr<CSSValueList> fontFamilyList = CSSValueList::createCommaS
eparated(); | 4652 RefPtr<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated(); |
| 4653 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily)); | 4653 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily)); |
| 4654 addProperty(CSSPropertyFontFamily, fontFamilyList.release(), important); | 4654 addProperty(CSSPropertyFontFamily, fontFamilyList.release(), important); |
| 4655 | 4655 |
| 4656 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); | 4656 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); |
| 4657 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); | 4657 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); |
| 4658 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV
alueNormal), important); | 4658 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV
alueNormal), important); |
| 4659 return true; | 4659 return true; |
| 4660 } | 4660 } |
| 4661 | 4661 |
| 4662 class FontFamilyValueBuilder { | 4662 class FontFamilyValueBuilder { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4683 void commit() | 4683 void commit() |
| 4684 { | 4684 { |
| 4685 if (m_builder.isEmpty()) | 4685 if (m_builder.isEmpty()) |
| 4686 return; | 4686 return; |
| 4687 m_list->append(cssValuePool().createFontFamilyValue(m_builder.toString()
)); | 4687 m_list->append(cssValuePool().createFontFamilyValue(m_builder.toString()
)); |
| 4688 m_builder.clear(); | 4688 m_builder.clear(); |
| 4689 } | 4689 } |
| 4690 | 4690 |
| 4691 private: | 4691 private: |
| 4692 StringBuilder m_builder; | 4692 StringBuilder m_builder; |
| 4693 RawPtrWillBeMember<CSSValueList> m_list; | 4693 RawPtr<CSSValueList> m_list; |
| 4694 }; | 4694 }; |
| 4695 | 4695 |
| 4696 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFamily() | 4696 PassRefPtr<CSSValueList> CSSPropertyParser::parseFontFamily() |
| 4697 { | 4697 { |
| 4698 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 4698 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
| 4699 CSSParserValue* value = m_valueList->current(); | 4699 CSSParserValue* value = m_valueList->current(); |
| 4700 | 4700 |
| 4701 FontFamilyValueBuilder familyBuilder(list.get()); | 4701 FontFamilyValueBuilder familyBuilder(list.get()); |
| 4702 bool inFamily = false; | 4702 bool inFamily = false; |
| 4703 | 4703 |
| 4704 while (value) { | 4704 while (value) { |
| 4705 CSSParserValue* nextValue = m_valueList->next(); | 4705 CSSParserValue* nextValue = m_valueList->next(); |
| 4706 bool nextValBreaksFont = !nextValue || isComma(nextValue); | 4706 bool nextValBreaksFont = !nextValue || isComma(nextValue); |
| 4707 bool nextValIsFontName = nextValue && | 4707 bool nextValIsFontName = nextValue && |
| 4708 ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitB
ody) || | 4708 ((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitB
ody) || |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4757 value = nextValue; | 4757 value = nextValue; |
| 4758 else | 4758 else |
| 4759 break; | 4759 break; |
| 4760 } | 4760 } |
| 4761 familyBuilder.commit(); | 4761 familyBuilder.commit(); |
| 4762 if (!list->length() || (m_ruleType == StyleRule::FontFace && list->length()
> 1)) | 4762 if (!list->length() || (m_ruleType == StyleRule::FontFace && list->length()
> 1)) |
| 4763 list = nullptr; | 4763 list = nullptr; |
| 4764 return list.release(); | 4764 return list.release(); |
| 4765 } | 4765 } |
| 4766 | 4766 |
| 4767 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseLineHeight() | 4767 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseLineHeight() |
| 4768 { | 4768 { |
| 4769 CSSParserValue* value = m_valueList->current(); | 4769 CSSParserValue* value = m_valueList->current(); |
| 4770 CSSValueID id = value->id; | 4770 CSSValueID id = value->id; |
| 4771 | 4771 |
| 4772 // normal | <number> | <length> | <percentage> | inherit | 4772 // normal | <number> | <length> | <percentage> | inherit |
| 4773 if (id == CSSValueNormal) { | 4773 if (id == CSSValueNormal) { |
| 4774 m_valueList->next(); | 4774 m_valueList->next(); |
| 4775 return cssValuePool().createIdentifierValue(id); | 4775 return cssValuePool().createIdentifierValue(id); |
| 4776 } | 4776 } |
| 4777 | 4777 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4797 validPrimitive = true; | 4797 validPrimitive = true; |
| 4798 else | 4798 else |
| 4799 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg | (inShor
thand() ? FUnknown : FUnitlessQuirk)); | 4799 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg | (inShor
thand() ? FUnknown : FUnitlessQuirk)); |
| 4800 if (validPrimitive && (!m_valueList->next() || inShorthand())) | 4800 if (validPrimitive && (!m_valueList->next() || inShorthand())) |
| 4801 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); | 4801 addProperty(CSSPropertyFontSize, parseValidPrimitive(id, value), importa
nt); |
| 4802 return validPrimitive; | 4802 return validPrimitive; |
| 4803 } | 4803 } |
| 4804 | 4804 |
| 4805 bool CSSPropertyParser::parseFontVariant(bool important) | 4805 bool CSSPropertyParser::parseFontVariant(bool important) |
| 4806 { | 4806 { |
| 4807 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | 4807 RefPtr<CSSValueList> values = nullptr; |
| 4808 if (m_valueList->size() > 1) | 4808 if (m_valueList->size() > 1) |
| 4809 values = CSSValueList::createCommaSeparated(); | 4809 values = CSSValueList::createCommaSeparated(); |
| 4810 bool expectComma = false; | 4810 bool expectComma = false; |
| 4811 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->c
urrent()) { | 4811 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->c
urrent()) { |
| 4812 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue = nullptr; | 4812 RefPtr<CSSPrimitiveValue> parsedValue = nullptr; |
| 4813 if (!expectComma) { | 4813 if (!expectComma) { |
| 4814 expectComma = true; | 4814 expectComma = true; |
| 4815 if (val->id == CSSValueNormal || val->id == CSSValueSmallCaps) | 4815 if (val->id == CSSValueNormal || val->id == CSSValueSmallCaps) |
| 4816 parsedValue = cssValuePool().createIdentifierValue(val->id); | 4816 parsedValue = cssValuePool().createIdentifierValue(val->id); |
| 4817 else if (val->id == CSSValueAll && !values) { | 4817 else if (val->id == CSSValueAll && !values) { |
| 4818 // FIXME: CSSPropertyParser::parseFontVariant() implements | 4818 // FIXME: CSSPropertyParser::parseFontVariant() implements |
| 4819 // the old css3 draft: | 4819 // the old css3 draft: |
| 4820 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-var
iant | 4820 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-var
iant |
| 4821 // 'all' is only allowed in @font-face and with no other values.
Make a value list to | 4821 // 'all' is only allowed in @font-face and with no other values.
Make a value list to |
| 4822 // indicate that we are in the @font-face case. | 4822 // indicate that we are in the @font-face case. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4863 if (!(weight % 100) && weight >= 100 && weight <= 900) { | 4863 if (!(weight % 100) && weight >= 100 && weight <= 900) { |
| 4864 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); | 4864 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); |
| 4865 return true; | 4865 return true; |
| 4866 } | 4866 } |
| 4867 } | 4867 } |
| 4868 return false; | 4868 return false; |
| 4869 } | 4869 } |
| 4870 | 4870 |
| 4871 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) | 4871 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) |
| 4872 { | 4872 { |
| 4873 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(m_valueList->current()->string), m_context.shouldCheckContentSecuri
tyPolicy())); | 4873 RefPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL
(m_valueList->current()->string), m_context.shouldCheckContentSecurityPolicy()))
; |
| 4874 uriValue->setReferrer(m_context.referrer()); | 4874 uriValue->setReferrer(m_context.referrer()); |
| 4875 | 4875 |
| 4876 CSSParserValue* value = m_valueList->next(); | 4876 CSSParserValue* value = m_valueList->next(); |
| 4877 if (!value || value->m_unit != CSSParserValue::Function || value->function->
id != CSSValueFormat) { | 4877 if (!value || value->m_unit != CSSParserValue::Function || value->function->
id != CSSValueFormat) { |
| 4878 valueList->append(uriValue.release()); | 4878 valueList->append(uriValue.release()); |
| 4879 return true; | 4879 return true; |
| 4880 } | 4880 } |
| 4881 | 4881 |
| 4882 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format
() contains a comma-separated list of strings, | 4882 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format
() contains a comma-separated list of strings, |
| 4883 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. | 4883 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4909 builder.append(' '); | 4909 builder.append(' '); |
| 4910 builder.append(localValue->string); | 4910 builder.append(localValue->string); |
| 4911 } | 4911 } |
| 4912 valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString(), s
houldCheckContentSecurityPolicy)); | 4912 valueList->append(CSSFontFaceSrcValue::createLocal(builder.toString(), s
houldCheckContentSecurityPolicy)); |
| 4913 } else | 4913 } else |
| 4914 return false; | 4914 return false; |
| 4915 | 4915 |
| 4916 return true; | 4916 return true; |
| 4917 } | 4917 } |
| 4918 | 4918 |
| 4919 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc() | 4919 PassRefPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc() |
| 4920 { | 4920 { |
| 4921 RefPtrWillBeRawPtr<CSSValueList> values(CSSValueList::createCommaSeparated()
); | 4921 RefPtr<CSSValueList> values(CSSValueList::createCommaSeparated()); |
| 4922 | 4922 |
| 4923 while (true) { | 4923 while (true) { |
| 4924 CSSParserValue* value = m_valueList->current(); | 4924 CSSParserValue* value = m_valueList->current(); |
| 4925 if (!value) | 4925 if (!value) |
| 4926 return nullptr; | 4926 return nullptr; |
| 4927 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { | 4927 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 4928 if (!parseFontFaceSrcURI(values.get())) | 4928 if (!parseFontFaceSrcURI(values.get())) |
| 4929 return nullptr; | 4929 return nullptr; |
| 4930 } else if (value->m_unit == CSSParserValue::Function && value->function-
>id == CSSValueLocal) { | 4930 } else if (value->m_unit == CSSParserValue::Function && value->function-
>id == CSSValueLocal) { |
| 4931 if (!parseFontFaceSrcLocal(values.get())) | 4931 if (!parseFontFaceSrcLocal(values.get())) |
| 4932 return nullptr; | 4932 return nullptr; |
| 4933 } else { | 4933 } else { |
| 4934 return nullptr; | 4934 return nullptr; |
| 4935 } | 4935 } |
| 4936 | 4936 |
| 4937 if (!m_valueList->current()) | 4937 if (!m_valueList->current()) |
| 4938 return values.release(); | 4938 return values.release(); |
| 4939 if (!consumeComma(m_valueList)) | 4939 if (!consumeComma(m_valueList)) |
| 4940 return nullptr; | 4940 return nullptr; |
| 4941 } | 4941 } |
| 4942 } | 4942 } |
| 4943 | 4943 |
| 4944 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRang
e() | 4944 PassRefPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRange() |
| 4945 { | 4945 { |
| 4946 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 4946 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); |
| 4947 | 4947 |
| 4948 do { | 4948 do { |
| 4949 CSSParserValue* current = m_valueList->current(); | 4949 CSSParserValue* current = m_valueList->current(); |
| 4950 if (!current || current->m_unit != CSSParserValue::UnicodeRange) | 4950 if (!current || current->m_unit != CSSParserValue::UnicodeRange) |
| 4951 return nullptr; | 4951 return nullptr; |
| 4952 | 4952 |
| 4953 UChar32 start = current->m_unicodeRange.start; | 4953 UChar32 start = current->m_unicodeRange.start; |
| 4954 UChar32 end = current->m_unicodeRange.end; | 4954 UChar32 end = current->m_unicodeRange.end; |
| 4955 if (start > end) | 4955 if (start > end) |
| 4956 return nullptr; | 4956 return nullptr; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5178 | 5178 |
| 5179 allowX = true; | 5179 allowX = true; |
| 5180 allowColor = true; | 5180 allowColor = true; |
| 5181 allowBreak = true; | 5181 allowBreak = true; |
| 5182 allowY = false; | 5182 allowY = false; |
| 5183 allowBlur = false; | 5183 allowBlur = false; |
| 5184 allowSpread = false; | 5184 allowSpread = false; |
| 5185 allowStyle = property == CSSPropertyBoxShadow; | 5185 allowStyle = property == CSSPropertyBoxShadow; |
| 5186 } | 5186 } |
| 5187 | 5187 |
| 5188 void commitLength(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) | 5188 void commitLength(PassRefPtr<CSSPrimitiveValue> val) |
| 5189 { | 5189 { |
| 5190 if (allowX) { | 5190 if (allowX) { |
| 5191 x = val; | 5191 x = val; |
| 5192 allowX = false; | 5192 allowX = false; |
| 5193 allowY = true; | 5193 allowY = true; |
| 5194 allowColor = false; | 5194 allowColor = false; |
| 5195 allowStyle = false; | 5195 allowStyle = false; |
| 5196 allowBreak = false; | 5196 allowBreak = false; |
| 5197 } else if (allowY) { | 5197 } else if (allowY) { |
| 5198 y = val; | 5198 y = val; |
| 5199 allowY = false; | 5199 allowY = false; |
| 5200 allowBlur = true; | 5200 allowBlur = true; |
| 5201 allowColor = true; | 5201 allowColor = true; |
| 5202 allowStyle = property == CSSPropertyBoxShadow; | 5202 allowStyle = property == CSSPropertyBoxShadow; |
| 5203 allowBreak = true; | 5203 allowBreak = true; |
| 5204 } else if (allowBlur) { | 5204 } else if (allowBlur) { |
| 5205 blur = val; | 5205 blur = val; |
| 5206 allowBlur = false; | 5206 allowBlur = false; |
| 5207 allowSpread = property == CSSPropertyBoxShadow; | 5207 allowSpread = property == CSSPropertyBoxShadow; |
| 5208 } else if (allowSpread) { | 5208 } else if (allowSpread) { |
| 5209 spread = val; | 5209 spread = val; |
| 5210 allowSpread = false; | 5210 allowSpread = false; |
| 5211 } | 5211 } |
| 5212 } | 5212 } |
| 5213 | 5213 |
| 5214 void commitColor(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) | 5214 void commitColor(PassRefPtr<CSSPrimitiveValue> val) |
| 5215 { | 5215 { |
| 5216 color = val; | 5216 color = val; |
| 5217 allowColor = false; | 5217 allowColor = false; |
| 5218 if (allowX) { | 5218 if (allowX) { |
| 5219 allowStyle = false; | 5219 allowStyle = false; |
| 5220 allowBreak = false; | 5220 allowBreak = false; |
| 5221 } else { | 5221 } else { |
| 5222 allowBlur = false; | 5222 allowBlur = false; |
| 5223 allowSpread = false; | 5223 allowSpread = false; |
| 5224 allowStyle = property == CSSPropertyBoxShadow; | 5224 allowStyle = property == CSSPropertyBoxShadow; |
| 5225 } | 5225 } |
| 5226 } | 5226 } |
| 5227 | 5227 |
| 5228 void commitStyle(CSSParserValue* v) | 5228 void commitStyle(CSSParserValue* v) |
| 5229 { | 5229 { |
| 5230 style = cssValuePool().createIdentifierValue(v->id); | 5230 style = cssValuePool().createIdentifierValue(v->id); |
| 5231 allowStyle = false; | 5231 allowStyle = false; |
| 5232 if (allowX) | 5232 if (allowX) |
| 5233 allowBreak = false; | 5233 allowBreak = false; |
| 5234 else { | 5234 else { |
| 5235 allowBlur = false; | 5235 allowBlur = false; |
| 5236 allowSpread = false; | 5236 allowSpread = false; |
| 5237 allowColor = false; | 5237 allowColor = false; |
| 5238 } | 5238 } |
| 5239 } | 5239 } |
| 5240 | 5240 |
| 5241 CSSPropertyID property; | 5241 CSSPropertyID property; |
| 5242 | 5242 |
| 5243 RefPtrWillBeMember<CSSValueList> values; | 5243 RefPtr<CSSValueList> values; |
| 5244 RefPtrWillBeMember<CSSPrimitiveValue> x; | 5244 RefPtr<CSSPrimitiveValue> x; |
| 5245 RefPtrWillBeMember<CSSPrimitiveValue> y; | 5245 RefPtr<CSSPrimitiveValue> y; |
| 5246 RefPtrWillBeMember<CSSPrimitiveValue> blur; | 5246 RefPtr<CSSPrimitiveValue> blur; |
| 5247 RefPtrWillBeMember<CSSPrimitiveValue> spread; | 5247 RefPtr<CSSPrimitiveValue> spread; |
| 5248 RefPtrWillBeMember<CSSPrimitiveValue> style; | 5248 RefPtr<CSSPrimitiveValue> style; |
| 5249 RefPtrWillBeMember<CSSPrimitiveValue> color; | 5249 RefPtr<CSSPrimitiveValue> color; |
| 5250 | 5250 |
| 5251 bool allowX; | 5251 bool allowX; |
| 5252 bool allowY; | 5252 bool allowY; |
| 5253 bool allowBlur; | 5253 bool allowBlur; |
| 5254 bool allowSpread; | 5254 bool allowSpread; |
| 5255 bool allowColor; | 5255 bool allowColor; |
| 5256 bool allowStyle; // inset or not. | 5256 bool allowStyle; // inset or not. |
| 5257 bool allowBreak; | 5257 bool allowBreak; |
| 5258 }; | 5258 }; |
| 5259 | 5259 |
| 5260 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserVal
ueList* valueList, CSSPropertyID propId) | 5260 PassRefPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserValueList* valu
eList, CSSPropertyID propId) |
| 5261 { | 5261 { |
| 5262 ShadowParseContext context(propId); | 5262 ShadowParseContext context(propId); |
| 5263 for (CSSParserValue* val = valueList->current(); val; val = valueList->next(
)) { | 5263 for (CSSParserValue* val = valueList->current(); val; val = valueList->next(
)) { |
| 5264 // Check for a comma break first. | 5264 // Check for a comma break first. |
| 5265 if (val->m_unit == CSSParserValue::Operator) { | 5265 if (val->m_unit == CSSParserValue::Operator) { |
| 5266 if (val->iValue != ',' || !context.allowBreak) { | 5266 if (val->iValue != ',' || !context.allowBreak) { |
| 5267 // Other operators aren't legal or we aren't done with the curre
nt shadow | 5267 // Other operators aren't legal or we aren't done with the curre
nt shadow |
| 5268 // value. Treat as invalid. | 5268 // value. Treat as invalid. |
| 5269 return nullptr; | 5269 return nullptr; |
| 5270 } | 5270 } |
| 5271 // The value is good. Commit it. | 5271 // The value is good. Commit it. |
| 5272 context.commitValue(); | 5272 context.commitValue(); |
| 5273 } else if (validUnit(val, FLength, HTMLStandardMode)) { | 5273 } else if (validUnit(val, FLength, HTMLStandardMode)) { |
| 5274 // We required a length and didn't get one. Invalid. | 5274 // We required a length and didn't get one. Invalid. |
| 5275 if (!context.allowLength()) | 5275 if (!context.allowLength()) |
| 5276 return nullptr; | 5276 return nullptr; |
| 5277 | 5277 |
| 5278 // Blur radius must be non-negative. | 5278 // Blur radius must be non-negative. |
| 5279 if (context.allowBlur && (m_parsedCalculation ? m_parsedCalculation-
>isNegative() : !validUnit(val, FLength | FNonNeg, HTMLStandardMode))) | 5279 if (context.allowBlur && (m_parsedCalculation ? m_parsedCalculation-
>isNegative() : !validUnit(val, FLength | FNonNeg, HTMLStandardMode))) |
| 5280 return nullptr; | 5280 return nullptr; |
| 5281 | 5281 |
| 5282 // A length is allowed here. Construct the value and add it. | 5282 // A length is allowed here. Construct the value and add it. |
| 5283 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumeri
cValue(val); | 5283 RefPtr<CSSPrimitiveValue> length = createPrimitiveNumericValue(val); |
| 5284 context.commitLength(length.release()); | 5284 context.commitLength(length.release()); |
| 5285 } else if (val->id == CSSValueInset) { | 5285 } else if (val->id == CSSValueInset) { |
| 5286 if (!context.allowStyle) | 5286 if (!context.allowStyle) |
| 5287 return nullptr; | 5287 return nullptr; |
| 5288 | 5288 |
| 5289 context.commitStyle(val); | 5289 context.commitStyle(val); |
| 5290 } else { | 5290 } else { |
| 5291 if (!context.allowColor) | 5291 if (!context.allowColor) |
| 5292 return nullptr; | 5292 return nullptr; |
| 5293 | 5293 |
| 5294 // The only other type of value that's ok is a color value. | 5294 // The only other type of value that's ok is a color value. |
| 5295 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedColor = parseColor(val); | 5295 RefPtr<CSSPrimitiveValue> parsedColor = parseColor(val); |
| 5296 if (!parsedColor) | 5296 if (!parsedColor) |
| 5297 return nullptr; | 5297 return nullptr; |
| 5298 | 5298 |
| 5299 context.commitColor(parsedColor.release()); | 5299 context.commitColor(parsedColor.release()); |
| 5300 } | 5300 } |
| 5301 } | 5301 } |
| 5302 | 5302 |
| 5303 if (context.allowBreak) { | 5303 if (context.allowBreak) { |
| 5304 context.commitValue(); | 5304 context.commitValue(); |
| 5305 if (context.values && context.values->length()) | 5305 if (context.values && context.values->length()) |
| 5306 return context.values.release(); | 5306 return context.values.release(); |
| 5307 } | 5307 } |
| 5308 | 5308 |
| 5309 return nullptr; | 5309 return nullptr; |
| 5310 } | 5310 } |
| 5311 | 5311 |
| 5312 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() | 5312 PassRefPtr<CSSValue> CSSPropertyParser::parseReflect() |
| 5313 { | 5313 { |
| 5314 // box-reflect: <direction> <offset> <mask> | 5314 // box-reflect: <direction> <offset> <mask> |
| 5315 | 5315 |
| 5316 // Direction comes first. | 5316 // Direction comes first. |
| 5317 CSSParserValue* val = m_valueList->current(); | 5317 CSSParserValue* val = m_valueList->current(); |
| 5318 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; | 5318 RefPtr<CSSPrimitiveValue> direction = nullptr; |
| 5319 switch (val->id) { | 5319 switch (val->id) { |
| 5320 case CSSValueAbove: | 5320 case CSSValueAbove: |
| 5321 case CSSValueBelow: | 5321 case CSSValueBelow: |
| 5322 case CSSValueLeft: | 5322 case CSSValueLeft: |
| 5323 case CSSValueRight: | 5323 case CSSValueRight: |
| 5324 direction = cssValuePool().createIdentifierValue(val->id); | 5324 direction = cssValuePool().createIdentifierValue(val->id); |
| 5325 break; | 5325 break; |
| 5326 default: | 5326 default: |
| 5327 return nullptr; | 5327 return nullptr; |
| 5328 } | 5328 } |
| 5329 | 5329 |
| 5330 // The offset comes next. | 5330 // The offset comes next. |
| 5331 val = m_valueList->next(); | 5331 val = m_valueList->next(); |
| 5332 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; | 5332 RefPtr<CSSPrimitiveValue> offset = nullptr; |
| 5333 if (!val) | 5333 if (!val) |
| 5334 offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixe
ls); | 5334 offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixe
ls); |
| 5335 else { | 5335 else { |
| 5336 if (!validUnit(val, FLength | FPercent)) | 5336 if (!validUnit(val, FLength | FPercent)) |
| 5337 return nullptr; | 5337 return nullptr; |
| 5338 offset = createPrimitiveNumericValue(val); | 5338 offset = createPrimitiveNumericValue(val); |
| 5339 } | 5339 } |
| 5340 | 5340 |
| 5341 // Now for the mask. | 5341 // Now for the mask. |
| 5342 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; | 5342 RefPtr<CSSValue> mask = nullptr; |
| 5343 val = m_valueList->next(); | 5343 val = m_valueList->next(); |
| 5344 if (val) { | 5344 if (val) { |
| 5345 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); | 5345 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); |
| 5346 if (!mask) | 5346 if (!mask) |
| 5347 return nullptr; | 5347 return nullptr; |
| 5348 } | 5348 } |
| 5349 | 5349 |
| 5350 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); | 5350 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); |
| 5351 } | 5351 } |
| 5352 | 5352 |
| 5353 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse
tValue, int argSize) | 5353 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse
tValue, int argSize) |
| 5354 { | 5354 { |
| 5355 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; | 5355 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; |
| 5356 } | 5356 } |
| 5357 | 5357 |
| 5358 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) | 5358 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) |
| 5359 { | 5359 { |
| 5360 if (!args || !args->size() || args->size() > 3) | 5360 if (!args || !args->size() || args->size() > 3) |
| 5361 return false; | 5361 return false; |
| 5362 static const double unsetValue = -1; | 5362 static const double unsetValue = -1; |
| 5363 double flexGrow = unsetValue; | 5363 double flexGrow = unsetValue; |
| 5364 double flexShrink = unsetValue; | 5364 double flexShrink = unsetValue; |
| 5365 RefPtrWillBeRawPtr<CSSPrimitiveValue> flexBasis = nullptr; | 5365 RefPtr<CSSPrimitiveValue> flexBasis = nullptr; |
| 5366 | 5366 |
| 5367 while (CSSParserValue* arg = args->current()) { | 5367 while (CSSParserValue* arg = args->current()) { |
| 5368 if (validUnit(arg, FNumber | FNonNeg)) { | 5368 if (validUnit(arg, FNumber | FNonNeg)) { |
| 5369 if (flexGrow == unsetValue) | 5369 if (flexGrow == unsetValue) |
| 5370 flexGrow = arg->fValue; | 5370 flexGrow = arg->fValue; |
| 5371 else if (flexShrink == unsetValue) | 5371 else if (flexShrink == unsetValue) |
| 5372 flexShrink = arg->fValue; | 5372 flexShrink = arg->fValue; |
| 5373 else if (!arg->fValue) { | 5373 else if (!arg->fValue) { |
| 5374 // flex only allows a basis of 0 (sans units) if flex-grow and f
lex-shrink values have already been set. | 5374 // flex only allows a basis of 0 (sans units) if flex-grow and f
lex-shrink values have already been set. |
| 5375 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::Uni
tType::Pixels); | 5375 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::Uni
tType::Pixels); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5392 flexShrink = 1; | 5392 flexShrink = 1; |
| 5393 if (!flexBasis) | 5393 if (!flexBasis) |
| 5394 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::P
ercentage); | 5394 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::P
ercentage); |
| 5395 | 5395 |
| 5396 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::UnitType::Number), important); | 5396 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::UnitType::Number), important); |
| 5397 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::UnitType::Number), important); | 5397 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::UnitType::Number), important); |
| 5398 addProperty(CSSPropertyFlexBasis, flexBasis, important); | 5398 addProperty(CSSPropertyFlexBasis, flexBasis, important); |
| 5399 return true; | 5399 return true; |
| 5400 } | 5400 } |
| 5401 | 5401 |
| 5402 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue
List* valueList) | 5402 PassRefPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValueList* valueL
ist) |
| 5403 { | 5403 { |
| 5404 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 5404 RefPtr<CSSValue> xValue = nullptr; |
| 5405 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 5405 RefPtr<CSSValue> yValue = nullptr; |
| 5406 parseFillPosition(valueList, xValue, yValue); | 5406 parseFillPosition(valueList, xValue, yValue); |
| 5407 if (!xValue || !yValue) | 5407 if (!xValue || !yValue) |
| 5408 return nullptr; | 5408 return nullptr; |
| 5409 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim
itiveValue(yValue.get()), Pair::KeepIdenticalValues); | 5409 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim
itiveValue(yValue.get()), Pair::KeepIdenticalValues); |
| 5410 } | 5410 } |
| 5411 | 5411 |
| 5412 // Parses a list of comma separated positions. i.e., <position># | 5412 // Parses a list of comma separated positions. i.e., <position># |
| 5413 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar
serValueList* valueList) | 5413 PassRefPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSParserValueList
* valueList) |
| 5414 { | 5414 { |
| 5415 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara
ted(); | 5415 RefPtr<CSSValueList> positions = CSSValueList::createCommaSeparated(); |
| 5416 while (true) { | 5416 while (true) { |
| 5417 // parsePosition consumes values until it reaches a separator [,/], | 5417 // parsePosition consumes values until it reaches a separator [,/], |
| 5418 // an invalid token, or end of the list | 5418 // an invalid token, or end of the list |
| 5419 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); | 5419 RefPtr<CSSValue> position = parsePosition(valueList); |
| 5420 if (!position) | 5420 if (!position) |
| 5421 return nullptr; | 5421 return nullptr; |
| 5422 positions->append(position); | 5422 positions->append(position); |
| 5423 | 5423 |
| 5424 if (!valueList->current()) | 5424 if (!valueList->current()) |
| 5425 break; | 5425 break; |
| 5426 if (!consumeComma(valueList) || !valueList->current()) | 5426 if (!consumeComma(valueList) || !valueList->current()) |
| 5427 return nullptr; | 5427 return nullptr; |
| 5428 } | 5428 } |
| 5429 | 5429 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5449 | 5449 |
| 5450 bool allowCommit() const { return m_allowCommit; } | 5450 bool allowCommit() const { return m_allowCommit; } |
| 5451 bool allowImage() const { return m_allowImage; } | 5451 bool allowImage() const { return m_allowImage; } |
| 5452 bool allowImageSlice() const { return m_allowImageSlice; } | 5452 bool allowImageSlice() const { return m_allowImageSlice; } |
| 5453 bool allowRepeat() const { return m_allowRepeat; } | 5453 bool allowRepeat() const { return m_allowRepeat; } |
| 5454 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator;
} | 5454 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator;
} |
| 5455 | 5455 |
| 5456 bool allowWidth() const { return m_allowWidth; } | 5456 bool allowWidth() const { return m_allowWidth; } |
| 5457 bool requireOutset() const { return m_requireOutset; } | 5457 bool requireOutset() const { return m_requireOutset; } |
| 5458 | 5458 |
| 5459 void commitImage(PassRefPtrWillBeRawPtr<CSSValue> image) | 5459 void commitImage(PassRefPtr<CSSValue> image) |
| 5460 { | 5460 { |
| 5461 m_image = image; | 5461 m_image = image; |
| 5462 m_canAdvance = true; | 5462 m_canAdvance = true; |
| 5463 m_allowCommit = true; | 5463 m_allowCommit = true; |
| 5464 m_allowImage = false; | 5464 m_allowImage = false; |
| 5465 m_allowForwardSlashOperator = false; | 5465 m_allowForwardSlashOperator = false; |
| 5466 m_allowWidth = false; | 5466 m_allowWidth = false; |
| 5467 m_requireOutset = false; | 5467 m_requireOutset = false; |
| 5468 m_allowImageSlice = !m_imageSlice; | 5468 m_allowImageSlice = !m_imageSlice; |
| 5469 m_allowRepeat = !m_repeat; | 5469 m_allowRepeat = !m_repeat; |
| 5470 } | 5470 } |
| 5471 void commitImageSlice(PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> slice
) | 5471 void commitImageSlice(PassRefPtr<CSSBorderImageSliceValue> slice) |
| 5472 { | 5472 { |
| 5473 m_imageSlice = slice; | 5473 m_imageSlice = slice; |
| 5474 m_canAdvance = true; | 5474 m_canAdvance = true; |
| 5475 m_allowCommit = true; | 5475 m_allowCommit = true; |
| 5476 m_allowForwardSlashOperator = true; | 5476 m_allowForwardSlashOperator = true; |
| 5477 m_allowImageSlice = false; | 5477 m_allowImageSlice = false; |
| 5478 m_allowWidth = false; | 5478 m_allowWidth = false; |
| 5479 m_requireOutset = false; | 5479 m_requireOutset = false; |
| 5480 m_allowImage = !m_image; | 5480 m_allowImage = !m_image; |
| 5481 m_allowRepeat = !m_repeat; | 5481 m_allowRepeat = !m_repeat; |
| 5482 } | 5482 } |
| 5483 void commitForwardSlashOperator() | 5483 void commitForwardSlashOperator() |
| 5484 { | 5484 { |
| 5485 m_canAdvance = true; | 5485 m_canAdvance = true; |
| 5486 m_allowCommit = false; | 5486 m_allowCommit = false; |
| 5487 m_allowImage = false; | 5487 m_allowImage = false; |
| 5488 m_allowImageSlice = false; | 5488 m_allowImageSlice = false; |
| 5489 m_allowRepeat = false; | 5489 m_allowRepeat = false; |
| 5490 if (!m_borderWidth && !m_allowWidth) { | 5490 if (!m_borderWidth && !m_allowWidth) { |
| 5491 m_allowForwardSlashOperator = true; | 5491 m_allowForwardSlashOperator = true; |
| 5492 m_allowWidth = true; | 5492 m_allowWidth = true; |
| 5493 m_requireOutset = false; | 5493 m_requireOutset = false; |
| 5494 } else { | 5494 } else { |
| 5495 m_allowForwardSlashOperator = false; | 5495 m_allowForwardSlashOperator = false; |
| 5496 m_requireOutset = true; | 5496 m_requireOutset = true; |
| 5497 m_allowWidth = false; | 5497 m_allowWidth = false; |
| 5498 } | 5498 } |
| 5499 } | 5499 } |
| 5500 void commitBorderWidth(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> width) | 5500 void commitBorderWidth(PassRefPtr<CSSPrimitiveValue> width) |
| 5501 { | 5501 { |
| 5502 m_borderWidth = width; | 5502 m_borderWidth = width; |
| 5503 m_canAdvance = true; | 5503 m_canAdvance = true; |
| 5504 m_allowCommit = true; | 5504 m_allowCommit = true; |
| 5505 m_allowForwardSlashOperator = true; | 5505 m_allowForwardSlashOperator = true; |
| 5506 m_allowImageSlice = false; | 5506 m_allowImageSlice = false; |
| 5507 m_allowWidth = false; | 5507 m_allowWidth = false; |
| 5508 m_requireOutset = false; | 5508 m_requireOutset = false; |
| 5509 m_allowImage = !m_image; | 5509 m_allowImage = !m_image; |
| 5510 m_allowRepeat = !m_repeat; | 5510 m_allowRepeat = !m_repeat; |
| 5511 } | 5511 } |
| 5512 void commitBorderOutset(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> outset) | 5512 void commitBorderOutset(PassRefPtr<CSSPrimitiveValue> outset) |
| 5513 { | 5513 { |
| 5514 m_outset = outset; | 5514 m_outset = outset; |
| 5515 m_canAdvance = true; | 5515 m_canAdvance = true; |
| 5516 m_allowCommit = true; | 5516 m_allowCommit = true; |
| 5517 m_allowImageSlice = false; | 5517 m_allowImageSlice = false; |
| 5518 m_allowForwardSlashOperator = false; | 5518 m_allowForwardSlashOperator = false; |
| 5519 m_allowWidth = false; | 5519 m_allowWidth = false; |
| 5520 m_requireOutset = false; | 5520 m_requireOutset = false; |
| 5521 m_allowImage = !m_image; | 5521 m_allowImage = !m_image; |
| 5522 m_allowRepeat = !m_repeat; | 5522 m_allowRepeat = !m_repeat; |
| 5523 } | 5523 } |
| 5524 void commitRepeat(PassRefPtrWillBeRawPtr<CSSValue> repeat) | 5524 void commitRepeat(PassRefPtr<CSSValue> repeat) |
| 5525 { | 5525 { |
| 5526 m_repeat = repeat; | 5526 m_repeat = repeat; |
| 5527 m_canAdvance = true; | 5527 m_canAdvance = true; |
| 5528 m_allowCommit = true; | 5528 m_allowCommit = true; |
| 5529 m_allowRepeat = false; | 5529 m_allowRepeat = false; |
| 5530 m_allowForwardSlashOperator = false; | 5530 m_allowForwardSlashOperator = false; |
| 5531 m_allowWidth = false; | 5531 m_allowWidth = false; |
| 5532 m_requireOutset = false; | 5532 m_requireOutset = false; |
| 5533 m_allowImageSlice = !m_imageSlice; | 5533 m_allowImageSlice = !m_imageSlice; |
| 5534 m_allowImage = !m_image; | 5534 m_allowImage = !m_image; |
| 5535 } | 5535 } |
| 5536 | 5536 |
| 5537 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() | 5537 PassRefPtr<CSSValue> commitCSSValue() |
| 5538 { | 5538 { |
| 5539 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth
.get(), m_outset.get(), m_repeat.get()); | 5539 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth
.get(), m_outset.get(), m_repeat.get()); |
| 5540 } | 5540 } |
| 5541 | 5541 |
| 5542 bool m_canAdvance; | 5542 bool m_canAdvance; |
| 5543 | 5543 |
| 5544 bool m_allowCommit; | 5544 bool m_allowCommit; |
| 5545 bool m_allowImage; | 5545 bool m_allowImage; |
| 5546 bool m_allowImageSlice; | 5546 bool m_allowImageSlice; |
| 5547 bool m_allowRepeat; | 5547 bool m_allowRepeat; |
| 5548 bool m_allowForwardSlashOperator; | 5548 bool m_allowForwardSlashOperator; |
| 5549 | 5549 |
| 5550 bool m_allowWidth; | 5550 bool m_allowWidth; |
| 5551 bool m_requireOutset; | 5551 bool m_requireOutset; |
| 5552 | 5552 |
| 5553 RefPtrWillBeMember<CSSValue> m_image; | 5553 RefPtr<CSSValue> m_image; |
| 5554 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; | 5554 RefPtr<CSSBorderImageSliceValue> m_imageSlice; |
| 5555 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; | 5555 RefPtr<CSSPrimitiveValue> m_borderWidth; |
| 5556 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; | 5556 RefPtr<CSSPrimitiveValue> m_outset; |
| 5557 | 5557 |
| 5558 RefPtrWillBeMember<CSSValue> m_repeat; | 5558 RefPtr<CSSValue> m_repeat; |
| 5559 }; | 5559 }; |
| 5560 | 5560 |
| 5561 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde
rImageParseContext& context) | 5561 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde
rImageParseContext& context) |
| 5562 { | 5562 { |
| 5563 CSSPropertyParser::ShorthandScope scope(this, propId); | 5563 CSSPropertyParser::ShorthandScope scope(this, propId); |
| 5564 while (CSSParserValue* val = m_valueList->current()) { | 5564 while (CSSParserValue* val = m_valueList->current()) { |
| 5565 context.setCanAdvance(false); | 5565 context.setCanAdvance(false); |
| 5566 | 5566 |
| 5567 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 5567 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
| 5568 context.commitForwardSlashOperator(); | 5568 context.commitForwardSlashOperator(); |
| 5569 | 5569 |
| 5570 if (!context.canAdvance() && context.allowImage()) { | 5570 if (!context.canAdvance() && context.allowImage()) { |
| 5571 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { | 5571 if (val->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 5572 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); | 5572 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); |
| 5573 } else if (isGeneratedImageValue(val)) { | 5573 } else if (isGeneratedImageValue(val)) { |
| 5574 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 5574 RefPtr<CSSValue> value = nullptr; |
| 5575 if (parseGeneratedImage(m_valueList, value)) | 5575 if (parseGeneratedImage(m_valueList, value)) |
| 5576 context.commitImage(value.release()); | 5576 context.commitImage(value.release()); |
| 5577 else | 5577 else |
| 5578 return false; | 5578 return false; |
| 5579 } else if (val->m_unit == CSSParserValue::Function && val->function-
>id == CSSValueWebkitImageSet) { | 5579 } else if (val->m_unit == CSSParserValue::Function && val->function-
>id == CSSValueWebkitImageSet) { |
| 5580 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); | 5580 RefPtr<CSSValue> value = parseImageSet(m_valueList); |
| 5581 if (value) | 5581 if (value) |
| 5582 context.commitImage(value.release()); | 5582 context.commitImage(value.release()); |
| 5583 else | 5583 else |
| 5584 return false; | 5584 return false; |
| 5585 } else if (val->id == CSSValueNone) | 5585 } else if (val->id == CSSValueNone) |
| 5586 context.commitImage(cssValuePool().createIdentifierValue(CSSValu
eNone)); | 5586 context.commitImage(cssValuePool().createIdentifierValue(CSSValu
eNone)); |
| 5587 } | 5587 } |
| 5588 | 5588 |
| 5589 if (!context.canAdvance() && context.allowImageSlice()) { | 5589 if (!context.canAdvance() && context.allowImageSlice()) { |
| 5590 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; | 5590 RefPtr<CSSBorderImageSliceValue> imageSlice = nullptr; |
| 5591 if (parseBorderImageSlice(propId, imageSlice)) | 5591 if (parseBorderImageSlice(propId, imageSlice)) |
| 5592 context.commitImageSlice(imageSlice.release()); | 5592 context.commitImageSlice(imageSlice.release()); |
| 5593 } | 5593 } |
| 5594 | 5594 |
| 5595 if (!context.canAdvance() && context.allowRepeat()) { | 5595 if (!context.canAdvance() && context.allowRepeat()) { |
| 5596 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; | 5596 RefPtr<CSSValue> repeat = nullptr; |
| 5597 if (parseBorderImageRepeat(repeat)) | 5597 if (parseBorderImageRepeat(repeat)) |
| 5598 context.commitRepeat(repeat.release()); | 5598 context.commitRepeat(repeat.release()); |
| 5599 } | 5599 } |
| 5600 | 5600 |
| 5601 if (!context.canAdvance() && context.allowWidth()) { | 5601 if (!context.canAdvance() && context.allowWidth()) { |
| 5602 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; | 5602 RefPtr<CSSPrimitiveValue> borderWidth = nullptr; |
| 5603 if (parseBorderImageWidth(borderWidth)) | 5603 if (parseBorderImageWidth(borderWidth)) |
| 5604 context.commitBorderWidth(borderWidth.release()); | 5604 context.commitBorderWidth(borderWidth.release()); |
| 5605 } | 5605 } |
| 5606 | 5606 |
| 5607 if (!context.canAdvance() && context.requireOutset()) { | 5607 if (!context.canAdvance() && context.requireOutset()) { |
| 5608 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; | 5608 RefPtr<CSSPrimitiveValue> borderOutset = nullptr; |
| 5609 if (parseBorderImageOutset(borderOutset)) | 5609 if (parseBorderImageOutset(borderOutset)) |
| 5610 context.commitBorderOutset(borderOutset.release()); | 5610 context.commitBorderOutset(borderOutset.release()); |
| 5611 } | 5611 } |
| 5612 | 5612 |
| 5613 if (!context.canAdvance()) | 5613 if (!context.canAdvance()) |
| 5614 return false; | 5614 return false; |
| 5615 | 5615 |
| 5616 m_valueList->next(); | 5616 m_valueList->next(); |
| 5617 } | 5617 } |
| 5618 | 5618 |
| 5619 return context.allowCommit(); | 5619 return context.allowCommit(); |
| 5620 } | 5620 } |
| 5621 | 5621 |
| 5622 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP
trWillBeRawPtr<CSSValue> value, bool important) | 5622 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP
tr<CSSValue> value, bool important) |
| 5623 { | 5623 { |
| 5624 if (value) | 5624 if (value) |
| 5625 addProperty(propId, value, important); | 5625 addProperty(propId, value, important); |
| 5626 else | 5626 else |
| 5627 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa
nt, true); | 5627 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa
nt, true); |
| 5628 } | 5628 } |
| 5629 | 5629 |
| 5630 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp
ortant) | 5630 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp
ortant) |
| 5631 { | 5631 { |
| 5632 BorderImageParseContext context; | 5632 BorderImageParseContext context; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5647 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re
peat, important); | 5647 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re
peat, important); |
| 5648 return true; | 5648 return true; |
| 5649 default: | 5649 default: |
| 5650 ASSERT_NOT_REACHED(); | 5650 ASSERT_NOT_REACHED(); |
| 5651 return false; | 5651 return false; |
| 5652 } | 5652 } |
| 5653 } | 5653 } |
| 5654 return false; | 5654 return false; |
| 5655 } | 5655 } |
| 5656 | 5656 |
| 5657 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty
ID propId) | 5657 PassRefPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSPropertyID propId) |
| 5658 { | 5658 { |
| 5659 BorderImageParseContext context; | 5659 BorderImageParseContext context; |
| 5660 if (buildBorderImageParseContext(propId, context)) { | 5660 if (buildBorderImageParseContext(propId, context)) { |
| 5661 return context.commitCSSValue(); | 5661 return context.commitCSSValue(); |
| 5662 } | 5662 } |
| 5663 return nullptr; | 5663 return nullptr; |
| 5664 } | 5664 } |
| 5665 | 5665 |
| 5666 static bool isBorderImageRepeatKeyword(int id) | 5666 static bool isBorderImageRepeatKeyword(int id) |
| 5667 { | 5667 { |
| 5668 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; | 5668 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; |
| 5669 } | 5669 } |
| 5670 | 5670 |
| 5671 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res
ult) | 5671 bool CSSPropertyParser::parseBorderImageRepeat(RefPtr<CSSValue>& result) |
| 5672 { | 5672 { |
| 5673 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; | 5673 RefPtr<CSSPrimitiveValue> firstValue = nullptr; |
| 5674 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; | 5674 RefPtr<CSSPrimitiveValue> secondValue = nullptr; |
| 5675 CSSParserValue* val = m_valueList->current(); | 5675 CSSParserValue* val = m_valueList->current(); |
| 5676 if (!val) | 5676 if (!val) |
| 5677 return false; | 5677 return false; |
| 5678 if (isBorderImageRepeatKeyword(val->id)) | 5678 if (isBorderImageRepeatKeyword(val->id)) |
| 5679 firstValue = cssValuePool().createIdentifierValue(val->id); | 5679 firstValue = cssValuePool().createIdentifierValue(val->id); |
| 5680 else | 5680 else |
| 5681 return false; | 5681 return false; |
| 5682 | 5682 |
| 5683 val = m_valueList->next(); | 5683 val = m_valueList->next(); |
| 5684 if (val) { | 5684 if (val) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5708 , m_allowFill(true) | 5708 , m_allowFill(true) |
| 5709 , m_allowFinalCommit(false) | 5709 , m_allowFinalCommit(false) |
| 5710 , m_fill(false) | 5710 , m_fill(false) |
| 5711 { } | 5711 { } |
| 5712 | 5712 |
| 5713 bool allowNumber() const { return m_allowNumber; } | 5713 bool allowNumber() const { return m_allowNumber; } |
| 5714 bool allowFill() const { return m_allowFill; } | 5714 bool allowFill() const { return m_allowFill; } |
| 5715 bool allowFinalCommit() const { return m_allowFinalCommit; } | 5715 bool allowFinalCommit() const { return m_allowFinalCommit; } |
| 5716 CSSPrimitiveValue* top() const { return m_top.get(); } | 5716 CSSPrimitiveValue* top() const { return m_top.get(); } |
| 5717 | 5717 |
| 5718 void commitNumber(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) | 5718 void commitNumber(PassRefPtr<CSSPrimitiveValue> val) |
| 5719 { | 5719 { |
| 5720 if (!m_top) | 5720 if (!m_top) |
| 5721 m_top = val; | 5721 m_top = val; |
| 5722 else if (!m_right) | 5722 else if (!m_right) |
| 5723 m_right = val; | 5723 m_right = val; |
| 5724 else if (!m_bottom) | 5724 else if (!m_bottom) |
| 5725 m_bottom = val; | 5725 m_bottom = val; |
| 5726 else { | 5726 else { |
| 5727 ASSERT(!m_left); | 5727 ASSERT(!m_left); |
| 5728 m_left = val; | 5728 m_left = val; |
| 5729 } | 5729 } |
| 5730 | 5730 |
| 5731 m_allowNumber = !m_left; | 5731 m_allowNumber = !m_left; |
| 5732 m_allowFinalCommit = true; | 5732 m_allowFinalCommit = true; |
| 5733 } | 5733 } |
| 5734 | 5734 |
| 5735 void commitFill() { m_fill = true; m_allowFill = false; m_allowNumber = !m_t
op; } | 5735 void commitFill() { m_fill = true; m_allowFill = false; m_allowNumber = !m_t
op; } |
| 5736 | 5736 |
| 5737 PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> commitBorderImageSlice() | 5737 PassRefPtr<CSSBorderImageSliceValue> commitBorderImageSlice() |
| 5738 { | 5738 { |
| 5739 // We need to clone and repeat values for any omissions. | 5739 // We need to clone and repeat values for any omissions. |
| 5740 ASSERT(m_top); | 5740 ASSERT(m_top); |
| 5741 if (!m_right) { | 5741 if (!m_right) { |
| 5742 m_right = m_top; | 5742 m_right = m_top; |
| 5743 m_bottom = m_top; | 5743 m_bottom = m_top; |
| 5744 m_left = m_top; | 5744 m_left = m_top; |
| 5745 } | 5745 } |
| 5746 if (!m_bottom) { | 5746 if (!m_bottom) { |
| 5747 m_bottom = m_top; | 5747 m_bottom = m_top; |
| 5748 m_left = m_right; | 5748 m_left = m_right; |
| 5749 } | 5749 } |
| 5750 if (!m_left) | 5750 if (!m_left) |
| 5751 m_left = m_right; | 5751 m_left = m_right; |
| 5752 | 5752 |
| 5753 // Now build a rect value to hold all four of our primitive values. | 5753 // Now build a rect value to hold all four of our primitive values. |
| 5754 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); | 5754 RefPtr<Quad> quad = Quad::create(); |
| 5755 quad->setTop(m_top); | 5755 quad->setTop(m_top); |
| 5756 quad->setRight(m_right); | 5756 quad->setRight(m_right); |
| 5757 quad->setBottom(m_bottom); | 5757 quad->setBottom(m_bottom); |
| 5758 quad->setLeft(m_left); | 5758 quad->setLeft(m_left); |
| 5759 | 5759 |
| 5760 // Make our new border image value now. | 5760 // Make our new border image value now. |
| 5761 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.
release()), m_fill); | 5761 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.
release()), m_fill); |
| 5762 } | 5762 } |
| 5763 | 5763 |
| 5764 private: | 5764 private: |
| 5765 bool m_allowNumber; | 5765 bool m_allowNumber; |
| 5766 bool m_allowFill; | 5766 bool m_allowFill; |
| 5767 bool m_allowFinalCommit; | 5767 bool m_allowFinalCommit; |
| 5768 | 5768 |
| 5769 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 5769 RefPtr<CSSPrimitiveValue> m_top; |
| 5770 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 5770 RefPtr<CSSPrimitiveValue> m_right; |
| 5771 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 5771 RefPtr<CSSPrimitiveValue> m_bottom; |
| 5772 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 5772 RefPtr<CSSPrimitiveValue> m_left; |
| 5773 | 5773 |
| 5774 bool m_fill; | 5774 bool m_fill; |
| 5775 }; | 5775 }; |
| 5776 | 5776 |
| 5777 bool CSSPropertyParser::parseBorderImageSlice(CSSPropertyID propId, RefPtrWillBe
RawPtr<CSSBorderImageSliceValue>& result) | 5777 bool CSSPropertyParser::parseBorderImageSlice(CSSPropertyID propId, RefPtr<CSSBo
rderImageSliceValue>& result) |
| 5778 { | 5778 { |
| 5779 BorderImageSliceParseContext context; | 5779 BorderImageSliceParseContext context; |
| 5780 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n
ext()) { | 5780 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n
ext()) { |
| 5781 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values ar
e not created yet. | 5781 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values ar
e not created yet. |
| 5782 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInte
ger | FNonNeg | FPercent)) { | 5782 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInte
ger | FNonNeg | FPercent)) { |
| 5783 context.commitNumber(createPrimitiveNumericValue(val)); | 5783 context.commitNumber(createPrimitiveNumericValue(val)); |
| 5784 } else if (context.allowFill() && val->id == CSSValueFill) { | 5784 } else if (context.allowFill() && val->id == CSSValueFill) { |
| 5785 context.commitFill(); | 5785 context.commitFill(); |
| 5786 } else if (!inShorthand()) { | 5786 } else if (!inShorthand()) { |
| 5787 // If we're not parsing a shorthand then we are invalid. | 5787 // If we're not parsing a shorthand then we are invalid. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5814 public: | 5814 public: |
| 5815 BorderImageQuadParseContext() | 5815 BorderImageQuadParseContext() |
| 5816 : m_allowNumber(true) | 5816 : m_allowNumber(true) |
| 5817 , m_allowFinalCommit(false) | 5817 , m_allowFinalCommit(false) |
| 5818 { } | 5818 { } |
| 5819 | 5819 |
| 5820 bool allowNumber() const { return m_allowNumber; } | 5820 bool allowNumber() const { return m_allowNumber; } |
| 5821 bool allowFinalCommit() const { return m_allowFinalCommit; } | 5821 bool allowFinalCommit() const { return m_allowFinalCommit; } |
| 5822 CSSPrimitiveValue* top() const { return m_top.get(); } | 5822 CSSPrimitiveValue* top() const { return m_top.get(); } |
| 5823 | 5823 |
| 5824 void commitNumber(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) | 5824 void commitNumber(PassRefPtr<CSSPrimitiveValue> val) |
| 5825 { | 5825 { |
| 5826 if (!m_top) | 5826 if (!m_top) |
| 5827 m_top = val; | 5827 m_top = val; |
| 5828 else if (!m_right) | 5828 else if (!m_right) |
| 5829 m_right = val; | 5829 m_right = val; |
| 5830 else if (!m_bottom) | 5830 else if (!m_bottom) |
| 5831 m_bottom = val; | 5831 m_bottom = val; |
| 5832 else { | 5832 else { |
| 5833 ASSERT(!m_left); | 5833 ASSERT(!m_left); |
| 5834 m_left = val; | 5834 m_left = val; |
| 5835 } | 5835 } |
| 5836 | 5836 |
| 5837 m_allowNumber = !m_left; | 5837 m_allowNumber = !m_left; |
| 5838 m_allowFinalCommit = true; | 5838 m_allowFinalCommit = true; |
| 5839 } | 5839 } |
| 5840 | 5840 |
| 5841 void setTop(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) { m_top = val; } | 5841 void setTop(PassRefPtr<CSSPrimitiveValue> val) { m_top = val; } |
| 5842 | 5842 |
| 5843 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> commitBorderImageQuad() | 5843 PassRefPtr<CSSPrimitiveValue> commitBorderImageQuad() |
| 5844 { | 5844 { |
| 5845 // We need to clone and repeat values for any omissions. | 5845 // We need to clone and repeat values for any omissions. |
| 5846 ASSERT(m_top); | 5846 ASSERT(m_top); |
| 5847 if (!m_right) { | 5847 if (!m_right) { |
| 5848 m_right = m_top; | 5848 m_right = m_top; |
| 5849 m_bottom = m_top; | 5849 m_bottom = m_top; |
| 5850 m_left = m_top; | 5850 m_left = m_top; |
| 5851 } | 5851 } |
| 5852 if (!m_bottom) { | 5852 if (!m_bottom) { |
| 5853 m_bottom = m_top; | 5853 m_bottom = m_top; |
| 5854 m_left = m_right; | 5854 m_left = m_right; |
| 5855 } | 5855 } |
| 5856 if (!m_left) | 5856 if (!m_left) |
| 5857 m_left = m_right; | 5857 m_left = m_right; |
| 5858 | 5858 |
| 5859 // Now build a quad value to hold all four of our primitive values. | 5859 // Now build a quad value to hold all four of our primitive values. |
| 5860 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); | 5860 RefPtr<Quad> quad = Quad::create(); |
| 5861 quad->setTop(m_top); | 5861 quad->setTop(m_top); |
| 5862 quad->setRight(m_right); | 5862 quad->setRight(m_right); |
| 5863 quad->setBottom(m_bottom); | 5863 quad->setBottom(m_bottom); |
| 5864 quad->setLeft(m_left); | 5864 quad->setLeft(m_left); |
| 5865 | 5865 |
| 5866 // Make our new value now. | 5866 // Make our new value now. |
| 5867 return cssValuePool().createValue(quad.release()); | 5867 return cssValuePool().createValue(quad.release()); |
| 5868 } | 5868 } |
| 5869 | 5869 |
| 5870 private: | 5870 private: |
| 5871 bool m_allowNumber; | 5871 bool m_allowNumber; |
| 5872 bool m_allowFinalCommit; | 5872 bool m_allowFinalCommit; |
| 5873 | 5873 |
| 5874 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 5874 RefPtr<CSSPrimitiveValue> m_top; |
| 5875 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 5875 RefPtr<CSSPrimitiveValue> m_right; |
| 5876 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 5876 RefPtr<CSSPrimitiveValue> m_bottom; |
| 5877 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 5877 RefPtr<CSSPrimitiveValue> m_left; |
| 5878 }; | 5878 }; |
| 5879 | 5879 |
| 5880 bool CSSPropertyParser::parseBorderImageQuad(Units validUnits, RefPtrWillBeRawPt
r<CSSPrimitiveValue>& result) | 5880 bool CSSPropertyParser::parseBorderImageQuad(Units validUnits, RefPtr<CSSPrimiti
veValue>& result) |
| 5881 { | 5881 { |
| 5882 BorderImageQuadParseContext context; | 5882 BorderImageQuadParseContext context; |
| 5883 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n
ext()) { | 5883 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n
ext()) { |
| 5884 if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMod
e) || val->id == CSSValueAuto)) { | 5884 if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMod
e) || val->id == CSSValueAuto)) { |
| 5885 if (val->id == CSSValueAuto) | 5885 if (val->id == CSSValueAuto) |
| 5886 context.commitNumber(cssValuePool().createIdentifierValue(val->i
d)); | 5886 context.commitNumber(cssValuePool().createIdentifierValue(val->i
d)); |
| 5887 else | 5887 else |
| 5888 context.commitNumber(createPrimitiveNumericValue(val)); | 5888 context.commitNumber(createPrimitiveNumericValue(val)); |
| 5889 } else if (!inShorthand()) { | 5889 } else if (!inShorthand()) { |
| 5890 // If we're not parsing a shorthand then we are invalid. | 5890 // If we're not parsing a shorthand then we are invalid. |
| 5891 return false; | 5891 return false; |
| 5892 } else { | 5892 } else { |
| 5893 if (context.allowFinalCommit()) | 5893 if (context.allowFinalCommit()) |
| 5894 m_valueList->previous(); // The shorthand loop will advance back
to this point. | 5894 m_valueList->previous(); // The shorthand loop will advance back
to this point. |
| 5895 break; | 5895 break; |
| 5896 } | 5896 } |
| 5897 } | 5897 } |
| 5898 | 5898 |
| 5899 if (context.allowFinalCommit()) { | 5899 if (context.allowFinalCommit()) { |
| 5900 // Need to fully commit as a single value. | 5900 // Need to fully commit as a single value. |
| 5901 result = context.commitBorderImageQuad(); | 5901 result = context.commitBorderImageQuad(); |
| 5902 return true; | 5902 return true; |
| 5903 } | 5903 } |
| 5904 return false; | 5904 return false; |
| 5905 } | 5905 } |
| 5906 | 5906 |
| 5907 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSPrimitiveVal
ue>& result) | 5907 bool CSSPropertyParser::parseBorderImageWidth(RefPtr<CSSPrimitiveValue>& result) |
| 5908 { | 5908 { |
| 5909 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); | 5909 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
| 5910 } | 5910 } |
| 5911 | 5911 |
| 5912 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSPrimitiveVa
lue>& result) | 5912 bool CSSPropertyParser::parseBorderImageOutset(RefPtr<CSSPrimitiveValue>& result
) |
| 5913 { | 5913 { |
| 5914 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); | 5914 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
| 5915 } | 5915 } |
| 5916 | 5916 |
| 5917 bool CSSPropertyParser::parseBorderRadius(CSSPropertyID unresolvedProperty, bool
important) | 5917 bool CSSPropertyParser::parseBorderRadius(CSSPropertyID unresolvedProperty, bool
important) |
| 5918 { | 5918 { |
| 5919 unsigned num = m_valueList->size(); | 5919 unsigned num = m_valueList->size(); |
| 5920 if (num > 9) | 5920 if (num > 9) |
| 5921 return false; | 5921 return false; |
| 5922 | 5922 |
| 5923 ShorthandScope scope(this, unresolvedProperty); | 5923 ShorthandScope scope(this, unresolvedProperty); |
| 5924 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | 5924 RefPtr<CSSPrimitiveValue> radii[2][4]; |
| 5925 #if ENABLE(OILPAN) | 5925 #if ENABLE(OILPAN) |
| 5926 // Zero initialize the array of raw pointers. | 5926 // Zero initialize the array of raw pointers. |
| 5927 memset(&radii, 0, sizeof(radii)); | 5927 memset(&radii, 0, sizeof(radii)); |
| 5928 #endif | 5928 #endif |
| 5929 | 5929 |
| 5930 unsigned indexAfterSlash = 0; | 5930 unsigned indexAfterSlash = 0; |
| 5931 for (unsigned i = 0; i < num; ++i) { | 5931 for (unsigned i = 0; i < num; ++i) { |
| 5932 CSSParserValue* value = m_valueList->valueAt(i); | 5932 CSSParserValue* value = m_valueList->valueAt(i); |
| 5933 if (value->m_unit == CSSParserValue::Operator) { | 5933 if (value->m_unit == CSSParserValue::Operator) { |
| 5934 if (value->iValue != '/') | 5934 if (value->iValue != '/') |
| 5935 return false; | 5935 return false; |
| 5936 | 5936 |
| 5937 if (!i || indexAfterSlash || i + 1 == num || num > i + 5) | 5937 if (!i || indexAfterSlash || i + 1 == num || num > i + 5) |
| 5938 return false; | 5938 return false; |
| 5939 | 5939 |
| 5940 indexAfterSlash = i + 1; | 5940 indexAfterSlash = i + 1; |
| 5941 completeBorderRadii(radii[0]); | 5941 completeBorderRadii(radii[0]); |
| 5942 continue; | 5942 continue; |
| 5943 } | 5943 } |
| 5944 | 5944 |
| 5945 if (i - indexAfterSlash >= 4) | 5945 if (i - indexAfterSlash >= 4) |
| 5946 return false; | 5946 return false; |
| 5947 | 5947 |
| 5948 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 5948 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
| 5949 return false; | 5949 return false; |
| 5950 | 5950 |
| 5951 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal
ue(value); | 5951 RefPtr<CSSPrimitiveValue> radius = createPrimitiveNumericValue(value); |
| 5952 | 5952 |
| 5953 if (!indexAfterSlash) { | 5953 if (!indexAfterSlash) { |
| 5954 radii[0][i] = radius; | 5954 radii[0][i] = radius; |
| 5955 | 5955 |
| 5956 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to bor
der-radius: l1 / l2; | 5956 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to bor
der-radius: l1 / l2; |
| 5957 if (num == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa
dius) { | 5957 if (num == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa
dius) { |
| 5958 indexAfterSlash = 1; | 5958 indexAfterSlash = 1; |
| 5959 completeBorderRadii(radii[0]); | 5959 completeBorderRadii(radii[0]); |
| 5960 } | 5960 } |
| 5961 } else | 5961 } else |
| 5962 radii[1][i - indexAfterSlash] = radius.release(); | 5962 radii[1][i - indexAfterSlash] = radius.release(); |
| 5963 } | 5963 } |
| 5964 | 5964 |
| 5965 if (!indexAfterSlash) { | 5965 if (!indexAfterSlash) { |
| 5966 completeBorderRadii(radii[0]); | 5966 completeBorderRadii(radii[0]); |
| 5967 for (unsigned i = 0; i < 4; ++i) | 5967 for (unsigned i = 0; i < 4; ++i) |
| 5968 radii[1][i] = radii[0][i]; | 5968 radii[1][i] = radii[0][i]; |
| 5969 } else | 5969 } else |
| 5970 completeBorderRadii(radii[1]); | 5970 completeBorderRadii(radii[1]); |
| 5971 | 5971 |
| 5972 ImplicitScope implicitScope(this); | 5972 ImplicitScope implicitScope(this); |
| 5973 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); | 5973 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); |
| 5974 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); | 5974 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); |
| 5975 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); | 5975 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); |
| 5976 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); | 5976 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); |
| 5977 return true; | 5977 return true; |
| 5978 } | 5978 } |
| 5979 | 5979 |
| 5980 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu
e) | 5980 PassRefPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValue) |
| 5981 { | 5981 { |
| 5982 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 5982 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
| 5983 | 5983 |
| 5984 while (m_valueList->current()) { | 5984 while (m_valueList->current()) { |
| 5985 CSSParserValue* val = m_valueList->current(); | 5985 CSSParserValue* val = m_valueList->current(); |
| 5986 if (val->m_unit != CSSParserValue::Identifier) | 5986 if (val->m_unit != CSSParserValue::Identifier) |
| 5987 return nullptr; | 5987 return nullptr; |
| 5988 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto
mIdentValue(val); | 5988 RefPtr<CSSPrimitiveValue> counterName = createPrimitiveCustomIdentValue(
val); |
| 5989 m_valueList->next(); | 5989 m_valueList->next(); |
| 5990 | 5990 |
| 5991 val = m_valueList->current(); | 5991 val = m_valueList->current(); |
| 5992 int i = defaultValue; | 5992 int i = defaultValue; |
| 5993 if (val && validUnit(val, FInteger)) { | 5993 if (val && validUnit(val, FInteger)) { |
| 5994 i = clampTo<int>(val->fValue); | 5994 i = clampTo<int>(val->fValue); |
| 5995 m_valueList->next(); | 5995 m_valueList->next(); |
| 5996 } | 5996 } |
| 5997 | 5997 |
| 5998 list->append(createPrimitiveValuePair(counterName.release(), | 5998 list->append(createPrimitiveValuePair(counterName.release(), |
| 5999 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number)))
; | 5999 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number)))
; |
| 6000 } | 6000 } |
| 6001 | 6001 |
| 6002 if (!list->length()) | 6002 if (!list->length()) |
| 6003 return nullptr; | 6003 return nullptr; |
| 6004 return list.release(); | 6004 return list.release(); |
| 6005 } | 6005 } |
| 6006 | 6006 |
| 6007 // This should go away once we drop support for -webkit-gradient | 6007 // This should go away once we drop support for -webkit-gradient |
| 6008 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) | 6008 static PassRefPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue
* a, bool horizontal) |
| 6009 { | 6009 { |
| 6010 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 6010 RefPtr<CSSPrimitiveValue> result = nullptr; |
| 6011 if (a->m_unit == CSSParserValue::Identifier) { | 6011 if (a->m_unit == CSSParserValue::Identifier) { |
| 6012 if ((a->id == CSSValueLeft && horizontal) | 6012 if ((a->id == CSSValueLeft && horizontal) |
| 6013 || (a->id == CSSValueTop && !horizontal)) | 6013 || (a->id == CSSValueTop && !horizontal)) |
| 6014 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType:
:Percentage); | 6014 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType:
:Percentage); |
| 6015 else if ((a->id == CSSValueRight && horizontal) | 6015 else if ((a->id == CSSValueRight && horizontal) |
| 6016 || (a->id == CSSValueBottom && !horizontal)) | 6016 || (a->id == CSSValueBottom && !horizontal)) |
| 6017 result = cssValuePool().createValue(100., CSSPrimitiveValue::UnitTyp
e::Percentage); | 6017 result = cssValuePool().createValue(100., CSSPrimitiveValue::UnitTyp
e::Percentage); |
| 6018 else if (a->id == CSSValueCenter) | 6018 else if (a->id == CSSValueCenter) |
| 6019 result = cssValuePool().createValue(50., CSSPrimitiveValue::UnitType
::Percentage); | 6019 result = cssValuePool().createValue(50., CSSPrimitiveValue::UnitType
::Percentage); |
| 6020 } else if (a->unit() == CSSPrimitiveValue::UnitType::Number || a->unit() ==
CSSPrimitiveValue::UnitType::Percentage) { | 6020 } else if (a->unit() == CSSPrimitiveValue::UnitType::Number || a->unit() ==
CSSPrimitiveValue::UnitType::Percentage) { |
| 6021 result = cssValuePool().createValue(a->fValue, a->unit()); | 6021 result = cssValuePool().createValue(a->fValue, a->unit()); |
| 6022 } | 6022 } |
| 6023 return result; | 6023 return result; |
| 6024 } | 6024 } |
| 6025 | 6025 |
| 6026 // Used to parse colors for -webkit-gradient(...). | 6026 // Used to parse colors for -webkit-gradient(...). |
| 6027 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseDeprecatedGrad
ientStopColor(const CSSParserValue* value) | 6027 PassRefPtr<CSSPrimitiveValue> CSSPropertyParser::parseDeprecatedGradientStopColo
r(const CSSParserValue* value) |
| 6028 { | 6028 { |
| 6029 // Disallow currentcolor. | 6029 // Disallow currentcolor. |
| 6030 if (value->id == CSSValueCurrentcolor) | 6030 if (value->id == CSSValueCurrentcolor) |
| 6031 return nullptr; | 6031 return nullptr; |
| 6032 return parseColor(value); | 6032 return parseColor(value); |
| 6033 } | 6033 } |
| 6034 | 6034 |
| 6035 bool CSSPropertyParser::parseDeprecatedGradientColorStop(CSSParserValue* a, CSSG
radientColorStop& stop) | 6035 bool CSSPropertyParser::parseDeprecatedGradientColorStop(CSSParserValue* a, CSSG
radientColorStop& stop) |
| 6036 { | 6036 { |
| 6037 if (a->m_unit != CSSParserValue::Function) | 6037 if (a->m_unit != CSSParserValue::Function) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6079 return false; | 6079 return false; |
| 6080 | 6080 |
| 6081 stop.m_color = parseDeprecatedGradientStopColor(args->current()); | 6081 stop.m_color = parseDeprecatedGradientStopColor(args->current()); |
| 6082 if (!stop.m_color) | 6082 if (!stop.m_color) |
| 6083 return false; | 6083 return false; |
| 6084 } | 6084 } |
| 6085 | 6085 |
| 6086 return true; | 6086 return true; |
| 6087 } | 6087 } |
| 6088 | 6088 |
| 6089 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
efPtrWillBeRawPtr<CSSValue>& gradient) | 6089 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
efPtr<CSSValue>& gradient) |
| 6090 { | 6090 { |
| 6091 // Walk the arguments. | 6091 // Walk the arguments. |
| 6092 CSSParserValueList* args = valueList->current()->function->args.get(); | 6092 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6093 if (!args || args->size() == 0) | 6093 if (!args || args->size() == 0) |
| 6094 return false; | 6094 return false; |
| 6095 | 6095 |
| 6096 // The first argument is the gradient type. It is an identifier. | 6096 // The first argument is the gradient type. It is an identifier. |
| 6097 CSSGradientType gradientType; | 6097 CSSGradientType gradientType; |
| 6098 CSSParserValue* a = args->current(); | 6098 CSSParserValue* a = args->current(); |
| 6099 if (!a || a->m_unit != CSSParserValue::Identifier) | 6099 if (!a || a->m_unit != CSSParserValue::Identifier) |
| 6100 return false; | 6100 return false; |
| 6101 if (a->id == CSSValueLinear) | 6101 if (a->id == CSSValueLinear) |
| 6102 gradientType = CSSDeprecatedLinearGradient; | 6102 gradientType = CSSDeprecatedLinearGradient; |
| 6103 else if (a->id == CSSValueRadial) | 6103 else if (a->id == CSSValueRadial) |
| 6104 gradientType = CSSDeprecatedRadialGradient; | 6104 gradientType = CSSDeprecatedRadialGradient; |
| 6105 else | 6105 else |
| 6106 return false; | 6106 return false; |
| 6107 | 6107 |
| 6108 RefPtrWillBeRawPtr<CSSGradientValue> result = nullptr; | 6108 RefPtr<CSSGradientValue> result = nullptr; |
| 6109 switch (gradientType) { | 6109 switch (gradientType) { |
| 6110 case CSSDeprecatedLinearGradient: | 6110 case CSSDeprecatedLinearGradient: |
| 6111 result = CSSLinearGradientValue::create(NonRepeating, gradientType); | 6111 result = CSSLinearGradientValue::create(NonRepeating, gradientType); |
| 6112 break; | 6112 break; |
| 6113 case CSSDeprecatedRadialGradient: | 6113 case CSSDeprecatedRadialGradient: |
| 6114 result = CSSRadialGradientValue::create(NonRepeating, gradientType); | 6114 result = CSSRadialGradientValue::create(NonRepeating, gradientType); |
| 6115 break; | 6115 break; |
| 6116 default: | 6116 default: |
| 6117 // The rest of the gradient types shouldn't appear here. | 6117 // The rest of the gradient types shouldn't appear here. |
| 6118 ASSERT_NOT_REACHED(); | 6118 ASSERT_NOT_REACHED(); |
| 6119 } | 6119 } |
| 6120 args->next(); | 6120 args->next(); |
| 6121 | 6121 |
| 6122 if (!consumeComma(args)) | 6122 if (!consumeComma(args)) |
| 6123 return false; | 6123 return false; |
| 6124 | 6124 |
| 6125 // Next comes the starting point for the gradient as an x y pair. There is
no | 6125 // Next comes the starting point for the gradient as an x y pair. There is
no |
| 6126 // comma between the x and the y values. | 6126 // comma between the x and the y values. |
| 6127 // First X. It can be left, right, number or percent. | 6127 // First X. It can be left, right, number or percent. |
| 6128 a = args->current(); | 6128 a = args->current(); |
| 6129 if (!a) | 6129 if (!a) |
| 6130 return false; | 6130 return false; |
| 6131 RefPtrWillBeRawPtr<CSSPrimitiveValue> point = parseDeprecatedGradientPoint(a
, true); | 6131 RefPtr<CSSPrimitiveValue> point = parseDeprecatedGradientPoint(a, true); |
| 6132 if (!point) | 6132 if (!point) |
| 6133 return false; | 6133 return false; |
| 6134 result->setFirstX(point.release()); | 6134 result->setFirstX(point.release()); |
| 6135 | 6135 |
| 6136 // First Y. It can be top, bottom, number or percent. | 6136 // First Y. It can be top, bottom, number or percent. |
| 6137 a = args->next(); | 6137 a = args->next(); |
| 6138 if (!a) | 6138 if (!a) |
| 6139 return false; | 6139 return false; |
| 6140 point = parseDeprecatedGradientPoint(a, false); | 6140 point = parseDeprecatedGradientPoint(a, false); |
| 6141 if (!point) | 6141 if (!point) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6212 result->addStop(stop); | 6212 result->addStop(stop); |
| 6213 | 6213 |
| 6214 // Advance | 6214 // Advance |
| 6215 a = args->next(); | 6215 a = args->next(); |
| 6216 } | 6216 } |
| 6217 | 6217 |
| 6218 gradient = result.release(); | 6218 gradient = result.release(); |
| 6219 return true; | 6219 return true; |
| 6220 } | 6220 } |
| 6221 | 6221 |
| 6222 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueFromSideKeyword(CSSParserV
alue* a, bool& isHorizontal) | 6222 static PassRefPtr<CSSPrimitiveValue> valueFromSideKeyword(CSSParserValue* a, boo
l& isHorizontal) |
| 6223 { | 6223 { |
| 6224 if (a->m_unit != CSSParserValue::Identifier) | 6224 if (a->m_unit != CSSParserValue::Identifier) |
| 6225 return nullptr; | 6225 return nullptr; |
| 6226 | 6226 |
| 6227 switch (a->id) { | 6227 switch (a->id) { |
| 6228 case CSSValueLeft: | 6228 case CSSValueLeft: |
| 6229 case CSSValueRight: | 6229 case CSSValueRight: |
| 6230 isHorizontal = true; | 6230 isHorizontal = true; |
| 6231 break; | 6231 break; |
| 6232 case CSSValueTop: | 6232 case CSSValueTop: |
| 6233 case CSSValueBottom: | 6233 case CSSValueBottom: |
| 6234 isHorizontal = false; | 6234 isHorizontal = false; |
| 6235 break; | 6235 break; |
| 6236 default: | 6236 default: |
| 6237 return nullptr; | 6237 return nullptr; |
| 6238 } | 6238 } |
| 6239 return cssValuePool().createIdentifierValue(a->id); | 6239 return cssValuePool().createIdentifierValue(a->id); |
| 6240 } | 6240 } |
| 6241 | 6241 |
| 6242 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL
ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6242 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL
ist, RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating) |
| 6243 { | 6243 { |
| 6244 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::
create(repeating, CSSPrefixedLinearGradient); | 6244 RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, CSSPrefixedLinearGradient); |
| 6245 | 6245 |
| 6246 // Walk the arguments. | 6246 // Walk the arguments. |
| 6247 CSSParserValueList* args = valueList->current()->function->args.get(); | 6247 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6248 if (!args || !args->size()) | 6248 if (!args || !args->size()) |
| 6249 return false; | 6249 return false; |
| 6250 | 6250 |
| 6251 CSSParserValue* a = args->current(); | 6251 CSSParserValue* a = args->current(); |
| 6252 if (!a) | 6252 if (!a) |
| 6253 return false; | 6253 return false; |
| 6254 | 6254 |
| 6255 bool expectComma = false; | 6255 bool expectComma = false; |
| 6256 // Look for angle. | 6256 // Look for angle. |
| 6257 if (validUnit(a, FAngle, HTMLStandardMode)) { | 6257 if (validUnit(a, FAngle, HTMLStandardMode)) { |
| 6258 result->setAngle(createPrimitiveNumericValue(a)); | 6258 result->setAngle(createPrimitiveNumericValue(a)); |
| 6259 | 6259 |
| 6260 args->next(); | 6260 args->next(); |
| 6261 expectComma = true; | 6261 expectComma = true; |
| 6262 } else { | 6262 } else { |
| 6263 // Look one or two optional keywords that indicate a side or corner. | 6263 // Look one or two optional keywords that indicate a side or corner. |
| 6264 RefPtrWillBeRawPtr<CSSPrimitiveValue> startX = nullptr; | 6264 RefPtr<CSSPrimitiveValue> startX = nullptr; |
| 6265 RefPtrWillBeRawPtr<CSSPrimitiveValue> startY = nullptr; | 6265 RefPtr<CSSPrimitiveValue> startY = nullptr; |
| 6266 | 6266 |
| 6267 RefPtrWillBeRawPtr<CSSPrimitiveValue> location = nullptr; | 6267 RefPtr<CSSPrimitiveValue> location = nullptr; |
| 6268 bool isHorizontal = false; | 6268 bool isHorizontal = false; |
| 6269 if ((location = valueFromSideKeyword(a, isHorizontal))) { | 6269 if ((location = valueFromSideKeyword(a, isHorizontal))) { |
| 6270 if (isHorizontal) | 6270 if (isHorizontal) |
| 6271 startX = location; | 6271 startX = location; |
| 6272 else | 6272 else |
| 6273 startY = location; | 6273 startY = location; |
| 6274 | 6274 |
| 6275 a = args->next(); | 6275 a = args->next(); |
| 6276 if (a) { | 6276 if (a) { |
| 6277 if ((location = valueFromSideKeyword(a, isHorizontal))) { | 6277 if ((location = valueFromSideKeyword(a, isHorizontal))) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6302 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6302 if (!parseGradientColorStops(args, result.get(), expectComma)) |
| 6303 return false; | 6303 return false; |
| 6304 | 6304 |
| 6305 if (!result->stopCount()) | 6305 if (!result->stopCount()) |
| 6306 return false; | 6306 return false; |
| 6307 | 6307 |
| 6308 gradient = result.release(); | 6308 gradient = result.release(); |
| 6309 return true; | 6309 return true; |
| 6310 } | 6310 } |
| 6311 | 6311 |
| 6312 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL
ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6312 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL
ist, RefPtr<CSSValue>& gradient, CSSGradientRepeat repeating) |
| 6313 { | 6313 { |
| 6314 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::
create(repeating, CSSPrefixedRadialGradient); | 6314 RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSPrefixedRadialGradient); |
| 6315 | 6315 |
| 6316 // Walk the arguments. | 6316 // Walk the arguments. |
| 6317 CSSParserValueList* args = valueList->current()->function->args.get(); | 6317 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6318 if (!args || !args->size()) | 6318 if (!args || !args->size()) |
| 6319 return false; | 6319 return false; |
| 6320 | 6320 |
| 6321 CSSParserValue* a = args->current(); | 6321 CSSParserValue* a = args->current(); |
| 6322 if (!a) | 6322 if (!a) |
| 6323 return false; | 6323 return false; |
| 6324 | 6324 |
| 6325 bool expectComma = false; | 6325 bool expectComma = false; |
| 6326 | 6326 |
| 6327 // Optional background-position | 6327 // Optional background-position |
| 6328 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 6328 RefPtr<CSSValue> centerX = nullptr; |
| 6329 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 6329 RefPtr<CSSValue> centerY = nullptr; |
| 6330 // parse2ValuesFillPosition advances the args next pointer. | 6330 // parse2ValuesFillPosition advances the args next pointer. |
| 6331 parse2ValuesFillPosition(args, centerX, centerY); | 6331 parse2ValuesFillPosition(args, centerX, centerY); |
| 6332 | 6332 |
| 6333 if ((centerX || centerY) && !consumeComma(args)) | 6333 if ((centerX || centerY) && !consumeComma(args)) |
| 6334 return false; | 6334 return false; |
| 6335 | 6335 |
| 6336 a = args->current(); | 6336 a = args->current(); |
| 6337 if (!a) | 6337 if (!a) |
| 6338 return false; | 6338 return false; |
| 6339 | 6339 |
| 6340 result->setFirstX(toCSSPrimitiveValue(centerX.get())); | 6340 result->setFirstX(toCSSPrimitiveValue(centerX.get())); |
| 6341 result->setSecondX(toCSSPrimitiveValue(centerX.get())); | 6341 result->setSecondX(toCSSPrimitiveValue(centerX.get())); |
| 6342 // CSS3 radial gradients always share the same start and end point. | 6342 // CSS3 radial gradients always share the same start and end point. |
| 6343 result->setFirstY(toCSSPrimitiveValue(centerY.get())); | 6343 result->setFirstY(toCSSPrimitiveValue(centerY.get())); |
| 6344 result->setSecondY(toCSSPrimitiveValue(centerY.get())); | 6344 result->setSecondY(toCSSPrimitiveValue(centerY.get())); |
| 6345 | 6345 |
| 6346 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; | 6346 RefPtr<CSSPrimitiveValue> shapeValue = nullptr; |
| 6347 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; | 6347 RefPtr<CSSPrimitiveValue> sizeValue = nullptr; |
| 6348 | 6348 |
| 6349 // Optional shape and/or size in any order. | 6349 // Optional shape and/or size in any order. |
| 6350 for (int i = 0; i < 2; ++i) { | 6350 for (int i = 0; i < 2; ++i) { |
| 6351 if (a->m_unit != CSSParserValue::Identifier) | 6351 if (a->m_unit != CSSParserValue::Identifier) |
| 6352 break; | 6352 break; |
| 6353 | 6353 |
| 6354 bool foundValue = false; | 6354 bool foundValue = false; |
| 6355 switch (a->id) { | 6355 switch (a->id) { |
| 6356 case CSSValueCircle: | 6356 case CSSValueCircle: |
| 6357 case CSSValueEllipse: | 6357 case CSSValueEllipse: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6377 return false; | 6377 return false; |
| 6378 | 6378 |
| 6379 expectComma = true; | 6379 expectComma = true; |
| 6380 } | 6380 } |
| 6381 } | 6381 } |
| 6382 | 6382 |
| 6383 result->setShape(shapeValue); | 6383 result->setShape(shapeValue); |
| 6384 result->setSizingBehavior(sizeValue); | 6384 result->setSizingBehavior(sizeValue); |
| 6385 | 6385 |
| 6386 // Or, two lengths or percentages | 6386 // Or, two lengths or percentages |
| 6387 RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalSize = nullptr; | 6387 RefPtr<CSSPrimitiveValue> horizontalSize = nullptr; |
| 6388 RefPtrWillBeRawPtr<CSSPrimitiveValue> verticalSize = nullptr; | 6388 RefPtr<CSSPrimitiveValue> verticalSize = nullptr; |
| 6389 | 6389 |
| 6390 if (!shapeValue && !sizeValue) { | 6390 if (!shapeValue && !sizeValue) { |
| 6391 if (validUnit(a, FLength | FPercent)) { | 6391 if (validUnit(a, FLength | FPercent)) { |
| 6392 horizontalSize = createPrimitiveNumericValue(a); | 6392 horizontalSize = createPrimitiveNumericValue(a); |
| 6393 a = args->next(); | 6393 a = args->next(); |
| 6394 if (!a) | 6394 if (!a) |
| 6395 return false; | 6395 return false; |
| 6396 | 6396 |
| 6397 expectComma = true; | 6397 expectComma = true; |
| 6398 } | 6398 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6414 result->setEndHorizontalSize(horizontalSize); | 6414 result->setEndHorizontalSize(horizontalSize); |
| 6415 result->setEndVerticalSize(verticalSize); | 6415 result->setEndVerticalSize(verticalSize); |
| 6416 | 6416 |
| 6417 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6417 if (!parseGradientColorStops(args, result.get(), expectComma)) |
| 6418 return false; | 6418 return false; |
| 6419 | 6419 |
| 6420 gradient = result.release(); | 6420 gradient = result.release(); |
| 6421 return true; | 6421 return true; |
| 6422 } | 6422 } |
| 6423 | 6423 |
| 6424 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6424 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, RefPt
r<CSSValue>& gradient, CSSGradientRepeat repeating) |
| 6425 { | 6425 { |
| 6426 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::
create(repeating, CSSLinearGradient); | 6426 RefPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, CSSLinearGradient); |
| 6427 | 6427 |
| 6428 CSSParserFunction* function = valueList->current()->function; | 6428 CSSParserFunction* function = valueList->current()->function; |
| 6429 CSSParserValueList* args = function->args.get(); | 6429 CSSParserValueList* args = function->args.get(); |
| 6430 if (!args || !args->size()) | 6430 if (!args || !args->size()) |
| 6431 return false; | 6431 return false; |
| 6432 | 6432 |
| 6433 CSSParserValue* a = args->current(); | 6433 CSSParserValue* a = args->current(); |
| 6434 if (!a) | 6434 if (!a) |
| 6435 return false; | 6435 return false; |
| 6436 | 6436 |
| 6437 bool expectComma = false; | 6437 bool expectComma = false; |
| 6438 // Look for angle. | 6438 // Look for angle. |
| 6439 if (validUnit(a, FAngle, HTMLStandardMode)) { | 6439 if (validUnit(a, FAngle, HTMLStandardMode)) { |
| 6440 result->setAngle(createPrimitiveNumericValue(a)); | 6440 result->setAngle(createPrimitiveNumericValue(a)); |
| 6441 | 6441 |
| 6442 args->next(); | 6442 args->next(); |
| 6443 expectComma = true; | 6443 expectComma = true; |
| 6444 } else if (a->m_unit == CSSParserValue::Identifier && a->id == CSSValueTo) { | 6444 } else if (a->m_unit == CSSParserValue::Identifier && a->id == CSSValueTo) { |
| 6445 // to [ [left | right] || [top | bottom] ] | 6445 // to [ [left | right] || [top | bottom] ] |
| 6446 a = args->next(); | 6446 a = args->next(); |
| 6447 if (!a) | 6447 if (!a) |
| 6448 return false; | 6448 return false; |
| 6449 | 6449 |
| 6450 RefPtrWillBeRawPtr<CSSPrimitiveValue> endX = nullptr; | 6450 RefPtr<CSSPrimitiveValue> endX = nullptr; |
| 6451 RefPtrWillBeRawPtr<CSSPrimitiveValue> endY = nullptr; | 6451 RefPtr<CSSPrimitiveValue> endY = nullptr; |
| 6452 RefPtrWillBeRawPtr<CSSPrimitiveValue> location = nullptr; | 6452 RefPtr<CSSPrimitiveValue> location = nullptr; |
| 6453 bool isHorizontal = false; | 6453 bool isHorizontal = false; |
| 6454 | 6454 |
| 6455 location = valueFromSideKeyword(a, isHorizontal); | 6455 location = valueFromSideKeyword(a, isHorizontal); |
| 6456 if (!location) | 6456 if (!location) |
| 6457 return false; | 6457 return false; |
| 6458 | 6458 |
| 6459 if (isHorizontal) | 6459 if (isHorizontal) |
| 6460 endX = location; | 6460 endX = location; |
| 6461 else | 6461 else |
| 6462 endY = location; | 6462 endY = location; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6488 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6488 if (!parseGradientColorStops(args, result.get(), expectComma)) |
| 6489 return false; | 6489 return false; |
| 6490 | 6490 |
| 6491 if (!result->stopCount()) | 6491 if (!result->stopCount()) |
| 6492 return false; | 6492 return false; |
| 6493 | 6493 |
| 6494 gradient = result.release(); | 6494 gradient = result.release(); |
| 6495 return true; | 6495 return true; |
| 6496 } | 6496 } |
| 6497 | 6497 |
| 6498 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6498 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt
r<CSSValue>& gradient, CSSGradientRepeat repeating) |
| 6499 { | 6499 { |
| 6500 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::
create(repeating, CSSRadialGradient); | 6500 RefPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSRadialGradient); |
| 6501 | 6501 |
| 6502 CSSParserValueList* args = valueList->current()->function->args.get(); | 6502 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6503 if (!args || !args->size()) | 6503 if (!args || !args->size()) |
| 6504 return false; | 6504 return false; |
| 6505 | 6505 |
| 6506 CSSParserValue* a = args->current(); | 6506 CSSParserValue* a = args->current(); |
| 6507 if (!a) | 6507 if (!a) |
| 6508 return false; | 6508 return false; |
| 6509 | 6509 |
| 6510 bool expectComma = false; | 6510 bool expectComma = false; |
| 6511 | 6511 |
| 6512 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; | 6512 RefPtr<CSSPrimitiveValue> shapeValue = nullptr; |
| 6513 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; | 6513 RefPtr<CSSPrimitiveValue> sizeValue = nullptr; |
| 6514 RefPtrWillBeRawPtr<CSSPrimitiveValue> horizontalSize = nullptr; | 6514 RefPtr<CSSPrimitiveValue> horizontalSize = nullptr; |
| 6515 RefPtrWillBeRawPtr<CSSPrimitiveValue> verticalSize = nullptr; | 6515 RefPtr<CSSPrimitiveValue> verticalSize = nullptr; |
| 6516 | 6516 |
| 6517 // First part of grammar, the size/shape clause: | 6517 // First part of grammar, the size/shape clause: |
| 6518 // [ circle || <length> ] | | 6518 // [ circle || <length> ] | |
| 6519 // [ ellipse || [ <length> | <percentage> ]{2} ] | | 6519 // [ ellipse || [ <length> | <percentage> ]{2} ] | |
| 6520 // [ [ circle | ellipse] || <size-keyword> ] | 6520 // [ [ circle | ellipse] || <size-keyword> ] |
| 6521 for (int i = 0; i < 3; ++i) { | 6521 for (int i = 0; i < 3; ++i) { |
| 6522 if (a->m_unit == CSSParserValue::Identifier) { | 6522 if (a->m_unit == CSSParserValue::Identifier) { |
| 6523 bool badIdent = false; | 6523 bool badIdent = false; |
| 6524 switch (a->id) { | 6524 switch (a->id) { |
| 6525 case CSSValueCircle: | 6525 case CSSValueCircle: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6580 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) | 6580 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) |
| 6581 return false; | 6581 return false; |
| 6582 | 6582 |
| 6583 result->setShape(shapeValue); | 6583 result->setShape(shapeValue); |
| 6584 result->setSizingBehavior(sizeValue); | 6584 result->setSizingBehavior(sizeValue); |
| 6585 result->setEndHorizontalSize(horizontalSize); | 6585 result->setEndHorizontalSize(horizontalSize); |
| 6586 result->setEndVerticalSize(verticalSize); | 6586 result->setEndVerticalSize(verticalSize); |
| 6587 | 6587 |
| 6588 // Second part of grammar, the center-position clause: | 6588 // Second part of grammar, the center-position clause: |
| 6589 // at <position> | 6589 // at <position> |
| 6590 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 6590 RefPtr<CSSValue> centerX = nullptr; |
| 6591 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 6591 RefPtr<CSSValue> centerY = nullptr; |
| 6592 if (a->m_unit == CSSParserValue::Identifier && a->id == CSSValueAt) { | 6592 if (a->m_unit == CSSParserValue::Identifier && a->id == CSSValueAt) { |
| 6593 a = args->next(); | 6593 a = args->next(); |
| 6594 if (!a) | 6594 if (!a) |
| 6595 return false; | 6595 return false; |
| 6596 | 6596 |
| 6597 parseFillPosition(args, centerX, centerY); | 6597 parseFillPosition(args, centerX, centerY); |
| 6598 if (!(centerX && centerY)) | 6598 if (!(centerX && centerY)) |
| 6599 return false; | 6599 return false; |
| 6600 | 6600 |
| 6601 a = args->current(); | 6601 a = args->current(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6668 } | 6668 } |
| 6669 | 6669 |
| 6670 // The last color stop cannot be a color hint. | 6670 // The last color stop cannot be a color hint. |
| 6671 if (previousStopWasColorHint) | 6671 if (previousStopWasColorHint) |
| 6672 return false; | 6672 return false; |
| 6673 | 6673 |
| 6674 // Must have 2 or more stops to be valid. | 6674 // Must have 2 or more stops to be valid. |
| 6675 return gradient->stopCount() >= 2; | 6675 return gradient->stopCount() >= 2; |
| 6676 } | 6676 } |
| 6677 | 6677 |
| 6678 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& value) | 6678 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
r<CSSValue>& value) |
| 6679 { | 6679 { |
| 6680 CSSParserValue* val = valueList->current(); | 6680 CSSParserValue* val = valueList->current(); |
| 6681 | 6681 |
| 6682 if (val->m_unit != CSSParserValue::Function) | 6682 if (val->m_unit != CSSParserValue::Function) |
| 6683 return false; | 6683 return false; |
| 6684 | 6684 |
| 6685 if (val->function->id == CSSValueWebkitGradient) { | 6685 if (val->function->id == CSSValueWebkitGradient) { |
| 6686 // FIXME: This should send a deprecation message. | 6686 // FIXME: This should send a deprecation message. |
| 6687 if (m_context.useCounter()) | 6687 if (m_context.useCounter()) |
| 6688 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); | 6688 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6730 | 6730 |
| 6731 if (val->function->id == CSSValueWebkitCanvas) | 6731 if (val->function->id == CSSValueWebkitCanvas) |
| 6732 return parseCanvas(valueList, value); | 6732 return parseCanvas(valueList, value); |
| 6733 | 6733 |
| 6734 if (val->function->id == CSSValueWebkitCrossFade) | 6734 if (val->function->id == CSSValueWebkitCrossFade) |
| 6735 return parseCrossfade(valueList, value); | 6735 return parseCrossfade(valueList, value); |
| 6736 | 6736 |
| 6737 return false; | 6737 return false; |
| 6738 } | 6738 } |
| 6739 | 6739 |
| 6740 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& crossfade) | 6740 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtr<CSS
Value>& crossfade) |
| 6741 { | 6741 { |
| 6742 // Walk the arguments. | 6742 // Walk the arguments. |
| 6743 CSSParserValueList* args = valueList->current()->function->args.get(); | 6743 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6744 if (!args || args->size() != 5) | 6744 if (!args || args->size() != 5) |
| 6745 return false; | 6745 return false; |
| 6746 RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr; | 6746 RefPtr<CSSValue> fromImageValue = nullptr; |
| 6747 RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr; | 6747 RefPtr<CSSValue> toImageValue = nullptr; |
| 6748 | 6748 |
| 6749 // The first argument is the "from" image. It is a fill image. | 6749 // The first argument is the "from" image. It is a fill image. |
| 6750 if (!args->current() || !parseFillImage(args, fromImageValue)) | 6750 if (!args->current() || !parseFillImage(args, fromImageValue)) |
| 6751 return false; | 6751 return false; |
| 6752 args->next(); | 6752 args->next(); |
| 6753 | 6753 |
| 6754 if (!consumeComma(args)) | 6754 if (!consumeComma(args)) |
| 6755 return false; | 6755 return false; |
| 6756 | 6756 |
| 6757 // The second argument is the "to" image. It is a fill image. | 6757 // The second argument is the "to" image. It is a fill image. |
| 6758 if (!args->current() || !parseFillImage(args, toImageValue)) | 6758 if (!args->current() || !parseFillImage(args, toImageValue)) |
| 6759 return false; | 6759 return false; |
| 6760 args->next(); | 6760 args->next(); |
| 6761 | 6761 |
| 6762 if (!consumeComma(args)) | 6762 if (!consumeComma(args)) |
| 6763 return false; | 6763 return false; |
| 6764 | 6764 |
| 6765 // The third argument is the crossfade value. It is a percentage or a fracti
onal number. | 6765 // The third argument is the crossfade value. It is a percentage or a fracti
onal number. |
| 6766 RefPtrWillBeRawPtr<CSSPrimitiveValue> percentage = nullptr; | 6766 RefPtr<CSSPrimitiveValue> percentage = nullptr; |
| 6767 CSSParserValue* value = args->current(); | 6767 CSSParserValue* value = args->current(); |
| 6768 if (!value) | 6768 if (!value) |
| 6769 return false; | 6769 return false; |
| 6770 | 6770 |
| 6771 if (value->unit() == CSSPrimitiveValue::UnitType::Percentage) | 6771 if (value->unit() == CSSPrimitiveValue::UnitType::Percentage) |
| 6772 percentage = cssValuePool().createValue(clampTo<double>(value->fValue /
100, 0, 1), CSSPrimitiveValue::UnitType::Number); | 6772 percentage = cssValuePool().createValue(clampTo<double>(value->fValue /
100, 0, 1), CSSPrimitiveValue::UnitType::Number); |
| 6773 else if (value->unit() == CSSPrimitiveValue::UnitType::Number) | 6773 else if (value->unit() == CSSPrimitiveValue::UnitType::Number) |
| 6774 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0
, 1), CSSPrimitiveValue::UnitType::Number); | 6774 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0
, 1), CSSPrimitiveValue::UnitType::Number); |
| 6775 else | 6775 else |
| 6776 return false; | 6776 return false; |
| 6777 | 6777 |
| 6778 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fro
mImageValue, toImageValue); | 6778 RefPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fromImageValue,
toImageValue); |
| 6779 result->setPercentage(percentage); | 6779 result->setPercentage(percentage); |
| 6780 | 6780 |
| 6781 crossfade = result; | 6781 crossfade = result; |
| 6782 | 6782 |
| 6783 return true; | 6783 return true; |
| 6784 } | 6784 } |
| 6785 | 6785 |
| 6786 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, RefPtrWillBeR
awPtr<CSSValue>& canvas) | 6786 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, RefPtr<CSSVal
ue>& canvas) |
| 6787 { | 6787 { |
| 6788 // Walk the arguments. | 6788 // Walk the arguments. |
| 6789 CSSParserValueList* args = valueList->current()->function->args.get(); | 6789 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6790 if (!args || args->size() != 1) | 6790 if (!args || args->size() != 1) |
| 6791 return false; | 6791 return false; |
| 6792 | 6792 |
| 6793 // The first argument is the canvas name. It is an identifier. | 6793 // The first argument is the canvas name. It is an identifier. |
| 6794 CSSParserValue* value = args->current(); | 6794 CSSParserValue* value = args->current(); |
| 6795 if (!value || value->m_unit != CSSParserValue::Identifier) | 6795 if (!value || value->m_unit != CSSParserValue::Identifier) |
| 6796 return false; | 6796 return false; |
| 6797 | 6797 |
| 6798 canvas = CSSCanvasValue::create(value->string); | 6798 canvas = CSSCanvasValue::create(value->string); |
| 6799 return true; | 6799 return true; |
| 6800 } | 6800 } |
| 6801 | 6801 |
| 6802 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
List* valueList) | 6802 PassRefPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValueList* valueL
ist) |
| 6803 { | 6803 { |
| 6804 CSSParserValue* function = valueList->current(); | 6804 CSSParserValue* function = valueList->current(); |
| 6805 | 6805 |
| 6806 if (function->m_unit != CSSParserValue::Function) | 6806 if (function->m_unit != CSSParserValue::Function) |
| 6807 return nullptr; | 6807 return nullptr; |
| 6808 | 6808 |
| 6809 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); | 6809 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); |
| 6810 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 6810 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
| 6811 return nullptr; | 6811 return nullptr; |
| 6812 | 6812 |
| 6813 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 6813 RefPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
| 6814 | 6814 |
| 6815 while (functionArgs->current()) { | 6815 while (functionArgs->current()) { |
| 6816 CSSParserValue* arg = functionArgs->current(); | 6816 CSSParserValue* arg = functionArgs->current(); |
| 6817 if (arg->unit() != CSSPrimitiveValue::UnitType::URI) | 6817 if (arg->unit() != CSSPrimitiveValue::UnitType::URI) |
| 6818 return nullptr; | 6818 return nullptr; |
| 6819 | 6819 |
| 6820 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg
->string, completeURL(arg->string)); | 6820 RefPtr<CSSValue> image = createCSSImageValueWithReferrer(arg->string, co
mpleteURL(arg->string)); |
| 6821 imageSet->append(image); | 6821 imageSet->append(image); |
| 6822 | 6822 |
| 6823 arg = functionArgs->next(); | 6823 arg = functionArgs->next(); |
| 6824 if (!arg) | 6824 if (!arg) |
| 6825 return nullptr; | 6825 return nullptr; |
| 6826 | 6826 |
| 6827 if (arg->m_unit != CSSParserValue::DimensionList) | 6827 if (arg->m_unit != CSSParserValue::DimensionList) |
| 6828 return nullptr; | 6828 return nullptr; |
| 6829 ASSERT(arg->valueList->valueAt(0)->unit() == CSSPrimitiveValue::UnitType
::Number); | 6829 ASSERT(arg->valueList->valueAt(0)->unit() == CSSPrimitiveValue::UnitType
::Number); |
| 6830 ASSERT(arg->valueList->valueAt(1)->m_unit == CSSParserValue::Identifier)
; | 6830 ASSERT(arg->valueList->valueAt(1)->m_unit == CSSParserValue::Identifier)
; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6841 break; | 6841 break; |
| 6842 | 6842 |
| 6843 // If there are more arguments, they should be after a comma. | 6843 // If there are more arguments, they should be after a comma. |
| 6844 if (!consumeComma(functionArgs)) | 6844 if (!consumeComma(functionArgs)) |
| 6845 return nullptr; | 6845 return nullptr; |
| 6846 } | 6846 } |
| 6847 | 6847 |
| 6848 return imageSet.release(); | 6848 return imageSet.release(); |
| 6849 } | 6849 } |
| 6850 | 6850 |
| 6851 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange() | 6851 PassRefPtr<CSSValue> CSSPropertyParser::parseWillChange() |
| 6852 { | 6852 { |
| 6853 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 6853 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); |
| 6854 if (m_valueList->current()->id == CSSValueAuto) { | 6854 if (m_valueList->current()->id == CSSValueAuto) { |
| 6855 // FIXME: This will be read back as an empty string instead of auto | 6855 // FIXME: This will be read back as an empty string instead of auto |
| 6856 return values.release(); | 6856 return values.release(); |
| 6857 } | 6857 } |
| 6858 | 6858 |
| 6859 // Every comma-separated list of identifiers is a valid will-change value, | 6859 // Every comma-separated list of identifiers is a valid will-change value, |
| 6860 // unless the list includes an explicitly disallowed identifier. | 6860 // unless the list includes an explicitly disallowed identifier. |
| 6861 while (true) { | 6861 while (true) { |
| 6862 CSSParserValue* currentValue = m_valueList->current(); | 6862 CSSParserValue* currentValue = m_valueList->current(); |
| 6863 if (!currentValue || currentValue->m_unit != CSSParserValue::Identifier) | 6863 if (!currentValue || currentValue->m_unit != CSSParserValue::Identifier) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6891 | 6891 |
| 6892 if (!m_valueList->next()) | 6892 if (!m_valueList->next()) |
| 6893 break; | 6893 break; |
| 6894 if (!consumeComma(m_valueList)) | 6894 if (!consumeComma(m_valueList)) |
| 6895 return nullptr; | 6895 return nullptr; |
| 6896 } | 6896 } |
| 6897 | 6897 |
| 6898 return values.release(); | 6898 return values.release(); |
| 6899 } | 6899 } |
| 6900 | 6900 |
| 6901 PassRefPtrWillBeRawPtr<CSSFunctionValue> CSSPropertyParser::parseBuiltinFilterAr
guments(CSSParserValueList* args, CSSValueID filterType) | 6901 PassRefPtr<CSSFunctionValue> CSSPropertyParser::parseBuiltinFilterArguments(CSSP
arserValueList* args, CSSValueID filterType) |
| 6902 { | 6902 { |
| 6903 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(
filterType); | 6903 RefPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(filterType); |
| 6904 ASSERT(args); | 6904 ASSERT(args); |
| 6905 | 6905 |
| 6906 switch (filterType) { | 6906 switch (filterType) { |
| 6907 case CSSValueGrayscale: | 6907 case CSSValueGrayscale: |
| 6908 case CSSValueSepia: | 6908 case CSSValueSepia: |
| 6909 case CSSValueSaturate: | 6909 case CSSValueSaturate: |
| 6910 case CSSValueInvert: | 6910 case CSSValueInvert: |
| 6911 case CSSValueOpacity: | 6911 case CSSValueOpacity: |
| 6912 case CSSValueContrast: { | 6912 case CSSValueContrast: { |
| 6913 // One optional argument, 0-1 or 0%-100%, if missing use 100%. | 6913 // One optional argument, 0-1 or 0%-100%, if missing use 100%. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6962 CSSParserValue* argument = args->current(); | 6962 CSSParserValue* argument = args->current(); |
| 6963 if (!validUnit(argument, FLength | FNonNeg, HTMLStandardMode)) | 6963 if (!validUnit(argument, FLength | FNonNeg, HTMLStandardMode)) |
| 6964 return nullptr; | 6964 return nullptr; |
| 6965 | 6965 |
| 6966 filterValue->append(createPrimitiveNumericValue(argument)); | 6966 filterValue->append(createPrimitiveNumericValue(argument)); |
| 6967 } | 6967 } |
| 6968 break; | 6968 break; |
| 6969 } | 6969 } |
| 6970 case CSSValueDropShadow: { | 6970 case CSSValueDropShadow: { |
| 6971 // drop-shadow() takes a single shadow. | 6971 // drop-shadow() takes a single shadow. |
| 6972 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(args, CSS
PropertyWebkitFilter); | 6972 RefPtr<CSSValueList> shadowValueList = parseShadow(args, CSSPropertyWebk
itFilter); |
| 6973 if (!shadowValueList || shadowValueList->length() != 1) | 6973 if (!shadowValueList || shadowValueList->length() != 1) |
| 6974 return nullptr; | 6974 return nullptr; |
| 6975 | 6975 |
| 6976 filterValue->append((shadowValueList.release())->item(0)); | 6976 filterValue->append((shadowValueList.release())->item(0)); |
| 6977 break; | 6977 break; |
| 6978 } | 6978 } |
| 6979 default: | 6979 default: |
| 6980 return nullptr; | 6980 return nullptr; |
| 6981 } | 6981 } |
| 6982 return filterValue.release(); | 6982 return filterValue.release(); |
| 6983 } | 6983 } |
| 6984 | 6984 |
| 6985 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter() | 6985 PassRefPtr<CSSValueList> CSSPropertyParser::parseFilter() |
| 6986 { | 6986 { |
| 6987 if (!m_valueList) | 6987 if (!m_valueList) |
| 6988 return nullptr; | 6988 return nullptr; |
| 6989 | 6989 |
| 6990 // The filter is a list of functional primitives that specify individual ope
rations. | 6990 // The filter is a list of functional primitives that specify individual ope
rations. |
| 6991 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 6991 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 6992 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 6992 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 6993 if (value->unit() != CSSPrimitiveValue::UnitType::URI && (value->m_unit
!= CSSParserValue::Function || !value->function)) | 6993 if (value->unit() != CSSPrimitiveValue::UnitType::URI && (value->m_unit
!= CSSParserValue::Function || !value->function)) |
| 6994 return nullptr; | 6994 return nullptr; |
| 6995 | 6995 |
| 6996 // See if the specified primitive is one we understand. | 6996 // See if the specified primitive is one we understand. |
| 6997 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { | 6997 if (value->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 6998 RefPtrWillBeRawPtr<CSSFunctionValue> referenceFilterValue = CSSFunct
ionValue::create(CSSValueUrl); | 6998 RefPtr<CSSFunctionValue> referenceFilterValue = CSSFunctionValue::cr
eate(CSSValueUrl); |
| 6999 referenceFilterValue->append(CSSSVGDocumentValue::create(value->stri
ng)); | 6999 referenceFilterValue->append(CSSSVGDocumentValue::create(value->stri
ng)); |
| 7000 list->append(referenceFilterValue.release()); | 7000 list->append(referenceFilterValue.release()); |
| 7001 } else { | 7001 } else { |
| 7002 CSSValueID filterType = value->function->id; | 7002 CSSValueID filterType = value->function->id; |
| 7003 unsigned maximumArgumentCount = filterType == CSSValueDropShadow ? 4
: 1; | 7003 unsigned maximumArgumentCount = filterType == CSSValueDropShadow ? 4
: 1; |
| 7004 | 7004 |
| 7005 CSSParserValueList* args = value->function->args.get(); | 7005 CSSParserValueList* args = value->function->args.get(); |
| 7006 if (!args || args->size() > maximumArgumentCount) | 7006 if (!args || args->size() > maximumArgumentCount) |
| 7007 return nullptr; | 7007 return nullptr; |
| 7008 | 7008 |
| 7009 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = parseBuiltinFilte
rArguments(args, filterType); | 7009 RefPtr<CSSFunctionValue> filterValue = parseBuiltinFilterArguments(a
rgs, filterType); |
| 7010 if (!filterValue) | 7010 if (!filterValue) |
| 7011 return nullptr; | 7011 return nullptr; |
| 7012 | 7012 |
| 7013 list->append(filterValue); | 7013 list->append(filterValue); |
| 7014 } | 7014 } |
| 7015 } | 7015 } |
| 7016 | 7016 |
| 7017 return list.release(); | 7017 return list.release(); |
| 7018 } | 7018 } |
| 7019 | 7019 |
| 7020 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() | 7020 PassRefPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() |
| 7021 { | 7021 { |
| 7022 CSSParserValue* value = m_valueList->current(); | 7022 CSSParserValue* value = m_valueList->current(); |
| 7023 CSSValueID id = value->id; | 7023 CSSValueID id = value->id; |
| 7024 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 7024 RefPtr<CSSValue> xValue = nullptr; |
| 7025 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 7025 RefPtr<CSSValue> yValue = nullptr; |
| 7026 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; | 7026 RefPtr<CSSValue> zValue = nullptr; |
| 7027 if (id == CSSValueLeft || id == CSSValueRight) { | 7027 if (id == CSSValueLeft || id == CSSValueRight) { |
| 7028 xValue = cssValuePool().createIdentifierValue(id); | 7028 xValue = cssValuePool().createIdentifierValue(id); |
| 7029 } else if (id == CSSValueTop || id == CSSValueBottom) { | 7029 } else if (id == CSSValueTop || id == CSSValueBottom) { |
| 7030 yValue = cssValuePool().createIdentifierValue(id); | 7030 yValue = cssValuePool().createIdentifierValue(id); |
| 7031 } else if (id == CSSValueCenter) { | 7031 } else if (id == CSSValueCenter) { |
| 7032 // Unresolved as to whether this is X or Y. | 7032 // Unresolved as to whether this is X or Y. |
| 7033 } else if (validUnit(value, FPercent | FLength)) { | 7033 } else if (validUnit(value, FPercent | FLength)) { |
| 7034 xValue = createPrimitiveNumericValue(value); | 7034 xValue = createPrimitiveNumericValue(value); |
| 7035 } else { | 7035 } else { |
| 7036 return nullptr; | 7036 return nullptr; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7068 return nullptr; | 7068 return nullptr; |
| 7069 } | 7069 } |
| 7070 } else if (!xValue) { | 7070 } else if (!xValue) { |
| 7071 if (yValue) { | 7071 if (yValue) { |
| 7072 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::UnitType:
:Percentage); | 7072 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::UnitType:
:Percentage); |
| 7073 } else { | 7073 } else { |
| 7074 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); | 7074 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); |
| 7075 } | 7075 } |
| 7076 } | 7076 } |
| 7077 | 7077 |
| 7078 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7078 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 7079 list->append(xValue.release()); | 7079 list->append(xValue.release()); |
| 7080 if (yValue) | 7080 if (yValue) |
| 7081 list->append(yValue.release()); | 7081 list->append(yValue.release()); |
| 7082 if (zValue) | 7082 if (zValue) |
| 7083 list->append(zValue.release()); | 7083 list->append(zValue.release()); |
| 7084 return list.release(); | 7084 return list.release(); |
| 7085 } | 7085 } |
| 7086 | 7086 |
| 7087 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction() | 7087 PassRefPtr<CSSValue> CSSPropertyParser::parseTouchAction() |
| 7088 { | 7088 { |
| 7089 CSSParserValue* value = m_valueList->current(); | 7089 CSSParserValue* value = m_valueList->current(); |
| 7090 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7090 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 7091 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value
->id == CSSValueNone || value->id == CSSValueManipulation)) { | 7091 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value
->id == CSSValueNone || value->id == CSSValueManipulation)) { |
| 7092 list->append(cssValuePool().createIdentifierValue(value->id)); | 7092 list->append(cssValuePool().createIdentifierValue(value->id)); |
| 7093 m_valueList->next(); | 7093 m_valueList->next(); |
| 7094 return list.release(); | 7094 return list.release(); |
| 7095 } | 7095 } |
| 7096 | 7096 |
| 7097 bool xSet = false; | 7097 bool xSet = false; |
| 7098 bool ySet = false; | 7098 bool ySet = false; |
| 7099 while (value) { | 7099 while (value) { |
| 7100 switch (value->id) { | 7100 switch (value->id) { |
| 7101 case CSSValuePanX: | 7101 case CSSValuePanX: |
| 7102 case CSSValuePanRight: | 7102 case CSSValuePanRight: |
| 7103 case CSSValuePanLeft: { | 7103 case CSSValuePanLeft: { |
| 7104 if (xSet) | 7104 if (xSet) |
| 7105 return nullptr; | 7105 return nullptr; |
| 7106 xSet = true; | 7106 xSet = true; |
| 7107 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) | 7107 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) |
| 7108 return nullptr; | 7108 return nullptr; |
| 7109 | 7109 |
| 7110 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif
ierValue(value->id); | 7110 RefPtr<CSSValue> panValue = cssValuePool().createIdentifierValue(val
ue->id); |
| 7111 list->append(panValue.release()); | 7111 list->append(panValue.release()); |
| 7112 break; | 7112 break; |
| 7113 } | 7113 } |
| 7114 case CSSValuePanY: | 7114 case CSSValuePanY: |
| 7115 case CSSValuePanDown: | 7115 case CSSValuePanDown: |
| 7116 case CSSValuePanUp: { | 7116 case CSSValuePanUp: { |
| 7117 if (ySet) | 7117 if (ySet) |
| 7118 return nullptr; | 7118 return nullptr; |
| 7119 ySet = true; | 7119 ySet = true; |
| 7120 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) | 7120 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) |
| 7121 return nullptr; | 7121 return nullptr; |
| 7122 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif
ierValue(value->id); | 7122 RefPtr<CSSValue> panValue = cssValuePool().createIdentifierValue(val
ue->id); |
| 7123 list->append(panValue.release()); | 7123 list->append(panValue.release()); |
| 7124 break; | 7124 break; |
| 7125 } | 7125 } |
| 7126 default: | 7126 default: |
| 7127 return nullptr; | 7127 return nullptr; |
| 7128 } | 7128 } |
| 7129 value = m_valueList->next(); | 7129 value = m_valueList->next(); |
| 7130 } | 7130 } |
| 7131 | 7131 |
| 7132 if (list->length()) | 7132 if (list->length()) |
| 7133 return list.release(); | 7133 return list.release(); |
| 7134 | 7134 |
| 7135 return nullptr; | 7135 return nullptr; |
| 7136 } | 7136 } |
| 7137 | 7137 |
| 7138 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextDecoration() | 7138 PassRefPtr<CSSValue> CSSPropertyParser::parseTextDecoration() |
| 7139 { | 7139 { |
| 7140 CSSParserValue* value = m_valueList->current(); | 7140 CSSParserValue* value = m_valueList->current(); |
| 7141 if (value && value->id == CSSValueNone) { | 7141 if (value && value->id == CSSValueNone) { |
| 7142 m_valueList->next(); | 7142 m_valueList->next(); |
| 7143 return cssValuePool().createIdentifierValue(CSSValueNone); | 7143 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 7144 } | 7144 } |
| 7145 | 7145 |
| 7146 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7146 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 7147 bool isValid = true; | 7147 bool isValid = true; |
| 7148 while (isValid && value) { | 7148 while (isValid && value) { |
| 7149 switch (value->id) { | 7149 switch (value->id) { |
| 7150 case CSSValueUnderline: | 7150 case CSSValueUnderline: |
| 7151 case CSSValueOverline: | 7151 case CSSValueOverline: |
| 7152 case CSSValueLineThrough: | 7152 case CSSValueLineThrough: |
| 7153 case CSSValueBlink: | 7153 case CSSValueBlink: |
| 7154 // TODO(timloh): This will incorrectly accept "blink blink" | 7154 // TODO(timloh): This will incorrectly accept "blink blink" |
| 7155 list->append(cssValuePool().createIdentifierValue(value->id)); | 7155 list->append(cssValuePool().createIdentifierValue(value->id)); |
| 7156 break; | 7156 break; |
| 7157 default: | 7157 default: |
| 7158 isValid = false; | 7158 isValid = false; |
| 7159 break; | 7159 break; |
| 7160 } | 7160 } |
| 7161 if (isValid) | 7161 if (isValid) |
| 7162 value = m_valueList->next(); | 7162 value = m_valueList->next(); |
| 7163 } | 7163 } |
| 7164 | 7164 |
| 7165 // Values are either valid or in shorthand scope. | 7165 // Values are either valid or in shorthand scope. |
| 7166 if (list->length()) | 7166 if (list->length()) |
| 7167 return list.release(); | 7167 return list.release(); |
| 7168 return nullptr; | 7168 return nullptr; |
| 7169 } | 7169 } |
| 7170 | 7170 |
| 7171 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() | 7171 PassRefPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() |
| 7172 { | 7172 { |
| 7173 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; | 7173 RefPtr<CSSPrimitiveValue> fill = nullptr; |
| 7174 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; | 7174 RefPtr<CSSPrimitiveValue> shape = nullptr; |
| 7175 | 7175 |
| 7176 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7176 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 7177 if (value->unit() == CSSPrimitiveValue::UnitType::String) { | 7177 if (value->unit() == CSSPrimitiveValue::UnitType::String) { |
| 7178 if (fill || shape) | 7178 if (fill || shape) |
| 7179 return nullptr; | 7179 return nullptr; |
| 7180 m_valueList->next(); | 7180 m_valueList->next(); |
| 7181 return createPrimitiveStringValue(value); | 7181 return createPrimitiveStringValue(value); |
| 7182 } | 7182 } |
| 7183 | 7183 |
| 7184 if (value->id == CSSValueNone) { | 7184 if (value->id == CSSValueNone) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7195 } else if (value->id == CSSValueDot || value->id == CSSValueCircle || va
lue->id == CSSValueDoubleCircle || value->id == CSSValueTriangle || value->id ==
CSSValueSesame) { | 7195 } else if (value->id == CSSValueDot || value->id == CSSValueCircle || va
lue->id == CSSValueDoubleCircle || value->id == CSSValueTriangle || value->id ==
CSSValueSesame) { |
| 7196 if (shape) | 7196 if (shape) |
| 7197 return nullptr; | 7197 return nullptr; |
| 7198 shape = cssValuePool().createIdentifierValue(value->id); | 7198 shape = cssValuePool().createIdentifierValue(value->id); |
| 7199 } else { | 7199 } else { |
| 7200 break; | 7200 break; |
| 7201 } | 7201 } |
| 7202 } | 7202 } |
| 7203 | 7203 |
| 7204 if (fill && shape) { | 7204 if (fill && shape) { |
| 7205 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpac
eSeparated(); | 7205 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated()
; |
| 7206 parsedValues->append(fill.release()); | 7206 parsedValues->append(fill.release()); |
| 7207 parsedValues->append(shape.release()); | 7207 parsedValues->append(shape.release()); |
| 7208 return parsedValues.release(); | 7208 return parsedValues.release(); |
| 7209 } | 7209 } |
| 7210 if (fill) | 7210 if (fill) |
| 7211 return fill.release(); | 7211 return fill.release(); |
| 7212 if (shape) | 7212 if (shape) |
| 7213 return shape.release(); | 7213 return shape.release(); |
| 7214 | 7214 |
| 7215 return nullptr; | 7215 return nullptr; |
| 7216 } | 7216 } |
| 7217 | 7217 |
| 7218 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() | 7218 PassRefPtr<CSSValue> CSSPropertyParser::parseTextIndent() |
| 7219 { | 7219 { |
| 7220 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7220 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 7221 | 7221 |
| 7222 bool hasLengthOrPercentage = false; | 7222 bool hasLengthOrPercentage = false; |
| 7223 bool hasEachLine = false; | 7223 bool hasEachLine = false; |
| 7224 bool hasHanging = false; | 7224 bool hasHanging = false; |
| 7225 | 7225 |
| 7226 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7226 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 7227 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te
xtEnabled() returns false | 7227 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te
xtEnabled() returns false |
| 7228 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni
tlessQuirk)) { | 7228 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni
tlessQuirk)) { |
| 7229 list->append(createPrimitiveNumericValue(value)); | 7229 list->append(createPrimitiveNumericValue(value)); |
| 7230 hasLengthOrPercentage = true; | 7230 hasLengthOrPercentage = true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7247 } | 7247 } |
| 7248 return nullptr; | 7248 return nullptr; |
| 7249 } | 7249 } |
| 7250 | 7250 |
| 7251 if (!hasLengthOrPercentage) | 7251 if (!hasLengthOrPercentage) |
| 7252 return nullptr; | 7252 return nullptr; |
| 7253 | 7253 |
| 7254 return list.release(); | 7254 return list.release(); |
| 7255 } | 7255 } |
| 7256 | 7256 |
| 7257 PassRefPtrWillBeRawPtr<CSSLineBoxContainValue> CSSPropertyParser::parseLineBoxCo
ntain() | 7257 PassRefPtr<CSSLineBoxContainValue> CSSPropertyParser::parseLineBoxContain() |
| 7258 { | 7258 { |
| 7259 LineBoxContain lineBoxContain = LineBoxContainNone; | 7259 LineBoxContain lineBoxContain = LineBoxContainNone; |
| 7260 | 7260 |
| 7261 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7261 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 7262 LineBoxContainFlags flag; | 7262 LineBoxContainFlags flag; |
| 7263 if (value->id == CSSValueBlock) { | 7263 if (value->id == CSSValueBlock) { |
| 7264 flag = LineBoxContainBlock; | 7264 flag = LineBoxContainBlock; |
| 7265 } else if (value->id == CSSValueInline) { | 7265 } else if (value->id == CSSValueInline) { |
| 7266 flag = LineBoxContainInline; | 7266 flag = LineBoxContainInline; |
| 7267 } else if (value->id == CSSValueFont) { | 7267 } else if (value->id == CSSValueFont) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7314 m_valueList->next(); | 7314 m_valueList->next(); |
| 7315 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { | 7315 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { |
| 7316 tagValue = value->id == CSSValueOn; | 7316 tagValue = value->id == CSSValueOn; |
| 7317 m_valueList->next(); | 7317 m_valueList->next(); |
| 7318 } | 7318 } |
| 7319 } | 7319 } |
| 7320 settings->append(CSSFontFeatureValue::create(tag, tagValue)); | 7320 settings->append(CSSFontFeatureValue::create(tag, tagValue)); |
| 7321 return true; | 7321 return true; |
| 7322 } | 7322 } |
| 7323 | 7323 |
| 7324 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() | 7324 PassRefPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() |
| 7325 { | 7325 { |
| 7326 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat
ed(); | 7326 RefPtr<CSSValueList> settings = CSSValueList::createCommaSeparated(); |
| 7327 while (true) { | 7327 while (true) { |
| 7328 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) | 7328 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) |
| 7329 return nullptr; | 7329 return nullptr; |
| 7330 if (!m_valueList->current()) | 7330 if (!m_valueList->current()) |
| 7331 break; | 7331 break; |
| 7332 if (!consumeComma(m_valueList)) | 7332 if (!consumeComma(m_valueList)) |
| 7333 return nullptr; | 7333 return nullptr; |
| 7334 } | 7334 } |
| 7335 return settings.release(); | 7335 return settings.release(); |
| 7336 } | 7336 } |
| 7337 | 7337 |
| 7338 bool CSSPropertyParser::parseFontVariantLigatures(bool important) | 7338 bool CSSPropertyParser::parseFontVariantLigatures(bool important) |
| 7339 { | 7339 { |
| 7340 RefPtrWillBeRawPtr<CSSValueList> ligatureValues = CSSValueList::createSpaceS
eparated(); | 7340 RefPtr<CSSValueList> ligatureValues = CSSValueList::createSpaceSeparated(); |
| 7341 bool sawCommonLigaturesValue = false; | 7341 bool sawCommonLigaturesValue = false; |
| 7342 bool sawDiscretionaryLigaturesValue = false; | 7342 bool sawDiscretionaryLigaturesValue = false; |
| 7343 bool sawHistoricalLigaturesValue = false; | 7343 bool sawHistoricalLigaturesValue = false; |
| 7344 bool sawContextualLigaturesValue = false; | 7344 bool sawContextualLigaturesValue = false; |
| 7345 | 7345 |
| 7346 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7346 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 7347 if (value->m_unit != CSSParserValue::Identifier) | 7347 if (value->m_unit != CSSParserValue::Identifier) |
| 7348 return false; | 7348 return false; |
| 7349 | 7349 |
| 7350 switch (value->id) { | 7350 switch (value->id) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7401 return false; | 7401 return false; |
| 7402 | 7402 |
| 7403 return true; | 7403 return true; |
| 7404 } | 7404 } |
| 7405 | 7405 |
| 7406 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) | 7406 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) |
| 7407 { | 7407 { |
| 7408 CSSParserValue* value = m_valueList->current(); | 7408 CSSParserValue* value = m_valueList->current(); |
| 7409 ASSERT(value); | 7409 ASSERT(value); |
| 7410 CSSValueID id = value->id; | 7410 CSSValueID id = value->id; |
| 7411 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 7411 RefPtr<CSSValue> parsedValue = nullptr; |
| 7412 | 7412 |
| 7413 switch (propId) { | 7413 switch (propId) { |
| 7414 case CSSPropertyFontFamily: | 7414 case CSSPropertyFontFamily: |
| 7415 // <family-name> | 7415 // <family-name> |
| 7416 // TODO(rwlbuis): check there is only one family-name | 7416 // TODO(rwlbuis): check there is only one family-name |
| 7417 parsedValue = parseFontFamily(); | 7417 parsedValue = parseFontFamily(); |
| 7418 break; | 7418 break; |
| 7419 case CSSPropertySrc: // This is a list of urls or local references. | 7419 case CSSPropertySrc: // This is a list of urls or local references. |
| 7420 parsedValue = parseFontFaceSrc(); | 7420 parsedValue = parseFontFaceSrc(); |
| 7421 break; | 7421 break; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7488 if (id == CSSValueZoom || id == CSSValueFixed) | 7488 if (id == CSSValueZoom || id == CSSValueFixed) |
| 7489 validPrimitive = true; | 7489 validPrimitive = true; |
| 7490 break; | 7490 break; |
| 7491 case CSSPropertyOrientation: // auto | portrait | landscape | 7491 case CSSPropertyOrientation: // auto | portrait | landscape |
| 7492 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc
ape) | 7492 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc
ape) |
| 7493 validPrimitive = true; | 7493 validPrimitive = true; |
| 7494 default: | 7494 default: |
| 7495 break; | 7495 break; |
| 7496 } | 7496 } |
| 7497 | 7497 |
| 7498 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 7498 RefPtr<CSSValue> parsedValue = nullptr; |
| 7499 if (validPrimitive) { | 7499 if (validPrimitive) { |
| 7500 parsedValue = parseValidPrimitive(id, value); | 7500 parsedValue = parseValidPrimitive(id, value); |
| 7501 m_valueList->next(); | 7501 m_valueList->next(); |
| 7502 } | 7502 } |
| 7503 | 7503 |
| 7504 if (parsedValue) { | 7504 if (parsedValue) { |
| 7505 if (!m_valueList->current() || inShorthand()) { | 7505 if (!m_valueList->current() || inShorthand()) { |
| 7506 addProperty(propId, parsedValue.release(), important); | 7506 addProperty(propId, parsedValue.release(), important); |
| 7507 return true; | 7507 return true; |
| 7508 } | 7508 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7613 } | 7613 } |
| 7614 | 7614 |
| 7615 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) | 7615 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) |
| 7616 { | 7616 { |
| 7617 CSSParserValue* value = m_valueList->current(); | 7617 CSSParserValue* value = m_valueList->current(); |
| 7618 ASSERT(value); | 7618 ASSERT(value); |
| 7619 | 7619 |
| 7620 CSSValueID id = value->id; | 7620 CSSValueID id = value->id; |
| 7621 | 7621 |
| 7622 bool validPrimitive = false; | 7622 bool validPrimitive = false; |
| 7623 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 7623 RefPtr<CSSValue> parsedValue = nullptr; |
| 7624 | 7624 |
| 7625 switch (propId) { | 7625 switch (propId) { |
| 7626 /* The comment to the right defines all valid value of these | 7626 /* The comment to the right defines all valid value of these |
| 7627 * properties as defined in SVG 1.1, Appendix N. Property index */ | 7627 * properties as defined in SVG 1.1, Appendix N. Property index */ |
| 7628 case CSSPropertyBaselineShift: | 7628 case CSSPropertyBaselineShift: |
| 7629 // baseline | super | sub | <percentage> | <length> | inherit | 7629 // baseline | super | sub | <percentage> | <length> | inherit |
| 7630 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | 7630 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) |
| 7631 validPrimitive = true; | 7631 validPrimitive = true; |
| 7632 else | 7632 else |
| 7633 validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMo
de); | 7633 validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMo
de); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7678 } | 7678 } |
| 7679 break; | 7679 break; |
| 7680 | 7680 |
| 7681 case CSSPropertyFill: // <paint> | inherit | 7681 case CSSPropertyFill: // <paint> | inherit |
| 7682 case CSSPropertyStroke: // <paint> | inherit | 7682 case CSSPropertyStroke: // <paint> | inherit |
| 7683 { | 7683 { |
| 7684 if (id == CSSValueNone) { | 7684 if (id == CSSValueNone) { |
| 7685 parsedValue = cssValuePool().createIdentifierValue(id); | 7685 parsedValue = cssValuePool().createIdentifierValue(id); |
| 7686 } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) { | 7686 } else if (value->unit() == CSSPrimitiveValue::UnitType::URI) { |
| 7687 if (m_valueList->next()) { | 7687 if (m_valueList->next()) { |
| 7688 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea
teSpaceSeparated(); | 7688 RefPtr<CSSValueList> values = CSSValueList::createSpaceSepar
ated(); |
| 7689 values->append(CSSPrimitiveValue::create(value->string, CSSP
rimitiveValue::UnitType::URI)); | 7689 values->append(CSSPrimitiveValue::create(value->string, CSSP
rimitiveValue::UnitType::URI)); |
| 7690 if (m_valueList->current()->id == CSSValueNone) | 7690 if (m_valueList->current()->id == CSSValueNone) |
| 7691 parsedValue = cssValuePool().createIdentifierValue(m_val
ueList->current()->id); | 7691 parsedValue = cssValuePool().createIdentifierValue(m_val
ueList->current()->id); |
| 7692 else | 7692 else |
| 7693 parsedValue = parseColor(m_valueList->current()); | 7693 parsedValue = parseColor(m_valueList->current()); |
| 7694 if (parsedValue) { | 7694 if (parsedValue) { |
| 7695 values->append(parsedValue); | 7695 values->append(parsedValue); |
| 7696 parsedValue = values; | 7696 parsedValue = values; |
| 7697 } | 7697 } |
| 7698 } | 7698 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7782 } | 7782 } |
| 7783 m_valueList->next(); | 7783 m_valueList->next(); |
| 7784 } | 7784 } |
| 7785 if (!parsedValue || (m_valueList->current() && !inShorthand())) | 7785 if (!parsedValue || (m_valueList->current() && !inShorthand())) |
| 7786 return false; | 7786 return false; |
| 7787 | 7787 |
| 7788 addProperty(propId, parsedValue.release(), important); | 7788 addProperty(propId, parsedValue.release(), important); |
| 7789 return true; | 7789 return true; |
| 7790 } | 7790 } |
| 7791 | 7791 |
| 7792 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray() | 7792 PassRefPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray() |
| 7793 { | 7793 { |
| 7794 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); | 7794 RefPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); |
| 7795 CSSParserValue* value = m_valueList->current(); | 7795 CSSParserValue* value = m_valueList->current(); |
| 7796 bool validPrimitive = true; | 7796 bool validPrimitive = true; |
| 7797 while (value) { | 7797 while (value) { |
| 7798 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri
buteMode); | 7798 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri
buteMode); |
| 7799 if (!validPrimitive) | 7799 if (!validPrimitive) |
| 7800 break; | 7800 break; |
| 7801 if (value->id) | 7801 if (value->id) |
| 7802 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); | 7802 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); |
| 7803 else if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->
unit() <= CSSPrimitiveValue::UnitType::Kilohertz) | 7803 else if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->
unit() <= CSSPrimitiveValue::UnitType::Kilohertz) |
| 7804 ret->append(CSSPrimitiveValue::create(value->fValue, value->unit()))
; | 7804 ret->append(CSSPrimitiveValue::create(value->fValue, value->unit()))
; |
| 7805 else if (value->unit() == CSSPrimitiveValue::UnitType::Rems || value->un
it() == CSSPrimitiveValue::UnitType::Chs) | 7805 else if (value->unit() == CSSPrimitiveValue::UnitType::Rems || value->un
it() == CSSPrimitiveValue::UnitType::Chs) |
| 7806 ret->append(CSSPrimitiveValue::create(value->fValue, value->unit()))
; | 7806 ret->append(CSSPrimitiveValue::create(value->fValue, value->unit()))
; |
| 7807 value = m_valueList->next(); | 7807 value = m_valueList->next(); |
| 7808 bool commaConsumed = consumeComma(m_valueList); | 7808 bool commaConsumed = consumeComma(m_valueList); |
| 7809 value = m_valueList->current(); | 7809 value = m_valueList->current(); |
| 7810 if (commaConsumed && !value) | 7810 if (commaConsumed && !value) |
| 7811 return nullptr; | 7811 return nullptr; |
| 7812 } | 7812 } |
| 7813 if (!validPrimitive) | 7813 if (!validPrimitive) |
| 7814 return nullptr; | 7814 return nullptr; |
| 7815 return ret.release(); | 7815 return ret.release(); |
| 7816 } | 7816 } |
| 7817 | 7817 |
| 7818 // normal | [ fill || stroke || markers ] | 7818 // normal | [ fill || stroke || markers ] |
| 7819 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const | 7819 PassRefPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const |
| 7820 { | 7820 { |
| 7821 if (m_valueList->size() > 3) | 7821 if (m_valueList->size() > 3) |
| 7822 return nullptr; | 7822 return nullptr; |
| 7823 | 7823 |
| 7824 CSSParserValue* value = m_valueList->current(); | 7824 CSSParserValue* value = m_valueList->current(); |
| 7825 ASSERT(value); | 7825 ASSERT(value); |
| 7826 | 7826 |
| 7827 Vector<CSSValueID, 3> paintTypeList; | 7827 Vector<CSSValueID, 3> paintTypeList; |
| 7828 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; | 7828 RefPtr<CSSPrimitiveValue> fill = nullptr; |
| 7829 RefPtrWillBeRawPtr<CSSPrimitiveValue> stroke = nullptr; | 7829 RefPtr<CSSPrimitiveValue> stroke = nullptr; |
| 7830 RefPtrWillBeRawPtr<CSSPrimitiveValue> markers = nullptr; | 7830 RefPtr<CSSPrimitiveValue> markers = nullptr; |
| 7831 while (value) { | 7831 while (value) { |
| 7832 if (value->id == CSSValueFill && !fill) | 7832 if (value->id == CSSValueFill && !fill) |
| 7833 fill = CSSPrimitiveValue::createIdentifier(value->id); | 7833 fill = CSSPrimitiveValue::createIdentifier(value->id); |
| 7834 else if (value->id == CSSValueStroke && !stroke) | 7834 else if (value->id == CSSValueStroke && !stroke) |
| 7835 stroke = CSSPrimitiveValue::createIdentifier(value->id); | 7835 stroke = CSSPrimitiveValue::createIdentifier(value->id); |
| 7836 else if (value->id == CSSValueMarkers && !markers) | 7836 else if (value->id == CSSValueMarkers && !markers) |
| 7837 markers = CSSPrimitiveValue::createIdentifier(value->id); | 7837 markers = CSSPrimitiveValue::createIdentifier(value->id); |
| 7838 else | 7838 else |
| 7839 return nullptr; | 7839 return nullptr; |
| 7840 paintTypeList.append(value->id); | 7840 paintTypeList.append(value->id); |
| 7841 value = m_valueList->next(); | 7841 value = m_valueList->next(); |
| 7842 } | 7842 } |
| 7843 | 7843 |
| 7844 // After parsing we serialize the paint-order list. Since it is not possible
to | 7844 // After parsing we serialize the paint-order list. Since it is not possible
to |
| 7845 // pop a last list items from CSSValueList without bigger cost, we create th
e | 7845 // pop a last list items from CSSValueList without bigger cost, we create th
e |
| 7846 // list after parsing. | 7846 // list after parsing. |
| 7847 CSSValueID firstPaintOrderType = paintTypeList.at(0); | 7847 CSSValueID firstPaintOrderType = paintTypeList.at(0); |
| 7848 RefPtrWillBeRawPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceS
eparated(); | 7848 RefPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceSeparated(); |
| 7849 switch (firstPaintOrderType) { | 7849 switch (firstPaintOrderType) { |
| 7850 case CSSValueFill: | 7850 case CSSValueFill: |
| 7851 case CSSValueStroke: | 7851 case CSSValueStroke: |
| 7852 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releas
e() : stroke.release()); | 7852 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releas
e() : stroke.release()); |
| 7853 if (paintTypeList.size() > 1) { | 7853 if (paintTypeList.size() > 1) { |
| 7854 if (paintTypeList.at(1) == CSSValueMarkers) | 7854 if (paintTypeList.at(1) == CSSValueMarkers) |
| 7855 paintOrderList->append(markers.release()); | 7855 paintOrderList->append(markers.release()); |
| 7856 } | 7856 } |
| 7857 break; | 7857 break; |
| 7858 case CSSValueMarkers: | 7858 case CSSValueMarkers: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7964 | 7964 |
| 7965 bool hasCorrectArgCount(unsigned argCount) { return m_argCount == argCount |
| (m_allowSingleArgument && argCount == 1); } | 7965 bool hasCorrectArgCount(unsigned argCount) { return m_argCount == argCount |
| (m_allowSingleArgument && argCount == 1); } |
| 7966 | 7966 |
| 7967 private: | 7967 private: |
| 7968 bool m_validID; | 7968 bool m_validID; |
| 7969 bool m_allowSingleArgument; | 7969 bool m_allowSingleArgument; |
| 7970 unsigned m_argCount; | 7970 unsigned m_argCount; |
| 7971 CSSPropertyParser::Units m_unit; | 7971 CSSPropertyParser::Units m_unit; |
| 7972 }; | 7972 }; |
| 7973 | 7973 |
| 7974 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL
egacyParsing) | 7974 PassRefPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useLegacyParsing
) |
| 7975 { | 7975 { |
| 7976 if (!m_valueList) | 7976 if (!m_valueList) |
| 7977 return nullptr; | 7977 return nullptr; |
| 7978 | 7978 |
| 7979 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7979 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 7980 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7980 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 7981 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue(
useLegacyParsing, value); | 7981 RefPtr<CSSValue> parsedTransformValue = parseTransformValue(useLegacyPar
sing, value); |
| 7982 if (!parsedTransformValue) | 7982 if (!parsedTransformValue) |
| 7983 return nullptr; | 7983 return nullptr; |
| 7984 | 7984 |
| 7985 list->append(parsedTransformValue.release()); | 7985 list->append(parsedTransformValue.release()); |
| 7986 } | 7986 } |
| 7987 | 7987 |
| 7988 return list.release(); | 7988 return list.release(); |
| 7989 } | 7989 } |
| 7990 | 7990 |
| 7991 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(bool use
LegacyParsing, CSSParserValue *value) | 7991 PassRefPtr<CSSValue> CSSPropertyParser::parseTransformValue(bool useLegacyParsin
g, CSSParserValue *value) |
| 7992 { | 7992 { |
| 7993 if (value->m_unit != CSSParserValue::Function || !value->function) | 7993 if (value->m_unit != CSSParserValue::Function || !value->function) |
| 7994 return nullptr; | 7994 return nullptr; |
| 7995 | 7995 |
| 7996 // Every primitive requires at least one argument. | 7996 // Every primitive requires at least one argument. |
| 7997 CSSParserValueList* args = value->function->args.get(); | 7997 CSSParserValueList* args = value->function->args.get(); |
| 7998 if (!args) | 7998 if (!args) |
| 7999 return nullptr; | 7999 return nullptr; |
| 8000 | 8000 |
| 8001 // See if the specified primitive is one we understand. | 8001 // See if the specified primitive is one we understand. |
| 8002 CSSValueID type = value->function->id; | 8002 CSSValueID type = value->function->id; |
| 8003 TransformOperationInfo info(type); | 8003 TransformOperationInfo info(type); |
| 8004 if (!info.validID()) | 8004 if (!info.validID()) |
| 8005 return nullptr; | 8005 return nullptr; |
| 8006 | 8006 |
| 8007 if (!info.hasCorrectArgCount(args->size())) | 8007 if (!info.hasCorrectArgCount(args->size())) |
| 8008 return nullptr; | 8008 return nullptr; |
| 8009 | 8009 |
| 8010 // The transform is a list of functional primitives that specify transform o
perations. | 8010 // The transform is a list of functional primitives that specify transform o
perations. |
| 8011 // We collect a list of CSSFunctionValues, where each value specifies a sing
le operation. | 8011 // We collect a list of CSSFunctionValues, where each value specifies a sing
le operation. |
| 8012 | 8012 |
| 8013 // Create the new CSSFunctionValue for this operation and add it to our list
. | 8013 // Create the new CSSFunctionValue for this operation and add it to our list
. |
| 8014 RefPtrWillBeRawPtr<CSSFunctionValue> transformValue = CSSFunctionValue::crea
te(type); | 8014 RefPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(type); |
| 8015 | 8015 |
| 8016 // Snag our values. | 8016 // Snag our values. |
| 8017 CSSParserValue* a = args->current(); | 8017 CSSParserValue* a = args->current(); |
| 8018 unsigned argNumber = 0; | 8018 unsigned argNumber = 0; |
| 8019 while (a) { | 8019 while (a) { |
| 8020 CSSPropertyParser::Units unit = info.unit(); | 8020 CSSPropertyParser::Units unit = info.unit(); |
| 8021 | 8021 |
| 8022 if (type == CSSValueRotate3d && argNumber == 3) { | 8022 if (type == CSSValueRotate3d && argNumber == 3) { |
| 8023 // 4th param of rotate3d() is an angle rather than a bare number, va
lidate it as such | 8023 // 4th param of rotate3d() is an angle rather than a bare number, va
lidate it as such |
| 8024 if (!validUnit(a, FAngle, HTMLStandardMode)) | 8024 if (!validUnit(a, FAngle, HTMLStandardMode)) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 8053 if (!isComma(a)) | 8053 if (!isComma(a)) |
| 8054 return nullptr; | 8054 return nullptr; |
| 8055 a = args->next(); | 8055 a = args->next(); |
| 8056 | 8056 |
| 8057 argNumber++; | 8057 argNumber++; |
| 8058 } | 8058 } |
| 8059 | 8059 |
| 8060 return transformValue.release(); | 8060 return transformValue.release(); |
| 8061 } | 8061 } |
| 8062 | 8062 |
| 8063 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() | 8063 PassRefPtr<CSSValue> CSSPropertyParser::parseMotionPath() |
| 8064 { | 8064 { |
| 8065 CSSParserValue* value = m_valueList->current(); | 8065 CSSParserValue* value = m_valueList->current(); |
| 8066 | 8066 |
| 8067 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. | 8067 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
| 8068 if (value->m_unit != CSSParserValue::Function || value->function->id != CSSV
aluePath) | 8068 if (value->m_unit != CSSParserValue::Function || value->function->id != CSSV
aluePath) |
| 8069 return nullptr; | 8069 return nullptr; |
| 8070 | 8070 |
| 8071 // FIXME: Add support for <fill-rule>. | 8071 // FIXME: Add support for <fill-rule>. |
| 8072 CSSParserValueList* functionArgs = value->function->args.get(); | 8072 CSSParserValueList* functionArgs = value->function->args.get(); |
| 8073 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) | 8073 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) |
| 8074 return nullptr; | 8074 return nullptr; |
| 8075 | 8075 |
| 8076 CSSParserValue* arg = functionArgs->current(); | 8076 CSSParserValue* arg = functionArgs->current(); |
| 8077 if (arg->unit() != CSSPrimitiveValue::UnitType::String) | 8077 if (arg->unit() != CSSPrimitiveValue::UnitType::String) |
| 8078 return nullptr; | 8078 return nullptr; |
| 8079 | 8079 |
| 8080 String pathString = arg->string; | 8080 String pathString = arg->string; |
| 8081 Path path; | 8081 Path path; |
| 8082 if (!buildPathFromString(pathString, path)) | 8082 if (!buildPathFromString(pathString, path)) |
| 8083 return nullptr; | 8083 return nullptr; |
| 8084 | 8084 |
| 8085 m_valueList->next(); | 8085 m_valueList->next(); |
| 8086 return CSSPathValue::create(pathString); | 8086 return CSSPathValue::create(pathString); |
| 8087 } | 8087 } |
| 8088 | 8088 |
| 8089 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionRotation() | 8089 PassRefPtr<CSSValue> CSSPropertyParser::parseMotionRotation() |
| 8090 { | 8090 { |
| 8091 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 8091 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 8092 bool hasAutoOrReverse = false; | 8092 bool hasAutoOrReverse = false; |
| 8093 bool hasAngle = false; | 8093 bool hasAngle = false; |
| 8094 | 8094 |
| 8095 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8095 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
| 8096 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA
utoOrReverse) { | 8096 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA
utoOrReverse) { |
| 8097 list->append(cssValuePool().createIdentifierValue(value->id)); | 8097 list->append(cssValuePool().createIdentifierValue(value->id)); |
| 8098 hasAutoOrReverse = true; | 8098 hasAutoOrReverse = true; |
| 8099 } else if (!hasAngle && validUnit(value, FAngle)) { | 8099 } else if (!hasAngle && validUnit(value, FAngle)) { |
| 8100 list->append(createPrimitiveNumericValue(value)); | 8100 list->append(createPrimitiveNumericValue(value)); |
| 8101 hasAngle = true; | 8101 hasAngle = true; |
| 8102 } else { | 8102 } else { |
| 8103 break; | 8103 break; |
| 8104 } | 8104 } |
| 8105 } | 8105 } |
| 8106 | 8106 |
| 8107 if (!list->length()) | 8107 if (!list->length()) |
| 8108 return nullptr; | 8108 return nullptr; |
| 8109 | 8109 |
| 8110 return list.release(); | 8110 return list.release(); |
| 8111 } | 8111 } |
| 8112 | 8112 |
| 8113 } // namespace blink | 8113 } // namespace blink |
| OLD | NEW |