| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSPropertyParser.h" | 5 #include "core/css/parser/CSSPropertyParser.h" |
| 6 | 6 |
| 7 #include "core/StylePropertyShorthand.h" | 7 #include "core/StylePropertyShorthand.h" |
| 8 #include "core/css/CSSBasicShapeValues.h" | 8 #include "core/css/CSSBasicShapeValues.h" |
| 9 #include "core/css/CSSBorderImage.h" | 9 #include "core/css/CSSBorderImage.h" |
| 10 #include "core/css/CSSContentDistributionValue.h" | 10 #include "core/css/CSSContentDistributionValue.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // This doesn't count UA style sheets | 94 // This doesn't count UA style sheets |
| 95 if (parseSuccess && context.useCounter()) | 95 if (parseSuccess && context.useCounter()) |
| 96 context.useCounter()->count(context.mode(), unresolvedProperty); | 96 context.useCounter()->count(context.mode(), unresolvedProperty); |
| 97 | 97 |
| 98 if (!parseSuccess) | 98 if (!parseSuccess) |
| 99 parsedProperties.shrink(parsedPropertiesSize); | 99 parsedProperties.shrink(parsedPropertiesSize); |
| 100 | 100 |
| 101 return parseSuccess; | 101 return parseSuccess; |
| 102 } | 102 } |
| 103 | 103 |
| 104 RawPtr<CSSValue> CSSPropertyParser::parseSingleValue( | 104 CSSValue* CSSPropertyParser::parseSingleValue( |
| 105 CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserCon
text& context) | 105 CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserCon
text& context) |
| 106 { | 106 { |
| 107 if (hasInvalidNumericValues(range)) | 107 if (hasInvalidNumericValues(range)) |
| 108 return nullptr; | 108 return nullptr; |
| 109 CSSPropertyParser parser(range, context, nullptr); | 109 CSSPropertyParser parser(range, context, nullptr); |
| 110 RawPtr<CSSValue> value = parser.parseSingleValue(property); | 110 CSSValue* value = parser.parseSingleValue(property); |
| 111 if (!value || !parser.m_range.atEnd()) | 111 if (!value || !parser.m_range.atEnd()) |
| 112 return nullptr; | 112 return nullptr; |
| 113 return value.release(); | 113 return value; |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool CSSPropertyParser::isValidNumericValue(double value) | 116 bool CSSPropertyParser::isValidNumericValue(double value) |
| 117 { | 117 { |
| 118 return std::isfinite(value) | 118 return std::isfinite(value) |
| 119 && value >= -std::numeric_limits<float>::max() | 119 && value >= -std::numeric_limits<float>::max() |
| 120 && value <= std::numeric_limits<float>::max(); | 120 && value <= std::numeric_limits<float>::max(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool CSSPropertyParser::parseValueStart(CSSPropertyID unresolvedProperty, bool i
mportant) | 123 bool CSSPropertyParser::parseValueStart(CSSPropertyID unresolvedProperty, bool i
mportant) |
| 124 { | 124 { |
| 125 if (consumeCSSWideKeyword(unresolvedProperty, important)) | 125 if (consumeCSSWideKeyword(unresolvedProperty, important)) |
| 126 return true; | 126 return true; |
| 127 | 127 |
| 128 CSSParserTokenRange originalRange = m_range; | 128 CSSParserTokenRange originalRange = m_range; |
| 129 CSSPropertyID propertyId = resolveCSSPropertyID(unresolvedProperty); | 129 CSSPropertyID propertyId = resolveCSSPropertyID(unresolvedProperty); |
| 130 | 130 |
| 131 if (isShorthandProperty(propertyId)) { | 131 if (isShorthandProperty(propertyId)) { |
| 132 if (parseShorthand(unresolvedProperty, important)) | 132 if (parseShorthand(unresolvedProperty, important)) |
| 133 return true; | 133 return true; |
| 134 } else { | 134 } else { |
| 135 if (RawPtr<CSSValue> parsedValue = parseSingleValue(unresolvedProperty))
{ | 135 if (CSSValue* parsedValue = parseSingleValue(unresolvedProperty)) { |
| 136 if (m_range.atEnd()) { | 136 if (m_range.atEnd()) { |
| 137 addProperty(propertyId, parsedValue.release(), important); | 137 addProperty(propertyId, parsedValue, important); |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::cont
ainsValidVariableReferences(originalRange)) { | 143 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::cont
ainsValidVariableReferences(originalRange)) { |
| 144 // We don't expand the shorthand here because crazypants. | 144 // We don't expand the shorthand here because crazypants. |
| 145 RawPtr<CSSVariableReferenceValue> variable = CSSVariableReferenceValue::
create(CSSVariableData::create(originalRange)); | 145 CSSVariableReferenceValue* variable = CSSVariableReferenceValue::create(
CSSVariableData::create(originalRange)); |
| 146 addProperty(propertyId, variable.release(), important); | 146 addProperty(propertyId, variable, important); |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| 149 | 149 |
| 150 return false; | 150 return false; |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool CSSPropertyParser::isColorKeyword(CSSValueID id) | 153 bool CSSPropertyParser::isColorKeyword(CSSValueID id) |
| 154 { | 154 { |
| 155 // Named colors and color keywords: | 155 // Named colors and color keywords: |
| 156 // | 156 // |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); | 259 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); |
| 260 } | 260 } |
| 261 | 261 |
| 262 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID unresolvedProperty,
bool important) | 262 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID unresolvedProperty,
bool important) |
| 263 { | 263 { |
| 264 CSSParserTokenRange rangeCopy = m_range; | 264 CSSParserTokenRange rangeCopy = m_range; |
| 265 CSSValueID id = rangeCopy.consumeIncludingWhitespace().id(); | 265 CSSValueID id = rangeCopy.consumeIncludingWhitespace().id(); |
| 266 if (!rangeCopy.atEnd()) | 266 if (!rangeCopy.atEnd()) |
| 267 return false; | 267 return false; |
| 268 | 268 |
| 269 RawPtr<CSSValue> value = nullptr; | 269 CSSValue* value = nullptr; |
| 270 if (id == CSSValueInitial) | 270 if (id == CSSValueInitial) |
| 271 value = cssValuePool().createExplicitInitialValue(); | 271 value = cssValuePool().createExplicitInitialValue(); |
| 272 else if (id == CSSValueInherit) | 272 else if (id == CSSValueInherit) |
| 273 value = cssValuePool().createInheritedValue(); | 273 value = cssValuePool().createInheritedValue(); |
| 274 else if (id == CSSValueUnset) | 274 else if (id == CSSValueUnset) |
| 275 value = cssValuePool().createUnsetValue(); | 275 value = cssValuePool().createUnsetValue(); |
| 276 else | 276 else |
| 277 return false; | 277 return false; |
| 278 | 278 |
| 279 addExpandedPropertyForValue(resolveCSSPropertyID(unresolvedProperty), value.
release(), important); | 279 addExpandedPropertyForValue(resolveCSSPropertyID(unresolvedProperty), value,
important); |
| 280 m_range = rangeCopy; | 280 m_range = rangeCopy; |
| 281 return true; | 281 return true; |
| 282 } | 282 } |
| 283 | 283 |
| 284 static RawPtr<CSSValueList> consumeTransformOrigin(CSSParserTokenRange& range, C
SSParserMode cssParserMode, UnitlessQuirk unitless) | 284 static CSSValueList* consumeTransformOrigin(CSSParserTokenRange& range, CSSParse
rMode cssParserMode, UnitlessQuirk unitless) |
| 285 { | 285 { |
| 286 RawPtr<CSSValue> resultX = nullptr; | 286 CSSValue* resultX = nullptr; |
| 287 RawPtr<CSSValue> resultY = nullptr; | 287 CSSValue* resultY = nullptr; |
| 288 if (consumeOneOrTwoValuedPosition(range, cssParserMode, unitless, resultX, r
esultY)) { | 288 if (consumeOneOrTwoValuedPosition(range, cssParserMode, unitless, resultX, r
esultY)) { |
| 289 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 289 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 290 list->append(resultX.release()); | 290 list->append(resultX); |
| 291 list->append(resultY.release()); | 291 list->append(resultY); |
| 292 RawPtr<CSSValue> resultZ = consumeLength(range, cssParserMode, ValueRang
eAll); | 292 CSSValue* resultZ = consumeLength(range, cssParserMode, ValueRangeAll); |
| 293 if (!resultZ) | 293 if (!resultZ) |
| 294 resultZ = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType:
:Pixels); | 294 resultZ = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType:
:Pixels); |
| 295 list->append(resultZ.release()); | 295 list->append(resultZ); |
| 296 return list.release(); | 296 return list; |
| 297 } | 297 } |
| 298 return nullptr; | 298 return nullptr; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Methods for consuming non-shorthand properties starts here. | 301 // Methods for consuming non-shorthand properties starts here. |
| 302 static RawPtr<CSSValue> consumeWillChange(CSSParserTokenRange& range) | 302 static CSSValue* consumeWillChange(CSSParserTokenRange& range) |
| 303 { | 303 { |
| 304 if (range.peek().id() == CSSValueAuto) | 304 if (range.peek().id() == CSSValueAuto) |
| 305 return consumeIdent(range); | 305 return consumeIdent(range); |
| 306 | 306 |
| 307 RawPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); | 307 CSSValueList* values = CSSValueList::createCommaSeparated(); |
| 308 // Every comma-separated list of identifiers is a valid will-change value, | 308 // Every comma-separated list of identifiers is a valid will-change value, |
| 309 // unless the list includes an explicitly disallowed identifier. | 309 // unless the list includes an explicitly disallowed identifier. |
| 310 while (true) { | 310 while (true) { |
| 311 if (range.peek().type() != IdentToken) | 311 if (range.peek().type() != IdentToken) |
| 312 return nullptr; | 312 return nullptr; |
| 313 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(range.peek().
value()); | 313 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(range.peek().
value()); |
| 314 if (unresolvedProperty) { | 314 if (unresolvedProperty) { |
| 315 ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty)); | 315 ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty)); |
| 316 // Now "all" is used by both CSSValue and CSSPropertyValue. | 316 // Now "all" is used by both CSSValue and CSSPropertyValue. |
| 317 // Need to return nullptr when currentValue is CSSPropertyAll. | 317 // Need to return nullptr when currentValue is CSSPropertyAll. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 337 break; | 337 break; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 if (range.atEnd()) | 341 if (range.atEnd()) |
| 342 break; | 342 break; |
| 343 if (!consumeCommaIncludingWhitespace(range)) | 343 if (!consumeCommaIncludingWhitespace(range)) |
| 344 return nullptr; | 344 return nullptr; |
| 345 } | 345 } |
| 346 | 346 |
| 347 return values.release(); | 347 return values; |
| 348 } | 348 } |
| 349 | 349 |
| 350 static RawPtr<CSSFontFeatureValue> consumeFontFeatureTag(CSSParserTokenRange& ra
nge) | 350 static CSSFontFeatureValue* consumeFontFeatureTag(CSSParserTokenRange& range) |
| 351 { | 351 { |
| 352 // Feature tag name consists of 4-letter characters. | 352 // Feature tag name consists of 4-letter characters. |
| 353 static const unsigned tagNameLength = 4; | 353 static const unsigned tagNameLength = 4; |
| 354 | 354 |
| 355 const CSSParserToken& token = range.consumeIncludingWhitespace(); | 355 const CSSParserToken& token = range.consumeIncludingWhitespace(); |
| 356 // Feature tag name comes first | 356 // Feature tag name comes first |
| 357 if (token.type() != StringToken) | 357 if (token.type() != StringToken) |
| 358 return nullptr; | 358 return nullptr; |
| 359 if (token.value().length() != tagNameLength) | 359 if (token.value().length() != tagNameLength) |
| 360 return nullptr; | 360 return nullptr; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 371 if (range.peek().type() == NumberToken && range.peek().numericValueType() ==
IntegerValueType && range.peek().numericValue() >= 0) { | 371 if (range.peek().type() == NumberToken && range.peek().numericValueType() ==
IntegerValueType && range.peek().numericValue() >= 0) { |
| 372 tagValue = clampTo<int>(range.consumeIncludingWhitespace().numericValue(
)); | 372 tagValue = clampTo<int>(range.consumeIncludingWhitespace().numericValue(
)); |
| 373 if (tagValue < 0) | 373 if (tagValue < 0) |
| 374 return nullptr; | 374 return nullptr; |
| 375 } else if (range.peek().id() == CSSValueOn || range.peek().id() == CSSValueO
ff) { | 375 } else if (range.peek().id() == CSSValueOn || range.peek().id() == CSSValueO
ff) { |
| 376 tagValue = range.consumeIncludingWhitespace().id() == CSSValueOn; | 376 tagValue = range.consumeIncludingWhitespace().id() == CSSValueOn; |
| 377 } | 377 } |
| 378 return CSSFontFeatureValue::create(tag, tagValue); | 378 return CSSFontFeatureValue::create(tag, tagValue); |
| 379 } | 379 } |
| 380 | 380 |
| 381 static RawPtr<CSSValue> consumeFontFeatureSettings(CSSParserTokenRange& range) | 381 static CSSValue* consumeFontFeatureSettings(CSSParserTokenRange& range) |
| 382 { | 382 { |
| 383 if (range.peek().id() == CSSValueNormal) | 383 if (range.peek().id() == CSSValueNormal) |
| 384 return consumeIdent(range); | 384 return consumeIdent(range); |
| 385 RawPtr<CSSValueList> settings = CSSValueList::createCommaSeparated(); | 385 CSSValueList* settings = CSSValueList::createCommaSeparated(); |
| 386 do { | 386 do { |
| 387 RawPtr<CSSFontFeatureValue> fontFeatureValue = consumeFontFeatureTag(ran
ge); | 387 CSSFontFeatureValue* fontFeatureValue = consumeFontFeatureTag(range); |
| 388 if (!fontFeatureValue) | 388 if (!fontFeatureValue) |
| 389 return nullptr; | 389 return nullptr; |
| 390 settings->append(fontFeatureValue); | 390 settings->append(fontFeatureValue); |
| 391 } while (consumeCommaIncludingWhitespace(range)); | 391 } while (consumeCommaIncludingWhitespace(range)); |
| 392 return settings.release(); | 392 return settings; |
| 393 } | 393 } |
| 394 | 394 |
| 395 static RawPtr<CSSValue> consumePage(CSSParserTokenRange& range) | 395 static CSSValue* consumePage(CSSParserTokenRange& range) |
| 396 { | 396 { |
| 397 if (range.peek().id() == CSSValueAuto) | 397 if (range.peek().id() == CSSValueAuto) |
| 398 return consumeIdent(range); | 398 return consumeIdent(range); |
| 399 return consumeCustomIdent(range); | 399 return consumeCustomIdent(range); |
| 400 } | 400 } |
| 401 | 401 |
| 402 static RawPtr<CSSValue> consumeQuotes(CSSParserTokenRange& range) | 402 static CSSValue* consumeQuotes(CSSParserTokenRange& range) |
| 403 { | 403 { |
| 404 if (range.peek().id() == CSSValueNone) | 404 if (range.peek().id() == CSSValueNone) |
| 405 return consumeIdent(range); | 405 return consumeIdent(range); |
| 406 RawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); | 406 CSSValueList* values = CSSValueList::createSpaceSeparated(); |
| 407 while (!range.atEnd()) { | 407 while (!range.atEnd()) { |
| 408 RawPtr<CSSStringValue> parsedValue = consumeString(range); | 408 CSSStringValue* parsedValue = consumeString(range); |
| 409 if (!parsedValue) | 409 if (!parsedValue) |
| 410 return nullptr; | 410 return nullptr; |
| 411 values->append(parsedValue.release()); | 411 values->append(parsedValue); |
| 412 } | 412 } |
| 413 if (values->length() && values->length() % 2 == 0) | 413 if (values->length() && values->length() % 2 == 0) |
| 414 return values.release(); | 414 return values; |
| 415 return nullptr; | 415 return nullptr; |
| 416 } | 416 } |
| 417 | 417 |
| 418 static RawPtr<CSSValue> consumeWebkitHighlight(CSSParserTokenRange& range) | 418 static CSSValue* consumeWebkitHighlight(CSSParserTokenRange& range) |
| 419 { | 419 { |
| 420 if (range.peek().id() == CSSValueNone) | 420 if (range.peek().id() == CSSValueNone) |
| 421 return consumeIdent(range); | 421 return consumeIdent(range); |
| 422 return consumeString(range); | 422 return consumeString(range); |
| 423 } | 423 } |
| 424 | 424 |
| 425 static RawPtr<CSSValue> consumeFontVariantLigatures(CSSParserTokenRange& range) | 425 static CSSValue* consumeFontVariantLigatures(CSSParserTokenRange& range) |
| 426 { | 426 { |
| 427 if (range.peek().id() == CSSValueNormal) | 427 if (range.peek().id() == CSSValueNormal) |
| 428 return consumeIdent(range); | 428 return consumeIdent(range); |
| 429 RawPtr<CSSValueList> ligatureValues = CSSValueList::createSpaceSeparated(); | 429 CSSValueList* ligatureValues = CSSValueList::createSpaceSeparated(); |
| 430 bool sawCommonLigaturesValue = false; | 430 bool sawCommonLigaturesValue = false; |
| 431 bool sawDiscretionaryLigaturesValue = false; | 431 bool sawDiscretionaryLigaturesValue = false; |
| 432 bool sawHistoricalLigaturesValue = false; | 432 bool sawHistoricalLigaturesValue = false; |
| 433 bool sawContextualLigaturesValue = false; | 433 bool sawContextualLigaturesValue = false; |
| 434 do { | 434 do { |
| 435 CSSValueID id = range.peek().id(); | 435 CSSValueID id = range.peek().id(); |
| 436 switch (id) { | 436 switch (id) { |
| 437 case CSSValueNoCommonLigatures: | 437 case CSSValueNoCommonLigatures: |
| 438 case CSSValueCommonLigatures: | 438 case CSSValueCommonLigatures: |
| 439 if (sawCommonLigaturesValue) | 439 if (sawCommonLigaturesValue) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 457 if (sawContextualLigaturesValue) | 457 if (sawContextualLigaturesValue) |
| 458 return nullptr; | 458 return nullptr; |
| 459 sawContextualLigaturesValue = true; | 459 sawContextualLigaturesValue = true; |
| 460 break; | 460 break; |
| 461 default: | 461 default: |
| 462 return nullptr; | 462 return nullptr; |
| 463 } | 463 } |
| 464 ligatureValues->append(consumeIdent(range)); | 464 ligatureValues->append(consumeIdent(range)); |
| 465 } while (!range.atEnd()); | 465 } while (!range.atEnd()); |
| 466 | 466 |
| 467 return ligatureValues.release(); | 467 return ligatureValues; |
| 468 } | 468 } |
| 469 | 469 |
| 470 static RawPtr<CSSPrimitiveValue> consumeFontVariant(CSSParserTokenRange& range) | 470 static CSSPrimitiveValue* consumeFontVariant(CSSParserTokenRange& range) |
| 471 { | 471 { |
| 472 return consumeIdent<CSSValueNormal, CSSValueSmallCaps>(range); | 472 return consumeIdent<CSSValueNormal, CSSValueSmallCaps>(range); |
| 473 } | 473 } |
| 474 | 474 |
| 475 static RawPtr<CSSValue> consumeFontVariantList(CSSParserTokenRange& range) | 475 static CSSValue* consumeFontVariantList(CSSParserTokenRange& range) |
| 476 { | 476 { |
| 477 RawPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); | 477 CSSValueList* values = CSSValueList::createCommaSeparated(); |
| 478 do { | 478 do { |
| 479 if (range.peek().id() == CSSValueAll) { | 479 if (range.peek().id() == CSSValueAll) { |
| 480 // FIXME: CSSPropertyParser::parseFontVariant() implements | 480 // FIXME: CSSPropertyParser::parseFontVariant() implements |
| 481 // the old css3 draft: | 481 // the old css3 draft: |
| 482 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant | 482 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant |
| 483 // 'all' is only allowed in @font-face and with no other values. | 483 // 'all' is only allowed in @font-face and with no other values. |
| 484 if (values->length()) | 484 if (values->length()) |
| 485 return nullptr; | 485 return nullptr; |
| 486 return consumeIdent(range); | 486 return consumeIdent(range); |
| 487 } | 487 } |
| 488 RawPtr<CSSPrimitiveValue> fontVariant = consumeFontVariant(range); | 488 CSSPrimitiveValue* fontVariant = consumeFontVariant(range); |
| 489 if (fontVariant) | 489 if (fontVariant) |
| 490 values->append(fontVariant.release()); | 490 values->append(fontVariant); |
| 491 } while (consumeCommaIncludingWhitespace(range)); | 491 } while (consumeCommaIncludingWhitespace(range)); |
| 492 | 492 |
| 493 if (values->length()) | 493 if (values->length()) |
| 494 return values.release(); | 494 return values; |
| 495 | 495 |
| 496 return nullptr; | 496 return nullptr; |
| 497 } | 497 } |
| 498 | 498 |
| 499 static RawPtr<CSSPrimitiveValue> consumeFontWeight(CSSParserTokenRange& range) | 499 static CSSPrimitiveValue* consumeFontWeight(CSSParserTokenRange& range) |
| 500 { | 500 { |
| 501 const CSSParserToken& token = range.peek(); | 501 const CSSParserToken& token = range.peek(); |
| 502 if (token.id() >= CSSValueNormal && token.id() <= CSSValueLighter) | 502 if (token.id() >= CSSValueNormal && token.id() <= CSSValueLighter) |
| 503 return consumeIdent(range); | 503 return consumeIdent(range); |
| 504 if (token.type() != NumberToken || token.numericValueType() != IntegerValueT
ype) | 504 if (token.type() != NumberToken || token.numericValueType() != IntegerValueT
ype) |
| 505 return nullptr; | 505 return nullptr; |
| 506 int weight = static_cast<int>(token.numericValue()); | 506 int weight = static_cast<int>(token.numericValue()); |
| 507 if ((weight % 100) || weight < 100 || weight > 900) | 507 if ((weight % 100) || weight < 100 || weight > 900) |
| 508 return nullptr; | 508 return nullptr; |
| 509 range.consumeIncludingWhitespace(); | 509 range.consumeIncludingWhitespace(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 520 builder.append(' '); | 520 builder.append(' '); |
| 521 addedSpace = true; | 521 addedSpace = true; |
| 522 } | 522 } |
| 523 builder.append(range.consumeIncludingWhitespace().value()); | 523 builder.append(range.consumeIncludingWhitespace().value()); |
| 524 } | 524 } |
| 525 if (!addedSpace && isCSSWideKeyword(firstToken.id())) | 525 if (!addedSpace && isCSSWideKeyword(firstToken.id())) |
| 526 return String(); | 526 return String(); |
| 527 return builder.toString(); | 527 return builder.toString(); |
| 528 } | 528 } |
| 529 | 529 |
| 530 static RawPtr<CSSValue> consumeFamilyName(CSSParserTokenRange& range) | 530 static CSSValue* consumeFamilyName(CSSParserTokenRange& range) |
| 531 { | 531 { |
| 532 if (range.peek().type() == StringToken) | 532 if (range.peek().type() == StringToken) |
| 533 return cssValuePool().createFontFamilyValue(range.consumeIncludingWhites
pace().value()); | 533 return cssValuePool().createFontFamilyValue(range.consumeIncludingWhites
pace().value()); |
| 534 if (range.peek().type() != IdentToken) | 534 if (range.peek().type() != IdentToken) |
| 535 return nullptr; | 535 return nullptr; |
| 536 String familyName = concatenateFamilyName(range); | 536 String familyName = concatenateFamilyName(range); |
| 537 if (familyName.isNull()) | 537 if (familyName.isNull()) |
| 538 return nullptr; | 538 return nullptr; |
| 539 return cssValuePool().createFontFamilyValue(familyName); | 539 return cssValuePool().createFontFamilyValue(familyName); |
| 540 } | 540 } |
| 541 | 541 |
| 542 static RawPtr<CSSValue> consumeGenericFamily(CSSParserTokenRange& range) | 542 static CSSValue* consumeGenericFamily(CSSParserTokenRange& range) |
| 543 { | 543 { |
| 544 return consumeIdentRange(range, CSSValueSerif, CSSValueWebkitBody); | 544 return consumeIdentRange(range, CSSValueSerif, CSSValueWebkitBody); |
| 545 } | 545 } |
| 546 | 546 |
| 547 static RawPtr<CSSValueList> consumeFontFamily(CSSParserTokenRange& range) | 547 static CSSValueList* consumeFontFamily(CSSParserTokenRange& range) |
| 548 { | 548 { |
| 549 RawPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); | 549 CSSValueList* list = CSSValueList::createCommaSeparated(); |
| 550 do { | 550 do { |
| 551 RawPtr<CSSValue> parsedValue = nullptr; | 551 CSSValue* parsedValue = consumeGenericFamily(range); |
| 552 if ((parsedValue = consumeGenericFamily(range))) { | 552 if (parsedValue) { |
| 553 list->append(parsedValue); | |
| 554 } else if ((parsedValue = consumeFamilyName(range))) { | |
| 555 list->append(parsedValue); | 553 list->append(parsedValue); |
| 556 } else { | 554 } else { |
| 557 return nullptr; | 555 parsedValue = consumeFamilyName(range); |
| 556 if (parsedValue) { |
| 557 list->append(parsedValue); |
| 558 } else { |
| 559 return nullptr; |
| 560 } |
| 558 } | 561 } |
| 559 } while (consumeCommaIncludingWhitespace(range)); | 562 } while (consumeCommaIncludingWhitespace(range)); |
| 560 return list.release(); | 563 return list; |
| 561 } | 564 } |
| 562 | 565 |
| 563 static RawPtr<CSSValue> consumeSpacing(CSSParserTokenRange& range, CSSParserMode
cssParserMode) | 566 static CSSValue* consumeSpacing(CSSParserTokenRange& range, CSSParserMode cssPar
serMode) |
| 564 { | 567 { |
| 565 if (range.peek().id() == CSSValueNormal) | 568 if (range.peek().id() == CSSValueNormal) |
| 566 return consumeIdent(range); | 569 return consumeIdent(range); |
| 567 // TODO(timloh): Don't allow unitless values, and allow <percentage>s in wor
d-spacing. | 570 // TODO(timloh): Don't allow unitless values, and allow <percentage>s in wor
d-spacing. |
| 568 return consumeLength(range, cssParserMode, ValueRangeAll, UnitlessQuirk::All
ow); | 571 return consumeLength(range, cssParserMode, ValueRangeAll, UnitlessQuirk::All
ow); |
| 569 } | 572 } |
| 570 | 573 |
| 571 static RawPtr<CSSValue> consumeTabSize(CSSParserTokenRange& range, CSSParserMode
cssParserMode) | 574 static CSSValue* consumeTabSize(CSSParserTokenRange& range, CSSParserMode cssPar
serMode) |
| 572 { | 575 { |
| 573 RawPtr<CSSPrimitiveValue> parsedValue = consumeInteger(range, 0); | 576 CSSPrimitiveValue* parsedValue = consumeInteger(range, 0); |
| 574 if (parsedValue) | 577 if (parsedValue) |
| 575 return parsedValue; | 578 return parsedValue; |
| 576 return consumeLength(range, cssParserMode, ValueRangeNonNegative); | 579 return consumeLength(range, cssParserMode, ValueRangeNonNegative); |
| 577 } | 580 } |
| 578 | 581 |
| 579 static RawPtr<CSSValue> consumeFontSize(CSSParserTokenRange& range, CSSParserMod
e cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid) | 582 static CSSValue* consumeFontSize(CSSParserTokenRange& range, CSSParserMode cssPa
rserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid) |
| 580 { | 583 { |
| 581 if (range.peek().id() >= CSSValueXxSmall && range.peek().id() <= CSSValueLar
ger) | 584 if (range.peek().id() >= CSSValueXxSmall && range.peek().id() <= CSSValueLar
ger) |
| 582 return consumeIdent(range); | 585 return consumeIdent(range); |
| 583 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, u
nitless); | 586 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, u
nitless); |
| 584 } | 587 } |
| 585 | 588 |
| 586 static RawPtr<CSSPrimitiveValue> consumeLineHeight(CSSParserTokenRange& range, C
SSParserMode cssParserMode) | 589 static CSSPrimitiveValue* consumeLineHeight(CSSParserTokenRange& range, CSSParse
rMode cssParserMode) |
| 587 { | 590 { |
| 588 if (range.peek().id() == CSSValueNormal) | 591 if (range.peek().id() == CSSValueNormal) |
| 589 return consumeIdent(range); | 592 return consumeIdent(range); |
| 590 | 593 |
| 591 RawPtr<CSSPrimitiveValue> lineHeight = consumeNumber(range, ValueRangeNonNeg
ative); | 594 CSSPrimitiveValue* lineHeight = consumeNumber(range, ValueRangeNonNegative); |
| 592 if (lineHeight) | 595 if (lineHeight) |
| 593 return lineHeight; | 596 return lineHeight; |
| 594 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); | 597 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); |
| 595 } | 598 } |
| 596 | 599 |
| 597 static RawPtr<CSSValueList> consumeRotation(CSSParserTokenRange& range) | 600 static CSSValueList* consumeRotation(CSSParserTokenRange& range) |
| 598 { | 601 { |
| 599 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); | 602 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); |
| 600 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 603 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 601 | 604 |
| 602 RawPtr<CSSValue> rotation = consumeAngle(range); | 605 CSSValue* rotation = consumeAngle(range); |
| 603 if (!rotation) | 606 if (!rotation) |
| 604 return nullptr; | 607 return nullptr; |
| 605 list->append(rotation.release()); | 608 list->append(rotation); |
| 606 | 609 |
| 607 if (range.atEnd()) | 610 if (range.atEnd()) |
| 608 return list.release(); | 611 return list; |
| 609 | 612 |
| 610 for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation | 613 for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation |
| 611 RawPtr<CSSValue> dimension = consumeNumber(range, ValueRangeAll); | 614 CSSValue* dimension = consumeNumber(range, ValueRangeAll); |
| 612 if (!dimension) | 615 if (!dimension) |
| 613 return nullptr; | 616 return nullptr; |
| 614 list->append(dimension.release()); | 617 list->append(dimension); |
| 615 } | 618 } |
| 616 | 619 |
| 617 return list.release(); | 620 return list; |
| 618 } | 621 } |
| 619 | 622 |
| 620 static RawPtr<CSSValueList> consumeScale(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) | 623 static CSSValueList* consumeScale(CSSParserTokenRange& range, CSSParserMode cssP
arserMode) |
| 621 { | 624 { |
| 622 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); | 625 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); |
| 623 | 626 |
| 624 RawPtr<CSSValue> scale = consumeNumber(range, ValueRangeAll); | 627 CSSValue* scale = consumeNumber(range, ValueRangeAll); |
| 625 if (!scale) | 628 if (!scale) |
| 626 return nullptr; | 629 return nullptr; |
| 627 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 630 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 628 list->append(scale.release()); | 631 list->append(scale); |
| 629 if ((scale = consumeNumber(range, ValueRangeAll))) { | 632 scale = consumeNumber(range, ValueRangeAll); |
| 630 list->append(scale.release()); | 633 if (scale) { |
| 631 if ((scale = consumeNumber(range, ValueRangeAll))) | 634 list->append(scale); |
| 632 list->append(scale.release()); | 635 scale = consumeNumber(range, ValueRangeAll); |
| 636 if (scale) |
| 637 list->append(scale); |
| 633 } | 638 } |
| 634 | 639 |
| 635 return list.release(); | 640 return list; |
| 636 } | 641 } |
| 637 | 642 |
| 638 static RawPtr<CSSValueList> consumeTranslate(CSSParserTokenRange& range, CSSPars
erMode cssParserMode) | 643 static CSSValueList* consumeTranslate(CSSParserTokenRange& range, CSSParserMode
cssParserMode) |
| 639 { | 644 { |
| 640 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); | 645 ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled()); |
| 641 RawPtr<CSSValue> translate = consumeLengthOrPercent(range, cssParserMode, Va
lueRangeAll); | 646 CSSValue* translate = consumeLengthOrPercent(range, cssParserMode, ValueRang
eAll); |
| 642 if (!translate) | 647 if (!translate) |
| 643 return nullptr; | 648 return nullptr; |
| 644 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 649 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 645 list->append(translate.release()); | 650 list->append(translate); |
| 646 if ((translate = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll)
)) { | 651 translate = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); |
| 647 list->append(translate.release()); | 652 if (translate) { |
| 648 if ((translate = consumeLength(range, cssParserMode, ValueRangeAll))) | 653 list->append(translate); |
| 649 list->append(translate.release()); | 654 translate = consumeLength(range, cssParserMode, ValueRangeAll); |
| 655 if (translate) |
| 656 list->append(translate); |
| 650 } | 657 } |
| 651 | 658 |
| 652 return list.release(); | 659 return list; |
| 653 } | 660 } |
| 654 | 661 |
| 655 static RawPtr<CSSValue> consumeCounter(CSSParserTokenRange& range, CSSParserMode
cssParserMode, int defaultValue) | 662 static CSSValue* consumeCounter(CSSParserTokenRange& range, CSSParserMode cssPar
serMode, int defaultValue) |
| 656 { | 663 { |
| 657 if (range.peek().id() == CSSValueNone) | 664 if (range.peek().id() == CSSValueNone) |
| 658 return consumeIdent(range); | 665 return consumeIdent(range); |
| 659 | 666 |
| 660 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 667 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 661 do { | 668 do { |
| 662 RawPtr<CSSCustomIdentValue> counterName = consumeCustomIdent(range); | 669 CSSCustomIdentValue* counterName = consumeCustomIdent(range); |
| 663 if (!counterName) | 670 if (!counterName) |
| 664 return nullptr; | 671 return nullptr; |
| 665 int i = defaultValue; | 672 int i = defaultValue; |
| 666 if (RawPtr<CSSPrimitiveValue> counterValue = consumeInteger(range)) | 673 if (CSSPrimitiveValue* counterValue = consumeInteger(range)) |
| 667 i = clampTo<int>(counterValue->getDoubleValue()); | 674 i = clampTo<int>(counterValue->getDoubleValue()); |
| 668 list->append(CSSValuePair::create(counterName.release(), | 675 list->append(CSSValuePair::create(counterName, |
| 669 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Integer), | 676 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Integer), |
| 670 CSSValuePair::DropIdenticalValues)); | 677 CSSValuePair::DropIdenticalValues)); |
| 671 } while (!range.atEnd()); | 678 } while (!range.atEnd()); |
| 672 return list.release(); | 679 return list; |
| 673 } | 680 } |
| 674 | 681 |
| 675 static RawPtr<CSSValue> consumePageSize(CSSParserTokenRange& range) | 682 static CSSValue* consumePageSize(CSSParserTokenRange& range) |
| 676 { | 683 { |
| 677 return consumeIdent<CSSValueA3, CSSValueA4, CSSValueA5, CSSValueB4, CSSValue
B5, CSSValueLedger, CSSValueLegal, CSSValueLetter>(range); | 684 return consumeIdent<CSSValueA3, CSSValueA4, CSSValueA5, CSSValueB4, CSSValue
B5, CSSValueLedger, CSSValueLegal, CSSValueLetter>(range); |
| 678 } | 685 } |
| 679 | 686 |
| 680 static RawPtr<CSSValueList> consumeSize(CSSParserTokenRange& range, CSSParserMod
e cssParserMode) | 687 static CSSValueList* consumeSize(CSSParserTokenRange& range, CSSParserMode cssPa
rserMode) |
| 681 { | 688 { |
| 682 RawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); | 689 CSSValueList* result = CSSValueList::createSpaceSeparated(); |
| 683 | 690 |
| 684 if (range.peek().id() == CSSValueAuto) { | 691 if (range.peek().id() == CSSValueAuto) { |
| 685 result->append(consumeIdent(range)); | 692 result->append(consumeIdent(range)); |
| 686 return result.release(); | 693 return result; |
| 687 } | 694 } |
| 688 | 695 |
| 689 if (RawPtr<CSSValue> width = consumeLength(range, cssParserMode, ValueRangeN
onNegative)) { | 696 if (CSSValue* width = consumeLength(range, cssParserMode, ValueRangeNonNegat
ive)) { |
| 690 RawPtr<CSSValue> height = consumeLength(range, cssParserMode, ValueRange
NonNegative); | 697 CSSValue* height = consumeLength(range, cssParserMode, ValueRangeNonNega
tive); |
| 691 result->append(width.release()); | 698 result->append(width); |
| 692 if (height) | 699 if (height) |
| 693 result->append(height.release()); | 700 result->append(height); |
| 694 return result.release(); | 701 return result; |
| 695 } | 702 } |
| 696 | 703 |
| 697 RawPtr<CSSValue> pageSize = consumePageSize(range); | 704 CSSValue* pageSize = consumePageSize(range); |
| 698 RawPtr<CSSValue> orientation = consumeIdent<CSSValuePortrait, CSSValueLandsc
ape>(range); | 705 CSSValue* orientation = consumeIdent<CSSValuePortrait, CSSValueLandscape>(ra
nge); |
| 699 if (!pageSize) | 706 if (!pageSize) |
| 700 pageSize = consumePageSize(range); | 707 pageSize = consumePageSize(range); |
| 701 | 708 |
| 702 if (!orientation && !pageSize) | 709 if (!orientation && !pageSize) |
| 703 return nullptr; | 710 return nullptr; |
| 704 if (pageSize) | 711 if (pageSize) |
| 705 result->append(pageSize.release()); | 712 result->append(pageSize); |
| 706 if (orientation) | 713 if (orientation) |
| 707 result->append(orientation.release()); | 714 result->append(orientation); |
| 708 return result.release(); | 715 return result; |
| 709 } | 716 } |
| 710 | 717 |
| 711 static RawPtr<CSSValue> consumeSnapHeight(CSSParserTokenRange& range, CSSParserM
ode cssParserMode) | 718 static CSSValue* consumeSnapHeight(CSSParserTokenRange& range, CSSParserMode css
ParserMode) |
| 712 { | 719 { |
| 713 RawPtr<CSSPrimitiveValue> unit = consumeLength(range, cssParserMode, ValueRa
ngeNonNegative); | 720 CSSPrimitiveValue* unit = consumeLength(range, cssParserMode, ValueRangeNonN
egative); |
| 714 if (!unit) | 721 if (!unit) |
| 715 return nullptr; | 722 return nullptr; |
| 716 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 723 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 717 list->append(unit.release()); | 724 list->append(unit); |
| 718 | 725 |
| 719 if (RawPtr<CSSPrimitiveValue> position = consumePositiveInteger(range)) { | 726 if (CSSPrimitiveValue* position = consumePositiveInteger(range)) { |
| 720 if (position->getIntValue() > 100) | 727 if (position->getIntValue() > 100) |
| 721 return nullptr; | 728 return nullptr; |
| 722 list->append(position.release()); | 729 list->append(position); |
| 723 } | 730 } |
| 724 | 731 |
| 725 return list.release(); | 732 return list; |
| 726 } | 733 } |
| 727 | 734 |
| 728 static RawPtr<CSSValue> consumeTextIndent(CSSParserTokenRange& range, CSSParserM
ode cssParserMode) | 735 static CSSValue* consumeTextIndent(CSSParserTokenRange& range, CSSParserMode css
ParserMode) |
| 729 { | 736 { |
| 730 // [ <length> | <percentage> ] && hanging? && each-line? | 737 // [ <length> | <percentage> ] && hanging? && each-line? |
| 731 // Keywords only allowed when css3Text is enabled. | 738 // Keywords only allowed when css3Text is enabled. |
| 732 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 739 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 733 | 740 |
| 734 bool hasLengthOrPercentage = false; | 741 bool hasLengthOrPercentage = false; |
| 735 bool hasEachLine = false; | 742 bool hasEachLine = false; |
| 736 bool hasHanging = false; | 743 bool hasHanging = false; |
| 737 | 744 |
| 738 do { | 745 do { |
| 739 if (!hasLengthOrPercentage) { | 746 if (!hasLengthOrPercentage) { |
| 740 if (RawPtr<CSSValue> textIndent = consumeLengthOrPercent(range, cssP
arserMode, ValueRangeAll, UnitlessQuirk::Allow)) { | 747 if (CSSValue* textIndent = consumeLengthOrPercent(range, cssParserMo
de, ValueRangeAll, UnitlessQuirk::Allow)) { |
| 741 list->append(textIndent.release()); | 748 list->append(textIndent); |
| 742 hasLengthOrPercentage = true; | 749 hasLengthOrPercentage = true; |
| 743 continue; | 750 continue; |
| 744 } | 751 } |
| 745 } | 752 } |
| 746 | 753 |
| 747 if (RuntimeEnabledFeatures::css3TextEnabled()) { | 754 if (RuntimeEnabledFeatures::css3TextEnabled()) { |
| 748 CSSValueID id = range.peek().id(); | 755 CSSValueID id = range.peek().id(); |
| 749 if (!hasEachLine && id == CSSValueEachLine) { | 756 if (!hasEachLine && id == CSSValueEachLine) { |
| 750 list->append(consumeIdent(range)); | 757 list->append(consumeIdent(range)); |
| 751 hasEachLine = true; | 758 hasEachLine = true; |
| 752 continue; | 759 continue; |
| 753 } | 760 } |
| 754 if (!hasHanging && id == CSSValueHanging) { | 761 if (!hasHanging && id == CSSValueHanging) { |
| 755 list->append(consumeIdent(range)); | 762 list->append(consumeIdent(range)); |
| 756 hasHanging = true; | 763 hasHanging = true; |
| 757 continue; | 764 continue; |
| 758 } | 765 } |
| 759 } | 766 } |
| 760 return nullptr; | 767 return nullptr; |
| 761 } while (!range.atEnd()); | 768 } while (!range.atEnd()); |
| 762 | 769 |
| 763 if (!hasLengthOrPercentage) | 770 if (!hasLengthOrPercentage) |
| 764 return nullptr; | 771 return nullptr; |
| 765 | 772 |
| 766 return list.release(); | 773 return list; |
| 767 } | 774 } |
| 768 | 775 |
| 769 static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& con
text) | 776 static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& con
text) |
| 770 { | 777 { |
| 771 if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || id =
= CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent | 778 if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || id =
= CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent |
| 772 || id == CSSValueMinContent || id == CSSValueMaxContent || id == CSSValu
eFitContent) { | 779 || id == CSSValueMinContent || id == CSSValueMaxContent || id == CSSValu
eFitContent) { |
| 773 if (context.useCounter()) { | 780 if (context.useCounter()) { |
| 774 switch (id) { | 781 switch (id) { |
| 775 case CSSValueWebkitMinContent: | 782 case CSSValueWebkitMinContent: |
| 776 context.useCounter()->count(UseCounter::CSSValuePrefixedMinConte
nt); | 783 context.useCounter()->count(UseCounter::CSSValuePrefixedMinConte
nt); |
| 777 break; | 784 break; |
| 778 case CSSValueWebkitMaxContent: | 785 case CSSValueWebkitMaxContent: |
| 779 context.useCounter()->count(UseCounter::CSSValuePrefixedMaxConte
nt); | 786 context.useCounter()->count(UseCounter::CSSValuePrefixedMaxConte
nt); |
| 780 break; | 787 break; |
| 781 case CSSValueWebkitFillAvailable: | 788 case CSSValueWebkitFillAvailable: |
| 782 context.useCounter()->count(UseCounter::CSSValuePrefixedFillAvai
lable); | 789 context.useCounter()->count(UseCounter::CSSValuePrefixedFillAvai
lable); |
| 783 break; | 790 break; |
| 784 case CSSValueWebkitFitContent: | 791 case CSSValueWebkitFitContent: |
| 785 context.useCounter()->count(UseCounter::CSSValuePrefixedFitConte
nt); | 792 context.useCounter()->count(UseCounter::CSSValuePrefixedFitConte
nt); |
| 786 break; | 793 break; |
| 787 default: | 794 default: |
| 788 break; | 795 break; |
| 789 } | 796 } |
| 790 } | 797 } |
| 791 return true; | 798 return true; |
| 792 } | 799 } |
| 793 return false; | 800 return false; |
| 794 } | 801 } |
| 795 | 802 |
| 796 static RawPtr<CSSValue> consumeMaxWidthOrHeight(CSSParserTokenRange& range, cons
t CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid) | 803 static CSSValue* consumeMaxWidthOrHeight(CSSParserTokenRange& range, const CSSPa
rserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid) |
| 797 { | 804 { |
| 798 if (range.peek().id() == CSSValueNone || validWidthOrHeightKeyword(range.pee
k().id(), context)) | 805 if (range.peek().id() == CSSValueNone || validWidthOrHeightKeyword(range.pee
k().id(), context)) |
| 799 return consumeIdent(range); | 806 return consumeIdent(range); |
| 800 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); | 807 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); |
| 801 } | 808 } |
| 802 | 809 |
| 803 static RawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange& range, const C
SSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid) | 810 static CSSValue* consumeWidthOrHeight(CSSParserTokenRange& range, const CSSParse
rContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid) |
| 804 { | 811 { |
| 805 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee
k().id(), context)) | 812 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee
k().id(), context)) |
| 806 return consumeIdent(range); | 813 return consumeIdent(range); |
| 807 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); | 814 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative,
unitless); |
| 808 } | 815 } |
| 809 | 816 |
| 810 static RawPtr<CSSValue> consumeMarginOrOffset(CSSParserTokenRange& range, CSSPar
serMode cssParserMode, UnitlessQuirk unitless) | 817 static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range, CSSParserMode
cssParserMode, UnitlessQuirk unitless) |
| 811 { | 818 { |
| 812 if (range.peek().id() == CSSValueAuto) | 819 if (range.peek().id() == CSSValueAuto) |
| 813 return consumeIdent(range); | 820 return consumeIdent(range); |
| 814 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless)
; | 821 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless)
; |
| 815 } | 822 } |
| 816 | 823 |
| 817 static RawPtr<CSSPrimitiveValue> consumeClipComponent(CSSParserTokenRange& range
, CSSParserMode cssParserMode) | 824 static CSSPrimitiveValue* consumeClipComponent(CSSParserTokenRange& range, CSSPa
rserMode cssParserMode) |
| 818 { | 825 { |
| 819 if (range.peek().id() == CSSValueAuto) | 826 if (range.peek().id() == CSSValueAuto) |
| 820 return consumeIdent(range); | 827 return consumeIdent(range); |
| 821 return consumeLength(range, cssParserMode, ValueRangeAll, UnitlessQuirk::All
ow); | 828 return consumeLength(range, cssParserMode, ValueRangeAll, UnitlessQuirk::All
ow); |
| 822 } | 829 } |
| 823 | 830 |
| 824 static RawPtr<CSSValue> consumeClip(CSSParserTokenRange& range, CSSParserMode cs
sParserMode) | 831 static CSSValue* consumeClip(CSSParserTokenRange& range, CSSParserMode cssParser
Mode) |
| 825 { | 832 { |
| 826 if (range.peek().id() == CSSValueAuto) | 833 if (range.peek().id() == CSSValueAuto) |
| 827 return consumeIdent(range); | 834 return consumeIdent(range); |
| 828 | 835 |
| 829 if (range.peek().functionId() != CSSValueRect) | 836 if (range.peek().functionId() != CSSValueRect) |
| 830 return nullptr; | 837 return nullptr; |
| 831 | 838 |
| 832 CSSParserTokenRange args = consumeFunction(range); | 839 CSSParserTokenRange args = consumeFunction(range); |
| 833 // rect(t, r, b, l) || rect(t r b l) | 840 // rect(t, r, b, l) || rect(t r b l) |
| 834 RawPtr<CSSPrimitiveValue> top = consumeClipComponent(args, cssParserMode); | 841 CSSPrimitiveValue* top = consumeClipComponent(args, cssParserMode); |
| 835 if (!top) | 842 if (!top) |
| 836 return nullptr; | 843 return nullptr; |
| 837 bool needsComma = consumeCommaIncludingWhitespace(args); | 844 bool needsComma = consumeCommaIncludingWhitespace(args); |
| 838 RawPtr<CSSPrimitiveValue> right = consumeClipComponent(args, cssParserMode); | 845 CSSPrimitiveValue* right = consumeClipComponent(args, cssParserMode); |
| 839 if (!right || (needsComma && !consumeCommaIncludingWhitespace(args))) | 846 if (!right || (needsComma && !consumeCommaIncludingWhitespace(args))) |
| 840 return nullptr; | 847 return nullptr; |
| 841 RawPtr<CSSPrimitiveValue> bottom = consumeClipComponent(args, cssParserMode)
; | 848 CSSPrimitiveValue* bottom = consumeClipComponent(args, cssParserMode); |
| 842 if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args))) | 849 if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args))) |
| 843 return nullptr; | 850 return nullptr; |
| 844 RawPtr<CSSPrimitiveValue> left = consumeClipComponent(args, cssParserMode); | 851 CSSPrimitiveValue* left = consumeClipComponent(args, cssParserMode); |
| 845 if (!left || !args.atEnd()) | 852 if (!left || !args.atEnd()) |
| 846 return nullptr; | 853 return nullptr; |
| 847 return CSSQuadValue::create(top.release(), right.release(), bottom.release()
, left.release(), CSSQuadValue::SerializeAsRect); | 854 return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::Serializ
eAsRect); |
| 848 } | 855 } |
| 849 | 856 |
| 850 static bool consumePan(CSSParserTokenRange& range, RawPtr<CSSValue>& panX, RawPt
r<CSSValue>& panY) | 857 static bool consumePan(CSSParserTokenRange& range, CSSValue*& panX, CSSValue*& p
anY) |
| 851 { | 858 { |
| 852 CSSValueID id = range.peek().id(); | 859 CSSValueID id = range.peek().id(); |
| 853 if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft)
&& !panX) { | 860 if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft)
&& !panX) { |
| 854 if (id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchActionPanDire
ctionsEnabled()) | 861 if (id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchActionPanDire
ctionsEnabled()) |
| 855 return false; | 862 return false; |
| 856 panX = consumeIdent(range); | 863 panX = consumeIdent(range); |
| 857 } else if ((id == CSSValuePanY || id == CSSValuePanDown || id == CSSValuePan
Up) && !panY) { | 864 } else if ((id == CSSValuePanY || id == CSSValuePanDown || id == CSSValuePan
Up) && !panY) { |
| 858 if (id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchActionPanDire
ctionsEnabled()) | 865 if (id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchActionPanDire
ctionsEnabled()) |
| 859 return false; | 866 return false; |
| 860 panY = consumeIdent(range); | 867 panY = consumeIdent(range); |
| 861 } else { | 868 } else { |
| 862 return false; | 869 return false; |
| 863 } | 870 } |
| 864 return true; | 871 return true; |
| 865 } | 872 } |
| 866 | 873 |
| 867 static RawPtr<CSSValue> consumeTouchAction(CSSParserTokenRange& range) | 874 static CSSValue* consumeTouchAction(CSSParserTokenRange& range) |
| 868 { | 875 { |
| 869 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 876 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 870 CSSValueID id = range.peek().id(); | 877 CSSValueID id = range.peek().id(); |
| 871 if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation)
{ | 878 if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation)
{ |
| 872 list->append(consumeIdent(range)); | 879 list->append(consumeIdent(range)); |
| 873 return list.release(); | 880 return list; |
| 874 } | 881 } |
| 875 | 882 |
| 876 RawPtr<CSSValue> panX = nullptr; | 883 CSSValue* panX = nullptr; |
| 877 RawPtr<CSSValue> panY = nullptr; | 884 CSSValue* panY = nullptr; |
| 878 if (!consumePan(range, panX, panY)) | 885 if (!consumePan(range, panX, panY)) |
| 879 return nullptr; | 886 return nullptr; |
| 880 if (!range.atEnd() && !consumePan(range, panX, panY)) | 887 if (!range.atEnd() && !consumePan(range, panX, panY)) |
| 881 return nullptr; | 888 return nullptr; |
| 882 | 889 |
| 883 if (panX) | 890 if (panX) |
| 884 list->append(panX.release()); | 891 list->append(panX); |
| 885 if (panY) | 892 if (panY) |
| 886 list->append(panY.release()); | 893 list->append(panY); |
| 887 return list.release(); | 894 return list; |
| 888 } | 895 } |
| 889 | 896 |
| 890 static RawPtr<CSSPrimitiveValue> consumeLineClamp(CSSParserTokenRange& range) | 897 static CSSPrimitiveValue* consumeLineClamp(CSSParserTokenRange& range) |
| 891 { | 898 { |
| 892 if (range.peek().type() != PercentageToken && range.peek().type() != NumberT
oken) | 899 if (range.peek().type() != PercentageToken && range.peek().type() != NumberT
oken) |
| 893 return nullptr; | 900 return nullptr; |
| 894 RawPtr<CSSPrimitiveValue> clampValue = consumePercent(range, ValueRangeNonNe
gative); | 901 CSSPrimitiveValue* clampValue = consumePercent(range, ValueRangeNonNegative)
; |
| 895 if (clampValue) | 902 if (clampValue) |
| 896 return clampValue; | 903 return clampValue; |
| 897 // When specifying number of lines, don't allow 0 as a valid value. | 904 // When specifying number of lines, don't allow 0 as a valid value. |
| 898 return consumePositiveInteger(range); | 905 return consumePositiveInteger(range); |
| 899 } | 906 } |
| 900 | 907 |
| 901 static RawPtr<CSSValue> consumeLocale(CSSParserTokenRange& range) | 908 static CSSValue* consumeLocale(CSSParserTokenRange& range) |
| 902 { | 909 { |
| 903 if (range.peek().id() == CSSValueAuto) | 910 if (range.peek().id() == CSSValueAuto) |
| 904 return consumeIdent(range); | 911 return consumeIdent(range); |
| 905 return consumeString(range); | 912 return consumeString(range); |
| 906 } | 913 } |
| 907 | 914 |
| 908 static RawPtr<CSSValue> consumeColumnWidth(CSSParserTokenRange& range) | 915 static CSSValue* consumeColumnWidth(CSSParserTokenRange& range) |
| 909 { | 916 { |
| 910 if (range.peek().id() == CSSValueAuto) | 917 if (range.peek().id() == CSSValueAuto) |
| 911 return consumeIdent(range); | 918 return consumeIdent(range); |
| 912 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | 919 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in |
| 913 // the 'columns' shorthand property. | 920 // the 'columns' shorthand property. |
| 914 RawPtr<CSSPrimitiveValue> columnWidth = consumeLength(range, HTMLStandardMod
e, ValueRangeNonNegative); | 921 CSSPrimitiveValue* columnWidth = consumeLength(range, HTMLStandardMode, Valu
eRangeNonNegative); |
| 915 if (!columnWidth || (!columnWidth->isCalculated() && columnWidth->getDoubleV
alue() == 0)) | 922 if (!columnWidth || (!columnWidth->isCalculated() && columnWidth->getDoubleV
alue() == 0)) |
| 916 return nullptr; | 923 return nullptr; |
| 917 return columnWidth.release(); | 924 return columnWidth; |
| 918 } | 925 } |
| 919 | 926 |
| 920 static RawPtr<CSSValue> consumeColumnCount(CSSParserTokenRange& range) | 927 static CSSValue* consumeColumnCount(CSSParserTokenRange& range) |
| 921 { | 928 { |
| 922 if (range.peek().id() == CSSValueAuto) | 929 if (range.peek().id() == CSSValueAuto) |
| 923 return consumeIdent(range); | 930 return consumeIdent(range); |
| 924 return consumePositiveInteger(range); | 931 return consumePositiveInteger(range); |
| 925 } | 932 } |
| 926 | 933 |
| 927 static RawPtr<CSSValue> consumeColumnGap(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) | 934 static CSSValue* consumeColumnGap(CSSParserTokenRange& range, CSSParserMode cssP
arserMode) |
| 928 { | 935 { |
| 929 if (range.peek().id() == CSSValueNormal) | 936 if (range.peek().id() == CSSValueNormal) |
| 930 return consumeIdent(range); | 937 return consumeIdent(range); |
| 931 return consumeLength(range, cssParserMode, ValueRangeNonNegative); | 938 return consumeLength(range, cssParserMode, ValueRangeNonNegative); |
| 932 } | 939 } |
| 933 | 940 |
| 934 static RawPtr<CSSValue> consumeColumnSpan(CSSParserTokenRange& range, CSSParserM
ode cssParserMode) | 941 static CSSValue* consumeColumnSpan(CSSParserTokenRange& range, CSSParserMode css
ParserMode) |
| 935 { | 942 { |
| 936 return consumeIdent<CSSValueAll, CSSValueNone>(range); | 943 return consumeIdent<CSSValueAll, CSSValueNone>(range); |
| 937 } | 944 } |
| 938 | 945 |
| 939 static RawPtr<CSSValue> consumeZoom(CSSParserTokenRange& range, const CSSParserC
ontext& context) | 946 static CSSValue* consumeZoom(CSSParserTokenRange& range, const CSSParserContext&
context) |
| 940 { | 947 { |
| 941 const CSSParserToken& token = range.peek(); | 948 const CSSParserToken& token = range.peek(); |
| 942 RawPtr<CSSPrimitiveValue> zoom = nullptr; | 949 CSSPrimitiveValue* zoom = nullptr; |
| 943 if (token.type() == IdentToken) { | 950 if (token.type() == IdentToken) { |
| 944 zoom = consumeIdent<CSSValueNormal, CSSValueReset, CSSValueDocument>(ran
ge); | 951 zoom = consumeIdent<CSSValueNormal, CSSValueReset, CSSValueDocument>(ran
ge); |
| 945 } else { | 952 } else { |
| 946 zoom = consumePercent(range, ValueRangeNonNegative); | 953 zoom = consumePercent(range, ValueRangeNonNegative); |
| 947 if (!zoom) | 954 if (!zoom) |
| 948 zoom = consumeNumber(range, ValueRangeNonNegative); | 955 zoom = consumeNumber(range, ValueRangeNonNegative); |
| 949 } | 956 } |
| 950 if (zoom && context.useCounter() | 957 if (zoom && context.useCounter() |
| 951 && !(token.id() == CSSValueNormal | 958 && !(token.id() == CSSValueNormal |
| 952 || (token.type() == NumberToken && zoom->getDoubleValue() == 1) | 959 || (token.type() == NumberToken && zoom->getDoubleValue() == 1) |
| 953 || (token.type() == PercentageToken && zoom->getDoubleValue() == 100
))) | 960 || (token.type() == PercentageToken && zoom->getDoubleValue() == 100
))) |
| 954 context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne); | 961 context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne); |
| 955 return zoom.release(); | 962 return zoom; |
| 956 } | 963 } |
| 957 | 964 |
| 958 static RawPtr<CSSValue> consumeAnimationIterationCount(CSSParserTokenRange& rang
e) | 965 static CSSValue* consumeAnimationIterationCount(CSSParserTokenRange& range) |
| 959 { | 966 { |
| 960 if (range.peek().id() == CSSValueInfinite) | 967 if (range.peek().id() == CSSValueInfinite) |
| 961 return consumeIdent(range); | 968 return consumeIdent(range); |
| 962 return consumeNumber(range, ValueRangeNonNegative); | 969 return consumeNumber(range, ValueRangeNonNegative); |
| 963 } | 970 } |
| 964 | 971 |
| 965 static RawPtr<CSSValue> consumeAnimationName(CSSParserTokenRange& range, const C
SSParserContext& context, bool allowQuotedName) | 972 static CSSValue* consumeAnimationName(CSSParserTokenRange& range, const CSSParse
rContext& context, bool allowQuotedName) |
| 966 { | 973 { |
| 967 if (range.peek().id() == CSSValueNone) | 974 if (range.peek().id() == CSSValueNone) |
| 968 return consumeIdent(range); | 975 return consumeIdent(range); |
| 969 | 976 |
| 970 if (allowQuotedName && range.peek().type() == StringToken) { | 977 if (allowQuotedName && range.peek().type() == StringToken) { |
| 971 // Legacy support for strings in prefixed animations. | 978 // Legacy support for strings in prefixed animations. |
| 972 if (context.useCounter()) | 979 if (context.useCounter()) |
| 973 context.useCounter()->count(UseCounter::QuotedAnimationName); | 980 context.useCounter()->count(UseCounter::QuotedAnimationName); |
| 974 | 981 |
| 975 const CSSParserToken& token = range.consumeIncludingWhitespace(); | 982 const CSSParserToken& token = range.consumeIncludingWhitespace(); |
| 976 if (token.valueEqualsIgnoringASCIICase("none")) | 983 if (token.valueEqualsIgnoringASCIICase("none")) |
| 977 return cssValuePool().createIdentifierValue(CSSValueNone); | 984 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 978 return CSSCustomIdentValue::create(token.value()); | 985 return CSSCustomIdentValue::create(token.value()); |
| 979 } | 986 } |
| 980 | 987 |
| 981 return consumeCustomIdent(range); | 988 return consumeCustomIdent(range); |
| 982 } | 989 } |
| 983 | 990 |
| 984 static RawPtr<CSSValue> consumeTransitionProperty(CSSParserTokenRange& range) | 991 static CSSValue* consumeTransitionProperty(CSSParserTokenRange& range) |
| 985 { | 992 { |
| 986 const CSSParserToken& token = range.peek(); | 993 const CSSParserToken& token = range.peek(); |
| 987 if (token.type() != IdentToken) | 994 if (token.type() != IdentToken) |
| 988 return nullptr; | 995 return nullptr; |
| 989 if (token.id() == CSSValueNone) | 996 if (token.id() == CSSValueNone) |
| 990 return consumeIdent(range); | 997 return consumeIdent(range); |
| 991 | 998 |
| 992 if (CSSPropertyID property = token.parseAsUnresolvedCSSPropertyID()) { | 999 if (CSSPropertyID property = token.parseAsUnresolvedCSSPropertyID()) { |
| 993 ASSERT(CSSPropertyMetadata::isEnabledProperty(property)); | 1000 ASSERT(CSSPropertyMetadata::isEnabledProperty(property)); |
| 994 range.consumeIncludingWhitespace(); | 1001 range.consumeIncludingWhitespace(); |
| 995 return cssValuePool().createIdentifierValue(property); | 1002 return cssValuePool().createIdentifierValue(property); |
| 996 } | 1003 } |
| 997 return consumeCustomIdent(range); | 1004 return consumeCustomIdent(range); |
| 998 } | 1005 } |
| 999 | 1006 |
| 1000 static RawPtr<CSSValue> consumeSteps(CSSParserTokenRange& range) | 1007 static CSSValue* consumeSteps(CSSParserTokenRange& range) |
| 1001 { | 1008 { |
| 1002 ASSERT(range.peek().functionId() == CSSValueSteps); | 1009 ASSERT(range.peek().functionId() == CSSValueSteps); |
| 1003 CSSParserTokenRange rangeCopy = range; | 1010 CSSParserTokenRange rangeCopy = range; |
| 1004 CSSParserTokenRange args = consumeFunction(rangeCopy); | 1011 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 1005 | 1012 |
| 1006 RawPtr<CSSPrimitiveValue> steps = consumePositiveInteger(args); | 1013 CSSPrimitiveValue* steps = consumePositiveInteger(args); |
| 1007 if (!steps) | 1014 if (!steps) |
| 1008 return nullptr; | 1015 return nullptr; |
| 1009 | 1016 |
| 1010 StepsTimingFunction::StepAtPosition position = StepsTimingFunction::End; | 1017 StepsTimingFunction::StepAtPosition position = StepsTimingFunction::End; |
| 1011 if (consumeCommaIncludingWhitespace(args)) { | 1018 if (consumeCommaIncludingWhitespace(args)) { |
| 1012 switch (args.consumeIncludingWhitespace().id()) { | 1019 switch (args.consumeIncludingWhitespace().id()) { |
| 1013 case CSSValueMiddle: | 1020 case CSSValueMiddle: |
| 1014 if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled()) | 1021 if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled()) |
| 1015 return nullptr; | 1022 return nullptr; |
| 1016 position = StepsTimingFunction::Middle; | 1023 position = StepsTimingFunction::Middle; |
| 1017 break; | 1024 break; |
| 1018 case CSSValueStart: | 1025 case CSSValueStart: |
| 1019 position = StepsTimingFunction::Start; | 1026 position = StepsTimingFunction::Start; |
| 1020 break; | 1027 break; |
| 1021 case CSSValueEnd: | 1028 case CSSValueEnd: |
| 1022 position = StepsTimingFunction::End; | 1029 position = StepsTimingFunction::End; |
| 1023 break; | 1030 break; |
| 1024 default: | 1031 default: |
| 1025 return nullptr; | 1032 return nullptr; |
| 1026 } | 1033 } |
| 1027 } | 1034 } |
| 1028 | 1035 |
| 1029 if (!args.atEnd()) | 1036 if (!args.atEnd()) |
| 1030 return nullptr; | 1037 return nullptr; |
| 1031 | 1038 |
| 1032 range = rangeCopy; | 1039 range = rangeCopy; |
| 1033 return CSSStepsTimingFunctionValue::create(steps->getIntValue(), position); | 1040 return CSSStepsTimingFunctionValue::create(steps->getIntValue(), position); |
| 1034 } | 1041 } |
| 1035 | 1042 |
| 1036 static RawPtr<CSSValue> consumeCubicBezier(CSSParserTokenRange& range) | 1043 static CSSValue* consumeCubicBezier(CSSParserTokenRange& range) |
| 1037 { | 1044 { |
| 1038 ASSERT(range.peek().functionId() == CSSValueCubicBezier); | 1045 ASSERT(range.peek().functionId() == CSSValueCubicBezier); |
| 1039 CSSParserTokenRange rangeCopy = range; | 1046 CSSParserTokenRange rangeCopy = range; |
| 1040 CSSParserTokenRange args = consumeFunction(rangeCopy); | 1047 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 1041 | 1048 |
| 1042 double x1, y1, x2, y2; | 1049 double x1, y1, x2, y2; |
| 1043 if (consumeNumberRaw(args, x1) | 1050 if (consumeNumberRaw(args, x1) |
| 1044 && x1 >= 0 && x1 <= 1 | 1051 && x1 >= 0 && x1 <= 1 |
| 1045 && consumeCommaIncludingWhitespace(args) | 1052 && consumeCommaIncludingWhitespace(args) |
| 1046 && consumeNumberRaw(args, y1) | 1053 && consumeNumberRaw(args, y1) |
| 1047 && consumeCommaIncludingWhitespace(args) | 1054 && consumeCommaIncludingWhitespace(args) |
| 1048 && consumeNumberRaw(args, x2) | 1055 && consumeNumberRaw(args, x2) |
| 1049 && x2 >= 0 && x2 <= 1 | 1056 && x2 >= 0 && x2 <= 1 |
| 1050 && consumeCommaIncludingWhitespace(args) | 1057 && consumeCommaIncludingWhitespace(args) |
| 1051 && consumeNumberRaw(args, y2) | 1058 && consumeNumberRaw(args, y2) |
| 1052 && args.atEnd()) { | 1059 && args.atEnd()) { |
| 1053 range = rangeCopy; | 1060 range = rangeCopy; |
| 1054 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); | 1061 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); |
| 1055 } | 1062 } |
| 1056 | 1063 |
| 1057 return nullptr; | 1064 return nullptr; |
| 1058 } | 1065 } |
| 1059 | 1066 |
| 1060 static RawPtr<CSSValue> consumeAnimationTimingFunction(CSSParserTokenRange& rang
e) | 1067 static CSSValue* consumeAnimationTimingFunction(CSSParserTokenRange& range) |
| 1061 { | 1068 { |
| 1062 CSSValueID id = range.peek().id(); | 1069 CSSValueID id = range.peek().id(); |
| 1063 if (id == CSSValueEase || id == CSSValueLinear || id == CSSValueEaseIn | 1070 if (id == CSSValueEase || id == CSSValueLinear || id == CSSValueEaseIn |
| 1064 || id == CSSValueEaseOut || id == CSSValueEaseInOut || id == CSSValueSte
pStart | 1071 || id == CSSValueEaseOut || id == CSSValueEaseInOut || id == CSSValueSte
pStart |
| 1065 || id == CSSValueStepEnd || id == CSSValueStepMiddle) | 1072 || id == CSSValueStepEnd || id == CSSValueStepMiddle) |
| 1066 return consumeIdent(range); | 1073 return consumeIdent(range); |
| 1067 | 1074 |
| 1068 CSSValueID function = range.peek().functionId(); | 1075 CSSValueID function = range.peek().functionId(); |
| 1069 if (function == CSSValueSteps) | 1076 if (function == CSSValueSteps) |
| 1070 return consumeSteps(range); | 1077 return consumeSteps(range); |
| 1071 if (function == CSSValueCubicBezier) | 1078 if (function == CSSValueCubicBezier) |
| 1072 return consumeCubicBezier(range); | 1079 return consumeCubicBezier(range); |
| 1073 return nullptr; | 1080 return nullptr; |
| 1074 } | 1081 } |
| 1075 | 1082 |
| 1076 static RawPtr<CSSValue> consumeAnimationValue(CSSPropertyID property, CSSParserT
okenRange& range, const CSSParserContext& context, bool useLegacyParsing) | 1083 static CSSValue* consumeAnimationValue(CSSPropertyID property, CSSParserTokenRan
ge& range, const CSSParserContext& context, bool useLegacyParsing) |
| 1077 { | 1084 { |
| 1078 switch (property) { | 1085 switch (property) { |
| 1079 case CSSPropertyAnimationDelay: | 1086 case CSSPropertyAnimationDelay: |
| 1080 case CSSPropertyTransitionDelay: | 1087 case CSSPropertyTransitionDelay: |
| 1081 return consumeTime(range, ValueRangeAll); | 1088 return consumeTime(range, ValueRangeAll); |
| 1082 case CSSPropertyAnimationDirection: | 1089 case CSSPropertyAnimationDirection: |
| 1083 return consumeIdent<CSSValueNormal, CSSValueAlternate, CSSValueReverse,
CSSValueAlternateReverse>(range); | 1090 return consumeIdent<CSSValueNormal, CSSValueAlternate, CSSValueReverse,
CSSValueAlternateReverse>(range); |
| 1084 case CSSPropertyAnimationDuration: | 1091 case CSSPropertyAnimationDuration: |
| 1085 case CSSPropertyTransitionDuration: | 1092 case CSSPropertyTransitionDuration: |
| 1086 return consumeTime(range, ValueRangeNonNegative); | 1093 return consumeTime(range, ValueRangeNonNegative); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1108 if (property != CSSPropertyTransitionProperty || valueList.length() < 2) | 1115 if (property != CSSPropertyTransitionProperty || valueList.length() < 2) |
| 1109 return true; | 1116 return true; |
| 1110 for (auto& value : valueList) { | 1117 for (auto& value : valueList) { |
| 1111 if (value->isPrimitiveValue() && toCSSPrimitiveValue(*value).isValueID() | 1118 if (value->isPrimitiveValue() && toCSSPrimitiveValue(*value).isValueID() |
| 1112 && toCSSPrimitiveValue(*value).getValueID() == CSSValueNone) | 1119 && toCSSPrimitiveValue(*value).getValueID() == CSSValueNone) |
| 1113 return false; | 1120 return false; |
| 1114 } | 1121 } |
| 1115 return true; | 1122 return true; |
| 1116 } | 1123 } |
| 1117 | 1124 |
| 1118 static RawPtr<CSSValueList> consumeAnimationPropertyList(CSSPropertyID property,
CSSParserTokenRange& range, const CSSParserContext& context, bool useLegacyPars
ing) | 1125 static CSSValueList* consumeAnimationPropertyList(CSSPropertyID property, CSSPar
serTokenRange& range, const CSSParserContext& context, bool useLegacyParsing) |
| 1119 { | 1126 { |
| 1120 RawPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); | 1127 CSSValueList* list = CSSValueList::createCommaSeparated(); |
| 1121 do { | 1128 do { |
| 1122 RawPtr<CSSValue> value = consumeAnimationValue(property, range, context,
useLegacyParsing); | 1129 CSSValue* value = consumeAnimationValue(property, range, context, useLeg
acyParsing); |
| 1123 if (!value) | 1130 if (!value) |
| 1124 return nullptr; | 1131 return nullptr; |
| 1125 list->append(value.release()); | 1132 list->append(value); |
| 1126 } while (consumeCommaIncludingWhitespace(range)); | 1133 } while (consumeCommaIncludingWhitespace(range)); |
| 1127 if (!isValidAnimationPropertyList(property, *list)) | 1134 if (!isValidAnimationPropertyList(property, *list)) |
| 1128 return nullptr; | 1135 return nullptr; |
| 1129 ASSERT(list->length()); | 1136 ASSERT(list->length()); |
| 1130 return list.release(); | 1137 return list; |
| 1131 } | 1138 } |
| 1132 | 1139 |
| 1133 bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand&
shorthand, bool useLegacyParsing, bool important) | 1140 bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand&
shorthand, bool useLegacyParsing, bool important) |
| 1134 { | 1141 { |
| 1135 const unsigned longhandCount = shorthand.length(); | 1142 const unsigned longhandCount = shorthand.length(); |
| 1136 RawPtr<CSSValueList> longhands[8]; | 1143 CSSValueList* longhands[8]; |
| 1137 ASSERT(longhandCount <= 8); | 1144 ASSERT(longhandCount <= 8); |
| 1138 for (size_t i = 0; i < longhandCount; ++i) | 1145 for (size_t i = 0; i < longhandCount; ++i) |
| 1139 longhands[i] = CSSValueList::createCommaSeparated(); | 1146 longhands[i] = CSSValueList::createCommaSeparated(); |
| 1140 | 1147 |
| 1141 do { | 1148 do { |
| 1142 bool parsedLonghand[8] = { false }; | 1149 bool parsedLonghand[8] = { false }; |
| 1143 do { | 1150 do { |
| 1144 bool foundProperty = false; | 1151 bool foundProperty = false; |
| 1145 for (size_t i = 0; i < longhandCount; ++i) { | 1152 for (size_t i = 0; i < longhandCount; ++i) { |
| 1146 if (parsedLonghand[i]) | 1153 if (parsedLonghand[i]) |
| 1147 continue; | 1154 continue; |
| 1148 | 1155 |
| 1149 if (RawPtr<CSSValue> value = consumeAnimationValue(shorthand.pro
perties()[i], m_range, m_context, useLegacyParsing)) { | 1156 if (CSSValue* value = consumeAnimationValue(shorthand.properties
()[i], m_range, m_context, useLegacyParsing)) { |
| 1150 parsedLonghand[i] = true; | 1157 parsedLonghand[i] = true; |
| 1151 foundProperty = true; | 1158 foundProperty = true; |
| 1152 longhands[i]->append(value.release()); | 1159 longhands[i]->append(value); |
| 1153 break; | 1160 break; |
| 1154 } | 1161 } |
| 1155 } | 1162 } |
| 1156 if (!foundProperty) | 1163 if (!foundProperty) |
| 1157 return false; | 1164 return false; |
| 1158 } while (!m_range.atEnd() && m_range.peek().type() != CommaToken); | 1165 } while (!m_range.atEnd() && m_range.peek().type() != CommaToken); |
| 1159 | 1166 |
| 1160 // TODO(timloh): This will make invalid longhands, see crbug.com/386459 | 1167 // TODO(timloh): This will make invalid longhands, see crbug.com/386459 |
| 1161 for (size_t i = 0; i < longhandCount; ++i) { | 1168 for (size_t i = 0; i < longhandCount; ++i) { |
| 1162 if (!parsedLonghand[i]) | 1169 if (!parsedLonghand[i]) |
| 1163 longhands[i]->append(cssValuePool().createImplicitInitialValue()
); | 1170 longhands[i]->append(cssValuePool().createImplicitInitialValue()
); |
| 1164 parsedLonghand[i] = false; | 1171 parsedLonghand[i] = false; |
| 1165 } | 1172 } |
| 1166 } while (consumeCommaIncludingWhitespace(m_range)); | 1173 } while (consumeCommaIncludingWhitespace(m_range)); |
| 1167 | 1174 |
| 1168 for (size_t i = 0; i < longhandCount; ++i) { | 1175 for (size_t i = 0; i < longhandCount; ++i) { |
| 1169 if (!isValidAnimationPropertyList(shorthand.properties()[i], *longhands[
i])) | 1176 if (!isValidAnimationPropertyList(shorthand.properties()[i], *longhands[
i])) |
| 1170 return false; | 1177 return false; |
| 1171 } | 1178 } |
| 1172 | 1179 |
| 1173 for (size_t i = 0; i < longhandCount; ++i) | 1180 for (size_t i = 0; i < longhandCount; ++i) |
| 1174 addProperty(shorthand.properties()[i], longhands[i].release(), important
); | 1181 addProperty(shorthand.properties()[i], longhands[i], important); |
| 1175 | 1182 |
| 1176 return m_range.atEnd(); | 1183 return m_range.atEnd(); |
| 1177 } | 1184 } |
| 1178 | 1185 |
| 1179 static RawPtr<CSSValue> consumeWidowsOrOrphans(CSSParserTokenRange& range) | 1186 static CSSValue* consumeWidowsOrOrphans(CSSParserTokenRange& range) |
| 1180 { | 1187 { |
| 1181 // Support for auto is non-standard and for backwards compatibility. | 1188 // Support for auto is non-standard and for backwards compatibility. |
| 1182 if (range.peek().id() == CSSValueAuto) | 1189 if (range.peek().id() == CSSValueAuto) |
| 1183 return consumeIdent(range); | 1190 return consumeIdent(range); |
| 1184 return consumePositiveInteger(range); | 1191 return consumePositiveInteger(range); |
| 1185 } | 1192 } |
| 1186 | 1193 |
| 1187 static RawPtr<CSSValue> consumeZIndex(CSSParserTokenRange& range) | 1194 static CSSValue* consumeZIndex(CSSParserTokenRange& range) |
| 1188 { | 1195 { |
| 1189 if (range.peek().id() == CSSValueAuto) | 1196 if (range.peek().id() == CSSValueAuto) |
| 1190 return consumeIdent(range); | 1197 return consumeIdent(range); |
| 1191 return consumeInteger(range); | 1198 return consumeInteger(range); |
| 1192 } | 1199 } |
| 1193 | 1200 |
| 1194 static RawPtr<CSSShadowValue> parseSingleShadow(CSSParserTokenRange& range, CSSP
arserMode cssParserMode, bool allowInset, bool allowSpread) | 1201 static CSSShadowValue* parseSingleShadow(CSSParserTokenRange& range, CSSParserMo
de cssParserMode, bool allowInset, bool allowSpread) |
| 1195 { | 1202 { |
| 1196 RawPtr<CSSPrimitiveValue> style = nullptr; | 1203 CSSPrimitiveValue* style = nullptr; |
| 1197 RawPtr<CSSValue> color = nullptr; | 1204 CSSValue* color = nullptr; |
| 1198 | 1205 |
| 1199 if (range.atEnd()) | 1206 if (range.atEnd()) |
| 1200 return nullptr; | 1207 return nullptr; |
| 1201 if (range.peek().id() == CSSValueInset) { | 1208 if (range.peek().id() == CSSValueInset) { |
| 1202 if (!allowInset) | 1209 if (!allowInset) |
| 1203 return nullptr; | 1210 return nullptr; |
| 1204 style = consumeIdent(range); | 1211 style = consumeIdent(range); |
| 1205 } | 1212 } |
| 1206 color = consumeColor(range, cssParserMode); | 1213 color = consumeColor(range, cssParserMode); |
| 1207 | 1214 |
| 1208 RawPtr<CSSPrimitiveValue> horizontalOffset = consumeLength(range, cssParserM
ode, ValueRangeAll); | 1215 CSSPrimitiveValue* horizontalOffset = consumeLength(range, cssParserMode, Va
lueRangeAll); |
| 1209 if (!horizontalOffset) | 1216 if (!horizontalOffset) |
| 1210 return nullptr; | 1217 return nullptr; |
| 1211 | 1218 |
| 1212 RawPtr<CSSPrimitiveValue> verticalOffset = consumeLength(range, cssParserMod
e, ValueRangeAll); | 1219 CSSPrimitiveValue* verticalOffset = consumeLength(range, cssParserMode, Valu
eRangeAll); |
| 1213 if (!verticalOffset) | 1220 if (!verticalOffset) |
| 1214 return nullptr; | 1221 return nullptr; |
| 1215 | 1222 |
| 1216 RawPtr<CSSPrimitiveValue> blurRadius = consumeLength(range, cssParserMode, V
alueRangeAll); | 1223 CSSPrimitiveValue* blurRadius = consumeLength(range, cssParserMode, ValueRan
geAll); |
| 1217 RawPtr<CSSPrimitiveValue> spreadDistance = nullptr; | 1224 CSSPrimitiveValue* spreadDistance = nullptr; |
| 1218 if (blurRadius) { | 1225 if (blurRadius) { |
| 1219 // Blur radius must be non-negative. | 1226 // Blur radius must be non-negative. |
| 1220 if (blurRadius->getDoubleValue() < 0) | 1227 if (blurRadius->getDoubleValue() < 0) |
| 1221 return nullptr; | 1228 return nullptr; |
| 1222 if (allowSpread) | 1229 if (allowSpread) |
| 1223 spreadDistance = consumeLength(range, cssParserMode, ValueRangeAll); | 1230 spreadDistance = consumeLength(range, cssParserMode, ValueRangeAll); |
| 1224 } | 1231 } |
| 1225 | 1232 |
| 1226 if (!range.atEnd()) { | 1233 if (!range.atEnd()) { |
| 1227 if (!color) | 1234 if (!color) |
| 1228 color = consumeColor(range, cssParserMode); | 1235 color = consumeColor(range, cssParserMode); |
| 1229 if (range.peek().id() == CSSValueInset) { | 1236 if (range.peek().id() == CSSValueInset) { |
| 1230 if (!allowInset || style) | 1237 if (!allowInset || style) |
| 1231 return nullptr; | 1238 return nullptr; |
| 1232 style = consumeIdent(range); | 1239 style = consumeIdent(range); |
| 1233 } | 1240 } |
| 1234 } | 1241 } |
| 1235 return CSSShadowValue::create(horizontalOffset.release(), verticalOffset.rel
ease(), blurRadius.release(), | 1242 return CSSShadowValue::create(horizontalOffset, verticalOffset, blurRadius, |
| 1236 spreadDistance.release(), style.release(), color.release()); | 1243 spreadDistance, style, color); |
| 1237 } | 1244 } |
| 1238 | 1245 |
| 1239 static RawPtr<CSSValue> consumeShadow(CSSParserTokenRange& range, CSSParserMode
cssParserMode, bool isBoxShadowProperty) | 1246 static CSSValue* consumeShadow(CSSParserTokenRange& range, CSSParserMode cssPars
erMode, bool isBoxShadowProperty) |
| 1240 { | 1247 { |
| 1241 if (range.peek().id() == CSSValueNone) | 1248 if (range.peek().id() == CSSValueNone) |
| 1242 return consumeIdent(range); | 1249 return consumeIdent(range); |
| 1243 | 1250 |
| 1244 RawPtr<CSSValueList> shadowValueList = CSSValueList::createCommaSeparated(); | 1251 CSSValueList* shadowValueList = CSSValueList::createCommaSeparated(); |
| 1245 do { | 1252 do { |
| 1246 if (RawPtr<CSSShadowValue> shadowValue = parseSingleShadow(range, cssPar
serMode, isBoxShadowProperty, isBoxShadowProperty)) | 1253 if (CSSShadowValue* shadowValue = parseSingleShadow(range, cssParserMode
, isBoxShadowProperty, isBoxShadowProperty)) |
| 1247 shadowValueList->append(shadowValue.release()); | 1254 shadowValueList->append(shadowValue); |
| 1248 else | 1255 else |
| 1249 return nullptr; | 1256 return nullptr; |
| 1250 } while (consumeCommaIncludingWhitespace(range)); | 1257 } while (consumeCommaIncludingWhitespace(range)); |
| 1251 return shadowValueList; | 1258 return shadowValueList; |
| 1252 } | 1259 } |
| 1253 | 1260 |
| 1254 static RawPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range
, CSSParserMode cssParserMode) | 1261 static CSSFunctionValue* consumeFilterFunction(CSSParserTokenRange& range, CSSPa
rserMode cssParserMode) |
| 1255 { | 1262 { |
| 1256 CSSValueID filterType = range.peek().functionId(); | 1263 CSSValueID filterType = range.peek().functionId(); |
| 1257 if (filterType < CSSValueInvert || filterType > CSSValueDropShadow) | 1264 if (filterType < CSSValueInvert || filterType > CSSValueDropShadow) |
| 1258 return nullptr; | 1265 return nullptr; |
| 1259 CSSParserTokenRange args = consumeFunction(range); | 1266 CSSParserTokenRange args = consumeFunction(range); |
| 1260 RawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create(filterType); | 1267 CSSFunctionValue* filterValue = CSSFunctionValue::create(filterType); |
| 1261 RawPtr<CSSValue> parsedValue = nullptr; | 1268 CSSValue* parsedValue = nullptr; |
| 1262 | 1269 |
| 1263 if (filterType == CSSValueDropShadow) { | 1270 if (filterType == CSSValueDropShadow) { |
| 1264 parsedValue = parseSingleShadow(args, cssParserMode, false, false); | 1271 parsedValue = parseSingleShadow(args, cssParserMode, false, false); |
| 1265 } else { | 1272 } else { |
| 1266 // TODO(timloh): Add UseCounters for empty filter arguments. | 1273 // TODO(timloh): Add UseCounters for empty filter arguments. |
| 1267 if (args.atEnd()) | 1274 if (args.atEnd()) |
| 1268 return filterValue.release(); | 1275 return filterValue; |
| 1269 if (filterType == CSSValueBrightness) { | 1276 if (filterType == CSSValueBrightness) { |
| 1270 // FIXME (crbug.com/397061): Support calc expressions like calc(10%
+ 0.5) | 1277 // FIXME (crbug.com/397061): Support calc expressions like calc(10%
+ 0.5) |
| 1271 parsedValue = consumePercent(args, ValueRangeAll); | 1278 parsedValue = consumePercent(args, ValueRangeAll); |
| 1272 if (!parsedValue) | 1279 if (!parsedValue) |
| 1273 parsedValue = consumeNumber(args, ValueRangeAll); | 1280 parsedValue = consumeNumber(args, ValueRangeAll); |
| 1274 } else if (filterType == CSSValueHueRotate) { | 1281 } else if (filterType == CSSValueHueRotate) { |
| 1275 parsedValue = consumeAngle(args); | 1282 parsedValue = consumeAngle(args); |
| 1276 } else if (filterType == CSSValueBlur) { | 1283 } else if (filterType == CSSValueBlur) { |
| 1277 parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNeg
ative); | 1284 parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNeg
ative); |
| 1278 } else { | 1285 } else { |
| 1279 // FIXME (crbug.com/397061): Support calc expressions like calc(10%
+ 0.5) | 1286 // FIXME (crbug.com/397061): Support calc expressions like calc(10%
+ 0.5) |
| 1280 parsedValue = consumePercent(args, ValueRangeNonNegative); | 1287 parsedValue = consumePercent(args, ValueRangeNonNegative); |
| 1281 if (!parsedValue) | 1288 if (!parsedValue) |
| 1282 parsedValue = consumeNumber(args, ValueRangeNonNegative); | 1289 parsedValue = consumeNumber(args, ValueRangeNonNegative); |
| 1283 if (parsedValue && filterType != CSSValueSaturate && filterType != C
SSValueContrast) { | 1290 if (parsedValue && filterType != CSSValueSaturate && filterType != C
SSValueContrast) { |
| 1284 double maxAllowed = toCSSPrimitiveValue(parsedValue.get())->isPe
rcentage() ? 100.0 : 1.0; | 1291 double maxAllowed = toCSSPrimitiveValue(parsedValue)->isPercenta
ge() ? 100.0 : 1.0; |
| 1285 if (toCSSPrimitiveValue(parsedValue.get())->getDoubleValue() > m
axAllowed) | 1292 if (toCSSPrimitiveValue(parsedValue)->getDoubleValue() > maxAllo
wed) |
| 1286 return nullptr; | 1293 return nullptr; |
| 1287 } | 1294 } |
| 1288 } | 1295 } |
| 1289 } | 1296 } |
| 1290 if (!parsedValue || !args.atEnd()) | 1297 if (!parsedValue || !args.atEnd()) |
| 1291 return nullptr; | 1298 return nullptr; |
| 1292 filterValue->append(parsedValue.release()); | 1299 filterValue->append(parsedValue); |
| 1293 return filterValue.release(); | 1300 return filterValue; |
| 1294 } | 1301 } |
| 1295 | 1302 |
| 1296 static RawPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, CSSParserMode
cssParserMode) | 1303 static CSSValue* consumeFilter(CSSParserTokenRange& range, CSSParserMode cssPars
erMode) |
| 1297 { | 1304 { |
| 1298 if (range.peek().id() == CSSValueNone) | 1305 if (range.peek().id() == CSSValueNone) |
| 1299 return consumeIdent(range); | 1306 return consumeIdent(range); |
| 1300 | 1307 |
| 1301 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 1308 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 1302 do { | 1309 do { |
| 1303 String url = consumeUrl(range); | 1310 String url = consumeUrl(range); |
| 1304 RawPtr<CSSFunctionValue> filterValue = nullptr; | 1311 CSSFunctionValue* filterValue = nullptr; |
| 1305 if (!url.isNull()) { | 1312 if (!url.isNull()) { |
| 1306 filterValue = CSSFunctionValue::create(CSSValueUrl); | 1313 filterValue = CSSFunctionValue::create(CSSValueUrl); |
| 1307 filterValue->append(CSSSVGDocumentValue::create(url)); | 1314 filterValue->append(CSSSVGDocumentValue::create(url)); |
| 1308 } else { | 1315 } else { |
| 1309 filterValue = consumeFilterFunction(range, cssParserMode); | 1316 filterValue = consumeFilterFunction(range, cssParserMode); |
| 1310 if (!filterValue) | 1317 if (!filterValue) |
| 1311 return nullptr; | 1318 return nullptr; |
| 1312 } | 1319 } |
| 1313 list->append(filterValue.release()); | 1320 list->append(filterValue); |
| 1314 } while (!range.atEnd()); | 1321 } while (!range.atEnd()); |
| 1315 return list.release(); | 1322 return list; |
| 1316 } | 1323 } |
| 1317 | 1324 |
| 1318 static RawPtr<CSSValue> consumeTextDecorationLine(CSSParserTokenRange& range) | 1325 static CSSValue* consumeTextDecorationLine(CSSParserTokenRange& range) |
| 1319 { | 1326 { |
| 1320 CSSValueID id = range.peek().id(); | 1327 CSSValueID id = range.peek().id(); |
| 1321 if (id == CSSValueNone) | 1328 if (id == CSSValueNone) |
| 1322 return consumeIdent(range); | 1329 return consumeIdent(range); |
| 1323 | 1330 |
| 1324 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 1331 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 1325 RawPtr<CSSPrimitiveValue> ident = nullptr; | 1332 while (true) { |
| 1326 while ((ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverl
ine, CSSValueLineThrough>(range))) { | 1333 CSSPrimitiveValue* ident = consumeIdent<CSSValueBlink, CSSValueUnderline
, CSSValueOverline, CSSValueLineThrough>(range); |
| 1327 if (list->hasValue(ident.get())) | 1334 if (!ident) |
| 1335 break; |
| 1336 if (list->hasValue(ident)) |
| 1328 return nullptr; | 1337 return nullptr; |
| 1329 list->append(ident.release()); | 1338 list->append(ident); |
| 1330 } | 1339 } |
| 1331 | 1340 |
| 1332 if (!list->length()) | 1341 if (!list->length()) |
| 1333 return nullptr; | 1342 return nullptr; |
| 1334 return list.release(); | 1343 return list; |
| 1335 } | 1344 } |
| 1336 | 1345 |
| 1337 // none | strict | [ layout || style || paint ] | 1346 // none | strict | [ layout || style || paint ] |
| 1338 static RawPtr<CSSValue> consumeContain(CSSParserTokenRange& range) | 1347 static CSSValue* consumeContain(CSSParserTokenRange& range) |
| 1339 { | 1348 { |
| 1340 CSSValueID id = range.peek().id(); | 1349 CSSValueID id = range.peek().id(); |
| 1341 if (id == CSSValueNone) | 1350 if (id == CSSValueNone) |
| 1342 return consumeIdent(range); | 1351 return consumeIdent(range); |
| 1343 | 1352 |
| 1344 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 1353 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 1345 if (id == CSSValueStrict) { | 1354 if (id == CSSValueStrict) { |
| 1346 list->append(consumeIdent(range)); | 1355 list->append(consumeIdent(range)); |
| 1347 return list.release(); | 1356 return list; |
| 1348 } | 1357 } |
| 1349 RawPtr<CSSPrimitiveValue> ident = nullptr; | 1358 while (true) { |
| 1350 while ((ident = consumeIdent<CSSValuePaint, CSSValueLayout, CSSValueStyle>(r
ange))) { | 1359 CSSPrimitiveValue* ident = consumeIdent<CSSValuePaint, CSSValueLayout, C
SSValueStyle>(range); |
| 1351 if (list->hasValue(ident.get())) | 1360 if (!ident) |
| 1361 break; |
| 1362 if (list->hasValue(ident)) |
| 1352 return nullptr; | 1363 return nullptr; |
| 1353 list->append(ident.release()); | 1364 list->append(ident); |
| 1354 } | 1365 } |
| 1355 | 1366 |
| 1356 if (!list->length()) | 1367 if (!list->length()) |
| 1357 return nullptr; | 1368 return nullptr; |
| 1358 return list.release(); | 1369 return list; |
| 1359 } | 1370 } |
| 1360 | 1371 |
| 1361 static RawPtr<CSSValue> consumePath(CSSParserTokenRange& range) | 1372 static CSSValue* consumePath(CSSParserTokenRange& range) |
| 1362 { | 1373 { |
| 1363 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. | 1374 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
| 1364 if (range.peek().functionId() != CSSValuePath) | 1375 if (range.peek().functionId() != CSSValuePath) |
| 1365 return nullptr; | 1376 return nullptr; |
| 1366 | 1377 |
| 1367 CSSParserTokenRange functionRange = range; | 1378 CSSParserTokenRange functionRange = range; |
| 1368 CSSParserTokenRange functionArgs = consumeFunction(functionRange); | 1379 CSSParserTokenRange functionArgs = consumeFunction(functionRange); |
| 1369 | 1380 |
| 1370 if (functionArgs.peek().type() != StringToken) | 1381 if (functionArgs.peek().type() != StringToken) |
| 1371 return nullptr; | 1382 return nullptr; |
| 1372 String pathString = functionArgs.consumeIncludingWhitespace().value(); | 1383 String pathString = functionArgs.consumeIncludingWhitespace().value(); |
| 1373 | 1384 |
| 1374 OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); | 1385 OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); |
| 1375 if (buildByteStreamFromString(pathString, *byteStream) != SVGParseStatus::No
Error | 1386 if (buildByteStreamFromString(pathString, *byteStream) != SVGParseStatus::No
Error |
| 1376 || !functionArgs.atEnd()) | 1387 || !functionArgs.atEnd()) |
| 1377 return nullptr; | 1388 return nullptr; |
| 1378 | 1389 |
| 1379 range = functionRange; | 1390 range = functionRange; |
| 1380 if (byteStream->isEmpty()) | 1391 if (byteStream->isEmpty()) |
| 1381 return cssValuePool().createIdentifierValue(CSSValueNone); | 1392 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 1382 return CSSPathValue::create(byteStream.release()); | 1393 return CSSPathValue::create(byteStream.release()); |
| 1383 } | 1394 } |
| 1384 | 1395 |
| 1385 static RawPtr<CSSValue> consumePathOrNone(CSSParserTokenRange& range) | 1396 static CSSValue* consumePathOrNone(CSSParserTokenRange& range) |
| 1386 { | 1397 { |
| 1387 CSSValueID id = range.peek().id(); | 1398 CSSValueID id = range.peek().id(); |
| 1388 if (id == CSSValueNone) | 1399 if (id == CSSValueNone) |
| 1389 return consumeIdent(range); | 1400 return consumeIdent(range); |
| 1390 | 1401 |
| 1391 return consumePath(range); | 1402 return consumePath(range); |
| 1392 } | 1403 } |
| 1393 | 1404 |
| 1394 static RawPtr<CSSValue> consumeMotionRotation(CSSParserTokenRange& range) | 1405 static CSSValue* consumeMotionRotation(CSSParserTokenRange& range) |
| 1395 { | 1406 { |
| 1396 RawPtr<CSSValue> angle = consumeAngle(range); | 1407 CSSValue* angle = consumeAngle(range); |
| 1397 RawPtr<CSSValue> keyword = consumeIdent<CSSValueAuto, CSSValueReverse>(range
); | 1408 CSSValue* keyword = consumeIdent<CSSValueAuto, CSSValueReverse>(range); |
| 1398 if (!angle && !keyword) | 1409 if (!angle && !keyword) |
| 1399 return nullptr; | 1410 return nullptr; |
| 1400 | 1411 |
| 1401 if (!angle) | 1412 if (!angle) |
| 1402 angle = consumeAngle(range); | 1413 angle = consumeAngle(range); |
| 1403 | 1414 |
| 1404 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 1415 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 1405 if (keyword) | 1416 if (keyword) |
| 1406 list->append(keyword.release()); | 1417 list->append(keyword); |
| 1407 if (angle) | 1418 if (angle) |
| 1408 list->append(angle.release()); | 1419 list->append(angle); |
| 1409 return list.release(); | 1420 return list; |
| 1410 } | 1421 } |
| 1411 | 1422 |
| 1412 static RawPtr<CSSValue> consumeTextEmphasisStyle(CSSParserTokenRange& range) | 1423 static CSSValue* consumeTextEmphasisStyle(CSSParserTokenRange& range) |
| 1413 { | 1424 { |
| 1414 CSSValueID id = range.peek().id(); | 1425 CSSValueID id = range.peek().id(); |
| 1415 if (id == CSSValueNone) | 1426 if (id == CSSValueNone) |
| 1416 return consumeIdent(range); | 1427 return consumeIdent(range); |
| 1417 | 1428 |
| 1418 if (RawPtr<CSSValue> textEmphasisStyle = consumeString(range)) | 1429 if (CSSValue* textEmphasisStyle = consumeString(range)) |
| 1419 return textEmphasisStyle.release(); | 1430 return textEmphasisStyle; |
| 1420 | 1431 |
| 1421 RawPtr<CSSPrimitiveValue> fill = consumeIdent<CSSValueFilled, CSSValueOpen>(
range); | 1432 CSSPrimitiveValue* fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range); |
| 1422 RawPtr<CSSPrimitiveValue> shape = consumeIdent<CSSValueDot, CSSValueCircle,
CSSValueDoubleCircle, CSSValueTriangle, CSSValueSesame>(range); | 1433 CSSPrimitiveValue* shape = consumeIdent<CSSValueDot, CSSValueCircle, CSSValu
eDoubleCircle, CSSValueTriangle, CSSValueSesame>(range); |
| 1423 if (!fill) | 1434 if (!fill) |
| 1424 fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range); | 1435 fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range); |
| 1425 if (fill && shape) { | 1436 if (fill && shape) { |
| 1426 RawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated()
; | 1437 CSSValueList* parsedValues = CSSValueList::createSpaceSeparated(); |
| 1427 parsedValues->append(fill.release()); | 1438 parsedValues->append(fill); |
| 1428 parsedValues->append(shape.release()); | 1439 parsedValues->append(shape); |
| 1429 return parsedValues.release(); | 1440 return parsedValues; |
| 1430 } | 1441 } |
| 1431 if (fill) | 1442 if (fill) |
| 1432 return fill.release(); | 1443 return fill; |
| 1433 if (shape) | 1444 if (shape) |
| 1434 return shape.release(); | 1445 return shape; |
| 1435 return nullptr; | 1446 return nullptr; |
| 1436 } | 1447 } |
| 1437 | 1448 |
| 1438 static RawPtr<CSSValue> consumeOutlineColor(CSSParserTokenRange& range, CSSParse
rMode cssParserMode) | 1449 static CSSValue* consumeOutlineColor(CSSParserTokenRange& range, CSSParserMode c
ssParserMode) |
| 1439 { | 1450 { |
| 1440 // Outline color has "invert" as additional keyword. | 1451 // Outline color has "invert" as additional keyword. |
| 1441 // Also, we want to allow the special focus color even in HTML Standard pars
ing mode. | 1452 // Also, we want to allow the special focus color even in HTML Standard pars
ing mode. |
| 1442 if (range.peek().id() == CSSValueInvert || range.peek().id() == CSSValueWebk
itFocusRingColor) | 1453 if (range.peek().id() == CSSValueInvert || range.peek().id() == CSSValueWebk
itFocusRingColor) |
| 1443 return consumeIdent(range); | 1454 return consumeIdent(range); |
| 1444 return consumeColor(range, cssParserMode); | 1455 return consumeColor(range, cssParserMode); |
| 1445 } | 1456 } |
| 1446 | 1457 |
| 1447 static RawPtr<CSSPrimitiveValue> consumeLineWidth(CSSParserTokenRange& range, CS
SParserMode cssParserMode, UnitlessQuirk unitless) | 1458 static CSSPrimitiveValue* consumeLineWidth(CSSParserTokenRange& range, CSSParser
Mode cssParserMode, UnitlessQuirk unitless) |
| 1448 { | 1459 { |
| 1449 CSSValueID id = range.peek().id(); | 1460 CSSValueID id = range.peek().id(); |
| 1450 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) | 1461 if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) |
| 1451 return consumeIdent(range); | 1462 return consumeIdent(range); |
| 1452 return consumeLength(range, cssParserMode, ValueRangeNonNegative, unitless); | 1463 return consumeLength(range, cssParserMode, ValueRangeNonNegative, unitless); |
| 1453 } | 1464 } |
| 1454 | 1465 |
| 1455 static RawPtr<CSSPrimitiveValue> consumeBorderWidth(CSSParserTokenRange& range,
CSSParserMode cssParserMode, UnitlessQuirk unitless) | 1466 static CSSPrimitiveValue* consumeBorderWidth(CSSParserTokenRange& range, CSSPars
erMode cssParserMode, UnitlessQuirk unitless) |
| 1456 { | 1467 { |
| 1457 return consumeLineWidth(range, cssParserMode, unitless); | 1468 return consumeLineWidth(range, cssParserMode, unitless); |
| 1458 } | 1469 } |
| 1459 | 1470 |
| 1460 static RawPtr<CSSPrimitiveValue> consumeTextStrokeWidth(CSSParserTokenRange& ran
ge, CSSParserMode cssParserMode) | 1471 static CSSPrimitiveValue* consumeTextStrokeWidth(CSSParserTokenRange& range, CSS
ParserMode cssParserMode) |
| 1461 { | 1472 { |
| 1462 return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); | 1473 return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); |
| 1463 } | 1474 } |
| 1464 | 1475 |
| 1465 static RawPtr<CSSPrimitiveValue> consumeColumnRuleWidth(CSSParserTokenRange& ran
ge, CSSParserMode cssParserMode) | 1476 static CSSPrimitiveValue* consumeColumnRuleWidth(CSSParserTokenRange& range, CSS
ParserMode cssParserMode) |
| 1466 { | 1477 { |
| 1467 return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); | 1478 return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); |
| 1468 } | 1479 } |
| 1469 | 1480 |
| 1470 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParse
rMode, RawPtr<CSSFunctionValue>& transformValue) | 1481 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParse
rMode, CSSFunctionValue*& transformValue) |
| 1471 { | 1482 { |
| 1472 unsigned numberOfArguments = 2; | 1483 unsigned numberOfArguments = 2; |
| 1473 RawPtr<CSSValue> parsedValue = nullptr; | 1484 CSSValue* parsedValue = nullptr; |
| 1474 do { | 1485 do { |
| 1475 parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll)
; | 1486 parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll)
; |
| 1476 if (!parsedValue) | 1487 if (!parsedValue) |
| 1477 return false; | 1488 return false; |
| 1478 transformValue->append(parsedValue); | 1489 transformValue->append(parsedValue); |
| 1479 if (!consumeCommaIncludingWhitespace(args)) | 1490 if (!consumeCommaIncludingWhitespace(args)) |
| 1480 return false; | 1491 return false; |
| 1481 } while (--numberOfArguments); | 1492 } while (--numberOfArguments); |
| 1482 parsedValue = consumeLength(args, cssParserMode, ValueRangeAll); | 1493 parsedValue = consumeLength(args, cssParserMode, ValueRangeAll); |
| 1483 if (!parsedValue) | 1494 if (!parsedValue) |
| 1484 return false; | 1495 return false; |
| 1485 transformValue->append(parsedValue); | 1496 transformValue->append(parsedValue); |
| 1486 return true; | 1497 return true; |
| 1487 } | 1498 } |
| 1488 | 1499 |
| 1489 static bool consumeNumbers(CSSParserTokenRange& args, RawPtr<CSSFunctionValue>&
transformValue, unsigned numberOfArguments) | 1500 static bool consumeNumbers(CSSParserTokenRange& args, CSSFunctionValue*& transfo
rmValue, unsigned numberOfArguments) |
| 1490 { | 1501 { |
| 1491 do { | 1502 do { |
| 1492 RawPtr<CSSValue> parsedValue = consumeNumber(args, ValueRangeAll); | 1503 CSSValue* parsedValue = consumeNumber(args, ValueRangeAll); |
| 1493 if (!parsedValue) | 1504 if (!parsedValue) |
| 1494 return false; | 1505 return false; |
| 1495 transformValue->append(parsedValue); | 1506 transformValue->append(parsedValue); |
| 1496 if (--numberOfArguments && !consumeCommaIncludingWhitespace(args)) | 1507 if (--numberOfArguments && !consumeCommaIncludingWhitespace(args)) |
| 1497 return false; | 1508 return false; |
| 1498 } while (numberOfArguments); | 1509 } while (numberOfArguments); |
| 1499 return true; | 1510 return true; |
| 1500 } | 1511 } |
| 1501 | 1512 |
| 1502 static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParse
rMode, RawPtr<CSSFunctionValue>& transformValue, bool useLegacyParsing) | 1513 static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParse
rMode, CSSFunctionValue*& transformValue, bool useLegacyParsing) |
| 1503 { | 1514 { |
| 1504 RawPtr<CSSPrimitiveValue> parsedValue = consumeLength(args, cssParserMode, V
alueRangeNonNegative); | 1515 CSSPrimitiveValue* parsedValue = consumeLength(args, cssParserMode, ValueRan
geNonNegative); |
| 1505 if (!parsedValue && useLegacyParsing) { | 1516 if (!parsedValue && useLegacyParsing) { |
| 1506 double perspective; | 1517 double perspective; |
| 1507 if (!consumeNumberRaw(args, perspective) || perspective < 0) | 1518 if (!consumeNumberRaw(args, perspective) || perspective < 0) |
| 1508 return false; | 1519 return false; |
| 1509 parsedValue = cssValuePool().createValue(perspective, CSSPrimitiveValue:
:UnitType::Pixels); | 1520 parsedValue = cssValuePool().createValue(perspective, CSSPrimitiveValue:
:UnitType::Pixels); |
| 1510 } | 1521 } |
| 1511 if (!parsedValue) | 1522 if (!parsedValue) |
| 1512 return false; | 1523 return false; |
| 1513 transformValue->append(parsedValue); | 1524 transformValue->append(parsedValue); |
| 1514 return true; | 1525 return true; |
| 1515 } | 1526 } |
| 1516 | 1527 |
| 1517 static RawPtr<CSSValue> consumeTransformValue(CSSParserTokenRange& range, CSSPar
serMode cssParserMode, bool useLegacyParsing) | 1528 static CSSValue* consumeTransformValue(CSSParserTokenRange& range, CSSParserMode
cssParserMode, bool useLegacyParsing) |
| 1518 { | 1529 { |
| 1519 CSSValueID functionId = range.peek().functionId(); | 1530 CSSValueID functionId = range.peek().functionId(); |
| 1520 if (functionId == CSSValueInvalid) | 1531 if (functionId == CSSValueInvalid) |
| 1521 return nullptr; | 1532 return nullptr; |
| 1522 CSSParserTokenRange args = consumeFunction(range); | 1533 CSSParserTokenRange args = consumeFunction(range); |
| 1523 if (args.atEnd()) | 1534 if (args.atEnd()) |
| 1524 return nullptr; | 1535 return nullptr; |
| 1525 RawPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(functionI
d); | 1536 CSSFunctionValue* transformValue = CSSFunctionValue::create(functionId); |
| 1526 RawPtr<CSSValue> parsedValue = nullptr; | 1537 CSSValue* parsedValue = nullptr; |
| 1527 switch (functionId) { | 1538 switch (functionId) { |
| 1528 case CSSValueRotate: | 1539 case CSSValueRotate: |
| 1529 case CSSValueRotateX: | 1540 case CSSValueRotateX: |
| 1530 case CSSValueRotateY: | 1541 case CSSValueRotateY: |
| 1531 case CSSValueRotateZ: | 1542 case CSSValueRotateZ: |
| 1532 case CSSValueSkewX: | 1543 case CSSValueSkewX: |
| 1533 case CSSValueSkewY: | 1544 case CSSValueSkewY: |
| 1534 case CSSValueSkew: | 1545 case CSSValueSkew: |
| 1535 parsedValue = consumeAngle(args); | 1546 parsedValue = consumeAngle(args); |
| 1536 if (!parsedValue) | 1547 if (!parsedValue) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 if (!consumeTranslate3d(args, cssParserMode, transformValue)) | 1607 if (!consumeTranslate3d(args, cssParserMode, transformValue)) |
| 1597 return nullptr; | 1608 return nullptr; |
| 1598 break; | 1609 break; |
| 1599 default: | 1610 default: |
| 1600 return nullptr; | 1611 return nullptr; |
| 1601 } | 1612 } |
| 1602 if (parsedValue) | 1613 if (parsedValue) |
| 1603 transformValue->append(parsedValue); | 1614 transformValue->append(parsedValue); |
| 1604 if (!args.atEnd()) | 1615 if (!args.atEnd()) |
| 1605 return nullptr; | 1616 return nullptr; |
| 1606 return transformValue.release(); | 1617 return transformValue; |
| 1607 } | 1618 } |
| 1608 | 1619 |
| 1609 static RawPtr<CSSValue> consumeTransform(CSSParserTokenRange& range, CSSParserMo
de cssParserMode, bool useLegacyParsing) | 1620 static CSSValue* consumeTransform(CSSParserTokenRange& range, CSSParserMode cssP
arserMode, bool useLegacyParsing) |
| 1610 { | 1621 { |
| 1611 if (range.peek().id() == CSSValueNone) | 1622 if (range.peek().id() == CSSValueNone) |
| 1612 return consumeIdent(range); | 1623 return consumeIdent(range); |
| 1613 | 1624 |
| 1614 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 1625 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 1615 do { | 1626 do { |
| 1616 RawPtr<CSSValue> parsedTransformValue = consumeTransformValue(range, css
ParserMode, useLegacyParsing); | 1627 CSSValue* parsedTransformValue = consumeTransformValue(range, cssParserM
ode, useLegacyParsing); |
| 1617 if (!parsedTransformValue) | 1628 if (!parsedTransformValue) |
| 1618 return nullptr; | 1629 return nullptr; |
| 1619 list->append(parsedTransformValue.release()); | 1630 list->append(parsedTransformValue); |
| 1620 } while (!range.atEnd()); | 1631 } while (!range.atEnd()); |
| 1621 | 1632 |
| 1622 return list.release(); | 1633 return list; |
| 1623 } | 1634 } |
| 1624 | 1635 |
| 1625 template <CSSValueID start, CSSValueID end> | 1636 template <CSSValueID start, CSSValueID end> |
| 1626 static RawPtr<CSSValue> consumePositionLonghand(CSSParserTokenRange& range, CSSP
arserMode cssParserMode) | 1637 static CSSValue* consumePositionLonghand(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) |
| 1627 { | 1638 { |
| 1628 if (range.peek().type() == IdentToken) { | 1639 if (range.peek().type() == IdentToken) { |
| 1629 CSSValueID id = range.peek().id(); | 1640 CSSValueID id = range.peek().id(); |
| 1630 int percent; | 1641 int percent; |
| 1631 if (id == start) | 1642 if (id == start) |
| 1632 percent = 0; | 1643 percent = 0; |
| 1633 else if (id == CSSValueCenter) | 1644 else if (id == CSSValueCenter) |
| 1634 percent = 50; | 1645 percent = 50; |
| 1635 else if (id == end) | 1646 else if (id == end) |
| 1636 percent = 100; | 1647 percent = 100; |
| 1637 else | 1648 else |
| 1638 return nullptr; | 1649 return nullptr; |
| 1639 range.consumeIncludingWhitespace(); | 1650 range.consumeIncludingWhitespace(); |
| 1640 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); | 1651 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); |
| 1641 } | 1652 } |
| 1642 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); | 1653 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); |
| 1643 } | 1654 } |
| 1644 | 1655 |
| 1645 static RawPtr<CSSValue> consumePositionX(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) | 1656 static CSSValue* consumePositionX(CSSParserTokenRange& range, CSSParserMode cssP
arserMode) |
| 1646 { | 1657 { |
| 1647 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParser
Mode); | 1658 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParser
Mode); |
| 1648 } | 1659 } |
| 1649 | 1660 |
| 1650 static RawPtr<CSSValue> consumePositionY(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) | 1661 static CSSValue* consumePositionY(CSSParserTokenRange& range, CSSParserMode cssP
arserMode) |
| 1651 { | 1662 { |
| 1652 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParser
Mode); | 1663 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParser
Mode); |
| 1653 } | 1664 } |
| 1654 | 1665 |
| 1655 static RawPtr<CSSValue> consumePaintStroke(CSSParserTokenRange& range, CSSParser
Mode cssParserMode) | 1666 static CSSValue* consumePaintStroke(CSSParserTokenRange& range, CSSParserMode cs
sParserMode) |
| 1656 { | 1667 { |
| 1657 if (range.peek().id() == CSSValueNone) | 1668 if (range.peek().id() == CSSValueNone) |
| 1658 return consumeIdent(range); | 1669 return consumeIdent(range); |
| 1659 String url = consumeUrl(range); | 1670 String url = consumeUrl(range); |
| 1660 if (!url.isNull()) { | 1671 if (!url.isNull()) { |
| 1661 RawPtr<CSSValue> parsedValue = nullptr; | 1672 CSSValue* parsedValue = nullptr; |
| 1662 if (range.peek().id() == CSSValueNone) | 1673 if (range.peek().id() == CSSValueNone) |
| 1663 parsedValue = consumeIdent(range); | 1674 parsedValue = consumeIdent(range); |
| 1664 else | 1675 else |
| 1665 parsedValue = consumeColor(range, cssParserMode); | 1676 parsedValue = consumeColor(range, cssParserMode); |
| 1666 if (parsedValue) { | 1677 if (parsedValue) { |
| 1667 RawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); | 1678 CSSValueList* values = CSSValueList::createSpaceSeparated(); |
| 1668 values->append(CSSURIValue::create(url)); | 1679 values->append(CSSURIValue::create(url)); |
| 1669 values->append(parsedValue); | 1680 values->append(parsedValue); |
| 1670 return values.release(); | 1681 return values; |
| 1671 } | 1682 } |
| 1672 return CSSURIValue::create(url); | 1683 return CSSURIValue::create(url); |
| 1673 } | 1684 } |
| 1674 return consumeColor(range, cssParserMode); | 1685 return consumeColor(range, cssParserMode); |
| 1675 } | 1686 } |
| 1676 | 1687 |
| 1677 static RawPtr<CSSValue> consumePaintOrder(CSSParserTokenRange& range) | 1688 static CSSValue* consumePaintOrder(CSSParserTokenRange& range) |
| 1678 { | 1689 { |
| 1679 if (range.peek().id() == CSSValueNormal) | 1690 if (range.peek().id() == CSSValueNormal) |
| 1680 return consumeIdent(range); | 1691 return consumeIdent(range); |
| 1681 | 1692 |
| 1682 Vector<CSSValueID, 3> paintTypeList; | 1693 Vector<CSSValueID, 3> paintTypeList; |
| 1683 RawPtr<CSSPrimitiveValue> fill = nullptr; | 1694 CSSPrimitiveValue* fill = nullptr; |
| 1684 RawPtr<CSSPrimitiveValue> stroke = nullptr; | 1695 CSSPrimitiveValue* stroke = nullptr; |
| 1685 RawPtr<CSSPrimitiveValue> markers = nullptr; | 1696 CSSPrimitiveValue* markers = nullptr; |
| 1686 do { | 1697 do { |
| 1687 CSSValueID id = range.peek().id(); | 1698 CSSValueID id = range.peek().id(); |
| 1688 if (id == CSSValueFill && !fill) | 1699 if (id == CSSValueFill && !fill) |
| 1689 fill = consumeIdent(range); | 1700 fill = consumeIdent(range); |
| 1690 else if (id == CSSValueStroke && !stroke) | 1701 else if (id == CSSValueStroke && !stroke) |
| 1691 stroke = consumeIdent(range); | 1702 stroke = consumeIdent(range); |
| 1692 else if (id == CSSValueMarkers && !markers) | 1703 else if (id == CSSValueMarkers && !markers) |
| 1693 markers = consumeIdent(range); | 1704 markers = consumeIdent(range); |
| 1694 else | 1705 else |
| 1695 return nullptr; | 1706 return nullptr; |
| 1696 paintTypeList.append(id); | 1707 paintTypeList.append(id); |
| 1697 } while (!range.atEnd()); | 1708 } while (!range.atEnd()); |
| 1698 | 1709 |
| 1699 // After parsing we serialize the paint-order list. Since it is not possible
to | 1710 // After parsing we serialize the paint-order list. Since it is not possible
to |
| 1700 // pop a last list items from CSSValueList without bigger cost, we create th
e | 1711 // pop a last list items from CSSValueList without bigger cost, we create th
e |
| 1701 // list after parsing. | 1712 // list after parsing. |
| 1702 CSSValueID firstPaintOrderType = paintTypeList.at(0); | 1713 CSSValueID firstPaintOrderType = paintTypeList.at(0); |
| 1703 RawPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceSeparated(); | 1714 CSSValueList* paintOrderList = CSSValueList::createSpaceSeparated(); |
| 1704 switch (firstPaintOrderType) { | 1715 switch (firstPaintOrderType) { |
| 1705 case CSSValueFill: | 1716 case CSSValueFill: |
| 1706 case CSSValueStroke: | 1717 case CSSValueStroke: |
| 1707 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releas
e() : stroke.release()); | 1718 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill : stro
ke); |
| 1708 if (paintTypeList.size() > 1) { | 1719 if (paintTypeList.size() > 1) { |
| 1709 if (paintTypeList.at(1) == CSSValueMarkers) | 1720 if (paintTypeList.at(1) == CSSValueMarkers) |
| 1710 paintOrderList->append(markers.release()); | 1721 paintOrderList->append(markers); |
| 1711 } | 1722 } |
| 1712 break; | 1723 break; |
| 1713 case CSSValueMarkers: | 1724 case CSSValueMarkers: |
| 1714 paintOrderList->append(markers.release()); | 1725 paintOrderList->append(markers); |
| 1715 if (paintTypeList.size() > 1) { | 1726 if (paintTypeList.size() > 1) { |
| 1716 if (paintTypeList.at(1) == CSSValueStroke) | 1727 if (paintTypeList.at(1) == CSSValueStroke) |
| 1717 paintOrderList->append(stroke.release()); | 1728 paintOrderList->append(stroke); |
| 1718 } | 1729 } |
| 1719 break; | 1730 break; |
| 1720 default: | 1731 default: |
| 1721 ASSERT_NOT_REACHED(); | 1732 ASSERT_NOT_REACHED(); |
| 1722 } | 1733 } |
| 1723 | 1734 |
| 1724 return paintOrderList.release(); | 1735 return paintOrderList; |
| 1725 } | 1736 } |
| 1726 | 1737 |
| 1727 static RawPtr<CSSValue> consumeNoneOrURI(CSSParserTokenRange& range) | 1738 static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range) |
| 1728 { | 1739 { |
| 1729 if (range.peek().id() == CSSValueNone) | 1740 if (range.peek().id() == CSSValueNone) |
| 1730 return consumeIdent(range); | 1741 return consumeIdent(range); |
| 1731 | 1742 |
| 1732 String url = consumeUrl(range); | 1743 String url = consumeUrl(range); |
| 1733 if (url.isNull()) | 1744 if (url.isNull()) |
| 1734 return nullptr; | 1745 return nullptr; |
| 1735 return CSSURIValue::create(url); | 1746 return CSSURIValue::create(url); |
| 1736 } | 1747 } |
| 1737 | 1748 |
| 1738 static RawPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) | 1749 static CSSValue* consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssP
arserMode) |
| 1739 { | 1750 { |
| 1740 // FIXME: Support intrinsic dimensions too. | 1751 // FIXME: Support intrinsic dimensions too. |
| 1741 if (range.peek().id() == CSSValueAuto) | 1752 if (range.peek().id() == CSSValueAuto) |
| 1742 return consumeIdent(range); | 1753 return consumeIdent(range); |
| 1743 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); | 1754 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); |
| 1744 } | 1755 } |
| 1745 | 1756 |
| 1746 static RawPtr<CSSValue> consumeStrokeDasharray(CSSParserTokenRange& range) | 1757 static CSSValue* consumeStrokeDasharray(CSSParserTokenRange& range) |
| 1747 { | 1758 { |
| 1748 CSSValueID id = range.peek().id(); | 1759 CSSValueID id = range.peek().id(); |
| 1749 if (id == CSSValueNone) | 1760 if (id == CSSValueNone) |
| 1750 return consumeIdent(range); | 1761 return consumeIdent(range); |
| 1751 | 1762 |
| 1752 RawPtr<CSSValueList> dashes = CSSValueList::createCommaSeparated(); | 1763 CSSValueList* dashes = CSSValueList::createCommaSeparated(); |
| 1753 do { | 1764 do { |
| 1754 RawPtr<CSSPrimitiveValue> dash = consumeLengthOrPercent(range, SVGAttrib
uteMode, ValueRangeNonNegative, UnitlessQuirk::Allow); | 1765 CSSPrimitiveValue* dash = consumeLengthOrPercent(range, SVGAttributeMode
, ValueRangeNonNegative, UnitlessQuirk::Allow); |
| 1755 if (!dash || (consumeCommaIncludingWhitespace(range) && range.atEnd())) | 1766 if (!dash || (consumeCommaIncludingWhitespace(range) && range.atEnd())) |
| 1756 return nullptr; | 1767 return nullptr; |
| 1757 dashes->append(dash.release()); | 1768 dashes->append(dash); |
| 1758 } while (!range.atEnd()); | 1769 } while (!range.atEnd()); |
| 1759 return dashes.release(); | 1770 return dashes; |
| 1760 } | 1771 } |
| 1761 | 1772 |
| 1762 static RawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserTokenRange& range
) | 1773 static CSSPrimitiveValue* consumeBaselineShift(CSSParserTokenRange& range) |
| 1763 { | 1774 { |
| 1764 CSSValueID id = range.peek().id(); | 1775 CSSValueID id = range.peek().id(); |
| 1765 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | 1776 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) |
| 1766 return consumeIdent(range); | 1777 return consumeIdent(range); |
| 1767 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll); | 1778 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll); |
| 1768 } | 1779 } |
| 1769 | 1780 |
| 1770 static RawPtr<CSSValue> createCSSImageValueWithReferrer(const AtomicString& rawV
alue, const CSSParserContext& context) | 1781 static CSSValue* createCSSImageValueWithReferrer(const AtomicString& rawValue, c
onst CSSParserContext& context) |
| 1771 { | 1782 { |
| 1772 RawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, context.comple
teURL(rawValue)); | 1783 CSSValue* imageValue = CSSImageValue::create(rawValue, context.completeURL(r
awValue)); |
| 1773 toCSSImageValue(imageValue.get())->setReferrer(context.referrer()); | 1784 toCSSImageValue(imageValue)->setReferrer(context.referrer()); |
| 1774 return imageValue; | 1785 return imageValue; |
| 1775 } | 1786 } |
| 1776 | 1787 |
| 1777 static RawPtr<CSSValue> consumeImageSet(CSSParserTokenRange& range, const CSSPar
serContext& context) | 1788 static CSSValue* consumeImageSet(CSSParserTokenRange& range, const CSSParserCont
ext& context) |
| 1778 { | 1789 { |
| 1779 CSSParserTokenRange rangeCopy = range; | 1790 CSSParserTokenRange rangeCopy = range; |
| 1780 CSSParserTokenRange args = consumeFunction(rangeCopy); | 1791 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 1781 RawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 1792 CSSImageSetValue* imageSet = CSSImageSetValue::create(); |
| 1782 do { | 1793 do { |
| 1783 AtomicString urlValue(consumeUrl(args)); | 1794 AtomicString urlValue(consumeUrl(args)); |
| 1784 if (urlValue.isNull()) | 1795 if (urlValue.isNull()) |
| 1785 return nullptr; | 1796 return nullptr; |
| 1786 | 1797 |
| 1787 RawPtr<CSSValue> image = createCSSImageValueWithReferrer(urlValue, conte
xt); | 1798 CSSValue* image = createCSSImageValueWithReferrer(urlValue, context); |
| 1788 imageSet->append(image); | 1799 imageSet->append(image); |
| 1789 | 1800 |
| 1790 const CSSParserToken& token = args.consumeIncludingWhitespace(); | 1801 const CSSParserToken& token = args.consumeIncludingWhitespace(); |
| 1791 if (token.type() != DimensionToken) | 1802 if (token.type() != DimensionToken) |
| 1792 return nullptr; | 1803 return nullptr; |
| 1793 if (String(token.value()) != "x") | 1804 if (String(token.value()) != "x") |
| 1794 return nullptr; | 1805 return nullptr; |
| 1795 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::Unknown); | 1806 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::Unknown); |
| 1796 double imageScaleFactor = token.numericValue(); | 1807 double imageScaleFactor = token.numericValue(); |
| 1797 if (imageScaleFactor <= 0) | 1808 if (imageScaleFactor <= 0) |
| 1798 return nullptr; | 1809 return nullptr; |
| 1799 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::UnitType::Number)); | 1810 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::UnitType::Number)); |
| 1800 } while (consumeCommaIncludingWhitespace(args)); | 1811 } while (consumeCommaIncludingWhitespace(args)); |
| 1801 if (!args.atEnd()) | 1812 if (!args.atEnd()) |
| 1802 return nullptr; | 1813 return nullptr; |
| 1803 range = rangeCopy; | 1814 range = rangeCopy; |
| 1804 return imageSet.release(); | 1815 return imageSet; |
| 1805 } | 1816 } |
| 1806 | 1817 |
| 1807 static RawPtr<CSSValue> consumeCursor(CSSParserTokenRange& range, const CSSParse
rContext& context, bool inQuirksMode) | 1818 static CSSValue* consumeCursor(CSSParserTokenRange& range, const CSSParserContex
t& context, bool inQuirksMode) |
| 1808 { | 1819 { |
| 1809 RawPtr<CSSValueList> list = nullptr; | 1820 CSSValueList* list = nullptr; |
| 1810 while (true) { | 1821 while (true) { |
| 1811 RawPtr<CSSValue> image = nullptr; | 1822 CSSValue* image = nullptr; |
| 1812 AtomicString uri(consumeUrl(range)); | 1823 AtomicString uri(consumeUrl(range)); |
| 1813 if (!uri.isNull()) { | 1824 if (!uri.isNull()) { |
| 1814 image = createCSSImageValueWithReferrer(uri, context); | 1825 image = createCSSImageValueWithReferrer(uri, context); |
| 1815 } else if (range.peek().type() == FunctionToken && range.peek().function
Id() == CSSValueWebkitImageSet) { | 1826 } else if (range.peek().type() == FunctionToken && range.peek().function
Id() == CSSValueWebkitImageSet) { |
| 1816 image = consumeImageSet(range, context); | 1827 image = consumeImageSet(range, context); |
| 1817 if (!image) | 1828 if (!image) |
| 1818 return nullptr; | 1829 return nullptr; |
| 1819 } else { | 1830 } else { |
| 1820 break; | 1831 break; |
| 1821 } | 1832 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1839 return nullptr; | 1850 return nullptr; |
| 1840 } | 1851 } |
| 1841 | 1852 |
| 1842 CSSValueID id = range.peek().id(); | 1853 CSSValueID id = range.peek().id(); |
| 1843 if (!range.atEnd() && context.useCounter()) { | 1854 if (!range.atEnd() && context.useCounter()) { |
| 1844 if (id == CSSValueWebkitZoomIn) | 1855 if (id == CSSValueWebkitZoomIn) |
| 1845 context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); | 1856 context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); |
| 1846 else if (id == CSSValueWebkitZoomOut) | 1857 else if (id == CSSValueWebkitZoomOut) |
| 1847 context.useCounter()->count(UseCounter::PrefixedCursorZoomOut); | 1858 context.useCounter()->count(UseCounter::PrefixedCursorZoomOut); |
| 1848 } | 1859 } |
| 1849 RawPtr<CSSValue> cursorType = nullptr; | 1860 CSSValue* cursorType = nullptr; |
| 1850 if (id == CSSValueHand) { | 1861 if (id == CSSValueHand) { |
| 1851 if (!inQuirksMode) // Non-standard behavior | 1862 if (!inQuirksMode) // Non-standard behavior |
| 1852 return nullptr; | 1863 return nullptr; |
| 1853 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer); | 1864 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer); |
| 1854 range.consumeIncludingWhitespace(); | 1865 range.consumeIncludingWhitespace(); |
| 1855 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV
alueCopy || id == CSSValueNone) { | 1866 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV
alueCopy || id == CSSValueNone) { |
| 1856 cursorType = consumeIdent(range); | 1867 cursorType = consumeIdent(range); |
| 1857 } else { | 1868 } else { |
| 1858 return nullptr; | 1869 return nullptr; |
| 1859 } | 1870 } |
| 1860 | 1871 |
| 1861 if (!list) | 1872 if (!list) |
| 1862 return cursorType.release(); | 1873 return cursorType; |
| 1863 list->append(cursorType.release()); | 1874 list->append(cursorType); |
| 1864 return list.release(); | 1875 return list; |
| 1865 } | 1876 } |
| 1866 | 1877 |
| 1867 // This should go away once we drop support for -webkit-gradient | 1878 // This should go away once we drop support for -webkit-gradient |
| 1868 static RawPtr<CSSPrimitiveValue> consumeDeprecatedGradientPoint(CSSParserTokenRa
nge& args, bool horizontal) | 1879 static CSSPrimitiveValue* consumeDeprecatedGradientPoint(CSSParserTokenRange& ar
gs, bool horizontal) |
| 1869 { | 1880 { |
| 1870 if (args.peek().type() == IdentToken) { | 1881 if (args.peek().type() == IdentToken) { |
| 1871 if ((horizontal && consumeIdent<CSSValueLeft>(args)) || (!horizontal &&
consumeIdent<CSSValueTop>(args))) | 1882 if ((horizontal && consumeIdent<CSSValueLeft>(args)) || (!horizontal &&
consumeIdent<CSSValueTop>(args))) |
| 1872 return cssValuePool().createValue(0., CSSPrimitiveValue::UnitType::P
ercentage); | 1883 return cssValuePool().createValue(0., CSSPrimitiveValue::UnitType::P
ercentage); |
| 1873 if ((horizontal && consumeIdent<CSSValueRight>(args)) || (!horizontal &&
consumeIdent<CSSValueBottom>(args))) | 1884 if ((horizontal && consumeIdent<CSSValueRight>(args)) || (!horizontal &&
consumeIdent<CSSValueBottom>(args))) |
| 1874 return cssValuePool().createValue(100., CSSPrimitiveValue::UnitType:
:Percentage); | 1885 return cssValuePool().createValue(100., CSSPrimitiveValue::UnitType:
:Percentage); |
| 1875 if (consumeIdent<CSSValueCenter>(args)) | 1886 if (consumeIdent<CSSValueCenter>(args)) |
| 1876 return cssValuePool().createValue(50., CSSPrimitiveValue::UnitType::
Percentage); | 1887 return cssValuePool().createValue(50., CSSPrimitiveValue::UnitType::
Percentage); |
| 1877 return nullptr; | 1888 return nullptr; |
| 1878 } | 1889 } |
| 1879 RawPtr<CSSPrimitiveValue> result = consumePercent(args, ValueRangeAll); | 1890 CSSPrimitiveValue* result = consumePercent(args, ValueRangeAll); |
| 1880 if (!result) | 1891 if (!result) |
| 1881 result = consumeNumber(args, ValueRangeAll); | 1892 result = consumeNumber(args, ValueRangeAll); |
| 1882 return result; | 1893 return result; |
| 1883 } | 1894 } |
| 1884 | 1895 |
| 1885 // Used to parse colors for -webkit-gradient(...). | 1896 // Used to parse colors for -webkit-gradient(...). |
| 1886 static RawPtr<CSSValue> consumeDeprecatedGradientStopColor(CSSParserTokenRange&
args, CSSParserMode cssParserMode) | 1897 static CSSValue* consumeDeprecatedGradientStopColor(CSSParserTokenRange& args, C
SSParserMode cssParserMode) |
| 1887 { | 1898 { |
| 1888 if (args.peek().id() == CSSValueCurrentcolor) | 1899 if (args.peek().id() == CSSValueCurrentcolor) |
| 1889 return nullptr; | 1900 return nullptr; |
| 1890 return consumeColor(args, cssParserMode); | 1901 return consumeColor(args, cssParserMode); |
| 1891 } | 1902 } |
| 1892 | 1903 |
| 1893 static bool consumeDeprecatedGradientColorStop(CSSParserTokenRange& range, CSSGr
adientColorStop& stop, CSSParserMode cssParserMode) | 1904 static bool consumeDeprecatedGradientColorStop(CSSParserTokenRange& range, CSSGr
adientColorStop& stop, CSSParserMode cssParserMode) |
| 1894 { | 1905 { |
| 1895 CSSValueID id = range.peek().functionId(); | 1906 CSSValueID id = range.peek().functionId(); |
| 1896 if (id != CSSValueFrom && id != CSSValueTo && id != CSSValueColorStop) | 1907 if (id != CSSValueFrom && id != CSSValueTo && id != CSSValueColorStop) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1912 | 1923 |
| 1913 if (!consumeCommaIncludingWhitespace(args)) | 1924 if (!consumeCommaIncludingWhitespace(args)) |
| 1914 return false; | 1925 return false; |
| 1915 } | 1926 } |
| 1916 | 1927 |
| 1917 stop.m_position = cssValuePool().createValue(position, CSSPrimitiveValue::Un
itType::Number); | 1928 stop.m_position = cssValuePool().createValue(position, CSSPrimitiveValue::Un
itType::Number); |
| 1918 stop.m_color = consumeDeprecatedGradientStopColor(args, cssParserMode); | 1929 stop.m_color = consumeDeprecatedGradientStopColor(args, cssParserMode); |
| 1919 return stop.m_color && args.atEnd(); | 1930 return stop.m_color && args.atEnd(); |
| 1920 } | 1931 } |
| 1921 | 1932 |
| 1922 static RawPtr<CSSValue> consumeDeprecatedGradient(CSSParserTokenRange& args, CSS
ParserMode cssParserMode) | 1933 static CSSValue* consumeDeprecatedGradient(CSSParserTokenRange& args, CSSParserM
ode cssParserMode) |
| 1923 { | 1934 { |
| 1924 RawPtr<CSSGradientValue> result = nullptr; | 1935 CSSGradientValue* result = nullptr; |
| 1925 CSSValueID id = args.consumeIncludingWhitespace().id(); | 1936 CSSValueID id = args.consumeIncludingWhitespace().id(); |
| 1926 bool isDeprecatedRadialGradient = (id == CSSValueRadial); | 1937 bool isDeprecatedRadialGradient = (id == CSSValueRadial); |
| 1927 if (isDeprecatedRadialGradient) | 1938 if (isDeprecatedRadialGradient) |
| 1928 result = CSSRadialGradientValue::create(NonRepeating, CSSDeprecatedRadia
lGradient); | 1939 result = CSSRadialGradientValue::create(NonRepeating, CSSDeprecatedRadia
lGradient); |
| 1929 else if (id == CSSValueLinear) | 1940 else if (id == CSSValueLinear) |
| 1930 result = CSSLinearGradientValue::create(NonRepeating, CSSDeprecatedLinea
rGradient); | 1941 result = CSSLinearGradientValue::create(NonRepeating, CSSDeprecatedLinea
rGradient); |
| 1931 if (!result || !consumeCommaIncludingWhitespace(args)) | 1942 if (!result || !consumeCommaIncludingWhitespace(args)) |
| 1932 return nullptr; | 1943 return nullptr; |
| 1933 | 1944 |
| 1934 RawPtr<CSSPrimitiveValue> point = consumeDeprecatedGradientPoint(args, true)
; | 1945 CSSPrimitiveValue* point = consumeDeprecatedGradientPoint(args, true); |
| 1935 if (!point) | 1946 if (!point) |
| 1936 return nullptr; | 1947 return nullptr; |
| 1937 result->setFirstX(point.release()); | 1948 result->setFirstX(point); |
| 1938 point = consumeDeprecatedGradientPoint(args, false); | 1949 point = consumeDeprecatedGradientPoint(args, false); |
| 1939 if (!point) | 1950 if (!point) |
| 1940 return nullptr; | 1951 return nullptr; |
| 1941 result->setFirstY(point.release()); | 1952 result->setFirstY(point); |
| 1942 | 1953 |
| 1943 if (!consumeCommaIncludingWhitespace(args)) | 1954 if (!consumeCommaIncludingWhitespace(args)) |
| 1944 return nullptr; | 1955 return nullptr; |
| 1945 | 1956 |
| 1946 // For radial gradients only, we now expect a numeric radius. | 1957 // For radial gradients only, we now expect a numeric radius. |
| 1947 if (isDeprecatedRadialGradient) { | 1958 if (isDeprecatedRadialGradient) { |
| 1948 RawPtr<CSSPrimitiveValue> radius = consumeNumber(args, ValueRangeAll); | 1959 CSSPrimitiveValue* radius = consumeNumber(args, ValueRangeAll); |
| 1949 if (!radius || !consumeCommaIncludingWhitespace(args)) | 1960 if (!radius || !consumeCommaIncludingWhitespace(args)) |
| 1950 return nullptr; | 1961 return nullptr; |
| 1951 toCSSRadialGradientValue(result.get())->setFirstRadius(radius.release())
; | 1962 toCSSRadialGradientValue(result)->setFirstRadius(radius); |
| 1952 } | 1963 } |
| 1953 | 1964 |
| 1954 point = consumeDeprecatedGradientPoint(args, true); | 1965 point = consumeDeprecatedGradientPoint(args, true); |
| 1955 if (!point) | 1966 if (!point) |
| 1956 return nullptr; | 1967 return nullptr; |
| 1957 result->setSecondX(point.release()); | 1968 result->setSecondX(point); |
| 1958 point = consumeDeprecatedGradientPoint(args, false); | 1969 point = consumeDeprecatedGradientPoint(args, false); |
| 1959 if (!point) | 1970 if (!point) |
| 1960 return nullptr; | 1971 return nullptr; |
| 1961 result->setSecondY(point.release()); | 1972 result->setSecondY(point); |
| 1962 | 1973 |
| 1963 // For radial gradients only, we now expect the second radius. | 1974 // For radial gradients only, we now expect the second radius. |
| 1964 if (isDeprecatedRadialGradient) { | 1975 if (isDeprecatedRadialGradient) { |
| 1965 if (!consumeCommaIncludingWhitespace(args)) | 1976 if (!consumeCommaIncludingWhitespace(args)) |
| 1966 return nullptr; | 1977 return nullptr; |
| 1967 RawPtr<CSSPrimitiveValue> radius = consumeNumber(args, ValueRangeAll); | 1978 CSSPrimitiveValue* radius = consumeNumber(args, ValueRangeAll); |
| 1968 if (!radius) | 1979 if (!radius) |
| 1969 return nullptr; | 1980 return nullptr; |
| 1970 toCSSRadialGradientValue(result.get())->setSecondRadius(radius.release()
); | 1981 toCSSRadialGradientValue(result)->setSecondRadius(radius); |
| 1971 } | 1982 } |
| 1972 | 1983 |
| 1973 CSSGradientColorStop stop; | 1984 CSSGradientColorStop stop; |
| 1974 while (consumeCommaIncludingWhitespace(args)) { | 1985 while (consumeCommaIncludingWhitespace(args)) { |
| 1975 if (!consumeDeprecatedGradientColorStop(args, stop, cssParserMode)) | 1986 if (!consumeDeprecatedGradientColorStop(args, stop, cssParserMode)) |
| 1976 return nullptr; | 1987 return nullptr; |
| 1977 result->addStop(stop); | 1988 result->addStop(stop); |
| 1978 } | 1989 } |
| 1979 | 1990 |
| 1980 return result.release(); | 1991 return result; |
| 1981 } | 1992 } |
| 1982 | 1993 |
| 1983 static bool consumeGradientColorStops(CSSParserTokenRange& range, CSSParserMode
cssParserMode, CSSGradientValue* gradient) | 1994 static bool consumeGradientColorStops(CSSParserTokenRange& range, CSSParserMode
cssParserMode, CSSGradientValue* gradient) |
| 1984 { | 1995 { |
| 1985 bool supportsColorHints = gradient->gradientType() == CSSLinearGradient || g
radient->gradientType() == CSSRadialGradient; | 1996 bool supportsColorHints = gradient->gradientType() == CSSLinearGradient || g
radient->gradientType() == CSSRadialGradient; |
| 1986 | 1997 |
| 1987 // The first color stop cannot be a color hint. | 1998 // The first color stop cannot be a color hint. |
| 1988 bool previousStopWasColorHint = true; | 1999 bool previousStopWasColorHint = true; |
| 1989 do { | 2000 do { |
| 1990 CSSGradientColorStop stop; | 2001 CSSGradientColorStop stop; |
| 1991 stop.m_color = consumeColor(range, cssParserMode); | 2002 stop.m_color = consumeColor(range, cssParserMode); |
| 1992 // Two hints in a row are not allowed. | 2003 // Two hints in a row are not allowed. |
| 1993 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) | 2004 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) |
| 1994 return false; | 2005 return false; |
| 1995 previousStopWasColorHint = !stop.m_color; | 2006 previousStopWasColorHint = !stop.m_color; |
| 1996 stop.m_position = consumeLengthOrPercent(range, cssParserMode, ValueRang
eAll); | 2007 stop.m_position = consumeLengthOrPercent(range, cssParserMode, ValueRang
eAll); |
| 1997 if (!stop.m_color && !stop.m_position) | 2008 if (!stop.m_color && !stop.m_position) |
| 1998 return false; | 2009 return false; |
| 1999 gradient->addStop(stop); | 2010 gradient->addStop(stop); |
| 2000 } while (consumeCommaIncludingWhitespace(range)); | 2011 } while (consumeCommaIncludingWhitespace(range)); |
| 2001 | 2012 |
| 2002 // The last color stop cannot be a color hint. | 2013 // The last color stop cannot be a color hint. |
| 2003 if (previousStopWasColorHint) | 2014 if (previousStopWasColorHint) |
| 2004 return false; | 2015 return false; |
| 2005 | 2016 |
| 2006 // Must have 2 or more stops to be valid. | 2017 // Must have 2 or more stops to be valid. |
| 2007 return gradient->stopCount() >= 2; | 2018 return gradient->stopCount() >= 2; |
| 2008 } | 2019 } |
| 2009 | 2020 |
| 2010 static RawPtr<CSSValue> consumeDeprecatedRadialGradient(CSSParserTokenRange& arg
s, CSSParserMode cssParserMode, CSSGradientRepeat repeating) | 2021 static CSSValue* consumeDeprecatedRadialGradient(CSSParserTokenRange& args, CSSP
arserMode cssParserMode, CSSGradientRepeat repeating) |
| 2011 { | 2022 { |
| 2012 RawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSPrefixedRadialGradient); | 2023 CSSRadialGradientValue* result = CSSRadialGradientValue::create(repeating, C
SSPrefixedRadialGradient); |
| 2013 RawPtr<CSSValue> centerX = nullptr; | 2024 CSSValue* centerX = nullptr; |
| 2014 RawPtr<CSSValue> centerY = nullptr; | 2025 CSSValue* centerY = nullptr; |
| 2015 consumeOneOrTwoValuedPosition(args, cssParserMode, UnitlessQuirk::Forbid, ce
nterX, centerY); | 2026 consumeOneOrTwoValuedPosition(args, cssParserMode, UnitlessQuirk::Forbid, ce
nterX, centerY); |
| 2016 if ((centerX || centerY) && !consumeCommaIncludingWhitespace(args)) | 2027 if ((centerX || centerY) && !consumeCommaIncludingWhitespace(args)) |
| 2017 return nullptr; | 2028 return nullptr; |
| 2018 | 2029 |
| 2019 result->setFirstX(toCSSPrimitiveValue(centerX.get())); | 2030 result->setFirstX(toCSSPrimitiveValue(centerX)); |
| 2020 result->setSecondX(toCSSPrimitiveValue(centerX.get())); | 2031 result->setSecondX(toCSSPrimitiveValue(centerX)); |
| 2021 result->setFirstY(toCSSPrimitiveValue(centerY.get())); | 2032 result->setFirstY(toCSSPrimitiveValue(centerY)); |
| 2022 result->setSecondY(toCSSPrimitiveValue(centerY.get())); | 2033 result->setSecondY(toCSSPrimitiveValue(centerY)); |
| 2023 | 2034 |
| 2024 RawPtr<CSSPrimitiveValue> shape = consumeIdent<CSSValueCircle, CSSValueEllip
se>(args); | 2035 CSSPrimitiveValue* shape = consumeIdent<CSSValueCircle, CSSValueEllipse>(arg
s); |
| 2025 RawPtr<CSSPrimitiveValue> sizeKeyword = consumeIdent<CSSValueClosestSide, CS
SValueClosestCorner, CSSValueFarthestSide, CSSValueFarthestCorner, CSSValueConta
in, CSSValueCover>(args); | 2036 CSSPrimitiveValue* sizeKeyword = consumeIdent<CSSValueClosestSide, CSSValueC
losestCorner, CSSValueFarthestSide, CSSValueFarthestCorner, CSSValueContain, CSS
ValueCover>(args); |
| 2026 if (!shape) | 2037 if (!shape) |
| 2027 shape = consumeIdent<CSSValueCircle, CSSValueEllipse>(args); | 2038 shape = consumeIdent<CSSValueCircle, CSSValueEllipse>(args); |
| 2028 result->setShape(shape); | 2039 result->setShape(shape); |
| 2029 result->setSizingBehavior(sizeKeyword); | 2040 result->setSizingBehavior(sizeKeyword); |
| 2030 | 2041 |
| 2031 // Or, two lengths or percentages | 2042 // Or, two lengths or percentages |
| 2032 if (!shape && !sizeKeyword) { | 2043 if (!shape && !sizeKeyword) { |
| 2033 RawPtr<CSSPrimitiveValue> horizontalSize = nullptr; | 2044 CSSPrimitiveValue* horizontalSize = consumeLengthOrPercent(args, cssPars
erMode, ValueRangeAll); |
| 2034 RawPtr<CSSPrimitiveValue> verticalSize = nullptr; | 2045 CSSPrimitiveValue* verticalSize = nullptr; |
| 2035 if ((horizontalSize = consumeLengthOrPercent(args, cssParserMode, ValueR
angeAll))) { | 2046 if (horizontalSize) { |
| 2036 verticalSize = consumeLengthOrPercent(args, cssParserMode, ValueRang
eAll); | 2047 verticalSize = consumeLengthOrPercent(args, cssParserMode, ValueRang
eAll); |
| 2037 if (!verticalSize) | 2048 if (!verticalSize) |
| 2038 return nullptr; | 2049 return nullptr; |
| 2039 consumeCommaIncludingWhitespace(args); | 2050 consumeCommaIncludingWhitespace(args); |
| 2040 result->setEndHorizontalSize(horizontalSize); | 2051 result->setEndHorizontalSize(horizontalSize); |
| 2041 result->setEndVerticalSize(verticalSize); | 2052 result->setEndVerticalSize(verticalSize); |
| 2042 } | 2053 } |
| 2043 } else { | 2054 } else { |
| 2044 consumeCommaIncludingWhitespace(args); | 2055 consumeCommaIncludingWhitespace(args); |
| 2045 } | 2056 } |
| 2046 if (!consumeGradientColorStops(args, cssParserMode, result.get())) | 2057 if (!consumeGradientColorStops(args, cssParserMode, result)) |
| 2047 return nullptr; | 2058 return nullptr; |
| 2048 | 2059 |
| 2049 return result.release(); | 2060 return result; |
| 2050 } | 2061 } |
| 2051 | 2062 |
| 2052 static RawPtr<CSSValue> consumeRadialGradient(CSSParserTokenRange& args, CSSPars
erMode cssParserMode, CSSGradientRepeat repeating) | 2063 static CSSValue* consumeRadialGradient(CSSParserTokenRange& args, CSSParserMode
cssParserMode, CSSGradientRepeat repeating) |
| 2053 { | 2064 { |
| 2054 RawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::create(repea
ting, CSSRadialGradient); | 2065 CSSRadialGradientValue* result = CSSRadialGradientValue::create(repeating, C
SSRadialGradient); |
| 2055 | 2066 |
| 2056 RawPtr<CSSPrimitiveValue> shape = nullptr; | 2067 CSSPrimitiveValue* shape = nullptr; |
| 2057 RawPtr<CSSPrimitiveValue> sizeKeyword = nullptr; | 2068 CSSPrimitiveValue* sizeKeyword = nullptr; |
| 2058 RawPtr<CSSPrimitiveValue> horizontalSize = nullptr; | 2069 CSSPrimitiveValue* horizontalSize = nullptr; |
| 2059 RawPtr<CSSPrimitiveValue> verticalSize = nullptr; | 2070 CSSPrimitiveValue* verticalSize = nullptr; |
| 2060 | 2071 |
| 2061 // First part of grammar, the size/shape clause: | 2072 // First part of grammar, the size/shape clause: |
| 2062 // [ circle || <length> ] | | 2073 // [ circle || <length> ] | |
| 2063 // [ ellipse || [ <length> | <percentage> ]{2} ] | | 2074 // [ ellipse || [ <length> | <percentage> ]{2} ] | |
| 2064 // [ [ circle | ellipse] || <size-keyword> ] | 2075 // [ [ circle | ellipse] || <size-keyword> ] |
| 2065 for (int i = 0; i < 3; ++i) { | 2076 for (int i = 0; i < 3; ++i) { |
| 2066 if (args.peek().type() == IdentToken) { | 2077 if (args.peek().type() == IdentToken) { |
| 2067 CSSValueID id = args.peek().id(); | 2078 CSSValueID id = args.peek().id(); |
| 2068 if (id == CSSValueCircle || id == CSSValueEllipse) { | 2079 if (id == CSSValueCircle || id == CSSValueEllipse) { |
| 2069 if (shape) | 2080 if (shape) |
| 2070 return nullptr; | 2081 return nullptr; |
| 2071 shape = consumeIdent(args); | 2082 shape = consumeIdent(args); |
| 2072 } else if (id == CSSValueClosestSide || id == CSSValueClosestCorner
|| id == CSSValueFarthestSide || id == CSSValueFarthestCorner) { | 2083 } else if (id == CSSValueClosestSide || id == CSSValueClosestCorner
|| id == CSSValueFarthestSide || id == CSSValueFarthestCorner) { |
| 2073 if (sizeKeyword) | 2084 if (sizeKeyword) |
| 2074 return nullptr; | 2085 return nullptr; |
| 2075 sizeKeyword = consumeIdent(args); | 2086 sizeKeyword = consumeIdent(args); |
| 2076 } else { | 2087 } else { |
| 2077 break; | 2088 break; |
| 2078 } | 2089 } |
| 2079 } else { | 2090 } else { |
| 2080 RawPtr<CSSPrimitiveValue> center = consumeLengthOrPercent(args, cssP
arserMode, ValueRangeAll); | 2091 CSSPrimitiveValue* center = consumeLengthOrPercent(args, cssParserMo
de, ValueRangeAll); |
| 2081 if (!center) | 2092 if (!center) |
| 2082 break; | 2093 break; |
| 2083 if (horizontalSize) | 2094 if (horizontalSize) |
| 2084 return nullptr; | 2095 return nullptr; |
| 2085 horizontalSize = center; | 2096 horizontalSize = center; |
| 2086 if ((center = consumeLengthOrPercent(args, cssParserMode, ValueRange
All))) { | 2097 center = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll); |
| 2087 verticalSize = center.release(); | 2098 if (center) { |
| 2099 verticalSize = center; |
| 2088 ++i; | 2100 ++i; |
| 2089 } | 2101 } |
| 2090 } | 2102 } |
| 2091 } | 2103 } |
| 2092 | 2104 |
| 2093 // You can specify size as a keyword or a length/percentage, not both. | 2105 // You can specify size as a keyword or a length/percentage, not both. |
| 2094 if (sizeKeyword && horizontalSize) | 2106 if (sizeKeyword && horizontalSize) |
| 2095 return nullptr; | 2107 return nullptr; |
| 2096 // Circles must have 0 or 1 lengths. | 2108 // Circles must have 0 or 1 lengths. |
| 2097 if (shape && shape->getValueID() == CSSValueCircle && verticalSize) | 2109 if (shape && shape->getValueID() == CSSValueCircle && verticalSize) |
| 2098 return nullptr; | 2110 return nullptr; |
| 2099 // Ellipses must have 0 or 2 length/percentages. | 2111 // Ellipses must have 0 or 2 length/percentages. |
| 2100 if (shape && shape->getValueID() == CSSValueEllipse && horizontalSize && !ve
rticalSize) | 2112 if (shape && shape->getValueID() == CSSValueEllipse && horizontalSize && !ve
rticalSize) |
| 2101 return nullptr; | 2113 return nullptr; |
| 2102 // If there's only one size, it must be a length. | 2114 // If there's only one size, it must be a length. |
| 2103 // TODO(timloh): Calcs with both lengths and percentages should be rejected. | 2115 // TODO(timloh): Calcs with both lengths and percentages should be rejected. |
| 2104 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) | 2116 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) |
| 2105 return nullptr; | 2117 return nullptr; |
| 2106 | 2118 |
| 2107 result->setShape(shape); | 2119 result->setShape(shape); |
| 2108 result->setSizingBehavior(sizeKeyword); | 2120 result->setSizingBehavior(sizeKeyword); |
| 2109 result->setEndHorizontalSize(horizontalSize); | 2121 result->setEndHorizontalSize(horizontalSize); |
| 2110 result->setEndVerticalSize(verticalSize); | 2122 result->setEndVerticalSize(verticalSize); |
| 2111 | 2123 |
| 2112 RawPtr<CSSValue> centerX = nullptr; | 2124 CSSValue* centerX = nullptr; |
| 2113 RawPtr<CSSValue> centerY = nullptr; | 2125 CSSValue* centerY = nullptr; |
| 2114 if (args.peek().id() == CSSValueAt) { | 2126 if (args.peek().id() == CSSValueAt) { |
| 2115 args.consumeIncludingWhitespace(); | 2127 args.consumeIncludingWhitespace(); |
| 2116 consumePosition(args, cssParserMode, UnitlessQuirk::Forbid, centerX, cen
terY); | 2128 consumePosition(args, cssParserMode, UnitlessQuirk::Forbid, centerX, cen
terY); |
| 2117 if (!(centerX && centerY)) | 2129 if (!(centerX && centerY)) |
| 2118 return nullptr; | 2130 return nullptr; |
| 2119 result->setFirstX(centerX); | 2131 result->setFirstX(centerX); |
| 2120 result->setFirstY(centerY); | 2132 result->setFirstY(centerY); |
| 2121 // Right now, CSS radial gradients have the same start and end centers. | 2133 // Right now, CSS radial gradients have the same start and end centers. |
| 2122 result->setSecondX(centerX); | 2134 result->setSecondX(centerX); |
| 2123 result->setSecondY(centerY); | 2135 result->setSecondY(centerY); |
| 2124 } | 2136 } |
| 2125 | 2137 |
| 2126 if ((shape || sizeKeyword || horizontalSize || centerX || centerY) && !consu
meCommaIncludingWhitespace(args)) | 2138 if ((shape || sizeKeyword || horizontalSize || centerX || centerY) && !consu
meCommaIncludingWhitespace(args)) |
| 2127 return nullptr; | 2139 return nullptr; |
| 2128 if (!consumeGradientColorStops(args, cssParserMode, result.get())) | 2140 if (!consumeGradientColorStops(args, cssParserMode, result)) |
| 2129 return nullptr; | 2141 return nullptr; |
| 2130 return result.release(); | 2142 return result; |
| 2131 } | 2143 } |
| 2132 | 2144 |
| 2133 static RawPtr<CSSValue> consumeLinearGradient(CSSParserTokenRange& args, CSSPars
erMode cssParserMode, CSSGradientRepeat repeating, CSSGradientType gradientType) | 2145 static CSSValue* consumeLinearGradient(CSSParserTokenRange& args, CSSParserMode
cssParserMode, CSSGradientRepeat repeating, CSSGradientType gradientType) |
| 2134 { | 2146 { |
| 2135 RawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::create(repea
ting, gradientType); | 2147 CSSLinearGradientValue* result = CSSLinearGradientValue::create(repeating, g
radientType); |
| 2136 | 2148 |
| 2137 bool expectComma = true; | 2149 bool expectComma = true; |
| 2138 RawPtr<CSSPrimitiveValue> angle = consumeAngle(args); | 2150 CSSPrimitiveValue* angle = consumeAngle(args); |
| 2139 if (angle) { | 2151 if (angle) { |
| 2140 result->setAngle(angle.release()); | 2152 result->setAngle(angle); |
| 2141 } else if (gradientType == CSSPrefixedLinearGradient || consumeIdent<CSSValu
eTo>(args)) { | 2153 } else if (gradientType == CSSPrefixedLinearGradient || consumeIdent<CSSValu
eTo>(args)) { |
| 2142 RawPtr<CSSPrimitiveValue> endX = consumeIdent<CSSValueLeft, CSSValueRigh
t>(args); | 2154 CSSPrimitiveValue* endX = consumeIdent<CSSValueLeft, CSSValueRight>(args
); |
| 2143 RawPtr<CSSPrimitiveValue> endY = consumeIdent<CSSValueBottom, CSSValueTo
p>(args); | 2155 CSSPrimitiveValue* endY = consumeIdent<CSSValueBottom, CSSValueTop>(args
); |
| 2144 if (!endX && !endY) { | 2156 if (!endX && !endY) { |
| 2145 if (gradientType == CSSLinearGradient) | 2157 if (gradientType == CSSLinearGradient) |
| 2146 return nullptr; | 2158 return nullptr; |
| 2147 endY = cssValuePool().createIdentifierValue(CSSValueTop); | 2159 endY = cssValuePool().createIdentifierValue(CSSValueTop); |
| 2148 expectComma = false; | 2160 expectComma = false; |
| 2149 } else if (!endX) { | 2161 } else if (!endX) { |
| 2150 endX = consumeIdent<CSSValueLeft, CSSValueRight>(args); | 2162 endX = consumeIdent<CSSValueLeft, CSSValueRight>(args); |
| 2151 } | 2163 } |
| 2152 | 2164 |
| 2153 result->setFirstX(endX.release()); | 2165 result->setFirstX(endX); |
| 2154 result->setFirstY(endY.release()); | 2166 result->setFirstY(endY); |
| 2155 } else { | 2167 } else { |
| 2156 expectComma = false; | 2168 expectComma = false; |
| 2157 } | 2169 } |
| 2158 | 2170 |
| 2159 if (expectComma && !consumeCommaIncludingWhitespace(args)) | 2171 if (expectComma && !consumeCommaIncludingWhitespace(args)) |
| 2160 return nullptr; | 2172 return nullptr; |
| 2161 if (!consumeGradientColorStops(args, cssParserMode, result.get())) | 2173 if (!consumeGradientColorStops(args, cssParserMode, result)) |
| 2162 return nullptr; | 2174 return nullptr; |
| 2163 return result.release(); | 2175 return result; |
| 2164 } | 2176 } |
| 2165 | 2177 |
| 2166 static RawPtr<CSSValue> consumeImageOrNone(CSSParserTokenRange&, CSSParserContex
t); | 2178 static CSSValue* consumeImageOrNone(CSSParserTokenRange&, CSSParserContext); |
| 2167 | 2179 |
| 2168 static RawPtr<CSSValue> consumeCrossFade(CSSParserTokenRange& args, CSSParserCon
text context) | 2180 static CSSValue* consumeCrossFade(CSSParserTokenRange& args, CSSParserContext co
ntext) |
| 2169 { | 2181 { |
| 2170 RawPtr<CSSValue> fromImageValue = consumeImageOrNone(args, context); | 2182 CSSValue* fromImageValue = consumeImageOrNone(args, context); |
| 2171 if (!fromImageValue || !consumeCommaIncludingWhitespace(args)) | 2183 if (!fromImageValue || !consumeCommaIncludingWhitespace(args)) |
| 2172 return nullptr; | 2184 return nullptr; |
| 2173 RawPtr<CSSValue> toImageValue = consumeImageOrNone(args, context); | 2185 CSSValue* toImageValue = consumeImageOrNone(args, context); |
| 2174 if (!toImageValue || !consumeCommaIncludingWhitespace(args)) | 2186 if (!toImageValue || !consumeCommaIncludingWhitespace(args)) |
| 2175 return nullptr; | 2187 return nullptr; |
| 2176 | 2188 |
| 2177 RawPtr<CSSPrimitiveValue> percentage = nullptr; | 2189 CSSPrimitiveValue* percentage = nullptr; |
| 2178 const CSSParserToken& percentageArg = args.consumeIncludingWhitespace(); | 2190 const CSSParserToken& percentageArg = args.consumeIncludingWhitespace(); |
| 2179 if (percentageArg.type() == PercentageToken) | 2191 if (percentageArg.type() == PercentageToken) |
| 2180 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu
mericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::Number); | 2192 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu
mericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::Number); |
| 2181 else if (percentageArg.type() == NumberToken) | 2193 else if (percentageArg.type() == NumberToken) |
| 2182 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu
mericValue(), 0, 1), CSSPrimitiveValue::UnitType::Number); | 2194 percentage = cssValuePool().createValue(clampTo<double>(percentageArg.nu
mericValue(), 0, 1), CSSPrimitiveValue::UnitType::Number); |
| 2183 | 2195 |
| 2184 if (!percentage) | 2196 if (!percentage) |
| 2185 return nullptr; | 2197 return nullptr; |
| 2186 return CSSCrossfadeValue::create(fromImageValue, toImageValue, percentage); | 2198 return CSSCrossfadeValue::create(fromImageValue, toImageValue, percentage); |
| 2187 } | 2199 } |
| 2188 | 2200 |
| 2189 static RawPtr<CSSValue> consumePaint(CSSParserTokenRange& args, CSSParserContext
context) | 2201 static CSSValue* consumePaint(CSSParserTokenRange& args, CSSParserContext contex
t) |
| 2190 { | 2202 { |
| 2191 ASSERT(RuntimeEnabledFeatures::cssPaintAPIEnabled()); | 2203 ASSERT(RuntimeEnabledFeatures::cssPaintAPIEnabled()); |
| 2192 | 2204 |
| 2193 RawPtr<CSSCustomIdentValue> name = consumeCustomIdent(args); | 2205 CSSCustomIdentValue* name = consumeCustomIdent(args); |
| 2194 if (!name) | 2206 if (!name) |
| 2195 return nullptr; | 2207 return nullptr; |
| 2196 | 2208 |
| 2197 return CSSPaintValue::create(name.release()); | 2209 return CSSPaintValue::create(name); |
| 2198 } | 2210 } |
| 2199 | 2211 |
| 2200 static RawPtr<CSSValue> consumeGeneratedImage(CSSParserTokenRange& range, CSSPar
serContext context) | 2212 static CSSValue* consumeGeneratedImage(CSSParserTokenRange& range, CSSParserCont
ext context) |
| 2201 { | 2213 { |
| 2202 CSSValueID id = range.peek().functionId(); | 2214 CSSValueID id = range.peek().functionId(); |
| 2203 CSSParserTokenRange rangeCopy = range; | 2215 CSSParserTokenRange rangeCopy = range; |
| 2204 CSSParserTokenRange args = consumeFunction(rangeCopy); | 2216 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 2205 RawPtr<CSSValue> result = nullptr; | 2217 CSSValue* result = nullptr; |
| 2206 if (id == CSSValueRadialGradient) { | 2218 if (id == CSSValueRadialGradient) { |
| 2207 result = consumeRadialGradient(args, context.mode(), NonRepeating); | 2219 result = consumeRadialGradient(args, context.mode(), NonRepeating); |
| 2208 } else if (id == CSSValueRepeatingRadialGradient) { | 2220 } else if (id == CSSValueRepeatingRadialGradient) { |
| 2209 result = consumeRadialGradient(args, context.mode(), Repeating); | 2221 result = consumeRadialGradient(args, context.mode(), Repeating); |
| 2210 } else if (id == CSSValueWebkitLinearGradient) { | 2222 } else if (id == CSSValueWebkitLinearGradient) { |
| 2211 // FIXME: This should send a deprecation message. | 2223 // FIXME: This should send a deprecation message. |
| 2212 if (context.useCounter()) | 2224 if (context.useCounter()) |
| 2213 context.useCounter()->count(UseCounter::DeprecatedWebKitLinearGradie
nt); | 2225 context.useCounter()->count(UseCounter::DeprecatedWebKitLinearGradie
nt); |
| 2214 result = consumeLinearGradient(args, context.mode(), NonRepeating, CSSPr
efixedLinearGradient); | 2226 result = consumeLinearGradient(args, context.mode(), NonRepeating, CSSPr
efixedLinearGradient); |
| 2215 } else if (id == CSSValueWebkitRepeatingLinearGradient) { | 2227 } else if (id == CSSValueWebkitRepeatingLinearGradient) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 | 2260 |
| 2249 static bool isGeneratedImage(CSSValueID id) | 2261 static bool isGeneratedImage(CSSValueID id) |
| 2250 { | 2262 { |
| 2251 return id == CSSValueLinearGradient || id == CSSValueRadialGradient | 2263 return id == CSSValueLinearGradient || id == CSSValueRadialGradient |
| 2252 || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadia
lGradient | 2264 || id == CSSValueRepeatingLinearGradient || id == CSSValueRepeatingRadia
lGradient |
| 2253 || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradi
ent | 2265 || id == CSSValueWebkitLinearGradient || id == CSSValueWebkitRadialGradi
ent |
| 2254 || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRe
peatingRadialGradient | 2266 || id == CSSValueWebkitRepeatingLinearGradient || id == CSSValueWebkitRe
peatingRadialGradient |
| 2255 || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id =
= CSSValuePaint; | 2267 || id == CSSValueWebkitGradient || id == CSSValueWebkitCrossFade || id =
= CSSValuePaint; |
| 2256 } | 2268 } |
| 2257 | 2269 |
| 2258 static RawPtr<CSSValue> consumeImage(CSSParserTokenRange& range, CSSParserContex
t context) | 2270 static CSSValue* consumeImage(CSSParserTokenRange& range, CSSParserContext conte
xt) |
| 2259 { | 2271 { |
| 2260 AtomicString uri(consumeUrl(range)); | 2272 AtomicString uri(consumeUrl(range)); |
| 2261 if (!uri.isNull()) | 2273 if (!uri.isNull()) |
| 2262 return createCSSImageValueWithReferrer(uri, context); | 2274 return createCSSImageValueWithReferrer(uri, context); |
| 2263 if (range.peek().type() == FunctionToken) { | 2275 if (range.peek().type() == FunctionToken) { |
| 2264 CSSValueID id = range.peek().functionId(); | 2276 CSSValueID id = range.peek().functionId(); |
| 2265 if (id == CSSValueWebkitImageSet) | 2277 if (id == CSSValueWebkitImageSet) |
| 2266 return consumeImageSet(range, context); | 2278 return consumeImageSet(range, context); |
| 2267 if (isGeneratedImage(id)) | 2279 if (isGeneratedImage(id)) |
| 2268 return consumeGeneratedImage(range, context); | 2280 return consumeGeneratedImage(range, context); |
| 2269 } | 2281 } |
| 2270 return nullptr; | 2282 return nullptr; |
| 2271 } | 2283 } |
| 2272 | 2284 |
| 2273 static RawPtr<CSSValue> consumeImageOrNone(CSSParserTokenRange& range, CSSParser
Context context) | 2285 static CSSValue* consumeImageOrNone(CSSParserTokenRange& range, CSSParserContext
context) |
| 2274 { | 2286 { |
| 2275 if (range.peek().id() == CSSValueNone) | 2287 if (range.peek().id() == CSSValueNone) |
| 2276 return consumeIdent(range); | 2288 return consumeIdent(range); |
| 2277 return consumeImage(range, context); | 2289 return consumeImage(range, context); |
| 2278 } | 2290 } |
| 2279 | 2291 |
| 2280 static RawPtr<CSSValue> consumeAttr(CSSParserTokenRange args, CSSParserContext c
ontext) | 2292 static CSSValue* consumeAttr(CSSParserTokenRange args, CSSParserContext context) |
| 2281 { | 2293 { |
| 2282 if (args.peek().type() != IdentToken) | 2294 if (args.peek().type() != IdentToken) |
| 2283 return nullptr; | 2295 return nullptr; |
| 2284 | 2296 |
| 2285 String attrName = args.consumeIncludingWhitespace().value(); | 2297 String attrName = args.consumeIncludingWhitespace().value(); |
| 2286 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". | 2298 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". |
| 2287 // But HTML attribute names can't have those characters, and we should not | 2299 // But HTML attribute names can't have those characters, and we should not |
| 2288 // even parse them inside attr(). | 2300 // even parse them inside attr(). |
| 2289 // TODO(timloh): We should allow any <ident-token> here. | 2301 // TODO(timloh): We should allow any <ident-token> here. |
| 2290 if (attrName[0] == '-' || !args.atEnd()) | 2302 if (attrName[0] == '-' || !args.atEnd()) |
| 2291 return nullptr; | 2303 return nullptr; |
| 2292 | 2304 |
| 2293 if (context.isHTMLDocument()) | 2305 if (context.isHTMLDocument()) |
| 2294 attrName = attrName.lower(); | 2306 attrName = attrName.lower(); |
| 2295 | 2307 |
| 2296 RawPtr<CSSFunctionValue> attrValue = CSSFunctionValue::create(CSSValueAttr); | 2308 CSSFunctionValue* attrValue = CSSFunctionValue::create(CSSValueAttr); |
| 2297 attrValue->append(CSSCustomIdentValue::create(attrName)); | 2309 attrValue->append(CSSCustomIdentValue::create(attrName)); |
| 2298 return attrValue.release(); | 2310 return attrValue; |
| 2299 } | 2311 } |
| 2300 | 2312 |
| 2301 static RawPtr<CSSValue> consumeCounterContent(CSSParserTokenRange args, bool cou
nters) | 2313 static CSSValue* consumeCounterContent(CSSParserTokenRange args, bool counters) |
| 2302 { | 2314 { |
| 2303 RawPtr<CSSCustomIdentValue> identifier = consumeCustomIdent(args); | 2315 CSSCustomIdentValue* identifier = consumeCustomIdent(args); |
| 2304 if (!identifier) | 2316 if (!identifier) |
| 2305 return nullptr; | 2317 return nullptr; |
| 2306 | 2318 |
| 2307 // TODO(timloh): Make this a CSSStringValue. | 2319 // TODO(timloh): Make this a CSSStringValue. |
| 2308 RawPtr<CSSCustomIdentValue> separator = nullptr; | 2320 CSSCustomIdentValue* separator = nullptr; |
| 2309 if (!counters) { | 2321 if (!counters) { |
| 2310 separator = CSSCustomIdentValue::create(String()); | 2322 separator = CSSCustomIdentValue::create(String()); |
| 2311 } else { | 2323 } else { |
| 2312 if (!consumeCommaIncludingWhitespace(args)) | 2324 if (!consumeCommaIncludingWhitespace(args)) |
| 2313 return nullptr; | 2325 return nullptr; |
| 2314 if (args.peek().type() != StringToken) | 2326 if (args.peek().type() != StringToken) |
| 2315 return nullptr; | 2327 return nullptr; |
| 2316 separator = CSSCustomIdentValue::create(args.consumeIncludingWhitespace(
).value()); | 2328 separator = CSSCustomIdentValue::create(args.consumeIncludingWhitespace(
).value()); |
| 2317 } | 2329 } |
| 2318 | 2330 |
| 2319 RawPtr<CSSPrimitiveValue> listStyle = nullptr; | 2331 CSSPrimitiveValue* listStyle = nullptr; |
| 2320 if (consumeCommaIncludingWhitespace(args)) { | 2332 if (consumeCommaIncludingWhitespace(args)) { |
| 2321 CSSValueID id = args.peek().id(); | 2333 CSSValueID id = args.peek().id(); |
| 2322 if ((id != CSSValueNone && (id < CSSValueDisc || id > CSSValueKatakanaIr
oha))) | 2334 if ((id != CSSValueNone && (id < CSSValueDisc || id > CSSValueKatakanaIr
oha))) |
| 2323 return nullptr; | 2335 return nullptr; |
| 2324 listStyle = consumeIdent(args); | 2336 listStyle = consumeIdent(args); |
| 2325 } else { | 2337 } else { |
| 2326 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); | 2338 listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal); |
| 2327 } | 2339 } |
| 2328 | 2340 |
| 2329 if (!args.atEnd()) | 2341 if (!args.atEnd()) |
| 2330 return nullptr; | 2342 return nullptr; |
| 2331 return CSSCounterValue::create(identifier.release(), listStyle.release(), se
parator.release()); | 2343 return CSSCounterValue::create(identifier, listStyle, separator); |
| 2332 } | 2344 } |
| 2333 | 2345 |
| 2334 static RawPtr<CSSValue> consumeContent(CSSParserTokenRange& range, CSSParserCont
ext context) | 2346 static CSSValue* consumeContent(CSSParserTokenRange& range, CSSParserContext con
text) |
| 2335 { | 2347 { |
| 2336 if (identMatches<CSSValueNone, CSSValueNormal>(range.peek().id())) | 2348 if (identMatches<CSSValueNone, CSSValueNormal>(range.peek().id())) |
| 2337 return consumeIdent(range); | 2349 return consumeIdent(range); |
| 2338 | 2350 |
| 2339 RawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); | 2351 CSSValueList* values = CSSValueList::createSpaceSeparated(); |
| 2340 | 2352 |
| 2341 do { | 2353 do { |
| 2342 RawPtr<CSSValue> parsedValue = consumeImage(range, context); | 2354 CSSValue* parsedValue = consumeImage(range, context); |
| 2343 if (!parsedValue) | 2355 if (!parsedValue) |
| 2344 parsedValue = consumeIdent<CSSValueOpenQuote, CSSValueCloseQuote, CS
SValueNoOpenQuote, CSSValueNoCloseQuote>(range); | 2356 parsedValue = consumeIdent<CSSValueOpenQuote, CSSValueCloseQuote, CS
SValueNoOpenQuote, CSSValueNoCloseQuote>(range); |
| 2345 if (!parsedValue) | 2357 if (!parsedValue) |
| 2346 parsedValue = consumeString(range); | 2358 parsedValue = consumeString(range); |
| 2347 if (!parsedValue) { | 2359 if (!parsedValue) { |
| 2348 if (range.peek().functionId() == CSSValueAttr) | 2360 if (range.peek().functionId() == CSSValueAttr) |
| 2349 parsedValue = consumeAttr(consumeFunction(range), context); | 2361 parsedValue = consumeAttr(consumeFunction(range), context); |
| 2350 else if (range.peek().functionId() == CSSValueCounter) | 2362 else if (range.peek().functionId() == CSSValueCounter) |
| 2351 parsedValue = consumeCounterContent(consumeFunction(range), fals
e); | 2363 parsedValue = consumeCounterContent(consumeFunction(range), fals
e); |
| 2352 else if (range.peek().functionId() == CSSValueCounters) | 2364 else if (range.peek().functionId() == CSSValueCounters) |
| 2353 parsedValue = consumeCounterContent(consumeFunction(range), true
); | 2365 parsedValue = consumeCounterContent(consumeFunction(range), true
); |
| 2354 if (!parsedValue) | 2366 if (!parsedValue) |
| 2355 return nullptr; | 2367 return nullptr; |
| 2356 } | 2368 } |
| 2357 values->append(parsedValue.release()); | 2369 values->append(parsedValue); |
| 2358 } while (!range.atEnd()); | 2370 } while (!range.atEnd()); |
| 2359 | 2371 |
| 2360 return values.release(); | 2372 return values; |
| 2361 } | 2373 } |
| 2362 | 2374 |
| 2363 static RawPtr<CSSPrimitiveValue> consumePerspective(CSSParserTokenRange& range,
CSSParserMode cssParserMode, CSSPropertyID unresolvedProperty) | 2375 static CSSPrimitiveValue* consumePerspective(CSSParserTokenRange& range, CSSPars
erMode cssParserMode, CSSPropertyID unresolvedProperty) |
| 2364 { | 2376 { |
| 2365 if (range.peek().id() == CSSValueNone) | 2377 if (range.peek().id() == CSSValueNone) |
| 2366 return consumeIdent(range); | 2378 return consumeIdent(range); |
| 2367 RawPtr<CSSPrimitiveValue> parsedValue = consumeLength(range, cssParserMode,
ValueRangeAll); | 2379 CSSPrimitiveValue* parsedValue = consumeLength(range, cssParserMode, ValueRa
ngeAll); |
| 2368 if (!parsedValue && (unresolvedProperty == CSSPropertyAliasWebkitPerspective
)) { | 2380 if (!parsedValue && (unresolvedProperty == CSSPropertyAliasWebkitPerspective
)) { |
| 2369 double perspective; | 2381 double perspective; |
| 2370 if (!consumeNumberRaw(range, perspective)) | 2382 if (!consumeNumberRaw(range, perspective)) |
| 2371 return nullptr; | 2383 return nullptr; |
| 2372 parsedValue = cssValuePool().createValue(perspective, CSSPrimitiveValue:
:UnitType::Pixels); | 2384 parsedValue = cssValuePool().createValue(perspective, CSSPrimitiveValue:
:UnitType::Pixels); |
| 2373 } | 2385 } |
| 2374 if (parsedValue && (parsedValue->isCalculated() || parsedValue->getDoubleVal
ue() > 0)) | 2386 if (parsedValue && (parsedValue->isCalculated() || parsedValue->getDoubleVal
ue() > 0)) |
| 2375 return parsedValue.release(); | 2387 return parsedValue; |
| 2376 return nullptr; | 2388 return nullptr; |
| 2377 } | 2389 } |
| 2378 | 2390 |
| 2379 static RawPtr<CSSValueList> consumePositionList(CSSParserTokenRange& range, CSSP
arserMode cssParserMode) | 2391 static CSSValueList* consumePositionList(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) |
| 2380 { | 2392 { |
| 2381 RawPtr<CSSValueList> positions = CSSValueList::createCommaSeparated(); | 2393 CSSValueList* positions = CSSValueList::createCommaSeparated(); |
| 2382 do { | 2394 do { |
| 2383 RawPtr<CSSValue> position = consumePosition(range, cssParserMode, Unitle
ssQuirk::Forbid); | 2395 CSSValue* position = consumePosition(range, cssParserMode, UnitlessQuirk
::Forbid); |
| 2384 if (!position) | 2396 if (!position) |
| 2385 return nullptr; | 2397 return nullptr; |
| 2386 positions->append(position); | 2398 positions->append(position); |
| 2387 } while (consumeCommaIncludingWhitespace(range)); | 2399 } while (consumeCommaIncludingWhitespace(range)); |
| 2388 return positions.release(); | 2400 return positions; |
| 2389 } | 2401 } |
| 2390 | 2402 |
| 2391 static RawPtr<CSSValue> consumeScrollSnapCoordinate(CSSParserTokenRange& range,
CSSParserMode cssParserMode) | 2403 static CSSValue* consumeScrollSnapCoordinate(CSSParserTokenRange& range, CSSPars
erMode cssParserMode) |
| 2392 { | 2404 { |
| 2393 if (range.peek().id() == CSSValueNone) | 2405 if (range.peek().id() == CSSValueNone) |
| 2394 return consumeIdent(range); | 2406 return consumeIdent(range); |
| 2395 return consumePositionList(range, cssParserMode); | 2407 return consumePositionList(range, cssParserMode); |
| 2396 } | 2408 } |
| 2397 | 2409 |
| 2398 static RawPtr<CSSValue> consumeScrollSnapPoints(CSSParserTokenRange& range, CSSP
arserMode cssParserMode) | 2410 static CSSValue* consumeScrollSnapPoints(CSSParserTokenRange& range, CSSParserMo
de cssParserMode) |
| 2399 { | 2411 { |
| 2400 if (range.peek().id() == CSSValueNone) | 2412 if (range.peek().id() == CSSValueNone) |
| 2401 return consumeIdent(range); | 2413 return consumeIdent(range); |
| 2402 if (range.peek().functionId() == CSSValueRepeat) { | 2414 if (range.peek().functionId() == CSSValueRepeat) { |
| 2403 CSSParserTokenRange args = consumeFunction(range); | 2415 CSSParserTokenRange args = consumeFunction(range); |
| 2404 RawPtr<CSSPrimitiveValue> parsedValue = consumeLengthOrPercent(args, css
ParserMode, ValueRangeNonNegative); | 2416 CSSPrimitiveValue* parsedValue = consumeLengthOrPercent(args, cssParserM
ode, ValueRangeNonNegative); |
| 2405 if (args.atEnd() && parsedValue && (parsedValue->isCalculated() || parse
dValue->getDoubleValue() > 0)) { | 2417 if (args.atEnd() && parsedValue && (parsedValue->isCalculated() || parse
dValue->getDoubleValue() > 0)) { |
| 2406 RawPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueR
epeat); | 2418 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueRepeat); |
| 2407 result->append(parsedValue.release()); | 2419 result->append(parsedValue); |
| 2408 return result.release(); | 2420 return result; |
| 2409 } | 2421 } |
| 2410 } | 2422 } |
| 2411 return nullptr; | 2423 return nullptr; |
| 2412 } | 2424 } |
| 2413 | 2425 |
| 2414 static RawPtr<CSSValue> consumeBorderRadiusCorner(CSSParserTokenRange& range, CS
SParserMode cssParserMode) | 2426 static CSSValue* consumeBorderRadiusCorner(CSSParserTokenRange& range, CSSParser
Mode cssParserMode) |
| 2415 { | 2427 { |
| 2416 RawPtr<CSSValue> parsedValue1 = consumeLengthOrPercent(range, cssParserMode,
ValueRangeNonNegative); | 2428 CSSValue* parsedValue1 = consumeLengthOrPercent(range, cssParserMode, ValueR
angeNonNegative); |
| 2417 if (!parsedValue1) | 2429 if (!parsedValue1) |
| 2418 return nullptr; | 2430 return nullptr; |
| 2419 RawPtr<CSSValue> parsedValue2 = consumeLengthOrPercent(range, cssParserMode,
ValueRangeNonNegative); | 2431 CSSValue* parsedValue2 = consumeLengthOrPercent(range, cssParserMode, ValueR
angeNonNegative); |
| 2420 if (!parsedValue2) | 2432 if (!parsedValue2) |
| 2421 parsedValue2 = parsedValue1; | 2433 parsedValue2 = parsedValue1; |
| 2422 return CSSValuePair::create(parsedValue1.release(), parsedValue2.release(),
CSSValuePair::DropIdenticalValues); | 2434 return CSSValuePair::create(parsedValue1, parsedValue2, CSSValuePair::DropId
enticalValues); |
| 2423 } | 2435 } |
| 2424 | 2436 |
| 2425 static RawPtr<CSSPrimitiveValue> consumeVerticalAlign(CSSParserTokenRange& range
, CSSParserMode cssParserMode) | 2437 static CSSPrimitiveValue* consumeVerticalAlign(CSSParserTokenRange& range, CSSPa
rserMode cssParserMode) |
| 2426 { | 2438 { |
| 2427 RawPtr<CSSPrimitiveValue> parsedValue = consumeIdentRange(range, CSSValueBas
eline, CSSValueWebkitBaselineMiddle); | 2439 CSSPrimitiveValue* parsedValue = consumeIdentRange(range, CSSValueBaseline,
CSSValueWebkitBaselineMiddle); |
| 2428 if (!parsedValue) | 2440 if (!parsedValue) |
| 2429 parsedValue = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll
, UnitlessQuirk::Allow); | 2441 parsedValue = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll
, UnitlessQuirk::Allow); |
| 2430 return parsedValue.release(); | 2442 return parsedValue; |
| 2431 } | 2443 } |
| 2432 | 2444 |
| 2433 static RawPtr<CSSPrimitiveValue> consumeShapeRadius(CSSParserTokenRange& args, C
SSParserMode cssParserMode) | 2445 static CSSPrimitiveValue* consumeShapeRadius(CSSParserTokenRange& args, CSSParse
rMode cssParserMode) |
| 2434 { | 2446 { |
| 2435 if (identMatches<CSSValueClosestSide, CSSValueFarthestSide>(args.peek().id()
)) | 2447 if (identMatches<CSSValueClosestSide, CSSValueFarthestSide>(args.peek().id()
)) |
| 2436 return consumeIdent(args); | 2448 return consumeIdent(args); |
| 2437 return consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative); | 2449 return consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative); |
| 2438 } | 2450 } |
| 2439 | 2451 |
| 2440 static RawPtr<CSSBasicShapeCircleValue> consumeBasicShapeCircle(CSSParserTokenRa
nge& args, const CSSParserContext& context) | 2452 static CSSBasicShapeCircleValue* consumeBasicShapeCircle(CSSParserTokenRange& ar
gs, const CSSParserContext& context) |
| 2441 { | 2453 { |
| 2442 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes | 2454 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes |
| 2443 // circle( [<shape-radius>]? [at <position>]? ) | 2455 // circle( [<shape-radius>]? [at <position>]? ) |
| 2444 RawPtr<CSSBasicShapeCircleValue> shape = CSSBasicShapeCircleValue::create(); | 2456 CSSBasicShapeCircleValue* shape = CSSBasicShapeCircleValue::create(); |
| 2445 if (RawPtr<CSSPrimitiveValue> radius = consumeShapeRadius(args, context.mode
())) | 2457 if (CSSPrimitiveValue* radius = consumeShapeRadius(args, context.mode())) |
| 2446 shape->setRadius(radius.release()); | 2458 shape->setRadius(radius); |
| 2447 if (consumeIdent<CSSValueAt>(args)) { | 2459 if (consumeIdent<CSSValueAt>(args)) { |
| 2448 RawPtr<CSSValue> centerX = nullptr; | 2460 CSSValue* centerX = nullptr; |
| 2449 RawPtr<CSSValue> centerY = nullptr; | 2461 CSSValue* centerY = nullptr; |
| 2450 if (!consumePosition(args, context.mode(), UnitlessQuirk::Forbid, center
X, centerY)) | 2462 if (!consumePosition(args, context.mode(), UnitlessQuirk::Forbid, center
X, centerY)) |
| 2451 return nullptr; | 2463 return nullptr; |
| 2452 shape->setCenterX(centerX); | 2464 shape->setCenterX(centerX); |
| 2453 shape->setCenterY(centerY); | 2465 shape->setCenterY(centerY); |
| 2454 } | 2466 } |
| 2455 return shape.release(); | 2467 return shape; |
| 2456 } | 2468 } |
| 2457 | 2469 |
| 2458 static RawPtr<CSSBasicShapeEllipseValue> consumeBasicShapeEllipse(CSSParserToken
Range& args, const CSSParserContext& context) | 2470 static CSSBasicShapeEllipseValue* consumeBasicShapeEllipse(CSSParserTokenRange&
args, const CSSParserContext& context) |
| 2459 { | 2471 { |
| 2460 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes | 2472 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes |
| 2461 // ellipse( [<shape-radius>{2}]? [at <position>]? ) | 2473 // ellipse( [<shape-radius>{2}]? [at <position>]? ) |
| 2462 RawPtr<CSSBasicShapeEllipseValue> shape = CSSBasicShapeEllipseValue::create(
); | 2474 CSSBasicShapeEllipseValue* shape = CSSBasicShapeEllipseValue::create(); |
| 2463 if (RawPtr<CSSPrimitiveValue> radiusX = consumeShapeRadius(args, context.mod
e())) { | 2475 if (CSSPrimitiveValue* radiusX = consumeShapeRadius(args, context.mode())) { |
| 2464 shape->setRadiusX(radiusX); | 2476 shape->setRadiusX(radiusX); |
| 2465 if (RawPtr<CSSPrimitiveValue> radiusY = consumeShapeRadius(args, context
.mode())) | 2477 if (CSSPrimitiveValue* radiusY = consumeShapeRadius(args, context.mode()
)) |
| 2466 shape->setRadiusY(radiusY); | 2478 shape->setRadiusY(radiusY); |
| 2467 } | 2479 } |
| 2468 if (consumeIdent<CSSValueAt>(args)) { | 2480 if (consumeIdent<CSSValueAt>(args)) { |
| 2469 RawPtr<CSSValue> centerX = nullptr; | 2481 CSSValue* centerX = nullptr; |
| 2470 RawPtr<CSSValue> centerY = nullptr; | 2482 CSSValue* centerY = nullptr; |
| 2471 if (!consumePosition(args, context.mode(), UnitlessQuirk::Forbid, center
X, centerY)) | 2483 if (!consumePosition(args, context.mode(), UnitlessQuirk::Forbid, center
X, centerY)) |
| 2472 return nullptr; | 2484 return nullptr; |
| 2473 shape->setCenterX(centerX); | 2485 shape->setCenterX(centerX); |
| 2474 shape->setCenterY(centerY); | 2486 shape->setCenterY(centerY); |
| 2475 } | 2487 } |
| 2476 return shape.release(); | 2488 return shape; |
| 2477 } | 2489 } |
| 2478 | 2490 |
| 2479 static RawPtr<CSSBasicShapePolygonValue> consumeBasicShapePolygon(CSSParserToken
Range& args, const CSSParserContext& context) | 2491 static CSSBasicShapePolygonValue* consumeBasicShapePolygon(CSSParserTokenRange&
args, const CSSParserContext& context) |
| 2480 { | 2492 { |
| 2481 RawPtr<CSSBasicShapePolygonValue> shape = CSSBasicShapePolygonValue::create(
); | 2493 CSSBasicShapePolygonValue* shape = CSSBasicShapePolygonValue::create(); |
| 2482 if (identMatches<CSSValueEvenodd, CSSValueNonzero>(args.peek().id())) { | 2494 if (identMatches<CSSValueEvenodd, CSSValueNonzero>(args.peek().id())) { |
| 2483 shape->setWindRule(args.consumeIncludingWhitespace().id() == CSSValueEve
nodd ? RULE_EVENODD : RULE_NONZERO); | 2495 shape->setWindRule(args.consumeIncludingWhitespace().id() == CSSValueEve
nodd ? RULE_EVENODD : RULE_NONZERO); |
| 2484 if (!consumeCommaIncludingWhitespace(args)) | 2496 if (!consumeCommaIncludingWhitespace(args)) |
| 2485 return nullptr; | 2497 return nullptr; |
| 2486 } | 2498 } |
| 2487 | 2499 |
| 2488 do { | 2500 do { |
| 2489 RawPtr<CSSPrimitiveValue> xLength = consumeLengthOrPercent(args, context
.mode(), ValueRangeAll); | 2501 CSSPrimitiveValue* xLength = consumeLengthOrPercent(args, context.mode()
, ValueRangeAll); |
| 2490 if (!xLength) | 2502 if (!xLength) |
| 2491 return nullptr; | 2503 return nullptr; |
| 2492 RawPtr<CSSPrimitiveValue> yLength = consumeLengthOrPercent(args, context
.mode(), ValueRangeAll); | 2504 CSSPrimitiveValue* yLength = consumeLengthOrPercent(args, context.mode()
, ValueRangeAll); |
| 2493 if (!yLength) | 2505 if (!yLength) |
| 2494 return nullptr; | 2506 return nullptr; |
| 2495 shape->appendPoint(xLength.release(), yLength.release()); | 2507 shape->appendPoint(xLength, yLength); |
| 2496 } while (consumeCommaIncludingWhitespace(args)); | 2508 } while (consumeCommaIncludingWhitespace(args)); |
| 2497 return shape.release(); | 2509 return shape; |
| 2498 } | 2510 } |
| 2499 | 2511 |
| 2500 static void complete4Sides(RawPtr<CSSPrimitiveValue> side[4]) | 2512 static void complete4Sides(CSSPrimitiveValue* side[4]) |
| 2501 { | 2513 { |
| 2502 if (side[3]) | 2514 if (side[3]) |
| 2503 return; | 2515 return; |
| 2504 if (!side[2]) { | 2516 if (!side[2]) { |
| 2505 if (!side[1]) | 2517 if (!side[1]) |
| 2506 side[1] = side[0]; | 2518 side[1] = side[0]; |
| 2507 side[2] = side[0]; | 2519 side[2] = side[0]; |
| 2508 } | 2520 } |
| 2509 side[3] = side[1]; | 2521 side[3] = side[1]; |
| 2510 } | 2522 } |
| 2511 | 2523 |
| 2512 static bool consumeRadii(RawPtr<CSSPrimitiveValue> horizontalRadii[4], RawPtr<CS
SPrimitiveValue> verticalRadii[4], CSSParserTokenRange& range, CSSParserMode css
ParserMode, bool useLegacyParsing) | 2524 static bool consumeRadii(CSSPrimitiveValue* horizontalRadii[4], CSSPrimitiveValu
e* verticalRadii[4], CSSParserTokenRange& range, CSSParserMode cssParserMode, bo
ol useLegacyParsing) |
| 2513 { | 2525 { |
| 2514 #if ENABLE(OILPAN) | 2526 #if ENABLE(OILPAN) |
| 2515 // Unconditionally zero initialize the arrays of raw pointers. | 2527 // Unconditionally zero initialize the arrays of raw pointers. |
| 2516 memset(horizontalRadii, 0, 4 * sizeof(horizontalRadii[0])); | 2528 memset(horizontalRadii, 0, 4 * sizeof(horizontalRadii[0])); |
| 2517 memset(verticalRadii, 0, 4 * sizeof(verticalRadii[0])); | 2529 memset(verticalRadii, 0, 4 * sizeof(verticalRadii[0])); |
| 2518 #endif | 2530 #endif |
| 2519 unsigned i = 0; | 2531 unsigned i = 0; |
| 2520 for (; i < 4 && !range.atEnd() && range.peek().type() != DelimiterToken; ++i
) { | 2532 for (; i < 4 && !range.atEnd() && range.peek().type() != DelimiterToken; ++i
) { |
| 2521 horizontalRadii[i] = consumeLengthOrPercent(range, cssParserMode, ValueR
angeNonNegative); | 2533 horizontalRadii[i] = consumeLengthOrPercent(range, cssParserMode, ValueR
angeNonNegative); |
| 2522 if (!horizontalRadii[i]) | 2534 if (!horizontalRadii[i]) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2544 return false; | 2556 return false; |
| 2545 } | 2557 } |
| 2546 if (!verticalRadii[0] || !range.atEnd()) | 2558 if (!verticalRadii[0] || !range.atEnd()) |
| 2547 return false; | 2559 return false; |
| 2548 } | 2560 } |
| 2549 complete4Sides(horizontalRadii); | 2561 complete4Sides(horizontalRadii); |
| 2550 complete4Sides(verticalRadii); | 2562 complete4Sides(verticalRadii); |
| 2551 return true; | 2563 return true; |
| 2552 } | 2564 } |
| 2553 | 2565 |
| 2554 static RawPtr<CSSBasicShapeInsetValue> consumeBasicShapeInset(CSSParserTokenRang
e& args, const CSSParserContext& context) | 2566 static CSSBasicShapeInsetValue* consumeBasicShapeInset(CSSParserTokenRange& args
, const CSSParserContext& context) |
| 2555 { | 2567 { |
| 2556 RawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue::create(); | 2568 CSSBasicShapeInsetValue* shape = CSSBasicShapeInsetValue::create(); |
| 2557 RawPtr<CSSPrimitiveValue> top = consumeLengthOrPercent(args, context.mode(),
ValueRangeAll); | 2569 CSSPrimitiveValue* top = consumeLengthOrPercent(args, context.mode(), ValueR
angeAll); |
| 2558 if (!top) | 2570 if (!top) |
| 2559 return nullptr; | 2571 return nullptr; |
| 2560 RawPtr<CSSPrimitiveValue> right = nullptr; | 2572 CSSPrimitiveValue* right = consumeLengthOrPercent(args, context.mode(), Valu
eRangeAll); |
| 2561 RawPtr<CSSPrimitiveValue> bottom = nullptr; | 2573 CSSPrimitiveValue* bottom = nullptr; |
| 2562 RawPtr<CSSPrimitiveValue> left = nullptr; | 2574 CSSPrimitiveValue* left = nullptr; |
| 2563 if ((right = consumeLengthOrPercent(args, context.mode(), ValueRangeAll))) { | 2575 if (right) { |
| 2564 if ((bottom = consumeLengthOrPercent(args, context.mode(), ValueRangeAll
))) | 2576 bottom = consumeLengthOrPercent(args, context.mode(), ValueRangeAll); |
| 2577 if (bottom) |
| 2565 left = consumeLengthOrPercent(args, context.mode(), ValueRangeAll); | 2578 left = consumeLengthOrPercent(args, context.mode(), ValueRangeAll); |
| 2566 } | 2579 } |
| 2567 if (left) | 2580 if (left) |
| 2568 shape->updateShapeSize4Values(top.get(), right.get(), bottom.get(), left
.get()); | 2581 shape->updateShapeSize4Values(top, right, bottom, left); |
| 2569 else if (bottom) | 2582 else if (bottom) |
| 2570 shape->updateShapeSize3Values(top.get(), right.get(), bottom.get()); | 2583 shape->updateShapeSize3Values(top, right, bottom); |
| 2571 else if (right) | 2584 else if (right) |
| 2572 shape->updateShapeSize2Values(top.get(), right.get()); | 2585 shape->updateShapeSize2Values(top, right); |
| 2573 else | 2586 else |
| 2574 shape->updateShapeSize1Value(top.get()); | 2587 shape->updateShapeSize1Value(top); |
| 2575 | 2588 |
| 2576 if (consumeIdent<CSSValueRound>(args)) { | 2589 if (consumeIdent<CSSValueRound>(args)) { |
| 2577 RawPtr<CSSPrimitiveValue> horizontalRadii[4]; | 2590 CSSPrimitiveValue* horizontalRadii[4]; |
| 2578 RawPtr<CSSPrimitiveValue> verticalRadii[4]; | 2591 CSSPrimitiveValue* verticalRadii[4]; |
| 2579 if (!consumeRadii(horizontalRadii, verticalRadii, args, context.mode(),
false)) | 2592 if (!consumeRadii(horizontalRadii, verticalRadii, args, context.mode(),
false)) |
| 2580 return nullptr; | 2593 return nullptr; |
| 2581 shape->setTopLeftRadius(CSSValuePair::create(horizontalRadii[0].release(
), verticalRadii[0].release(), CSSValuePair::DropIdenticalValues)); | 2594 shape->setTopLeftRadius(CSSValuePair::create(horizontalRadii[0], vertica
lRadii[0], CSSValuePair::DropIdenticalValues)); |
| 2582 shape->setTopRightRadius(CSSValuePair::create(horizontalRadii[1].release
(), verticalRadii[1].release(), CSSValuePair::DropIdenticalValues)); | 2595 shape->setTopRightRadius(CSSValuePair::create(horizontalRadii[1], vertic
alRadii[1], CSSValuePair::DropIdenticalValues)); |
| 2583 shape->setBottomRightRadius(CSSValuePair::create(horizontalRadii[2].rele
ase(), verticalRadii[2].release(), CSSValuePair::DropIdenticalValues)); | 2596 shape->setBottomRightRadius(CSSValuePair::create(horizontalRadii[2], ver
ticalRadii[2], CSSValuePair::DropIdenticalValues)); |
| 2584 shape->setBottomLeftRadius(CSSValuePair::create(horizontalRadii[3].relea
se(), verticalRadii[3].release(), CSSValuePair::DropIdenticalValues)); | 2597 shape->setBottomLeftRadius(CSSValuePair::create(horizontalRadii[3], vert
icalRadii[3], CSSValuePair::DropIdenticalValues)); |
| 2585 } | 2598 } |
| 2586 return shape.release(); | 2599 return shape; |
| 2587 } | 2600 } |
| 2588 | 2601 |
| 2589 static RawPtr<CSSValue> consumeBasicShape(CSSParserTokenRange& range, const CSSP
arserContext& context) | 2602 static CSSValue* consumeBasicShape(CSSParserTokenRange& range, const CSSParserCo
ntext& context) |
| 2590 { | 2603 { |
| 2591 RawPtr<CSSValue> shape = nullptr; | 2604 CSSValue* shape = nullptr; |
| 2592 if (range.peek().type() != FunctionToken) | 2605 if (range.peek().type() != FunctionToken) |
| 2593 return nullptr; | 2606 return nullptr; |
| 2594 CSSValueID id = range.peek().functionId(); | 2607 CSSValueID id = range.peek().functionId(); |
| 2595 CSSParserTokenRange rangeCopy = range; | 2608 CSSParserTokenRange rangeCopy = range; |
| 2596 CSSParserTokenRange args = consumeFunction(rangeCopy); | 2609 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 2597 if (id == CSSValueCircle) | 2610 if (id == CSSValueCircle) |
| 2598 shape = consumeBasicShapeCircle(args, context); | 2611 shape = consumeBasicShapeCircle(args, context); |
| 2599 else if (id == CSSValueEllipse) | 2612 else if (id == CSSValueEllipse) |
| 2600 shape = consumeBasicShapeEllipse(args, context); | 2613 shape = consumeBasicShapeEllipse(args, context); |
| 2601 else if (id == CSSValuePolygon) | 2614 else if (id == CSSValuePolygon) |
| 2602 shape = consumeBasicShapePolygon(args, context); | 2615 shape = consumeBasicShapePolygon(args, context); |
| 2603 else if (id == CSSValueInset) | 2616 else if (id == CSSValueInset) |
| 2604 shape = consumeBasicShapeInset(args, context); | 2617 shape = consumeBasicShapeInset(args, context); |
| 2605 if (!shape || !args.atEnd()) | 2618 if (!shape || !args.atEnd()) |
| 2606 return nullptr; | 2619 return nullptr; |
| 2607 range = rangeCopy; | 2620 range = rangeCopy; |
| 2608 return shape.release(); | 2621 return shape; |
| 2609 } | 2622 } |
| 2610 | 2623 |
| 2611 static RawPtr<CSSValue> consumeClipPath(CSSParserTokenRange& range, const CSSPar
serContext& context) | 2624 static CSSValue* consumeClipPath(CSSParserTokenRange& range, const CSSParserCont
ext& context) |
| 2612 { | 2625 { |
| 2613 if (range.peek().id() == CSSValueNone) | 2626 if (range.peek().id() == CSSValueNone) |
| 2614 return consumeIdent(range); | 2627 return consumeIdent(range); |
| 2615 String url = consumeUrl(range); | 2628 String url = consumeUrl(range); |
| 2616 if (!url.isNull()) | 2629 if (!url.isNull()) |
| 2617 return CSSURIValue::create(url); | 2630 return CSSURIValue::create(url); |
| 2618 return consumeBasicShape(range, context); | 2631 return consumeBasicShape(range, context); |
| 2619 } | 2632 } |
| 2620 | 2633 |
| 2621 static RawPtr<CSSValue> consumeShapeOutside(CSSParserTokenRange& range, const CS
SParserContext& context) | 2634 static CSSValue* consumeShapeOutside(CSSParserTokenRange& range, const CSSParser
Context& context) |
| 2622 { | 2635 { |
| 2623 if (RawPtr<CSSValue> imageValue = consumeImageOrNone(range, context)) | 2636 if (CSSValue* imageValue = consumeImageOrNone(range, context)) |
| 2624 return imageValue.release(); | 2637 return imageValue; |
| 2625 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); | 2638 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 2626 if (RawPtr<CSSValue> boxValue = consumeIdent<CSSValueContentBox, CSSValuePad
dingBox, CSSValueBorderBox, CSSValueMarginBox>(range)) | 2639 if (CSSValue* boxValue = consumeIdent<CSSValueContentBox, CSSValuePaddingBox
, CSSValueBorderBox, CSSValueMarginBox>(range)) |
| 2627 list->append(boxValue.release()); | 2640 list->append(boxValue); |
| 2628 if (RawPtr<CSSValue> shapeValue = consumeBasicShape(range, context)) { | 2641 if (CSSValue* shapeValue = consumeBasicShape(range, context)) { |
| 2629 list->append(shapeValue.release()); | 2642 list->append(shapeValue); |
| 2630 if (list->length() < 2) { | 2643 if (list->length() < 2) { |
| 2631 if (RawPtr<CSSValue> boxValue = consumeIdent<CSSValueContentBox, CSS
ValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range)) | 2644 if (CSSValue* boxValue = consumeIdent<CSSValueContentBox, CSSValuePa
ddingBox, CSSValueBorderBox, CSSValueMarginBox>(range)) |
| 2632 list->append(boxValue.release()); | 2645 list->append(boxValue); |
| 2633 } | 2646 } |
| 2634 } | 2647 } |
| 2635 if (!list->length()) | 2648 if (!list->length()) |
| 2636 return nullptr; | 2649 return nullptr; |
| 2637 return list.release(); | 2650 return list; |
| 2638 } | 2651 } |
| 2639 | 2652 |
| 2640 static RawPtr<CSSValue> consumeContentDistributionOverflowPosition(CSSParserToke
nRange& range) | 2653 static CSSValue* consumeContentDistributionOverflowPosition(CSSParserTokenRange&
range) |
| 2641 { | 2654 { |
| 2642 if (identMatches<CSSValueNormal, CSSValueBaseline, CSSValueLastBaseline>(ran
ge.peek().id())) | 2655 if (identMatches<CSSValueNormal, CSSValueBaseline, CSSValueLastBaseline>(ran
ge.peek().id())) |
| 2643 return CSSContentDistributionValue::create(CSSValueInvalid, range.consum
eIncludingWhitespace().id(), CSSValueInvalid); | 2656 return CSSContentDistributionValue::create(CSSValueInvalid, range.consum
eIncludingWhitespace().id(), CSSValueInvalid); |
| 2644 | 2657 |
| 2645 CSSValueID distribution = CSSValueInvalid; | 2658 CSSValueID distribution = CSSValueInvalid; |
| 2646 CSSValueID position = CSSValueInvalid; | 2659 CSSValueID position = CSSValueInvalid; |
| 2647 CSSValueID overflow = CSSValueInvalid; | 2660 CSSValueID overflow = CSSValueInvalid; |
| 2648 do { | 2661 do { |
| 2649 CSSValueID id = range.peek().id(); | 2662 CSSValueID id = range.peek().id(); |
| 2650 if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpac
eEvenly, CSSValueStretch>(id)) { | 2663 if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpac
eEvenly, CSSValueStretch>(id)) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2669 if (position == CSSValueInvalid && distribution == CSSValueInvalid) | 2682 if (position == CSSValueInvalid && distribution == CSSValueInvalid) |
| 2670 return nullptr; | 2683 return nullptr; |
| 2671 | 2684 |
| 2672 // The grammar states that <overflow-position> must be associated to <conten
t-position>. | 2685 // The grammar states that <overflow-position> must be associated to <conten
t-position>. |
| 2673 if (overflow != CSSValueInvalid && position == CSSValueInvalid) | 2686 if (overflow != CSSValueInvalid && position == CSSValueInvalid) |
| 2674 return nullptr; | 2687 return nullptr; |
| 2675 | 2688 |
| 2676 return CSSContentDistributionValue::create(distribution, position, overflow)
; | 2689 return CSSContentDistributionValue::create(distribution, position, overflow)
; |
| 2677 } | 2690 } |
| 2678 | 2691 |
| 2679 static RawPtr<CSSPrimitiveValue> consumeBorderImageRepeatKeyword(CSSParserTokenR
ange& range) | 2692 static CSSPrimitiveValue* consumeBorderImageRepeatKeyword(CSSParserTokenRange& r
ange) |
| 2680 { | 2693 { |
| 2681 return consumeIdent<CSSValueStretch, CSSValueRepeat, CSSValueSpace, CSSValue
Round>(range); | 2694 return consumeIdent<CSSValueStretch, CSSValueRepeat, CSSValueSpace, CSSValue
Round>(range); |
| 2682 } | 2695 } |
| 2683 | 2696 |
| 2684 static RawPtr<CSSValue> consumeBorderImageRepeat(CSSParserTokenRange& range) | 2697 static CSSValue* consumeBorderImageRepeat(CSSParserTokenRange& range) |
| 2685 { | 2698 { |
| 2686 RawPtr<CSSPrimitiveValue> horizontal = consumeBorderImageRepeatKeyword(range
); | 2699 CSSPrimitiveValue* horizontal = consumeBorderImageRepeatKeyword(range); |
| 2687 if (!horizontal) | 2700 if (!horizontal) |
| 2688 return nullptr; | 2701 return nullptr; |
| 2689 RawPtr<CSSPrimitiveValue> vertical = consumeBorderImageRepeatKeyword(range); | 2702 CSSPrimitiveValue* vertical = consumeBorderImageRepeatKeyword(range); |
| 2690 if (!vertical) | 2703 if (!vertical) |
| 2691 vertical = horizontal; | 2704 vertical = horizontal; |
| 2692 return CSSValuePair::create(horizontal.release(), vertical.release(), CSSVal
uePair::DropIdenticalValues); | 2705 return CSSValuePair::create(horizontal, vertical, CSSValuePair::DropIdentica
lValues); |
| 2693 } | 2706 } |
| 2694 | 2707 |
| 2695 static RawPtr<CSSValue> consumeBorderImageSlice(CSSPropertyID property, CSSParse
rTokenRange& range, CSSParserMode cssParserMode) | 2708 static CSSValue* consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenR
ange& range, CSSParserMode cssParserMode) |
| 2696 { | 2709 { |
| 2697 bool fill = consumeIdent<CSSValueFill>(range); | 2710 bool fill = consumeIdent<CSSValueFill>(range); |
| 2698 RawPtr<CSSPrimitiveValue> slices[4]; | 2711 CSSPrimitiveValue* slices[4]; |
| 2699 #if ENABLE(OILPAN) | 2712 #if ENABLE(OILPAN) |
| 2700 // Unconditionally zero initialize the arrays of raw pointers. | 2713 // Unconditionally zero initialize the arrays of raw pointers. |
| 2701 memset(slices, 0, 4 * sizeof(slices[0])); | 2714 memset(slices, 0, 4 * sizeof(slices[0])); |
| 2702 #endif | 2715 #endif |
| 2703 for (size_t index = 0; index < 4; ++index) { | 2716 for (size_t index = 0; index < 4; ++index) { |
| 2704 RawPtr<CSSPrimitiveValue> value = consumePercent(range, ValueRangeNonNeg
ative); | 2717 CSSPrimitiveValue* value = consumePercent(range, ValueRangeNonNegative); |
| 2705 if (!value) | 2718 if (!value) |
| 2706 value = consumeNumber(range, ValueRangeNonNegative); | 2719 value = consumeNumber(range, ValueRangeNonNegative); |
| 2707 if (!value) | 2720 if (!value) |
| 2708 break; | 2721 break; |
| 2709 slices[index] = value; | 2722 slices[index] = value; |
| 2710 } | 2723 } |
| 2711 if (!slices[0]) | 2724 if (!slices[0]) |
| 2712 return nullptr; | 2725 return nullptr; |
| 2713 if (consumeIdent<CSSValueFill>(range)) { | 2726 if (consumeIdent<CSSValueFill>(range)) { |
| 2714 if (fill) | 2727 if (fill) |
| 2715 return nullptr; | 2728 return nullptr; |
| 2716 fill = true; | 2729 fill = true; |
| 2717 } | 2730 } |
| 2718 complete4Sides(slices); | 2731 complete4Sides(slices); |
| 2719 // FIXME: For backwards compatibility, -webkit-border-image, -webkit-mask-bo
x-image and -webkit-box-reflect have to do a fill by default. | 2732 // FIXME: For backwards compatibility, -webkit-border-image, -webkit-mask-bo
x-image and -webkit-box-reflect have to do a fill by default. |
| 2720 // FIXME: What do we do with -webkit-box-reflect and -webkit-mask-box-image?
Probably just have to leave them filling... | 2733 // FIXME: What do we do with -webkit-box-reflect and -webkit-mask-box-image?
Probably just have to leave them filling... |
| 2721 if (property == CSSPropertyWebkitBorderImage || property == CSSPropertyWebki
tMaskBoxImage || property == CSSPropertyWebkitBoxReflect) | 2734 if (property == CSSPropertyWebkitBorderImage || property == CSSPropertyWebki
tMaskBoxImage || property == CSSPropertyWebkitBoxReflect) |
| 2722 fill = true; | 2735 fill = true; |
| 2723 return CSSBorderImageSliceValue::create(CSSQuadValue::create(slices[0].relea
se(), slices[1].release(), slices[2].release(), slices[3].release(), CSSQuadValu
e::SerializeAsQuad), fill); | 2736 return CSSBorderImageSliceValue::create(CSSQuadValue::create(slices[0], slic
es[1], slices[2], slices[3], CSSQuadValue::SerializeAsQuad), fill); |
| 2724 } | 2737 } |
| 2725 | 2738 |
| 2726 static RawPtr<CSSValue> consumeBorderImageOutset(CSSParserTokenRange& range) | 2739 static CSSValue* consumeBorderImageOutset(CSSParserTokenRange& range) |
| 2727 { | 2740 { |
| 2728 RawPtr<CSSPrimitiveValue> outsets[4]; | 2741 CSSPrimitiveValue* outsets[4]; |
| 2729 #if ENABLE(OILPAN) | 2742 #if ENABLE(OILPAN) |
| 2730 // Unconditionally zero initialize the arrays of raw pointers. | 2743 // Unconditionally zero initialize the arrays of raw pointers. |
| 2731 memset(outsets, 0, 4 * sizeof(outsets[0])); | 2744 memset(outsets, 0, 4 * sizeof(outsets[0])); |
| 2732 #endif | 2745 #endif |
| 2733 RawPtr<CSSPrimitiveValue> value = nullptr; | 2746 CSSPrimitiveValue* value = nullptr; |
| 2734 for (size_t index = 0; index < 4; ++index) { | 2747 for (size_t index = 0; index < 4; ++index) { |
| 2735 value = consumeNumber(range, ValueRangeNonNegative); | 2748 value = consumeNumber(range, ValueRangeNonNegative); |
| 2736 if (!value) | 2749 if (!value) |
| 2737 value = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative
); | 2750 value = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative
); |
| 2738 if (!value) | 2751 if (!value) |
| 2739 break; | 2752 break; |
| 2740 outsets[index] = value; | 2753 outsets[index] = value; |
| 2741 } | 2754 } |
| 2742 if (!outsets[0]) | 2755 if (!outsets[0]) |
| 2743 return nullptr; | 2756 return nullptr; |
| 2744 complete4Sides(outsets); | 2757 complete4Sides(outsets); |
| 2745 return CSSQuadValue::create(outsets[0].release(), outsets[1].release(), outs
ets[2].release(), outsets[3].release(), CSSQuadValue::SerializeAsQuad); | 2758 return CSSQuadValue::create(outsets[0], outsets[1], outsets[2], outsets[3],
CSSQuadValue::SerializeAsQuad); |
| 2746 } | 2759 } |
| 2747 | 2760 |
| 2748 static RawPtr<CSSValue> consumeBorderImageWidth(CSSParserTokenRange& range) | 2761 static CSSValue* consumeBorderImageWidth(CSSParserTokenRange& range) |
| 2749 { | 2762 { |
| 2750 RawPtr<CSSPrimitiveValue> widths[4]; | 2763 CSSPrimitiveValue* widths[4]; |
| 2751 #if ENABLE(OILPAN) | 2764 #if ENABLE(OILPAN) |
| 2752 // Unconditionally zero initialize the arrays of raw pointers. | 2765 // Unconditionally zero initialize the arrays of raw pointers. |
| 2753 memset(widths, 0, 4 * sizeof(widths[0])); | 2766 memset(widths, 0, 4 * sizeof(widths[0])); |
| 2754 #endif | 2767 #endif |
| 2755 RawPtr<CSSPrimitiveValue> value = nullptr; | 2768 CSSPrimitiveValue* value = nullptr; |
| 2756 for (size_t index = 0; index < 4; ++index) { | 2769 for (size_t index = 0; index < 4; ++index) { |
| 2757 value = consumeNumber(range, ValueRangeNonNegative); | 2770 value = consumeNumber(range, ValueRangeNonNegative); |
| 2758 if (!value) | 2771 if (!value) |
| 2759 value = consumeLengthOrPercent(range, HTMLStandardMode, ValueRangeNo
nNegative, UnitlessQuirk::Forbid); | 2772 value = consumeLengthOrPercent(range, HTMLStandardMode, ValueRangeNo
nNegative, UnitlessQuirk::Forbid); |
| 2760 if (!value) | 2773 if (!value) |
| 2761 value = consumeIdent<CSSValueAuto>(range); | 2774 value = consumeIdent<CSSValueAuto>(range); |
| 2762 if (!value) | 2775 if (!value) |
| 2763 break; | 2776 break; |
| 2764 widths[index] = value; | 2777 widths[index] = value; |
| 2765 } | 2778 } |
| 2766 if (!widths[0]) | 2779 if (!widths[0]) |
| 2767 return nullptr; | 2780 return nullptr; |
| 2768 complete4Sides(widths); | 2781 complete4Sides(widths); |
| 2769 return CSSQuadValue::create(widths[0].release(), widths[1].release(), widths
[2].release(), widths[3].release(), CSSQuadValue::SerializeAsQuad); | 2782 return CSSQuadValue::create(widths[0], widths[1], widths[2], widths[3], CSSQ
uadValue::SerializeAsQuad); |
| 2770 } | 2783 } |
| 2771 | 2784 |
| 2772 static bool consumeBorderImageComponents(CSSPropertyID property, CSSParserTokenR
ange& range, const CSSParserContext& context, RawPtr<CSSValue>& source, | 2785 static bool consumeBorderImageComponents(CSSPropertyID property, CSSParserTokenR
ange& range, const CSSParserContext& context, CSSValue*& source, |
| 2773 RawPtr<CSSValue>& slice, RawPtr<CSSValue>& width, RawPtr<CSSValue>& outset,
RawPtr<CSSValue>& repeat) | 2786 CSSValue*& slice, CSSValue*& width, CSSValue*& outset, CSSValue*& repeat) |
| 2774 { | 2787 { |
| 2775 do { | 2788 do { |
| 2776 if (!source && (source = consumeImageOrNone(range, context))) | 2789 if (!source) { |
| 2777 continue; | 2790 source = consumeImageOrNone(range, context); |
| 2778 if (!repeat && (repeat = consumeBorderImageRepeat(range))) | 2791 if (source) |
| 2779 continue; | 2792 continue; |
| 2780 if (!slice && (slice = consumeBorderImageSlice(property, range, context.
mode()))) { | 2793 } |
| 2781 ASSERT(!width && !outset); | 2794 if (!repeat) { |
| 2782 if (consumeSlashIncludingWhitespace(range)) { | 2795 repeat = consumeBorderImageRepeat(range); |
| 2783 width = consumeBorderImageWidth(range); | 2796 if (repeat) |
| 2797 continue; |
| 2798 } |
| 2799 if (!slice) { |
| 2800 slice = consumeBorderImageSlice(property, range, context.mode()); |
| 2801 if (slice) { |
| 2802 ASSERT(!width && !outset); |
| 2784 if (consumeSlashIncludingWhitespace(range)) { | 2803 if (consumeSlashIncludingWhitespace(range)) { |
| 2785 outset = consumeBorderImageOutset(range); | 2804 width = consumeBorderImageWidth(range); |
| 2786 if (!outset) | 2805 if (consumeSlashIncludingWhitespace(range)) { |
| 2806 outset = consumeBorderImageOutset(range); |
| 2807 if (!outset) |
| 2808 return false; |
| 2809 } else if (!width) { |
| 2787 return false; | 2810 return false; |
| 2788 } else if (!width) { | 2811 } |
| 2789 return false; | |
| 2790 } | 2812 } |
| 2813 } else { |
| 2814 return false; |
| 2791 } | 2815 } |
| 2792 } else { | 2816 } else { |
| 2793 return false; | 2817 return false; |
| 2794 } | 2818 } |
| 2795 } while (!range.atEnd()); | 2819 } while (!range.atEnd()); |
| 2796 return true; | 2820 return true; |
| 2797 } | 2821 } |
| 2798 | 2822 |
| 2799 static RawPtr<CSSValue> consumeWebkitBorderImage(CSSPropertyID property, CSSPars
erTokenRange& range, const CSSParserContext& context) | 2823 static CSSValue* consumeWebkitBorderImage(CSSPropertyID property, CSSParserToken
Range& range, const CSSParserContext& context) |
| 2800 { | 2824 { |
| 2801 RawPtr<CSSValue> source = nullptr; | 2825 CSSValue* source = nullptr; |
| 2802 RawPtr<CSSValue> slice = nullptr; | 2826 CSSValue* slice = nullptr; |
| 2803 RawPtr<CSSValue> width = nullptr; | 2827 CSSValue* width = nullptr; |
| 2804 RawPtr<CSSValue> outset = nullptr; | 2828 CSSValue* outset = nullptr; |
| 2805 RawPtr<CSSValue> repeat = nullptr; | 2829 CSSValue* repeat = nullptr; |
| 2806 if (consumeBorderImageComponents(property, range, context, source, slice, wi
dth, outset, repeat)) | 2830 if (consumeBorderImageComponents(property, range, context, source, slice, wi
dth, outset, repeat)) |
| 2807 return createBorderImageValue(source, slice, width, outset, repeat); | 2831 return createBorderImageValue(source, slice, width, outset, repeat); |
| 2808 return nullptr; | 2832 return nullptr; |
| 2809 } | 2833 } |
| 2810 | 2834 |
| 2811 static RawPtr<CSSValue> consumeReflect(CSSParserTokenRange& range, const CSSPars
erContext& context) | 2835 static CSSValue* consumeReflect(CSSParserTokenRange& range, const CSSParserConte
xt& context) |
| 2812 { | 2836 { |
| 2813 RawPtr<CSSPrimitiveValue> direction = consumeIdent<CSSValueAbove, CSSValueBe
low, CSSValueLeft, CSSValueRight>(range); | 2837 CSSPrimitiveValue* direction = consumeIdent<CSSValueAbove, CSSValueBelow, CS
SValueLeft, CSSValueRight>(range); |
| 2814 if (!direction) | 2838 if (!direction) |
| 2815 return nullptr; | 2839 return nullptr; |
| 2816 | 2840 |
| 2817 RawPtr<CSSPrimitiveValue> offset = nullptr; | 2841 CSSPrimitiveValue* offset = nullptr; |
| 2818 if (range.atEnd()) { | 2842 if (range.atEnd()) { |
| 2819 offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixe
ls); | 2843 offset = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixe
ls); |
| 2820 } else { | 2844 } else { |
| 2821 offset = consumeLengthOrPercent(range, context.mode(), ValueRangeAll, Un
itlessQuirk::Forbid); | 2845 offset = consumeLengthOrPercent(range, context.mode(), ValueRangeAll, Un
itlessQuirk::Forbid); |
| 2822 if (!offset) | 2846 if (!offset) |
| 2823 return nullptr; | 2847 return nullptr; |
| 2824 } | 2848 } |
| 2825 | 2849 |
| 2826 RawPtr<CSSValue> mask = nullptr; | 2850 CSSValue* mask = nullptr; |
| 2827 if (!range.atEnd()) { | 2851 if (!range.atEnd()) { |
| 2828 mask = consumeWebkitBorderImage(CSSPropertyWebkitBoxReflect, range, cont
ext); | 2852 mask = consumeWebkitBorderImage(CSSPropertyWebkitBoxReflect, range, cont
ext); |
| 2829 if (!mask) | 2853 if (!mask) |
| 2830 return nullptr; | 2854 return nullptr; |
| 2831 } | 2855 } |
| 2832 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); | 2856 return CSSReflectValue::create(direction, offset, mask); |
| 2833 } | 2857 } |
| 2834 | 2858 |
| 2835 static RawPtr<CSSValue> consumeFontSizeAdjust(CSSParserTokenRange& range) | 2859 static CSSValue* consumeFontSizeAdjust(CSSParserTokenRange& range) |
| 2836 { | 2860 { |
| 2837 if (range.peek().id() == CSSValueNone) | 2861 if (range.peek().id() == CSSValueNone) |
| 2838 return consumeIdent(range); | 2862 return consumeIdent(range); |
| 2839 return consumeNumber(range, ValueRangeNonNegative); | 2863 return consumeNumber(range, ValueRangeNonNegative); |
| 2840 } | 2864 } |
| 2841 | 2865 |
| 2842 static RawPtr<CSSValue> consumeImageOrientation(CSSParserTokenRange& range) | 2866 static CSSValue* consumeImageOrientation(CSSParserTokenRange& range) |
| 2843 { | 2867 { |
| 2844 if (range.peek().id() == CSSValueFromImage) | 2868 if (range.peek().id() == CSSValueFromImage) |
| 2845 return consumeIdent(range); | 2869 return consumeIdent(range); |
| 2846 if (range.peek().type() != NumberToken) { | 2870 if (range.peek().type() != NumberToken) { |
| 2847 RawPtr<CSSPrimitiveValue> angle = consumeAngle(range); | 2871 CSSPrimitiveValue* angle = consumeAngle(range); |
| 2848 if (angle && angle->getDoubleValue() == 0) | 2872 if (angle && angle->getDoubleValue() == 0) |
| 2849 return angle; | 2873 return angle; |
| 2850 } | 2874 } |
| 2851 return nullptr; | 2875 return nullptr; |
| 2852 } | 2876 } |
| 2853 | 2877 |
| 2854 static RawPtr<CSSValue> consumeBackgroundBlendMode(CSSParserTokenRange& range) | 2878 static CSSValue* consumeBackgroundBlendMode(CSSParserTokenRange& range) |
| 2855 { | 2879 { |
| 2856 CSSValueID id = range.peek().id(); | 2880 CSSValueID id = range.peek().id(); |
| 2857 if (id == CSSValueNormal || id == CSSValueOverlay || (id >= CSSValueMultiply
&& id <= CSSValueLuminosity)) | 2881 if (id == CSSValueNormal || id == CSSValueOverlay || (id >= CSSValueMultiply
&& id <= CSSValueLuminosity)) |
| 2858 return consumeIdent(range); | 2882 return consumeIdent(range); |
| 2859 return nullptr; | 2883 return nullptr; |
| 2860 } | 2884 } |
| 2861 | 2885 |
| 2862 static RawPtr<CSSValue> consumeBackgroundAttachment(CSSParserTokenRange& range) | 2886 static CSSValue* consumeBackgroundAttachment(CSSParserTokenRange& range) |
| 2863 { | 2887 { |
| 2864 return consumeIdent<CSSValueScroll, CSSValueFixed, CSSValueLocal>(range); | 2888 return consumeIdent<CSSValueScroll, CSSValueFixed, CSSValueLocal>(range); |
| 2865 } | 2889 } |
| 2866 | 2890 |
| 2867 static RawPtr<CSSValue> consumeBackgroundBox(CSSParserTokenRange& range) | 2891 static CSSValue* consumeBackgroundBox(CSSParserTokenRange& range) |
| 2868 { | 2892 { |
| 2869 return consumeIdent<CSSValueBorderBox, CSSValuePaddingBox, CSSValueContentBo
x>(range); | 2893 return consumeIdent<CSSValueBorderBox, CSSValuePaddingBox, CSSValueContentBo
x>(range); |
| 2870 } | 2894 } |
| 2871 | 2895 |
| 2872 static RawPtr<CSSValue> consumeBackgroundComposite(CSSParserTokenRange& range) | 2896 static CSSValue* consumeBackgroundComposite(CSSParserTokenRange& range) |
| 2873 { | 2897 { |
| 2874 return consumeIdentRange(range, CSSValueClear, CSSValuePlusLighter); | 2898 return consumeIdentRange(range, CSSValueClear, CSSValuePlusLighter); |
| 2875 } | 2899 } |
| 2876 | 2900 |
| 2877 static RawPtr<CSSValue> consumeMaskSourceType(CSSParserTokenRange& range) | 2901 static CSSValue* consumeMaskSourceType(CSSParserTokenRange& range) |
| 2878 { | 2902 { |
| 2879 ASSERT(RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()); | 2903 ASSERT(RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()); |
| 2880 return consumeIdent<CSSValueAuto, CSSValueAlpha, CSSValueLuminance>(range); | 2904 return consumeIdent<CSSValueAuto, CSSValueAlpha, CSSValueLuminance>(range); |
| 2881 } | 2905 } |
| 2882 | 2906 |
| 2883 static RawPtr<CSSValue> consumePrefixedBackgroundBox(CSSPropertyID property, CSS
ParserTokenRange& range, const CSSParserContext& context) | 2907 static CSSValue* consumePrefixedBackgroundBox(CSSPropertyID property, CSSParserT
okenRange& range, const CSSParserContext& context) |
| 2884 { | 2908 { |
| 2885 // The values 'border', 'padding' and 'content' are deprecated and do not ap
ply to the version of the property that has the -webkit- prefix removed. | 2909 // The values 'border', 'padding' and 'content' are deprecated and do not ap
ply to the version of the property that has the -webkit- prefix removed. |
| 2886 if (RawPtr<CSSValue> value = consumeIdentRange(range, CSSValueBorder, CSSVal
uePaddingBox)) | 2910 if (CSSValue* value = consumeIdentRange(range, CSSValueBorder, CSSValuePaddi
ngBox)) |
| 2887 return value.release(); | 2911 return value; |
| 2888 if ((property == CSSPropertyWebkitBackgroundClip || property == CSSPropertyW
ebkitMaskClip) && range.peek().id() == CSSValueText) | 2912 if ((property == CSSPropertyWebkitBackgroundClip || property == CSSPropertyW
ebkitMaskClip) && range.peek().id() == CSSValueText) |
| 2889 return consumeIdent(range); | 2913 return consumeIdent(range); |
| 2890 return nullptr; | 2914 return nullptr; |
| 2891 } | 2915 } |
| 2892 | 2916 |
| 2893 static RawPtr<CSSValue> consumeBackgroundSize(CSSPropertyID unresolvedProperty,
CSSParserTokenRange& range, CSSParserMode mode) | 2917 static CSSValue* consumeBackgroundSize(CSSPropertyID unresolvedProperty, CSSPars
erTokenRange& range, CSSParserMode mode) |
| 2894 { | 2918 { |
| 2895 if (identMatches<CSSValueContain, CSSValueCover>(range.peek().id())) | 2919 if (identMatches<CSSValueContain, CSSValueCover>(range.peek().id())) |
| 2896 return consumeIdent(range); | 2920 return consumeIdent(range); |
| 2897 | 2921 |
| 2898 RawPtr<CSSPrimitiveValue> horizontal = consumeIdent<CSSValueAuto>(range); | 2922 CSSPrimitiveValue* horizontal = consumeIdent<CSSValueAuto>(range); |
| 2899 if (!horizontal) | 2923 if (!horizontal) |
| 2900 horizontal = consumeLengthOrPercent(range, mode, ValueRangeAll, Unitless
Quirk::Forbid); | 2924 horizontal = consumeLengthOrPercent(range, mode, ValueRangeAll, Unitless
Quirk::Forbid); |
| 2901 | 2925 |
| 2902 RawPtr<CSSPrimitiveValue> vertical = nullptr; | 2926 CSSPrimitiveValue* vertical = nullptr; |
| 2903 if (!range.atEnd()) { | 2927 if (!range.atEnd()) { |
| 2904 if (range.peek().id() == CSSValueAuto) // `auto' is the default | 2928 if (range.peek().id() == CSSValueAuto) // `auto' is the default |
| 2905 range.consumeIncludingWhitespace(); | 2929 range.consumeIncludingWhitespace(); |
| 2906 else | 2930 else |
| 2907 vertical = consumeLengthOrPercent(range, mode, ValueRangeAll, Unitle
ssQuirk::Forbid); | 2931 vertical = consumeLengthOrPercent(range, mode, ValueRangeAll, Unitle
ssQuirk::Forbid); |
| 2908 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { | 2932 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { |
| 2909 // Legacy syntax: "-webkit-background-size: 10px" is equivalent to "back
ground-size: 10px 10px". | 2933 // Legacy syntax: "-webkit-background-size: 10px" is equivalent to "back
ground-size: 10px 10px". |
| 2910 vertical = horizontal; | 2934 vertical = horizontal; |
| 2911 } | 2935 } |
| 2912 if (!vertical) | 2936 if (!vertical) |
| 2913 return horizontal; | 2937 return horizontal; |
| 2914 return CSSValuePair::create(horizontal.release(), vertical.release(), CSSVal
uePair::KeepIdenticalValues); | 2938 return CSSValuePair::create(horizontal, vertical, CSSValuePair::KeepIdentica
lValues); |
| 2915 } | 2939 } |
| 2916 | 2940 |
| 2917 static RawPtr<CSSValue> consumeBackgroundComponent(CSSPropertyID unresolvedPrope
rty, CSSParserTokenRange& range, const CSSParserContext& context) | 2941 static CSSValue* consumeBackgroundComponent(CSSPropertyID unresolvedProperty, CS
SParserTokenRange& range, const CSSParserContext& context) |
| 2918 { | 2942 { |
| 2919 switch (unresolvedProperty) { | 2943 switch (unresolvedProperty) { |
| 2920 case CSSPropertyBackgroundClip: | 2944 case CSSPropertyBackgroundClip: |
| 2921 return consumeBackgroundBox(range); | 2945 return consumeBackgroundBox(range); |
| 2922 case CSSPropertyBackgroundBlendMode: | 2946 case CSSPropertyBackgroundBlendMode: |
| 2923 return consumeBackgroundBlendMode(range); | 2947 return consumeBackgroundBlendMode(range); |
| 2924 case CSSPropertyBackgroundAttachment: | 2948 case CSSPropertyBackgroundAttachment: |
| 2925 return consumeBackgroundAttachment(range); | 2949 return consumeBackgroundAttachment(range); |
| 2926 case CSSPropertyBackgroundOrigin: | 2950 case CSSPropertyBackgroundOrigin: |
| 2927 return consumeBackgroundBox(range); | 2951 return consumeBackgroundBox(range); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2948 case CSSPropertyWebkitMaskSize: | 2972 case CSSPropertyWebkitMaskSize: |
| 2949 return consumeBackgroundSize(unresolvedProperty, range, context.mode()); | 2973 return consumeBackgroundSize(unresolvedProperty, range, context.mode()); |
| 2950 case CSSPropertyBackgroundColor: | 2974 case CSSPropertyBackgroundColor: |
| 2951 return consumeColor(range, context.mode()); | 2975 return consumeColor(range, context.mode()); |
| 2952 default: | 2976 default: |
| 2953 break; | 2977 break; |
| 2954 }; | 2978 }; |
| 2955 return nullptr; | 2979 return nullptr; |
| 2956 } | 2980 } |
| 2957 | 2981 |
| 2958 static void addBackgroundValue(RawPtr<CSSValue>& list, RawPtr<CSSValue> value) | 2982 static void addBackgroundValue(CSSValue*& list, CSSValue* value) |
| 2959 { | 2983 { |
| 2960 if (list) { | 2984 if (list) { |
| 2961 if (!list->isBaseValueList()) { | 2985 if (!list->isBaseValueList()) { |
| 2962 RawPtr<CSSValue> firstValue = list.release(); | 2986 CSSValue* firstValue = list; |
| 2963 list = CSSValueList::createCommaSeparated(); | 2987 list = CSSValueList::createCommaSeparated(); |
| 2964 toCSSValueList(list.get())->append(firstValue.release()); | 2988 toCSSValueList(list)->append(firstValue); |
| 2965 } | 2989 } |
| 2966 toCSSValueList(list.get())->append(value); | 2990 toCSSValueList(list)->append(value); |
| 2967 } else { | 2991 } else { |
| 2968 // To conserve memory we don't actually wrap a single value in a list. | 2992 // To conserve memory we don't actually wrap a single value in a list. |
| 2969 list = value; | 2993 list = value; |
| 2970 } | 2994 } |
| 2971 } | 2995 } |
| 2972 | 2996 |
| 2973 static RawPtr<CSSValue> consumeCommaSeparatedBackgroundComponent(CSSPropertyID u
nresolvedProperty, CSSParserTokenRange& range, const CSSParserContext& context) | 2997 static CSSValue* consumeCommaSeparatedBackgroundComponent(CSSPropertyID unresolv
edProperty, CSSParserTokenRange& range, const CSSParserContext& context) |
| 2974 { | 2998 { |
| 2975 RawPtr<CSSValue> result = nullptr; | 2999 CSSValue* result = nullptr; |
| 2976 do { | 3000 do { |
| 2977 RawPtr<CSSValue> value = consumeBackgroundComponent(unresolvedProperty,
range, context); | 3001 CSSValue* value = consumeBackgroundComponent(unresolvedProperty, range,
context); |
| 2978 if (!value) | 3002 if (!value) |
| 2979 return nullptr; | 3003 return nullptr; |
| 2980 addBackgroundValue(result, value); | 3004 addBackgroundValue(result, value); |
| 2981 } while (consumeCommaIncludingWhitespace(range)); | 3005 } while (consumeCommaIncludingWhitespace(range)); |
| 2982 return result.release(); | 3006 return result; |
| 2983 } | 3007 } |
| 2984 | 3008 |
| 2985 static RawPtr<CSSPrimitiveValue> consumeSelfPositionKeyword(CSSParserTokenRange&
range) | 3009 static CSSPrimitiveValue* consumeSelfPositionKeyword(CSSParserTokenRange& range) |
| 2986 { | 3010 { |
| 2987 CSSValueID id = range.peek().id(); | 3011 CSSValueID id = range.peek().id(); |
| 2988 if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter | 3012 if (id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter |
| 2989 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle
xStart | 3013 || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFle
xStart |
| 2990 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight) | 3014 || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight) |
| 2991 return consumeIdent(range); | 3015 return consumeIdent(range); |
| 2992 return nullptr; | 3016 return nullptr; |
| 2993 } | 3017 } |
| 2994 | 3018 |
| 2995 static RawPtr<CSSValue> consumeSelfPositionOverflowPosition(CSSParserTokenRange&
range) | 3019 static CSSValue* consumeSelfPositionOverflowPosition(CSSParserTokenRange& range) |
| 2996 { | 3020 { |
| 2997 if (identMatches<CSSValueAuto, CSSValueStretch, CSSValueBaseline, CSSValueLa
stBaseline>(range.peek().id())) | 3021 if (identMatches<CSSValueAuto, CSSValueStretch, CSSValueBaseline, CSSValueLa
stBaseline>(range.peek().id())) |
| 2998 return consumeIdent(range); | 3022 return consumeIdent(range); |
| 2999 | 3023 |
| 3000 RawPtr<CSSPrimitiveValue> overflowPosition = consumeIdent<CSSValueUnsafe, CS
SValueSafe>(range); | 3024 CSSPrimitiveValue* overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueS
afe>(range); |
| 3001 RawPtr<CSSPrimitiveValue> selfPosition = consumeSelfPositionKeyword(range); | 3025 CSSPrimitiveValue* selfPosition = consumeSelfPositionKeyword(range); |
| 3002 if (!selfPosition) | 3026 if (!selfPosition) |
| 3003 return nullptr; | 3027 return nullptr; |
| 3004 if (!overflowPosition) | 3028 if (!overflowPosition) |
| 3005 overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range); | 3029 overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range); |
| 3006 if (overflowPosition) | 3030 if (overflowPosition) |
| 3007 return CSSValuePair::create(selfPosition.release(), overflowPosition, CS
SValuePair::DropIdenticalValues); | 3031 return CSSValuePair::create(selfPosition, overflowPosition, CSSValuePair
::DropIdenticalValues); |
| 3008 return selfPosition.release(); | 3032 return selfPosition; |
| 3009 } | 3033 } |
| 3010 | 3034 |
| 3011 static RawPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& range) | 3035 static CSSValue* consumeJustifyItems(CSSParserTokenRange& range) |
| 3012 { | 3036 { |
| 3013 CSSParserTokenRange rangeCopy = range; | 3037 CSSParserTokenRange rangeCopy = range; |
| 3014 RawPtr<CSSPrimitiveValue> legacy = consumeIdent<CSSValueLegacy>(rangeCopy); | 3038 CSSPrimitiveValue* legacy = consumeIdent<CSSValueLegacy>(rangeCopy); |
| 3015 RawPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValueCenter, CSS
ValueLeft, CSSValueRight>(rangeCopy); | 3039 CSSPrimitiveValue* positionKeyword = consumeIdent<CSSValueCenter, CSSValueLe
ft, CSSValueRight>(rangeCopy); |
| 3016 if (!legacy) | 3040 if (!legacy) |
| 3017 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); | 3041 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); |
| 3018 if (legacy && positionKeyword) { | 3042 if (legacy && positionKeyword) { |
| 3019 range = rangeCopy; | 3043 range = rangeCopy; |
| 3020 return CSSValuePair::create(legacy.release(), positionKeyword.release(),
CSSValuePair::DropIdenticalValues); | 3044 return CSSValuePair::create(legacy, positionKeyword, CSSValuePair::DropI
denticalValues); |
| 3021 } | 3045 } |
| 3022 return consumeSelfPositionOverflowPosition(range); | 3046 return consumeSelfPositionOverflowPosition(range); |
| 3023 } | 3047 } |
| 3024 | 3048 |
| 3025 static RawPtr<CSSCustomIdentValue> consumeCustomIdentForGridLine(CSSParserTokenR
ange& range) | 3049 static CSSCustomIdentValue* consumeCustomIdentForGridLine(CSSParserTokenRange& r
ange) |
| 3026 { | 3050 { |
| 3027 if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan) | 3051 if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan) |
| 3028 return nullptr; | 3052 return nullptr; |
| 3029 return consumeCustomIdent(range); | 3053 return consumeCustomIdent(range); |
| 3030 } | 3054 } |
| 3031 | 3055 |
| 3032 static RawPtr<CSSValue> consumeGridLine(CSSParserTokenRange& range) | 3056 static CSSValue* consumeGridLine(CSSParserTokenRange& range) |
| 3033 { | 3057 { |
| 3034 if (range.peek().id() == CSSValueAuto) | 3058 if (range.peek().id() == CSSValueAuto) |
| 3035 return consumeIdent(range); | 3059 return consumeIdent(range); |
| 3036 | 3060 |
| 3037 RawPtr<CSSPrimitiveValue> spanValue = nullptr; | 3061 CSSPrimitiveValue* spanValue = nullptr; |
| 3038 RawPtr<CSSCustomIdentValue> gridLineName = nullptr; | 3062 CSSCustomIdentValue* gridLineName = nullptr; |
| 3039 RawPtr<CSSPrimitiveValue> numericValue = consumeInteger(range); | 3063 CSSPrimitiveValue* numericValue = consumeInteger(range); |
| 3040 if (numericValue) { | 3064 if (numericValue) { |
| 3041 gridLineName = consumeCustomIdentForGridLine(range); | 3065 gridLineName = consumeCustomIdentForGridLine(range); |
| 3042 spanValue = consumeIdent<CSSValueSpan>(range); | 3066 spanValue = consumeIdent<CSSValueSpan>(range); |
| 3043 } else if ((spanValue = consumeIdent<CSSValueSpan>(range))) { | 3067 } else { |
| 3044 numericValue = consumeInteger(range); | 3068 spanValue = consumeIdent<CSSValueSpan>(range); |
| 3045 gridLineName = consumeCustomIdentForGridLine(range); | 3069 if (spanValue) { |
| 3046 if (!numericValue) | |
| 3047 numericValue = consumeInteger(range); | 3070 numericValue = consumeInteger(range); |
| 3048 } else if ((gridLineName = consumeCustomIdentForGridLine(range))) { | 3071 gridLineName = consumeCustomIdentForGridLine(range); |
| 3049 numericValue = consumeInteger(range); | 3072 if (!numericValue) |
| 3050 spanValue = consumeIdent<CSSValueSpan>(range); | 3073 numericValue = consumeInteger(range); |
| 3051 if (!spanValue && !numericValue) | 3074 } else { |
| 3052 return gridLineName.release(); | 3075 gridLineName = consumeCustomIdentForGridLine(range); |
| 3053 } else { | 3076 if (gridLineName) { |
| 3054 return nullptr; | 3077 numericValue = consumeInteger(range); |
| 3078 spanValue = consumeIdent<CSSValueSpan>(range); |
| 3079 if (!spanValue && !numericValue) |
| 3080 return gridLineName; |
| 3081 } else { |
| 3082 return nullptr; |
| 3083 } |
| 3084 } |
| 3055 } | 3085 } |
| 3056 | 3086 |
| 3057 if (spanValue && numericValue && numericValue->getIntValue() < 0) | 3087 if (spanValue && numericValue && numericValue->getIntValue() < 0) |
| 3058 return nullptr; // Negative numbers are not allowed for span. | 3088 return nullptr; // Negative numbers are not allowed for span. |
| 3059 if (numericValue && numericValue->getIntValue() == 0) | 3089 if (numericValue && numericValue->getIntValue() == 0) |
| 3060 return nullptr; // An <integer> value of zero makes the declaration inva
lid. | 3090 return nullptr; // An <integer> value of zero makes the declaration inva
lid. |
| 3061 | 3091 |
| 3062 RawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); | 3092 CSSValueList* values = CSSValueList::createSpaceSeparated(); |
| 3063 if (spanValue) | 3093 if (spanValue) |
| 3064 values->append(spanValue.release()); | 3094 values->append(spanValue); |
| 3065 if (numericValue) | 3095 if (numericValue) |
| 3066 values->append(numericValue.release()); | 3096 values->append(numericValue); |
| 3067 if (gridLineName) | 3097 if (gridLineName) |
| 3068 values->append(gridLineName.release()); | 3098 values->append(gridLineName); |
| 3069 ASSERT(values->length()); | 3099 ASSERT(values->length()); |
| 3070 return values.release(); | 3100 return values; |
| 3071 } | 3101 } |
| 3072 | 3102 |
| 3073 static RawPtr<CSSPrimitiveValue> consumeGridBreadth(CSSParserTokenRange& range,
CSSParserMode cssParserMode, TrackSizeRestriction restriction = AllowAll) | 3103 static CSSPrimitiveValue* consumeGridBreadth(CSSParserTokenRange& range, CSSPars
erMode cssParserMode, TrackSizeRestriction restriction = AllowAll) |
| 3074 { | 3104 { |
| 3075 if (restriction == AllowAll) { | 3105 if (restriction == AllowAll) { |
| 3076 const CSSParserToken& token = range.peek(); | 3106 const CSSParserToken& token = range.peek(); |
| 3077 if (identMatches<CSSValueMinContent, CSSValueMaxContent, CSSValueAuto>(t
oken.id())) | 3107 if (identMatches<CSSValueMinContent, CSSValueMaxContent, CSSValueAuto>(t
oken.id())) |
| 3078 return consumeIdent(range); | 3108 return consumeIdent(range); |
| 3079 if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveVa
lue::UnitType::Fraction) { | 3109 if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveVa
lue::UnitType::Fraction) { |
| 3080 if (range.peek().numericValue() < 0) | 3110 if (range.peek().numericValue() < 0) |
| 3081 return nullptr; | 3111 return nullptr; |
| 3082 return cssValuePool().createValue(range.consumeIncludingWhitespace()
.numericValue(), CSSPrimitiveValue::UnitType::Fraction); | 3112 return cssValuePool().createValue(range.consumeIncludingWhitespace()
.numericValue(), CSSPrimitiveValue::UnitType::Fraction); |
| 3083 } | 3113 } |
| 3084 } | 3114 } |
| 3085 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, U
nitlessQuirk::Allow); | 3115 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, U
nitlessQuirk::Allow); |
| 3086 } | 3116 } |
| 3087 | 3117 |
| 3088 static RawPtr<CSSValue> consumeGridTrackSize(CSSParserTokenRange& range, CSSPars
erMode cssParserMode, TrackSizeRestriction restriction = AllowAll) | 3118 static CSSValue* consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode
cssParserMode, TrackSizeRestriction restriction = AllowAll) |
| 3089 { | 3119 { |
| 3090 const CSSParserToken& token = range.peek(); | 3120 const CSSParserToken& token = range.peek(); |
| 3091 if (restriction == AllowAll && identMatches<CSSValueAuto>(token.id())) | 3121 if (restriction == AllowAll && identMatches<CSSValueAuto>(token.id())) |
| 3092 return consumeIdent(range); | 3122 return consumeIdent(range); |
| 3093 | 3123 |
| 3094 if (token.functionId() == CSSValueMinmax) { | 3124 if (token.functionId() == CSSValueMinmax) { |
| 3095 CSSParserTokenRange rangeCopy = range; | 3125 CSSParserTokenRange rangeCopy = range; |
| 3096 CSSParserTokenRange args = consumeFunction(rangeCopy); | 3126 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 3097 RawPtr<CSSPrimitiveValue> minTrackBreadth = consumeGridBreadth(args, css
ParserMode, restriction); | 3127 CSSPrimitiveValue* minTrackBreadth = consumeGridBreadth(args, cssParserM
ode, restriction); |
| 3098 if (!minTrackBreadth || !consumeCommaIncludingWhitespace(args)) | 3128 if (!minTrackBreadth || !consumeCommaIncludingWhitespace(args)) |
| 3099 return nullptr; | 3129 return nullptr; |
| 3100 RawPtr<CSSPrimitiveValue> maxTrackBreadth = consumeGridBreadth(args, css
ParserMode); | 3130 CSSPrimitiveValue* maxTrackBreadth = consumeGridBreadth(args, cssParserM
ode); |
| 3101 if (!maxTrackBreadth || !args.atEnd()) | 3131 if (!maxTrackBreadth || !args.atEnd()) |
| 3102 return nullptr; | 3132 return nullptr; |
| 3103 range = rangeCopy; | 3133 range = rangeCopy; |
| 3104 RawPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueMinma
x); | 3134 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueMinmax); |
| 3105 result->append(minTrackBreadth.release()); | 3135 result->append(minTrackBreadth); |
| 3106 result->append(maxTrackBreadth.release()); | 3136 result->append(maxTrackBreadth); |
| 3107 return result.release(); | 3137 return result; |
| 3108 } | 3138 } |
| 3109 return consumeGridBreadth(range, cssParserMode, restriction); | 3139 return consumeGridBreadth(range, cssParserMode, restriction); |
| 3110 } | 3140 } |
| 3111 | 3141 |
| 3112 static RawPtr<CSSGridLineNamesValue> consumeGridLineNames(CSSParserTokenRange& r
ange) | 3142 static CSSGridLineNamesValue* consumeGridLineNames(CSSParserTokenRange& range) |
| 3113 { | 3143 { |
| 3114 CSSParserTokenRange rangeCopy = range; | 3144 CSSParserTokenRange rangeCopy = range; |
| 3115 if (rangeCopy.consumeIncludingWhitespace().type() != LeftBracketToken) | 3145 if (rangeCopy.consumeIncludingWhitespace().type() != LeftBracketToken) |
| 3116 return nullptr; | 3146 return nullptr; |
| 3117 RawPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create(); | 3147 CSSGridLineNamesValue* lineNames = CSSGridLineNamesValue::create(); |
| 3118 while (RawPtr<CSSCustomIdentValue> lineName = consumeCustomIdentForGridLine(
rangeCopy)) | 3148 while (CSSCustomIdentValue* lineName = consumeCustomIdentForGridLine(rangeCo
py)) |
| 3119 lineNames->append(lineName.release()); | 3149 lineNames->append(lineName); |
| 3120 if (rangeCopy.consumeIncludingWhitespace().type() != RightBracketToken) | 3150 if (rangeCopy.consumeIncludingWhitespace().type() != RightBracketToken) |
| 3121 return nullptr; | 3151 return nullptr; |
| 3122 range = rangeCopy; | 3152 range = rangeCopy; |
| 3123 return lineNames.release(); | 3153 return lineNames; |
| 3124 } | 3154 } |
| 3125 | 3155 |
| 3126 static bool consumeGridTrackRepeatFunction(CSSParserTokenRange& range, CSSParser
Mode cssParserMode, CSSValueList& list, bool& isAutoRepeat) | 3156 static bool consumeGridTrackRepeatFunction(CSSParserTokenRange& range, CSSParser
Mode cssParserMode, CSSValueList& list, bool& isAutoRepeat) |
| 3127 { | 3157 { |
| 3128 CSSParserTokenRange args = consumeFunction(range); | 3158 CSSParserTokenRange args = consumeFunction(range); |
| 3129 // The number of repetitions for <auto-repeat> is not important at parsing l
evel | 3159 // The number of repetitions for <auto-repeat> is not important at parsing l
evel |
| 3130 // because it will be computed later, let's set it to 1. | 3160 // because it will be computed later, let's set it to 1. |
| 3131 size_t repetitions = 1; | 3161 size_t repetitions = 1; |
| 3132 isAutoRepeat = identMatches<CSSValueAutoFill, CSSValueAutoFit>(args.peek().i
d()); | 3162 isAutoRepeat = identMatches<CSSValueAutoFill, CSSValueAutoFit>(args.peek().i
d()); |
| 3133 RawPtr<CSSValueList> repeatedValues; | 3163 CSSValueList* repeatedValues; |
| 3134 if (isAutoRepeat) { | 3164 if (isAutoRepeat) { |
| 3135 repeatedValues = CSSGridAutoRepeatValue::create(args.consumeIncludingWhi
tespace().id()); | 3165 repeatedValues = CSSGridAutoRepeatValue::create(args.consumeIncludingWhi
tespace().id()); |
| 3136 } else { | 3166 } else { |
| 3137 // TODO(rob.buis): a consumeIntegerRaw would be more efficient here. | 3167 // TODO(rob.buis): a consumeIntegerRaw would be more efficient here. |
| 3138 RawPtr<CSSPrimitiveValue> repetition = consumePositiveInteger(args); | 3168 CSSPrimitiveValue* repetition = consumePositiveInteger(args); |
| 3139 if (!repetition) | 3169 if (!repetition) |
| 3140 return false; | 3170 return false; |
| 3141 repetitions = clampTo<size_t>(repetition->getDoubleValue(), 0, kGridMaxT
racks); | 3171 repetitions = clampTo<size_t>(repetition->getDoubleValue(), 0, kGridMaxT
racks); |
| 3142 repeatedValues = CSSValueList::createSpaceSeparated(); | 3172 repeatedValues = CSSValueList::createSpaceSeparated(); |
| 3143 } | 3173 } |
| 3144 if (!consumeCommaIncludingWhitespace(args)) | 3174 if (!consumeCommaIncludingWhitespace(args)) |
| 3145 return false; | 3175 return false; |
| 3146 RawPtr<CSSGridLineNamesValue> lineNames = consumeGridLineNames(args); | 3176 CSSGridLineNamesValue* lineNames = consumeGridLineNames(args); |
| 3147 if (lineNames) | 3177 if (lineNames) |
| 3148 repeatedValues->append(lineNames.release()); | 3178 repeatedValues->append(lineNames); |
| 3149 | 3179 |
| 3150 size_t numberOfTracks = 0; | 3180 size_t numberOfTracks = 0; |
| 3151 TrackSizeRestriction restriction = isAutoRepeat ? FixedSizeOnly : AllowAll; | 3181 TrackSizeRestriction restriction = isAutoRepeat ? FixedSizeOnly : AllowAll; |
| 3152 while (!args.atEnd()) { | 3182 while (!args.atEnd()) { |
| 3153 if (isAutoRepeat && numberOfTracks) | 3183 if (isAutoRepeat && numberOfTracks) |
| 3154 return false; | 3184 return false; |
| 3155 RawPtr<CSSValue> trackSize = consumeGridTrackSize(args, cssParserMode, r
estriction); | 3185 CSSValue* trackSize = consumeGridTrackSize(args, cssParserMode, restrict
ion); |
| 3156 if (!trackSize) | 3186 if (!trackSize) |
| 3157 return false; | 3187 return false; |
| 3158 repeatedValues->append(trackSize.release()); | 3188 repeatedValues->append(trackSize); |
| 3159 ++numberOfTracks; | 3189 ++numberOfTracks; |
| 3160 lineNames = consumeGridLineNames(args); | 3190 lineNames = consumeGridLineNames(args); |
| 3161 if (lineNames) | 3191 if (lineNames) |
| 3162 repeatedValues->append(lineNames.release()); | 3192 repeatedValues->append(lineNames); |
| 3163 } | 3193 } |
| 3164 // We should have found at least one <track-size> or else it is not a valid
<track-list>. | 3194 // We should have found at least one <track-size> or else it is not a valid
<track-list>. |
| 3165 if (!numberOfTracks) | 3195 if (!numberOfTracks) |
| 3166 return false; | 3196 return false; |
| 3167 | 3197 |
| 3168 if (isAutoRepeat) { | 3198 if (isAutoRepeat) { |
| 3169 list.append(repeatedValues.release()); | 3199 list.append(repeatedValues); |
| 3170 } else { | 3200 } else { |
| 3171 // We clamp the repetitions to a multiple of the repeat() track list's s
ize, while staying below the max grid size. | 3201 // We clamp the repetitions to a multiple of the repeat() track list's s
ize, while staying below the max grid size. |
| 3172 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); | 3202 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); |
| 3173 for (size_t i = 0; i < repetitions; ++i) { | 3203 for (size_t i = 0; i < repetitions; ++i) { |
| 3174 for (size_t j = 0; j < repeatedValues->length(); ++j) | 3204 for (size_t j = 0; j < repeatedValues->length(); ++j) |
| 3175 list.append(repeatedValues->item(j)); | 3205 list.append(repeatedValues->item(j)); |
| 3176 } | 3206 } |
| 3177 } | 3207 } |
| 3178 return true; | 3208 return true; |
| 3179 } | 3209 } |
| 3180 | 3210 |
| 3181 static RawPtr<CSSValue> consumeGridTrackList(CSSParserTokenRange& range, CSSPars
erMode cssParserMode) | 3211 static CSSValue* consumeGridTrackList(CSSParserTokenRange& range, CSSParserMode
cssParserMode) |
| 3182 { | 3212 { |
| 3183 RawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); | 3213 CSSValueList* values = CSSValueList::createSpaceSeparated(); |
| 3184 RawPtr<CSSGridLineNamesValue> lineNames = consumeGridLineNames(range); | 3214 CSSGridLineNamesValue* lineNames = consumeGridLineNames(range); |
| 3185 if (lineNames) | 3215 if (lineNames) |
| 3186 values->append(lineNames.release()); | 3216 values->append(lineNames); |
| 3187 | 3217 |
| 3188 bool seenAutoRepeat = false; | 3218 bool seenAutoRepeat = false; |
| 3189 // TODO(rob.buis): <line-names> should not be able to directly precede <auto
-repeat>. | 3219 // TODO(rob.buis): <line-names> should not be able to directly precede <auto
-repeat>. |
| 3190 do { | 3220 do { |
| 3191 bool isAutoRepeat; | 3221 bool isAutoRepeat; |
| 3192 if (range.peek().functionId() == CSSValueRepeat) { | 3222 if (range.peek().functionId() == CSSValueRepeat) { |
| 3193 if (!consumeGridTrackRepeatFunction(range, cssParserMode, *values, i
sAutoRepeat)) | 3223 if (!consumeGridTrackRepeatFunction(range, cssParserMode, *values, i
sAutoRepeat)) |
| 3194 return nullptr; | 3224 return nullptr; |
| 3195 if (isAutoRepeat && seenAutoRepeat) | 3225 if (isAutoRepeat && seenAutoRepeat) |
| 3196 return nullptr; | 3226 return nullptr; |
| 3197 seenAutoRepeat = seenAutoRepeat || isAutoRepeat; | 3227 seenAutoRepeat = seenAutoRepeat || isAutoRepeat; |
| 3198 } else if (RawPtr<CSSValue> value = consumeGridTrackSize(range, cssParse
rMode, seenAutoRepeat ? FixedSizeOnly : AllowAll)) { | 3228 } else if (CSSValue* value = consumeGridTrackSize(range, cssParserMode,
seenAutoRepeat ? FixedSizeOnly : AllowAll)) { |
| 3199 values->append(value.release()); | 3229 values->append(value); |
| 3200 } else { | 3230 } else { |
| 3201 return nullptr; | 3231 return nullptr; |
| 3202 } | 3232 } |
| 3203 lineNames = consumeGridLineNames(range); | 3233 lineNames = consumeGridLineNames(range); |
| 3204 if (lineNames) | 3234 if (lineNames) |
| 3205 values->append(lineNames.release()); | 3235 values->append(lineNames); |
| 3206 } while (!range.atEnd() && range.peek().type() != DelimiterToken); | 3236 } while (!range.atEnd() && range.peek().type() != DelimiterToken); |
| 3207 // <auto-repeat> requires definite minimum track sizes in order to compute t
he number of repetitions. | 3237 // <auto-repeat> requires definite minimum track sizes in order to compute t
he number of repetitions. |
| 3208 // The above while loop detects those appearances after the <auto-repeat> bu
t not the ones before. | 3238 // The above while loop detects those appearances after the <auto-repeat> bu
t not the ones before. |
| 3209 if (seenAutoRepeat && !allTracksAreFixedSized(*values)) | 3239 if (seenAutoRepeat && !allTracksAreFixedSized(*values)) |
| 3210 return nullptr; | 3240 return nullptr; |
| 3211 return values.release(); | 3241 return values; |
| 3212 } | 3242 } |
| 3213 | 3243 |
| 3214 static RawPtr<CSSValue> consumeGridTemplatesRowsOrColumns(CSSParserTokenRange& r
ange, CSSParserMode cssParserMode) | 3244 static CSSValue* consumeGridTemplatesRowsOrColumns(CSSParserTokenRange& range, C
SSParserMode cssParserMode) |
| 3215 { | 3245 { |
| 3216 if (range.peek().id() == CSSValueNone) | 3246 if (range.peek().id() == CSSValueNone) |
| 3217 return consumeIdent(range); | 3247 return consumeIdent(range); |
| 3218 return consumeGridTrackList(range, cssParserMode); | 3248 return consumeGridTrackList(range, cssParserMode); |
| 3219 } | 3249 } |
| 3220 | 3250 |
| 3221 static RawPtr<CSSValue> consumeGridTemplateAreas(CSSParserTokenRange& range) | 3251 static CSSValue* consumeGridTemplateAreas(CSSParserTokenRange& range) |
| 3222 { | 3252 { |
| 3223 if (range.peek().id() == CSSValueNone) | 3253 if (range.peek().id() == CSSValueNone) |
| 3224 return consumeIdent(range); | 3254 return consumeIdent(range); |
| 3225 | 3255 |
| 3226 NamedGridAreaMap gridAreaMap; | 3256 NamedGridAreaMap gridAreaMap; |
| 3227 size_t rowCount = 0; | 3257 size_t rowCount = 0; |
| 3228 size_t columnCount = 0; | 3258 size_t columnCount = 0; |
| 3229 | 3259 |
| 3230 while (range.peek().type() == StringToken) { | 3260 while (range.peek().type() == StringToken) { |
| 3231 if (!parseGridTemplateAreasRow(range.consumeIncludingWhitespace().value(
), gridAreaMap, rowCount, columnCount)) | 3261 if (!parseGridTemplateAreasRow(range.consumeIncludingWhitespace().value(
), gridAreaMap, rowCount, columnCount)) |
| 3232 return nullptr; | 3262 return nullptr; |
| 3233 ++rowCount; | 3263 ++rowCount; |
| 3234 } | 3264 } |
| 3235 | 3265 |
| 3236 if (rowCount == 0) | 3266 if (rowCount == 0) |
| 3237 return nullptr; | 3267 return nullptr; |
| 3238 ASSERT(columnCount); | 3268 ASSERT(columnCount); |
| 3239 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; | 3269 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; |
| 3240 } | 3270 } |
| 3241 | 3271 |
| 3242 RawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedPro
perty) | 3272 CSSValue* CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty) |
| 3243 { | 3273 { |
| 3244 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3274 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 3245 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3275 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
| 3246 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id())) | 3276 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id())) |
| 3247 return nullptr; | 3277 return nullptr; |
| 3248 return consumeIdent(m_range); | 3278 return consumeIdent(m_range); |
| 3249 } | 3279 } |
| 3250 switch (property) { | 3280 switch (property) { |
| 3251 case CSSPropertyWillChange: | 3281 case CSSPropertyWillChange: |
| 3252 return consumeWillChange(m_range); | 3282 return consumeWillChange(m_range); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3615 case CSSPropertyGridTemplateRows: | 3645 case CSSPropertyGridTemplateRows: |
| 3616 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3646 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3617 return consumeGridTemplatesRowsOrColumns(m_range, m_context.mode()); | 3647 return consumeGridTemplatesRowsOrColumns(m_range, m_context.mode()); |
| 3618 case CSSPropertyGridTemplateAreas: | 3648 case CSSPropertyGridTemplateAreas: |
| 3619 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3649 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 3620 return consumeGridTemplateAreas(m_range); | 3650 return consumeGridTemplateAreas(m_range); |
| 3621 default: | 3651 default: |
| 3622 CSSParserValueList valueList(m_range); | 3652 CSSParserValueList valueList(m_range); |
| 3623 if (valueList.size()) { | 3653 if (valueList.size()) { |
| 3624 m_valueList = &valueList; | 3654 m_valueList = &valueList; |
| 3625 if (RawPtr<CSSValue> result = legacyParseValue(unresolvedProperty))
{ | 3655 if (CSSValue* result = legacyParseValue(unresolvedProperty)) { |
| 3626 while (!m_range.atEnd()) | 3656 while (!m_range.atEnd()) |
| 3627 m_range.consume(); | 3657 m_range.consume(); |
| 3628 return result.release(); | 3658 return result; |
| 3629 } | 3659 } |
| 3630 } | 3660 } |
| 3631 return nullptr; | 3661 return nullptr; |
| 3632 } | 3662 } |
| 3633 } | 3663 } |
| 3634 | 3664 |
| 3635 static RawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParserTokenRange& ran
ge) | 3665 static CSSValueList* consumeFontFaceUnicodeRange(CSSParserTokenRange& range) |
| 3636 { | 3666 { |
| 3637 RawPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); | 3667 CSSValueList* values = CSSValueList::createCommaSeparated(); |
| 3638 | 3668 |
| 3639 do { | 3669 do { |
| 3640 const CSSParserToken& token = range.consumeIncludingWhitespace(); | 3670 const CSSParserToken& token = range.consumeIncludingWhitespace(); |
| 3641 if (token.type() != UnicodeRangeToken) | 3671 if (token.type() != UnicodeRangeToken) |
| 3642 return nullptr; | 3672 return nullptr; |
| 3643 | 3673 |
| 3644 UChar32 start = token.unicodeRangeStart(); | 3674 UChar32 start = token.unicodeRangeStart(); |
| 3645 UChar32 end = token.unicodeRangeEnd(); | 3675 UChar32 end = token.unicodeRangeEnd(); |
| 3646 if (start > end) | 3676 if (start > end) |
| 3647 return nullptr; | 3677 return nullptr; |
| 3648 values->append(CSSUnicodeRangeValue::create(start, end)); | 3678 values->append(CSSUnicodeRangeValue::create(start, end)); |
| 3649 } while (consumeCommaIncludingWhitespace(range)); | 3679 } while (consumeCommaIncludingWhitespace(range)); |
| 3650 | 3680 |
| 3651 return values.release(); | 3681 return values; |
| 3652 } | 3682 } |
| 3653 | 3683 |
| 3654 static RawPtr<CSSValue> consumeFontFaceSrcURI(CSSParserTokenRange& range, const
CSSParserContext& context) | 3684 static CSSValue* consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSPars
erContext& context) |
| 3655 { | 3685 { |
| 3656 String url = consumeUrl(range); | 3686 String url = consumeUrl(range); |
| 3657 if (url.isNull()) | 3687 if (url.isNull()) |
| 3658 return nullptr; | 3688 return nullptr; |
| 3659 RawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(url, contex
t.completeURL(url), context.shouldCheckContentSecurityPolicy())); | 3689 CSSFontFaceSrcValue* uriValue(CSSFontFaceSrcValue::create(url, context.compl
eteURL(url), context.shouldCheckContentSecurityPolicy())); |
| 3660 uriValue->setReferrer(context.referrer()); | 3690 uriValue->setReferrer(context.referrer()); |
| 3661 | 3691 |
| 3662 if (range.peek().functionId() != CSSValueFormat) | 3692 if (range.peek().functionId() != CSSValueFormat) |
| 3663 return uriValue.release(); | 3693 return uriValue; |
| 3664 | 3694 |
| 3665 // FIXME: https://drafts.csswg.org/css-fonts says that format() contains a c
omma-separated list of strings, | 3695 // FIXME: https://drafts.csswg.org/css-fonts says that format() contains a c
omma-separated list of strings, |
| 3666 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. | 3696 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. |
| 3667 // FIXME: IdentToken should not be supported here. | 3697 // FIXME: IdentToken should not be supported here. |
| 3668 CSSParserTokenRange args = consumeFunction(range); | 3698 CSSParserTokenRange args = consumeFunction(range); |
| 3669 const CSSParserToken& arg = args.consumeIncludingWhitespace(); | 3699 const CSSParserToken& arg = args.consumeIncludingWhitespace(); |
| 3670 if ((arg.type() != StringToken && arg.type() != IdentToken) || !args.atEnd()
) | 3700 if ((arg.type() != StringToken && arg.type() != IdentToken) || !args.atEnd()
) |
| 3671 return nullptr; | 3701 return nullptr; |
| 3672 uriValue->setFormat(arg.value()); | 3702 uriValue->setFormat(arg.value()); |
| 3673 return uriValue.release(); | 3703 return uriValue; |
| 3674 } | 3704 } |
| 3675 | 3705 |
| 3676 static RawPtr<CSSValue> consumeFontFaceSrcLocal(CSSParserTokenRange& range, cons
t CSSParserContext& context) | 3706 static CSSValue* consumeFontFaceSrcLocal(CSSParserTokenRange& range, const CSSPa
rserContext& context) |
| 3677 { | 3707 { |
| 3678 CSSParserTokenRange args = consumeFunction(range); | 3708 CSSParserTokenRange args = consumeFunction(range); |
| 3679 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = context.
shouldCheckContentSecurityPolicy(); | 3709 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = context.
shouldCheckContentSecurityPolicy(); |
| 3680 if (args.peek().type() == StringToken) { | 3710 if (args.peek().type() == StringToken) { |
| 3681 const CSSParserToken& arg = args.consumeIncludingWhitespace(); | 3711 const CSSParserToken& arg = args.consumeIncludingWhitespace(); |
| 3682 if (!args.atEnd()) | 3712 if (!args.atEnd()) |
| 3683 return nullptr; | 3713 return nullptr; |
| 3684 return CSSFontFaceSrcValue::createLocal(arg.value(), shouldCheckContentS
ecurityPolicy); | 3714 return CSSFontFaceSrcValue::createLocal(arg.value(), shouldCheckContentS
ecurityPolicy); |
| 3685 } | 3715 } |
| 3686 if (args.peek().type() == IdentToken) { | 3716 if (args.peek().type() == IdentToken) { |
| 3687 String familyName = concatenateFamilyName(args); | 3717 String familyName = concatenateFamilyName(args); |
| 3688 if (!args.atEnd()) | 3718 if (!args.atEnd()) |
| 3689 return nullptr; | 3719 return nullptr; |
| 3690 return CSSFontFaceSrcValue::createLocal(familyName, shouldCheckContentSe
curityPolicy); | 3720 return CSSFontFaceSrcValue::createLocal(familyName, shouldCheckContentSe
curityPolicy); |
| 3691 } | 3721 } |
| 3692 return nullptr; | 3722 return nullptr; |
| 3693 } | 3723 } |
| 3694 | 3724 |
| 3695 static RawPtr<CSSValueList> consumeFontFaceSrc(CSSParserTokenRange& range, const
CSSParserContext& context) | 3725 static CSSValueList* consumeFontFaceSrc(CSSParserTokenRange& range, const CSSPar
serContext& context) |
| 3696 { | 3726 { |
| 3697 RawPtr<CSSValueList> values(CSSValueList::createCommaSeparated()); | 3727 CSSValueList* values = CSSValueList::createCommaSeparated(); |
| 3698 | 3728 |
| 3699 do { | 3729 do { |
| 3700 const CSSParserToken& token = range.peek(); | 3730 const CSSParserToken& token = range.peek(); |
| 3701 RawPtr<CSSValue> parsedValue = nullptr; | 3731 CSSValue* parsedValue = nullptr; |
| 3702 if (token.functionId() == CSSValueLocal) | 3732 if (token.functionId() == CSSValueLocal) |
| 3703 parsedValue = consumeFontFaceSrcLocal(range, context); | 3733 parsedValue = consumeFontFaceSrcLocal(range, context); |
| 3704 else | 3734 else |
| 3705 parsedValue = consumeFontFaceSrcURI(range, context); | 3735 parsedValue = consumeFontFaceSrcURI(range, context); |
| 3706 if (!parsedValue) | 3736 if (!parsedValue) |
| 3707 return nullptr; | 3737 return nullptr; |
| 3708 values->append(parsedValue); | 3738 values->append(parsedValue); |
| 3709 } while (consumeCommaIncludingWhitespace(range)); | 3739 } while (consumeCommaIncludingWhitespace(range)); |
| 3710 return values.release(); | 3740 return values; |
| 3711 } | 3741 } |
| 3712 | 3742 |
| 3713 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) | 3743 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) |
| 3714 { | 3744 { |
| 3715 RawPtr<CSSValue> parsedValue = nullptr; | 3745 CSSValue* parsedValue = nullptr; |
| 3716 switch (propId) { | 3746 switch (propId) { |
| 3717 case CSSPropertyFontFamily: | 3747 case CSSPropertyFontFamily: |
| 3718 if (consumeGenericFamily(m_range)) | 3748 if (consumeGenericFamily(m_range)) |
| 3719 return false; | 3749 return false; |
| 3720 parsedValue = consumeFamilyName(m_range); | 3750 parsedValue = consumeFamilyName(m_range); |
| 3721 break; | 3751 break; |
| 3722 case CSSPropertySrc: // This is a list of urls or local references. | 3752 case CSSPropertySrc: // This is a list of urls or local references. |
| 3723 parsedValue = consumeFontFaceSrc(m_range, m_context); | 3753 parsedValue = consumeFontFaceSrc(m_range, m_context); |
| 3724 break; | 3754 break; |
| 3725 case CSSPropertyUnicodeRange: | 3755 case CSSPropertyUnicodeRange: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3743 case CSSPropertyFontFeatureSettings: | 3773 case CSSPropertyFontFeatureSettings: |
| 3744 parsedValue = consumeFontFeatureSettings(m_range); | 3774 parsedValue = consumeFontFeatureSettings(m_range); |
| 3745 break; | 3775 break; |
| 3746 default: | 3776 default: |
| 3747 break; | 3777 break; |
| 3748 } | 3778 } |
| 3749 | 3779 |
| 3750 if (!parsedValue || !m_range.atEnd()) | 3780 if (!parsedValue || !m_range.atEnd()) |
| 3751 return false; | 3781 return false; |
| 3752 | 3782 |
| 3753 addProperty(propId, parsedValue.release(), false); | 3783 addProperty(propId, parsedValue, false); |
| 3754 return true; | 3784 return true; |
| 3755 } | 3785 } |
| 3756 | 3786 |
| 3757 bool CSSPropertyParser::consumeSystemFont(bool important) | 3787 bool CSSPropertyParser::consumeSystemFont(bool important) |
| 3758 { | 3788 { |
| 3759 CSSValueID systemFontID = m_range.consumeIncludingWhitespace().id(); | 3789 CSSValueID systemFontID = m_range.consumeIncludingWhitespace().id(); |
| 3760 ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar)
; | 3790 ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar)
; |
| 3761 if (!m_range.atEnd()) | 3791 if (!m_range.atEnd()) |
| 3762 return false; | 3792 return false; |
| 3763 | 3793 |
| 3764 FontStyle fontStyle = FontStyleNormal; | 3794 FontStyle fontStyle = FontStyleNormal; |
| 3765 FontWeight fontWeight = FontWeightNormal; | 3795 FontWeight fontWeight = FontWeightNormal; |
| 3766 float fontSize = 0; | 3796 float fontSize = 0; |
| 3767 AtomicString fontFamily; | 3797 AtomicString fontFamily; |
| 3768 LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz
e, fontFamily); | 3798 LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz
e, fontFamily); |
| 3769 | 3799 |
| 3770 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontS
tyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important); | 3800 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontS
tyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important); |
| 3771 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i
mportant); | 3801 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i
mportant); |
| 3772 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri
mitiveValue::UnitType::Pixels), important); | 3802 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri
mitiveValue::UnitType::Pixels), important); |
| 3773 RawPtr<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated(); | 3803 CSSValueList* fontFamilyList = CSSValueList::createCommaSeparated(); |
| 3774 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily)); | 3804 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily)); |
| 3775 addProperty(CSSPropertyFontFamily, fontFamilyList.release(), important); | 3805 addProperty(CSSPropertyFontFamily, fontFamilyList, important); |
| 3776 | 3806 |
| 3777 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); | 3807 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); |
| 3778 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); | 3808 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); |
| 3779 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV
alueNormal), important); | 3809 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV
alueNormal), important); |
| 3780 return true; | 3810 return true; |
| 3781 } | 3811 } |
| 3782 | 3812 |
| 3783 bool CSSPropertyParser::consumeFont(bool important) | 3813 bool CSSPropertyParser::consumeFont(bool important) |
| 3784 { | 3814 { |
| 3785 // Let's check if there is an inherit or initial somewhere in the shorthand. | 3815 // Let's check if there is an inherit or initial somewhere in the shorthand. |
| 3786 CSSParserTokenRange range = m_range; | 3816 CSSParserTokenRange range = m_range; |
| 3787 while (!range.atEnd()) { | 3817 while (!range.atEnd()) { |
| 3788 CSSValueID id = range.consumeIncludingWhitespace().id(); | 3818 CSSValueID id = range.consumeIncludingWhitespace().id(); |
| 3789 if (id == CSSValueInherit || id == CSSValueInitial) | 3819 if (id == CSSValueInherit || id == CSSValueInitial) |
| 3790 return false; | 3820 return false; |
| 3791 } | 3821 } |
| 3792 // Optional font-style, font-variant, font-stretch and font-weight. | 3822 // Optional font-style, font-variant, font-stretch and font-weight. |
| 3793 RawPtr<CSSPrimitiveValue> fontStyle = nullptr; | 3823 CSSPrimitiveValue* fontStyle = nullptr; |
| 3794 RawPtr<CSSPrimitiveValue> fontVariant = nullptr; | 3824 CSSPrimitiveValue* fontVariant = nullptr; |
| 3795 RawPtr<CSSPrimitiveValue> fontWeight = nullptr; | 3825 CSSPrimitiveValue* fontWeight = nullptr; |
| 3796 RawPtr<CSSPrimitiveValue> fontStretch = nullptr; | 3826 CSSPrimitiveValue* fontStretch = nullptr; |
| 3797 while (!m_range.atEnd()) { | 3827 while (!m_range.atEnd()) { |
| 3798 CSSValueID id = m_range.peek().id(); | 3828 CSSValueID id = m_range.peek().id(); |
| 3799 if (!fontStyle && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSS
PropertyFontStyle, id)) { | 3829 if (!fontStyle && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSS
PropertyFontStyle, id)) { |
| 3800 fontStyle = consumeIdent(m_range); | 3830 fontStyle = consumeIdent(m_range); |
| 3801 continue; | 3831 continue; |
| 3802 } | 3832 } |
| 3803 if (!fontVariant) { | 3833 if (!fontVariant) { |
| 3804 // Font variant in the shorthand is particular, it only accepts norm
al or small-caps. | 3834 // Font variant in the shorthand is particular, it only accepts norm
al or small-caps. |
| 3805 fontVariant = consumeFontVariant(m_range); | 3835 fontVariant = consumeFontVariant(m_range); |
| 3806 if (fontVariant) | 3836 if (fontVariant) |
| 3807 continue; | 3837 continue; |
| 3808 } | 3838 } |
| 3809 if (!fontWeight) { | 3839 if (!fontWeight) { |
| 3810 fontWeight = consumeFontWeight(m_range); | 3840 fontWeight = consumeFontWeight(m_range); |
| 3811 if (fontWeight) | 3841 if (fontWeight) |
| 3812 continue; | 3842 continue; |
| 3813 } | 3843 } |
| 3814 if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(C
SSPropertyFontStretch, id)) | 3844 if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(C
SSPropertyFontStretch, id)) |
| 3815 fontStretch = consumeIdent(m_range); | 3845 fontStretch = consumeIdent(m_range); |
| 3816 else | 3846 else |
| 3817 break; | 3847 break; |
| 3818 } | 3848 } |
| 3819 | 3849 |
| 3820 if (m_range.atEnd()) | 3850 if (m_range.atEnd()) |
| 3821 return false; | 3851 return false; |
| 3822 | 3852 |
| 3823 addProperty(CSSPropertyFontStyle, fontStyle ? fontStyle.release() : cssValue
Pool().createIdentifierValue(CSSValueNormal), important); | 3853 addProperty(CSSPropertyFontStyle, fontStyle ? fontStyle : cssValuePool().cre
ateIdentifierValue(CSSValueNormal), important); |
| 3824 addProperty(CSSPropertyFontVariant, fontVariant ? fontVariant.release() : cs
sValuePool().createIdentifierValue(CSSValueNormal), important); | 3854 addProperty(CSSPropertyFontVariant, fontVariant ? fontVariant : cssValuePool
().createIdentifierValue(CSSValueNormal), important); |
| 3825 addProperty(CSSPropertyFontWeight, fontWeight ? fontWeight.release() : cssVa
luePool().createIdentifierValue(CSSValueNormal), important); | 3855 addProperty(CSSPropertyFontWeight, fontWeight ? fontWeight : cssValuePool().
createIdentifierValue(CSSValueNormal), important); |
| 3826 addProperty(CSSPropertyFontStretch, fontStretch ? fontStretch.release() : cs
sValuePool().createIdentifierValue(CSSValueNormal), important); | 3856 addProperty(CSSPropertyFontStretch, fontStretch ? fontStretch : cssValuePool
().createIdentifierValue(CSSValueNormal), important); |
| 3827 | 3857 |
| 3828 // Now a font size _must_ come. | 3858 // Now a font size _must_ come. |
| 3829 RawPtr<CSSValue> fontSize = consumeFontSize(m_range, m_context.mode()); | 3859 CSSValue* fontSize = consumeFontSize(m_range, m_context.mode()); |
| 3830 if (!fontSize || m_range.atEnd()) | 3860 if (!fontSize || m_range.atEnd()) |
| 3831 return false; | 3861 return false; |
| 3832 | 3862 |
| 3833 addProperty(CSSPropertyFontSize, fontSize.release(), important); | 3863 addProperty(CSSPropertyFontSize, fontSize, important); |
| 3834 | 3864 |
| 3835 if (consumeSlashIncludingWhitespace(m_range)) { | 3865 if (consumeSlashIncludingWhitespace(m_range)) { |
| 3836 RawPtr<CSSPrimitiveValue> lineHeight = consumeLineHeight(m_range, m_cont
ext.mode()); | 3866 CSSPrimitiveValue* lineHeight = consumeLineHeight(m_range, m_context.mod
e()); |
| 3837 if (!lineHeight) | 3867 if (!lineHeight) |
| 3838 return false; | 3868 return false; |
| 3839 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); | 3869 addProperty(CSSPropertyLineHeight, lineHeight, important); |
| 3840 } else { | 3870 } else { |
| 3841 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important); | 3871 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important); |
| 3842 } | 3872 } |
| 3843 | 3873 |
| 3844 // Font family must come now. | 3874 // Font family must come now. |
| 3845 RawPtr<CSSValue> parsedFamilyValue = consumeFontFamily(m_range); | 3875 CSSValue* parsedFamilyValue = consumeFontFamily(m_range); |
| 3846 if (!parsedFamilyValue) | 3876 if (!parsedFamilyValue) |
| 3847 return false; | 3877 return false; |
| 3848 | 3878 |
| 3849 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); | 3879 addProperty(CSSPropertyFontFamily, parsedFamilyValue, important); |
| 3850 | 3880 |
| 3851 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that | 3881 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that |
| 3852 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values | 3882 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values |
| 3853 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. | 3883 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. |
| 3854 return m_range.atEnd(); | 3884 return m_range.atEnd(); |
| 3855 } | 3885 } |
| 3856 | 3886 |
| 3857 bool CSSPropertyParser::consumeBorderSpacing(bool important) | 3887 bool CSSPropertyParser::consumeBorderSpacing(bool important) |
| 3858 { | 3888 { |
| 3859 RawPtr<CSSValue> horizontalSpacing = consumeLength(m_range, m_context.mode()
, ValueRangeNonNegative, UnitlessQuirk::Allow); | 3889 CSSValue* horizontalSpacing = consumeLength(m_range, m_context.mode(), Value
RangeNonNegative, UnitlessQuirk::Allow); |
| 3860 if (!horizontalSpacing) | 3890 if (!horizontalSpacing) |
| 3861 return false; | 3891 return false; |
| 3862 RawPtr<CSSValue> verticalSpacing = horizontalSpacing; | 3892 CSSValue* verticalSpacing = horizontalSpacing; |
| 3863 if (!m_range.atEnd()) | 3893 if (!m_range.atEnd()) |
| 3864 verticalSpacing = consumeLength(m_range, m_context.mode(), ValueRangeNon
Negative, UnitlessQuirk::Allow); | 3894 verticalSpacing = consumeLength(m_range, m_context.mode(), ValueRangeNon
Negative, UnitlessQuirk::Allow); |
| 3865 if (!verticalSpacing || !m_range.atEnd()) | 3895 if (!verticalSpacing || !m_range.atEnd()) |
| 3866 return false; | 3896 return false; |
| 3867 addProperty(CSSPropertyWebkitBorderHorizontalSpacing, horizontalSpacing.rele
ase(), important); | 3897 addProperty(CSSPropertyWebkitBorderHorizontalSpacing, horizontalSpacing, imp
ortant); |
| 3868 addProperty(CSSPropertyWebkitBorderVerticalSpacing, verticalSpacing.release(
), important); | 3898 addProperty(CSSPropertyWebkitBorderVerticalSpacing, verticalSpacing, importa
nt); |
| 3869 return true; | 3899 return true; |
| 3870 } | 3900 } |
| 3871 | 3901 |
| 3872 static RawPtr<CSSValue> consumeSingleViewportDescriptor(CSSParserTokenRange& ran
ge, CSSPropertyID propId, CSSParserMode cssParserMode) | 3902 static CSSValue* consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSS
PropertyID propId, CSSParserMode cssParserMode) |
| 3873 { | 3903 { |
| 3874 CSSValueID id = range.peek().id(); | 3904 CSSValueID id = range.peek().id(); |
| 3875 switch (propId) { | 3905 switch (propId) { |
| 3876 case CSSPropertyMinWidth: | 3906 case CSSPropertyMinWidth: |
| 3877 case CSSPropertyMaxWidth: | 3907 case CSSPropertyMaxWidth: |
| 3878 case CSSPropertyMinHeight: | 3908 case CSSPropertyMinHeight: |
| 3879 case CSSPropertyMaxHeight: | 3909 case CSSPropertyMaxHeight: |
| 3880 if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom) | 3910 if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom) |
| 3881 return consumeIdent(range); | 3911 return consumeIdent(range); |
| 3882 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegativ
e); | 3912 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegativ
e); |
| 3883 case CSSPropertyMinZoom: | 3913 case CSSPropertyMinZoom: |
| 3884 case CSSPropertyMaxZoom: | 3914 case CSSPropertyMaxZoom: |
| 3885 case CSSPropertyZoom: { | 3915 case CSSPropertyZoom: { |
| 3886 if (id == CSSValueAuto) | 3916 if (id == CSSValueAuto) |
| 3887 return consumeIdent(range); | 3917 return consumeIdent(range); |
| 3888 RawPtr<CSSValue> parsedValue = consumeNumber(range, ValueRangeNonNegativ
e); | 3918 CSSValue* parsedValue = consumeNumber(range, ValueRangeNonNegative); |
| 3889 if (parsedValue) | 3919 if (parsedValue) |
| 3890 return parsedValue.release(); | 3920 return parsedValue; |
| 3891 return consumePercent(range, ValueRangeNonNegative); | 3921 return consumePercent(range, ValueRangeNonNegative); |
| 3892 } | 3922 } |
| 3893 case CSSPropertyUserZoom: | 3923 case CSSPropertyUserZoom: |
| 3894 return consumeIdent<CSSValueZoom, CSSValueFixed>(range); | 3924 return consumeIdent<CSSValueZoom, CSSValueFixed>(range); |
| 3895 case CSSPropertyOrientation: | 3925 case CSSPropertyOrientation: |
| 3896 return consumeIdent<CSSValueAuto, CSSValuePortrait, CSSValueLandscape>(r
ange); | 3926 return consumeIdent<CSSValueAuto, CSSValuePortrait, CSSValueLandscape>(r
ange); |
| 3897 default: | 3927 default: |
| 3898 ASSERT_NOT_REACHED(); | 3928 ASSERT_NOT_REACHED(); |
| 3899 break; | 3929 break; |
| 3900 } | 3930 } |
| 3901 | 3931 |
| 3902 ASSERT_NOT_REACHED(); | 3932 ASSERT_NOT_REACHED(); |
| 3903 return nullptr; | 3933 return nullptr; |
| 3904 } | 3934 } |
| 3905 | 3935 |
| 3906 bool CSSPropertyParser::parseViewportDescriptor(CSSPropertyID propId, bool impor
tant) | 3936 bool CSSPropertyParser::parseViewportDescriptor(CSSPropertyID propId, bool impor
tant) |
| 3907 { | 3937 { |
| 3908 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | 3938 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); |
| 3909 | 3939 |
| 3910 switch (propId) { | 3940 switch (propId) { |
| 3911 case CSSPropertyWidth: { | 3941 case CSSPropertyWidth: { |
| 3912 RawPtr<CSSValue> minWidth = consumeSingleViewportDescriptor(m_range, CSS
PropertyMinWidth, m_context.mode()); | 3942 CSSValue* minWidth = consumeSingleViewportDescriptor(m_range, CSSPropert
yMinWidth, m_context.mode()); |
| 3913 if (!minWidth) | 3943 if (!minWidth) |
| 3914 return false; | 3944 return false; |
| 3915 RawPtr<CSSValue> maxWidth = minWidth; | 3945 CSSValue* maxWidth = minWidth; |
| 3916 if (!m_range.atEnd()) | 3946 if (!m_range.atEnd()) |
| 3917 maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWi
dth, m_context.mode()); | 3947 maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWi
dth, m_context.mode()); |
| 3918 if (!maxWidth || !m_range.atEnd()) | 3948 if (!maxWidth || !m_range.atEnd()) |
| 3919 return false; | 3949 return false; |
| 3920 addProperty(CSSPropertyMinWidth, minWidth.release(), important); | 3950 addProperty(CSSPropertyMinWidth, minWidth, important); |
| 3921 addProperty(CSSPropertyMaxWidth, maxWidth.release(), important); | 3951 addProperty(CSSPropertyMaxWidth, maxWidth, important); |
| 3922 return true; | 3952 return true; |
| 3923 } | 3953 } |
| 3924 case CSSPropertyHeight: { | 3954 case CSSPropertyHeight: { |
| 3925 RawPtr<CSSValue> minHeight = consumeSingleViewportDescriptor(m_range, CS
SPropertyMinHeight, m_context.mode()); | 3955 CSSValue* minHeight = consumeSingleViewportDescriptor(m_range, CSSProper
tyMinHeight, m_context.mode()); |
| 3926 if (!minHeight) | 3956 if (!minHeight) |
| 3927 return false; | 3957 return false; |
| 3928 RawPtr<CSSValue> maxHeight = minHeight; | 3958 CSSValue* maxHeight = minHeight; |
| 3929 if (!m_range.atEnd()) | 3959 if (!m_range.atEnd()) |
| 3930 maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxH
eight, m_context.mode()); | 3960 maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxH
eight, m_context.mode()); |
| 3931 if (!maxHeight || !m_range.atEnd()) | 3961 if (!maxHeight || !m_range.atEnd()) |
| 3932 return false; | 3962 return false; |
| 3933 addProperty(CSSPropertyMinHeight, minHeight.release(), important); | 3963 addProperty(CSSPropertyMinHeight, minHeight, important); |
| 3934 addProperty(CSSPropertyMaxHeight, maxHeight.release(), important); | 3964 addProperty(CSSPropertyMaxHeight, maxHeight, important); |
| 3935 return true; | 3965 return true; |
| 3936 } | 3966 } |
| 3937 case CSSPropertyMinWidth: | 3967 case CSSPropertyMinWidth: |
| 3938 case CSSPropertyMaxWidth: | 3968 case CSSPropertyMaxWidth: |
| 3939 case CSSPropertyMinHeight: | 3969 case CSSPropertyMinHeight: |
| 3940 case CSSPropertyMaxHeight: | 3970 case CSSPropertyMaxHeight: |
| 3941 case CSSPropertyMinZoom: | 3971 case CSSPropertyMinZoom: |
| 3942 case CSSPropertyMaxZoom: | 3972 case CSSPropertyMaxZoom: |
| 3943 case CSSPropertyZoom: | 3973 case CSSPropertyZoom: |
| 3944 case CSSPropertyUserZoom: | 3974 case CSSPropertyUserZoom: |
| 3945 case CSSPropertyOrientation: { | 3975 case CSSPropertyOrientation: { |
| 3946 RawPtr<CSSValue> parsedValue = consumeSingleViewportDescriptor(m_range,
propId, m_context.mode()); | 3976 CSSValue* parsedValue = consumeSingleViewportDescriptor(m_range, propId,
m_context.mode()); |
| 3947 if (!parsedValue || !m_range.atEnd()) | 3977 if (!parsedValue || !m_range.atEnd()) |
| 3948 return false; | 3978 return false; |
| 3949 addProperty(propId, parsedValue.release(), important); | 3979 addProperty(propId, parsedValue, important); |
| 3950 return true; | 3980 return true; |
| 3951 } | 3981 } |
| 3952 default: | 3982 default: |
| 3953 return false; | 3983 return false; |
| 3954 } | 3984 } |
| 3955 } | 3985 } |
| 3956 | 3986 |
| 3957 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSParserMode
cssParserMode, RawPtr<CSSValue>& columnWidth, RawPtr<CSSValue>& columnCount) | 3987 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSParserMode
cssParserMode, CSSValue*& columnWidth, CSSValue*& columnCount) |
| 3958 { | 3988 { |
| 3959 if (range.peek().id() == CSSValueAuto) { | 3989 if (range.peek().id() == CSSValueAuto) { |
| 3960 consumeIdent(range); | 3990 consumeIdent(range); |
| 3961 return true; | 3991 return true; |
| 3962 } | 3992 } |
| 3963 if (!columnWidth) { | 3993 if (!columnWidth) { |
| 3964 if ((columnWidth = consumeColumnWidth(range))) | 3994 columnWidth = consumeColumnWidth(range); |
| 3995 if (columnWidth) |
| 3965 return true; | 3996 return true; |
| 3966 } | 3997 } |
| 3967 if (!columnCount) | 3998 if (!columnCount) |
| 3968 columnCount = consumeColumnCount(range); | 3999 columnCount = consumeColumnCount(range); |
| 3969 return columnCount; | 4000 return columnCount; |
| 3970 } | 4001 } |
| 3971 | 4002 |
| 3972 bool CSSPropertyParser::consumeColumns(bool important) | 4003 bool CSSPropertyParser::consumeColumns(bool important) |
| 3973 { | 4004 { |
| 3974 RawPtr<CSSValue> columnWidth = nullptr; | 4005 CSSValue* columnWidth = nullptr; |
| 3975 RawPtr<CSSValue> columnCount = nullptr; | 4006 CSSValue* columnCount = nullptr; |
| 3976 if (!consumeColumnWidthOrCount(m_range, m_context.mode(), columnWidth, colum
nCount)) | 4007 if (!consumeColumnWidthOrCount(m_range, m_context.mode(), columnWidth, colum
nCount)) |
| 3977 return false; | 4008 return false; |
| 3978 consumeColumnWidthOrCount(m_range, m_context.mode(), columnWidth, columnCoun
t); | 4009 consumeColumnWidthOrCount(m_range, m_context.mode(), columnWidth, columnCoun
t); |
| 3979 if (!m_range.atEnd()) | 4010 if (!m_range.atEnd()) |
| 3980 return false; | 4011 return false; |
| 3981 if (!columnWidth) | 4012 if (!columnWidth) |
| 3982 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); | 4013 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); |
| 3983 if (!columnCount) | 4014 if (!columnCount) |
| 3984 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); | 4015 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); |
| 3985 addProperty(CSSPropertyColumnWidth, columnWidth.release(), important); | 4016 addProperty(CSSPropertyColumnWidth, columnWidth, important); |
| 3986 addProperty(CSSPropertyColumnCount, columnCount.release(), important); | 4017 addProperty(CSSPropertyColumnCount, columnCount, important); |
| 3987 return true; | 4018 return true; |
| 3988 } | 4019 } |
| 3989 | 4020 |
| 3990 bool CSSPropertyParser::consumeShorthandGreedily(const StylePropertyShorthand& s
horthand, bool important) | 4021 bool CSSPropertyParser::consumeShorthandGreedily(const StylePropertyShorthand& s
horthand, bool important) |
| 3991 { | 4022 { |
| 3992 ASSERT(shorthand.length() <= 6); // Existing shorthands have at most 6 longh
ands. | 4023 ASSERT(shorthand.length() <= 6); // Existing shorthands have at most 6 longh
ands. |
| 3993 RawPtr<CSSValue> longhands[6] = { nullptr, nullptr, nullptr, nullptr, nullpt
r, nullptr }; | 4024 CSSValue* longhands[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, null
ptr }; |
| 3994 const CSSPropertyID* shorthandProperties = shorthand.properties(); | 4025 const CSSPropertyID* shorthandProperties = shorthand.properties(); |
| 3995 do { | 4026 do { |
| 3996 bool foundLonghand = false; | 4027 bool foundLonghand = false; |
| 3997 for (size_t i = 0; !foundLonghand && i < shorthand.length(); ++i) { | 4028 for (size_t i = 0; !foundLonghand && i < shorthand.length(); ++i) { |
| 3998 if (longhands[i]) | 4029 if (longhands[i]) |
| 3999 continue; | 4030 continue; |
| 4000 longhands[i] = parseSingleValue(shorthandProperties[i]); | 4031 longhands[i] = parseSingleValue(shorthandProperties[i]); |
| 4001 if (longhands[i]) | 4032 if (longhands[i]) |
| 4002 foundLonghand = true; | 4033 foundLonghand = true; |
| 4003 } | 4034 } |
| 4004 if (!foundLonghand) | 4035 if (!foundLonghand) |
| 4005 return false; | 4036 return false; |
| 4006 } while (!m_range.atEnd()); | 4037 } while (!m_range.atEnd()); |
| 4007 | 4038 |
| 4008 for (size_t i = 0; i < shorthand.length(); ++i) { | 4039 for (size_t i = 0; i < shorthand.length(); ++i) { |
| 4009 if (longhands[i]) | 4040 if (longhands[i]) |
| 4010 addProperty(shorthandProperties[i], longhands[i].release(), importan
t); | 4041 addProperty(shorthandProperties[i], longhands[i], important); |
| 4011 else | 4042 else |
| 4012 addProperty(shorthandProperties[i], cssValuePool().createImplicitIni
tialValue(), important); | 4043 addProperty(shorthandProperties[i], cssValuePool().createImplicitIni
tialValue(), important); |
| 4013 } | 4044 } |
| 4014 return true; | 4045 return true; |
| 4015 } | 4046 } |
| 4016 | 4047 |
| 4017 bool CSSPropertyParser::consumeFlex(bool important) | 4048 bool CSSPropertyParser::consumeFlex(bool important) |
| 4018 { | 4049 { |
| 4019 static const double unsetValue = -1; | 4050 static const double unsetValue = -1; |
| 4020 double flexGrow = unsetValue; | 4051 double flexGrow = unsetValue; |
| 4021 double flexShrink = unsetValue; | 4052 double flexShrink = unsetValue; |
| 4022 RawPtr<CSSPrimitiveValue> flexBasis = nullptr; | 4053 CSSPrimitiveValue* flexBasis = nullptr; |
| 4023 | 4054 |
| 4024 if (m_range.peek().id() == CSSValueNone) { | 4055 if (m_range.peek().id() == CSSValueNone) { |
| 4025 flexGrow = 0; | 4056 flexGrow = 0; |
| 4026 flexShrink = 0; | 4057 flexShrink = 0; |
| 4027 flexBasis = cssValuePool().createIdentifierValue(CSSValueAuto); | 4058 flexBasis = cssValuePool().createIdentifierValue(CSSValueAuto); |
| 4028 m_range.consumeIncludingWhitespace(); | 4059 m_range.consumeIncludingWhitespace(); |
| 4029 } else { | 4060 } else { |
| 4030 unsigned index = 0; | 4061 unsigned index = 0; |
| 4031 while (!m_range.atEnd() && index++ < 3) { | 4062 while (!m_range.atEnd() && index++ < 3) { |
| 4032 double num; | 4063 double num; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4063 if (!m_range.atEnd()) | 4094 if (!m_range.atEnd()) |
| 4064 return false; | 4095 return false; |
| 4065 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::UnitType::Number), important); | 4096 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::UnitType::Number), important); |
| 4066 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::UnitType::Number), important); | 4097 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::UnitType::Number), important); |
| 4067 addProperty(CSSPropertyFlexBasis, flexBasis, important); | 4098 addProperty(CSSPropertyFlexBasis, flexBasis, important); |
| 4068 return true; | 4099 return true; |
| 4069 } | 4100 } |
| 4070 | 4101 |
| 4071 bool CSSPropertyParser::consumeBorder(bool important) | 4102 bool CSSPropertyParser::consumeBorder(bool important) |
| 4072 { | 4103 { |
| 4073 RawPtr<CSSValue> width = nullptr; | 4104 CSSValue* width = nullptr; |
| 4074 RawPtr<CSSValue> style = nullptr; | 4105 CSSValue* style = nullptr; |
| 4075 RawPtr<CSSValue> color = nullptr; | 4106 CSSValue* color = nullptr; |
| 4076 | 4107 |
| 4077 while (!width || !style || !color) { | 4108 while (!width || !style || !color) { |
| 4078 if (!width && (width = consumeLineWidth(m_range, m_context.mode(), Unitl
essQuirk::Forbid))) | 4109 if (!width) { |
| 4079 continue; | 4110 width = consumeLineWidth(m_range, m_context.mode(), UnitlessQuirk::F
orbid); |
| 4080 if (!style && (style = parseSingleValue(CSSPropertyBorderLeftStyle))) | 4111 if (width) |
| 4081 continue; | 4112 continue; |
| 4082 if (!color && (color = consumeColor(m_range, m_context.mode()))) | 4113 } |
| 4083 continue; | 4114 if (!style) { |
| 4115 style = parseSingleValue(CSSPropertyBorderLeftStyle); |
| 4116 if (style) |
| 4117 continue; |
| 4118 } |
| 4119 if (!color) { |
| 4120 color = consumeColor(m_range, m_context.mode()); |
| 4121 if (color) |
| 4122 continue; |
| 4123 } |
| 4084 break; | 4124 break; |
| 4085 } | 4125 } |
| 4086 | 4126 |
| 4087 if (!width && !style && !color) | 4127 if (!width && !style && !color) |
| 4088 return false; | 4128 return false; |
| 4089 | 4129 |
| 4090 if (!width) | 4130 if (!width) |
| 4091 width = cssValuePool().createImplicitInitialValue(); | 4131 width = cssValuePool().createImplicitInitialValue(); |
| 4092 if (!style) | 4132 if (!style) |
| 4093 style = cssValuePool().createImplicitInitialValue(); | 4133 style = cssValuePool().createImplicitInitialValue(); |
| 4094 if (!color) | 4134 if (!color) |
| 4095 color = cssValuePool().createImplicitInitialValue(); | 4135 color = cssValuePool().createImplicitInitialValue(); |
| 4096 | 4136 |
| 4097 addExpandedPropertyForValue(CSSPropertyBorderWidth, width.release(), importa
nt); | 4137 addExpandedPropertyForValue(CSSPropertyBorderWidth, width, important); |
| 4098 addExpandedPropertyForValue(CSSPropertyBorderStyle, style.release(), importa
nt); | 4138 addExpandedPropertyForValue(CSSPropertyBorderStyle, style, important); |
| 4099 addExpandedPropertyForValue(CSSPropertyBorderColor, color.release(), importa
nt); | 4139 addExpandedPropertyForValue(CSSPropertyBorderColor, color, important); |
| 4100 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().createImp
licitInitialValue(), important); | 4140 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().createImp
licitInitialValue(), important); |
| 4101 | 4141 |
| 4102 return m_range.atEnd(); | 4142 return m_range.atEnd(); |
| 4103 } | 4143 } |
| 4104 | 4144 |
| 4105 bool CSSPropertyParser::consume4Values(const StylePropertyShorthand& shorthand,
bool important) | 4145 bool CSSPropertyParser::consume4Values(const StylePropertyShorthand& shorthand,
bool important) |
| 4106 { | 4146 { |
| 4107 ASSERT(shorthand.length() == 4); | 4147 ASSERT(shorthand.length() == 4); |
| 4108 const CSSPropertyID* longhands = shorthand.properties(); | 4148 const CSSPropertyID* longhands = shorthand.properties(); |
| 4109 RawPtr<CSSValue> top = parseSingleValue(longhands[0]); | 4149 CSSValue* top = parseSingleValue(longhands[0]); |
| 4110 if (!top) | 4150 if (!top) |
| 4111 return false; | 4151 return false; |
| 4112 | 4152 |
| 4113 RawPtr<CSSValue> right = nullptr; | 4153 CSSValue* right = parseSingleValue(longhands[1]); |
| 4114 RawPtr<CSSValue> bottom = nullptr; | 4154 CSSValue* bottom = nullptr; |
| 4115 RawPtr<CSSValue> left = nullptr; | 4155 CSSValue* left = nullptr; |
| 4116 if ((right = parseSingleValue(longhands[1]))) { | 4156 if (right) { |
| 4117 if ((bottom = parseSingleValue(longhands[2]))) | 4157 bottom = parseSingleValue(longhands[2]); |
| 4158 if (bottom) |
| 4118 left = parseSingleValue(longhands[3]); | 4159 left = parseSingleValue(longhands[3]); |
| 4119 } | 4160 } |
| 4120 | 4161 |
| 4121 if (!right) | 4162 if (!right) |
| 4122 right = top; | 4163 right = top; |
| 4123 if (!bottom) | 4164 if (!bottom) |
| 4124 bottom = top; | 4165 bottom = top; |
| 4125 if (!left) | 4166 if (!left) |
| 4126 left = right; | 4167 left = right; |
| 4127 | 4168 |
| 4128 addProperty(longhands[0], top.release(), important); | 4169 addProperty(longhands[0], top, important); |
| 4129 addProperty(longhands[1], right.release(), important); | 4170 addProperty(longhands[1], right, important); |
| 4130 addProperty(longhands[2], bottom.release(), important); | 4171 addProperty(longhands[2], bottom, important); |
| 4131 addProperty(longhands[3], left.release(), important); | 4172 addProperty(longhands[3], left, important); |
| 4132 | 4173 |
| 4133 return m_range.atEnd(); | 4174 return m_range.atEnd(); |
| 4134 } | 4175 } |
| 4135 | 4176 |
| 4136 bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool importan
t) | 4177 bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool importan
t) |
| 4137 { | 4178 { |
| 4138 RawPtr<CSSValue> source = nullptr; | 4179 CSSValue* source = nullptr; |
| 4139 RawPtr<CSSValue> slice = nullptr; | 4180 CSSValue* slice = nullptr; |
| 4140 RawPtr<CSSValue> width = nullptr; | 4181 CSSValue* width = nullptr; |
| 4141 RawPtr<CSSValue> outset = nullptr; | 4182 CSSValue* outset = nullptr; |
| 4142 RawPtr<CSSValue> repeat = nullptr; | 4183 CSSValue* repeat = nullptr; |
| 4143 if (consumeBorderImageComponents(property, m_range, m_context, source, slice
, width, outset, repeat)) { | 4184 if (consumeBorderImageComponents(property, m_range, m_context, source, slice
, width, outset, repeat)) { |
| 4144 switch (property) { | 4185 switch (property) { |
| 4145 case CSSPropertyWebkitMaskBoxImage: | 4186 case CSSPropertyWebkitMaskBoxImage: |
| 4146 addProperty(CSSPropertyWebkitMaskBoxImageSource, source ? source : c
ssValuePool().createImplicitInitialValue(), important); | 4187 addProperty(CSSPropertyWebkitMaskBoxImageSource, source ? source : c
ssValuePool().createImplicitInitialValue(), important); |
| 4147 addProperty(CSSPropertyWebkitMaskBoxImageSlice, slice ? slice : cssV
aluePool().createImplicitInitialValue(), important); | 4188 addProperty(CSSPropertyWebkitMaskBoxImageSlice, slice ? slice : cssV
aluePool().createImplicitInitialValue(), important); |
| 4148 addProperty(CSSPropertyWebkitMaskBoxImageWidth, width ? width : cssV
aluePool().createImplicitInitialValue(), important); | 4189 addProperty(CSSPropertyWebkitMaskBoxImageWidth, width ? width : cssV
aluePool().createImplicitInitialValue(), important); |
| 4149 addProperty(CSSPropertyWebkitMaskBoxImageOutset, outset ? outset : c
ssValuePool().createImplicitInitialValue(), important); | 4190 addProperty(CSSPropertyWebkitMaskBoxImageOutset, outset ? outset : c
ssValuePool().createImplicitInitialValue(), important); |
| 4150 addProperty(CSSPropertyWebkitMaskBoxImageRepeat, repeat ? repeat : c
ssValuePool().createImplicitInitialValue(), important); | 4191 addProperty(CSSPropertyWebkitMaskBoxImageRepeat, repeat ? repeat : c
ssValuePool().createImplicitInitialValue(), important); |
| 4151 return true; | 4192 return true; |
| 4152 case CSSPropertyBorderImage: | 4193 case CSSPropertyBorderImage: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4197 return CSSPropertyBreakBefore; | 4238 return CSSPropertyBreakBefore; |
| 4198 ASSERT(property == CSSPropertyPageBreakInside || property == CSSPropertyWebk
itColumnBreakInside); | 4239 ASSERT(property == CSSPropertyPageBreakInside || property == CSSPropertyWebk
itColumnBreakInside); |
| 4199 return CSSPropertyBreakInside; | 4240 return CSSPropertyBreakInside; |
| 4200 } | 4241 } |
| 4201 | 4242 |
| 4202 bool CSSPropertyParser::consumeLegacyBreakProperty(CSSPropertyID property, bool
important) | 4243 bool CSSPropertyParser::consumeLegacyBreakProperty(CSSPropertyID property, bool
important) |
| 4203 { | 4244 { |
| 4204 // The fragmentation spec says that page-break-(after|before|inside) are to
be treated as | 4245 // The fragmentation spec says that page-break-(after|before|inside) are to
be treated as |
| 4205 // shorthands for their break-(after|before|inside) counterparts. We'll do t
he same for the | 4246 // shorthands for their break-(after|before|inside) counterparts. We'll do t
he same for the |
| 4206 // non-standard properties -webkit-column-break-(after|before|inside). | 4247 // non-standard properties -webkit-column-break-(after|before|inside). |
| 4207 RawPtr<CSSPrimitiveValue> keyword = consumeIdent(m_range); | 4248 CSSPrimitiveValue* keyword = consumeIdent(m_range); |
| 4208 if (!keyword) | 4249 if (!keyword) |
| 4209 return false; | 4250 return false; |
| 4210 if (!m_range.atEnd()) | 4251 if (!m_range.atEnd()) |
| 4211 return false; | 4252 return false; |
| 4212 CSSValueID value = keyword->getValueID(); | 4253 CSSValueID value = keyword->getValueID(); |
| 4213 switch (property) { | 4254 switch (property) { |
| 4214 case CSSPropertyPageBreakAfter: | 4255 case CSSPropertyPageBreakAfter: |
| 4215 case CSSPropertyPageBreakBefore: | 4256 case CSSPropertyPageBreakBefore: |
| 4216 value = mapFromPageBreakBetween(value); | 4257 value = mapFromPageBreakBetween(value); |
| 4217 break; | 4258 break; |
| 4218 case CSSPropertyWebkitColumnBreakAfter: | 4259 case CSSPropertyWebkitColumnBreakAfter: |
| 4219 case CSSPropertyWebkitColumnBreakBefore: | 4260 case CSSPropertyWebkitColumnBreakBefore: |
| 4220 value = mapFromColumnBreakBetween(value); | 4261 value = mapFromColumnBreakBetween(value); |
| 4221 break; | 4262 break; |
| 4222 case CSSPropertyPageBreakInside: | 4263 case CSSPropertyPageBreakInside: |
| 4223 case CSSPropertyWebkitColumnBreakInside: | 4264 case CSSPropertyWebkitColumnBreakInside: |
| 4224 value = mapFromColumnOrPageBreakInside(value); | 4265 value = mapFromColumnOrPageBreakInside(value); |
| 4225 break; | 4266 break; |
| 4226 default: | 4267 default: |
| 4227 ASSERT_NOT_REACHED(); | 4268 ASSERT_NOT_REACHED(); |
| 4228 } | 4269 } |
| 4229 if (value == CSSValueInvalid) | 4270 if (value == CSSValueInvalid) |
| 4230 return false; | 4271 return false; |
| 4231 | 4272 |
| 4232 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); | 4273 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); |
| 4233 addProperty(genericBreakProperty, cssValuePool().createIdentifierValue(value
), important); | 4274 addProperty(genericBreakProperty, cssValuePool().createIdentifierValue(value
), important); |
| 4234 return true; | 4275 return true; |
| 4235 } | 4276 } |
| 4236 | 4277 |
| 4237 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParse
rContext& context, UnitlessQuirk unitless, RawPtr<CSSValue>& resultX, RawPtr<CSS
Value>& resultY) | 4278 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParse
rContext& context, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& result
Y) |
| 4238 { | 4279 { |
| 4239 do { | 4280 do { |
| 4240 RawPtr<CSSValue> positionX = nullptr; | 4281 CSSValue* positionX = nullptr; |
| 4241 RawPtr<CSSValue> positionY = nullptr; | 4282 CSSValue* positionY = nullptr; |
| 4242 if (!consumePosition(range, context.mode(), unitless, positionX, positio
nY)) | 4283 if (!consumePosition(range, context.mode(), unitless, positionX, positio
nY)) |
| 4243 return false; | 4284 return false; |
| 4244 addBackgroundValue(resultX, positionX); | 4285 addBackgroundValue(resultX, positionX); |
| 4245 addBackgroundValue(resultY, positionY); | 4286 addBackgroundValue(resultY, positionY); |
| 4246 } while (consumeCommaIncludingWhitespace(range)); | 4287 } while (consumeCommaIncludingWhitespace(range)); |
| 4247 return true; | 4288 return true; |
| 4248 } | 4289 } |
| 4249 | 4290 |
| 4250 static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, RawPtr<CSSVa
lue>& value1, RawPtr<CSSValue>& value2, bool& implicit) | 4291 static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, CSSValue*& v
alue1, CSSValue*& value2, bool& implicit) |
| 4251 { | 4292 { |
| 4252 if (consumeIdent<CSSValueRepeatX>(range)) { | 4293 if (consumeIdent<CSSValueRepeatX>(range)) { |
| 4253 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); | 4294 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); |
| 4254 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); | 4295 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); |
| 4255 implicit = true; | 4296 implicit = true; |
| 4256 return true; | 4297 return true; |
| 4257 } | 4298 } |
| 4258 if (consumeIdent<CSSValueRepeatY>(range)) { | 4299 if (consumeIdent<CSSValueRepeatY>(range)) { |
| 4259 value1 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); | 4300 value1 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); |
| 4260 value2 = cssValuePool().createIdentifierValue(CSSValueRepeat); | 4301 value2 = cssValuePool().createIdentifierValue(CSSValueRepeat); |
| 4261 implicit = true; | 4302 implicit = true; |
| 4262 return true; | 4303 return true; |
| 4263 } | 4304 } |
| 4264 value1 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSVa
lueSpace>(range); | 4305 value1 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSVa
lueSpace>(range); |
| 4265 if (!value1) | 4306 if (!value1) |
| 4266 return false; | 4307 return false; |
| 4267 | 4308 |
| 4268 value2 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSVa
lueSpace>(range); | 4309 value2 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSVa
lueSpace>(range); |
| 4269 if (!value2) { | 4310 if (!value2) { |
| 4270 value2 = value1; | 4311 value2 = value1; |
| 4271 implicit = true; | 4312 implicit = true; |
| 4272 } | 4313 } |
| 4273 return true; | 4314 return true; |
| 4274 } | 4315 } |
| 4275 | 4316 |
| 4276 static bool consumeRepeatStyle(CSSParserTokenRange& range, RawPtr<CSSValue>& res
ultX, RawPtr<CSSValue>& resultY, bool& implicit) | 4317 static bool consumeRepeatStyle(CSSParserTokenRange& range, CSSValue*& resultX, C
SSValue*& resultY, bool& implicit) |
| 4277 { | 4318 { |
| 4278 do { | 4319 do { |
| 4279 RawPtr<CSSValue> repeatX = nullptr; | 4320 CSSValue* repeatX = nullptr; |
| 4280 RawPtr<CSSValue> repeatY = nullptr; | 4321 CSSValue* repeatY = nullptr; |
| 4281 if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit)) | 4322 if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit)) |
| 4282 return false; | 4323 return false; |
| 4283 addBackgroundValue(resultX, repeatX); | 4324 addBackgroundValue(resultX, repeatX); |
| 4284 addBackgroundValue(resultY, repeatY); | 4325 addBackgroundValue(resultY, repeatY); |
| 4285 } while (consumeCommaIncludingWhitespace(range)); | 4326 } while (consumeCommaIncludingWhitespace(range)); |
| 4286 return true; | 4327 return true; |
| 4287 } | 4328 } |
| 4288 | 4329 |
| 4289 // Note: consumeBackgroundShorthand assumes y properties (for example background
-position-y) follow | 4330 // Note: consumeBackgroundShorthand assumes y properties (for example background
-position-y) follow |
| 4290 // the x properties in the shorthand array. | 4331 // the x properties in the shorthand array. |
| 4291 bool CSSPropertyParser::consumeBackgroundShorthand(const StylePropertyShorthand&
shorthand, bool important) | 4332 bool CSSPropertyParser::consumeBackgroundShorthand(const StylePropertyShorthand&
shorthand, bool important) |
| 4292 { | 4333 { |
| 4293 const unsigned longhandCount = shorthand.length(); | 4334 const unsigned longhandCount = shorthand.length(); |
| 4294 RawPtr<CSSValue> longhands[10]; | 4335 CSSValue* longhands[10]; |
| 4295 ASSERT(longhandCount <= 10); | 4336 ASSERT(longhandCount <= 10); |
| 4296 #if ENABLE(OILPAN) | 4337 #if ENABLE(OILPAN) |
| 4297 // Zero initialize the array of raw pointers. | 4338 // Zero initialize the array of raw pointers. |
| 4298 memset(&longhands, 0, sizeof(longhands)); | 4339 memset(&longhands, 0, sizeof(longhands)); |
| 4299 #endif | 4340 #endif |
| 4300 bool implicit = false; | 4341 bool implicit = false; |
| 4301 do { | 4342 do { |
| 4302 bool parsedLonghand[10] = { false }; | 4343 bool parsedLonghand[10] = { false }; |
| 4303 RawPtr<CSSValue> originValue = nullptr; | 4344 CSSValue* originValue = nullptr; |
| 4304 do { | 4345 do { |
| 4305 bool foundProperty = false; | 4346 bool foundProperty = false; |
| 4306 for (size_t i = 0; i < longhandCount; ++i) { | 4347 for (size_t i = 0; i < longhandCount; ++i) { |
| 4307 if (parsedLonghand[i]) | 4348 if (parsedLonghand[i]) |
| 4308 continue; | 4349 continue; |
| 4309 | 4350 |
| 4310 RawPtr<CSSValue> value = nullptr; | 4351 CSSValue* value = nullptr; |
| 4311 RawPtr<CSSValue> valueY = nullptr; | 4352 CSSValue* valueY = nullptr; |
| 4312 CSSPropertyID property = shorthand.properties()[i]; | 4353 CSSPropertyID property = shorthand.properties()[i]; |
| 4313 if (property == CSSPropertyBackgroundRepeatX || property == CSSP
ropertyWebkitMaskRepeatX) { | 4354 if (property == CSSPropertyBackgroundRepeatX || property == CSSP
ropertyWebkitMaskRepeatX) { |
| 4314 consumeRepeatStyleComponent(m_range, value, valueY, implicit
); | 4355 consumeRepeatStyleComponent(m_range, value, valueY, implicit
); |
| 4315 } else if (property == CSSPropertyBackgroundPositionX || propert
y == CSSPropertyWebkitMaskPositionX) { | 4356 } else if (property == CSSPropertyBackgroundPositionX || propert
y == CSSPropertyWebkitMaskPositionX) { |
| 4316 CSSParserTokenRange rangeCopy = m_range; | 4357 CSSParserTokenRange rangeCopy = m_range; |
| 4317 if (!consumePosition(rangeCopy, m_context.mode(), UnitlessQu
irk::Forbid, value, valueY)) | 4358 if (!consumePosition(rangeCopy, m_context.mode(), UnitlessQu
irk::Forbid, value, valueY)) |
| 4318 continue; | 4359 continue; |
| 4319 m_range = rangeCopy; | 4360 m_range = rangeCopy; |
| 4320 } else if (property == CSSPropertyBackgroundSize || property ==
CSSPropertyWebkitMaskSize) { | 4361 } else if (property == CSSPropertyBackgroundSize || property ==
CSSPropertyWebkitMaskSize) { |
| 4321 if (!consumeSlashIncludingWhitespace(m_range)) | 4362 if (!consumeSlashIncludingWhitespace(m_range)) |
| 4322 continue; | 4363 continue; |
| 4323 value = consumeBackgroundSize(property, m_range, m_context.m
ode()); | 4364 value = consumeBackgroundSize(property, m_range, m_context.m
ode()); |
| 4324 if (!value || !parsedLonghand[i - 1]) // Position must have
been parsed in the current layer. | 4365 if (!value || !parsedLonghand[i - 1]) // Position must have
been parsed in the current layer. |
| 4325 return false; | 4366 return false; |
| 4326 } else if (property == CSSPropertyBackgroundPositionY || propert
y == CSSPropertyBackgroundRepeatY | 4367 } else if (property == CSSPropertyBackgroundPositionY || propert
y == CSSPropertyBackgroundRepeatY |
| 4327 || property == CSSPropertyWebkitMaskPositionY || property ==
CSSPropertyWebkitMaskRepeatY) { | 4368 || property == CSSPropertyWebkitMaskPositionY || property ==
CSSPropertyWebkitMaskRepeatY) { |
| 4328 continue; | 4369 continue; |
| 4329 } else { | 4370 } else { |
| 4330 value = consumeBackgroundComponent(property, m_range, m_cont
ext); | 4371 value = consumeBackgroundComponent(property, m_range, m_cont
ext); |
| 4331 } | 4372 } |
| 4332 if (value) { | 4373 if (value) { |
| 4333 if (property == CSSPropertyBackgroundOrigin || property == C
SSPropertyWebkitMaskOrigin) | 4374 if (property == CSSPropertyBackgroundOrigin || property == C
SSPropertyWebkitMaskOrigin) |
| 4334 originValue = value; | 4375 originValue = value; |
| 4335 parsedLonghand[i] = true; | 4376 parsedLonghand[i] = true; |
| 4336 foundProperty = true; | 4377 foundProperty = true; |
| 4337 addBackgroundValue(longhands[i], value.release()); | 4378 addBackgroundValue(longhands[i], value); |
| 4338 if (valueY) { | 4379 if (valueY) { |
| 4339 parsedLonghand[i + 1] = true; | 4380 parsedLonghand[i + 1] = true; |
| 4340 addBackgroundValue(longhands[i + 1], valueY.release()); | 4381 addBackgroundValue(longhands[i + 1], valueY); |
| 4341 } | 4382 } |
| 4342 } | 4383 } |
| 4343 } | 4384 } |
| 4344 if (!foundProperty) | 4385 if (!foundProperty) |
| 4345 return false; | 4386 return false; |
| 4346 } while (!m_range.atEnd() && m_range.peek().type() != CommaToken); | 4387 } while (!m_range.atEnd() && m_range.peek().type() != CommaToken); |
| 4347 | 4388 |
| 4348 // TODO(timloh): This will make invalid longhands, see crbug.com/386459 | 4389 // TODO(timloh): This will make invalid longhands, see crbug.com/386459 |
| 4349 for (size_t i = 0; i < longhandCount; ++i) { | 4390 for (size_t i = 0; i < longhandCount; ++i) { |
| 4350 CSSPropertyID property = shorthand.properties()[i]; | 4391 CSSPropertyID property = shorthand.properties()[i]; |
| 4351 if (property == CSSPropertyBackgroundColor && !m_range.atEnd()) { | 4392 if (property == CSSPropertyBackgroundColor && !m_range.atEnd()) { |
| 4352 if (parsedLonghand[i]) | 4393 if (parsedLonghand[i]) |
| 4353 return false; // Colors are only allowed in the last layer. | 4394 return false; // Colors are only allowed in the last layer. |
| 4354 continue; | 4395 continue; |
| 4355 } | 4396 } |
| 4356 if ((property == CSSPropertyBackgroundClip || property == CSSPropert
yWebkitMaskClip) && !parsedLonghand[i] && originValue) { | 4397 if ((property == CSSPropertyBackgroundClip || property == CSSPropert
yWebkitMaskClip) && !parsedLonghand[i] && originValue) { |
| 4357 addBackgroundValue(longhands[i], originValue.release()); | 4398 addBackgroundValue(longhands[i], originValue); |
| 4358 continue; | 4399 continue; |
| 4359 } | 4400 } |
| 4360 if (!parsedLonghand[i]) | 4401 if (!parsedLonghand[i]) |
| 4361 addBackgroundValue(longhands[i], cssValuePool().createImplicitIn
itialValue()); | 4402 addBackgroundValue(longhands[i], cssValuePool().createImplicitIn
itialValue()); |
| 4362 } | 4403 } |
| 4363 } while (consumeCommaIncludingWhitespace(m_range)); | 4404 } while (consumeCommaIncludingWhitespace(m_range)); |
| 4364 if (!m_range.atEnd()) | 4405 if (!m_range.atEnd()) |
| 4365 return false; | 4406 return false; |
| 4366 | 4407 |
| 4367 for (size_t i = 0; i < longhandCount; ++i) { | 4408 for (size_t i = 0; i < longhandCount; ++i) { |
| 4368 CSSPropertyID property = shorthand.properties()[i]; | 4409 CSSPropertyID property = shorthand.properties()[i]; |
| 4369 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.u
seLegacyBackgroundSizeShorthandBehavior()) | 4410 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.u
seLegacyBackgroundSizeShorthandBehavior()) |
| 4370 continue; | 4411 continue; |
| 4371 addProperty(property, longhands[i].release(), important, implicit); | 4412 addProperty(property, longhands[i], important, implicit); |
| 4372 } | 4413 } |
| 4373 return true; | 4414 return true; |
| 4374 } | 4415 } |
| 4375 | 4416 |
| 4376 bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthand
Id, bool important) | 4417 bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthand
Id, bool important) |
| 4377 { | 4418 { |
| 4378 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4419 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 4379 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); | 4420 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); |
| 4380 ASSERT(shorthand.length() == 2); | 4421 ASSERT(shorthand.length() == 2); |
| 4381 RawPtr<CSSValue> startValue = consumeGridLine(m_range); | 4422 CSSValue* startValue = consumeGridLine(m_range); |
| 4382 if (!startValue) | 4423 if (!startValue) |
| 4383 return false; | 4424 return false; |
| 4384 | 4425 |
| 4385 RawPtr<CSSValue> endValue = nullptr; | 4426 CSSValue* endValue = nullptr; |
| 4386 if (consumeSlashIncludingWhitespace(m_range)) { | 4427 if (consumeSlashIncludingWhitespace(m_range)) { |
| 4387 endValue = consumeGridLine(m_range); | 4428 endValue = consumeGridLine(m_range); |
| 4388 if (!endValue) | 4429 if (!endValue) |
| 4389 return false; | 4430 return false; |
| 4390 } else { | 4431 } else { |
| 4391 endValue = startValue->isCustomIdentValue() ? startValue : cssValuePool(
).createIdentifierValue(CSSValueAuto); | 4432 endValue = startValue->isCustomIdentValue() ? startValue : cssValuePool(
).createIdentifierValue(CSSValueAuto); |
| 4392 } | 4433 } |
| 4393 if (!m_range.atEnd()) | 4434 if (!m_range.atEnd()) |
| 4394 return false; | 4435 return false; |
| 4395 addProperty(shorthand.properties()[0], startValue, important); | 4436 addProperty(shorthand.properties()[0], startValue, important); |
| 4396 addProperty(shorthand.properties()[1], endValue, important); | 4437 addProperty(shorthand.properties()[1], endValue, important); |
| 4397 return true; | 4438 return true; |
| 4398 } | 4439 } |
| 4399 | 4440 |
| 4400 bool CSSPropertyParser::consumeGridAreaShorthand(bool important) | 4441 bool CSSPropertyParser::consumeGridAreaShorthand(bool important) |
| 4401 { | 4442 { |
| 4402 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4443 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
| 4403 ASSERT(gridAreaShorthand().length() == 4); | 4444 ASSERT(gridAreaShorthand().length() == 4); |
| 4404 RawPtr<CSSValue> rowStartValue = consumeGridLine(m_range); | 4445 CSSValue* rowStartValue = consumeGridLine(m_range); |
| 4405 if (!rowStartValue) | 4446 if (!rowStartValue) |
| 4406 return false; | 4447 return false; |
| 4407 RawPtr<CSSValue> columnStartValue = nullptr; | 4448 CSSValue* columnStartValue = nullptr; |
| 4408 RawPtr<CSSValue> rowEndValue = nullptr; | 4449 CSSValue* rowEndValue = nullptr; |
| 4409 RawPtr<CSSValue> columnEndValue = nullptr; | 4450 CSSValue* columnEndValue = nullptr; |
| 4410 if (consumeSlashIncludingWhitespace(m_range)) { | 4451 if (consumeSlashIncludingWhitespace(m_range)) { |
| 4411 columnStartValue = consumeGridLine(m_range); | 4452 columnStartValue = consumeGridLine(m_range); |
| 4412 if (!columnStartValue) | 4453 if (!columnStartValue) |
| 4413 return false; | 4454 return false; |
| 4414 if (consumeSlashIncludingWhitespace(m_range)) { | 4455 if (consumeSlashIncludingWhitespace(m_range)) { |
| 4415 rowEndValue = consumeGridLine(m_range); | 4456 rowEndValue = consumeGridLine(m_range); |
| 4416 if (!rowEndValue) | 4457 if (!rowEndValue) |
| 4417 return false; | 4458 return false; |
| 4418 if (consumeSlashIncludingWhitespace(m_range)) { | 4459 if (consumeSlashIncludingWhitespace(m_range)) { |
| 4419 columnEndValue = consumeGridLine(m_range); | 4460 columnEndValue = consumeGridLine(m_range); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4443 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 4484 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 4444 | 4485 |
| 4445 CSSPropertyID oldShorthand = m_currentShorthand; | 4486 CSSPropertyID oldShorthand = m_currentShorthand; |
| 4446 // TODO(rob.buis): Remove this when the legacy property parser is gone | 4487 // TODO(rob.buis): Remove this when the legacy property parser is gone |
| 4447 m_currentShorthand = property; | 4488 m_currentShorthand = property; |
| 4448 switch (property) { | 4489 switch (property) { |
| 4449 case CSSPropertyWebkitMarginCollapse: { | 4490 case CSSPropertyWebkitMarginCollapse: { |
| 4450 CSSValueID id = m_range.consumeIncludingWhitespace().id(); | 4491 CSSValueID id = m_range.consumeIncludingWhitespace().id(); |
| 4451 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginBeforeCollapse, id)) | 4492 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginBeforeCollapse, id)) |
| 4452 return false; | 4493 return false; |
| 4453 RawPtr<CSSValue> beforeCollapse = cssValuePool().createIdentifierValue(i
d); | 4494 CSSValue* beforeCollapse = cssValuePool().createIdentifierValue(id); |
| 4454 addProperty(CSSPropertyWebkitMarginBeforeCollapse, beforeCollapse, impor
tant); | 4495 addProperty(CSSPropertyWebkitMarginBeforeCollapse, beforeCollapse, impor
tant); |
| 4455 if (m_range.atEnd()) { | 4496 if (m_range.atEnd()) { |
| 4456 addProperty(CSSPropertyWebkitMarginAfterCollapse, beforeCollapse, im
portant); | 4497 addProperty(CSSPropertyWebkitMarginAfterCollapse, beforeCollapse, im
portant); |
| 4457 return true; | 4498 return true; |
| 4458 } | 4499 } |
| 4459 id = m_range.consumeIncludingWhitespace().id(); | 4500 id = m_range.consumeIncludingWhitespace().id(); |
| 4460 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginAfterCollapse, id)) | 4501 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginAfterCollapse, id)) |
| 4461 return false; | 4502 return false; |
| 4462 addProperty(CSSPropertyWebkitMarginAfterCollapse, cssValuePool().createI
dentifierValue(id), important); | 4503 addProperty(CSSPropertyWebkitMarginAfterCollapse, cssValuePool().createI
dentifierValue(id), important); |
| 4463 return true; | 4504 return true; |
| 4464 } | 4505 } |
| 4465 case CSSPropertyOverflow: { | 4506 case CSSPropertyOverflow: { |
| 4466 CSSValueID id = m_range.consumeIncludingWhitespace().id(); | 4507 CSSValueID id = m_range.consumeIncludingWhitespace().id(); |
| 4467 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverf
lowY, id)) | 4508 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverf
lowY, id)) |
| 4468 return false; | 4509 return false; |
| 4469 if (!m_range.atEnd()) | 4510 if (!m_range.atEnd()) |
| 4470 return false; | 4511 return false; |
| 4471 RawPtr<CSSValue> overflowYValue = cssValuePool().createIdentifierValue(i
d); | 4512 CSSValue* overflowYValue = cssValuePool().createIdentifierValue(id); |
| 4472 | 4513 |
| 4473 RawPtr<CSSValue> overflowXValue = nullptr; | 4514 CSSValue* overflowXValue = nullptr; |
| 4474 | 4515 |
| 4475 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been | 4516 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been |
| 4476 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement | 4517 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement |
| 4477 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but | 4518 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but |
| 4478 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. | 4519 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. |
| 4479 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | 4520 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) |
| 4480 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); | 4521 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); |
| 4481 else | 4522 else |
| 4482 overflowXValue = overflowYValue; | 4523 overflowXValue = overflowYValue; |
| 4483 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); | 4524 addProperty(CSSPropertyOverflowX, overflowXValue, important); |
| 4484 addProperty(CSSPropertyOverflowY, overflowYValue.release(), important); | 4525 addProperty(CSSPropertyOverflowY, overflowYValue, important); |
| 4485 return true; | 4526 return true; |
| 4486 } | 4527 } |
| 4487 case CSSPropertyFont: { | 4528 case CSSPropertyFont: { |
| 4488 const CSSParserToken& token = m_range.peek(); | 4529 const CSSParserToken& token = m_range.peek(); |
| 4489 if (token.id() >= CSSValueCaption && token.id() <= CSSValueStatusBar) | 4530 if (token.id() >= CSSValueCaption && token.id() <= CSSValueStatusBar) |
| 4490 return consumeSystemFont(important); | 4531 return consumeSystemFont(important); |
| 4491 return consumeFont(important); | 4532 return consumeFont(important); |
| 4492 } | 4533 } |
| 4493 case CSSPropertyBorderSpacing: | 4534 case CSSPropertyBorderSpacing: |
| 4494 return consumeBorderSpacing(important); | 4535 return consumeBorderSpacing(important); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4518 return consumeShorthandGreedily(webkitBorderStartShorthand(), important)
; | 4559 return consumeShorthandGreedily(webkitBorderStartShorthand(), important)
; |
| 4519 case CSSPropertyWebkitBorderEnd: | 4560 case CSSPropertyWebkitBorderEnd: |
| 4520 return consumeShorthandGreedily(webkitBorderEndShorthand(), important); | 4561 return consumeShorthandGreedily(webkitBorderEndShorthand(), important); |
| 4521 case CSSPropertyWebkitBorderBefore: | 4562 case CSSPropertyWebkitBorderBefore: |
| 4522 return consumeShorthandGreedily(webkitBorderBeforeShorthand(), important
); | 4563 return consumeShorthandGreedily(webkitBorderBeforeShorthand(), important
); |
| 4523 case CSSPropertyWebkitBorderAfter: | 4564 case CSSPropertyWebkitBorderAfter: |
| 4524 return consumeShorthandGreedily(webkitBorderAfterShorthand(), important)
; | 4565 return consumeShorthandGreedily(webkitBorderAfterShorthand(), important)
; |
| 4525 case CSSPropertyWebkitTextStroke: | 4566 case CSSPropertyWebkitTextStroke: |
| 4526 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); | 4567 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); |
| 4527 case CSSPropertyMarker: { | 4568 case CSSPropertyMarker: { |
| 4528 RawPtr<CSSValue> marker = parseSingleValue(CSSPropertyMarkerStart); | 4569 CSSValue* marker = parseSingleValue(CSSPropertyMarkerStart); |
| 4529 if (!marker || !m_range.atEnd()) | 4570 if (!marker || !m_range.atEnd()) |
| 4530 return false; | 4571 return false; |
| 4531 addProperty(CSSPropertyMarkerStart, marker, important); | 4572 addProperty(CSSPropertyMarkerStart, marker, important); |
| 4532 addProperty(CSSPropertyMarkerMid, marker, important); | 4573 addProperty(CSSPropertyMarkerMid, marker, important); |
| 4533 addProperty(CSSPropertyMarkerEnd, marker.release(), important); | 4574 addProperty(CSSPropertyMarkerEnd, marker, important); |
| 4534 return true; | 4575 return true; |
| 4535 } | 4576 } |
| 4536 case CSSPropertyFlex: | 4577 case CSSPropertyFlex: |
| 4537 return consumeFlex(important); | 4578 return consumeFlex(important); |
| 4538 case CSSPropertyFlexFlow: | 4579 case CSSPropertyFlexFlow: |
| 4539 return consumeShorthandGreedily(flexFlowShorthand(), important); | 4580 return consumeShorthandGreedily(flexFlowShorthand(), important); |
| 4540 case CSSPropertyColumnRule: | 4581 case CSSPropertyColumnRule: |
| 4541 return consumeShorthandGreedily(columnRuleShorthand(), important); | 4582 return consumeShorthandGreedily(columnRuleShorthand(), important); |
| 4542 case CSSPropertyListStyle: | 4583 case CSSPropertyListStyle: |
| 4543 return consumeShorthandGreedily(listStyleShorthand(), important); | 4584 return consumeShorthandGreedily(listStyleShorthand(), important); |
| 4544 case CSSPropertyBorderRadius: { | 4585 case CSSPropertyBorderRadius: { |
| 4545 RawPtr<CSSPrimitiveValue> horizontalRadii[4]; | 4586 CSSPrimitiveValue* horizontalRadii[4]; |
| 4546 RawPtr<CSSPrimitiveValue> verticalRadii[4]; | 4587 CSSPrimitiveValue* verticalRadii[4]; |
| 4547 if (!consumeRadii(horizontalRadii, verticalRadii, m_range, m_context.mod
e(), unresolvedProperty == CSSPropertyAliasWebkitBorderRadius)) | 4588 if (!consumeRadii(horizontalRadii, verticalRadii, m_range, m_context.mod
e(), unresolvedProperty == CSSPropertyAliasWebkitBorderRadius)) |
| 4548 return false; | 4589 return false; |
| 4549 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(horizon
talRadii[0].release(), verticalRadii[0].release(), CSSValuePair::DropIdenticalVa
lues), important); | 4590 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(horizon
talRadii[0], verticalRadii[0], CSSValuePair::DropIdenticalValues), important); |
| 4550 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(horizo
ntalRadii[1].release(), verticalRadii[1].release(), CSSValuePair::DropIdenticalV
alues), important); | 4591 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(horizo
ntalRadii[1], verticalRadii[1], CSSValuePair::DropIdenticalValues), important); |
| 4551 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(hor
izontalRadii[2].release(), verticalRadii[2].release(), CSSValuePair::DropIdentic
alValues), important); | 4592 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(hor
izontalRadii[2], verticalRadii[2], CSSValuePair::DropIdenticalValues), important
); |
| 4552 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(hori
zontalRadii[3].release(), verticalRadii[3].release(), CSSValuePair::DropIdentica
lValues), important); | 4593 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(hori
zontalRadii[3], verticalRadii[3], CSSValuePair::DropIdenticalValues), important)
; |
| 4553 return true; | 4594 return true; |
| 4554 } | 4595 } |
| 4555 case CSSPropertyBorderColor: | 4596 case CSSPropertyBorderColor: |
| 4556 return consume4Values(borderColorShorthand(), important); | 4597 return consume4Values(borderColorShorthand(), important); |
| 4557 case CSSPropertyBorderStyle: | 4598 case CSSPropertyBorderStyle: |
| 4558 return consume4Values(borderStyleShorthand(), important); | 4599 return consume4Values(borderStyleShorthand(), important); |
| 4559 case CSSPropertyBorderWidth: | 4600 case CSSPropertyBorderWidth: |
| 4560 return consume4Values(borderWidthShorthand(), important); | 4601 return consume4Values(borderWidthShorthand(), important); |
| 4561 case CSSPropertyBorderTop: | 4602 case CSSPropertyBorderTop: |
| 4562 return consumeShorthandGreedily(borderTopShorthand(), important); | 4603 return consumeShorthandGreedily(borderTopShorthand(), important); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4573 return consumeBorderImage(property, important); | 4614 return consumeBorderImage(property, important); |
| 4574 case CSSPropertyPageBreakAfter: | 4615 case CSSPropertyPageBreakAfter: |
| 4575 case CSSPropertyPageBreakBefore: | 4616 case CSSPropertyPageBreakBefore: |
| 4576 case CSSPropertyPageBreakInside: | 4617 case CSSPropertyPageBreakInside: |
| 4577 case CSSPropertyWebkitColumnBreakAfter: | 4618 case CSSPropertyWebkitColumnBreakAfter: |
| 4578 case CSSPropertyWebkitColumnBreakBefore: | 4619 case CSSPropertyWebkitColumnBreakBefore: |
| 4579 case CSSPropertyWebkitColumnBreakInside: | 4620 case CSSPropertyWebkitColumnBreakInside: |
| 4580 return consumeLegacyBreakProperty(property, important); | 4621 return consumeLegacyBreakProperty(property, important); |
| 4581 case CSSPropertyWebkitMaskPosition: | 4622 case CSSPropertyWebkitMaskPosition: |
| 4582 case CSSPropertyBackgroundPosition: { | 4623 case CSSPropertyBackgroundPosition: { |
| 4583 RawPtr<CSSValue> resultX = nullptr; | 4624 CSSValue* resultX = nullptr; |
| 4584 RawPtr<CSSValue> resultY = nullptr; | 4625 CSSValue* resultY = nullptr; |
| 4585 if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow,
resultX, resultY) || !m_range.atEnd()) | 4626 if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow,
resultX, resultY) || !m_range.atEnd()) |
| 4586 return false; | 4627 return false; |
| 4587 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionX : CSSPropertyWebkitMaskPositionX, resultX.release(), important); | 4628 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionX : CSSPropertyWebkitMaskPositionX, resultX, important); |
| 4588 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionY : CSSPropertyWebkitMaskPositionY, resultY.release(), important); | 4629 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionY : CSSPropertyWebkitMaskPositionY, resultY, important); |
| 4589 return true; | 4630 return true; |
| 4590 } | 4631 } |
| 4591 case CSSPropertyBackgroundRepeat: | 4632 case CSSPropertyBackgroundRepeat: |
| 4592 case CSSPropertyWebkitMaskRepeat: { | 4633 case CSSPropertyWebkitMaskRepeat: { |
| 4593 RawPtr<CSSValue> resultX = nullptr; | 4634 CSSValue* resultX = nullptr; |
| 4594 RawPtr<CSSValue> resultY = nullptr; | 4635 CSSValue* resultY = nullptr; |
| 4595 bool implicit = false; | 4636 bool implicit = false; |
| 4596 if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range
.atEnd()) | 4637 if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range
.atEnd()) |
| 4597 return false; | 4638 return false; |
| 4598 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatX : CSSPropertyWebkitMaskRepeatX, resultX.release(), important, implici
t); | 4639 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatX : CSSPropertyWebkitMaskRepeatX, resultX, important, implicit); |
| 4599 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatY : CSSPropertyWebkitMaskRepeatY, resultY.release(), important, implici
t); | 4640 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatY : CSSPropertyWebkitMaskRepeatY, resultY, important, implicit); |
| 4600 return true; | 4641 return true; |
| 4601 } | 4642 } |
| 4602 case CSSPropertyBackground: | 4643 case CSSPropertyBackground: |
| 4603 return consumeBackgroundShorthand(backgroundShorthand(), important); | 4644 return consumeBackgroundShorthand(backgroundShorthand(), important); |
| 4604 case CSSPropertyWebkitMask: | 4645 case CSSPropertyWebkitMask: |
| 4605 return consumeBackgroundShorthand(webkitMaskShorthand(), important); | 4646 return consumeBackgroundShorthand(webkitMaskShorthand(), important); |
| 4606 case CSSPropertyGridGap: { | 4647 case CSSPropertyGridGap: { |
| 4607 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled() && shorthandForPro
perty(CSSPropertyGridGap).length() == 2); | 4648 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled() && shorthandForPro
perty(CSSPropertyGridGap).length() == 2); |
| 4608 RawPtr<CSSValue> rowGap = consumeLength(m_range, m_context.mode(), Value
RangeNonNegative); | 4649 CSSValue* rowGap = consumeLength(m_range, m_context.mode(), ValueRangeNo
nNegative); |
| 4609 RawPtr<CSSValue> columnGap = consumeLength(m_range, m_context.mode(), Va
lueRangeNonNegative); | 4650 CSSValue* columnGap = consumeLength(m_range, m_context.mode(), ValueRang
eNonNegative); |
| 4610 if (!rowGap || !m_range.atEnd()) | 4651 if (!rowGap || !m_range.atEnd()) |
| 4611 return false; | 4652 return false; |
| 4612 if (!columnGap) | 4653 if (!columnGap) |
| 4613 columnGap = rowGap; | 4654 columnGap = rowGap; |
| 4614 addProperty(CSSPropertyGridRowGap, rowGap.release(), important); | 4655 addProperty(CSSPropertyGridRowGap, rowGap, important); |
| 4615 addProperty(CSSPropertyGridColumnGap, columnGap.release(), important); | 4656 addProperty(CSSPropertyGridColumnGap, columnGap, important); |
| 4616 return true; | 4657 return true; |
| 4617 } | 4658 } |
| 4618 case CSSPropertyGridColumn: | 4659 case CSSPropertyGridColumn: |
| 4619 case CSSPropertyGridRow: | 4660 case CSSPropertyGridRow: |
| 4620 return consumeGridItemPositionShorthand(property, important); | 4661 return consumeGridItemPositionShorthand(property, important); |
| 4621 case CSSPropertyGridArea: | 4662 case CSSPropertyGridArea: |
| 4622 return consumeGridAreaShorthand(important); | 4663 return consumeGridAreaShorthand(important); |
| 4623 default: | 4664 default: |
| 4624 m_currentShorthand = oldShorthand; | 4665 m_currentShorthand = oldShorthand; |
| 4625 CSSParserValueList valueList(m_range); | 4666 CSSParserValueList valueList(m_range); |
| 4626 if (!valueList.size()) | 4667 if (!valueList.size()) |
| 4627 return false; | 4668 return false; |
| 4628 m_valueList = &valueList; | 4669 m_valueList = &valueList; |
| 4629 return legacyParseShorthand(unresolvedProperty, important); | 4670 return legacyParseShorthand(unresolvedProperty, important); |
| 4630 } | 4671 } |
| 4631 } | 4672 } |
| 4632 | 4673 |
| 4633 } // namespace blink | 4674 } // namespace blink |
| OLD | NEW |