OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // This doesn't count UA style sheets | 118 // This doesn't count UA style sheets |
119 if (parseSuccess && context.useCounter()) | 119 if (parseSuccess && context.useCounter()) |
120 context.useCounter()->count(context, unresolvedProperty); | 120 context.useCounter()->count(context, unresolvedProperty); |
121 | 121 |
122 if (!parseSuccess) | 122 if (!parseSuccess) |
123 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties
Size); | 123 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties
Size); |
124 | 124 |
125 return parseSuccess; | 125 return parseSuccess; |
126 } | 126 } |
127 | 127 |
128 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr
<CSSValue> value, bool important, bool implicit) | 128 void CSSPropertyParser::addProperty(CSSPropertyID propId, CSSValue value, bool i
mportant, bool implicit) |
129 { | 129 { |
130 ASSERT(!isPropertyAlias(propId)); | 130 ASSERT(!isPropertyAlias(propId)); |
131 | 131 |
132 int shorthandIndex = 0; | 132 int shorthandIndex = 0; |
133 bool setFromShorthand = false; | 133 bool setFromShorthand = false; |
134 | 134 |
135 if (m_currentShorthand) { | 135 if (m_currentShorthand) { |
136 Vector<StylePropertyShorthand, 4> shorthands; | 136 Vector<StylePropertyShorthand, 4> shorthands; |
137 getMatchingShorthandsForLonghand(propId, &shorthands); | 137 getMatchingShorthandsForLonghand(propId, &shorthands); |
138 // Viewport descriptors have width and height as shorthands, but it does
n't | 138 // Viewport descriptors have width and height as shorthands, but it does
n't |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); | 310 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); |
311 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); | 311 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); |
312 } | 312 } |
313 | 313 |
314 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveCustomIdentValue(CSSParserValue* value) | 314 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveCustomIdentValue(CSSParserValue* value) |
315 { | 315 { |
316 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); | 316 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); |
317 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST
OM_IDENT); | 317 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST
OM_IDENT); |
318 } | 318 } |
319 | 319 |
320 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi
thReferrer(const String& rawValue, const KURL& url) | 320 inline CSSValue CSSPropertyParser::createCSSImageValueWithReferrer(const String&
rawValue, const KURL& url) |
321 { | 321 { |
322 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur
l); | 322 CSSValue imageValue = CSSImageValue::create(rawValue, url); |
323 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); | 323 toCSSImageValue(imageValue).setReferrer(m_context.referrer()); |
324 return imageValue; | 324 return imageValue; |
325 } | 325 } |
326 | 326 |
327 static inline bool isComma(CSSParserValue* value) | 327 static inline bool isComma(CSSParserValue* value) |
328 { | 328 { |
329 ASSERT(value); | 329 ASSERT(value); |
330 return value->unit == CSSParserValue::Operator && value->iValue == ','; | 330 return value->unit == CSSParserValue::Operator && value->iValue == ','; |
331 } | 331 } |
332 | 332 |
333 static bool consumeComma(CSSParserValueList* valueList) | 333 static bool consumeComma(CSSParserValueList* valueList) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv
eValue::CSS_DPCM) | 392 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv
eValue::CSS_DPCM) |
393 return createPrimitiveNumericValue(value); | 393 return createPrimitiveNumericValue(value); |
394 if (value->unit >= CSSParserValue::Q_EMS) | 394 if (value->unit >= CSSParserValue::Q_EMS) |
395 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::CSS_EMS); | 395 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr
imitiveValue::CSS_EMS); |
396 if (isCalculation(value)) | 396 if (isCalculation(value)) |
397 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | 397 return CSSPrimitiveValue::create(m_parsedCalculation.release()); |
398 | 398 |
399 return nullptr; | 399 return nullptr; |
400 } | 400 } |
401 | 401 |
402 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtrWillBeRawPtr<CSSValue> prpValue, bool important) | 402 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, CSSVal
ue prpValue, bool important) |
403 { | 403 { |
404 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 404 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
405 unsigned shorthandLength = shorthand.length(); | 405 unsigned shorthandLength = shorthand.length(); |
406 if (!shorthandLength) { | 406 if (!shorthandLength) { |
407 addProperty(propId, prpValue, important); | 407 addProperty(propId, prpValue, important); |
408 return; | 408 return; |
409 } | 409 } |
410 | 410 |
411 RefPtrWillBeRawPtr<CSSValue> value = prpValue; | 411 CSSValue value = prpValue; |
412 ShorthandScope scope(this, propId); | 412 ShorthandScope scope(this, propId); |
413 const CSSPropertyID* longhands = shorthand.properties(); | 413 const CSSPropertyID* longhands = shorthand.properties(); |
414 for (unsigned i = 0; i < shorthandLength; ++i) | 414 for (unsigned i = 0; i < shorthandLength; ++i) |
415 addProperty(longhands[i], value, important); | 415 addProperty(longhands[i], value, important); |
416 } | 416 } |
417 | 417 |
418 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant) | 418 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
ant) |
419 { | 419 { |
420 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); | 420 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); |
421 | 421 |
(...skipping 28 matching lines...) Expand all Loading... |
450 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) | 450 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
451 return false; | 451 return false; |
452 if (m_valueList->next() && !inShorthand()) | 452 if (m_valueList->next() && !inShorthand()) |
453 return false; | 453 return false; |
454 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; | 454 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; |
455 return true; | 455 return true; |
456 } | 456 } |
457 | 457 |
458 bool validPrimitive = false; | 458 bool validPrimitive = false; |
459 Units unitless = FUnknown; | 459 Units unitless = FUnknown; |
460 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 460 NullableCSSValue parsedValue; |
461 | 461 |
462 switch (propId) { | 462 switch (propId) { |
463 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] | 463 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait
| landscape] ] |
464 parsedValue = parseSize(); | 464 parsedValue = parseSize(); |
465 break; | 465 break; |
466 case CSSPropertyQuotes: // [<string> <string>]+ | none | 466 case CSSPropertyQuotes: // [<string> <string>]+ | none |
467 if (id == CSSValueNone) | 467 if (id == CSSValueNone) |
468 validPrimitive = true; | 468 validPrimitive = true; |
469 else | 469 else |
470 parsedValue = parseQuotes(); | 470 parsedValue = parseQuotes(); |
(...skipping 11 matching lines...) Expand all Loading... |
482 break; | 482 break; |
483 | 483 |
484 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work | 484 /* Start of supported CSS properties with validation. This is needed for par
seShorthand to work |
485 * correctly and allows optimization in blink::applyRule(..) | 485 * correctly and allows optimization in blink::applyRule(..) |
486 */ | 486 */ |
487 case CSSPropertyOverflow: { | 487 case CSSPropertyOverflow: { |
488 ShorthandScope scope(this, propId); | 488 ShorthandScope scope(this, propId); |
489 if (num != 1 || !parseValue(CSSPropertyOverflowY, important)) | 489 if (num != 1 || !parseValue(CSSPropertyOverflowY, important)) |
490 return false; | 490 return false; |
491 | 491 |
492 RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr; | |
493 | |
494 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been | 492 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been |
495 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement | 493 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement |
496 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but | 494 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but |
497 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. | 495 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. |
| 496 NullableCSSValue overflowXValue; |
498 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | 497 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) |
499 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); | 498 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); |
500 else | 499 else |
501 overflowXValue = m_parsedProperties.last().value(); | 500 overflowXValue = m_parsedProperties.last().value(); |
502 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); | 501 addProperty(CSSPropertyOverflowX, *overflowXValue, important); |
503 return true; | 502 return true; |
504 } | 503 } |
505 | 504 |
506 case CSSPropertyTextAlign: | 505 case CSSPropertyTextAlign: |
507 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent | 506 // left | right | center | justify | -webkit-left | -webkit-right | -web
kit-center | -webkit-match-parent |
508 // | start | end | <string> | inherit | -webkit-auto (converted to start
) | 507 // | start | end | <string> | inherit | -webkit-auto (converted to start
) |
509 // FIXME: <string> not supported right now | 508 // FIXME: <string> not supported right now |
510 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { | 509 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id
== CSSValueStart || id == CSSValueEnd) { |
511 validPrimitive = true; | 510 validPrimitive = true; |
512 } | 511 } |
513 break; | 512 break; |
514 | 513 |
515 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2
00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit | 514 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2
00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit |
516 if (m_valueList->size() != 1) | 515 if (m_valueList->size() != 1) |
517 return false; | 516 return false; |
518 return parseFontWeight(important); | 517 return parseFontWeight(important); |
519 } | 518 } |
520 | 519 |
521 case CSSPropertyBorderSpacing: { | 520 case CSSPropertyBorderSpacing: { |
522 if (num == 1) { | 521 if (num == 1) { |
523 ShorthandScope scope(this, CSSPropertyBorderSpacing); | 522 ShorthandScope scope(this, CSSPropertyBorderSpacing); |
524 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)
) | 523 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)
) |
525 return false; | 524 return false; |
526 CSSValue* value = m_parsedProperties.last().value(); | 525 CSSValue value = m_parsedProperties.last().value(); |
527 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important
); | 526 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important
); |
528 return true; | 527 return true; |
529 } | 528 } |
530 else if (num == 2) { | 529 else if (num == 2) { |
531 ShorthandScope scope(this, CSSPropertyBorderSpacing); | 530 ShorthandScope scope(this, CSSPropertyBorderSpacing); |
532 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)
|| !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) | 531 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important)
|| !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) |
533 return false; | 532 return false; |
534 return true; | 533 return true; |
535 } | 534 } |
536 return false; | 535 return false; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 case CSSPropertyCursor: { | 601 case CSSPropertyCursor: { |
603 // Grammar defined by CSS3 UI and modified by CSS4 images: | 602 // Grammar defined by CSS3 UI and modified by CSS4 images: |
604 // [ [<image> [<x> <y>]?,]* | 603 // [ [<image> [<x> <y>]?,]* |
605 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | | 604 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | |
606 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | 605 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | |
607 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | | 606 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | |
608 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | | 607 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | |
609 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit | 608 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit |
610 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | 609 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; |
611 while (value) { | 610 while (value) { |
612 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | 611 NullableCSSValue image; |
613 if (value->unit == CSSPrimitiveValue::CSS_URI) { | 612 if (value->unit == CSSPrimitiveValue::CSS_URI) { |
614 String uri = value->string; | 613 String uri = value->string; |
615 if (!uri.isNull()) | 614 if (!uri.isNull()) |
616 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); | 615 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); |
617 } else if (value->unit == CSSParserValue::Function && value->functio
n->id == CSSValueWebkitImageSet) { | 616 } else if (value->unit == CSSParserValue::Function && value->functio
n->id == CSSValueWebkitImageSet) { |
618 image = parseImageSet(m_valueList); | 617 image = parseImageSet(m_valueList); |
619 if (!image) | 618 if (!image) |
620 break; | 619 break; |
621 } else | 620 } else |
622 break; | 621 break; |
(...skipping 11 matching lines...) Expand all Loading... |
634 return false; | 633 return false; |
635 if (nrcoords == 2) { | 634 if (nrcoords == 2) { |
636 hotSpotSpecified = true; | 635 hotSpotSpecified = true; |
637 hotSpot = IntPoint(coords[0], coords[1]); | 636 hotSpot = IntPoint(coords[0], coords[1]); |
638 } | 637 } |
639 | 638 |
640 if (!list) | 639 if (!list) |
641 list = CSSValueList::createCommaSeparated(); | 640 list = CSSValueList::createCommaSeparated(); |
642 | 641 |
643 if (image) | 642 if (image) |
644 list->append(CSSCursorImageValue::create(image, hotSpotSpecified
, hotSpot)); | 643 list->append(CSSCursorImageValue::create(*image, hotSpotSpecifie
d, hotSpot).get()); |
645 | 644 |
646 if (!consumeComma(m_valueList)) | 645 if (!consumeComma(m_valueList)) |
647 return false; | 646 return false; |
648 value = m_valueList->current(); | 647 value = m_valueList->current(); |
649 } | 648 } |
650 if (value && m_context.useCounter()) { | 649 if (value && m_context.useCounter()) { |
651 if (value->id == CSSValueWebkitZoomIn) | 650 if (value->id == CSSValueWebkitZoomIn) |
652 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); | 651 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); |
653 else if (value->id == CSSValueWebkitZoomOut) | 652 else if (value->id == CSSValueWebkitZoomOut) |
654 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut)
; | 653 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut)
; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 case CSSPropertyWebkitMaskImage: | 695 case CSSPropertyWebkitMaskImage: |
697 case CSSPropertyWebkitMaskOrigin: | 696 case CSSPropertyWebkitMaskOrigin: |
698 case CSSPropertyWebkitMaskPosition: | 697 case CSSPropertyWebkitMaskPosition: |
699 case CSSPropertyWebkitMaskPositionX: | 698 case CSSPropertyWebkitMaskPositionX: |
700 case CSSPropertyWebkitMaskPositionY: | 699 case CSSPropertyWebkitMaskPositionY: |
701 case CSSPropertyWebkitMaskSize: | 700 case CSSPropertyWebkitMaskSize: |
702 case CSSPropertyWebkitMaskRepeat: | 701 case CSSPropertyWebkitMaskRepeat: |
703 case CSSPropertyWebkitMaskRepeatX: | 702 case CSSPropertyWebkitMaskRepeatX: |
704 case CSSPropertyWebkitMaskRepeatY: | 703 case CSSPropertyWebkitMaskRepeatY: |
705 { | 704 { |
706 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; | 705 NullableCSSValue val1; |
707 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; | 706 NullableCSSValue val2; |
708 CSSPropertyID propId1, propId2; | 707 CSSPropertyID propId1, propId2; |
709 bool result = false; | 708 bool result = false; |
710 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2))
{ | 709 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2))
{ |
711 if (propId == CSSPropertyBackgroundPosition || | 710 if (propId == CSSPropertyBackgroundPosition || |
712 propId == CSSPropertyBackgroundRepeat || | 711 propId == CSSPropertyBackgroundRepeat || |
713 propId == CSSPropertyWebkitMaskPosition || | 712 propId == CSSPropertyWebkitMaskPosition || |
714 propId == CSSPropertyWebkitMaskRepeat) { | 713 propId == CSSPropertyWebkitMaskRepeat) { |
715 ShorthandScope scope(this, propId); | 714 ShorthandScope scope(this, propId); |
716 addProperty(propId1, val1.release(), important); | 715 addProperty(propId1, *val1, important); |
717 if (val2) | 716 if (val2) |
718 addProperty(propId2, val2.release(), important); | 717 addProperty(propId2, *val2, important); |
719 } else { | 718 } else { |
720 addProperty(propId1, val1.release(), important); | 719 addProperty(propId1, *val1, important); |
721 if (val2) | 720 if (val2) |
722 addProperty(propId2, val2.release(), important); | 721 addProperty(propId2, *val2, important); |
723 } | 722 } |
724 result = true; | 723 result = true; |
725 } | 724 } |
726 m_implicitShorthand = false; | 725 m_implicitShorthand = false; |
727 return result; | 726 return result; |
728 } | 727 } |
729 case CSSPropertyObjectPosition: | 728 case CSSPropertyObjectPosition: |
730 parsedValue = parseObjectPosition(); | 729 parsedValue = parseObjectPosition(); |
731 break; | 730 break; |
732 case CSSPropertyListStyleImage: // <uri> | none | inherit | 731 case CSSPropertyListStyleImage: // <uri> | none | inherit |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 case CSSPropertyUnicodeRange: | 924 case CSSPropertyUnicodeRange: |
926 /* @font-face only descriptors */ | 925 /* @font-face only descriptors */ |
927 break; | 926 break; |
928 | 927 |
929 /* CSS3 properties */ | 928 /* CSS3 properties */ |
930 | 929 |
931 case CSSPropertyBorderImage: | 930 case CSSPropertyBorderImage: |
932 case CSSPropertyWebkitMaskBoxImage: | 931 case CSSPropertyWebkitMaskBoxImage: |
933 return parseBorderImageShorthand(propId, important); | 932 return parseBorderImageShorthand(propId, important); |
934 case CSSPropertyWebkitBorderImage: { | 933 case CSSPropertyWebkitBorderImage: { |
935 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { | 934 if (NullableCSSValue result = parseBorderImage(propId)) { |
936 addProperty(propId, result, important); | 935 addProperty(propId, *result, important); |
937 return true; | 936 return true; |
938 } | 937 } |
939 return false; | 938 return false; |
940 } | 939 } |
941 | 940 |
942 case CSSPropertyBorderImageOutset: | 941 case CSSPropertyBorderImageOutset: |
943 case CSSPropertyWebkitMaskBoxImageOutset: { | 942 case CSSPropertyWebkitMaskBoxImageOutset: { |
944 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 943 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; |
945 if (parseBorderImageOutset(result)) { | 944 if (parseBorderImageOutset(result)) { |
946 addProperty(propId, result, important); | 945 addProperty(propId, result, important); |
947 return true; | 946 return true; |
948 } | 947 } |
949 break; | 948 break; |
950 } | 949 } |
951 case CSSPropertyBorderImageRepeat: | 950 case CSSPropertyBorderImageRepeat: |
952 case CSSPropertyWebkitMaskBoxImageRepeat: { | 951 case CSSPropertyWebkitMaskBoxImageRepeat: { |
953 RefPtrWillBeRawPtr<CSSValue> result = nullptr; | 952 NullableCSSValue result; |
954 if (parseBorderImageRepeat(result)) { | 953 if (parseBorderImageRepeat(result)) { |
955 addProperty(propId, result, important); | 954 addProperty(propId, *result, important); |
956 return true; | 955 return true; |
957 } | 956 } |
958 break; | 957 break; |
959 } | 958 } |
960 case CSSPropertyBorderImageSlice: | 959 case CSSPropertyBorderImageSlice: |
961 case CSSPropertyWebkitMaskBoxImageSlice: { | 960 case CSSPropertyWebkitMaskBoxImageSlice: { |
962 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr; | 961 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr; |
963 if (parseBorderImageSlice(propId, result)) { | 962 if (parseBorderImageSlice(propId, result)) { |
964 addProperty(propId, result, important); | 963 addProperty(propId, result, important); |
965 return true; | 964 return true; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 case CSSPropertyWebkitBoxFlexGroup: | 1038 case CSSPropertyWebkitBoxFlexGroup: |
1040 validPrimitive = validUnit(value, FInteger | FNonNeg); | 1039 validPrimitive = validUnit(value, FInteger | FNonNeg); |
1041 break; | 1040 break; |
1042 case CSSPropertyWebkitBoxOrdinalGroup: | 1041 case CSSPropertyWebkitBoxOrdinalGroup: |
1043 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; | 1042 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; |
1044 break; | 1043 break; |
1045 case CSSPropertyWebkitFilter: | 1044 case CSSPropertyWebkitFilter: |
1046 if (id == CSSValueNone) | 1045 if (id == CSSValueNone) |
1047 validPrimitive = true; | 1046 validPrimitive = true; |
1048 else { | 1047 else { |
1049 RefPtrWillBeRawPtr<CSSValue> val = parseFilter(); | 1048 NullableCSSValue val = parseFilter(); |
1050 if (val) { | 1049 if (val) { |
1051 addProperty(propId, val, important); | 1050 addProperty(propId, *val, important); |
1052 return true; | 1051 return true; |
1053 } | 1052 } |
1054 return false; | 1053 return false; |
1055 } | 1054 } |
1056 break; | 1055 break; |
1057 case CSSPropertyFlex: { | 1056 case CSSPropertyFlex: { |
1058 ShorthandScope scope(this, propId); | 1057 ShorthandScope scope(this, propId); |
1059 if (id == CSSValueNone) { | 1058 if (id == CSSValueNone) { |
1060 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr
imitiveValue::CSS_NUMBER), important); | 1059 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr
imitiveValue::CSS_NUMBER), important); |
1061 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS
PrimitiveValue::CSS_NUMBER), important); | 1060 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS
PrimitiveValue::CSS_NUMBER), important); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 | 1226 |
1228 case CSSPropertyGrid: | 1227 case CSSPropertyGrid: |
1229 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 1228 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
1230 return parseGridShorthand(important); | 1229 return parseGridShorthand(important); |
1231 | 1230 |
1232 case CSSPropertyWebkitMarginCollapse: { | 1231 case CSSPropertyWebkitMarginCollapse: { |
1233 if (num == 1) { | 1232 if (num == 1) { |
1234 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); | 1233 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); |
1235 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp
ortant)) | 1234 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp
ortant)) |
1236 return false; | 1235 return false; |
1237 CSSValue* value = m_parsedProperties.last().value(); | 1236 CSSValue value = m_parsedProperties.last().value(); |
1238 addProperty(webkitMarginCollapseShorthand().properties()[1], value,
important); | 1237 addProperty(webkitMarginCollapseShorthand().properties()[1], value,
important); |
1239 return true; | 1238 return true; |
1240 } | 1239 } |
1241 else if (num == 2) { | 1240 else if (num == 2) { |
1242 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); | 1241 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); |
1243 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp
ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan
t)) | 1242 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp
ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan
t)) |
1244 return false; | 1243 return false; |
1245 return true; | 1244 return true; |
1246 } | 1245 } |
1247 return false; | 1246 return false; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 else | 1437 else |
1439 return parseFontVariantLigatures(important); | 1438 return parseFontVariantLigatures(important); |
1440 break; | 1439 break; |
1441 case CSSPropertyWebkitClipPath: | 1440 case CSSPropertyWebkitClipPath: |
1442 if (id == CSSValueNone) { | 1441 if (id == CSSValueNone) { |
1443 validPrimitive = true; | 1442 validPrimitive = true; |
1444 } else if (value->unit == CSSParserValue::Function) { | 1443 } else if (value->unit == CSSParserValue::Function) { |
1445 parsedValue = parseBasicShape(); | 1444 parsedValue = parseBasicShape(); |
1446 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { | 1445 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
1447 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV
alue::CSS_URI); | 1446 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV
alue::CSS_URI); |
1448 addProperty(propId, parsedValue.release(), important); | 1447 addProperty(propId, *parsedValue, important); |
1449 return true; | 1448 return true; |
1450 } | 1449 } |
1451 break; | 1450 break; |
1452 case CSSPropertyShapeOutside: | 1451 case CSSPropertyShapeOutside: |
1453 if (id == CSSValueNone) | 1452 if (id == CSSValueNone) |
1454 validPrimitive = true; | 1453 validPrimitive = true; |
1455 else | 1454 else |
1456 parsedValue = parseShapeProperty(propId); | 1455 parsedValue = parseShapeProperty(propId); |
1457 break; | 1456 break; |
1458 case CSSPropertyShapeMargin: | 1457 case CSSPropertyShapeMargin: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 return parseSVGValue(propId, important); | 1498 return parseSVGValue(propId, important); |
1500 } | 1499 } |
1501 | 1500 |
1502 if (validPrimitive) { | 1501 if (validPrimitive) { |
1503 parsedValue = parseValidPrimitive(id, value); | 1502 parsedValue = parseValidPrimitive(id, value); |
1504 m_valueList->next(); | 1503 m_valueList->next(); |
1505 } | 1504 } |
1506 ASSERT(!m_parsedCalculation); | 1505 ASSERT(!m_parsedCalculation); |
1507 if (parsedValue) { | 1506 if (parsedValue) { |
1508 if (!m_valueList->current() || inShorthand()) { | 1507 if (!m_valueList->current() || inShorthand()) { |
1509 addProperty(propId, parsedValue.release(), important); | 1508 addProperty(propId, *parsedValue, important); |
1510 return true; | 1509 return true; |
1511 } | 1510 } |
1512 } | 1511 } |
1513 return false; | 1512 return false; |
1514 } | 1513 } |
1515 | 1514 |
1516 void CSSPropertyParser::addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRef
PtrWillBeRawPtr<CSSValue> rval) | 1515 void CSSPropertyParser::addFillValue(NullableCSSValue& lval, CSSValue rval) |
1517 { | 1516 { |
1518 if (lval) { | 1517 if (lval) { |
1519 if (lval->isBaseValueList()) | 1518 if (lval->isBaseValueList()) |
1520 toCSSValueList(lval.get())->append(rval); | 1519 toCSSValueList(lval)->append(rval); |
1521 else { | 1520 else { |
1522 PassRefPtrWillBeRawPtr<CSSValue> oldlVal(lval.release()); | |
1523 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm
aSeparated(); | 1521 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm
aSeparated(); |
1524 list->append(oldlVal); | 1522 list->append(*lval); |
1525 list->append(rval); | 1523 list->append(rval); |
1526 lval = list; | 1524 lval = list; |
1527 } | 1525 } |
1528 } | 1526 } |
1529 else | 1527 else |
1530 lval = rval; | 1528 lval = rval; |
1531 } | 1529 } |
1532 | 1530 |
1533 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtrWillBeRawPtr<
CSSValue>& cssValue) | 1531 static bool parseBackgroundClip(CSSParserValue* parserValue, NullableCSSValue& c
ssValue) |
1534 { | 1532 { |
1535 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi
ngBox | 1533 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi
ngBox |
1536 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW
ebkitText) { | 1534 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW
ebkitText) { |
1537 cssValue = cssValuePool().createIdentifierValue(parserValue->id); | 1535 cssValue = cssValuePool().createIdentifierValue(parserValue->id); |
1538 return true; | 1536 return true; |
1539 } | 1537 } |
1540 return false; | 1538 return false; |
1541 } | 1539 } |
1542 | 1540 |
1543 const int cMaxFillProperties = 9; | 1541 const int cMaxFillProperties = 9; |
1544 | 1542 |
1545 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper
tyID* properties, int numProperties, bool important) | 1543 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper
tyID* properties, int numProperties, bool important) |
1546 { | 1544 { |
1547 ASSERT(numProperties <= cMaxFillProperties); | 1545 ASSERT(numProperties <= cMaxFillProperties); |
1548 if (numProperties > cMaxFillProperties) | 1546 if (numProperties > cMaxFillProperties) |
1549 return false; | 1547 return false; |
1550 | 1548 |
1551 ShorthandScope scope(this, propId); | 1549 ShorthandScope scope(this, propId); |
1552 | 1550 |
1553 bool parsedProperty[cMaxFillProperties] = { false }; | 1551 bool parsedProperty[cMaxFillProperties] = { false }; |
1554 RefPtrWillBeRawPtr<CSSValue> values[cMaxFillProperties]; | 1552 NullableCSSValue values[cMaxFillProperties]; |
1555 #if ENABLE(OILPAN) | 1553 #if ENABLE(OILPAN) |
1556 // Zero initialize the array of raw pointers. | 1554 // Zero initialize the array of raw pointers. |
1557 memset(&values, 0, sizeof(values)); | 1555 memset(&values, 0, sizeof(values)); |
1558 #endif | 1556 #endif |
1559 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; | 1557 NullableCSSValue clipValue; |
1560 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; | 1558 NullableCSSValue positionYValue; |
1561 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; | 1559 NullableCSSValue repeatYValue; |
1562 bool foundClip = false; | 1560 bool foundClip = false; |
1563 int i; | 1561 int i; |
1564 bool foundPositionCSSProperty = false; | 1562 bool foundPositionCSSProperty = false; |
1565 | 1563 |
1566 while (m_valueList->current()) { | 1564 while (m_valueList->current()) { |
1567 CSSParserValue* val = m_valueList->current(); | 1565 CSSParserValue* val = m_valueList->current(); |
1568 if (isComma(val)) { | 1566 if (isComma(val)) { |
1569 // We hit the end. Fill in all remaining values with the initial va
lue. | 1567 // We hit the end. Fill in all remaining values with the initial va
lue. |
1570 m_valueList->next(); | 1568 m_valueList->next(); |
1571 for (i = 0; i < numProperties; ++i) { | 1569 for (i = 0; i < numProperties; ++i) { |
(...skipping 28 matching lines...) Expand all Loading... |
1600 foundPositionCSSProperty = false; | 1598 foundPositionCSSProperty = false; |
1601 bool found = false; | 1599 bool found = false; |
1602 for (i = 0; !found && i < numProperties; ++i) { | 1600 for (i = 0; !found && i < numProperties; ++i) { |
1603 | 1601 |
1604 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou
ndSize && properties[i] != CSSPropertyWebkitMaskSize)) | 1602 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou
ndSize && properties[i] != CSSPropertyWebkitMaskSize)) |
1605 continue; | 1603 continue; |
1606 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro
undSize || properties[i] == CSSPropertyWebkitMaskSize)) | 1604 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro
undSize || properties[i] == CSSPropertyWebkitMaskSize)) |
1607 continue; | 1605 continue; |
1608 | 1606 |
1609 if (!parsedProperty[i]) { | 1607 if (!parsedProperty[i]) { |
1610 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; | 1608 NullableCSSValue val1; |
1611 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; | 1609 NullableCSSValue val2; |
1612 CSSPropertyID propId1, propId2; | 1610 CSSPropertyID propId1, propId2; |
1613 CSSParserValue* parserValue = m_valueList->current(); | 1611 CSSParserValue* parserValue = m_valueList->current(); |
1614 // parseFillProperty() may modify m_implicitShorthand, so we MUS
T reset it | 1612 // parseFillProperty() may modify m_implicitShorthand, so we MUS
T reset it |
1615 // before EACH return below. | 1613 // before EACH return below. |
1616 if (parserValue && parseFillProperty(properties[i], propId1, pro
pId2, val1, val2)) { | 1614 if (parserValue && parseFillProperty(properties[i], propId1, pro
pId2, val1, val2)) { |
1617 parsedProperty[i] = found = true; | 1615 parsedProperty[i] = found = true; |
1618 addFillValue(values[i], val1.release()); | 1616 addFillValue(values[i], *val1); |
1619 if (properties[i] == CSSPropertyBackgroundPosition || proper
ties[i] == CSSPropertyWebkitMaskPosition) | 1617 if (properties[i] == CSSPropertyBackgroundPosition || proper
ties[i] == CSSPropertyWebkitMaskPosition) |
1620 addFillValue(positionYValue, val2.release()); | 1618 addFillValue(positionYValue, *val2); |
1621 if (properties[i] == CSSPropertyBackgroundRepeat || properti
es[i] == CSSPropertyWebkitMaskRepeat) | 1619 if (properties[i] == CSSPropertyBackgroundRepeat || properti
es[i] == CSSPropertyWebkitMaskRepeat) |
1622 addFillValue(repeatYValue, val2.release()); | 1620 addFillValue(repeatYValue, *val2); |
1623 if (properties[i] == CSSPropertyBackgroundOrigin || properti
es[i] == CSSPropertyWebkitMaskOrigin) { | 1621 if (properties[i] == CSSPropertyBackgroundOrigin || properti
es[i] == CSSPropertyWebkitMaskOrigin) { |
1624 // Reparse the value as a clip, and see if we succeed. | 1622 // Reparse the value as a clip, and see if we succeed. |
1625 if (parseBackgroundClip(parserValue, val1)) | 1623 if (parseBackgroundClip(parserValue, val1)) |
1626 addFillValue(clipValue, val1.release()); // The prop
erty parsed successfully. | 1624 addFillValue(clipValue, *val1); // The property pars
ed successfully. |
1627 else | 1625 else |
1628 addFillValue(clipValue, cssValuePool().createImplici
tInitialValue()); // Some value was used for origin that is not supported by cli
p. Just reset clip instead. | 1626 addFillValue(clipValue, cssValuePool().createImplici
tInitialValue()); // Some value was used for origin that is not supported by cli
p. Just reset clip instead. |
1629 } | 1627 } |
1630 if (properties[i] == CSSPropertyBackgroundClip || properties
[i] == CSSPropertyWebkitMaskClip) { | 1628 if (properties[i] == CSSPropertyBackgroundClip || properties
[i] == CSSPropertyWebkitMaskClip) { |
1631 // Update clipValue | 1629 // Update clipValue |
1632 addFillValue(clipValue, val1.release()); | 1630 addFillValue(clipValue, *val1); |
1633 foundClip = true; | 1631 foundClip = true; |
1634 } | 1632 } |
1635 if (properties[i] == CSSPropertyBackgroundPosition || proper
ties[i] == CSSPropertyWebkitMaskPosition) | 1633 if (properties[i] == CSSPropertyBackgroundPosition || proper
ties[i] == CSSPropertyWebkitMaskPosition) |
1636 foundPositionCSSProperty = true; | 1634 foundPositionCSSProperty = true; |
1637 } | 1635 } |
1638 } | 1636 } |
1639 } | 1637 } |
1640 | 1638 |
1641 // if we didn't find at least one match, this is an | 1639 // if we didn't find at least one match, this is an |
1642 // invalid shorthand and we have to ignore it | 1640 // invalid shorthand and we have to ignore it |
(...skipping 11 matching lines...) Expand all Loading... |
1654 if (properties[i] == CSSPropertyBackgroundPosition || properties[i]
== CSSPropertyWebkitMaskPosition) | 1652 if (properties[i] == CSSPropertyBackgroundPosition || properties[i]
== CSSPropertyWebkitMaskPosition) |
1655 addFillValue(positionYValue, cssValuePool().createImplicitInitia
lValue()); | 1653 addFillValue(positionYValue, cssValuePool().createImplicitInitia
lValue()); |
1656 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] ==
CSSPropertyWebkitMaskRepeat) | 1654 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] ==
CSSPropertyWebkitMaskRepeat) |
1657 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV
alue()); | 1655 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV
alue()); |
1658 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] ==
CSSPropertyWebkitMaskOrigin) { | 1656 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] ==
CSSPropertyWebkitMaskOrigin) { |
1659 // If background-origin wasn't present, then reset background-cl
ip also. | 1657 // If background-origin wasn't present, then reset background-cl
ip also. |
1660 addFillValue(clipValue, cssValuePool().createImplicitInitialValu
e()); | 1658 addFillValue(clipValue, cssValuePool().createImplicitInitialValu
e()); |
1661 } | 1659 } |
1662 } | 1660 } |
1663 if (properties[i] == CSSPropertyBackgroundPosition) { | 1661 if (properties[i] == CSSPropertyBackgroundPosition) { |
1664 addProperty(CSSPropertyBackgroundPositionX, values[i].release(), imp
ortant); | 1662 addProperty(CSSPropertyBackgroundPositionX, *values[i], important); |
1665 // it's OK to call positionYValue.release() since we only see CSSPro
pertyBackgroundPosition once | 1663 // it's OK to call positionYValue.release() since we only see CSSPro
pertyBackgroundPosition once |
1666 addProperty(CSSPropertyBackgroundPositionY, positionYValue.release()
, important); | 1664 addProperty(CSSPropertyBackgroundPositionY, *positionYValue, importa
nt); |
1667 } else if (properties[i] == CSSPropertyWebkitMaskPosition) { | 1665 } else if (properties[i] == CSSPropertyWebkitMaskPosition) { |
1668 addProperty(CSSPropertyWebkitMaskPositionX, values[i].release(), imp
ortant); | 1666 addProperty(CSSPropertyWebkitMaskPositionX, *values[i], important); |
1669 // it's OK to call positionYValue.release() since we only see CSSPro
pertyWebkitMaskPosition once | 1667 // it's OK to call positionYValue.release() since we only see CSSPro
pertyWebkitMaskPosition once |
1670 addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release()
, important); | 1668 addProperty(CSSPropertyWebkitMaskPositionY, *positionYValue, importa
nt); |
1671 } else if (properties[i] == CSSPropertyBackgroundRepeat) { | 1669 } else if (properties[i] == CSSPropertyBackgroundRepeat) { |
1672 addProperty(CSSPropertyBackgroundRepeatX, values[i].release(), impor
tant); | 1670 addProperty(CSSPropertyBackgroundRepeatX, *values[i], important); |
1673 // it's OK to call repeatYValue.release() since we only see CSSPrope
rtyBackgroundPosition once | 1671 // it's OK to call repeatYValue.release() since we only see CSSPrope
rtyBackgroundPosition once |
1674 addProperty(CSSPropertyBackgroundRepeatY, repeatYValue.release(), im
portant); | 1672 addProperty(CSSPropertyBackgroundRepeatY, *repeatYValue, important); |
1675 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) { | 1673 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) { |
1676 addProperty(CSSPropertyWebkitMaskRepeatX, values[i].release(), impor
tant); | 1674 addProperty(CSSPropertyWebkitMaskRepeatX, *values[i], important); |
1677 // it's OK to call repeatYValue.release() since we only see CSSPrope
rtyBackgroundPosition once | 1675 // it's OK to call repeatYValue.release() since we only see CSSPrope
rtyBackgroundPosition once |
1678 addProperty(CSSPropertyWebkitMaskRepeatY, repeatYValue.release(), im
portant); | 1676 addProperty(CSSPropertyWebkitMaskRepeatY, *repeatYValue, important); |
1679 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i]
== CSSPropertyWebkitMaskClip) && !foundClip) | 1677 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i]
== CSSPropertyWebkitMaskClip) && !foundClip) |
1680 // Value is already set while updating origin | 1678 // Value is already set while updating origin |
1681 continue; | 1679 continue; |
1682 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i
] && m_context.useLegacyBackgroundSizeShorthandBehavior()) | 1680 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i
] && m_context.useLegacyBackgroundSizeShorthandBehavior()) |
1683 continue; | 1681 continue; |
1684 else | 1682 else |
1685 addProperty(properties[i], values[i].release(), important); | 1683 addProperty(properties[i], *values[i], important); |
1686 | 1684 |
1687 // Add in clip values when we hit the corresponding origin property. | 1685 // Add in clip values when we hit the corresponding origin property. |
1688 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) | 1686 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) |
1689 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); | 1687 addProperty(CSSPropertyBackgroundClip, *clipValue, important); |
1690 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) | 1688 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) |
1691 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); | 1689 addProperty(CSSPropertyWebkitMaskClip, *clipValue, important); |
1692 } | 1690 } |
1693 | 1691 |
1694 m_implicitShorthand = false; | 1692 m_implicitShorthand = false; |
1695 return true; | 1693 return true; |
1696 } | 1694 } |
1697 | 1695 |
1698 static bool isValidTransitionPropertyList(CSSValueList* value) | 1696 static bool isValidTransitionPropertyList(CSSValueList* value) |
1699 { | 1697 { |
1700 if (value->length() < 2) | 1698 if (value->length() < 2) |
1701 return true; | 1699 return true; |
1702 for (auto& property : *value) { | 1700 for (auto& property : *value) { |
1703 // FIXME: Shorthand parsing shouldn't add initial to the list since it w
on't round-trip | 1701 // FIXME: Shorthand parsing shouldn't add initial to the list since it w
on't round-trip |
1704 if (property->isInitialValue()) | 1702 if (property.isInitialValue()) |
1705 continue; | 1703 continue; |
1706 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(property.get()); | 1704 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(property); |
1707 if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSVa
lueNone) | 1705 if (primitiveValue.isValueID() && primitiveValue.getValueID() == CSSValu
eNone) |
1708 return false; | 1706 return false; |
1709 } | 1707 } |
1710 return true; | 1708 return true; |
1711 } | 1709 } |
1712 | 1710 |
1713 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo
rtant) | 1711 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo
rtant) |
1714 { | 1712 { |
1715 const StylePropertyShorthand& animationProperties = animationShorthandForPar
sing(); | 1713 const StylePropertyShorthand& animationProperties = animationShorthandForPar
sing(); |
1716 const unsigned numProperties = 8; | 1714 const unsigned numProperties = 8; |
1717 | 1715 |
(...skipping 19 matching lines...) Expand all Loading... |
1737 parsedProperty[i] = false; | 1735 parsedProperty[i] = false; |
1738 } | 1736 } |
1739 if (!m_valueList->current()) | 1737 if (!m_valueList->current()) |
1740 break; | 1738 break; |
1741 } | 1739 } |
1742 | 1740 |
1743 bool found = false; | 1741 bool found = false; |
1744 for (size_t i = 0; i < numProperties; ++i) { | 1742 for (size_t i = 0; i < numProperties; ++i) { |
1745 if (parsedProperty[i]) | 1743 if (parsedProperty[i]) |
1746 continue; | 1744 continue; |
1747 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(animat
ionProperties.properties()[i], useLegacyparsing)) { | 1745 if (NullableCSSValue val = parseAnimationProperty(animationPropertie
s.properties()[i], useLegacyparsing)) { |
1748 parsedProperty[i] = found = true; | 1746 parsedProperty[i] = found = true; |
1749 values[i]->append(val.release()); | 1747 values[i]->append(*val); |
1750 break; | 1748 break; |
1751 } | 1749 } |
1752 } | 1750 } |
1753 | 1751 |
1754 // if we didn't find at least one match, this is an | 1752 // if we didn't find at least one match, this is an |
1755 // invalid shorthand and we have to ignore it | 1753 // invalid shorthand and we have to ignore it |
1756 if (!found) | 1754 if (!found) |
1757 return false; | 1755 return false; |
1758 } | 1756 } |
1759 | 1757 |
(...skipping 30 matching lines...) Expand all Loading... |
1790 parsedProperty[i] = false; | 1788 parsedProperty[i] = false; |
1791 } | 1789 } |
1792 if (!m_valueList->current()) | 1790 if (!m_valueList->current()) |
1793 break; | 1791 break; |
1794 } | 1792 } |
1795 | 1793 |
1796 bool found = false; | 1794 bool found = false; |
1797 for (size_t i = 0; i < numProperties; ++i) { | 1795 for (size_t i = 0; i < numProperties; ++i) { |
1798 if (parsedProperty[i]) | 1796 if (parsedProperty[i]) |
1799 continue; | 1797 continue; |
1800 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(shorth
and.properties()[i], false)) { | 1798 if (NullableCSSValue val = parseAnimationProperty(shorthand.properti
es()[i], false)) { |
1801 parsedProperty[i] = found = true; | 1799 parsedProperty[i] = found = true; |
1802 values[i]->append(val.release()); | 1800 values[i]->append(*val); |
1803 break; | 1801 break; |
1804 } | 1802 } |
1805 } | 1803 } |
1806 | 1804 |
1807 // if we didn't find at least one match, this is an | 1805 // if we didn't find at least one match, this is an |
1808 // invalid shorthand and we have to ignore it | 1806 // invalid shorthand and we have to ignore it |
1809 if (!found) | 1807 if (!found) |
1810 return false; | 1808 return false; |
1811 } | 1809 } |
1812 | 1810 |
1813 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); | 1811 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); |
1814 if (!isValidTransitionPropertyList(values[3].get())) | 1812 if (!isValidTransitionPropertyList(values[3].get())) |
1815 return false; | 1813 return false; |
1816 | 1814 |
1817 // Fill in any remaining properties with the initial value and add | 1815 // Fill in any remaining properties with the initial value and add |
1818 for (size_t i = 0; i < numProperties; ++i) { | 1816 for (size_t i = 0; i < numProperties; ++i) { |
1819 if (!parsedProperty[i]) | 1817 if (!parsedProperty[i]) |
1820 values[i]->append(cssValuePool().createImplicitInitialValue()); | 1818 values[i]->append(cssValuePool().createImplicitInitialValue()); |
1821 addProperty(shorthand.properties()[i], values[i].release(), important); | 1819 addProperty(shorthand.properties()[i], values[i].release(), important); |
1822 } | 1820 } |
1823 | 1821 |
1824 return true; | 1822 return true; |
1825 } | 1823 } |
1826 | 1824 |
1827 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() | 1825 NullableCSSValue CSSPropertyParser::parseColumnWidth() |
1828 { | 1826 { |
1829 CSSParserValue* value = m_valueList->current(); | 1827 CSSParserValue* value = m_valueList->current(); |
1830 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in | 1828 // Always parse lengths in strict mode here, since it would be ambiguous oth
erwise when used in |
1831 // the 'columns' shorthand property. | 1829 // the 'columns' shorthand property. |
1832 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { | 1830 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt
andardMode) && (m_parsedCalculation || value->fValue != 0))) { |
1833 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | 1831 CSSValue parsedValue = parseValidPrimitive(value->id, value); |
1834 m_valueList->next(); | 1832 m_valueList->next(); |
1835 return parsedValue; | 1833 return parsedValue; |
1836 } | 1834 } |
1837 return nullptr; | 1835 return nullptr; |
1838 } | 1836 } |
1839 | 1837 |
1840 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() | 1838 NullableCSSValue CSSPropertyParser::parseColumnCount() |
1841 { | 1839 { |
1842 CSSParserValue* value = m_valueList->current(); | 1840 CSSParserValue* value = m_valueList->current(); |
1843 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { | 1841 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { |
1844 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id
, value); | 1842 CSSValue parsedValue = parseValidPrimitive(value->id, value); |
1845 m_valueList->next(); | 1843 m_valueList->next(); |
1846 return parsedValue; | 1844 return parsedValue; |
1847 } | 1845 } |
1848 return nullptr; | 1846 return nullptr; |
1849 } | 1847 } |
1850 | 1848 |
1851 bool CSSPropertyParser::parseColumnsShorthand(bool important) | 1849 bool CSSPropertyParser::parseColumnsShorthand(bool important) |
1852 { | 1850 { |
1853 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; | 1851 NullableCSSValue columnWidth; |
1854 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; | 1852 NullableCSSValue columnCount; |
1855 bool hasPendingExplicitAuto = false; | 1853 bool hasPendingExplicitAuto = false; |
1856 | 1854 |
1857 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { | 1855 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur
rent(); propertiesParsed++) { |
1858 if (propertiesParsed >= 2) | 1856 if (propertiesParsed >= 2) |
1859 return false; // Too many values for this shorthand. Invalid declara
tion. | 1857 return false; // Too many values for this shorthand. Invalid declara
tion. |
1860 if (!propertiesParsed && value->id == CSSValueAuto) { | 1858 if (!propertiesParsed && value->id == CSSValueAuto) { |
1861 // 'auto' is a valid value for any of the two longhands, and at this
point we | 1859 // 'auto' is a valid value for any of the two longhands, and at this
point we |
1862 // don't know which one(s) it is meant for. We need to see if there
are other | 1860 // don't know which one(s) it is meant for. We need to see if there
are other |
1863 // values first. | 1861 // values first. |
1864 m_valueList->next(); | 1862 m_valueList->next(); |
(...skipping 21 matching lines...) Expand all Loading... |
1886 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); | 1884 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); |
1887 } else { | 1885 } else { |
1888 ASSERT(!columnCount); | 1886 ASSERT(!columnCount); |
1889 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); | 1887 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); |
1890 } | 1888 } |
1891 } | 1889 } |
1892 ASSERT(columnCount || columnWidth); | 1890 ASSERT(columnCount || columnWidth); |
1893 | 1891 |
1894 // Any unassigned property at this point will become implicit 'auto'. | 1892 // Any unassigned property at this point will become implicit 'auto'. |
1895 if (columnWidth) | 1893 if (columnWidth) |
1896 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); | 1894 addProperty(CSSPropertyWebkitColumnWidth, *columnWidth, important); |
1897 else | 1895 else |
1898 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); | 1896 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); |
1899 if (columnCount) | 1897 if (columnCount) |
1900 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); | 1898 addProperty(CSSPropertyWebkitColumnCount, *columnCount, important); |
1901 else | 1899 else |
1902 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); | 1900 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie
rValue(CSSValueAuto), important, true /* implicit */); |
1903 return true; | 1901 return true; |
1904 } | 1902 } |
1905 | 1903 |
1906 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) | 1904 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
Shorthand& shorthand, bool important) |
1907 { | 1905 { |
1908 // We try to match as many properties as possible | 1906 // We try to match as many properties as possible |
1909 // We set up an array of booleans to mark which property has been found, | 1907 // We set up an array of booleans to mark which property has been found, |
1910 // and we try to search for properties until it makes no longer any sense. | 1908 // and we try to search for properties until it makes no longer any sense. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 | 1960 |
1963 int num = inShorthand() ? 1 : m_valueList->size(); | 1961 int num = inShorthand() ? 1 : m_valueList->size(); |
1964 | 1962 |
1965 ShorthandScope scope(this, propId); | 1963 ShorthandScope scope(this, propId); |
1966 | 1964 |
1967 // the order is top, right, bottom, left | 1965 // the order is top, right, bottom, left |
1968 switch (num) { | 1966 switch (num) { |
1969 case 1: { | 1967 case 1: { |
1970 if (!parseValue(properties[0], important)) | 1968 if (!parseValue(properties[0], important)) |
1971 return false; | 1969 return false; |
1972 CSSValue* value = m_parsedProperties.last().value(); | 1970 CSSValue value = m_parsedProperties.last().value(); |
1973 ImplicitScope implicitScope(this); | 1971 ImplicitScope implicitScope(this); |
1974 addProperty(properties[1], value, important); | 1972 addProperty(properties[1], value, important); |
1975 addProperty(properties[2], value, important); | 1973 addProperty(properties[2], value, important); |
1976 addProperty(properties[3], value, important); | 1974 addProperty(properties[3], value, important); |
1977 break; | 1975 break; |
1978 } | 1976 } |
1979 case 2: { | 1977 case 2: { |
1980 if (!parseValue(properties[0], important) || !parseValue(properties[
1], important)) | 1978 if (!parseValue(properties[0], important) || !parseValue(properties[
1], important)) |
1981 return false; | 1979 return false; |
1982 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].
value(); | 1980 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v
alue(); |
1983 ImplicitScope implicitScope(this); | 1981 ImplicitScope implicitScope(this); |
1984 addProperty(properties[2], value, important); | 1982 addProperty(properties[2], value, important); |
1985 value = m_parsedProperties[m_parsedProperties.size() - 2].value(); | 1983 value = m_parsedProperties[m_parsedProperties.size() - 2].value(); |
1986 addProperty(properties[3], value, important); | 1984 addProperty(properties[3], value, important); |
1987 break; | 1985 break; |
1988 } | 1986 } |
1989 case 3: { | 1987 case 3: { |
1990 if (!parseValue(properties[0], important) || !parseValue(properties[
1], important) || !parseValue(properties[2], important)) | 1988 if (!parseValue(properties[0], important) || !parseValue(properties[
1], important) || !parseValue(properties[2], important)) |
1991 return false; | 1989 return false; |
1992 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].
value(); | 1990 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v
alue(); |
1993 ImplicitScope implicitScope(this); | 1991 ImplicitScope implicitScope(this); |
1994 addProperty(properties[3], value, important); | 1992 addProperty(properties[3], value, important); |
1995 break; | 1993 break; |
1996 } | 1994 } |
1997 case 4: { | 1995 case 4: { |
1998 if (!parseValue(properties[0], important) || !parseValue(properties[
1], important) || | 1996 if (!parseValue(properties[0], important) || !parseValue(properties[
1], important) || |
1999 !parseValue(properties[2], important) || !parseValue(properties[
3], important)) | 1997 !parseValue(properties[2], important) || !parseValue(properties[
3], important)) |
2000 return false; | 1998 return false; |
2001 break; | 1999 break; |
2002 } | 2000 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 parsedValues->append(createPrimitiveNumericValue(value)); | 2079 parsedValues->append(createPrimitiveNumericValue(value)); |
2082 return Length; | 2080 return Length; |
2083 } | 2081 } |
2084 return None; | 2082 return None; |
2085 default: | 2083 default: |
2086 return None; | 2084 return None; |
2087 } | 2085 } |
2088 } | 2086 } |
2089 | 2087 |
2090 // [ <string> <string> ]+ | none, but none is handled in parseValue | 2088 // [ <string> <string> ]+ | none, but none is handled in parseValue |
2091 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() | 2089 NullableCSSValue CSSPropertyParser::parseQuotes() |
2092 { | 2090 { |
2093 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 2091 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
2094 while (CSSParserValue* val = m_valueList->current()) { | 2092 while (CSSParserValue* val = m_valueList->current()) { |
2095 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2093 NullableCSSValue parsedValue; |
2096 if (val->unit != CSSPrimitiveValue::CSS_STRING) | 2094 if (val->unit != CSSPrimitiveValue::CSS_STRING) |
2097 return nullptr; | 2095 return nullptr; |
2098 parsedValue = createPrimitiveStringValue(val); | 2096 parsedValue = createPrimitiveStringValue(val); |
2099 values->append(parsedValue.release()); | 2097 values->append(*parsedValue); |
2100 m_valueList->next(); | 2098 m_valueList->next(); |
2101 } | 2099 } |
2102 if (values->length() && values->length() % 2 == 0) | 2100 if (values->length() && values->length() % 2 == 0) |
2103 return values.release(); | 2101 return values.release(); |
2104 return nullptr; | 2102 return nullptr; |
2105 } | 2103 } |
2106 | 2104 |
2107 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit | 2105 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open
-quote | no-close-quote ]+ | inherit |
2108 // in CSS 2.1 this got somewhat reduced: | 2106 // in CSS 2.1 this got somewhat reduced: |
2109 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 2107 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
2110 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() | 2108 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() |
2111 { | 2109 { |
2112 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 2110 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
2113 | 2111 |
2114 while (CSSParserValue* val = m_valueList->current()) { | 2112 while (CSSParserValue* val = m_valueList->current()) { |
2115 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2113 NullableCSSValue parsedValue; |
2116 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 2114 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
2117 // url | 2115 // url |
2118 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); | 2116 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); |
2119 } else if (val->unit == CSSParserValue::Function) { | 2117 } else if (val->unit == CSSParserValue::Function) { |
2120 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) | 2118 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) |
2121 CSSParserValueList* args = val->function->args.get(); | 2119 CSSParserValueList* args = val->function->args.get(); |
2122 if (!args) | 2120 if (!args) |
2123 return nullptr; | 2121 return nullptr; |
2124 if (val->function->id == CSSValueAttr) { | 2122 if (val->function->id == CSSValueAttr) { |
2125 parsedValue = parseAttr(args); | 2123 parsedValue = parseAttr(args); |
(...skipping 17 matching lines...) Expand all Loading... |
2143 case CSSValueNormal: | 2141 case CSSValueNormal: |
2144 parsedValue = cssValuePool().createIdentifierValue(val->id); | 2142 parsedValue = cssValuePool().createIdentifierValue(val->id); |
2145 default: | 2143 default: |
2146 break; | 2144 break; |
2147 } | 2145 } |
2148 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { | 2146 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { |
2149 parsedValue = createPrimitiveStringValue(val); | 2147 parsedValue = createPrimitiveStringValue(val); |
2150 } | 2148 } |
2151 if (!parsedValue) | 2149 if (!parsedValue) |
2152 return nullptr; | 2150 return nullptr; |
2153 values->append(parsedValue.release()); | 2151 values->append(*parsedValue); |
2154 m_valueList->next(); | 2152 m_valueList->next(); |
2155 } | 2153 } |
2156 | 2154 |
2157 return values.release(); | 2155 return values.release(); |
2158 } | 2156 } |
2159 | 2157 |
2160 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList
* args) | 2158 NullableCSSValue CSSPropertyParser::parseAttr(CSSParserValueList* args) |
2161 { | 2159 { |
2162 if (args->size() != 1) | 2160 if (args->size() != 1) |
2163 return nullptr; | 2161 return nullptr; |
2164 | 2162 |
2165 CSSParserValue* a = args->current(); | 2163 CSSParserValue* a = args->current(); |
2166 | 2164 |
2167 if (a->unit != CSSPrimitiveValue::CSS_IDENT) | 2165 if (a->unit != CSSPrimitiveValue::CSS_IDENT) |
2168 return nullptr; | 2166 return nullptr; |
2169 | 2167 |
2170 String attrName = a->string; | 2168 String attrName = a->string; |
2171 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". | 2169 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". |
2172 // But HTML attribute names can't have those characters, and we should not | 2170 // But HTML attribute names can't have those characters, and we should not |
2173 // even parse them inside attr(). | 2171 // even parse them inside attr(). |
2174 if (attrName[0] == '-') | 2172 if (attrName[0] == '-') |
2175 return nullptr; | 2173 return nullptr; |
2176 | 2174 |
2177 if (m_context.isHTMLDocument()) | 2175 if (m_context.isHTMLDocument()) |
2178 attrName = attrName.lower(); | 2176 attrName = attrName.lower(); |
2179 | 2177 |
2180 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); | 2178 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); |
2181 } | 2179 } |
2182 | 2180 |
2183 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBackgroundColor() | 2181 NullableCSSValue CSSPropertyParser::parseBackgroundColor() |
2184 { | 2182 { |
2185 CSSValueID id = m_valueList->current()->id; | 2183 CSSValueID id = m_valueList->current()->id; |
2186 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor || | 2184 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt
ext) || id == CSSValueMenu || id == CSSValueCurrentcolor || |
2187 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode())) | 2185 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode())) |
2188 return cssValuePool().createIdentifierValue(id); | 2186 return cssValuePool().createIdentifierValue(id); |
2189 return parseColor(); | 2187 return parseColor(); |
2190 } | 2188 } |
2191 | 2189 |
2192 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) | 2190 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, NullableCS
SValue& value) |
2193 { | 2191 { |
2194 if (valueList->current()->id == CSSValueNone) { | 2192 if (valueList->current()->id == CSSValueNone) { |
2195 value = cssValuePool().createIdentifierValue(CSSValueNone); | 2193 value = cssValuePool().createIdentifierValue(CSSValueNone); |
2196 return true; | 2194 return true; |
2197 } | 2195 } |
2198 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { | 2196 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { |
2199 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); | 2197 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); |
2200 return true; | 2198 return true; |
2201 } | 2199 } |
2202 | 2200 |
2203 if (isGeneratedImageValue(valueList->current())) | 2201 if (isGeneratedImageValue(valueList->current())) |
2204 return parseGeneratedImage(valueList, value); | 2202 return parseGeneratedImage(valueList, value); |
2205 | 2203 |
2206 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur
rent()->function->id == CSSValueWebkitImageSet) { | 2204 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur
rent()->function->id == CSSValueWebkitImageSet) { |
2207 value = parseImageSet(m_valueList); | 2205 value = parseImageSet(m_valueList); |
2208 if (value) | 2206 if (value) |
2209 return true; | 2207 return true; |
2210 } | 2208 } |
2211 | 2209 |
2212 return false; | 2210 return false; |
2213 } | 2211 } |
2214 | 2212 |
2215 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser
ValueList* valueList) | 2213 NullableCSSValue CSSPropertyParser::parseFillPositionX(CSSParserValueList* value
List) |
2216 { | 2214 { |
2217 int id = valueList->current()->id; | 2215 int id = valueList->current()->id; |
2218 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { | 2216 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { |
2219 int percent = 0; | 2217 int percent = 0; |
2220 if (id == CSSValueRight) | 2218 if (id == CSSValueRight) |
2221 percent = 100; | 2219 percent = 100; |
2222 else if (id == CSSValueCenter) | 2220 else if (id == CSSValueCenter) |
2223 percent = 50; | 2221 percent = 50; |
2224 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 2222 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
2225 } | 2223 } |
2226 if (validUnit(valueList->current(), FPercent | FLength)) | 2224 if (validUnit(valueList->current(), FPercent | FLength)) |
2227 return createPrimitiveNumericValue(valueList->current()); | 2225 return createPrimitiveNumericValue(valueList->current()); |
2228 return nullptr; | 2226 return nullptr; |
2229 } | 2227 } |
2230 | 2228 |
2231 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser
ValueList* valueList) | 2229 NullableCSSValue CSSPropertyParser::parseFillPositionY(CSSParserValueList* value
List) |
2232 { | 2230 { |
2233 int id = valueList->current()->id; | 2231 int id = valueList->current()->id; |
2234 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { | 2232 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { |
2235 int percent = 0; | 2233 int percent = 0; |
2236 if (id == CSSValueBottom) | 2234 if (id == CSSValueBottom) |
2237 percent = 100; | 2235 percent = 100; |
2238 else if (id == CSSValueCenter) | 2236 else if (id == CSSValueCenter) |
2239 percent = 50; | 2237 percent = 50; |
2240 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); | 2238 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN
TAGE); |
2241 } | 2239 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 return true; | 2300 return true; |
2303 | 2301 |
2304 return false; | 2302 return false; |
2305 } | 2303 } |
2306 | 2304 |
2307 static bool isFillPositionKeyword(CSSValueID value) | 2305 static bool isFillPositionKeyword(CSSValueID value) |
2308 { | 2306 { |
2309 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot
tom || value == CSSValueRight || value == CSSValueCenter; | 2307 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot
tom || value == CSSValueRight || value == CSSValueCenter; |
2310 } | 2308 } |
2311 | 2309 |
2312 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass
RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue2) | 2310 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList,
NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu
e2) |
2313 { | 2311 { |
2314 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce
ntage> | <length> ] | 2312 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce
ntage> | <length> ] |
2315 // In the case of 4 values <position> requires the second value to be a leng
th or a percentage. | 2313 // In the case of 4 values <position> requires the second value to be a leng
th or a percentage. |
2316 if (isFillPositionKeyword(parsedValue2->getValueID())) | 2314 if (isFillPositionKeyword(parsedValue2->getValueID())) |
2317 return; | 2315 return; |
2318 | 2316 |
2319 unsigned cumulativeFlags = 0; | 2317 unsigned cumulativeFlags = 0; |
2320 FillPositionFlag value3Flag = InvalidFillPosition; | 2318 FillPositionFlag value3Flag = InvalidFillPosition; |
2321 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va
lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); | 2319 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va
lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); |
2322 if (!value3) | 2320 if (!value3) |
(...skipping 27 matching lines...) Expand all Loading... |
2350 return; | 2348 return; |
2351 | 2349 |
2352 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); | 2350 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); |
2353 value2 = createPrimitiveValuePair(value3, value4); | 2351 value2 = createPrimitiveValuePair(value3, value4); |
2354 | 2352 |
2355 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) | 2353 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) |
2356 value1.swap(value2); | 2354 value1.swap(value2); |
2357 | 2355 |
2358 valueList->next(); | 2356 valueList->next(); |
2359 } | 2357 } |
2360 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass
RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue2) | 2358 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList,
NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu
e2) |
2361 { | 2359 { |
2362 unsigned cumulativeFlags = 0; | 2360 unsigned cumulativeFlags = 0; |
2363 FillPositionFlag value3Flag = InvalidFillPosition; | 2361 FillPositionFlag value3Flag = InvalidFillPosition; |
2364 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va
lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); | 2362 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va
lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); |
2365 | 2363 |
2366 // value3 is not an expected value, we return. | 2364 // value3 is not an expected value, we return. |
2367 if (!value3) | 2365 if (!value3) |
2368 return; | 2366 return; |
2369 | 2367 |
2370 valueList->next(); | 2368 valueList->next(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 return; | 2430 return; |
2433 | 2431 |
2434 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); | 2432 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); |
2435 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s
econdPositionKeyword), secondPositionValue); | 2433 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s
econdPositionKeyword), secondPositionValue); |
2436 } | 2434 } |
2437 | 2435 |
2438 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) | 2436 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) |
2439 value1.swap(value2); | 2437 value1.swap(value2); |
2440 | 2438 |
2441 #if ENABLE(ASSERT) | 2439 #if ENABLE(ASSERT) |
2442 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); | 2440 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1); |
2443 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); | 2441 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2); |
2444 ident1 = first->getPairValue()->first()->getValueID(); | 2442 ident1 = first->getPairValue()->first()->getValueID(); |
2445 ident2 = second->getPairValue()->first()->getValueID(); | 2443 ident2 = second->getPairValue()->first()->getValueID(); |
2446 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); | 2444 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); |
2447 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); | 2445 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); |
2448 #endif | 2446 #endif |
2449 } | 2447 } |
2450 | 2448 |
2451 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) | 2449 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) |
2452 { | 2450 { |
2453 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); | 2451 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); |
2454 } | 2452 } |
2455 | 2453 |
2456 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl
ess) | 2454 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, Nullabl
eCSSValue& value1, NullableCSSValue& value2, Units unitless) |
2457 { | 2455 { |
2458 unsigned numberOfValues = 0; | 2456 unsigned numberOfValues = 0; |
2459 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { | 2457 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n
umberOfValues) { |
2460 CSSParserValue* current = valueList->valueAt(i); | 2458 CSSParserValue* current = valueList->valueAt(i); |
2461 if (!current || isComma(current) || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) | 2459 if (!current || isComma(current) || isForwardSlashOperator(current) || !
isPotentialPositionValue(current)) |
2462 break; | 2460 break; |
2463 } | 2461 } |
2464 | 2462 |
2465 if (numberOfValues > 4) | 2463 if (numberOfValues > 4) |
2466 return; | 2464 return; |
(...skipping 22 matching lines...) Expand all Loading... |
2489 | 2487 |
2490 valueList->next(); | 2488 valueList->next(); |
2491 | 2489 |
2492 // In case we are parsing more than two values, relax the check inside of pa
rseFillPositionComponent. top 20px is | 2490 // In case we are parsing more than two values, relax the check inside of pa
rseFillPositionComponent. top 20px is |
2493 // a valid start for <position>. | 2491 // a valid start for <position>. |
2494 cumulativeFlags = AmbiguousFillPosition; | 2492 cumulativeFlags = AmbiguousFillPosition; |
2495 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag,
ResolveValuesAsKeyword); | 2493 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag,
ResolveValuesAsKeyword); |
2496 if (value2) | 2494 if (value2) |
2497 valueList->next(); | 2495 valueList->next(); |
2498 else { | 2496 else { |
2499 value1.clear(); | 2497 value1 = nullptr; |
2500 return; | 2498 return; |
2501 } | 2499 } |
2502 | 2500 |
2503 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val
ue1.get()); | 2501 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val
ue1); |
2504 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val
ue2.get()); | 2502 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val
ue2); |
2505 | 2503 |
2506 value1.clear(); | 2504 value1 = nullptr; |
2507 value2.clear(); | 2505 value2 = nullptr; |
2508 | 2506 |
2509 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. | 2507 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as
we have more arguments to follow. |
2510 if (parsedValue2->getValueID() == CSSValueCenter) | 2508 if (parsedValue2->getValueID() == CSSValueCenter) |
2511 return; | 2509 return; |
2512 | 2510 |
2513 if (numberOfValues == 3) | 2511 if (numberOfValues == 3) |
2514 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 2512 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed
Value2); |
2515 else | 2513 else |
2516 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release
(), parsedValue2.release()); | 2514 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed
Value2); |
2517 } | 2515 } |
2518 | 2516 |
2519 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Unit
s unitless) | 2517 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
NullableCSSValue& value1, NullableCSSValue& value2, Units unitless) |
2520 { | 2518 { |
2521 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. | 2519 // Parse the first value. We're just making sure that it is one of the vali
d keywords or a percentage/length. |
2522 unsigned cumulativeFlags = 0; | 2520 unsigned cumulativeFlags = 0; |
2523 FillPositionFlag value1Flag = InvalidFillPosition; | 2521 FillPositionFlag value1Flag = InvalidFillPosition; |
2524 FillPositionFlag value2Flag = InvalidFillPosition; | 2522 FillPositionFlag value2Flag = InvalidFillPosition; |
2525 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); | 2523 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag,
ResolveValuesAsPercent, unitless); |
2526 if (!value1) | 2524 if (!value1) |
2527 return; | 2525 return; |
2528 | 2526 |
2529 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we | 2527 // It only takes one value for background-position to be correctly parsed if
it was specified in a shorthand (since we |
2530 // can assume that any other values belong to the rest of the shorthand). I
f we're not parsing a shorthand, though, the | 2528 // can assume that any other values belong to the rest of the shorthand). I
f we're not parsing a shorthand, though, the |
2531 // value was explicitly specified for our property. | 2529 // value was explicitly specified for our property. |
2532 CSSParserValue* value = valueList->next(); | 2530 CSSParserValue* value = valueList->next(); |
2533 | 2531 |
2534 // First check for the comma. If so, we are finished parsing this value or
value pair. | 2532 // First check for the comma. If so, we are finished parsing this value or
value pair. |
2535 if (value && isComma(value)) | 2533 if (value && isComma(value)) |
2536 value = 0; | 2534 value = 0; |
2537 | 2535 |
2538 if (value) { | 2536 if (value) { |
2539 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl
ag, ResolveValuesAsPercent, unitless); | 2537 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl
ag, ResolveValuesAsPercent, unitless); |
2540 if (value2) | 2538 if (value2) |
2541 valueList->next(); | 2539 valueList->next(); |
2542 else { | 2540 else { |
2543 if (!inShorthand()) { | 2541 if (!inShorthand()) { |
2544 value1.clear(); | 2542 value1 = nullptr; |
2545 return; | 2543 return; |
2546 } | 2544 } |
2547 } | 2545 } |
2548 } | 2546 } |
2549 | 2547 |
2550 if (!value2) | 2548 if (!value2) |
2551 // Only one value was specified. If that value was not a keyword, then i
t sets the x position, and the y position | 2549 // Only one value was specified. If that value was not a keyword, then i
t sets the x position, and the y position |
2552 // is simply 50%. This is our default. | 2550 // is simply 50%. This is our default. |
2553 // For keywords, the keyword was either an x-keyword (left/right), a y-k
eyword (top/bottom), or an ambiguous keyword (center). | 2551 // For keywords, the keyword was either an x-keyword (left/right), a y-k
eyword (top/bottom), or an ambiguous keyword (center). |
2554 // For left/right/center, the default of 50% in the y is still correct. | 2552 // For left/right/center, the default of 50% in the y is still correct. |
2555 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG
E); | 2553 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG
E); |
2556 | 2554 |
2557 if (value1Flag == YFillPosition || value2Flag == XFillPosition) | 2555 if (value1Flag == YFillPosition || value2Flag == XFillPosition) |
2558 value1.swap(value2); | 2556 value1.swap(value2); |
2559 } | 2557 } |
2560 | 2558 |
2561 void CSSPropertyParser::parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>& value1, Re
fPtrWillBeRawPtr<CSSValue>& value2) | 2559 void CSSPropertyParser::parseFillRepeat(NullableCSSValue& value1, NullableCSSVal
ue& value2) |
2562 { | 2560 { |
2563 CSSValueID id = m_valueList->current()->id; | 2561 CSSValueID id = m_valueList->current()->id; |
2564 if (id == CSSValueRepeatX) { | 2562 if (id == CSSValueRepeatX) { |
2565 m_implicitShorthand = true; | 2563 m_implicitShorthand = true; |
2566 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); | 2564 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); |
2567 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); | 2565 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); |
2568 m_valueList->next(); | 2566 m_valueList->next(); |
2569 return; | 2567 return; |
2570 } | 2568 } |
2571 if (id == CSSValueRepeatY) { | 2569 if (id == CSSValueRepeatY) { |
(...skipping 17 matching lines...) Expand all Loading... |
2589 id = value->id; | 2587 id = value->id; |
2590 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun
d || id == CSSValueSpace) { | 2588 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun
d || id == CSSValueSpace) { |
2591 value2 = cssValuePool().createIdentifierValue(id); | 2589 value2 = cssValuePool().createIdentifierValue(id); |
2592 m_valueList->next(); | 2590 m_valueList->next(); |
2593 return; | 2591 return; |
2594 } | 2592 } |
2595 } | 2593 } |
2596 | 2594 |
2597 // If only one value was specified, value2 is the same as value1. | 2595 // If only one value was specified, value2 is the same as value1. |
2598 m_implicitShorthand = true; | 2596 m_implicitShorthand = true; |
2599 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get
())->getValueID()); | 2597 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1)->g
etValueID()); |
2600 } | 2598 } |
2601 | 2599 |
2602 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillSize(CSSPropertyID
unresolvedProperty) | 2600 NullableCSSValue CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProper
ty) |
2603 { | 2601 { |
2604 CSSParserValue* value = m_valueList->current(); | 2602 CSSParserValue* value = m_valueList->current(); |
2605 m_valueList->next(); | 2603 m_valueList->next(); |
2606 | 2604 |
2607 if (value->id == CSSValueContain || value->id == CSSValueCover) | 2605 if (value->id == CSSValueContain || value->id == CSSValueCover) |
2608 return cssValuePool().createIdentifierValue(value->id); | 2606 return cssValuePool().createIdentifierValue(value->id); |
2609 | 2607 |
2610 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr; | 2608 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr; |
2611 | 2609 |
2612 if (value->id == CSSValueAuto) | 2610 if (value->id == CSSValueAuto) |
(...skipping 21 matching lines...) Expand all Loading... |
2634 parsedValue2 = parsedValue1; | 2632 parsedValue2 = parsedValue1; |
2635 } | 2633 } |
2636 | 2634 |
2637 if (!parsedValue2) | 2635 if (!parsedValue2) |
2638 return parsedValue1; | 2636 return parsedValue1; |
2639 | 2637 |
2640 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
(), Pair::KeepIdenticalValues); | 2638 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
(), Pair::KeepIdenticalValues); |
2641 } | 2639 } |
2642 | 2640 |
2643 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, | 2641 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, |
2644 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa
lue2) | 2642 NullableCSSValue& retValue1, NullableCSSValue& retValue2) |
2645 { | 2643 { |
2646 // We initially store the first value in value/value2, and only create | 2644 // We initially store the first value in value/value2, and only create |
2647 // CSSValueLists if we have more values. | 2645 // CSSValueLists if we have more values. |
2648 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | 2646 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; |
2649 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; | 2647 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; |
2650 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 2648 NullableCSSValue value; |
2651 RefPtrWillBeRawPtr<CSSValue> value2 = nullptr; | 2649 NullableCSSValue value2; |
2652 | 2650 |
2653 retValue1 = retValue2 = nullptr; | 2651 retValue1 = nullptr; |
| 2652 retValue2 = nullptr; |
2654 propId1 = resolveCSSPropertyID(propId); | 2653 propId1 = resolveCSSPropertyID(propId); |
2655 propId2 = propId1; | 2654 propId2 = propId1; |
2656 if (propId == CSSPropertyBackgroundPosition) { | 2655 if (propId == CSSPropertyBackgroundPosition) { |
2657 propId1 = CSSPropertyBackgroundPositionX; | 2656 propId1 = CSSPropertyBackgroundPositionX; |
2658 propId2 = CSSPropertyBackgroundPositionY; | 2657 propId2 = CSSPropertyBackgroundPositionY; |
2659 } else if (propId == CSSPropertyWebkitMaskPosition) { | 2658 } else if (propId == CSSPropertyWebkitMaskPosition) { |
2660 propId1 = CSSPropertyWebkitMaskPositionX; | 2659 propId1 = CSSPropertyWebkitMaskPositionX; |
2661 propId2 = CSSPropertyWebkitMaskPositionY; | 2660 propId2 = CSSPropertyWebkitMaskPositionY; |
2662 } else if (propId == CSSPropertyBackgroundRepeat) { | 2661 } else if (propId == CSSPropertyBackgroundRepeat) { |
2663 propId1 = CSSPropertyBackgroundRepeatX; | 2662 propId1 = CSSPropertyBackgroundRepeatX; |
2664 propId2 = CSSPropertyBackgroundRepeatY; | 2663 propId2 = CSSPropertyBackgroundRepeatY; |
2665 } else if (propId == CSSPropertyWebkitMaskRepeat) { | 2664 } else if (propId == CSSPropertyWebkitMaskRepeat) { |
2666 propId1 = CSSPropertyWebkitMaskRepeatX; | 2665 propId1 = CSSPropertyWebkitMaskRepeatX; |
2667 propId2 = CSSPropertyWebkitMaskRepeatY; | 2666 propId2 = CSSPropertyWebkitMaskRepeatY; |
2668 } | 2667 } |
2669 | 2668 |
2670 while (true) { | 2669 while (true) { |
2671 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; | 2670 NullableCSSValue currValue; |
2672 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; | 2671 NullableCSSValue currValue2; |
2673 | 2672 |
2674 Units unitless = FUnknown; | 2673 Units unitless = FUnknown; |
2675 CSSParserValue* val = m_valueList->current(); | 2674 CSSParserValue* val = m_valueList->current(); |
2676 ASSERT(val); | 2675 ASSERT(val); |
2677 | 2676 |
2678 switch (propId) { | 2677 switch (propId) { |
2679 case CSSPropertyBackgroundColor: | 2678 case CSSPropertyBackgroundColor: |
2680 currValue = parseBackgroundColor(); | 2679 currValue = parseBackgroundColor(); |
2681 if (currValue) | 2680 if (currValue) |
2682 m_valueList->next(); | 2681 m_valueList->next(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 break; | 2777 break; |
2779 } | 2778 } |
2780 default: | 2779 default: |
2781 break; | 2780 break; |
2782 } | 2781 } |
2783 if (!currValue) | 2782 if (!currValue) |
2784 return false; | 2783 return false; |
2785 | 2784 |
2786 if (value && !values) { | 2785 if (value && !values) { |
2787 values = CSSValueList::createCommaSeparated(); | 2786 values = CSSValueList::createCommaSeparated(); |
2788 values->append(value.release()); | 2787 values->append(*value); |
2789 } | 2788 } |
2790 | 2789 |
2791 if (value2 && !values2) { | 2790 if (value2 && !values2) { |
2792 values2 = CSSValueList::createCommaSeparated(); | 2791 values2 = CSSValueList::createCommaSeparated(); |
2793 values2->append(value2.release()); | 2792 values2->append(*value2); |
2794 } | 2793 } |
2795 | 2794 |
2796 if (values) | 2795 if (values) |
2797 values->append(currValue.release()); | 2796 values->append(*currValue); |
2798 else | 2797 else |
2799 value = currValue.release(); | 2798 value = currValue; |
2800 if (currValue2) { | 2799 if (currValue2) { |
2801 if (values2) | 2800 if (values2) |
2802 values2->append(currValue2.release()); | 2801 values2->append(*currValue2); |
2803 else | 2802 else |
2804 value2 = currValue2.release(); | 2803 value2 = currValue2; |
2805 } | 2804 } |
2806 | 2805 |
2807 // When parsing any fill shorthand property, we let it handle building u
p the lists for all | 2806 // When parsing any fill shorthand property, we let it handle building u
p the lists for all |
2808 // properties. | 2807 // properties. |
2809 if (inShorthand()) | 2808 if (inShorthand()) |
2810 break; | 2809 break; |
2811 | 2810 |
2812 if (!m_valueList->current()) | 2811 if (!m_valueList->current()) |
2813 break; | 2812 break; |
2814 if (!consumeComma(m_valueList) || !m_valueList->current()) | 2813 if (!consumeComma(m_valueList) || !m_valueList->current()) |
2815 return false; | 2814 return false; |
2816 } | 2815 } |
2817 | 2816 |
2818 if (values) { | 2817 if (values) { |
2819 ASSERT(values->length()); | 2818 ASSERT(values->length()); |
2820 retValue1 = values.release(); | 2819 retValue1 = values.release(); |
2821 if (values2) { | 2820 if (values2) { |
2822 ASSERT(values2->length()); | 2821 ASSERT(values2->length()); |
2823 retValue2 = values2.release(); | 2822 retValue2 = values2.release(); |
2824 } | 2823 } |
2825 } else { | 2824 } else { |
2826 ASSERT(value); | 2825 ASSERT(value); |
2827 retValue1 = value.release(); | 2826 retValue1 = value; |
2828 retValue2 = value2.release(); | 2827 retValue2 = value2; |
2829 } | 2828 } |
2830 | 2829 |
2831 return true; | 2830 return true; |
2832 } | 2831 } |
2833 | 2832 |
2834 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() | 2833 NullableCSSValue CSSPropertyParser::parseAnimationDelay() |
2835 { | 2834 { |
2836 CSSParserValue* value = m_valueList->current(); | 2835 CSSParserValue* value = m_valueList->current(); |
2837 if (validUnit(value, FTime)) | 2836 if (validUnit(value, FTime)) |
2838 return createPrimitiveNumericValue(value); | 2837 return createPrimitiveNumericValue(value); |
2839 return nullptr; | 2838 return nullptr; |
2840 } | 2839 } |
2841 | 2840 |
2842 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() | 2841 NullableCSSValue CSSPropertyParser::parseAnimationDirection() |
2843 { | 2842 { |
2844 CSSParserValue* value = m_valueList->current(); | 2843 CSSParserValue* value = m_valueList->current(); |
2845 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) | 2844 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value->
id == CSSValueReverse || value->id == CSSValueAlternateReverse) |
2846 return cssValuePool().createIdentifierValue(value->id); | 2845 return cssValuePool().createIdentifierValue(value->id); |
2847 return nullptr; | 2846 return nullptr; |
2848 } | 2847 } |
2849 | 2848 |
2850 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() | 2849 NullableCSSValue CSSPropertyParser::parseAnimationDuration() |
2851 { | 2850 { |
2852 CSSParserValue* value = m_valueList->current(); | 2851 CSSParserValue* value = m_valueList->current(); |
2853 if (validUnit(value, FTime | FNonNeg)) | 2852 if (validUnit(value, FTime | FNonNeg)) |
2854 return createPrimitiveNumericValue(value); | 2853 return createPrimitiveNumericValue(value); |
2855 return nullptr; | 2854 return nullptr; |
2856 } | 2855 } |
2857 | 2856 |
2858 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() | 2857 NullableCSSValue CSSPropertyParser::parseAnimationFillMode() |
2859 { | 2858 { |
2860 CSSParserValue* value = m_valueList->current(); | 2859 CSSParserValue* value = m_valueList->current(); |
2861 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) | 2860 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id
== CSSValueBackwards || value->id == CSSValueBoth) |
2862 return cssValuePool().createIdentifierValue(value->id); | 2861 return cssValuePool().createIdentifierValue(value->id); |
2863 return nullptr; | 2862 return nullptr; |
2864 } | 2863 } |
2865 | 2864 |
2866 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount
() | 2865 NullableCSSValue CSSPropertyParser::parseAnimationIterationCount() |
2867 { | 2866 { |
2868 CSSParserValue* value = m_valueList->current(); | 2867 CSSParserValue* value = m_valueList->current(); |
2869 if (value->id == CSSValueInfinite) | 2868 if (value->id == CSSValueInfinite) |
2870 return cssValuePool().createIdentifierValue(value->id); | 2869 return cssValuePool().createIdentifierValue(value->id); |
2871 if (validUnit(value, FNumber | FNonNeg)) | 2870 if (validUnit(value, FNumber | FNonNeg)) |
2872 return createPrimitiveNumericValue(value); | 2871 return createPrimitiveNumericValue(value); |
2873 return nullptr; | 2872 return nullptr; |
2874 } | 2873 } |
2875 | 2874 |
2876 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo
wQuotedName) | 2875 NullableCSSValue CSSPropertyParser::parseAnimationName(bool allowQuotedName) |
2877 { | 2876 { |
2878 CSSParserValue* value = m_valueList->current(); | 2877 CSSParserValue* value = m_valueList->current(); |
2879 | 2878 |
2880 if (value->id == CSSValueNone) | 2879 if (value->id == CSSValueNone) |
2881 return cssValuePool().createIdentifierValue(CSSValueNone); | 2880 return cssValuePool().createIdentifierValue(CSSValueNone); |
2882 | 2881 |
2883 if (value->unit == CSSPrimitiveValue::CSS_IDENT) | 2882 if (value->unit == CSSPrimitiveValue::CSS_IDENT) |
2884 return createPrimitiveCustomIdentValue(value); | 2883 return createPrimitiveCustomIdentValue(value); |
2885 | 2884 |
2886 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) { | 2885 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) { |
2887 // Legacy support for strings in prefixed animations | 2886 // Legacy support for strings in prefixed animations |
2888 if (m_context.useCounter()) | 2887 if (m_context.useCounter()) |
2889 m_context.useCounter()->count(UseCounter::QuotedAnimationName); | 2888 m_context.useCounter()->count(UseCounter::QuotedAnimationName); |
2890 if (equalIgnoringCase(value->string, "none")) | 2889 if (equalIgnoringCase(value->string, "none")) |
2891 return cssValuePool().createIdentifierValue(CSSValueNone); | 2890 return cssValuePool().createIdentifierValue(CSSValueNone); |
2892 return createPrimitiveCustomIdentValue(value); | 2891 return createPrimitiveCustomIdentValue(value); |
2893 } | 2892 } |
2894 | 2893 |
2895 return nullptr; | 2894 return nullptr; |
2896 } | 2895 } |
2897 | 2896 |
2898 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() | 2897 NullableCSSValue CSSPropertyParser::parseAnimationPlayState() |
2899 { | 2898 { |
2900 CSSParserValue* value = m_valueList->current(); | 2899 CSSParserValue* value = m_valueList->current(); |
2901 if (value->id == CSSValueRunning || value->id == CSSValuePaused) | 2900 if (value->id == CSSValueRunning || value->id == CSSValuePaused) |
2902 return cssValuePool().createIdentifierValue(value->id); | 2901 return cssValuePool().createIdentifierValue(value->id); |
2903 return nullptr; | 2902 return nullptr; |
2904 } | 2903 } |
2905 | 2904 |
2906 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() | 2905 NullableCSSValue CSSPropertyParser::parseAnimationProperty() |
2907 { | 2906 { |
2908 CSSParserValue* value = m_valueList->current(); | 2907 CSSParserValue* value = m_valueList->current(); |
2909 if (value->unit != CSSPrimitiveValue::CSS_IDENT) | 2908 if (value->unit != CSSPrimitiveValue::CSS_IDENT) |
2910 return nullptr; | 2909 return nullptr; |
2911 // Since all is valid css property keyword, cssPropertyID for all | 2910 // Since all is valid css property keyword, cssPropertyID for all |
2912 // returns non-null value. We need to check "all" before | 2911 // returns non-null value. We need to check "all" before |
2913 // cssPropertyID check. | 2912 // cssPropertyID check. |
2914 if (value->id == CSSValueAll) | 2913 if (value->id == CSSValueAll) |
2915 return cssValuePool().createIdentifierValue(CSSValueAll); | 2914 return cssValuePool().createIdentifierValue(CSSValueAll); |
2916 CSSPropertyID property = unresolvedCSSPropertyID(value->string); | 2915 CSSPropertyID property = unresolvedCSSPropertyID(value->string); |
(...skipping 14 matching lines...) Expand all Loading... |
2931 if (!validUnit(v, FNumber)) | 2930 if (!validUnit(v, FNumber)) |
2932 return false; | 2931 return false; |
2933 result = v->fValue; | 2932 result = v->fValue; |
2934 v = args->next(); | 2933 v = args->next(); |
2935 if (!v) | 2934 if (!v) |
2936 // The last number in the function has no comma after it, so we're done. | 2935 // The last number in the function has no comma after it, so we're done. |
2937 return true; | 2936 return true; |
2938 return consumeComma(args); | 2937 return consumeComma(args); |
2939 } | 2938 } |
2940 | 2939 |
2941 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
() | 2940 NullableCSSValue CSSPropertyParser::parseAnimationTimingFunction() |
2942 { | 2941 { |
2943 CSSParserValue* value = m_valueList->current(); | 2942 CSSParserValue* value = m_valueList->current(); |
2944 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut | 2943 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id ==
CSSValueEaseIn || value->id == CSSValueEaseOut |
2945 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd | 2944 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v
alue->id == CSSValueStepEnd |
2946 || value->id == CSSValueStepMiddle) | 2945 || value->id == CSSValueStepMiddle) |
2947 return cssValuePool().createIdentifierValue(value->id); | 2946 return cssValuePool().createIdentifierValue(value->id); |
2948 | 2947 |
2949 // We must be a function. | 2948 // We must be a function. |
2950 if (value->unit != CSSParserValue::Function) | 2949 if (value->unit != CSSParserValue::Function) |
2951 return nullptr; | 2950 return nullptr; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 return nullptr; | 3011 return nullptr; |
3013 if (!parseCubicBezierTimingFunctionValue(args, y2)) | 3012 if (!parseCubicBezierTimingFunctionValue(args, y2)) |
3014 return nullptr; | 3013 return nullptr; |
3015 | 3014 |
3016 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); | 3015 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); |
3017 } | 3016 } |
3018 | 3017 |
3019 return nullptr; | 3018 return nullptr; |
3020 } | 3019 } |
3021 | 3020 |
3022 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPr
opertyID propId, bool useLegacyParsing) | 3021 NullableCSSValue CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId,
bool useLegacyParsing) |
3023 { | 3022 { |
3024 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 3023 NullableCSSValue value; |
3025 switch (propId) { | 3024 switch (propId) { |
3026 case CSSPropertyAnimationDelay: | 3025 case CSSPropertyAnimationDelay: |
3027 case CSSPropertyTransitionDelay: | 3026 case CSSPropertyTransitionDelay: |
3028 value = parseAnimationDelay(); | 3027 value = parseAnimationDelay(); |
3029 break; | 3028 break; |
3030 case CSSPropertyAnimationDirection: | 3029 case CSSPropertyAnimationDirection: |
3031 value = parseAnimationDirection(); | 3030 value = parseAnimationDirection(); |
3032 break; | 3031 break; |
3033 case CSSPropertyAnimationDuration: | 3032 case CSSPropertyAnimationDuration: |
3034 case CSSPropertyTransitionDuration: | 3033 case CSSPropertyTransitionDuration: |
(...skipping 18 matching lines...) Expand all Loading... |
3053 case CSSPropertyTransitionTimingFunction: | 3052 case CSSPropertyTransitionTimingFunction: |
3054 value = parseAnimationTimingFunction(); | 3053 value = parseAnimationTimingFunction(); |
3055 break; | 3054 break; |
3056 default: | 3055 default: |
3057 ASSERT_NOT_REACHED(); | 3056 ASSERT_NOT_REACHED(); |
3058 return nullptr; | 3057 return nullptr; |
3059 } | 3058 } |
3060 | 3059 |
3061 if (value) | 3060 if (value) |
3062 m_valueList->next(); | 3061 m_valueList->next(); |
3063 return value.release(); | 3062 return value; |
3064 } | 3063 } |
3065 | 3064 |
3066 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi
st(CSSPropertyID propId, bool useLegacyParsing) | 3065 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi
st(CSSPropertyID propId, bool useLegacyParsing) |
3067 { | 3066 { |
3068 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 3067 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
3069 while (true) { | 3068 while (true) { |
3070 RefPtrWillBeRawPtr<CSSValue> value = parseAnimationProperty(propId, useL
egacyParsing); | 3069 NullableCSSValue value = parseAnimationProperty(propId, useLegacyParsing
); |
3071 if (!value) | 3070 if (!value) |
3072 return nullptr; | 3071 return nullptr; |
3073 list->append(value.release()); | 3072 list->append(*value); |
3074 if (!m_valueList->current()) | 3073 if (!m_valueList->current()) |
3075 break; | 3074 break; |
3076 if (!consumeComma(m_valueList) || !m_valueList->current()) | 3075 if (!consumeComma(m_valueList) || !m_valueList->current()) |
3077 return nullptr; | 3076 return nullptr; |
3078 } | 3077 } |
3079 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis
t(list.get())) | 3078 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis
t(list.get())) |
3080 return nullptr; | 3079 return nullptr; |
3081 ASSERT(list->length()); | 3080 ASSERT(list->length()); |
3082 return list.release(); | 3081 return list.release(); |
3083 } | 3082 } |
(...skipping 29 matching lines...) Expand all Loading... |
3113 if (value && validUnit(value, FInteger) && value->fValue) { | 3112 if (value && validUnit(value, FInteger) && value->fValue) { |
3114 numericValue = createPrimitiveNumericValue(value); | 3113 numericValue = createPrimitiveNumericValue(value); |
3115 m_valueList->next(); | 3114 m_valueList->next(); |
3116 } | 3115 } |
3117 return true; | 3116 return true; |
3118 } | 3117 } |
3119 | 3118 |
3120 return false; | 3119 return false; |
3121 } | 3120 } |
3122 | 3121 |
3123 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition() | 3122 NullableCSSValue CSSPropertyParser::parseGridPosition() |
3124 { | 3123 { |
3125 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3124 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3126 | 3125 |
3127 CSSParserValue* value = m_valueList->current(); | 3126 CSSParserValue* value = m_valueList->current(); |
3128 if (value->id == CSSValueAuto) { | 3127 if (value->id == CSSValueAuto) { |
3129 m_valueList->next(); | 3128 m_valueList->next(); |
3130 return cssValuePool().createIdentifierValue(CSSValueAuto); | 3129 return cssValuePool().createIdentifierValue(CSSValueAuto); |
3131 } | 3130 } |
3132 | 3131 |
3133 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr; | 3132 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3169 if (hasSeenSpanKeyword) | 3168 if (hasSeenSpanKeyword) |
3170 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); | 3169 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); |
3171 if (numericValue) | 3170 if (numericValue) |
3172 values->append(numericValue.release()); | 3171 values->append(numericValue.release()); |
3173 if (gridLineName) | 3172 if (gridLineName) |
3174 values->append(gridLineName.release()); | 3173 values->append(gridLineName.release()); |
3175 ASSERT(values->length()); | 3174 ASSERT(values->length()); |
3176 return values.release(); | 3175 return values.release(); |
3177 } | 3176 } |
3178 | 3177 |
3179 static PassRefPtrWillBeRawPtr<CSSValue> gridMissingGridPositionValue(CSSValue* v
alue) | 3178 static CSSValue gridMissingGridPositionValue(CSSValue value) |
3180 { | 3179 { |
3181 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isString()) | 3180 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isString()) |
3182 return value; | 3181 return value; |
3183 | 3182 |
3184 return cssValuePool().createIdentifierValue(CSSValueAuto); | 3183 return cssValuePool().createIdentifierValue(CSSValueAuto); |
3185 } | 3184 } |
3186 | 3185 |
3187 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId
, bool important) | 3186 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId
, bool important) |
3188 { | 3187 { |
3189 ShorthandScope scope(this, shorthandId); | 3188 ShorthandScope scope(this, shorthandId); |
3190 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); | 3189 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); |
3191 ASSERT(shorthand.length() == 2); | 3190 ASSERT(shorthand.length() == 2); |
3192 | 3191 |
3193 RefPtrWillBeRawPtr<CSSValue> startValue = parseGridPosition(); | 3192 NullableCSSValue startValue = parseGridPosition(); |
3194 if (!startValue) | 3193 if (!startValue) |
3195 return false; | 3194 return false; |
3196 | 3195 |
3197 RefPtrWillBeRawPtr<CSSValue> endValue = nullptr; | 3196 NullableCSSValue endValue; |
3198 if (m_valueList->current()) { | 3197 if (m_valueList->current()) { |
3199 if (!isForwardSlashOperator(m_valueList->current())) | 3198 if (!isForwardSlashOperator(m_valueList->current())) |
3200 return false; | 3199 return false; |
3201 | 3200 |
3202 if (!m_valueList->next()) | 3201 if (!m_valueList->next()) |
3203 return false; | 3202 return false; |
3204 | 3203 |
3205 endValue = parseGridPosition(); | 3204 endValue = parseGridPosition(); |
3206 if (!endValue || m_valueList->current()) | 3205 if (!endValue || m_valueList->current()) |
3207 return false; | 3206 return false; |
3208 } else { | 3207 } else { |
3209 endValue = gridMissingGridPositionValue(startValue.get()); | 3208 endValue = gridMissingGridPositionValue(*startValue); |
3210 } | 3209 } |
3211 | 3210 |
3212 addProperty(shorthand.properties()[0], startValue, important); | 3211 addProperty(shorthand.properties()[0], *startValue, important); |
3213 addProperty(shorthand.properties()[1], endValue, important); | 3212 addProperty(shorthand.properties()[1], *endValue, important); |
3214 return true; | 3213 return true; |
3215 } | 3214 } |
3216 | 3215 |
3217 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
Value> templateColumns, bool important) | 3216 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(NullableCSSValue templateC
olumns, bool important) |
3218 { | 3217 { |
3219 NamedGridAreaMap gridAreaMap; | 3218 NamedGridAreaMap gridAreaMap; |
3220 size_t rowCount = 0; | 3219 size_t rowCount = 0; |
3221 size_t columnCount = 0; | 3220 size_t columnCount = 0; |
3222 bool trailingIdentWasAdded = false; | 3221 bool trailingIdentWasAdded = false; |
3223 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep
arated(); | 3222 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep
arated(); |
3224 | 3223 |
3225 // At least template-areas strings must be defined. | 3224 // At least template-areas strings must be defined. |
3226 if (!m_valueList->current()) | 3225 if (!m_valueList->current()) |
3227 return false; | 3226 return false; |
3228 | 3227 |
3229 while (m_valueList->current()) { | 3228 while (m_valueList->current()) { |
3230 // Handle leading <custom-ident>*. | 3229 // Handle leading <custom-ident>*. |
3231 if (trailingIdentWasAdded) { | 3230 if (trailingIdentWasAdded) { |
3232 // A row's trailing ident must be concatenated with the next row's l
eading one. | 3231 // A row's trailing ident must be concatenated with the next row's l
eading one. |
3233 maybeParseGridLineNames(*m_valueList, *templateRows, toCSSGridLineNa
mesValue(templateRows->item(templateRows->length() - 1))); | 3232 maybeParseGridLineNames(*m_valueList, *templateRows, &toCSSGridLineN
amesValue(templateRows->item(templateRows->length() - 1))); |
3234 } else { | 3233 } else { |
3235 maybeParseGridLineNames(*m_valueList, *templateRows); | 3234 maybeParseGridLineNames(*m_valueList, *templateRows); |
3236 } | 3235 } |
3237 | 3236 |
3238 // Handle a template-area's row. | 3237 // Handle a template-area's row. |
3239 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | 3238 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) |
3240 return false; | 3239 return false; |
3241 ++rowCount; | 3240 ++rowCount; |
3242 | 3241 |
3243 // Handle template-rows's track-size. | 3242 // Handle template-rows's track-size. |
3244 if (m_valueList->current() && m_valueList->current()->unit != CSSParserV
alue::ValueList && m_valueList->current()->unit != CSSPrimitiveValue::CSS_STRING
) { | 3243 if (m_valueList->current() && m_valueList->current()->unit != CSSParserV
alue::ValueList && m_valueList->current()->unit != CSSPrimitiveValue::CSS_STRING
) { |
3245 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList
); | 3244 NullableCSSValue value = parseGridTrackSize(*m_valueList); |
3246 if (!value) | 3245 if (!value) |
3247 return false; | 3246 return false; |
3248 templateRows->append(value); | 3247 templateRows->append(*value); |
3249 } else { | 3248 } else { |
3250 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu
to)); | 3249 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu
to)); |
3251 } | 3250 } |
3252 | 3251 |
3253 // This will handle the trailing/leading <custom-ident>* in the grammar. | 3252 // This will handle the trailing/leading <custom-ident>* in the grammar. |
3254 const CSSParserValue* current = m_valueList->current(); | 3253 const CSSParserValue* current = m_valueList->current(); |
3255 trailingIdentWasAdded = current && current->unit == CSSParserValue::Valu
eList && current->valueList->size() > 0; | 3254 trailingIdentWasAdded = current && current->unit == CSSParserValue::Valu
eList && current->valueList->size() > 0; |
3256 maybeParseGridLineNames(*m_valueList, *templateRows); | 3255 maybeParseGridLineNames(*m_valueList, *templateRows); |
3257 } | 3256 } |
3258 | 3257 |
3259 // [<track-list> /]? | 3258 // [<track-list> /]? |
3260 if (templateColumns) | 3259 if (templateColumns) |
3261 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); | 3260 addProperty(CSSPropertyGridTemplateColumns, *templateColumns, important)
; |
3262 else | 3261 else |
3263 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti
fierValue(CSSValueNone), important); | 3262 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti
fierValue(CSSValueNone), important); |
3264 | 3263 |
3265 // [<line-names>? <string> [<track-size> <line-names>]? ]+ | 3264 // [<line-names>? <string> [<track-size> <line-names>]? ]+ |
3266 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea
te(gridAreaMap, rowCount, columnCount); | 3265 CSSValue templateAreas = CSSGridTemplateAreasValue::create(gridAreaMap, rowC
ount, columnCount); |
3267 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important
); | 3266 addProperty(CSSPropertyGridTemplateAreas, templateAreas, important); |
3268 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); | 3267 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); |
3269 | 3268 |
3270 | 3269 |
3271 return true; | 3270 return true; |
3272 } | 3271 } |
3273 | 3272 |
3274 | 3273 |
3275 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) | 3274 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) |
3276 { | 3275 { |
3277 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3276 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3278 | 3277 |
3279 ShorthandScope scope(this, CSSPropertyGridTemplate); | 3278 ShorthandScope scope(this, CSSPropertyGridTemplate); |
3280 ASSERT(gridTemplateShorthand().length() == 3); | 3279 ASSERT(gridTemplateShorthand().length() == 3); |
3281 | 3280 |
3282 // At least "none" must be defined. | 3281 // At least "none" must be defined. |
3283 if (!m_valueList->current()) | 3282 if (!m_valueList->current()) |
3284 return false; | 3283 return false; |
3285 | 3284 |
3286 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; | 3285 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; |
3287 | 3286 |
3288 // 1- 'none' case. | 3287 // 1- 'none' case. |
3289 if (firstValueIsNone && !m_valueList->next()) { | 3288 if (firstValueIsNone && !m_valueList->next()) { |
3290 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif
ierValue(CSSValueNone), important); | 3289 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif
ierValue(CSSValueNone), important); |
3291 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier
Value(CSSValueNone), important); | 3290 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier
Value(CSSValueNone), important); |
3292 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie
rValue(CSSValueNone), important); | 3291 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie
rValue(CSSValueNone), important); |
3293 return true; | 3292 return true; |
3294 } | 3293 } |
3295 | 3294 |
3296 unsigned index = 0; | 3295 unsigned index = 0; |
3297 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr; | 3296 NullableCSSValue columnsValue; |
3298 if (firstValueIsNone) { | 3297 if (firstValueIsNone) { |
3299 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); | 3298 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); |
3300 } else { | 3299 } else { |
3301 columnsValue = parseGridTrackList(); | 3300 columnsValue = parseGridTrackList(); |
3302 } | 3301 } |
3303 | 3302 |
3304 // 2- <grid-template-columns> / <grid-template-columns> syntax. | 3303 // 2- <grid-template-columns> / <grid-template-columns> syntax. |
3305 if (columnsValue) { | 3304 if (columnsValue) { |
3306 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr
ent()) && m_valueList->next())) | 3305 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr
ent()) && m_valueList->next())) |
3307 return false; | 3306 return false; |
3308 index = m_valueList->currentIndex(); | 3307 index = m_valueList->currentIndex(); |
3309 if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) { | 3308 if (NullableCSSValue rowsValue = parseGridTrackList()) { |
3310 if (m_valueList->current()) | 3309 if (m_valueList->current()) |
3311 return false; | 3310 return false; |
3312 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important)
; | 3311 addProperty(CSSPropertyGridTemplateColumns, *columnsValue, important
); |
3313 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); | 3312 addProperty(CSSPropertyGridTemplateRows, *rowsValue, important); |
3314 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent
ifierValue(CSSValueNone), important); | 3313 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent
ifierValue(CSSValueNone), important); |
3315 return true; | 3314 return true; |
3316 } | 3315 } |
3317 } | 3316 } |
3318 | 3317 |
3319 | 3318 |
3320 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]?
]+ syntax. | 3319 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]?
]+ syntax. |
3321 // The template-columns <track-list> can't be 'none'. | 3320 // The template-columns <track-list> can't be 'none'. |
3322 if (firstValueIsNone) | 3321 if (firstValueIsNone) |
3323 return false; | 3322 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
3341 return true; | 3340 return true; |
3342 } | 3341 } |
3343 | 3342 |
3344 // Need to rewind parsing to explore the alternative syntax of this shorthan
d. | 3343 // Need to rewind parsing to explore the alternative syntax of this shorthan
d. |
3345 m_valueList->setCurrentIndex(0); | 3344 m_valueList->setCurrentIndex(0); |
3346 | 3345 |
3347 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] | 3346 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] |
3348 if (!parseValue(CSSPropertyGridAutoFlow, important)) | 3347 if (!parseValue(CSSPropertyGridAutoFlow, important)) |
3349 return false; | 3348 return false; |
3350 | 3349 |
3351 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = nullptr; | 3350 NullableCSSValue autoColumnsValue; |
3352 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr; | 3351 NullableCSSValue autoRowsValue; |
3353 | 3352 |
3354 if (m_valueList->current()) { | 3353 if (m_valueList->current()) { |
3355 autoColumnsValue = parseGridTrackSize(*m_valueList); | 3354 autoColumnsValue = parseGridTrackSize(*m_valueList); |
3356 if (!autoColumnsValue) | 3355 if (!autoColumnsValue) |
3357 return false; | 3356 return false; |
3358 if (m_valueList->current()) { | 3357 if (m_valueList->current()) { |
3359 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList-
>next()) | 3358 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList-
>next()) |
3360 return false; | 3359 return false; |
3361 autoRowsValue = parseGridTrackSize(*m_valueList); | 3360 autoRowsValue = parseGridTrackSize(*m_valueList); |
3362 if (!autoRowsValue) | 3361 if (!autoRowsValue) |
3363 return false; | 3362 return false; |
3364 } | 3363 } |
3365 if (m_valueList->current()) | 3364 if (m_valueList->current()) |
3366 return false; | 3365 return false; |
3367 } else { | 3366 } else { |
3368 // Other omitted values are set to their initial values. | 3367 // Other omitted values are set to their initial values. |
3369 autoColumnsValue = cssValuePool().createImplicitInitialValue(); | 3368 autoColumnsValue = cssValuePool().createImplicitInitialValue(); |
3370 autoRowsValue = cssValuePool().createImplicitInitialValue(); | 3369 autoRowsValue = cssValuePool().createImplicitInitialValue(); |
3371 } | 3370 } |
3372 | 3371 |
3373 // if <grid-auto-rows> value is omitted, it is set to the value specified fo
r grid-auto-columns. | 3372 // if <grid-auto-rows> value is omitted, it is set to the value specified fo
r grid-auto-columns. |
3374 if (!autoRowsValue) | 3373 if (!autoRowsValue) |
3375 autoRowsValue = autoColumnsValue; | 3374 autoRowsValue = autoColumnsValue; |
3376 | 3375 |
3377 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); | 3376 addProperty(CSSPropertyGridAutoColumns, *autoColumnsValue, important); |
3378 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); | 3377 addProperty(CSSPropertyGridAutoRows, *autoRowsValue, important); |
3379 | 3378 |
3380 // It can only be specified the explicit or the implicit grid properties in
a single grid declaration. | 3379 // It can only be specified the explicit or the implicit grid properties in
a single grid declaration. |
3381 // The sub-properties not specified are set to their initial value, as norma
l for shorthands. | 3380 // The sub-properties not specified are set to their initial value, as norma
l for shorthands. |
3382 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni
tialValue(), important); | 3381 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni
tialValue(), important); |
3383 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia
lValue(), important); | 3382 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia
lValue(), important); |
3384 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti
alValue(), important); | 3383 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti
alValue(), important); |
3385 | 3384 |
3386 return true; | 3385 return true; |
3387 } | 3386 } |
3388 | 3387 |
3389 bool CSSPropertyParser::parseGridAreaShorthand(bool important) | 3388 bool CSSPropertyParser::parseGridAreaShorthand(bool important) |
3390 { | 3389 { |
3391 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3390 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3392 | 3391 |
3393 ShorthandScope scope(this, CSSPropertyGridArea); | 3392 ShorthandScope scope(this, CSSPropertyGridArea); |
3394 const StylePropertyShorthand& shorthand = gridAreaShorthand(); | 3393 const StylePropertyShorthand& shorthand = gridAreaShorthand(); |
3395 ASSERT_UNUSED(shorthand, shorthand.length() == 4); | 3394 ASSERT_UNUSED(shorthand, shorthand.length() == 4); |
3396 | 3395 |
3397 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); | 3396 NullableCSSValue rowStartValue = parseGridPosition(); |
3398 if (!rowStartValue) | 3397 if (!rowStartValue) |
3399 return false; | 3398 return false; |
3400 | 3399 |
3401 RefPtrWillBeRawPtr<CSSValue> columnStartValue = nullptr; | 3400 NullableCSSValue columnStartValue; |
3402 if (!parseSingleGridAreaLonghand(columnStartValue)) | 3401 if (!parseSingleGridAreaLonghand(columnStartValue)) |
3403 return false; | 3402 return false; |
3404 | 3403 |
3405 RefPtrWillBeRawPtr<CSSValue> rowEndValue = nullptr; | 3404 NullableCSSValue rowEndValue; |
3406 if (!parseSingleGridAreaLonghand(rowEndValue)) | 3405 if (!parseSingleGridAreaLonghand(rowEndValue)) |
3407 return false; | 3406 return false; |
3408 | 3407 |
3409 RefPtrWillBeRawPtr<CSSValue> columnEndValue = nullptr; | 3408 NullableCSSValue columnEndValue; |
3410 if (!parseSingleGridAreaLonghand(columnEndValue)) | 3409 if (!parseSingleGridAreaLonghand(columnEndValue)) |
3411 return false; | 3410 return false; |
3412 | 3411 |
3413 if (!columnStartValue) | 3412 if (!columnStartValue) |
3414 columnStartValue = gridMissingGridPositionValue(rowStartValue.get()); | 3413 columnStartValue = gridMissingGridPositionValue(*rowStartValue); |
3415 | 3414 |
3416 if (!rowEndValue) | 3415 if (!rowEndValue) |
3417 rowEndValue = gridMissingGridPositionValue(rowStartValue.get()); | 3416 rowEndValue = gridMissingGridPositionValue(*rowStartValue); |
3418 | 3417 |
3419 if (!columnEndValue) | 3418 if (!columnEndValue) |
3420 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); | 3419 columnEndValue = gridMissingGridPositionValue(*columnStartValue); |
3421 | 3420 |
3422 addProperty(CSSPropertyGridRowStart, rowStartValue, important); | 3421 addProperty(CSSPropertyGridRowStart, *rowStartValue, important); |
3423 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); | 3422 addProperty(CSSPropertyGridColumnStart, *columnStartValue, important); |
3424 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); | 3423 addProperty(CSSPropertyGridRowEnd, *rowEndValue, important); |
3425 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); | 3424 addProperty(CSSPropertyGridColumnEnd, *columnEndValue, important); |
3426 return true; | 3425 return true; |
3427 } | 3426 } |
3428 | 3427 |
3429 bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtrWillBeRawPtr<CSSValue>
& property) | 3428 bool CSSPropertyParser::parseSingleGridAreaLonghand(NullableCSSValue& property) |
3430 { | 3429 { |
3431 if (!m_valueList->current()) | 3430 if (!m_valueList->current()) |
3432 return true; | 3431 return true; |
3433 | 3432 |
3434 if (!isForwardSlashOperator(m_valueList->current())) | 3433 if (!isForwardSlashOperator(m_valueList->current())) |
3435 return false; | 3434 return false; |
3436 | 3435 |
3437 if (!m_valueList->next()) | 3436 if (!m_valueList->next()) |
3438 return false; | 3437 return false; |
3439 | 3438 |
(...skipping 24 matching lines...) Expand all Loading... |
3464 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId
entValue(identValue); | 3463 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId
entValue(identValue); |
3465 lineNames->append(lineName.release()); | 3464 lineNames->append(lineName.release()); |
3466 identList->next(); | 3465 identList->next(); |
3467 } | 3466 } |
3468 if (!previousNamedAreaTrailingLineNames) | 3467 if (!previousNamedAreaTrailingLineNames) |
3469 valueList.append(lineNames.release()); | 3468 valueList.append(lineNames.release()); |
3470 | 3469 |
3471 inputList.next(); | 3470 inputList.next(); |
3472 } | 3471 } |
3473 | 3472 |
3474 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList() | 3473 NullableCSSValue CSSPropertyParser::parseGridTrackList() |
3475 { | 3474 { |
3476 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3475 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3477 | 3476 |
3478 CSSParserValue* value = m_valueList->current(); | 3477 CSSParserValue* value = m_valueList->current(); |
3479 if (value->id == CSSValueNone) { | 3478 if (value->id == CSSValueNone) { |
3480 m_valueList->next(); | 3479 m_valueList->next(); |
3481 return cssValuePool().createIdentifierValue(CSSValueNone); | 3480 return cssValuePool().createIdentifierValue(CSSValueNone); |
3482 } | 3481 } |
3483 | 3482 |
3484 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); | 3483 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated
(); |
3485 // Handle leading <ident>*. | 3484 // Handle leading <ident>*. |
3486 maybeParseGridLineNames(*m_valueList, *values); | 3485 maybeParseGridLineNames(*m_valueList, *values); |
3487 | 3486 |
3488 bool seenTrackSizeOrRepeatFunction = false; | 3487 bool seenTrackSizeOrRepeatFunction = false; |
3489 while (CSSParserValue* currentValue = m_valueList->current()) { | 3488 while (CSSParserValue* currentValue = m_valueList->current()) { |
3490 if (isForwardSlashOperator(currentValue)) | 3489 if (isForwardSlashOperator(currentValue)) |
3491 break; | 3490 break; |
3492 if (currentValue->unit == CSSParserValue::Function && currentValue->func
tion->id == CSSValueRepeat) { | 3491 if (currentValue->unit == CSSParserValue::Function && currentValue->func
tion->id == CSSValueRepeat) { |
3493 if (!parseGridTrackRepeatFunction(*values)) | 3492 if (!parseGridTrackRepeatFunction(*values)) |
3494 return nullptr; | 3493 return nullptr; |
3495 seenTrackSizeOrRepeatFunction = true; | 3494 seenTrackSizeOrRepeatFunction = true; |
3496 } else { | 3495 } else { |
3497 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList
); | 3496 NullableCSSValue value = parseGridTrackSize(*m_valueList); |
3498 if (!value) | 3497 if (!value) |
3499 return nullptr; | 3498 return nullptr; |
3500 values->append(value); | 3499 values->append(*value); |
3501 seenTrackSizeOrRepeatFunction = true; | 3500 seenTrackSizeOrRepeatFunction = true; |
3502 } | 3501 } |
3503 // This will handle the trailing <ident>* in the grammar. | 3502 // This will handle the trailing <ident>* in the grammar. |
3504 maybeParseGridLineNames(*m_valueList, *values); | 3503 maybeParseGridLineNames(*m_valueList, *values); |
3505 } | 3504 } |
3506 | 3505 |
3507 // We should have found a <track-size> or else it is not a valid <track-list
> | 3506 // We should have found a <track-size> or else it is not a valid <track-list
> |
3508 if (!seenTrackSizeOrRepeatFunction) | 3507 if (!seenTrackSizeOrRepeatFunction) |
3509 return nullptr; | 3508 return nullptr; |
3510 | 3509 |
(...skipping 11 matching lines...) Expand all Loading... |
3522 | 3521 |
3523 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS
eparated(); | 3522 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS
eparated(); |
3524 arguments->next(); // Skip the repetition count. | 3523 arguments->next(); // Skip the repetition count. |
3525 arguments->next(); // Skip the comma. | 3524 arguments->next(); // Skip the comma. |
3526 | 3525 |
3527 // Handle leading <ident>*. | 3526 // Handle leading <ident>*. |
3528 maybeParseGridLineNames(*arguments, *repeatedValues); | 3527 maybeParseGridLineNames(*arguments, *repeatedValues); |
3529 | 3528 |
3530 size_t numberOfTracks = 0; | 3529 size_t numberOfTracks = 0; |
3531 while (arguments->current()) { | 3530 while (arguments->current()) { |
3532 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); | 3531 NullableCSSValue trackSize = parseGridTrackSize(*arguments); |
3533 if (!trackSize) | 3532 if (!trackSize) |
3534 return false; | 3533 return false; |
3535 | 3534 |
3536 repeatedValues->append(trackSize); | 3535 repeatedValues->append(*trackSize); |
3537 ++numberOfTracks; | 3536 ++numberOfTracks; |
3538 | 3537 |
3539 // This takes care of any trailing <ident>* in the grammar. | 3538 // This takes care of any trailing <ident>* in the grammar. |
3540 maybeParseGridLineNames(*arguments, *repeatedValues); | 3539 maybeParseGridLineNames(*arguments, *repeatedValues); |
3541 } | 3540 } |
3542 | 3541 |
3543 // We should have found at least one <track-size> or else it is not a valid
<track-list>. | 3542 // We should have found at least one <track-size> or else it is not a valid
<track-list>. |
3544 if (!numberOfTracks) | 3543 if (!numberOfTracks) |
3545 return false; | 3544 return false; |
3546 | 3545 |
3547 // We clamp the number of repetitions to a multiple of the repeat() track li
st's size, while staying below the max | 3546 // We clamp the number of repetitions to a multiple of the repeat() track li
st's size, while staying below the max |
3548 // grid size. | 3547 // grid size. |
3549 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); | 3548 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); |
3550 | 3549 |
3551 for (size_t i = 0; i < repetitions; ++i) { | 3550 for (size_t i = 0; i < repetitions; ++i) { |
3552 for (size_t j = 0; j < repeatedValues->length(); ++j) | 3551 for (size_t j = 0; j < repeatedValues->length(); ++j) |
3553 list.append(repeatedValues->item(j)); | 3552 list.append(repeatedValues->item(j)); |
3554 } | 3553 } |
3555 | 3554 |
3556 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. | 3555 // parseGridTrackSize iterated over the repeat arguments, move to the next v
alue. |
3557 m_valueList->next(); | 3556 m_valueList->next(); |
3558 return true; | 3557 return true; |
3559 } | 3558 } |
3560 | 3559 |
3561 | 3560 |
3562 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParser
ValueList& inputList) | 3561 NullableCSSValue CSSPropertyParser::parseGridTrackSize(CSSParserValueList& input
List) |
3563 { | 3562 { |
3564 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3563 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3565 | 3564 |
3566 CSSParserValue* currentValue = inputList.current(); | 3565 CSSParserValue* currentValue = inputList.current(); |
3567 inputList.next(); | 3566 inputList.next(); |
3568 | 3567 |
3569 if (currentValue->id == CSSValueAuto) | 3568 if (currentValue->id == CSSValueAuto) |
3570 return cssValuePool().createIdentifierValue(CSSValueAuto); | 3569 return cssValuePool().createIdentifierValue(CSSValueAuto); |
3571 | 3570 |
3572 if (currentValue->unit == CSSParserValue::Function && currentValue->function
->id == CSSValueMinmax) { | 3571 if (currentValue->unit == CSSParserValue::Function && currentValue->function
->id == CSSValueMinmax) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 | 3668 |
3670 ++gridCoordinate.rows.resolvedFinalPosition; | 3669 ++gridCoordinate.rows.resolvedFinalPosition; |
3671 } | 3670 } |
3672 currentCol = lookAheadCol; | 3671 currentCol = lookAheadCol; |
3673 } | 3672 } |
3674 | 3673 |
3675 m_valueList->next(); | 3674 m_valueList->next(); |
3676 return true; | 3675 return true; |
3677 } | 3676 } |
3678 | 3677 |
3679 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() | 3678 NullableCSSValue CSSPropertyParser::parseGridTemplateAreas() |
3680 { | 3679 { |
3681 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { | 3680 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { |
3682 m_valueList->next(); | 3681 m_valueList->next(); |
3683 return cssValuePool().createIdentifierValue(CSSValueNone); | 3682 return cssValuePool().createIdentifierValue(CSSValueNone); |
3684 } | 3683 } |
3685 | 3684 |
3686 NamedGridAreaMap gridAreaMap; | 3685 NamedGridAreaMap gridAreaMap; |
3687 size_t rowCount = 0; | 3686 size_t rowCount = 0; |
3688 size_t columnCount = 0; | 3687 size_t columnCount = 0; |
3689 | 3688 |
3690 while (m_valueList->current()) { | 3689 while (m_valueList->current()) { |
3691 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) | 3690 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) |
3692 return nullptr; | 3691 return nullptr; |
3693 ++rowCount; | 3692 ++rowCount; |
3694 } | 3693 } |
3695 | 3694 |
3696 if (!rowCount || !columnCount) | 3695 if (!rowCount || !columnCount) |
3697 return nullptr; | 3696 return nullptr; |
3698 | 3697 |
3699 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; | 3698 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; |
3700 } | 3699 } |
3701 | 3700 |
3702 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV
alueList& list) | 3701 NullableCSSValue CSSPropertyParser::parseGridAutoFlow(CSSParserValueList& list) |
3703 { | 3702 { |
3704 // [ row | column ] || dense | 3703 // [ row | column ] || dense |
3705 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 3704 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
3706 | 3705 |
3707 CSSParserValue* value = list.current(); | 3706 CSSParserValue* value = list.current(); |
3708 if (!value) | 3707 if (!value) |
3709 return nullptr; | 3708 return nullptr; |
3710 | 3709 |
3711 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 3710 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); |
3712 | 3711 |
(...skipping 19 matching lines...) Expand all Loading... |
3732 default: | 3731 default: |
3733 return parsedValues; | 3732 return parsedValues; |
3734 } | 3733 } |
3735 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); | 3734 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); |
3736 list.next(); | 3735 list.next(); |
3737 } | 3736 } |
3738 | 3737 |
3739 return parsedValues; | 3738 return parsedValues; |
3740 } | 3739 } |
3741 | 3740 |
3742 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
rValueList* args, bool counters) | 3741 NullableCSSValue CSSPropertyParser::parseCounterContent(CSSParserValueList* args
, bool counters) |
3743 { | 3742 { |
3744 unsigned numArgs = args->size(); | 3743 unsigned numArgs = args->size(); |
3745 if (counters && numArgs != 3 && numArgs != 5) | 3744 if (counters && numArgs != 3 && numArgs != 5) |
3746 return nullptr; | 3745 return nullptr; |
3747 if (!counters && numArgs != 1 && numArgs != 3) | 3746 if (!counters && numArgs != 1 && numArgs != 3) |
3748 return nullptr; | 3747 return nullptr; |
3749 | 3748 |
3750 CSSParserValue* i = args->current(); | 3749 CSSParserValue* i = args->current(); |
3751 if (i->unit != CSSPrimitiveValue::CSS_IDENT) | 3750 if (i->unit != CSSPrimitiveValue::CSS_IDENT) |
3752 return nullptr; | 3751 return nullptr; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4010 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) | 4009 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) |
4011 return false; | 4010 return false; |
4012 } else { | 4011 } else { |
4013 return false; | 4012 return false; |
4014 } | 4013 } |
4015 | 4014 |
4016 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier
Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa
nt); | 4015 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier
Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa
nt); |
4017 return !m_valueList->next(); | 4016 return !m_valueList->next(); |
4018 } | 4017 } |
4019 | 4018 |
4020 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver
flowPosition() | 4019 NullableCSSValue CSSPropertyParser::parseContentDistributionOverflowPosition() |
4021 { | 4020 { |
4022 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] | 4021 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] |
4023 // <baseline-position> = baseline | last-baseline; | 4022 // <baseline-position> = baseline | last-baseline; |
4024 // <content-distribution> = space-between | space-around | space-evenly | st
retch; | 4023 // <content-distribution> = space-between | space-around | space-evenly | st
retch; |
4025 // <content-position> = center | start | end | flex-start | flex-end | left
| right; | 4024 // <content-position> = center | start | end | flex-start | flex-end | left
| right; |
4026 // <overflow-position> = true | safe | 4025 // <overflow-position> = true | safe |
4027 | 4026 |
4028 // auto | <baseline-position> | 4027 // auto | <baseline-position> |
4029 CSSParserValue* value = m_valueList->current(); | 4028 CSSParserValue* value = m_valueList->current(); |
4030 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { | 4029 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4149 if (!args->currentIndex() && argument->id != CSSValueAt) { | 4148 if (!args->currentIndex() && argument->id != CSSValueAt) { |
4150 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { | 4149 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius(
argument)) { |
4151 shape->setRadius(radius); | 4150 shape->setRadius(radius); |
4152 continue; | 4151 continue; |
4153 } | 4152 } |
4154 | 4153 |
4155 return nullptr; | 4154 return nullptr; |
4156 } | 4155 } |
4157 | 4156 |
4158 if (argument->id == CSSValueAt && args->next()) { | 4157 if (argument->id == CSSValueAt && args->next()) { |
4159 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 4158 NullableCSSValue centerX; |
4160 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 4159 NullableCSSValue centerY; |
4161 parseFillPosition(args, centerX, centerY); | 4160 parseFillPosition(args, centerX, centerY); |
4162 if (centerX && centerY && !args->current()) { | 4161 if (centerX && centerY && !args->current()) { |
4163 ASSERT(centerX->isPrimitiveValue()); | 4162 ASSERT(centerX->isPrimitiveValue()); |
4164 ASSERT(centerY->isPrimitiveValue()); | 4163 ASSERT(centerY->isPrimitiveValue()); |
4165 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | 4164 shape->setCenterX(toCSSPrimitiveValue(centerX)); |
4166 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | 4165 shape->setCenterY(toCSSPrimitiveValue(centerY)); |
4167 } else { | 4166 } else { |
4168 return nullptr; | 4167 return nullptr; |
4169 } | 4168 } |
4170 } else { | 4169 } else { |
4171 return nullptr; | 4170 return nullptr; |
4172 } | 4171 } |
4173 } | 4172 } |
4174 | 4173 |
4175 return shape; | 4174 return shape; |
4176 } | 4175 } |
(...skipping 24 matching lines...) Expand all Loading... |
4201 else | 4200 else |
4202 shape->setRadiusY(radius); | 4201 shape->setRadiusY(radius); |
4203 continue; | 4202 continue; |
4204 } | 4203 } |
4205 | 4204 |
4206 return nullptr; | 4205 return nullptr; |
4207 } | 4206 } |
4208 | 4207 |
4209 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) | 4208 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) |
4210 return nullptr; | 4209 return nullptr; |
4211 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 4210 NullableCSSValue centerX; |
4212 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 4211 NullableCSSValue centerY; |
4213 parseFillPosition(args, centerX, centerY); | 4212 parseFillPosition(args, centerX, centerY); |
4214 if (!centerX || !centerY || args->current()) | 4213 if (!centerX || !centerY || args->current()) |
4215 return nullptr; | 4214 return nullptr; |
4216 | 4215 |
4217 ASSERT(centerX->isPrimitiveValue()); | 4216 ASSERT(centerX->isPrimitiveValue()); |
4218 ASSERT(centerY->isPrimitiveValue()); | 4217 ASSERT(centerY->isPrimitiveValue()); |
4219 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | 4218 shape->setCenterX(toCSSPrimitiveValue(centerX)); |
4220 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | 4219 shape->setCenterY(toCSSPrimitiveValue(centerY)); |
4221 } | 4220 } |
4222 | 4221 |
4223 return shape; | 4222 return shape; |
4224 } | 4223 } |
4225 | 4224 |
4226 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) | 4225 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) |
4227 { | 4226 { |
4228 ASSERT(args); | 4227 ASSERT(args); |
4229 | 4228 |
4230 unsigned size = args->size(); | 4229 unsigned size = args->size(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4278 case CSSValueBorderBox: | 4277 case CSSValueBorderBox: |
4279 case CSSValueMarginBox: | 4278 case CSSValueMarginBox: |
4280 return true; | 4279 return true; |
4281 default: | 4280 default: |
4282 break; | 4281 break; |
4283 } | 4282 } |
4284 | 4283 |
4285 return false; | 4284 return false; |
4286 } | 4285 } |
4287 | 4286 |
4288 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
tyID propId) | 4287 NullableCSSValue CSSPropertyParser::parseShapeProperty(CSSPropertyID propId) |
4289 { | 4288 { |
4290 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; | 4289 NullableCSSValue imageValue; |
4291 if (parseFillImage(m_valueList, imageValue)) { | 4290 if (parseFillImage(m_valueList, imageValue)) { |
4292 m_valueList->next(); | 4291 m_valueList->next(); |
4293 return imageValue.release(); | 4292 return imageValue; |
4294 } | 4293 } |
4295 | 4294 |
4296 return parseBasicShapeAndOrBox(); | 4295 return parseBasicShapeAndOrBox(); |
4297 } | 4296 } |
4298 | 4297 |
4299 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() | 4298 NullableCSSValue CSSPropertyParser::parseBasicShapeAndOrBox() |
4300 { | 4299 { |
4301 CSSParserValue* value = m_valueList->current(); | 4300 CSSParserValue* value = m_valueList->current(); |
4302 | 4301 |
4303 bool shapeFound = false; | 4302 bool shapeFound = false; |
4304 bool boxFound = false; | 4303 bool boxFound = false; |
4305 CSSValueID valueId; | 4304 CSSValueID valueId; |
4306 | 4305 |
4307 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 4306 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
4308 for (unsigned i = 0; i < 2; ++i) { | 4307 for (unsigned i = 0; i < 2; ++i) { |
4309 if (!value) | 4308 if (!value) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4421 return false; | 4420 return false; |
4422 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); | 4421 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); |
4423 if (!lineHeight) | 4422 if (!lineHeight) |
4424 return false; | 4423 return false; |
4425 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); | 4424 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); |
4426 } else { | 4425 } else { |
4427 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important, true); | 4426 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important, true); |
4428 } | 4427 } |
4429 | 4428 |
4430 // Font family must come now. | 4429 // Font family must come now. |
4431 RefPtrWillBeRawPtr<CSSValue> parsedFamilyValue = parseFontFamily(); | 4430 NullableCSSValue parsedFamilyValue = parseFontFamily(); |
4432 if (!parsedFamilyValue) | 4431 if (!parsedFamilyValue) |
4433 return false; | 4432 return false; |
4434 | 4433 |
4435 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); | 4434 addProperty(CSSPropertyFontFamily, *parsedFamilyValue, important); |
4436 | 4435 |
4437 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that | 4436 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that |
4438 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values | 4437 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values |
4439 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. | 4438 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. |
4440 if (m_valueList->current()) | 4439 if (m_valueList->current()) |
4441 return false; | 4440 return false; |
4442 | 4441 |
4443 return true; | 4442 return true; |
4444 } | 4443 } |
4445 | 4444 |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5442 | 5441 |
5443 if (context.allowBreak) { | 5442 if (context.allowBreak) { |
5444 context.commitValue(); | 5443 context.commitValue(); |
5445 if (context.values && context.values->length()) | 5444 if (context.values && context.values->length()) |
5446 return context.values.release(); | 5445 return context.values.release(); |
5447 } | 5446 } |
5448 | 5447 |
5449 return nullptr; | 5448 return nullptr; |
5450 } | 5449 } |
5451 | 5450 |
5452 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() | 5451 NullableCSSValue CSSPropertyParser::parseReflect() |
5453 { | 5452 { |
5454 // box-reflect: <direction> <offset> <mask> | 5453 // box-reflect: <direction> <offset> <mask> |
5455 | 5454 |
5456 // Direction comes first. | 5455 // Direction comes first. |
5457 CSSParserValue* val = m_valueList->current(); | 5456 CSSParserValue* val = m_valueList->current(); |
5458 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; | 5457 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; |
5459 switch (val->id) { | 5458 switch (val->id) { |
5460 case CSSValueAbove: | 5459 case CSSValueAbove: |
5461 case CSSValueBelow: | 5460 case CSSValueBelow: |
5462 case CSSValueLeft: | 5461 case CSSValueLeft: |
5463 case CSSValueRight: | 5462 case CSSValueRight: |
5464 direction = cssValuePool().createIdentifierValue(val->id); | 5463 direction = cssValuePool().createIdentifierValue(val->id); |
5465 break; | 5464 break; |
5466 default: | 5465 default: |
5467 return nullptr; | 5466 return nullptr; |
5468 } | 5467 } |
5469 | 5468 |
5470 // The offset comes next. | 5469 // The offset comes next. |
5471 val = m_valueList->next(); | 5470 val = m_valueList->next(); |
5472 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; | 5471 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; |
5473 if (!val) | 5472 if (!val) |
5474 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); | 5473 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); |
5475 else { | 5474 else { |
5476 if (!validUnit(val, FLength | FPercent)) | 5475 if (!validUnit(val, FLength | FPercent)) |
5477 return nullptr; | 5476 return nullptr; |
5478 offset = createPrimitiveNumericValue(val); | 5477 offset = createPrimitiveNumericValue(val); |
5479 } | 5478 } |
5480 | 5479 |
5481 // Now for the mask. | 5480 // Now for the mask. |
5482 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; | 5481 NullableCSSValue mask; |
5483 val = m_valueList->next(); | 5482 val = m_valueList->next(); |
5484 if (val) { | 5483 if (val) { |
5485 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); | 5484 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); |
5486 if (!mask) | 5485 if (!mask) |
5487 return nullptr; | 5486 return nullptr; |
5488 } | 5487 } |
5489 | 5488 |
5490 return CSSReflectValue::create(direction.release(), offset.release(), mask.r
elease()); | 5489 return CSSReflectValue::create(direction.get(), offset.get(), mask); |
5491 } | 5490 } |
5492 | 5491 |
5493 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse
tValue, int argSize) | 5492 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse
tValue, int argSize) |
5494 { | 5493 { |
5495 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; | 5494 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; |
5496 } | 5495 } |
5497 | 5496 |
5498 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) | 5497 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) |
5499 { | 5498 { |
5500 if (!args || !args->size() || args->size() > 3) | 5499 if (!args || !args->size() || args->size() > 3) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5532 flexShrink = 1; | 5531 flexShrink = 1; |
5533 if (!flexBasis) | 5532 if (!flexBasis) |
5534 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT
AGE); | 5533 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT
AGE); |
5535 | 5534 |
5536 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::CSS_NUMBER), important); | 5535 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::CSS_NUMBER), important); |
5537 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); | 5536 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); |
5538 addProperty(CSSPropertyFlexBasis, flexBasis, important); | 5537 addProperty(CSSPropertyFlexBasis, flexBasis, important); |
5539 return true; | 5538 return true; |
5540 } | 5539 } |
5541 | 5540 |
5542 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseObjectPosition() | 5541 NullableCSSValue CSSPropertyParser::parseObjectPosition() |
5543 { | 5542 { |
5544 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 5543 NullableCSSValue xValue; |
5545 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 5544 NullableCSSValue yValue; |
5546 parseFillPosition(m_valueList, xValue, yValue); | 5545 parseFillPosition(m_valueList, xValue, yValue); |
5547 if (!xValue || !yValue) | 5546 if (!xValue || !yValue) |
5548 return nullptr; | 5547 return nullptr; |
5549 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim
itiveValue(yValue.get()), Pair::KeepIdenticalValues); | 5548 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue), toCSSPrimitiveV
alue(yValue), Pair::KeepIdenticalValues); |
5550 } | 5549 } |
5551 | 5550 |
5552 class BorderImageParseContext { | 5551 class BorderImageParseContext { |
5553 STACK_ALLOCATED(); | 5552 STACK_ALLOCATED(); |
5554 public: | 5553 public: |
5555 BorderImageParseContext() | 5554 BorderImageParseContext() |
5556 : m_canAdvance(false) | 5555 : m_canAdvance(false) |
5557 , m_allowCommit(true) | 5556 , m_allowCommit(true) |
5558 , m_allowImage(true) | 5557 , m_allowImage(true) |
5559 , m_allowImageSlice(true) | 5558 , m_allowImageSlice(true) |
5560 , m_allowRepeat(true) | 5559 , m_allowRepeat(true) |
5561 , m_allowForwardSlashOperator(false) | 5560 , m_allowForwardSlashOperator(false) |
5562 , m_allowWidth(false) | 5561 , m_allowWidth(false) |
5563 , m_requireOutset(false) | 5562 , m_requireOutset(false) |
5564 {} | 5563 {} |
5565 | 5564 |
5566 bool canAdvance() const { return m_canAdvance; } | 5565 bool canAdvance() const { return m_canAdvance; } |
5567 void setCanAdvance(bool canAdvance) { m_canAdvance = canAdvance; } | 5566 void setCanAdvance(bool canAdvance) { m_canAdvance = canAdvance; } |
5568 | 5567 |
5569 bool allowCommit() const { return m_allowCommit; } | 5568 bool allowCommit() const { return m_allowCommit; } |
5570 bool allowImage() const { return m_allowImage; } | 5569 bool allowImage() const { return m_allowImage; } |
5571 bool allowImageSlice() const { return m_allowImageSlice; } | 5570 bool allowImageSlice() const { return m_allowImageSlice; } |
5572 bool allowRepeat() const { return m_allowRepeat; } | 5571 bool allowRepeat() const { return m_allowRepeat; } |
5573 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator;
} | 5572 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator;
} |
5574 | 5573 |
5575 bool allowWidth() const { return m_allowWidth; } | 5574 bool allowWidth() const { return m_allowWidth; } |
5576 bool requireOutset() const { return m_requireOutset; } | 5575 bool requireOutset() const { return m_requireOutset; } |
5577 | 5576 |
5578 void commitImage(PassRefPtrWillBeRawPtr<CSSValue> image) | 5577 void commitImage(CSSValue image) |
5579 { | 5578 { |
5580 m_image = image; | 5579 m_image = image; |
5581 m_canAdvance = true; | 5580 m_canAdvance = true; |
5582 m_allowCommit = true; | 5581 m_allowCommit = true; |
5583 m_allowImage = false; | 5582 m_allowImage = false; |
5584 m_allowForwardSlashOperator = false; | 5583 m_allowForwardSlashOperator = false; |
5585 m_allowWidth = false; | 5584 m_allowWidth = false; |
5586 m_requireOutset = false; | 5585 m_requireOutset = false; |
5587 m_allowImageSlice = !m_imageSlice; | 5586 m_allowImageSlice = !m_imageSlice; |
5588 m_allowRepeat = !m_repeat; | 5587 m_allowRepeat = !m_repeat; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5633 m_outset = outset; | 5632 m_outset = outset; |
5634 m_canAdvance = true; | 5633 m_canAdvance = true; |
5635 m_allowCommit = true; | 5634 m_allowCommit = true; |
5636 m_allowImageSlice = false; | 5635 m_allowImageSlice = false; |
5637 m_allowForwardSlashOperator = false; | 5636 m_allowForwardSlashOperator = false; |
5638 m_allowWidth = false; | 5637 m_allowWidth = false; |
5639 m_requireOutset = false; | 5638 m_requireOutset = false; |
5640 m_allowImage = !m_image; | 5639 m_allowImage = !m_image; |
5641 m_allowRepeat = !m_repeat; | 5640 m_allowRepeat = !m_repeat; |
5642 } | 5641 } |
5643 void commitRepeat(PassRefPtrWillBeRawPtr<CSSValue> repeat) | 5642 void commitRepeat(CSSValue repeat) |
5644 { | 5643 { |
5645 m_repeat = repeat; | 5644 m_repeat = repeat; |
5646 m_canAdvance = true; | 5645 m_canAdvance = true; |
5647 m_allowCommit = true; | 5646 m_allowCommit = true; |
5648 m_allowRepeat = false; | 5647 m_allowRepeat = false; |
5649 m_allowForwardSlashOperator = false; | 5648 m_allowForwardSlashOperator = false; |
5650 m_allowWidth = false; | 5649 m_allowWidth = false; |
5651 m_requireOutset = false; | 5650 m_requireOutset = false; |
5652 m_allowImageSlice = !m_imageSlice; | 5651 m_allowImageSlice = !m_imageSlice; |
5653 m_allowImage = !m_image; | 5652 m_allowImage = !m_image; |
5654 } | 5653 } |
5655 | 5654 |
5656 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() | 5655 CSSValue commitCSSValue() |
5657 { | 5656 { |
5658 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth
.get(), m_outset.get(), m_repeat.get()); | 5657 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth
.get(), m_outset.get(), m_repeat); |
5659 } | 5658 } |
5660 | 5659 |
5661 bool m_canAdvance; | 5660 bool m_canAdvance; |
5662 | 5661 |
5663 bool m_allowCommit; | 5662 bool m_allowCommit; |
5664 bool m_allowImage; | 5663 bool m_allowImage; |
5665 bool m_allowImageSlice; | 5664 bool m_allowImageSlice; |
5666 bool m_allowRepeat; | 5665 bool m_allowRepeat; |
5667 bool m_allowForwardSlashOperator; | 5666 bool m_allowForwardSlashOperator; |
5668 | 5667 |
5669 bool m_allowWidth; | 5668 bool m_allowWidth; |
5670 bool m_requireOutset; | 5669 bool m_requireOutset; |
5671 | 5670 |
5672 RefPtrWillBeMember<CSSValue> m_image; | 5671 NullableCSSValue m_image; |
5673 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; | 5672 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; |
5674 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; | 5673 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; |
5675 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; | 5674 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; |
5676 | 5675 |
5677 RefPtrWillBeMember<CSSValue> m_repeat; | 5676 NullableCSSValue m_repeat; |
5678 }; | 5677 }; |
5679 | 5678 |
5680 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde
rImageParseContext& context) | 5679 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde
rImageParseContext& context) |
5681 { | 5680 { |
5682 CSSPropertyParser::ShorthandScope scope(this, propId); | 5681 CSSPropertyParser::ShorthandScope scope(this, propId); |
5683 while (CSSParserValue* val = m_valueList->current()) { | 5682 while (CSSParserValue* val = m_valueList->current()) { |
5684 context.setCanAdvance(false); | 5683 context.setCanAdvance(false); |
5685 | 5684 |
5686 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 5685 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
5687 context.commitForwardSlashOperator(); | 5686 context.commitForwardSlashOperator(); |
5688 | 5687 |
5689 if (!context.canAdvance() && context.allowImage()) { | 5688 if (!context.canAdvance() && context.allowImage()) { |
5690 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 5689 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
5691 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); | 5690 context.commitImage(createCSSImageValueWithReferrer(val->string,
m_context.completeURL(val->string))); |
5692 } else if (isGeneratedImageValue(val)) { | 5691 } else if (isGeneratedImageValue(val)) { |
5693 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 5692 NullableCSSValue value; |
5694 if (parseGeneratedImage(m_valueList, value)) | 5693 if (parseGeneratedImage(m_valueList, value)) |
5695 context.commitImage(value.release()); | 5694 context.commitImage(*value); |
5696 else | 5695 else |
5697 return false; | 5696 return false; |
5698 } else if (val->unit == CSSParserValue::Function && val->function->i
d == CSSValueWebkitImageSet) { | 5697 } else if (val->unit == CSSParserValue::Function && val->function->i
d == CSSValueWebkitImageSet) { |
5699 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); | 5698 NullableCSSValue value = parseImageSet(m_valueList); |
5700 if (value) | 5699 if (value) |
5701 context.commitImage(value.release()); | 5700 context.commitImage(*value); |
5702 else | 5701 else |
5703 return false; | 5702 return false; |
5704 } else if (val->id == CSSValueNone) | 5703 } else if (val->id == CSSValueNone) |
5705 context.commitImage(cssValuePool().createIdentifierValue(CSSValu
eNone)); | 5704 context.commitImage(cssValuePool().createIdentifierValue(CSSValu
eNone)); |
5706 } | 5705 } |
5707 | 5706 |
5708 if (!context.canAdvance() && context.allowImageSlice()) { | 5707 if (!context.canAdvance() && context.allowImageSlice()) { |
5709 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; | 5708 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; |
5710 if (parseBorderImageSlice(propId, imageSlice)) | 5709 if (parseBorderImageSlice(propId, imageSlice)) |
5711 context.commitImageSlice(imageSlice.release()); | 5710 context.commitImageSlice(imageSlice.release()); |
5712 } | 5711 } |
5713 | 5712 |
5714 if (!context.canAdvance() && context.allowRepeat()) { | 5713 if (!context.canAdvance() && context.allowRepeat()) { |
5715 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; | 5714 NullableCSSValue repeat; |
5716 if (parseBorderImageRepeat(repeat)) | 5715 if (parseBorderImageRepeat(repeat)) |
5717 context.commitRepeat(repeat.release()); | 5716 context.commitRepeat(*repeat); |
5718 } | 5717 } |
5719 | 5718 |
5720 if (!context.canAdvance() && context.allowWidth()) { | 5719 if (!context.canAdvance() && context.allowWidth()) { |
5721 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; | 5720 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; |
5722 if (parseBorderImageWidth(borderWidth)) | 5721 if (parseBorderImageWidth(borderWidth)) |
5723 context.commitBorderWidth(borderWidth.release()); | 5722 context.commitBorderWidth(borderWidth.release()); |
5724 } | 5723 } |
5725 | 5724 |
5726 if (!context.canAdvance() && context.requireOutset()) { | 5725 if (!context.canAdvance() && context.requireOutset()) { |
5727 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; | 5726 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; |
5728 if (parseBorderImageOutset(borderOutset)) | 5727 if (parseBorderImageOutset(borderOutset)) |
5729 context.commitBorderOutset(borderOutset.release()); | 5728 context.commitBorderOutset(borderOutset.release()); |
5730 } | 5729 } |
5731 | 5730 |
5732 if (!context.canAdvance()) | 5731 if (!context.canAdvance()) |
5733 return false; | 5732 return false; |
5734 | 5733 |
5735 m_valueList->next(); | 5734 m_valueList->next(); |
5736 } | 5735 } |
5737 | 5736 |
5738 return context.allowCommit(); | 5737 return context.allowCommit(); |
5739 } | 5738 } |
5740 | 5739 |
5741 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP
trWillBeRawPtr<CSSValue> value, bool important) | 5740 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, Nullable
CSSValue value, bool important) |
5742 { | 5741 { |
5743 if (value) | 5742 if (value) |
5744 addProperty(propId, value, important); | 5743 addProperty(propId, *value, important); |
5745 else | 5744 else |
5746 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa
nt, true); | 5745 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa
nt, true); |
5747 } | 5746 } |
5748 | 5747 |
5749 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp
ortant) | 5748 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp
ortant) |
5750 { | 5749 { |
5751 BorderImageParseContext context; | 5750 BorderImageParseContext context; |
5752 if (buildBorderImageParseContext(propId, context)) { | 5751 if (buildBorderImageParseContext(propId, context)) { |
5753 switch (propId) { | 5752 switch (propId) { |
5754 case CSSPropertyWebkitMaskBoxImage: | 5753 case CSSPropertyWebkitMaskBoxImage: |
5755 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte
xt.m_image, important); | 5754 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte
xt.m_image, important); |
5756 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex
t.m_imageSlice.get(), important); | 5755 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex
t.m_imageSlice.get(), important); |
5757 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex
t.m_borderWidth.get(), important); | 5756 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex
t.m_borderWidth.get(), important); |
5758 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte
xt.m_outset.get(), important); | 5757 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte
xt.m_outset.get(), important); |
5759 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte
xt.m_repeat.get(), important); | 5758 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte
xt.m_repeat, important); |
5760 return true; | 5759 return true; |
5761 case CSSPropertyBorderImage: | 5760 case CSSPropertyBorderImage: |
5762 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im
age, important); | 5761 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im
age, important); |
5763 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima
geSlice.get(), important); | 5762 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima
geSlice.get(), important); |
5764 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor
derWidth.get(), important); | 5763 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor
derWidth.get(), important); |
5765 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou
tset.get(), important); | 5764 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou
tset.get(), important); |
5766 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re
peat, important); | 5765 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re
peat, important); |
5767 return true; | 5766 return true; |
5768 default: | 5767 default: |
5769 ASSERT_NOT_REACHED(); | 5768 ASSERT_NOT_REACHED(); |
5770 return false; | 5769 return false; |
5771 } | 5770 } |
5772 } | 5771 } |
5773 return false; | 5772 return false; |
5774 } | 5773 } |
5775 | 5774 |
5776 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty
ID propId) | 5775 NullableCSSValue CSSPropertyParser::parseBorderImage(CSSPropertyID propId) |
5777 { | 5776 { |
5778 BorderImageParseContext context; | 5777 BorderImageParseContext context; |
5779 if (buildBorderImageParseContext(propId, context)) { | 5778 if (buildBorderImageParseContext(propId, context)) { |
5780 return context.commitCSSValue(); | 5779 return context.commitCSSValue(); |
5781 } | 5780 } |
5782 return nullptr; | 5781 return nullptr; |
5783 } | 5782 } |
5784 | 5783 |
5785 static bool isBorderImageRepeatKeyword(int id) | 5784 static bool isBorderImageRepeatKeyword(int id) |
5786 { | 5785 { |
5787 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; | 5786 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace
|| id == CSSValueRound; |
5788 } | 5787 } |
5789 | 5788 |
5790 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res
ult) | 5789 bool CSSPropertyParser::parseBorderImageRepeat(NullableCSSValue& result) |
5791 { | 5790 { |
5792 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; | 5791 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; |
5793 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; | 5792 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; |
5794 CSSParserValue* val = m_valueList->current(); | 5793 CSSParserValue* val = m_valueList->current(); |
5795 if (!val) | 5794 if (!val) |
5796 return false; | 5795 return false; |
5797 if (isBorderImageRepeatKeyword(val->id)) | 5796 if (isBorderImageRepeatKeyword(val->id)) |
5798 firstValue = cssValuePool().createIdentifierValue(val->id); | 5797 firstValue = cssValuePool().createIdentifierValue(val->id); |
5799 else | 5798 else |
5800 return false; | 5799 return false; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6089 completeBorderRadii(radii[1]); | 6088 completeBorderRadii(radii[1]); |
6090 | 6089 |
6091 ImplicitScope implicitScope(this); | 6090 ImplicitScope implicitScope(this); |
6092 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); | 6091 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); |
6093 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); | 6092 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); |
6094 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); | 6093 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); |
6095 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); | 6094 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); |
6096 return true; | 6095 return true; |
6097 } | 6096 } |
6098 | 6097 |
6099 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu
e) | 6098 NullableCSSValue CSSPropertyParser::parseCounter(int defaultValue) |
6100 { | 6099 { |
6101 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 6100 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
6102 | 6101 |
6103 while (m_valueList->current()) { | 6102 while (m_valueList->current()) { |
6104 CSSParserValue* val = m_valueList->current(); | 6103 CSSParserValue* val = m_valueList->current(); |
6105 if (val->unit != CSSPrimitiveValue::CSS_IDENT) | 6104 if (val->unit != CSSPrimitiveValue::CSS_IDENT) |
6106 return nullptr; | 6105 return nullptr; |
6107 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto
mIdentValue(val); | 6106 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto
mIdentValue(val); |
6108 m_valueList->next(); | 6107 m_valueList->next(); |
6109 | 6108 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6198 stop.m_color = cssValuePool().createIdentifierValue(id); | 6197 stop.m_color = cssValuePool().createIdentifierValue(id); |
6199 else | 6198 else |
6200 stop.m_color = parseColor(stopArg); | 6199 stop.m_color = parseColor(stopArg); |
6201 if (!stop.m_color) | 6200 if (!stop.m_color) |
6202 return false; | 6201 return false; |
6203 } | 6202 } |
6204 | 6203 |
6205 return true; | 6204 return true; |
6206 } | 6205 } |
6207 | 6206 |
6208 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
efPtrWillBeRawPtr<CSSValue>& gradient) | 6207 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, N
ullableCSSValue& gradient) |
6209 { | 6208 { |
6210 // Walk the arguments. | 6209 // Walk the arguments. |
6211 CSSParserValueList* args = valueList->current()->function->args.get(); | 6210 CSSParserValueList* args = valueList->current()->function->args.get(); |
6212 if (!args || args->size() == 0) | 6211 if (!args || args->size() == 0) |
6213 return false; | 6212 return false; |
6214 | 6213 |
6215 // The first argument is the gradient type. It is an identifier. | 6214 // The first argument is the gradient type. It is an identifier. |
6216 CSSGradientType gradientType; | 6215 CSSGradientType gradientType; |
6217 CSSParserValue* a = args->current(); | 6216 CSSParserValue* a = args->current(); |
6218 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) | 6217 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6351 case CSSValueTop: | 6350 case CSSValueTop: |
6352 case CSSValueBottom: | 6351 case CSSValueBottom: |
6353 isHorizontal = false; | 6352 isHorizontal = false; |
6354 break; | 6353 break; |
6355 default: | 6354 default: |
6356 return nullptr; | 6355 return nullptr; |
6357 } | 6356 } |
6358 return cssValuePool().createIdentifierValue(a->id); | 6357 return cssValuePool().createIdentifierValue(a->id); |
6359 } | 6358 } |
6360 | 6359 |
6361 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL
ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6360 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL
ist, NullableCSSValue& gradient, CSSGradientRepeat repeating) |
6362 { | 6361 { |
6363 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::
create(repeating, CSSPrefixedLinearGradient); | 6362 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::
create(repeating, CSSPrefixedLinearGradient); |
6364 | 6363 |
6365 // Walk the arguments. | 6364 // Walk the arguments. |
6366 CSSParserValueList* args = valueList->current()->function->args.get(); | 6365 CSSParserValueList* args = valueList->current()->function->args.get(); |
6367 if (!args || !args->size()) | 6366 if (!args || !args->size()) |
6368 return false; | 6367 return false; |
6369 | 6368 |
6370 CSSParserValue* a = args->current(); | 6369 CSSParserValue* a = args->current(); |
6371 if (!a) | 6370 if (!a) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6421 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6420 if (!parseGradientColorStops(args, result.get(), expectComma)) |
6422 return false; | 6421 return false; |
6423 | 6422 |
6424 if (!result->stopCount()) | 6423 if (!result->stopCount()) |
6425 return false; | 6424 return false; |
6426 | 6425 |
6427 gradient = result.release(); | 6426 gradient = result.release(); |
6428 return true; | 6427 return true; |
6429 } | 6428 } |
6430 | 6429 |
6431 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL
ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6430 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL
ist, NullableCSSValue& gradient, CSSGradientRepeat repeating) |
6432 { | 6431 { |
6433 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::
create(repeating, CSSPrefixedRadialGradient); | 6432 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::
create(repeating, CSSPrefixedRadialGradient); |
6434 | 6433 |
6435 // Walk the arguments. | 6434 // Walk the arguments. |
6436 CSSParserValueList* args = valueList->current()->function->args.get(); | 6435 CSSParserValueList* args = valueList->current()->function->args.get(); |
6437 if (!args || !args->size()) | 6436 if (!args || !args->size()) |
6438 return false; | 6437 return false; |
6439 | 6438 |
6440 CSSParserValue* a = args->current(); | 6439 CSSParserValue* a = args->current(); |
6441 if (!a) | 6440 if (!a) |
6442 return false; | 6441 return false; |
6443 | 6442 |
6444 bool expectComma = false; | 6443 bool expectComma = false; |
6445 | 6444 |
6446 // Optional background-position | 6445 // Optional background-position |
6447 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 6446 NullableCSSValue centerX; |
6448 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 6447 NullableCSSValue centerY; |
6449 // parse2ValuesFillPosition advances the args next pointer. | 6448 // parse2ValuesFillPosition advances the args next pointer. |
6450 parse2ValuesFillPosition(args, centerX, centerY); | 6449 parse2ValuesFillPosition(args, centerX, centerY); |
6451 | 6450 |
6452 if ((centerX || centerY) && !consumeComma(args)) | 6451 if ((centerX || centerY) && !consumeComma(args)) |
6453 return false; | 6452 return false; |
6454 | 6453 |
6455 a = args->current(); | 6454 a = args->current(); |
6456 if (!a) | 6455 if (!a) |
6457 return false; | 6456 return false; |
6458 | 6457 |
6459 result->setFirstX(toCSSPrimitiveValue(centerX.get())); | 6458 result->setFirstX(toCSSPrimitiveValue(centerX)); |
6460 result->setSecondX(toCSSPrimitiveValue(centerX.get())); | 6459 result->setSecondX(toCSSPrimitiveValue(centerX)); |
6461 // CSS3 radial gradients always share the same start and end point. | 6460 // CSS3 radial gradients always share the same start and end point. |
6462 result->setFirstY(toCSSPrimitiveValue(centerY.get())); | 6461 result->setFirstY(toCSSPrimitiveValue(centerY)); |
6463 result->setSecondY(toCSSPrimitiveValue(centerY.get())); | 6462 result->setSecondY(toCSSPrimitiveValue(centerY)); |
6464 | 6463 |
6465 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; | 6464 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; |
6466 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; | 6465 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; |
6467 | 6466 |
6468 // Optional shape and/or size in any order. | 6467 // Optional shape and/or size in any order. |
6469 for (int i = 0; i < 2; ++i) { | 6468 for (int i = 0; i < 2; ++i) { |
6470 if (a->unit != CSSPrimitiveValue::CSS_IDENT) | 6469 if (a->unit != CSSPrimitiveValue::CSS_IDENT) |
6471 break; | 6470 break; |
6472 | 6471 |
6473 bool foundValue = false; | 6472 bool foundValue = false; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6533 result->setEndHorizontalSize(horizontalSize); | 6532 result->setEndHorizontalSize(horizontalSize); |
6534 result->setEndVerticalSize(verticalSize); | 6533 result->setEndVerticalSize(verticalSize); |
6535 | 6534 |
6536 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6535 if (!parseGradientColorStops(args, result.get(), expectComma)) |
6537 return false; | 6536 return false; |
6538 | 6537 |
6539 gradient = result.release(); | 6538 gradient = result.release(); |
6540 return true; | 6539 return true; |
6541 } | 6540 } |
6542 | 6541 |
6543 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6542 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, Nulla
bleCSSValue& gradient, CSSGradientRepeat repeating) |
6544 { | 6543 { |
6545 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::
create(repeating, CSSLinearGradient); | 6544 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue::
create(repeating, CSSLinearGradient); |
6546 | 6545 |
6547 CSSParserFunction* function = valueList->current()->function; | 6546 CSSParserFunction* function = valueList->current()->function; |
6548 CSSParserValueList* args = function->args.get(); | 6547 CSSParserValueList* args = function->args.get(); |
6549 if (!args || !args->size()) | 6548 if (!args || !args->size()) |
6550 return false; | 6549 return false; |
6551 | 6550 |
6552 CSSParserValue* a = args->current(); | 6551 CSSParserValue* a = args->current(); |
6553 if (!a) | 6552 if (!a) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6607 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6606 if (!parseGradientColorStops(args, result.get(), expectComma)) |
6608 return false; | 6607 return false; |
6609 | 6608 |
6610 if (!result->stopCount()) | 6609 if (!result->stopCount()) |
6611 return false; | 6610 return false; |
6612 | 6611 |
6613 gradient = result.release(); | 6612 gradient = result.release(); |
6614 return true; | 6613 return true; |
6615 } | 6614 } |
6616 | 6615 |
6617 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6616 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, Nulla
bleCSSValue& gradient, CSSGradientRepeat repeating) |
6618 { | 6617 { |
6619 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::
create(repeating, CSSRadialGradient); | 6618 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue::
create(repeating, CSSRadialGradient); |
6620 | 6619 |
6621 CSSParserValueList* args = valueList->current()->function->args.get(); | 6620 CSSParserValueList* args = valueList->current()->function->args.get(); |
6622 if (!args || !args->size()) | 6621 if (!args || !args->size()) |
6623 return false; | 6622 return false; |
6624 | 6623 |
6625 CSSParserValue* a = args->current(); | 6624 CSSParserValue* a = args->current(); |
6626 if (!a) | 6625 if (!a) |
6627 return false; | 6626 return false; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6699 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) | 6698 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) |
6700 return false; | 6699 return false; |
6701 | 6700 |
6702 result->setShape(shapeValue); | 6701 result->setShape(shapeValue); |
6703 result->setSizingBehavior(sizeValue); | 6702 result->setSizingBehavior(sizeValue); |
6704 result->setEndHorizontalSize(horizontalSize); | 6703 result->setEndHorizontalSize(horizontalSize); |
6705 result->setEndVerticalSize(verticalSize); | 6704 result->setEndVerticalSize(verticalSize); |
6706 | 6705 |
6707 // Second part of grammar, the center-position clause: | 6706 // Second part of grammar, the center-position clause: |
6708 // at <position> | 6707 // at <position> |
6709 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 6708 NullableCSSValue centerX; |
6710 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 6709 NullableCSSValue centerY; |
6711 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) { | 6710 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) { |
6712 a = args->next(); | 6711 a = args->next(); |
6713 if (!a) | 6712 if (!a) |
6714 return false; | 6713 return false; |
6715 | 6714 |
6716 parseFillPosition(args, centerX, centerY); | 6715 parseFillPosition(args, centerX, centerY); |
6717 if (!(centerX && centerY)) | 6716 if (!(centerX && centerY)) |
6718 return false; | 6717 return false; |
6719 | 6718 |
6720 a = args->current(); | 6719 a = args->current(); |
6721 if (!a) | 6720 if (!a) |
6722 return false; | 6721 return false; |
6723 result->setFirstX(toCSSPrimitiveValue(centerX.get())); | 6722 result->setFirstX(toCSSPrimitiveValue(centerX)); |
6724 result->setFirstY(toCSSPrimitiveValue(centerY.get())); | 6723 result->setFirstY(toCSSPrimitiveValue(centerY)); |
6725 // Right now, CSS radial gradients have the same start and end centers. | 6724 // Right now, CSS radial gradients have the same start and end centers. |
6726 result->setSecondX(toCSSPrimitiveValue(centerX.get())); | 6725 result->setSecondX(toCSSPrimitiveValue(centerX)); |
6727 result->setSecondY(toCSSPrimitiveValue(centerY.get())); | 6726 result->setSecondY(toCSSPrimitiveValue(centerY)); |
6728 } | 6727 } |
6729 | 6728 |
6730 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) | 6729 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) |
6731 expectComma = true; | 6730 expectComma = true; |
6732 | 6731 |
6733 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6732 if (!parseGradientColorStops(args, result.get(), expectComma)) |
6734 return false; | 6733 return false; |
6735 | 6734 |
6736 gradient = result.release(); | 6735 gradient = result.release(); |
6737 return true; | 6736 return true; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6792 } | 6791 } |
6793 | 6792 |
6794 // The last color stop cannot be a color hint. | 6793 // The last color stop cannot be a color hint. |
6795 if (previousStopWasColorHint) | 6794 if (previousStopWasColorHint) |
6796 return false; | 6795 return false; |
6797 | 6796 |
6798 // Must have 2 or more stops to be valid. | 6797 // Must have 2 or more stops to be valid. |
6799 return gradient->stopCount() >= 2; | 6798 return gradient->stopCount() >= 2; |
6800 } | 6799 } |
6801 | 6800 |
6802 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& value) | 6801 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, Nulla
bleCSSValue& value) |
6803 { | 6802 { |
6804 CSSParserValue* val = valueList->current(); | 6803 CSSParserValue* val = valueList->current(); |
6805 | 6804 |
6806 if (val->unit != CSSParserValue::Function) | 6805 if (val->unit != CSSParserValue::Function) |
6807 return false; | 6806 return false; |
6808 | 6807 |
6809 if (val->function->id == CSSValueWebkitGradient) { | 6808 if (val->function->id == CSSValueWebkitGradient) { |
6810 // FIXME: This should send a deprecation message. | 6809 // FIXME: This should send a deprecation message. |
6811 if (m_context.useCounter()) | 6810 if (m_context.useCounter()) |
6812 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); | 6811 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6854 | 6853 |
6855 if (val->function->id == CSSValueWebkitCanvas) | 6854 if (val->function->id == CSSValueWebkitCanvas) |
6856 return parseCanvas(valueList, value); | 6855 return parseCanvas(valueList, value); |
6857 | 6856 |
6858 if (val->function->id == CSSValueWebkitCrossFade) | 6857 if (val->function->id == CSSValueWebkitCrossFade) |
6859 return parseCrossfade(valueList, value); | 6858 return parseCrossfade(valueList, value); |
6860 | 6859 |
6861 return false; | 6860 return false; |
6862 } | 6861 } |
6863 | 6862 |
6864 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& crossfade) | 6863 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, NullableCS
SValue& crossfade) |
6865 { | 6864 { |
6866 // Walk the arguments. | 6865 // Walk the arguments. |
6867 CSSParserValueList* args = valueList->current()->function->args.get(); | 6866 CSSParserValueList* args = valueList->current()->function->args.get(); |
6868 if (!args || args->size() != 5) | 6867 if (!args || args->size() != 5) |
6869 return false; | 6868 return false; |
6870 RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr; | 6869 NullableCSSValue fromImageValue; |
6871 RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr; | 6870 NullableCSSValue toImageValue; |
6872 | 6871 |
6873 // The first argument is the "from" image. It is a fill image. | 6872 // The first argument is the "from" image. It is a fill image. |
6874 if (!args->current() || !parseFillImage(args, fromImageValue)) | 6873 if (!args->current() || !parseFillImage(args, fromImageValue)) |
6875 return false; | 6874 return false; |
6876 args->next(); | 6875 args->next(); |
6877 | 6876 |
6878 if (!consumeComma(args)) | 6877 if (!consumeComma(args)) |
6879 return false; | 6878 return false; |
6880 | 6879 |
6881 // The second argument is the "to" image. It is a fill image. | 6880 // The second argument is the "to" image. It is a fill image. |
(...skipping 10 matching lines...) Expand all Loading... |
6892 if (!value) | 6891 if (!value) |
6893 return false; | 6892 return false; |
6894 | 6893 |
6895 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE) | 6894 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE) |
6896 percentage = cssValuePool().createValue(clampTo<double>(value->fValue /
100, 0, 1), CSSPrimitiveValue::CSS_NUMBER); | 6895 percentage = cssValuePool().createValue(clampTo<double>(value->fValue /
100, 0, 1), CSSPrimitiveValue::CSS_NUMBER); |
6897 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) | 6896 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) |
6898 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0
, 1), CSSPrimitiveValue::CSS_NUMBER); | 6897 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0
, 1), CSSPrimitiveValue::CSS_NUMBER); |
6899 else | 6898 else |
6900 return false; | 6899 return false; |
6901 | 6900 |
6902 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fro
mImageValue, toImageValue); | 6901 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(*fr
omImageValue, *toImageValue); |
6903 result->setPercentage(percentage); | 6902 result->setPercentage(percentage); |
6904 | 6903 |
6905 crossfade = result; | 6904 crossfade = result; |
6906 | 6905 |
6907 return true; | 6906 return true; |
6908 } | 6907 } |
6909 | 6908 |
6910 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, RefPtrWillBeR
awPtr<CSSValue>& canvas) | 6909 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, NullableCSSVa
lue& canvas) |
6911 { | 6910 { |
6912 // Walk the arguments. | 6911 // Walk the arguments. |
6913 CSSParserValueList* args = valueList->current()->function->args.get(); | 6912 CSSParserValueList* args = valueList->current()->function->args.get(); |
6914 if (!args || args->size() != 1) | 6913 if (!args || args->size() != 1) |
6915 return false; | 6914 return false; |
6916 | 6915 |
6917 // The first argument is the canvas name. It is an identifier. | 6916 // The first argument is the canvas name. It is an identifier. |
6918 CSSParserValue* value = args->current(); | 6917 CSSParserValue* value = args->current(); |
6919 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) | 6918 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) |
6920 return false; | 6919 return false; |
6921 | 6920 |
6922 canvas = CSSCanvasValue::create(value->string); | 6921 canvas = CSSCanvasValue::create(value->string); |
6923 return true; | 6922 return true; |
6924 } | 6923 } |
6925 | 6924 |
6926 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
List* valueList) | 6925 NullableCSSValue CSSPropertyParser::parseImageSet(CSSParserValueList* valueList) |
6927 { | 6926 { |
6928 CSSParserValue* function = valueList->current(); | 6927 CSSParserValue* function = valueList->current(); |
6929 | 6928 |
6930 if (function->unit != CSSParserValue::Function) | 6929 if (function->unit != CSSParserValue::Function) |
6931 return nullptr; | 6930 return nullptr; |
6932 | 6931 |
6933 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); | 6932 CSSParserValueList* functionArgs = valueList->current()->function->args.get(
); |
6934 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 6933 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
6935 return nullptr; | 6934 return nullptr; |
6936 | 6935 |
6937 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 6936 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
6938 | 6937 |
6939 while (functionArgs->current()) { | 6938 while (functionArgs->current()) { |
6940 CSSParserValue* arg = functionArgs->current(); | 6939 CSSParserValue* arg = functionArgs->current(); |
6941 if (arg->unit != CSSPrimitiveValue::CSS_URI) | 6940 if (arg->unit != CSSPrimitiveValue::CSS_URI) |
6942 return nullptr; | 6941 return nullptr; |
6943 | 6942 |
6944 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg
->string, completeURL(arg->string)); | 6943 CSSValue image = createCSSImageValueWithReferrer(arg->string, completeUR
L(arg->string)); |
6945 imageSet->append(image); | 6944 imageSet->append(image); |
6946 | 6945 |
6947 arg = functionArgs->next(); | 6946 arg = functionArgs->next(); |
6948 if (!arg) | 6947 if (!arg) |
6949 return nullptr; | 6948 return nullptr; |
6950 | 6949 |
6951 if (arg->unit != CSSParserValue::DimensionList) | 6950 if (arg->unit != CSSParserValue::DimensionList) |
6952 return nullptr; | 6951 return nullptr; |
6953 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER
); | 6952 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER
); |
6954 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT)
; | 6953 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT)
; |
(...skipping 10 matching lines...) Expand all Loading... |
6965 break; | 6964 break; |
6966 | 6965 |
6967 // If there are more arguments, they should be after a comma. | 6966 // If there are more arguments, they should be after a comma. |
6968 if (!consumeComma(functionArgs)) | 6967 if (!consumeComma(functionArgs)) |
6969 return nullptr; | 6968 return nullptr; |
6970 } | 6969 } |
6971 | 6970 |
6972 return imageSet.release(); | 6971 return imageSet.release(); |
6973 } | 6972 } |
6974 | 6973 |
6975 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange() | 6974 NullableCSSValue CSSPropertyParser::parseWillChange() |
6976 { | 6975 { |
6977 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 6976 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
6978 if (m_valueList->current()->id == CSSValueAuto) { | 6977 if (m_valueList->current()->id == CSSValueAuto) { |
6979 // FIXME: This will be read back as an empty string instead of auto | 6978 // FIXME: This will be read back as an empty string instead of auto |
6980 return values.release(); | 6979 return values.release(); |
6981 } | 6980 } |
6982 | 6981 |
6983 // Every comma-separated list of CSS_IDENTs is a valid will-change value, | 6982 // Every comma-separated list of CSS_IDENTs is a valid will-change value, |
6984 // unless the list includes an explicitly disallowed CSS_IDENT. | 6983 // unless the list includes an explicitly disallowed CSS_IDENT. |
6985 while (true) { | 6984 while (true) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7137 list->append(filterValue); | 7136 list->append(filterValue); |
7138 } | 7137 } |
7139 } | 7138 } |
7140 | 7139 |
7141 return list.release(); | 7140 return list.release(); |
7142 } | 7141 } |
7143 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() | 7142 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() |
7144 { | 7143 { |
7145 CSSParserValue* value = m_valueList->current(); | 7144 CSSParserValue* value = m_valueList->current(); |
7146 CSSValueID id = value->id; | 7145 CSSValueID id = value->id; |
7147 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 7146 NullableCSSValue xValue; |
7148 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 7147 NullableCSSValue yValue; |
7149 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; | 7148 NullableCSSValue zValue; |
7150 if (id == CSSValueLeft || id == CSSValueRight) { | 7149 if (id == CSSValueLeft || id == CSSValueRight) { |
7151 xValue = cssValuePool().createIdentifierValue(id); | 7150 xValue = cssValuePool().createIdentifierValue(id); |
7152 } else if (id == CSSValueTop || id == CSSValueBottom) { | 7151 } else if (id == CSSValueTop || id == CSSValueBottom) { |
7153 yValue = cssValuePool().createIdentifierValue(id); | 7152 yValue = cssValuePool().createIdentifierValue(id); |
7154 } else if (id == CSSValueCenter) { | 7153 } else if (id == CSSValueCenter) { |
7155 // Unresolved as to whether this is X or Y. | 7154 // Unresolved as to whether this is X or Y. |
7156 } else if (validUnit(value, FPercent | FLength)) { | 7155 } else if (validUnit(value, FPercent | FLength)) { |
7157 xValue = createPrimitiveNumericValue(value); | 7156 xValue = createPrimitiveNumericValue(value); |
7158 } else { | 7157 } else { |
7159 return nullptr; | 7158 return nullptr; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7192 } | 7191 } |
7193 } else if (!xValue) { | 7192 } else if (!xValue) { |
7194 if (yValue) { | 7193 if (yValue) { |
7195 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE
NTAGE); | 7194 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE
NTAGE); |
7196 } else { | 7195 } else { |
7197 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); | 7196 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); |
7198 } | 7197 } |
7199 } | 7198 } |
7200 | 7199 |
7201 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7200 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
7202 list->append(xValue.release()); | 7201 list->append(*xValue); |
7203 if (yValue) | 7202 if (yValue) |
7204 list->append(yValue.release()); | 7203 list->append(*yValue); |
7205 if (zValue) | 7204 if (zValue) |
7206 list->append(zValue.release()); | 7205 list->append(*zValue); |
7207 return list.release(); | 7206 return list.release(); |
7208 } | 7207 } |
7209 | 7208 |
7210 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction() | 7209 NullableCSSValue CSSPropertyParser::parseTouchAction() |
7211 { | 7210 { |
7212 CSSParserValue* value = m_valueList->current(); | 7211 CSSParserValue* value = m_valueList->current(); |
7213 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7212 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
7214 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value
->id == CSSValueNone || value->id == CSSValueManipulation)) { | 7213 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value
->id == CSSValueNone || value->id == CSSValueManipulation)) { |
7215 list->append(cssValuePool().createIdentifierValue(value->id)); | 7214 list->append(cssValuePool().createIdentifierValue(value->id)); |
7216 m_valueList->next(); | 7215 m_valueList->next(); |
7217 return list.release(); | 7216 return list.release(); |
7218 } | 7217 } |
7219 | 7218 |
7220 bool xSet = false; | 7219 bool xSet = false; |
7221 bool ySet = false; | 7220 bool ySet = false; |
7222 while (value) { | 7221 while (value) { |
7223 switch (value->id) { | 7222 switch (value->id) { |
7224 case CSSValuePanX: | 7223 case CSSValuePanX: |
7225 case CSSValuePanRight: | 7224 case CSSValuePanRight: |
7226 case CSSValuePanLeft: { | 7225 case CSSValuePanLeft: { |
7227 if (xSet) | 7226 if (xSet) |
7228 return nullptr; | 7227 return nullptr; |
7229 xSet = true; | 7228 xSet = true; |
7230 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) | 7229 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) |
7231 return nullptr; | 7230 return nullptr; |
7232 | 7231 |
7233 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif
ierValue(value->id); | 7232 CSSValue panValue = cssValuePool().createIdentifierValue(value->id); |
7234 list->append(panValue.release()); | 7233 list->append(panValue); |
7235 break; | 7234 break; |
7236 } | 7235 } |
7237 case CSSValuePanY: | 7236 case CSSValuePanY: |
7238 case CSSValuePanDown: | 7237 case CSSValuePanDown: |
7239 case CSSValuePanUp: { | 7238 case CSSValuePanUp: { |
7240 if (ySet) | 7239 if (ySet) |
7241 return nullptr; | 7240 return nullptr; |
7242 ySet = true; | 7241 ySet = true; |
7243 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) | 7242 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc
tionPanDirectionsEnabled()) |
7244 return nullptr; | 7243 return nullptr; |
7245 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif
ierValue(value->id); | 7244 CSSValue panValue = cssValuePool().createIdentifierValue(value->id); |
7246 list->append(panValue.release()); | 7245 list->append(panValue); |
7247 break; | 7246 break; |
7248 } | 7247 } |
7249 default: | 7248 default: |
7250 return nullptr; | 7249 return nullptr; |
7251 } | 7250 } |
7252 value = m_valueList->next(); | 7251 value = m_valueList->next(); |
7253 } | 7252 } |
7254 | 7253 |
7255 if (list->length()) | 7254 if (list->length()) |
7256 return list.release(); | 7255 return list.release(); |
7257 | 7256 |
7258 return nullptr; | 7257 return nullptr; |
7259 } | 7258 } |
7260 | 7259 |
7261 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollBlocksOn() | 7260 NullableCSSValue CSSPropertyParser::parseScrollBlocksOn() |
7262 { | 7261 { |
7263 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7262 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
7264 CSSParserValue* value = m_valueList->current(); | 7263 CSSParserValue* value = m_valueList->current(); |
7265 while (value) { | 7264 while (value) { |
7266 switch (value->id) { | 7265 switch (value->id) { |
7267 case CSSValueStartTouch: | 7266 case CSSValueStartTouch: |
7268 case CSSValueWheelEvent: | 7267 case CSSValueWheelEvent: |
7269 case CSSValueScrollEvent: { | 7268 case CSSValueScrollEvent: { |
7270 RefPtrWillBeRawPtr<CSSValue> flagValue = cssValuePool().createIdenti
fierValue(value->id); | 7269 CSSValue flagValue = cssValuePool().createIdentifierValue(value->id)
; |
7271 if (list->hasValue(flagValue.get())) | 7270 if (list->hasValue(flagValue)) |
7272 return nullptr; | 7271 return nullptr; |
7273 list->append(flagValue.release()); | 7272 list->append(flagValue); |
7274 break; | 7273 break; |
7275 } | 7274 } |
7276 default: | 7275 default: |
7277 return nullptr; | 7276 return nullptr; |
7278 } | 7277 } |
7279 value = m_valueList->next(); | 7278 value = m_valueList->next(); |
7280 } | 7279 } |
7281 | 7280 |
7282 ASSERT(list->length()); | 7281 ASSERT(list->length()); |
7283 return list.release(); | 7282 return list.release(); |
7284 } | 7283 } |
7285 | 7284 |
7286 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefP
trWillBeRawPtr<CSSValue> value, bool important) | 7285 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, CSSValue
value, bool important) |
7287 { | 7286 { |
7288 // The text-decoration-line property takes priority over text-decoration, un
less the latter has important priority set. | 7287 // The text-decoration-line property takes priority over text-decoration, un
less the latter has important priority set. |
7289 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { | 7288 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { |
7290 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { | 7289 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { |
7291 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) | 7290 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) |
7292 return; | 7291 return; |
7293 } | 7292 } |
7294 } | 7293 } |
7295 addProperty(propId, value, important); | 7294 addProperty(propId, value, important); |
7296 } | 7295 } |
(...skipping 29 matching lines...) Expand all Loading... |
7326 | 7325 |
7327 // Values are either valid or in shorthand scope. | 7326 // Values are either valid or in shorthand scope. |
7328 if (list->length() && (isValid || inShorthand())) { | 7327 if (list->length() && (isValid || inShorthand())) { |
7329 addTextDecorationProperty(propId, list.release(), important); | 7328 addTextDecorationProperty(propId, list.release(), important); |
7330 return true; | 7329 return true; |
7331 } | 7330 } |
7332 | 7331 |
7333 return false; | 7332 return false; |
7334 } | 7333 } |
7335 | 7334 |
7336 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() | 7335 NullableCSSValue CSSPropertyParser::parseTextEmphasisStyle() |
7337 { | 7336 { |
7338 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; | 7337 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; |
7339 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; | 7338 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; |
7340 | 7339 |
7341 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7340 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
7342 if (value->unit == CSSPrimitiveValue::CSS_STRING) { | 7341 if (value->unit == CSSPrimitiveValue::CSS_STRING) { |
7343 if (fill || shape) | 7342 if (fill || shape) |
7344 return nullptr; | 7343 return nullptr; |
7345 m_valueList->next(); | 7344 m_valueList->next(); |
7346 return createPrimitiveStringValue(value); | 7345 return createPrimitiveStringValue(value); |
(...skipping 26 matching lines...) Expand all Loading... |
7373 return parsedValues.release(); | 7372 return parsedValues.release(); |
7374 } | 7373 } |
7375 if (fill) | 7374 if (fill) |
7376 return fill.release(); | 7375 return fill.release(); |
7377 if (shape) | 7376 if (shape) |
7378 return shape.release(); | 7377 return shape.release(); |
7379 | 7378 |
7380 return nullptr; | 7379 return nullptr; |
7381 } | 7380 } |
7382 | 7381 |
7383 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() | 7382 NullableCSSValue CSSPropertyParser::parseTextIndent() |
7384 { | 7383 { |
7385 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 7384 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
7386 | 7385 |
7387 bool hasLengthOrPercentage = false; | 7386 bool hasLengthOrPercentage = false; |
7388 bool hasEachLine = false; | 7387 bool hasEachLine = false; |
7389 bool hasHanging = false; | 7388 bool hasHanging = false; |
7390 | 7389 |
7391 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 7390 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
7392 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te
xtEnabled() returns false | 7391 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te
xtEnabled() returns false |
7393 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni
tlessQuirk)) { | 7392 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni
tlessQuirk)) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7479 m_valueList->next(); | 7478 m_valueList->next(); |
7480 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { | 7479 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { |
7481 tagValue = value->id == CSSValueOn; | 7480 tagValue = value->id == CSSValueOn; |
7482 m_valueList->next(); | 7481 m_valueList->next(); |
7483 } | 7482 } |
7484 } | 7483 } |
7485 settings->append(CSSFontFeatureValue::create(tag, tagValue)); | 7484 settings->append(CSSFontFeatureValue::create(tag, tagValue)); |
7486 return true; | 7485 return true; |
7487 } | 7486 } |
7488 | 7487 |
7489 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() | 7488 NullableCSSValue CSSPropertyParser::parseFontFeatureSettings() |
7490 { | 7489 { |
7491 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat
ed(); | 7490 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat
ed(); |
7492 while (true) { | 7491 while (true) { |
7493 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) | 7492 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) |
7494 return nullptr; | 7493 return nullptr; |
7495 if (!m_valueList->current()) | 7494 if (!m_valueList->current()) |
7496 break; | 7495 break; |
7497 if (!consumeComma(m_valueList)) | 7496 if (!consumeComma(m_valueList)) |
7498 return nullptr; | 7497 return nullptr; |
7499 } | 7498 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7568 return false; | 7567 return false; |
7569 | 7568 |
7570 return true; | 7569 return true; |
7571 } | 7570 } |
7572 | 7571 |
7573 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) | 7572 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) |
7574 { | 7573 { |
7575 CSSParserValue* value = m_valueList->current(); | 7574 CSSParserValue* value = m_valueList->current(); |
7576 ASSERT(value); | 7575 ASSERT(value); |
7577 CSSValueID id = value->id; | 7576 CSSValueID id = value->id; |
7578 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 7577 NullableCSSValue parsedValue; |
7579 | 7578 |
7580 switch (propId) { | 7579 switch (propId) { |
7581 case CSSPropertyFontFamily: | 7580 case CSSPropertyFontFamily: |
7582 // <family-name> | 7581 // <family-name> |
7583 // TODO(rwlbuis): check there is only one family-name | 7582 // TODO(rwlbuis): check there is only one family-name |
7584 parsedValue = parseFontFamily(); | 7583 parsedValue = parseFontFamily(); |
7585 break; | 7584 break; |
7586 case CSSPropertySrc: // This is a list of urls or local references. | 7585 case CSSPropertySrc: // This is a list of urls or local references. |
7587 parsedValue = parseFontFaceSrc(); | 7586 parsedValue = parseFontFaceSrc(); |
7588 break; | 7587 break; |
(...skipping 20 matching lines...) Expand all Loading... |
7609 parsedValue = parseFontFeatureSettings(); | 7608 parsedValue = parseFontFeatureSettings(); |
7610 } | 7609 } |
7611 break; | 7610 break; |
7612 default: | 7611 default: |
7613 break; | 7612 break; |
7614 } | 7613 } |
7615 | 7614 |
7616 if (!parsedValue || m_valueList->current()) | 7615 if (!parsedValue || m_valueList->current()) |
7617 return false; | 7616 return false; |
7618 | 7617 |
7619 addProperty(propId, parsedValue.release(), false); | 7618 addProperty(propId, *parsedValue, false); |
7620 return true; | 7619 return true; |
7621 } | 7620 } |
7622 | 7621 |
7623 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa
nt) | 7622 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa
nt) |
7624 { | 7623 { |
7625 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | 7624 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); |
7626 | 7625 |
7627 CSSParserValue* value = m_valueList->current(); | 7626 CSSParserValue* value = m_valueList->current(); |
7628 if (!value) | 7627 if (!value) |
7629 return false; | 7628 return false; |
(...skipping 27 matching lines...) Expand all Loading... |
7657 if (id == CSSValueZoom || id == CSSValueFixed) | 7656 if (id == CSSValueZoom || id == CSSValueFixed) |
7658 validPrimitive = true; | 7657 validPrimitive = true; |
7659 break; | 7658 break; |
7660 case CSSPropertyOrientation: // auto | portrait | landscape | 7659 case CSSPropertyOrientation: // auto | portrait | landscape |
7661 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc
ape) | 7660 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc
ape) |
7662 validPrimitive = true; | 7661 validPrimitive = true; |
7663 default: | 7662 default: |
7664 break; | 7663 break; |
7665 } | 7664 } |
7666 | 7665 |
7667 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 7666 NullableCSSValue parsedValue; |
7668 if (validPrimitive) { | 7667 if (validPrimitive) { |
7669 parsedValue = parseValidPrimitive(id, value); | 7668 parsedValue = parseValidPrimitive(id, value); |
7670 m_valueList->next(); | 7669 m_valueList->next(); |
7671 } | 7670 } |
7672 | 7671 |
7673 if (parsedValue) { | 7672 if (parsedValue) { |
7674 if (!m_valueList->current() || inShorthand()) { | 7673 if (!m_valueList->current() || inShorthand()) { |
7675 addProperty(propId, parsedValue.release(), important); | 7674 addProperty(propId, *parsedValue, important); |
7676 return true; | 7675 return true; |
7677 } | 7676 } |
7678 } | 7677 } |
7679 | 7678 |
7680 return false; | 7679 return false; |
7681 } | 7680 } |
7682 | 7681 |
7683 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty
ID first, CSSPropertyID second, bool important) | 7682 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty
ID first, CSSPropertyID second, bool important) |
7684 { | 7683 { |
7685 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); | 7684 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c
ontext.mode())); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7798 } | 7797 } |
7799 | 7798 |
7800 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) | 7799 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) |
7801 { | 7800 { |
7802 CSSParserValue* value = m_valueList->current(); | 7801 CSSParserValue* value = m_valueList->current(); |
7803 ASSERT(value); | 7802 ASSERT(value); |
7804 | 7803 |
7805 CSSValueID id = value->id; | 7804 CSSValueID id = value->id; |
7806 | 7805 |
7807 bool validPrimitive = false; | 7806 bool validPrimitive = false; |
7808 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 7807 NullableCSSValue parsedValue; |
7809 | 7808 |
7810 switch (propId) { | 7809 switch (propId) { |
7811 /* The comment to the right defines all valid value of these | 7810 /* The comment to the right defines all valid value of these |
7812 * properties as defined in SVG 1.1, Appendix N. Property index */ | 7811 * properties as defined in SVG 1.1, Appendix N. Property index */ |
7813 case CSSPropertyAlignmentBaseline: | 7812 case CSSPropertyAlignmentBaseline: |
7814 // auto | baseline | before-edge | text-before-edge | middle | | 7813 // auto | baseline | before-edge | text-before-edge | middle | |
7815 // central | after-edge | text-after-edge | ideographic | alphabetic | | 7814 // central | after-edge | text-after-edge | ideographic | alphabetic | |
7816 // hanging | mathematical | inherit | 7815 // hanging | mathematical | inherit |
7817 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle | 7816 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle |
7818 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical)) | 7817 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical)) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7943 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { | 7942 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
7944 RGBA32 c = Color::transparent; | 7943 RGBA32 c = Color::transparent; |
7945 if (m_valueList->next()) { | 7944 if (m_valueList->next()) { |
7946 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea
teSpaceSeparated(); | 7945 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea
teSpaceSeparated(); |
7947 values->append(CSSPrimitiveValue::create(value->string, CSSP
rimitiveValue::CSS_URI)); | 7946 values->append(CSSPrimitiveValue::create(value->string, CSSP
rimitiveValue::CSS_URI)); |
7948 if (parseColorFromValue(m_valueList->current(), c)) | 7947 if (parseColorFromValue(m_valueList->current(), c)) |
7949 parsedValue = cssValuePool().createColorValue(c); | 7948 parsedValue = cssValuePool().createColorValue(c); |
7950 else if (m_valueList->current()->id == CSSValueNone || m_val
ueList->current()->id == CSSValueCurrentcolor) | 7949 else if (m_valueList->current()->id == CSSValueNone || m_val
ueList->current()->id == CSSValueCurrentcolor) |
7951 parsedValue = cssValuePool().createIdentifierValue(m_val
ueList->current()->id); | 7950 parsedValue = cssValuePool().createIdentifierValue(m_val
ueList->current()->id); |
7952 if (parsedValue) { | 7951 if (parsedValue) { |
7953 values->append(parsedValue); | 7952 values->append(*parsedValue); |
7954 parsedValue = values; | 7953 parsedValue = values; |
7955 } | 7954 } |
7956 } | 7955 } |
7957 if (!parsedValue) | 7956 if (!parsedValue) |
7958 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr
imitiveValue::CSS_URI); | 7957 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr
imitiveValue::CSS_URI); |
7959 } else { | 7958 } else { |
7960 parsedValue = parseColor(); | 7959 parsedValue = parseColor(); |
7961 } | 7960 } |
7962 | 7961 |
7963 if (parsedValue) | 7962 if (parsedValue) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8024 /* shorthand properties */ | 8023 /* shorthand properties */ |
8025 case CSSPropertyMarker: { | 8024 case CSSPropertyMarker: { |
8026 ShorthandScope scope(this, propId); | 8025 ShorthandScope scope(this, propId); |
8027 CSSPropertyParser::ImplicitScope implicitScope(this); | 8026 CSSPropertyParser::ImplicitScope implicitScope(this); |
8028 if (!parseValue(CSSPropertyMarkerStart, important)) | 8027 if (!parseValue(CSSPropertyMarkerStart, important)) |
8029 return false; | 8028 return false; |
8030 if (m_valueList->current()) { | 8029 if (m_valueList->current()) { |
8031 rollbackLastProperties(1); | 8030 rollbackLastProperties(1); |
8032 return false; | 8031 return false; |
8033 } | 8032 } |
8034 CSSValue* value = m_parsedProperties.last().value(); | 8033 CSSValue value = m_parsedProperties.last().value(); |
8035 addProperty(CSSPropertyMarkerMid, value, important); | 8034 addProperty(CSSPropertyMarkerMid, value, important); |
8036 addProperty(CSSPropertyMarkerEnd, value, important); | 8035 addProperty(CSSPropertyMarkerEnd, value, important); |
8037 return true; | 8036 return true; |
8038 } | 8037 } |
8039 default: | 8038 default: |
8040 // If you crash here, it's because you added a css property and are not
handling it | 8039 // If you crash here, it's because you added a css property and are not
handling it |
8041 // in either this switch statement or the one in CSSPropertyParser::pars
eValue | 8040 // in either this switch statement or the one in CSSPropertyParser::pars
eValue |
8042 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); | 8041 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); |
8043 return false; | 8042 return false; |
8044 } | 8043 } |
(...skipping 13 matching lines...) Expand all Loading... |
8058 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri
mitiveValue here, ie | 8057 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri
mitiveValue here, ie |
8059 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea
se()); | 8058 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea
se()); |
8060 m_parsedCalculation.release(); | 8059 m_parsedCalculation.release(); |
8061 parsedValue = nullptr; | 8060 parsedValue = nullptr; |
8062 } | 8061 } |
8063 m_valueList->next(); | 8062 m_valueList->next(); |
8064 } | 8063 } |
8065 if (!parsedValue || (m_valueList->current() && !inShorthand())) | 8064 if (!parsedValue || (m_valueList->current() && !inShorthand())) |
8066 return false; | 8065 return false; |
8067 | 8066 |
8068 addProperty(propId, parsedValue.release(), important); | 8067 addProperty(propId, *parsedValue, important); |
8069 return true; | 8068 return true; |
8070 } | 8069 } |
8071 | 8070 |
8072 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray() | 8071 NullableCSSValue CSSPropertyParser::parseSVGStrokeDasharray() |
8073 { | 8072 { |
8074 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); | 8073 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); |
8075 CSSParserValue* value = m_valueList->current(); | 8074 CSSParserValue* value = m_valueList->current(); |
8076 bool validPrimitive = true; | 8075 bool validPrimitive = true; |
8077 while (value) { | 8076 while (value) { |
8078 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri
buteMode); | 8077 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri
buteMode); |
8079 if (!validPrimitive) | 8078 if (!validPrimitive) |
8080 break; | 8079 break; |
8081 if (value->id) | 8080 if (value->id) |
8082 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); | 8081 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); |
8083 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <=
CSSPrimitiveValue::CSS_KHZ) | 8082 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <=
CSSPrimitiveValue::CSS_KHZ) |
8084 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa
lue::UnitType) value->unit)); | 8083 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa
lue::UnitType) value->unit)); |
8085 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS
SPrimitiveValue::CSS_CHS) | 8084 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS
SPrimitiveValue::CSS_CHS) |
8086 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa
lue::UnitType)value->unit)); | 8085 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa
lue::UnitType)value->unit)); |
8087 value = m_valueList->next(); | 8086 value = m_valueList->next(); |
8088 bool commaConsumed = consumeComma(m_valueList); | 8087 bool commaConsumed = consumeComma(m_valueList); |
8089 value = m_valueList->current(); | 8088 value = m_valueList->current(); |
8090 if (commaConsumed && !value) | 8089 if (commaConsumed && !value) |
8091 return nullptr; | 8090 return nullptr; |
8092 } | 8091 } |
8093 if (!validPrimitive) | 8092 if (!validPrimitive) |
8094 return nullptr; | 8093 return nullptr; |
8095 return ret.release(); | 8094 return ret.release(); |
8096 } | 8095 } |
8097 | 8096 |
8098 // normal | [ fill || stroke || markers ] | 8097 // normal | [ fill || stroke || markers ] |
8099 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const | 8098 NullableCSSValue CSSPropertyParser::parsePaintOrder() const |
8100 { | 8099 { |
8101 if (m_valueList->size() > 3) | 8100 if (m_valueList->size() > 3) |
8102 return nullptr; | 8101 return nullptr; |
8103 | 8102 |
8104 CSSParserValue* value = m_valueList->current(); | 8103 CSSParserValue* value = m_valueList->current(); |
8105 ASSERT(value); | 8104 ASSERT(value); |
8106 | 8105 |
8107 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); | 8106 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep
arated(); |
8108 | 8107 |
8109 // The default paint-order is: Fill, Stroke, Markers. | 8108 // The default paint-order is: Fill, Stroke, Markers. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8252 CSSPropertyParser::Units m_unit; | 8251 CSSPropertyParser::Units m_unit; |
8253 }; | 8252 }; |
8254 | 8253 |
8255 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL
egacyParsing) | 8254 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL
egacyParsing) |
8256 { | 8255 { |
8257 if (!m_valueList) | 8256 if (!m_valueList) |
8258 return nullptr; | 8257 return nullptr; |
8259 | 8258 |
8260 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 8259 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
8261 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8260 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
8262 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue(
useLegacyParsing, value); | 8261 NullableCSSValue parsedTransformValue = parseTransformValue(useLegacyPar
sing, value); |
8263 if (!parsedTransformValue) | 8262 if (!parsedTransformValue) |
8264 return nullptr; | 8263 return nullptr; |
8265 | 8264 |
8266 list->append(parsedTransformValue.release()); | 8265 list->append(*parsedTransformValue); |
8267 } | 8266 } |
8268 | 8267 |
8269 return list.release(); | 8268 return list.release(); |
8270 } | 8269 } |
8271 | 8270 |
8272 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(bool use
LegacyParsing, CSSParserValue *value) | 8271 NullableCSSValue CSSPropertyParser::parseTransformValue(bool useLegacyParsing, C
SSParserValue *value) |
8273 { | 8272 { |
8274 if (value->unit != CSSParserValue::Function || !value->function) | 8273 if (value->unit != CSSParserValue::Function || !value->function) |
8275 return nullptr; | 8274 return nullptr; |
8276 | 8275 |
8277 // Every primitive requires at least one argument. | 8276 // Every primitive requires at least one argument. |
8278 CSSParserValueList* args = value->function->args.get(); | 8277 CSSParserValueList* args = value->function->args.get(); |
8279 if (!args) | 8278 if (!args) |
8280 return nullptr; | 8279 return nullptr; |
8281 | 8280 |
8282 // See if the specified primitive is one we understand. | 8281 // See if the specified primitive is one we understand. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8334 if (!isComma(a)) | 8333 if (!isComma(a)) |
8335 return nullptr; | 8334 return nullptr; |
8336 a = args->next(); | 8335 a = args->next(); |
8337 | 8336 |
8338 argNumber++; | 8337 argNumber++; |
8339 } | 8338 } |
8340 | 8339 |
8341 return transformValue.release(); | 8340 return transformValue.release(); |
8342 } | 8341 } |
8343 | 8342 |
8344 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() | 8343 NullableCSSValue CSSPropertyParser::parseMotionPath() |
8345 { | 8344 { |
8346 CSSParserValue* value = m_valueList->current(); | 8345 CSSParserValue* value = m_valueList->current(); |
8347 | 8346 |
8348 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. | 8347 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
8349 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal
uePath) | 8348 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal
uePath) |
8350 return nullptr; | 8349 return nullptr; |
8351 | 8350 |
8352 // FIXME: Add support for <fill-rule>. | 8351 // FIXME: Add support for <fill-rule>. |
8353 CSSParserValueList* functionArgs = value->function->args.get(); | 8352 CSSParserValueList* functionArgs = value->function->args.get(); |
8354 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) | 8353 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) |
8355 return nullptr; | 8354 return nullptr; |
8356 | 8355 |
8357 CSSParserValue* arg = functionArgs->current(); | 8356 CSSParserValue* arg = functionArgs->current(); |
8358 if (arg->unit != CSSPrimitiveValue::CSS_STRING) | 8357 if (arg->unit != CSSPrimitiveValue::CSS_STRING) |
8359 return nullptr; | 8358 return nullptr; |
8360 | 8359 |
8361 String pathString = arg->string; | 8360 String pathString = arg->string; |
8362 Path path; | 8361 Path path; |
8363 if (!buildPathFromString(pathString, path)) | 8362 if (!buildPathFromString(pathString, path)) |
8364 return nullptr; | 8363 return nullptr; |
8365 | 8364 |
8366 m_valueList->next(); | 8365 m_valueList->next(); |
8367 return CSSPathValue::create(pathString); | 8366 return CSSPathValue::create(pathString); |
8368 } | 8367 } |
8369 | 8368 |
8370 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionRotation() | 8369 NullableCSSValue CSSPropertyParser::parseMotionRotation() |
8371 { | 8370 { |
8372 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 8371 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
8373 bool hasAutoOrReverse = false; | 8372 bool hasAutoOrReverse = false; |
8374 bool hasAngle = false; | 8373 bool hasAngle = false; |
8375 | 8374 |
8376 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { | 8375 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL
ist->next()) { |
8377 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA
utoOrReverse) { | 8376 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA
utoOrReverse) { |
8378 list->append(cssValuePool().createIdentifierValue(value->id)); | 8377 list->append(cssValuePool().createIdentifierValue(value->id)); |
8379 hasAutoOrReverse = true; | 8378 hasAutoOrReverse = true; |
8380 } else if (validUnit(value, FAngle) && !hasAngle) { | 8379 } else if (validUnit(value, FAngle) && !hasAngle) { |
8381 list->append(createPrimitiveNumericValue(value)); | 8380 list->append(createPrimitiveNumericValue(value)); |
8382 hasAngle = true; | 8381 hasAngle = true; |
8383 } else { | 8382 } else { |
8384 break; | 8383 break; |
8385 } | 8384 } |
8386 } | 8385 } |
8387 | 8386 |
8388 if (!list->length()) | 8387 if (!list->length()) |
8389 return nullptr; | 8388 return nullptr; |
8390 | 8389 |
8391 return list.release(); | 8390 return list.release(); |
8392 } | 8391 } |
8393 | 8392 |
8394 } // namespace blink | 8393 } // namespace blink |
OLD | NEW |