Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // This doesn't count UA style sheets 115 // This doesn't count UA style sheets
116 if (parseSuccess && context.useCounter()) 116 if (parseSuccess && context.useCounter())
117 context.useCounter()->count(context, unresolvedProperty); 117 context.useCounter()->count(context, unresolvedProperty);
118 118
119 if (!parseSuccess) 119 if (!parseSuccess)
120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size); 120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size);
121 121
122 return parseSuccess; 122 return parseSuccess;
123 } 123 }
124 124
125 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr <CSSValue> value, bool important, bool implicit) 125 void CSSPropertyParser::addProperty(CSSPropertyID propId, CSSValue value, bool i mportant, bool implicit)
126 { 126 {
127 ASSERT(!isPropertyAlias(propId)); 127 ASSERT(!isPropertyAlias(propId));
128 128
129 int shorthandIndex = 0; 129 int shorthandIndex = 0;
130 bool setFromShorthand = false; 130 bool setFromShorthand = false;
131 131
132 if (m_currentShorthand) { 132 if (m_currentShorthand) {
133 Vector<StylePropertyShorthand, 4> shorthands; 133 Vector<StylePropertyShorthand, 4> shorthands;
134 getMatchingShorthandsForLonghand(propId, &shorthands); 134 getMatchingShorthandsForLonghand(propId, &shorthands);
135 // Viewport descriptors have width and height as shorthands, but it does n't 135 // Viewport descriptors have width and height as shorthands, but it does n't
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 307 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
308 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG); 308 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG);
309 } 309 }
310 310
311 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value) 311 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value)
312 { 312 {
313 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 313 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
314 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT); 314 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT);
315 } 315 }
316 316
317 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi thReferrer(const String& rawValue, const KURL& url) 317 inline CSSValue CSSPropertyParser::createCSSImageValueWithReferrer(const String& rawValue, const KURL& url)
318 { 318 {
319 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur l); 319 CSSValue imageValue = CSSImageValue::create(rawValue, url);
320 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); 320 toCSSImageValue(imageValue).setReferrer(m_context.referrer());
321 return imageValue; 321 return imageValue;
322 } 322 }
323 323
324 static inline bool isComma(CSSParserValue* value) 324 static inline bool isComma(CSSParserValue* value)
325 { 325 {
326 ASSERT(value); 326 ASSERT(value);
327 return value->unit == CSSParserValue::Operator && value->iValue == ','; 327 return value->unit == CSSParserValue::Operator && value->iValue == ',';
328 } 328 }
329 329
330 static bool consumeComma(CSSParserValueList* valueList) 330 static bool consumeComma(CSSParserValueList* valueList)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) 389 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM)
390 return createPrimitiveNumericValue(value); 390 return createPrimitiveNumericValue(value);
391 if (value->unit == CSSPrimitiveValue::CSS_QEM) 391 if (value->unit == CSSPrimitiveValue::CSS_QEM)
392 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); 392 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS);
393 if (isCalculation(value)) 393 if (isCalculation(value))
394 return CSSPrimitiveValue::create(m_parsedCalculation.release()); 394 return CSSPrimitiveValue::create(m_parsedCalculation.release());
395 395
396 return nullptr; 396 return nullptr;
397 } 397 }
398 398
399 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe fPtrWillBeRawPtr<CSSValue> prpValue, bool important) 399 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, CSSVal ue prpValue, bool important)
400 { 400 {
401 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); 401 const StylePropertyShorthand& shorthand = shorthandForProperty(propId);
402 unsigned shorthandLength = shorthand.length(); 402 unsigned shorthandLength = shorthand.length();
403 if (!shorthandLength) { 403 if (!shorthandLength) {
404 addProperty(propId, prpValue, important); 404 addProperty(propId, prpValue, important);
405 return; 405 return;
406 } 406 }
407 407
408 RefPtrWillBeRawPtr<CSSValue> value = prpValue; 408 CSSValue value = prpValue;
409 ShorthandScope scope(this, propId); 409 ShorthandScope scope(this, propId);
410 const CSSPropertyID* longhands = shorthand.properties(); 410 const CSSPropertyID* longhands = shorthand.properties();
411 for (unsigned i = 0; i < shorthandLength; ++i) 411 for (unsigned i = 0; i < shorthandLength; ++i)
412 addProperty(longhands[i], value, important); 412 addProperty(longhands[i], value, important);
413 } 413 }
414 414
415 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant) 415 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant)
416 { 416 {
417 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); 417 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty);
418 418
(...skipping 28 matching lines...) Expand all
447 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) 447 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id))
448 return false; 448 return false;
449 if (m_valueList->next() && !inShorthand()) 449 if (m_valueList->next() && !inShorthand())
450 return false; 450 return false;
451 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; 451 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ;
452 return true; 452 return true;
453 } 453 }
454 454
455 bool validPrimitive = false; 455 bool validPrimitive = false;
456 Units unitless = FUnknown; 456 Units unitless = FUnknown;
457 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 457 NullableCSSValue parsedValue;
458 458
459 switch (propId) { 459 switch (propId) {
460 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] 460 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
461 parsedValue = parseSize(); 461 parsedValue = parseSize();
462 break; 462 break;
463 case CSSPropertyQuotes: // [<string> <string>]+ | none 463 case CSSPropertyQuotes: // [<string> <string>]+ | none
464 if (id == CSSValueNone) 464 if (id == CSSValueNone)
465 validPrimitive = true; 465 validPrimitive = true;
466 else 466 else
467 parsedValue = parseQuotes(); 467 parsedValue = parseQuotes();
(...skipping 11 matching lines...) Expand all
479 break; 479 break;
480 480
481 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work 481 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work
482 * correctly and allows optimization in blink::applyRule(..) 482 * correctly and allows optimization in blink::applyRule(..)
483 */ 483 */
484 case CSSPropertyOverflow: { 484 case CSSPropertyOverflow: {
485 ShorthandScope scope(this, propId); 485 ShorthandScope scope(this, propId);
486 if (num != 1 || !parseValue(CSSPropertyOverflowY, important)) 486 if (num != 1 || !parseValue(CSSPropertyOverflowY, important))
487 return false; 487 return false;
488 488
489 RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr;
490
491 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I f this value has been 489 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I f this value has been
492 // set using the shorthand, then for now overflow-x will default to auto , but once we implement 490 // set using the shorthand, then for now overflow-x will default to auto , but once we implement
493 // pagination controls, it should default to hidden. If the overflow-y v alue is anything but 491 // pagination controls, it should default to hidden. If the overflow-y v alue is anything but
494 // paged-x or paged-y, then overflow-x and overflow-y should have the sa me value. 492 // paged-x or paged-y, then overflow-x and overflow-y should have the sa me value.
493 NullableCSSValue overflowXValue;
495 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) 494 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY)
496 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); 495 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto);
497 else 496 else
498 overflowXValue = m_parsedProperties.last().value(); 497 overflowXValue = m_parsedProperties.last().value();
499 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); 498 addProperty(CSSPropertyOverflowX, *overflowXValue, important);
500 return true; 499 return true;
501 } 500 }
502 501
503 case CSSPropertyTextAlign: 502 case CSSPropertyTextAlign:
504 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent 503 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent
505 // | start | end | <string> | inherit | -webkit-auto (converted to start ) 504 // | start | end | <string> | inherit | -webkit-auto (converted to start )
506 // FIXME: <string> not supported right now 505 // FIXME: <string> not supported right now
507 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) { 506 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) {
508 validPrimitive = true; 507 validPrimitive = true;
509 } 508 }
510 break; 509 break;
511 510
512 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit 511 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
513 if (m_valueList->size() != 1) 512 if (m_valueList->size() != 1)
514 return false; 513 return false;
515 return parseFontWeight(important); 514 return parseFontWeight(important);
516 } 515 }
517 516
518 case CSSPropertyBorderSpacing: { 517 case CSSPropertyBorderSpacing: {
519 if (num == 1) { 518 if (num == 1) {
520 ShorthandScope scope(this, CSSPropertyBorderSpacing); 519 ShorthandScope scope(this, CSSPropertyBorderSpacing);
521 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) ) 520 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) )
522 return false; 521 return false;
523 CSSValue* value = m_parsedProperties.last().value(); 522 CSSValue value = m_parsedProperties.last().value();
524 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important ); 523 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important );
525 return true; 524 return true;
526 } 525 }
527 else if (num == 2) { 526 else if (num == 2) {
528 ShorthandScope scope(this, CSSPropertyBorderSpacing); 527 ShorthandScope scope(this, CSSPropertyBorderSpacing);
529 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) 528 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important))
530 return false; 529 return false;
531 return true; 530 return true;
532 } 531 }
533 return false; 532 return false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 case CSSPropertyCursor: { 570 case CSSPropertyCursor: {
572 // Grammar defined by CSS3 UI and modified by CSS4 images: 571 // Grammar defined by CSS3 UI and modified by CSS4 images:
573 // [ [<image> [<x> <y>]?,]* 572 // [ [<image> [<x> <y>]?,]*
574 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize | 573 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
575 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 574 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
576 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help | 575 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help |
577 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll | 576 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll |
578 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit 577 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit
579 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; 578 RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
580 while (value) { 579 while (value) {
581 RefPtrWillBeRawPtr<CSSValue> image = nullptr; 580 NullableCSSValue image;
582 if (value->unit == CSSPrimitiveValue::CSS_URI) { 581 if (value->unit == CSSPrimitiveValue::CSS_URI) {
583 String uri = value->string; 582 String uri = value->string;
584 if (!uri.isNull()) 583 if (!uri.isNull())
585 image = createCSSImageValueWithReferrer(uri, completeURL(uri )); 584 image = createCSSImageValueWithReferrer(uri, completeURL(uri ));
586 } else if (value->unit == CSSParserValue::Function && value->functio n->id == CSSValueWebkitImageSet) { 585 } else if (value->unit == CSSParserValue::Function && value->functio n->id == CSSValueWebkitImageSet) {
587 image = parseImageSet(m_valueList); 586 image = parseImageSet(m_valueList);
588 if (!image) 587 if (!image)
589 break; 588 break;
590 } else 589 } else
591 break; 590 break;
(...skipping 11 matching lines...) Expand all
603 return false; 602 return false;
604 if (nrcoords == 2) { 603 if (nrcoords == 2) {
605 hotSpotSpecified = true; 604 hotSpotSpecified = true;
606 hotSpot = IntPoint(coords[0], coords[1]); 605 hotSpot = IntPoint(coords[0], coords[1]);
607 } 606 }
608 607
609 if (!list) 608 if (!list)
610 list = CSSValueList::createCommaSeparated(); 609 list = CSSValueList::createCommaSeparated();
611 610
612 if (image) 611 if (image)
613 list->append(CSSCursorImageValue::create(image, hotSpotSpecified , hotSpot)); 612 list->append(CSSCursorImageValue::create(*image, hotSpotSpecifie d, hotSpot));
614 613
615 if (!consumeComma(m_valueList)) 614 if (!consumeComma(m_valueList))
616 return false; 615 return false;
617 value = m_valueList->current(); 616 value = m_valueList->current();
618 } 617 }
619 if (value && m_context.useCounter()) { 618 if (value && m_context.useCounter()) {
620 if (value->id == CSSValueWebkitZoomIn) 619 if (value->id == CSSValueWebkitZoomIn)
621 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); 620 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn);
622 else if (value->id == CSSValueWebkitZoomOut) 621 else if (value->id == CSSValueWebkitZoomOut)
623 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ; 622 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 case CSSPropertyWebkitMaskImage: 664 case CSSPropertyWebkitMaskImage:
666 case CSSPropertyWebkitMaskOrigin: 665 case CSSPropertyWebkitMaskOrigin:
667 case CSSPropertyWebkitMaskPosition: 666 case CSSPropertyWebkitMaskPosition:
668 case CSSPropertyWebkitMaskPositionX: 667 case CSSPropertyWebkitMaskPositionX:
669 case CSSPropertyWebkitMaskPositionY: 668 case CSSPropertyWebkitMaskPositionY:
670 case CSSPropertyWebkitMaskSize: 669 case CSSPropertyWebkitMaskSize:
671 case CSSPropertyWebkitMaskRepeat: 670 case CSSPropertyWebkitMaskRepeat:
672 case CSSPropertyWebkitMaskRepeatX: 671 case CSSPropertyWebkitMaskRepeatX:
673 case CSSPropertyWebkitMaskRepeatY: 672 case CSSPropertyWebkitMaskRepeatY:
674 { 673 {
675 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 674 NullableCSSValue val1;
676 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 675 NullableCSSValue val2;
677 CSSPropertyID propId1, propId2; 676 CSSPropertyID propId1, propId2;
678 bool result = false; 677 bool result = false;
679 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2)) { 678 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2)) {
680 if (propId == CSSPropertyBackgroundPosition || 679 if (propId == CSSPropertyBackgroundPosition ||
681 propId == CSSPropertyBackgroundRepeat || 680 propId == CSSPropertyBackgroundRepeat ||
682 propId == CSSPropertyWebkitMaskPosition || 681 propId == CSSPropertyWebkitMaskPosition ||
683 propId == CSSPropertyWebkitMaskRepeat) { 682 propId == CSSPropertyWebkitMaskRepeat) {
684 ShorthandScope scope(this, propId); 683 ShorthandScope scope(this, propId);
685 addProperty(propId1, val1.release(), important); 684 addProperty(propId1, *val1, important);
686 if (val2) 685 if (val2)
687 addProperty(propId2, val2.release(), important); 686 addProperty(propId2, *val2, important);
688 } else { 687 } else {
689 addProperty(propId1, val1.release(), important); 688 addProperty(propId1, *val1, important);
690 if (val2) 689 if (val2)
691 addProperty(propId2, val2.release(), important); 690 addProperty(propId2, *val2, important);
692 } 691 }
693 result = true; 692 result = true;
694 } 693 }
695 m_implicitShorthand = false; 694 m_implicitShorthand = false;
696 return result; 695 return result;
697 } 696 }
698 case CSSPropertyObjectPosition: 697 case CSSPropertyObjectPosition:
699 parsedValue = parsePosition(m_valueList); 698 parsedValue = parsePosition(m_valueList);
700 break; 699 break;
701 case CSSPropertyListStyleImage: // <uri> | none | inherit 700 case CSSPropertyListStyleImage: // <uri> | none | inherit
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 case CSSPropertyUnicodeRange: 895 case CSSPropertyUnicodeRange:
897 /* @font-face only descriptors */ 896 /* @font-face only descriptors */
898 break; 897 break;
899 898
900 /* CSS3 properties */ 899 /* CSS3 properties */
901 900
902 case CSSPropertyBorderImage: 901 case CSSPropertyBorderImage:
903 case CSSPropertyWebkitMaskBoxImage: 902 case CSSPropertyWebkitMaskBoxImage:
904 return parseBorderImageShorthand(propId, important); 903 return parseBorderImageShorthand(propId, important);
905 case CSSPropertyWebkitBorderImage: { 904 case CSSPropertyWebkitBorderImage: {
906 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { 905 if (NullableCSSValue result = parseBorderImage(propId)) {
907 addProperty(propId, result, important); 906 addProperty(propId, *result, important);
908 return true; 907 return true;
909 } 908 }
910 return false; 909 return false;
911 } 910 }
912 911
913 case CSSPropertyBorderImageOutset: 912 case CSSPropertyBorderImageOutset:
914 case CSSPropertyWebkitMaskBoxImageOutset: { 913 case CSSPropertyWebkitMaskBoxImageOutset: {
915 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; 914 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr;
916 if (parseBorderImageOutset(result)) { 915 if (parseBorderImageOutset(result)) {
917 addProperty(propId, result, important); 916 addProperty(propId, result, important);
918 return true; 917 return true;
919 } 918 }
920 break; 919 break;
921 } 920 }
922 case CSSPropertyBorderImageRepeat: 921 case CSSPropertyBorderImageRepeat:
923 case CSSPropertyWebkitMaskBoxImageRepeat: { 922 case CSSPropertyWebkitMaskBoxImageRepeat: {
924 RefPtrWillBeRawPtr<CSSValue> result = nullptr; 923 NullableCSSValue result;
925 if (parseBorderImageRepeat(result)) { 924 if (parseBorderImageRepeat(result)) {
926 addProperty(propId, result, important); 925 addProperty(propId, *result, important);
927 return true; 926 return true;
928 } 927 }
929 break; 928 break;
930 } 929 }
931 case CSSPropertyBorderImageSlice: 930 case CSSPropertyBorderImageSlice:
932 case CSSPropertyWebkitMaskBoxImageSlice: { 931 case CSSPropertyWebkitMaskBoxImageSlice: {
933 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr; 932 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr;
934 if (parseBorderImageSlice(propId, result)) { 933 if (parseBorderImageSlice(propId, result)) {
935 addProperty(propId, result, important); 934 addProperty(propId, result, important);
936 return true; 935 return true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 case CSSPropertyWebkitBoxFlexGroup: 1009 case CSSPropertyWebkitBoxFlexGroup:
1011 validPrimitive = validUnit(value, FInteger | FNonNeg); 1010 validPrimitive = validUnit(value, FInteger | FNonNeg);
1012 break; 1011 break;
1013 case CSSPropertyWebkitBoxOrdinalGroup: 1012 case CSSPropertyWebkitBoxOrdinalGroup:
1014 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; 1013 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue;
1015 break; 1014 break;
1016 case CSSPropertyWebkitFilter: 1015 case CSSPropertyWebkitFilter:
1017 if (id == CSSValueNone) 1016 if (id == CSSValueNone)
1018 validPrimitive = true; 1017 validPrimitive = true;
1019 else { 1018 else {
1020 RefPtrWillBeRawPtr<CSSValue> val = parseFilter(); 1019 NullableCSSValue val = parseFilter();
1021 if (val) { 1020 if (val) {
1022 addProperty(propId, val, important); 1021 addProperty(propId, *val, important);
1023 return true; 1022 return true;
1024 } 1023 }
1025 return false; 1024 return false;
1026 } 1025 }
1027 break; 1026 break;
1028 case CSSPropertyFlex: { 1027 case CSSPropertyFlex: {
1029 ShorthandScope scope(this, propId); 1028 ShorthandScope scope(this, propId);
1030 if (id == CSSValueNone) { 1029 if (id == CSSValueNone) {
1031 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important); 1030 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important);
1032 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important); 1031 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 1269
1271 case CSSPropertyGrid: 1270 case CSSPropertyGrid:
1272 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 1271 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
1273 return parseGridShorthand(important); 1272 return parseGridShorthand(important);
1274 1273
1275 case CSSPropertyWebkitMarginCollapse: { 1274 case CSSPropertyWebkitMarginCollapse: {
1276 if (num == 1) { 1275 if (num == 1) {
1277 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1276 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1278 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) 1277 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant))
1279 return false; 1278 return false;
1280 CSSValue* value = m_parsedProperties.last().value(); 1279 CSSValue value = m_parsedProperties.last().value();
1281 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); 1280 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important);
1282 return true; 1281 return true;
1283 } 1282 }
1284 else if (num == 2) { 1283 else if (num == 2) {
1285 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1284 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1286 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan t)) 1285 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan t))
1287 return false; 1286 return false;
1288 return true; 1287 return true;
1289 } 1288 }
1290 return false; 1289 return false;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 else 1475 else
1477 return parseFontVariantLigatures(important); 1476 return parseFontVariantLigatures(important);
1478 break; 1477 break;
1479 case CSSPropertyWebkitClipPath: 1478 case CSSPropertyWebkitClipPath:
1480 if (id == CSSValueNone) { 1479 if (id == CSSValueNone) {
1481 validPrimitive = true; 1480 validPrimitive = true;
1482 } else if (value->unit == CSSParserValue::Function) { 1481 } else if (value->unit == CSSParserValue::Function) {
1483 parsedValue = parseBasicShape(); 1482 parsedValue = parseBasicShape();
1484 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 1483 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
1485 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV alue::CSS_URI); 1484 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV alue::CSS_URI);
1486 addProperty(propId, parsedValue.release(), important); 1485 addProperty(propId, *parsedValue, important);
1487 return true; 1486 return true;
1488 } 1487 }
1489 break; 1488 break;
1490 case CSSPropertyShapeOutside: 1489 case CSSPropertyShapeOutside:
1491 if (id == CSSValueNone) 1490 if (id == CSSValueNone)
1492 validPrimitive = true; 1491 validPrimitive = true;
1493 else 1492 else
1494 parsedValue = parseShapeProperty(propId); 1493 parsedValue = parseShapeProperty(propId);
1495 break; 1494 break;
1496 case CSSPropertyShapeMargin: 1495 case CSSPropertyShapeMargin:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 return parseSVGValue(propId, important); 1547 return parseSVGValue(propId, important);
1549 } 1548 }
1550 1549
1551 if (validPrimitive) { 1550 if (validPrimitive) {
1552 parsedValue = parseValidPrimitive(id, value); 1551 parsedValue = parseValidPrimitive(id, value);
1553 m_valueList->next(); 1552 m_valueList->next();
1554 } 1553 }
1555 ASSERT(!m_parsedCalculation); 1554 ASSERT(!m_parsedCalculation);
1556 if (parsedValue) { 1555 if (parsedValue) {
1557 if (!m_valueList->current() || inShorthand()) { 1556 if (!m_valueList->current() || inShorthand()) {
1558 addProperty(propId, parsedValue.release(), important); 1557 addProperty(propId, *parsedValue, important);
1559 return true; 1558 return true;
1560 } 1559 }
1561 } 1560 }
1562 return false; 1561 return false;
1563 } 1562 }
1564 1563
1565 void CSSPropertyParser::addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRef PtrWillBeRawPtr<CSSValue> rval) 1564 void CSSPropertyParser::addFillValue(NullableCSSValue& lval, CSSValue rval)
1566 { 1565 {
1567 if (lval) { 1566 if (lval) {
1568 if (lval->isBaseValueList()) 1567 if (lval->isBaseValueList())
1569 toCSSValueList(lval.get())->append(rval); 1568 toCSSValueList(lval)->append(rval);
1570 else { 1569 else {
1571 PassRefPtrWillBeRawPtr<CSSValue> oldlVal(lval.release());
1572 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated(); 1570 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated();
1573 list->append(oldlVal); 1571 list->append(*lval);
1574 list->append(rval); 1572 list->append(rval);
1575 lval = list; 1573 lval = list;
1576 } 1574 }
1577 } 1575 }
1578 else 1576 else
1579 lval = rval; 1577 lval = rval;
1580 } 1578 }
1581 1579
1582 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtrWillBeRawPtr< CSSValue>& cssValue) 1580 static bool parseBackgroundClip(CSSParserValue* parserValue, NullableCSSValue& c ssValue)
1583 { 1581 {
1584 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi ngBox 1582 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi ngBox
1585 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW ebkitText) { 1583 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW ebkitText) {
1586 cssValue = cssValuePool().createIdentifierValue(parserValue->id); 1584 cssValue = cssValuePool().createIdentifierValue(parserValue->id);
1587 return true; 1585 return true;
1588 } 1586 }
1589 return false; 1587 return false;
1590 } 1588 }
1591 1589
1592 const int cMaxFillProperties = 9; 1590 const int cMaxFillProperties = 9;
1593 1591
1594 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper tyID* properties, int numProperties, bool important) 1592 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper tyID* properties, int numProperties, bool important)
1595 { 1593 {
1596 ASSERT(numProperties <= cMaxFillProperties); 1594 ASSERT(numProperties <= cMaxFillProperties);
1597 if (numProperties > cMaxFillProperties) 1595 if (numProperties > cMaxFillProperties)
1598 return false; 1596 return false;
1599 1597
1600 ShorthandScope scope(this, propId); 1598 ShorthandScope scope(this, propId);
1601 1599
1602 bool parsedProperty[cMaxFillProperties] = { false }; 1600 bool parsedProperty[cMaxFillProperties] = { false };
1603 RefPtrWillBeRawPtr<CSSValue> values[cMaxFillProperties]; 1601 NullableCSSValue values[cMaxFillProperties];
1604 #if ENABLE(OILPAN) 1602 #if ENABLE(OILPAN)
1605 // Zero initialize the array of raw pointers. 1603 // Zero initialize the array of raw pointers.
1606 memset(&values, 0, sizeof(values)); 1604 memset(&values, 0, sizeof(values));
1607 #endif 1605 #endif
1608 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; 1606 NullableCSSValue clipValue;
1609 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; 1607 NullableCSSValue positionYValue;
1610 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; 1608 NullableCSSValue repeatYValue;
1611 bool foundClip = false; 1609 bool foundClip = false;
1612 int i; 1610 int i;
1613 bool foundPositionCSSProperty = false; 1611 bool foundPositionCSSProperty = false;
1614 1612
1615 while (m_valueList->current()) { 1613 while (m_valueList->current()) {
1616 CSSParserValue* val = m_valueList->current(); 1614 CSSParserValue* val = m_valueList->current();
1617 if (isComma(val)) { 1615 if (isComma(val)) {
1618 // We hit the end. Fill in all remaining values with the initial va lue. 1616 // We hit the end. Fill in all remaining values with the initial va lue.
1619 m_valueList->next(); 1617 m_valueList->next();
1620 for (i = 0; i < numProperties; ++i) { 1618 for (i = 0; i < numProperties; ++i) {
(...skipping 28 matching lines...) Expand all
1649 foundPositionCSSProperty = false; 1647 foundPositionCSSProperty = false;
1650 bool found = false; 1648 bool found = false;
1651 for (i = 0; !found && i < numProperties; ++i) { 1649 for (i = 0; !found && i < numProperties; ++i) {
1652 1650
1653 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou ndSize && properties[i] != CSSPropertyWebkitMaskSize)) 1651 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou ndSize && properties[i] != CSSPropertyWebkitMaskSize))
1654 continue; 1652 continue;
1655 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro undSize || properties[i] == CSSPropertyWebkitMaskSize)) 1653 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro undSize || properties[i] == CSSPropertyWebkitMaskSize))
1656 continue; 1654 continue;
1657 1655
1658 if (!parsedProperty[i]) { 1656 if (!parsedProperty[i]) {
1659 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 1657 NullableCSSValue val1;
1660 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 1658 NullableCSSValue val2;
1661 CSSPropertyID propId1, propId2; 1659 CSSPropertyID propId1, propId2;
1662 CSSParserValue* parserValue = m_valueList->current(); 1660 CSSParserValue* parserValue = m_valueList->current();
1663 // parseFillProperty() may modify m_implicitShorthand, so we MUS T reset it 1661 // parseFillProperty() may modify m_implicitShorthand, so we MUS T reset it
1664 // before EACH return below. 1662 // before EACH return below.
1665 if (parserValue && parseFillProperty(properties[i], propId1, pro pId2, val1, val2)) { 1663 if (parserValue && parseFillProperty(properties[i], propId1, pro pId2, val1, val2)) {
1666 parsedProperty[i] = found = true; 1664 parsedProperty[i] = found = true;
1667 addFillValue(values[i], val1.release()); 1665 addFillValue(values[i], *val1);
1668 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition) 1666 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition)
1669 addFillValue(positionYValue, val2.release()); 1667 addFillValue(positionYValue, *val2);
1670 if (properties[i] == CSSPropertyBackgroundRepeat || properti es[i] == CSSPropertyWebkitMaskRepeat) 1668 if (properties[i] == CSSPropertyBackgroundRepeat || properti es[i] == CSSPropertyWebkitMaskRepeat)
1671 addFillValue(repeatYValue, val2.release()); 1669 addFillValue(repeatYValue, *val2);
1672 if (properties[i] == CSSPropertyBackgroundOrigin || properti es[i] == CSSPropertyWebkitMaskOrigin) { 1670 if (properties[i] == CSSPropertyBackgroundOrigin || properti es[i] == CSSPropertyWebkitMaskOrigin) {
1673 // Reparse the value as a clip, and see if we succeed. 1671 // Reparse the value as a clip, and see if we succeed.
1674 if (parseBackgroundClip(parserValue, val1)) 1672 if (parseBackgroundClip(parserValue, val1))
1675 addFillValue(clipValue, val1.release()); // The prop erty parsed successfully. 1673 addFillValue(clipValue, *val1); // The property pars ed successfully.
1676 else 1674 else
1677 addFillValue(clipValue, cssValuePool().createImplici tInitialValue()); // Some value was used for origin that is not supported by cli p. Just reset clip instead. 1675 addFillValue(clipValue, cssValuePool().createImplici tInitialValue()); // Some value was used for origin that is not supported by cli p. Just reset clip instead.
1678 } 1676 }
1679 if (properties[i] == CSSPropertyBackgroundClip || properties [i] == CSSPropertyWebkitMaskClip) { 1677 if (properties[i] == CSSPropertyBackgroundClip || properties [i] == CSSPropertyWebkitMaskClip) {
1680 // Update clipValue 1678 // Update clipValue
1681 addFillValue(clipValue, val1.release()); 1679 addFillValue(clipValue, *val1);
1682 foundClip = true; 1680 foundClip = true;
1683 } 1681 }
1684 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition) 1682 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition)
1685 foundPositionCSSProperty = true; 1683 foundPositionCSSProperty = true;
1686 } 1684 }
1687 } 1685 }
1688 } 1686 }
1689 1687
1690 // if we didn't find at least one match, this is an 1688 // if we didn't find at least one match, this is an
1691 // invalid shorthand and we have to ignore it 1689 // invalid shorthand and we have to ignore it
(...skipping 11 matching lines...) Expand all
1703 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition) 1701 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
1704 addFillValue(positionYValue, cssValuePool().createImplicitInitia lValue()); 1702 addFillValue(positionYValue, cssValuePool().createImplicitInitia lValue());
1705 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat) 1703 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
1706 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV alue()); 1704 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV alue());
1707 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) { 1705 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
1708 // If background-origin wasn't present, then reset background-cl ip also. 1706 // If background-origin wasn't present, then reset background-cl ip also.
1709 addFillValue(clipValue, cssValuePool().createImplicitInitialValu e()); 1707 addFillValue(clipValue, cssValuePool().createImplicitInitialValu e());
1710 } 1708 }
1711 } 1709 }
1712 if (properties[i] == CSSPropertyBackgroundPosition) { 1710 if (properties[i] == CSSPropertyBackgroundPosition) {
1713 addProperty(CSSPropertyBackgroundPositionX, values[i].release(), imp ortant); 1711 addProperty(CSSPropertyBackgroundPositionX, *values[i], important);
1714 // it's OK to call positionYValue.release() since we only see CSSPro pertyBackgroundPosition once 1712 // it's OK to call positionYValue.release() since we only see CSSPro pertyBackgroundPosition once
1715 addProperty(CSSPropertyBackgroundPositionY, positionYValue.release() , important); 1713 addProperty(CSSPropertyBackgroundPositionY, *positionYValue, importa nt);
1716 } else if (properties[i] == CSSPropertyWebkitMaskPosition) { 1714 } else if (properties[i] == CSSPropertyWebkitMaskPosition) {
1717 addProperty(CSSPropertyWebkitMaskPositionX, values[i].release(), imp ortant); 1715 addProperty(CSSPropertyWebkitMaskPositionX, *values[i], important);
1718 // it's OK to call positionYValue.release() since we only see CSSPro pertyWebkitMaskPosition once 1716 // it's OK to call positionYValue.release() since we only see CSSPro pertyWebkitMaskPosition once
1719 addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release() , important); 1717 addProperty(CSSPropertyWebkitMaskPositionY, *positionYValue, importa nt);
1720 } else if (properties[i] == CSSPropertyBackgroundRepeat) { 1718 } else if (properties[i] == CSSPropertyBackgroundRepeat) {
1721 addProperty(CSSPropertyBackgroundRepeatX, values[i].release(), impor tant); 1719 addProperty(CSSPropertyBackgroundRepeatX, *values[i], important);
1722 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once 1720 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once
1723 addProperty(CSSPropertyBackgroundRepeatY, repeatYValue.release(), im portant); 1721 addProperty(CSSPropertyBackgroundRepeatY, *repeatYValue, important);
1724 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) { 1722 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) {
1725 addProperty(CSSPropertyWebkitMaskRepeatX, values[i].release(), impor tant); 1723 addProperty(CSSPropertyWebkitMaskRepeatX, *values[i], important);
1726 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once 1724 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once
1727 addProperty(CSSPropertyWebkitMaskRepeatY, repeatYValue.release(), im portant); 1725 addProperty(CSSPropertyWebkitMaskRepeatY, *repeatYValue, important);
1728 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip) 1726 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip)
1729 // Value is already set while updating origin 1727 // Value is already set while updating origin
1730 continue; 1728 continue;
1731 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i ] && m_context.useLegacyBackgroundSizeShorthandBehavior()) 1729 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i ] && m_context.useLegacyBackgroundSizeShorthandBehavior())
1732 continue; 1730 continue;
1733 else 1731 else
1734 addProperty(properties[i], values[i].release(), important); 1732 addProperty(properties[i], *values[i], important);
1735 1733
1736 // Add in clip values when we hit the corresponding origin property. 1734 // Add in clip values when we hit the corresponding origin property.
1737 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) 1735 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip)
1738 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan t); 1736 addProperty(CSSPropertyBackgroundClip, *clipValue, important);
1739 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) 1737 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip)
1740 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan t); 1738 addProperty(CSSPropertyWebkitMaskClip, *clipValue, important);
1741 } 1739 }
1742 1740
1743 m_implicitShorthand = false; 1741 m_implicitShorthand = false;
1744 return true; 1742 return true;
1745 } 1743 }
1746 1744
1747 static bool isValidTransitionPropertyList(CSSValueList* value) 1745 static bool isValidTransitionPropertyList(CSSValueList* value)
1748 { 1746 {
1749 if (value->length() < 2) 1747 if (value->length() < 2)
1750 return true; 1748 return true;
1751 for (auto& property : *value) { 1749 for (auto& property : *value) {
1752 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip 1750 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip
1753 if (property->isInitialValue()) 1751 if (property.isInitialValue())
1754 continue; 1752 continue;
1755 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(property.get()); 1753 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(property);
1756 if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSVa lueNone) 1754 if (primitiveValue.isValueID() && primitiveValue.getValueID() == CSSValu eNone)
1757 return false; 1755 return false;
1758 } 1756 }
1759 return true; 1757 return true;
1760 } 1758 }
1761 1759
1762 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant) 1760 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant)
1763 { 1761 {
1764 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing(); 1762 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing();
1765 const unsigned numProperties = 8; 1763 const unsigned numProperties = 8;
1766 1764
(...skipping 19 matching lines...) Expand all
1786 parsedProperty[i] = false; 1784 parsedProperty[i] = false;
1787 } 1785 }
1788 if (!m_valueList->current()) 1786 if (!m_valueList->current())
1789 break; 1787 break;
1790 } 1788 }
1791 1789
1792 bool found = false; 1790 bool found = false;
1793 for (size_t i = 0; i < numProperties; ++i) { 1791 for (size_t i = 0; i < numProperties; ++i) {
1794 if (parsedProperty[i]) 1792 if (parsedProperty[i])
1795 continue; 1793 continue;
1796 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(animat ionProperties.properties()[i], useLegacyparsing)) { 1794 if (NullableCSSValue val = parseAnimationProperty(animationPropertie s.properties()[i], useLegacyparsing)) {
1797 parsedProperty[i] = found = true; 1795 parsedProperty[i] = found = true;
1798 values[i]->append(val.release()); 1796 values[i]->append(*val);
1799 break; 1797 break;
1800 } 1798 }
1801 } 1799 }
1802 1800
1803 // if we didn't find at least one match, this is an 1801 // if we didn't find at least one match, this is an
1804 // invalid shorthand and we have to ignore it 1802 // invalid shorthand and we have to ignore it
1805 if (!found) 1803 if (!found)
1806 return false; 1804 return false;
1807 } 1805 }
1808 1806
(...skipping 30 matching lines...) Expand all
1839 parsedProperty[i] = false; 1837 parsedProperty[i] = false;
1840 } 1838 }
1841 if (!m_valueList->current()) 1839 if (!m_valueList->current())
1842 break; 1840 break;
1843 } 1841 }
1844 1842
1845 bool found = false; 1843 bool found = false;
1846 for (size_t i = 0; i < numProperties; ++i) { 1844 for (size_t i = 0; i < numProperties; ++i) {
1847 if (parsedProperty[i]) 1845 if (parsedProperty[i])
1848 continue; 1846 continue;
1849 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(shorth and.properties()[i], false)) { 1847 if (NullableCSSValue val = parseAnimationProperty(shorthand.properti es()[i], false)) {
1850 parsedProperty[i] = found = true; 1848 parsedProperty[i] = found = true;
1851 values[i]->append(val.release()); 1849 values[i]->append(*val);
1852 break; 1850 break;
1853 } 1851 }
1854 } 1852 }
1855 1853
1856 // if we didn't find at least one match, this is an 1854 // if we didn't find at least one match, this is an
1857 // invalid shorthand and we have to ignore it 1855 // invalid shorthand and we have to ignore it
1858 if (!found) 1856 if (!found)
1859 return false; 1857 return false;
1860 } 1858 }
1861 1859
1862 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); 1860 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty);
1863 if (!isValidTransitionPropertyList(values[3].get())) 1861 if (!isValidTransitionPropertyList(values[3].get()))
1864 return false; 1862 return false;
1865 1863
1866 // Fill in any remaining properties with the initial value and add 1864 // Fill in any remaining properties with the initial value and add
1867 for (size_t i = 0; i < numProperties; ++i) { 1865 for (size_t i = 0; i < numProperties; ++i) {
1868 if (!parsedProperty[i]) 1866 if (!parsedProperty[i])
1869 values[i]->append(cssValuePool().createImplicitInitialValue()); 1867 values[i]->append(cssValuePool().createImplicitInitialValue());
1870 addProperty(shorthand.properties()[i], values[i].release(), important); 1868 addProperty(shorthand.properties()[i], values[i].release(), important);
1871 } 1869 }
1872 1870
1873 return true; 1871 return true;
1874 } 1872 }
1875 1873
1876 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() 1874 NullableCSSValue CSSPropertyParser::parseColumnWidth()
1877 { 1875 {
1878 CSSParserValue* value = m_valueList->current(); 1876 CSSParserValue* value = m_valueList->current();
1879 // Always parse lengths in strict mode here, since it would be ambiguous oth erwise when used in 1877 // Always parse lengths in strict mode here, since it would be ambiguous oth erwise when used in
1880 // the 'columns' shorthand property. 1878 // the 'columns' shorthand property.
1881 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt andardMode) && (m_parsedCalculation || value->fValue != 0))) { 1879 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt andardMode) && (m_parsedCalculation || value->fValue != 0))) {
1882 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id , value); 1880 CSSValue parsedValue = parseValidPrimitive(value->id, value);
1883 m_valueList->next(); 1881 m_valueList->next();
1884 return parsedValue; 1882 return parsedValue;
1885 } 1883 }
1886 return nullptr; 1884 return nullptr;
1887 } 1885 }
1888 1886
1889 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() 1887 NullableCSSValue CSSPropertyParser::parseColumnCount()
1890 { 1888 {
1891 CSSParserValue* value = m_valueList->current(); 1889 CSSParserValue* value = m_valueList->current();
1892 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { 1890 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) {
1893 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id , value); 1891 CSSValue parsedValue = parseValidPrimitive(value->id, value);
1894 m_valueList->next(); 1892 m_valueList->next();
1895 return parsedValue; 1893 return parsedValue;
1896 } 1894 }
1897 return nullptr; 1895 return nullptr;
1898 } 1896 }
1899 1897
1900 bool CSSPropertyParser::parseColumnsShorthand(bool important) 1898 bool CSSPropertyParser::parseColumnsShorthand(bool important)
1901 { 1899 {
1902 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; 1900 NullableCSSValue columnWidth;
1903 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; 1901 NullableCSSValue columnCount;
1904 bool hasPendingExplicitAuto = false; 1902 bool hasPendingExplicitAuto = false;
1905 1903
1906 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) { 1904 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) {
1907 if (propertiesParsed >= 2) 1905 if (propertiesParsed >= 2)
1908 return false; // Too many values for this shorthand. Invalid declara tion. 1906 return false; // Too many values for this shorthand. Invalid declara tion.
1909 if (!propertiesParsed && value->id == CSSValueAuto) { 1907 if (!propertiesParsed && value->id == CSSValueAuto) {
1910 // 'auto' is a valid value for any of the two longhands, and at this point we 1908 // 'auto' is a valid value for any of the two longhands, and at this point we
1911 // don't know which one(s) it is meant for. We need to see if there are other 1909 // don't know which one(s) it is meant for. We need to see if there are other
1912 // values first. 1910 // values first.
1913 m_valueList->next(); 1911 m_valueList->next();
(...skipping 21 matching lines...) Expand all
1935 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); 1933 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto);
1936 } else { 1934 } else {
1937 ASSERT(!columnCount); 1935 ASSERT(!columnCount);
1938 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); 1936 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto);
1939 } 1937 }
1940 } 1938 }
1941 ASSERT(columnCount || columnWidth); 1939 ASSERT(columnCount || columnWidth);
1942 1940
1943 // Any unassigned property at this point will become implicit 'auto'. 1941 // Any unassigned property at this point will become implicit 'auto'.
1944 if (columnWidth) 1942 if (columnWidth)
1945 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); 1943 addProperty(CSSPropertyWebkitColumnWidth, *columnWidth, important);
1946 else 1944 else
1947 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1945 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1948 if (columnCount) 1946 if (columnCount)
1949 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); 1947 addProperty(CSSPropertyWebkitColumnCount, *columnCount, important);
1950 else 1948 else
1951 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1949 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1952 return true; 1950 return true;
1953 } 1951 }
1954 1952
1955 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important) 1953 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important)
1956 { 1954 {
1957 // We try to match as many properties as possible 1955 // We try to match as many properties as possible
1958 // We set up an array of booleans to mark which property has been found, 1956 // We set up an array of booleans to mark which property has been found,
1959 // and we try to search for properties until it makes no longer any sense. 1957 // 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
2011 2009
2012 int num = inShorthand() ? 1 : m_valueList->size(); 2010 int num = inShorthand() ? 1 : m_valueList->size();
2013 2011
2014 ShorthandScope scope(this, propId); 2012 ShorthandScope scope(this, propId);
2015 2013
2016 // the order is top, right, bottom, left 2014 // the order is top, right, bottom, left
2017 switch (num) { 2015 switch (num) {
2018 case 1: { 2016 case 1: {
2019 if (!parseValue(properties[0], important)) 2017 if (!parseValue(properties[0], important))
2020 return false; 2018 return false;
2021 CSSValue* value = m_parsedProperties.last().value(); 2019 CSSValue value = m_parsedProperties.last().value();
2022 ImplicitScope implicitScope(this); 2020 ImplicitScope implicitScope(this);
2023 addProperty(properties[1], value, important); 2021 addProperty(properties[1], value, important);
2024 addProperty(properties[2], value, important); 2022 addProperty(properties[2], value, important);
2025 addProperty(properties[3], value, important); 2023 addProperty(properties[3], value, important);
2026 break; 2024 break;
2027 } 2025 }
2028 case 2: { 2026 case 2: {
2029 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important)) 2027 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important))
2030 return false; 2028 return false;
2031 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2]. value(); 2029 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue();
2032 ImplicitScope implicitScope(this); 2030 ImplicitScope implicitScope(this);
2033 addProperty(properties[2], value, important); 2031 addProperty(properties[2], value, important);
2034 value = m_parsedProperties[m_parsedProperties.size() - 2].value(); 2032 value = m_parsedProperties[m_parsedProperties.size() - 2].value();
2035 addProperty(properties[3], value, important); 2033 addProperty(properties[3], value, important);
2036 break; 2034 break;
2037 } 2035 }
2038 case 3: { 2036 case 3: {
2039 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important)) 2037 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important))
2040 return false; 2038 return false;
2041 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2]. value(); 2039 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue();
2042 ImplicitScope implicitScope(this); 2040 ImplicitScope implicitScope(this);
2043 addProperty(properties[3], value, important); 2041 addProperty(properties[3], value, important);
2044 break; 2042 break;
2045 } 2043 }
2046 case 4: { 2044 case 4: {
2047 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || 2045 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) ||
2048 !parseValue(properties[2], important) || !parseValue(properties[ 3], important)) 2046 !parseValue(properties[2], important) || !parseValue(properties[ 3], important))
2049 return false; 2047 return false;
2050 break; 2048 break;
2051 } 2049 }
2052 default: { 2050 default: {
2053 return false; 2051 return false;
2054 } 2052 }
2055 } 2053 }
2056 2054
2057 return true; 2055 return true;
2058 } 2056 }
2059 2057
2060 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() 2058 NullableCSSValue CSSPropertyParser::parseScrollSnapPoints()
2061 { 2059 {
2062 CSSParserValue* value = m_valueList->current(); 2060 CSSParserValue* value = m_valueList->current();
2063 2061
2064 if (value->id == CSSValueNone) { 2062 if (value->id == CSSValueNone) {
2065 m_valueList->next(); 2063 m_valueList->next();
2066 return cssValuePool().createIdentifierValue(CSSValueNone); 2064 return cssValuePool().createIdentifierValue(CSSValueNone);
2067 } 2065 }
2068 2066
2069 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) { 2067 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) {
2070 // The spec defines the following grammar: repeat( <length>) 2068 // The spec defines the following grammar: repeat( <length>)
2071 CSSParserValueList* arguments = value->function->args.get(); 2069 CSSParserValueList* arguments = value->function->args.get();
2072 if (!arguments || arguments->size() != 1) 2070 if (!arguments || arguments->size() != 1)
2073 return nullptr; 2071 return nullptr;
2074 2072
2075 CSSParserValue* repeatValue = arguments->valueAt(0); 2073 CSSParserValue* repeatValue = arguments->valueAt(0);
2076 if (validUnit(repeatValue, FNonNeg | FLength | FPercent) && (m_parsedCal culation || repeatValue->fValue > 0)) { 2074 if (validUnit(repeatValue, FNonNeg | FLength | FPercent) && (m_parsedCal culation || repeatValue->fValue > 0)) {
2077 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::crea te(CSSValueRepeat); 2075 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::crea te(CSSValueRepeat);
2078 result->append(parseValidPrimitive(repeatValue->id, repeatValue)); 2076 result->append(parseValidPrimitive(repeatValue->id, repeatValue));
2079 m_valueList->next(); 2077 m_valueList->next();
2080 return result.release(); 2078 return result.release();
2081 } 2079 }
2082 } 2080 }
2083 2081
2084 return nullptr; 2082 return nullptr;
2085 } 2083 }
2086 2084
2087 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() 2085 NullableCSSValue CSSPropertyParser::parseScrollSnapCoordinate()
2088 { 2086 {
2089 if (m_valueList->current()->id == CSSValueNone) { 2087 if (m_valueList->current()->id == CSSValueNone) {
2090 m_valueList->next(); 2088 m_valueList->next();
2091 return cssValuePool().createIdentifierValue(CSSValueNone); 2089 return cssValuePool().createIdentifierValue(CSSValueNone);
2092 } 2090 }
2093 2091
2094 return parsePositionList(m_valueList); 2092 return parsePositionList(m_valueList);
2095 } 2093 }
2096 2094
2097 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() 2095 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage()
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 parsedValues->append(createPrimitiveNumericValue(value)); 2165 parsedValues->append(createPrimitiveNumericValue(value));
2168 return Length; 2166 return Length;
2169 } 2167 }
2170 return None; 2168 return None;
2171 default: 2169 default:
2172 return None; 2170 return None;
2173 } 2171 }
2174 } 2172 }
2175 2173
2176 // [ <string> <string> ]+ | none, but none is handled in parseValue 2174 // [ <string> <string> ]+ | none, but none is handled in parseValue
2177 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() 2175 NullableCSSValue CSSPropertyParser::parseQuotes()
2178 { 2176 {
2179 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 2177 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
2180 while (CSSParserValue* val = m_valueList->current()) { 2178 while (CSSParserValue* val = m_valueList->current()) {
2181 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 2179 NullableCSSValue parsedValue;
2182 if (val->unit != CSSPrimitiveValue::CSS_STRING) 2180 if (val->unit != CSSPrimitiveValue::CSS_STRING)
2183 return nullptr; 2181 return nullptr;
2184 parsedValue = createPrimitiveStringValue(val); 2182 parsedValue = createPrimitiveStringValue(val);
2185 values->append(parsedValue.release()); 2183 values->append(*parsedValue);
2186 m_valueList->next(); 2184 m_valueList->next();
2187 } 2185 }
2188 if (values->length() && values->length() % 2 == 0) 2186 if (values->length() && values->length() % 2 == 0)
2189 return values.release(); 2187 return values.release();
2190 return nullptr; 2188 return nullptr;
2191 } 2189 }
2192 2190
2193 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit 2191 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit
2194 // in CSS 2.1 this got somewhat reduced: 2192 // in CSS 2.1 this got somewhat reduced:
2195 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit 2193 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit
2196 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() 2194 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent()
2197 { 2195 {
2198 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 2196 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
2199 2197
2200 while (CSSParserValue* val = m_valueList->current()) { 2198 while (CSSParserValue* val = m_valueList->current()) {
2201 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 2199 NullableCSSValue parsedValue;
2202 if (val->unit == CSSPrimitiveValue::CSS_URI) { 2200 if (val->unit == CSSPrimitiveValue::CSS_URI) {
2203 // url 2201 // url
2204 parsedValue = createCSSImageValueWithReferrer(val->string, completeU RL(val->string)); 2202 parsedValue = createCSSImageValueWithReferrer(val->string, completeU RL(val->string));
2205 } else if (val->unit == CSSParserValue::Function) { 2203 } else if (val->unit == CSSParserValue::Function) {
2206 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...) 2204 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...)
2207 CSSParserValueList* args = val->function->args.get(); 2205 CSSParserValueList* args = val->function->args.get();
2208 if (!args) 2206 if (!args)
2209 return nullptr; 2207 return nullptr;
2210 if (val->function->id == CSSValueAttr) { 2208 if (val->function->id == CSSValueAttr) {
2211 parsedValue = parseAttr(args); 2209 parsedValue = parseAttr(args);
(...skipping 17 matching lines...) Expand all
2229 case CSSValueNormal: 2227 case CSSValueNormal:
2230 parsedValue = cssValuePool().createIdentifierValue(val->id); 2228 parsedValue = cssValuePool().createIdentifierValue(val->id);
2231 default: 2229 default:
2232 break; 2230 break;
2233 } 2231 }
2234 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { 2232 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
2235 parsedValue = createPrimitiveStringValue(val); 2233 parsedValue = createPrimitiveStringValue(val);
2236 } 2234 }
2237 if (!parsedValue) 2235 if (!parsedValue)
2238 return nullptr; 2236 return nullptr;
2239 values->append(parsedValue.release()); 2237 values->append(*parsedValue);
2240 m_valueList->next(); 2238 m_valueList->next();
2241 } 2239 }
2242 2240
2243 return values.release(); 2241 return values.release();
2244 } 2242 }
2245 2243
2246 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList * args) 2244 NullableCSSValue CSSPropertyParser::parseAttr(CSSParserValueList* args)
2247 { 2245 {
2248 if (args->size() != 1) 2246 if (args->size() != 1)
2249 return nullptr; 2247 return nullptr;
2250 2248
2251 CSSParserValue* a = args->current(); 2249 CSSParserValue* a = args->current();
2252 2250
2253 if (a->unit != CSSPrimitiveValue::CSS_IDENT) 2251 if (a->unit != CSSPrimitiveValue::CSS_IDENT)
2254 return nullptr; 2252 return nullptr;
2255 2253
2256 String attrName = a->string; 2254 String attrName = a->string;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 2356
2359 // Used to parse colors for -webkit-gradient(...). 2357 // Used to parse colors for -webkit-gradient(...).
2360 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseDeprecatedGrad ientStopColor(const CSSParserValue* value) 2358 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseDeprecatedGrad ientStopColor(const CSSParserValue* value)
2361 { 2359 {
2362 // Disallow currentcolor. 2360 // Disallow currentcolor.
2363 if (value->id == CSSValueCurrentcolor) 2361 if (value->id == CSSValueCurrentcolor)
2364 return nullptr; 2362 return nullptr;
2365 return parseGradientStopColor(value); 2363 return parseGradientStopColor(value);
2366 } 2364 }
2367 2365
2368 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& value) 2366 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, NullableCS SValue& value)
2369 { 2367 {
2370 if (valueList->current()->id == CSSValueNone) { 2368 if (valueList->current()->id == CSSValueNone) {
2371 value = cssValuePool().createIdentifierValue(CSSValueNone); 2369 value = cssValuePool().createIdentifierValue(CSSValueNone);
2372 return true; 2370 return true;
2373 } 2371 }
2374 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { 2372 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
2375 value = createCSSImageValueWithReferrer(valueList->current()->string, co mpleteURL(valueList->current()->string)); 2373 value = createCSSImageValueWithReferrer(valueList->current()->string, co mpleteURL(valueList->current()->string));
2376 return true; 2374 return true;
2377 } 2375 }
2378 2376
2379 if (isGeneratedImageValue(valueList->current())) 2377 if (isGeneratedImageValue(valueList->current()))
2380 return parseGeneratedImage(valueList, value); 2378 return parseGeneratedImage(valueList, value);
2381 2379
2382 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur rent()->function->id == CSSValueWebkitImageSet) { 2380 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur rent()->function->id == CSSValueWebkitImageSet) {
2383 value = parseImageSet(m_valueList); 2381 value = parseImageSet(m_valueList);
2384 if (value) 2382 if (value)
2385 return true; 2383 return true;
2386 } 2384 }
2387 2385
2388 return false; 2386 return false;
2389 } 2387 }
2390 2388
2391 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser ValueList* valueList) 2389 NullableCSSValue CSSPropertyParser::parseFillPositionX(CSSParserValueList* value List)
2392 { 2390 {
2393 int id = valueList->current()->id; 2391 int id = valueList->current()->id;
2394 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { 2392 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) {
2395 int percent = 0; 2393 int percent = 0;
2396 if (id == CSSValueRight) 2394 if (id == CSSValueRight)
2397 percent = 100; 2395 percent = 100;
2398 else if (id == CSSValueCenter) 2396 else if (id == CSSValueCenter)
2399 percent = 50; 2397 percent = 50;
2400 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE); 2398 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE);
2401 } 2399 }
2402 if (validUnit(valueList->current(), FPercent | FLength)) 2400 if (validUnit(valueList->current(), FPercent | FLength))
2403 return createPrimitiveNumericValue(valueList->current()); 2401 return createPrimitiveNumericValue(valueList->current());
2404 return nullptr; 2402 return nullptr;
2405 } 2403 }
2406 2404
2407 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser ValueList* valueList) 2405 NullableCSSValue CSSPropertyParser::parseFillPositionY(CSSParserValueList* value List)
2408 { 2406 {
2409 int id = valueList->current()->id; 2407 int id = valueList->current()->id;
2410 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { 2408 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) {
2411 int percent = 0; 2409 int percent = 0;
2412 if (id == CSSValueBottom) 2410 if (id == CSSValueBottom)
2413 percent = 100; 2411 percent = 100;
2414 else if (id == CSSValueCenter) 2412 else if (id == CSSValueCenter)
2415 percent = 50; 2413 percent = 50;
2416 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE); 2414 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE);
2417 } 2415 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 return true; 2476 return true;
2479 2477
2480 return false; 2478 return false;
2481 } 2479 }
2482 2480
2483 static bool isFillPositionKeyword(CSSValueID value) 2481 static bool isFillPositionKeyword(CSSValueID value)
2484 { 2482 {
2485 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter; 2483 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter;
2486 } 2484 }
2487 2485
2488 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2486 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu e2)
2489 { 2487 {
2490 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ] 2488 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ]
2491 // In the case of 4 values <position> requires the second value to be a leng th or a percentage. 2489 // In the case of 4 values <position> requires the second value to be a leng th or a percentage.
2492 if (isFillPositionKeyword(parsedValue2->getValueID())) 2490 if (isFillPositionKeyword(parsedValue2->getValueID()))
2493 return; 2491 return;
2494 2492
2495 unsigned cumulativeFlags = 0; 2493 unsigned cumulativeFlags = 0;
2496 FillPositionFlag value3Flag = InvalidFillPosition; 2494 FillPositionFlag value3Flag = InvalidFillPosition;
2497 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); 2495 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword);
2498 if (!value3) 2496 if (!value3)
(...skipping 27 matching lines...) Expand all
2526 return; 2524 return;
2527 2525
2528 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); 2526 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2);
2529 value2 = createPrimitiveValuePair(value3, value4); 2527 value2 = createPrimitiveValuePair(value3, value4);
2530 2528
2531 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) 2529 if (ident1 == CSSValueTop || ident1 == CSSValueBottom)
2532 value1.swap(value2); 2530 value1.swap(value2);
2533 2531
2534 valueList->next(); 2532 valueList->next();
2535 } 2533 }
2536 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2534 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu e2)
2537 { 2535 {
2538 unsigned cumulativeFlags = 0; 2536 unsigned cumulativeFlags = 0;
2539 FillPositionFlag value3Flag = InvalidFillPosition; 2537 FillPositionFlag value3Flag = InvalidFillPosition;
2540 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); 2538 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword);
2541 2539
2542 // value3 is not an expected value, we return. 2540 // value3 is not an expected value, we return.
2543 if (!value3) 2541 if (!value3)
2544 return; 2542 return;
2545 2543
2546 valueList->next(); 2544 valueList->next();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 return; 2606 return;
2609 2607
2610 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); 2608 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue);
2611 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue); 2609 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue);
2612 } 2610 }
2613 2611
2614 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) 2612 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded)
2615 value1.swap(value2); 2613 value1.swap(value2);
2616 2614
2617 #if ENABLE(ASSERT) 2615 #if ENABLE(ASSERT)
2618 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); 2616 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1);
2619 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); 2617 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2);
2620 ident1 = first->getPairValue()->first()->getValueID(); 2618 ident1 = first->getPairValue()->first()->getValueID();
2621 ident2 = second->getPairValue()->first()->getValueID(); 2619 ident2 = second->getPairValue()->first()->getValueID();
2622 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); 2620 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight);
2623 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); 2621 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop);
2624 #endif 2622 #endif
2625 } 2623 }
2626 2624
2627 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) 2625 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value)
2628 { 2626 {
2629 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue); 2627 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue);
2630 } 2628 }
2631 2629
2632 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl ess) 2630 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, Nullabl eCSSValue& value1, NullableCSSValue& value2, Units unitless)
2633 { 2631 {
2634 unsigned numberOfValues = 0; 2632 unsigned numberOfValues = 0;
2635 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n umberOfValues) { 2633 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n umberOfValues) {
2636 CSSParserValue* current = valueList->valueAt(i); 2634 CSSParserValue* current = valueList->valueAt(i);
2637 if (!current || isComma(current) || isForwardSlashOperator(current) || ! isPotentialPositionValue(current)) 2635 if (!current || isComma(current) || isForwardSlashOperator(current) || ! isPotentialPositionValue(current))
2638 break; 2636 break;
2639 } 2637 }
2640 2638
2641 if (numberOfValues > 4) 2639 if (numberOfValues > 4)
2642 return; 2640 return;
(...skipping 22 matching lines...) Expand all
2665 2663
2666 valueList->next(); 2664 valueList->next();
2667 2665
2668 // In case we are parsing more than two values, relax the check inside of pa rseFillPositionComponent. top 20px is 2666 // In case we are parsing more than two values, relax the check inside of pa rseFillPositionComponent. top 20px is
2669 // a valid start for <position>. 2667 // a valid start for <position>.
2670 cumulativeFlags = AmbiguousFillPosition; 2668 cumulativeFlags = AmbiguousFillPosition;
2671 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword); 2669 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword);
2672 if (value2) 2670 if (value2)
2673 valueList->next(); 2671 valueList->next();
2674 else { 2672 else {
2675 value1.clear(); 2673 value1 = nullptr;
2676 return; 2674 return;
2677 } 2675 }
2678 2676
2679 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val ue1.get()); 2677 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val ue1);
2680 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val ue2.get()); 2678 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val ue2);
2681 2679
2682 value1.clear(); 2680 value1 = nullptr;
2683 value2.clear(); 2681 value2 = nullptr;
2684 2682
2685 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow. 2683 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow.
2686 if (parsedValue2->getValueID() == CSSValueCenter) 2684 if (parsedValue2->getValueID() == CSSValueCenter)
2687 return; 2685 return;
2688 2686
2689 if (numberOfValues == 3) 2687 if (numberOfValues == 3)
2690 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release (), parsedValue2.release()); 2688 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed Value2);
2691 else 2689 else
2692 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release (), parsedValue2.release()); 2690 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed Value2);
2693 } 2691 }
2694 2692
2695 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Unit s unitless) 2693 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, Units unitless)
2696 { 2694 {
2697 // Parse the first value. We're just making sure that it is one of the vali d keywords or a percentage/length. 2695 // Parse the first value. We're just making sure that it is one of the vali d keywords or a percentage/length.
2698 unsigned cumulativeFlags = 0; 2696 unsigned cumulativeFlags = 0;
2699 FillPositionFlag value1Flag = InvalidFillPosition; 2697 FillPositionFlag value1Flag = InvalidFillPosition;
2700 FillPositionFlag value2Flag = InvalidFillPosition; 2698 FillPositionFlag value2Flag = InvalidFillPosition;
2701 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag, ResolveValuesAsPercent, unitless); 2699 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag, ResolveValuesAsPercent, unitless);
2702 if (!value1) 2700 if (!value1)
2703 return; 2701 return;
2704 2702
2705 // It only takes one value for background-position to be correctly parsed if it was specified in a shorthand (since we 2703 // It only takes one value for background-position to be correctly parsed if it was specified in a shorthand (since we
2706 // can assume that any other values belong to the rest of the shorthand). I f we're not parsing a shorthand, though, the 2704 // can assume that any other values belong to the rest of the shorthand). I f we're not parsing a shorthand, though, the
2707 // value was explicitly specified for our property. 2705 // value was explicitly specified for our property.
2708 CSSParserValue* value = valueList->next(); 2706 CSSParserValue* value = valueList->next();
2709 2707
2710 // First check for the comma. If so, we are finished parsing this value or value pair. 2708 // First check for the comma. If so, we are finished parsing this value or value pair.
2711 if (value && isComma(value)) 2709 if (value && isComma(value))
2712 value = 0; 2710 value = 0;
2713 2711
2714 if (value) { 2712 if (value) {
2715 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl ag, ResolveValuesAsPercent, unitless); 2713 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl ag, ResolveValuesAsPercent, unitless);
2716 if (value2) 2714 if (value2)
2717 valueList->next(); 2715 valueList->next();
2718 else { 2716 else {
2719 if (!inShorthand()) { 2717 if (!inShorthand()) {
2720 value1.clear(); 2718 value1 = nullptr;
2721 return; 2719 return;
2722 } 2720 }
2723 } 2721 }
2724 } 2722 }
2725 2723
2726 if (!value2) 2724 if (!value2)
2727 // Only one value was specified. If that value was not a keyword, then i t sets the x position, and the y position 2725 // Only one value was specified. If that value was not a keyword, then i t sets the x position, and the y position
2728 // is simply 50%. This is our default. 2726 // is simply 50%. This is our default.
2729 // For keywords, the keyword was either an x-keyword (left/right), a y-k eyword (top/bottom), or an ambiguous keyword (center). 2727 // For keywords, the keyword was either an x-keyword (left/right), a y-k eyword (top/bottom), or an ambiguous keyword (center).
2730 // For left/right/center, the default of 50% in the y is still correct. 2728 // For left/right/center, the default of 50% in the y is still correct.
2731 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG E); 2729 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG E);
2732 2730
2733 if (value1Flag == YFillPosition || value2Flag == XFillPosition) 2731 if (value1Flag == YFillPosition || value2Flag == XFillPosition)
2734 value1.swap(value2); 2732 value1.swap(value2);
2735 } 2733 }
2736 2734
2737 void CSSPropertyParser::parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>& value1, Re fPtrWillBeRawPtr<CSSValue>& value2) 2735 void CSSPropertyParser::parseFillRepeat(NullableCSSValue& value1, NullableCSSVal ue& value2)
2738 { 2736 {
2739 CSSValueID id = m_valueList->current()->id; 2737 CSSValueID id = m_valueList->current()->id;
2740 if (id == CSSValueRepeatX) { 2738 if (id == CSSValueRepeatX) {
2741 m_implicitShorthand = true; 2739 m_implicitShorthand = true;
2742 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); 2740 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat);
2743 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); 2741 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
2744 m_valueList->next(); 2742 m_valueList->next();
2745 return; 2743 return;
2746 } 2744 }
2747 if (id == CSSValueRepeatY) { 2745 if (id == CSSValueRepeatY) {
(...skipping 17 matching lines...) Expand all
2765 id = value->id; 2763 id = value->id;
2766 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun d || id == CSSValueSpace) { 2764 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun d || id == CSSValueSpace) {
2767 value2 = cssValuePool().createIdentifierValue(id); 2765 value2 = cssValuePool().createIdentifierValue(id);
2768 m_valueList->next(); 2766 m_valueList->next();
2769 return; 2767 return;
2770 } 2768 }
2771 } 2769 }
2772 2770
2773 // If only one value was specified, value2 is the same as value1. 2771 // If only one value was specified, value2 is the same as value1.
2774 m_implicitShorthand = true; 2772 m_implicitShorthand = true;
2775 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get ())->getValueID()); 2773 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1)->g etValueID());
2776 } 2774 }
2777 2775
2778 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProperty) 2776 NullableCSSValue CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProper ty)
2779 { 2777 {
2780 CSSParserValue* value = m_valueList->current(); 2778 CSSParserValue* value = m_valueList->current();
2781 m_valueList->next(); 2779 m_valueList->next();
2782 2780
2783 if (value->id == CSSValueContain || value->id == CSSValueCover) 2781 if (value->id == CSSValueContain || value->id == CSSValueCover)
2784 return cssValuePool().createIdentifierValue(value->id); 2782 return cssValuePool().createIdentifierValue(value->id);
2785 2783
2786 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr; 2784 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr;
2787 2785
2788 if (value->id == CSSValueAuto) 2786 if (value->id == CSSValueAuto)
(...skipping 21 matching lines...) Expand all
2810 parsedValue2 = parsedValue1; 2808 parsedValue2 = parsedValue1;
2811 } 2809 }
2812 2810
2813 if (!parsedValue2) 2811 if (!parsedValue2)
2814 return parsedValue1; 2812 return parsedValue1;
2815 2813
2816 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues); 2814 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues);
2817 } 2815 }
2818 2816
2819 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, 2817 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2,
2820 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa lue2) 2818 NullableCSSValue& retValue1, NullableCSSValue& retValue2)
2821 { 2819 {
2822 // We initially store the first value in value/value2, and only create 2820 // We initially store the first value in value/value2, and only create
2823 // CSSValueLists if we have more values. 2821 // CSSValueLists if we have more values.
2824 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; 2822 RefPtrWillBeRawPtr<CSSValueList> values = nullptr;
2825 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; 2823 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr;
2826 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 2824 NullableCSSValue value;
2827 RefPtrWillBeRawPtr<CSSValue> value2 = nullptr; 2825 NullableCSSValue value2;
2828 2826
2829 retValue1 = retValue2 = nullptr; 2827 retValue1 = nullptr;
2828 retValue2 = nullptr;
2830 propId1 = resolveCSSPropertyID(propId); 2829 propId1 = resolveCSSPropertyID(propId);
2831 propId2 = propId1; 2830 propId2 = propId1;
2832 if (propId == CSSPropertyBackgroundPosition) { 2831 if (propId == CSSPropertyBackgroundPosition) {
2833 propId1 = CSSPropertyBackgroundPositionX; 2832 propId1 = CSSPropertyBackgroundPositionX;
2834 propId2 = CSSPropertyBackgroundPositionY; 2833 propId2 = CSSPropertyBackgroundPositionY;
2835 } else if (propId == CSSPropertyWebkitMaskPosition) { 2834 } else if (propId == CSSPropertyWebkitMaskPosition) {
2836 propId1 = CSSPropertyWebkitMaskPositionX; 2835 propId1 = CSSPropertyWebkitMaskPositionX;
2837 propId2 = CSSPropertyWebkitMaskPositionY; 2836 propId2 = CSSPropertyWebkitMaskPositionY;
2838 } else if (propId == CSSPropertyBackgroundRepeat) { 2837 } else if (propId == CSSPropertyBackgroundRepeat) {
2839 propId1 = CSSPropertyBackgroundRepeatX; 2838 propId1 = CSSPropertyBackgroundRepeatX;
2840 propId2 = CSSPropertyBackgroundRepeatY; 2839 propId2 = CSSPropertyBackgroundRepeatY;
2841 } else if (propId == CSSPropertyWebkitMaskRepeat) { 2840 } else if (propId == CSSPropertyWebkitMaskRepeat) {
2842 propId1 = CSSPropertyWebkitMaskRepeatX; 2841 propId1 = CSSPropertyWebkitMaskRepeatX;
2843 propId2 = CSSPropertyWebkitMaskRepeatY; 2842 propId2 = CSSPropertyWebkitMaskRepeatY;
2844 } 2843 }
2845 2844
2846 while (true) { 2845 while (true) {
2847 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; 2846 NullableCSSValue currValue;
2848 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; 2847 NullableCSSValue currValue2;
2849 2848
2850 Units unitless = FUnknown; 2849 Units unitless = FUnknown;
2851 CSSParserValue* val = m_valueList->current(); 2850 CSSParserValue* val = m_valueList->current();
2852 ASSERT(val); 2851 ASSERT(val);
2853 2852
2854 switch (propId) { 2853 switch (propId) {
2855 case CSSPropertyBackgroundColor: 2854 case CSSPropertyBackgroundColor:
2856 currValue = parseBackgroundColor(val); 2855 currValue = parseBackgroundColor(val);
2857 if (currValue) 2856 if (currValue)
2858 m_valueList->next(); 2857 m_valueList->next();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 break; 2953 break;
2955 } 2954 }
2956 default: 2955 default:
2957 break; 2956 break;
2958 } 2957 }
2959 if (!currValue) 2958 if (!currValue)
2960 return false; 2959 return false;
2961 2960
2962 if (value && !values) { 2961 if (value && !values) {
2963 values = CSSValueList::createCommaSeparated(); 2962 values = CSSValueList::createCommaSeparated();
2964 values->append(value.release()); 2963 values->append(*value);
2965 } 2964 }
2966 2965
2967 if (value2 && !values2) { 2966 if (value2 && !values2) {
2968 values2 = CSSValueList::createCommaSeparated(); 2967 values2 = CSSValueList::createCommaSeparated();
2969 values2->append(value2.release()); 2968 values2->append(*value2);
2970 } 2969 }
2971 2970
2972 if (values) 2971 if (values)
2973 values->append(currValue.release()); 2972 values->append(*currValue);
2974 else 2973 else
2975 value = currValue.release(); 2974 value = currValue;
2976 if (currValue2) { 2975 if (currValue2) {
2977 if (values2) 2976 if (values2)
2978 values2->append(currValue2.release()); 2977 values2->append(*currValue2);
2979 else 2978 else
2980 value2 = currValue2.release(); 2979 value2 = currValue2;
2981 } 2980 }
2982 2981
2983 // When parsing any fill shorthand property, we let it handle building u p the lists for all 2982 // When parsing any fill shorthand property, we let it handle building u p the lists for all
2984 // properties. 2983 // properties.
2985 if (inShorthand()) 2984 if (inShorthand())
2986 break; 2985 break;
2987 2986
2988 if (!m_valueList->current()) 2987 if (!m_valueList->current())
2989 break; 2988 break;
2990 if (!consumeComma(m_valueList) || !m_valueList->current()) 2989 if (!consumeComma(m_valueList) || !m_valueList->current())
2991 return false; 2990 return false;
2992 } 2991 }
2993 2992
2994 if (values) { 2993 if (values) {
2995 ASSERT(values->length()); 2994 ASSERT(values->length());
2996 retValue1 = values.release(); 2995 retValue1 = values.release();
2997 if (values2) { 2996 if (values2) {
2998 ASSERT(values2->length()); 2997 ASSERT(values2->length());
2999 retValue2 = values2.release(); 2998 retValue2 = values2.release();
3000 } 2999 }
3001 } else { 3000 } else {
3002 ASSERT(value); 3001 ASSERT(value);
3003 retValue1 = value.release(); 3002 retValue1 = value;
3004 retValue2 = value2.release(); 3003 retValue2 = value2;
3005 } 3004 }
3006 3005
3007 return true; 3006 return true;
3008 } 3007 }
3009 3008
3010 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() 3009 NullableCSSValue CSSPropertyParser::parseAnimationDelay()
3011 { 3010 {
3012 CSSParserValue* value = m_valueList->current(); 3011 CSSParserValue* value = m_valueList->current();
3013 if (validUnit(value, FTime)) 3012 if (validUnit(value, FTime))
3014 return createPrimitiveNumericValue(value); 3013 return createPrimitiveNumericValue(value);
3015 return nullptr; 3014 return nullptr;
3016 } 3015 }
3017 3016
3018 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() 3017 NullableCSSValue CSSPropertyParser::parseAnimationDirection()
3019 { 3018 {
3020 CSSParserValue* value = m_valueList->current(); 3019 CSSParserValue* value = m_valueList->current();
3021 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse) 3020 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse)
3022 return cssValuePool().createIdentifierValue(value->id); 3021 return cssValuePool().createIdentifierValue(value->id);
3023 return nullptr; 3022 return nullptr;
3024 } 3023 }
3025 3024
3026 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() 3025 NullableCSSValue CSSPropertyParser::parseAnimationDuration()
3027 { 3026 {
3028 CSSParserValue* value = m_valueList->current(); 3027 CSSParserValue* value = m_valueList->current();
3029 if (validUnit(value, FTime | FNonNeg)) 3028 if (validUnit(value, FTime | FNonNeg))
3030 return createPrimitiveNumericValue(value); 3029 return createPrimitiveNumericValue(value);
3031 return nullptr; 3030 return nullptr;
3032 } 3031 }
3033 3032
3034 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() 3033 NullableCSSValue CSSPropertyParser::parseAnimationFillMode()
3035 { 3034 {
3036 CSSParserValue* value = m_valueList->current(); 3035 CSSParserValue* value = m_valueList->current();
3037 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth) 3036 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth)
3038 return cssValuePool().createIdentifierValue(value->id); 3037 return cssValuePool().createIdentifierValue(value->id);
3039 return nullptr; 3038 return nullptr;
3040 } 3039 }
3041 3040
3042 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount () 3041 NullableCSSValue CSSPropertyParser::parseAnimationIterationCount()
3043 { 3042 {
3044 CSSParserValue* value = m_valueList->current(); 3043 CSSParserValue* value = m_valueList->current();
3045 if (value->id == CSSValueInfinite) 3044 if (value->id == CSSValueInfinite)
3046 return cssValuePool().createIdentifierValue(value->id); 3045 return cssValuePool().createIdentifierValue(value->id);
3047 if (validUnit(value, FNumber | FNonNeg)) 3046 if (validUnit(value, FNumber | FNonNeg))
3048 return createPrimitiveNumericValue(value); 3047 return createPrimitiveNumericValue(value);
3049 return nullptr; 3048 return nullptr;
3050 } 3049 }
3051 3050
3052 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo wQuotedName) 3051 NullableCSSValue CSSPropertyParser::parseAnimationName(bool allowQuotedName)
3053 { 3052 {
3054 CSSParserValue* value = m_valueList->current(); 3053 CSSParserValue* value = m_valueList->current();
3055 3054
3056 if (value->id == CSSValueNone) 3055 if (value->id == CSSValueNone)
3057 return cssValuePool().createIdentifierValue(CSSValueNone); 3056 return cssValuePool().createIdentifierValue(CSSValueNone);
3058 3057
3059 if (value->unit == CSSPrimitiveValue::CSS_IDENT) 3058 if (value->unit == CSSPrimitiveValue::CSS_IDENT)
3060 return createPrimitiveCustomIdentValue(value); 3059 return createPrimitiveCustomIdentValue(value);
3061 3060
3062 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) { 3061 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) {
3063 // Legacy support for strings in prefixed animations 3062 // Legacy support for strings in prefixed animations
3064 if (m_context.useCounter()) 3063 if (m_context.useCounter())
3065 m_context.useCounter()->count(UseCounter::QuotedAnimationName); 3064 m_context.useCounter()->count(UseCounter::QuotedAnimationName);
3066 if (equalIgnoringCase(value->string, "none")) 3065 if (equalIgnoringCase(value->string, "none"))
3067 return cssValuePool().createIdentifierValue(CSSValueNone); 3066 return cssValuePool().createIdentifierValue(CSSValueNone);
3068 return createPrimitiveCustomIdentValue(value); 3067 return createPrimitiveCustomIdentValue(value);
3069 } 3068 }
3070 3069
3071 return nullptr; 3070 return nullptr;
3072 } 3071 }
3073 3072
3074 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() 3073 NullableCSSValue CSSPropertyParser::parseAnimationPlayState()
3075 { 3074 {
3076 CSSParserValue* value = m_valueList->current(); 3075 CSSParserValue* value = m_valueList->current();
3077 if (value->id == CSSValueRunning || value->id == CSSValuePaused) 3076 if (value->id == CSSValueRunning || value->id == CSSValuePaused)
3078 return cssValuePool().createIdentifierValue(value->id); 3077 return cssValuePool().createIdentifierValue(value->id);
3079 return nullptr; 3078 return nullptr;
3080 } 3079 }
3081 3080
3082 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() 3081 NullableCSSValue CSSPropertyParser::parseAnimationProperty()
3083 { 3082 {
3084 CSSParserValue* value = m_valueList->current(); 3083 CSSParserValue* value = m_valueList->current();
3085 if (value->unit != CSSPrimitiveValue::CSS_IDENT) 3084 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
3086 return nullptr; 3085 return nullptr;
3087 // Since all is valid css property keyword, cssPropertyID for all 3086 // Since all is valid css property keyword, cssPropertyID for all
3088 // returns non-null value. We need to check "all" before 3087 // returns non-null value. We need to check "all" before
3089 // cssPropertyID check. 3088 // cssPropertyID check.
3090 if (value->id == CSSValueAll) 3089 if (value->id == CSSValueAll)
3091 return cssValuePool().createIdentifierValue(CSSValueAll); 3090 return cssValuePool().createIdentifierValue(CSSValueAll);
3092 CSSPropertyID property = unresolvedCSSPropertyID(value->string); 3091 CSSPropertyID property = unresolvedCSSPropertyID(value->string);
(...skipping 14 matching lines...) Expand all
3107 if (!validUnit(v, FNumber)) 3106 if (!validUnit(v, FNumber))
3108 return false; 3107 return false;
3109 result = v->fValue; 3108 result = v->fValue;
3110 v = args->next(); 3109 v = args->next();
3111 if (!v) 3110 if (!v)
3112 // The last number in the function has no comma after it, so we're done. 3111 // The last number in the function has no comma after it, so we're done.
3113 return true; 3112 return true;
3114 return consumeComma(args); 3113 return consumeComma(args);
3115 } 3114 }
3116 3115
3117 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction () 3116 NullableCSSValue CSSPropertyParser::parseAnimationTimingFunction()
3118 { 3117 {
3119 CSSParserValue* value = m_valueList->current(); 3118 CSSParserValue* value = m_valueList->current();
3120 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut 3119 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
3121 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd 3120 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd
3122 || value->id == CSSValueStepMiddle) 3121 || value->id == CSSValueStepMiddle)
3123 return cssValuePool().createIdentifierValue(value->id); 3122 return cssValuePool().createIdentifierValue(value->id);
3124 3123
3125 // We must be a function. 3124 // We must be a function.
3126 if (value->unit != CSSParserValue::Function) 3125 if (value->unit != CSSParserValue::Function)
3127 return nullptr; 3126 return nullptr;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 return nullptr; 3187 return nullptr;
3189 if (!parseCubicBezierTimingFunctionValue(args, y2)) 3188 if (!parseCubicBezierTimingFunctionValue(args, y2))
3190 return nullptr; 3189 return nullptr;
3191 3190
3192 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); 3191 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2);
3193 } 3192 }
3194 3193
3195 return nullptr; 3194 return nullptr;
3196 } 3195 }
3197 3196
3198 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPr opertyID propId, bool useLegacyParsing) 3197 NullableCSSValue CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId, bool useLegacyParsing)
3199 { 3198 {
3200 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 3199 NullableCSSValue value;
3201 switch (propId) { 3200 switch (propId) {
3202 case CSSPropertyAnimationDelay: 3201 case CSSPropertyAnimationDelay:
3203 case CSSPropertyTransitionDelay: 3202 case CSSPropertyTransitionDelay:
3204 value = parseAnimationDelay(); 3203 value = parseAnimationDelay();
3205 break; 3204 break;
3206 case CSSPropertyAnimationDirection: 3205 case CSSPropertyAnimationDirection:
3207 value = parseAnimationDirection(); 3206 value = parseAnimationDirection();
3208 break; 3207 break;
3209 case CSSPropertyAnimationDuration: 3208 case CSSPropertyAnimationDuration:
3210 case CSSPropertyTransitionDuration: 3209 case CSSPropertyTransitionDuration:
(...skipping 18 matching lines...) Expand all
3229 case CSSPropertyTransitionTimingFunction: 3228 case CSSPropertyTransitionTimingFunction:
3230 value = parseAnimationTimingFunction(); 3229 value = parseAnimationTimingFunction();
3231 break; 3230 break;
3232 default: 3231 default:
3233 ASSERT_NOT_REACHED(); 3232 ASSERT_NOT_REACHED();
3234 return nullptr; 3233 return nullptr;
3235 } 3234 }
3236 3235
3237 if (value) 3236 if (value)
3238 m_valueList->next(); 3237 m_valueList->next();
3239 return value.release(); 3238 return value;
3240 } 3239 }
3241 3240
3242 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi st(CSSPropertyID propId, bool useLegacyParsing) 3241 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi st(CSSPropertyID propId, bool useLegacyParsing)
3243 { 3242 {
3244 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 3243 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
3245 while (true) { 3244 while (true) {
3246 RefPtrWillBeRawPtr<CSSValue> value = parseAnimationProperty(propId, useL egacyParsing); 3245 NullableCSSValue value = parseAnimationProperty(propId, useLegacyParsing );
3247 if (!value) 3246 if (!value)
3248 return nullptr; 3247 return nullptr;
3249 list->append(value.release()); 3248 list->append(*value);
3250 if (!m_valueList->current()) 3249 if (!m_valueList->current())
3251 break; 3250 break;
3252 if (!consumeComma(m_valueList) || !m_valueList->current()) 3251 if (!consumeComma(m_valueList) || !m_valueList->current())
3253 return nullptr; 3252 return nullptr;
3254 } 3253 }
3255 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get())) 3254 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get()))
3256 return nullptr; 3255 return nullptr;
3257 ASSERT(list->length()); 3256 ASSERT(list->length());
3258 return list.release(); 3257 return list.release();
3259 } 3258 }
(...skipping 29 matching lines...) Expand all
3289 if (value && validUnit(value, FInteger) && value->fValue) { 3288 if (value && validUnit(value, FInteger) && value->fValue) {
3290 numericValue = createPrimitiveNumericValue(value); 3289 numericValue = createPrimitiveNumericValue(value);
3291 m_valueList->next(); 3290 m_valueList->next();
3292 } 3291 }
3293 return true; 3292 return true;
3294 } 3293 }
3295 3294
3296 return false; 3295 return false;
3297 } 3296 }
3298 3297
3299 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition() 3298 NullableCSSValue CSSPropertyParser::parseGridPosition()
3300 { 3299 {
3301 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3300 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3302 3301
3303 CSSParserValue* value = m_valueList->current(); 3302 CSSParserValue* value = m_valueList->current();
3304 if (value->id == CSSValueAuto) { 3303 if (value->id == CSSValueAuto) {
3305 m_valueList->next(); 3304 m_valueList->next();
3306 return cssValuePool().createIdentifierValue(CSSValueAuto); 3305 return cssValuePool().createIdentifierValue(CSSValueAuto);
3307 } 3306 }
3308 3307
3309 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr; 3308 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3345 if (hasSeenSpanKeyword) 3344 if (hasSeenSpanKeyword)
3346 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); 3345 values->append(cssValuePool().createIdentifierValue(CSSValueSpan));
3347 if (numericValue) 3346 if (numericValue)
3348 values->append(numericValue.release()); 3347 values->append(numericValue.release());
3349 if (gridLineName) 3348 if (gridLineName)
3350 values->append(gridLineName.release()); 3349 values->append(gridLineName.release());
3351 ASSERT(values->length()); 3350 ASSERT(values->length());
3352 return values.release(); 3351 return values.release();
3353 } 3352 }
3354 3353
3355 static PassRefPtrWillBeRawPtr<CSSValue> gridMissingGridPositionValue(CSSValue* v alue) 3354 static CSSValue gridMissingGridPositionValue(CSSValue value)
3356 { 3355 {
3357 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isCustomIdent() ) 3356 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isCustomIdent())
3358 return value; 3357 return value;
3359 3358
3360 return cssValuePool().createIdentifierValue(CSSValueAuto); 3359 return cssValuePool().createIdentifierValue(CSSValueAuto);
3361 } 3360 }
3362 3361
3363 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId , bool important) 3362 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId , bool important)
3364 { 3363 {
3365 ShorthandScope scope(this, shorthandId); 3364 ShorthandScope scope(this, shorthandId);
3366 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); 3365 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId);
3367 ASSERT(shorthand.length() == 2); 3366 ASSERT(shorthand.length() == 2);
3368 3367
3369 RefPtrWillBeRawPtr<CSSValue> startValue = parseGridPosition(); 3368 NullableCSSValue startValue = parseGridPosition();
3370 if (!startValue) 3369 if (!startValue)
3371 return false; 3370 return false;
3372 3371
3373 RefPtrWillBeRawPtr<CSSValue> endValue = nullptr; 3372 NullableCSSValue endValue;
3374 if (m_valueList->current()) { 3373 if (m_valueList->current()) {
3375 if (!isForwardSlashOperator(m_valueList->current())) 3374 if (!isForwardSlashOperator(m_valueList->current()))
3376 return false; 3375 return false;
3377 3376
3378 if (!m_valueList->next()) 3377 if (!m_valueList->next())
3379 return false; 3378 return false;
3380 3379
3381 endValue = parseGridPosition(); 3380 endValue = parseGridPosition();
3382 if (!endValue || m_valueList->current()) 3381 if (!endValue || m_valueList->current())
3383 return false; 3382 return false;
3384 } else { 3383 } else {
3385 endValue = gridMissingGridPositionValue(startValue.get()); 3384 endValue = gridMissingGridPositionValue(*startValue);
3386 } 3385 }
3387 3386
3388 addProperty(shorthand.properties()[0], startValue, important); 3387 addProperty(shorthand.properties()[0], *startValue, important);
3389 addProperty(shorthand.properties()[1], endValue, important); 3388 addProperty(shorthand.properties()[1], *endValue, important);
3390 return true; 3389 return true;
3391 } 3390 }
3392 3391
3393 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS Value> templateColumns, bool important) 3392 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(NullableCSSValue templateC olumns, bool important)
3394 { 3393 {
3395 NamedGridAreaMap gridAreaMap; 3394 NamedGridAreaMap gridAreaMap;
3396 size_t rowCount = 0; 3395 size_t rowCount = 0;
3397 size_t columnCount = 0; 3396 size_t columnCount = 0;
3398 bool trailingIdentWasAdded = false; 3397 bool trailingIdentWasAdded = false;
3399 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated(); 3398 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated();
3400 3399
3401 // At least template-areas strings must be defined. 3400 // At least template-areas strings must be defined.
3402 if (!m_valueList->current()) 3401 if (!m_valueList->current())
3403 return false; 3402 return false;
3404 3403
3405 while (m_valueList->current()) { 3404 while (m_valueList->current()) {
3406 // Handle leading <custom-ident>*. 3405 // Handle leading <custom-ident>*.
3407 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n ullptr)) 3406 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(NullableCSSValue(templateRows->item(templateRows->l ength() - 1))) : nullptr))
3408 return false; 3407 return false;
3409 3408
3410 // Handle a template-area's row. 3409 // Handle a template-area's row.
3411 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 3410 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
3412 return false; 3411 return false;
3413 ++rowCount; 3412 ++rowCount;
3414 3413
3415 // Handle template-rows's track-size. 3414 // Handle template-rows's track-size.
3416 if (m_valueList->current() && m_valueList->current()->unit != CSSPrimiti veValue::CSS_STRING) { 3415 if (m_valueList->current() && m_valueList->current()->unit != CSSPrimiti veValue::CSS_STRING) {
3417 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 3416 NullableCSSValue value = parseGridTrackSize(*m_valueList);
3418 if (!value) 3417 if (!value)
3419 return false; 3418 return false;
3420 templateRows->append(value); 3419 templateRows->append(*value);
3421 } else { 3420 } else {
3422 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); 3421 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to));
3423 } 3422 }
3424 3423
3425 // This will handle the trailing/leading <custom-ident>* in the grammar. 3424 // This will handle the trailing/leading <custom-ident>* in the grammar.
3426 if (!parseGridLineNames(*m_valueList, *templateRows)) 3425 if (!parseGridLineNames(*m_valueList, *templateRows))
3427 return false; 3426 return false;
3428 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)-> isGridLineNamesValue(); 3427 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1).i sGridLineNamesValue();
3429 } 3428 }
3430 3429
3431 // [<track-list> /]? 3430 // [<track-list> /]?
3432 if (templateColumns) 3431 if (templateColumns)
3433 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); 3432 addProperty(CSSPropertyGridTemplateColumns, *templateColumns, important) ;
3434 else 3433 else
3435 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important); 3434 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important);
3436 3435
3437 // [<line-names>? <string> [<track-size> <line-names>]? ]+ 3436 // [<line-names>? <string> [<track-size> <line-names>]? ]+
3438 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea te(gridAreaMap, rowCount, columnCount); 3437 CSSValue templateAreas = CSSGridTemplateAreasValue::create(gridAreaMap, rowC ount, columnCount);
3439 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important ); 3438 addProperty(CSSPropertyGridTemplateAreas, templateAreas, important);
3440 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); 3439 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
3441 3440
3442 return true; 3441 return true;
3443 } 3442 }
3444 3443
3445 3444
3446 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) 3445 bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
3447 { 3446 {
3448 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3447 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3449 3448
3450 ShorthandScope scope(this, CSSPropertyGridTemplate); 3449 ShorthandScope scope(this, CSSPropertyGridTemplate);
3451 ASSERT(gridTemplateShorthand().length() == 3); 3450 ASSERT(gridTemplateShorthand().length() == 3);
3452 3451
3453 // At least "none" must be defined. 3452 // At least "none" must be defined.
3454 if (!m_valueList->current()) 3453 if (!m_valueList->current())
3455 return false; 3454 return false;
3456 3455
3457 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; 3456 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone;
3458 3457
3459 // 1- 'none' case. 3458 // 1- 'none' case.
3460 if (firstValueIsNone && !m_valueList->next()) { 3459 if (firstValueIsNone && !m_valueList->next()) {
3461 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important); 3460 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important);
3462 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important); 3461 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important);
3463 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important); 3462 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important);
3464 return true; 3463 return true;
3465 } 3464 }
3466 3465
3467 unsigned index = 0; 3466 unsigned index = 0;
3468 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr; 3467 NullableCSSValue columnsValue;
3469 if (firstValueIsNone) { 3468 if (firstValueIsNone) {
3470 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); 3469 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone);
3471 } else { 3470 } else {
3472 columnsValue = parseGridTrackList(); 3471 columnsValue = parseGridTrackList();
3473 } 3472 }
3474 3473
3475 // 2- <grid-template-columns> / <grid-template-columns> syntax. 3474 // 2- <grid-template-columns> / <grid-template-columns> syntax.
3476 if (columnsValue) { 3475 if (columnsValue) {
3477 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next())) 3476 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next()))
3478 return false; 3477 return false;
3479 index = m_valueList->currentIndex(); 3478 index = m_valueList->currentIndex();
3480 if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) { 3479 if (NullableCSSValue rowsValue = parseGridTrackList()) {
3481 if (m_valueList->current()) 3480 if (m_valueList->current())
3482 return false; 3481 return false;
3483 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important) ; 3482 addProperty(CSSPropertyGridTemplateColumns, *columnsValue, important );
3484 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); 3483 addProperty(CSSPropertyGridTemplateRows, *rowsValue, important);
3485 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important); 3484 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important);
3486 return true; 3485 return true;
3487 } 3486 }
3488 } 3487 }
3489 3488
3490 3489
3491 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax. 3490 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
3492 // The template-columns <track-list> can't be 'none'. 3491 // The template-columns <track-list> can't be 'none'.
3493 if (firstValueIsNone) 3492 if (firstValueIsNone)
3494 return false; 3493 return false;
(...skipping 17 matching lines...) Expand all
3512 return true; 3511 return true;
3513 } 3512 }
3514 3513
3515 // Need to rewind parsing to explore the alternative syntax of this shorthan d. 3514 // Need to rewind parsing to explore the alternative syntax of this shorthan d.
3516 m_valueList->setCurrentIndex(0); 3515 m_valueList->setCurrentIndex(0);
3517 3516
3518 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] 3517 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ]
3519 if (!parseValue(CSSPropertyGridAutoFlow, important)) 3518 if (!parseValue(CSSPropertyGridAutoFlow, important))
3520 return false; 3519 return false;
3521 3520
3522 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = nullptr; 3521 NullableCSSValue autoColumnsValue;
3523 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr; 3522 NullableCSSValue autoRowsValue;
3524 3523
3525 if (m_valueList->current()) { 3524 if (m_valueList->current()) {
3526 autoColumnsValue = parseGridTrackSize(*m_valueList); 3525 autoColumnsValue = parseGridTrackSize(*m_valueList);
3527 if (!autoColumnsValue) 3526 if (!autoColumnsValue)
3528 return false; 3527 return false;
3529 if (m_valueList->current()) { 3528 if (m_valueList->current()) {
3530 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next()) 3529 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next())
3531 return false; 3530 return false;
3532 autoRowsValue = parseGridTrackSize(*m_valueList); 3531 autoRowsValue = parseGridTrackSize(*m_valueList);
3533 if (!autoRowsValue) 3532 if (!autoRowsValue)
3534 return false; 3533 return false;
3535 } 3534 }
3536 if (m_valueList->current()) 3535 if (m_valueList->current())
3537 return false; 3536 return false;
3538 } else { 3537 } else {
3539 // Other omitted values are set to their initial values. 3538 // Other omitted values are set to their initial values.
3540 autoColumnsValue = cssValuePool().createImplicitInitialValue(); 3539 autoColumnsValue = cssValuePool().createImplicitInitialValue();
3541 autoRowsValue = cssValuePool().createImplicitInitialValue(); 3540 autoRowsValue = cssValuePool().createImplicitInitialValue();
3542 } 3541 }
3543 3542
3544 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns. 3543 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns.
3545 if (!autoRowsValue) 3544 if (!autoRowsValue)
3546 autoRowsValue = autoColumnsValue; 3545 autoRowsValue = autoColumnsValue;
3547 3546
3548 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); 3547 addProperty(CSSPropertyGridAutoColumns, *autoColumnsValue, important);
3549 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); 3548 addProperty(CSSPropertyGridAutoRows, *autoRowsValue, important);
3550 3549
3551 // It can only be specified the explicit or the implicit grid properties in a single grid declaration. 3550 // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
3552 // The sub-properties not specified are set to their initial value, as norma l for shorthands. 3551 // The sub-properties not specified are set to their initial value, as norma l for shorthands.
3553 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important); 3552 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important);
3554 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important); 3553 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important);
3555 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important); 3554 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important);
3556 3555
3557 return true; 3556 return true;
3558 } 3557 }
3559 3558
3560 bool CSSPropertyParser::parseGridAreaShorthand(bool important) 3559 bool CSSPropertyParser::parseGridAreaShorthand(bool important)
3561 { 3560 {
3562 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3561 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3563 3562
3564 ShorthandScope scope(this, CSSPropertyGridArea); 3563 ShorthandScope scope(this, CSSPropertyGridArea);
3565 const StylePropertyShorthand& shorthand = gridAreaShorthand(); 3564 const StylePropertyShorthand& shorthand = gridAreaShorthand();
3566 ASSERT_UNUSED(shorthand, shorthand.length() == 4); 3565 ASSERT_UNUSED(shorthand, shorthand.length() == 4);
3567 3566
3568 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); 3567 NullableCSSValue rowStartValue = parseGridPosition();
3569 if (!rowStartValue) 3568 if (!rowStartValue)
3570 return false; 3569 return false;
3571 3570
3572 RefPtrWillBeRawPtr<CSSValue> columnStartValue = nullptr; 3571 NullableCSSValue columnStartValue;
3573 if (!parseSingleGridAreaLonghand(columnStartValue)) 3572 if (!parseSingleGridAreaLonghand(columnStartValue))
3574 return false; 3573 return false;
3575 3574
3576 RefPtrWillBeRawPtr<CSSValue> rowEndValue = nullptr; 3575 NullableCSSValue rowEndValue;
3577 if (!parseSingleGridAreaLonghand(rowEndValue)) 3576 if (!parseSingleGridAreaLonghand(rowEndValue))
3578 return false; 3577 return false;
3579 3578
3580 RefPtrWillBeRawPtr<CSSValue> columnEndValue = nullptr; 3579 NullableCSSValue columnEndValue;
3581 if (!parseSingleGridAreaLonghand(columnEndValue)) 3580 if (!parseSingleGridAreaLonghand(columnEndValue))
3582 return false; 3581 return false;
3583 3582
3584 if (!columnStartValue) 3583 if (!columnStartValue)
3585 columnStartValue = gridMissingGridPositionValue(rowStartValue.get()); 3584 columnStartValue = gridMissingGridPositionValue(*rowStartValue);
3586 3585
3587 if (!rowEndValue) 3586 if (!rowEndValue)
3588 rowEndValue = gridMissingGridPositionValue(rowStartValue.get()); 3587 rowEndValue = gridMissingGridPositionValue(*rowStartValue);
3589 3588
3590 if (!columnEndValue) 3589 if (!columnEndValue)
3591 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); 3590 columnEndValue = gridMissingGridPositionValue(*columnStartValue);
3592 3591
3593 addProperty(CSSPropertyGridRowStart, rowStartValue, important); 3592 addProperty(CSSPropertyGridRowStart, *rowStartValue, important);
3594 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); 3593 addProperty(CSSPropertyGridColumnStart, *columnStartValue, important);
3595 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); 3594 addProperty(CSSPropertyGridRowEnd, *rowEndValue, important);
3596 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); 3595 addProperty(CSSPropertyGridColumnEnd, *columnEndValue, important);
3597 return true; 3596 return true;
3598 } 3597 }
3599 3598
3600 bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtrWillBeRawPtr<CSSValue> & property) 3599 bool CSSPropertyParser::parseSingleGridAreaLonghand(NullableCSSValue& property)
3601 { 3600 {
3602 if (!m_valueList->current()) 3601 if (!m_valueList->current())
3603 return true; 3602 return true;
3604 3603
3605 if (!isForwardSlashOperator(m_valueList->current())) 3604 if (!isForwardSlashOperator(m_valueList->current()))
3606 return false; 3605 return false;
3607 3606
3608 if (!m_valueList->next()) 3607 if (!m_valueList->next())
3609 return false; 3608 return false;
3610 3609
3611 property = parseGridPosition(); 3610 property = parseGridPosition();
3612 return true; 3611 return true;
3613 } 3612 }
3614 3613
3615 static inline bool isClosingBracket(const CSSParserValue& value) 3614 static inline bool isClosingBracket(const CSSParserValue& value)
3616 { 3615 {
3617 return value.unit == CSSParserValue::Operator && value.iValue == ']'; 3616 return value.unit == CSSParserValue::Operator && value.iValue == ']';
3618 } 3617 }
3619 3618
3620 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames) 3619 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, NullableCSSValue previousNamedAreaTrailingLineNames)
3621 { 3620 {
3622 if (!inputList.current() || inputList.current()->unit != CSSParserValue::Ope rator || inputList.current()->iValue != '[') 3621 if (!inputList.current() || inputList.current()->unit != CSSParserValue::Ope rator || inputList.current()->iValue != '[')
3623 return true; 3622 return true;
3624 3623
3625 // Skip '[' 3624 // Skip '['
3626 inputList.next(); 3625 inputList.next();
3627 3626
3628 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = previousNamedAreaTrail ingLineNames; 3627 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = toCSSGridLineNamesValu e(previousNamedAreaTrailingLineNames);
3629 if (!lineNames) 3628 if (!lineNames)
3630 lineNames = CSSGridLineNamesValue::create(); 3629 lineNames = CSSGridLineNamesValue::create();
3631 3630
3632 while (CSSParserValue* identValue = inputList.current()) { 3631 while (CSSParserValue* identValue = inputList.current()) {
3633 if (isClosingBracket(*identValue)) 3632 if (isClosingBracket(*identValue))
3634 break; 3633 break;
3635 3634
3636 if (!isValidCustomIdentForGridPositions(*identValue)) 3635 if (!isValidCustomIdentForGridPositions(*identValue))
3637 return false; 3636 return false;
3638 3637
3639 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId entValue(identValue); 3638 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId entValue(identValue);
3640 lineNames->append(lineName.release()); 3639 lineNames->append(lineName.release());
3641 inputList.next(); 3640 inputList.next();
3642 } 3641 }
3643 3642
3644 if (!inputList.current() || !isClosingBracket(*inputList.current())) 3643 if (!inputList.current() || !isClosingBracket(*inputList.current()))
3645 return false; 3644 return false;
3646 3645
3647 if (!previousNamedAreaTrailingLineNames) 3646 if (!previousNamedAreaTrailingLineNames)
3648 valueList.append(lineNames.release()); 3647 valueList.append(lineNames.release());
3649 3648
3650 // Consume ']' 3649 // Consume ']'
3651 inputList.next(); 3650 inputList.next();
3652 return true; 3651 return true;
3653 } 3652 }
3654 3653
3655 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList() 3654 NullableCSSValue CSSPropertyParser::parseGridTrackList()
3656 { 3655 {
3657 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3656 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3658 3657
3659 CSSParserValue* value = m_valueList->current(); 3658 CSSParserValue* value = m_valueList->current();
3660 if (value->id == CSSValueNone) { 3659 if (value->id == CSSValueNone) {
3661 m_valueList->next(); 3660 m_valueList->next();
3662 return cssValuePool().createIdentifierValue(CSSValueNone); 3661 return cssValuePool().createIdentifierValue(CSSValueNone);
3663 } 3662 }
3664 3663
3665 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 3664 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
3666 // Handle leading <custom-ident>*. 3665 // Handle leading <custom-ident>*.
3667 if (!parseGridLineNames(*m_valueList, *values)) 3666 if (!parseGridLineNames(*m_valueList, *values))
3668 return nullptr; 3667 return nullptr;
3669 3668
3670 bool seenTrackSizeOrRepeatFunction = false; 3669 bool seenTrackSizeOrRepeatFunction = false;
3671 while (CSSParserValue* currentValue = m_valueList->current()) { 3670 while (CSSParserValue* currentValue = m_valueList->current()) {
3672 if (isForwardSlashOperator(currentValue)) 3671 if (isForwardSlashOperator(currentValue))
3673 break; 3672 break;
3674 if (currentValue->unit == CSSParserValue::Function && currentValue->func tion->id == CSSValueRepeat) { 3673 if (currentValue->unit == CSSParserValue::Function && currentValue->func tion->id == CSSValueRepeat) {
3675 if (!parseGridTrackRepeatFunction(*values)) 3674 if (!parseGridTrackRepeatFunction(*values))
3676 return nullptr; 3675 return nullptr;
3677 seenTrackSizeOrRepeatFunction = true; 3676 seenTrackSizeOrRepeatFunction = true;
3678 } else { 3677 } else {
3679 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 3678 NullableCSSValue value = parseGridTrackSize(*m_valueList);
3680 if (!value) 3679 if (!value)
3681 return nullptr; 3680 return nullptr;
3682 values->append(value); 3681 values->append(*value);
3683 seenTrackSizeOrRepeatFunction = true; 3682 seenTrackSizeOrRepeatFunction = true;
3684 } 3683 }
3685 // This will handle the trailing <custom-ident>* in the grammar. 3684 // This will handle the trailing <custom-ident>* in the grammar.
3686 if (!parseGridLineNames(*m_valueList, *values)) 3685 if (!parseGridLineNames(*m_valueList, *values))
3687 return nullptr; 3686 return nullptr;
3688 } 3687 }
3689 3688
3690 // We should have found a <track-size> or else it is not a valid <track-list > 3689 // We should have found a <track-size> or else it is not a valid <track-list >
3691 if (!seenTrackSizeOrRepeatFunction) 3690 if (!seenTrackSizeOrRepeatFunction)
3692 return nullptr; 3691 return nullptr;
(...skipping 13 matching lines...) Expand all
3706 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); 3705 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated();
3707 arguments->next(); // Skip the repetition count. 3706 arguments->next(); // Skip the repetition count.
3708 arguments->next(); // Skip the comma. 3707 arguments->next(); // Skip the comma.
3709 3708
3710 // Handle leading <custom-ident>*. 3709 // Handle leading <custom-ident>*.
3711 if (!parseGridLineNames(*arguments, *repeatedValues)) 3710 if (!parseGridLineNames(*arguments, *repeatedValues))
3712 return false; 3711 return false;
3713 3712
3714 size_t numberOfTracks = 0; 3713 size_t numberOfTracks = 0;
3715 while (arguments->current()) { 3714 while (arguments->current()) {
3716 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 3715 NullableCSSValue trackSize = parseGridTrackSize(*arguments);
3717 if (!trackSize) 3716 if (!trackSize)
3718 return false; 3717 return false;
3719 3718
3720 repeatedValues->append(trackSize); 3719 repeatedValues->append(*trackSize);
3721 ++numberOfTracks; 3720 ++numberOfTracks;
3722 3721
3723 // This takes care of any trailing <custom-ident>* in the grammar. 3722 // This takes care of any trailing <custom-ident>* in the grammar.
3724 if (!parseGridLineNames(*arguments, *repeatedValues)) 3723 if (!parseGridLineNames(*arguments, *repeatedValues))
3725 return false; 3724 return false;
3726 } 3725 }
3727 3726
3728 // We should have found at least one <track-size> or else it is not a valid <track-list>. 3727 // We should have found at least one <track-size> or else it is not a valid <track-list>.
3729 if (!numberOfTracks) 3728 if (!numberOfTracks)
3730 return false; 3729 return false;
3731 3730
3732 // We clamp the number of repetitions to a multiple of the repeat() track li st's size, while staying below the max 3731 // We clamp the number of repetitions to a multiple of the repeat() track li st's size, while staying below the max
3733 // grid size. 3732 // grid size.
3734 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); 3733 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks);
3735 3734
3736 for (size_t i = 0; i < repetitions; ++i) { 3735 for (size_t i = 0; i < repetitions; ++i) {
3737 for (size_t j = 0; j < repeatedValues->length(); ++j) 3736 for (size_t j = 0; j < repeatedValues->length(); ++j)
3738 list.append(repeatedValues->item(j)); 3737 list.append(repeatedValues->item(j));
3739 } 3738 }
3740 3739
3741 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. 3740 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue.
3742 m_valueList->next(); 3741 m_valueList->next();
3743 return true; 3742 return true;
3744 } 3743 }
3745 3744
3746 3745
3747 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParser ValueList& inputList) 3746 NullableCSSValue CSSPropertyParser::parseGridTrackSize(CSSParserValueList& input List)
3748 { 3747 {
3749 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3748 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3750 3749
3751 CSSParserValue* currentValue = inputList.current(); 3750 CSSParserValue* currentValue = inputList.current();
3752 inputList.next(); 3751 inputList.next();
3753 3752
3754 if (currentValue->id == CSSValueAuto) 3753 if (currentValue->id == CSSValueAuto)
3755 return cssValuePool().createIdentifierValue(CSSValueAuto); 3754 return cssValuePool().createIdentifierValue(CSSValueAuto);
3756 3755
3757 if (currentValue->unit == CSSParserValue::Function && currentValue->function ->id == CSSValueMinmax) { 3756 if (currentValue->unit == CSSParserValue::Function && currentValue->function ->id == CSSValueMinmax) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3891 3890
3892 ++gridCoordinate.rows.resolvedFinalPosition; 3891 ++gridCoordinate.rows.resolvedFinalPosition;
3893 } 3892 }
3894 currentCol = lookAheadCol; 3893 currentCol = lookAheadCol;
3895 } 3894 }
3896 3895
3897 m_valueList->next(); 3896 m_valueList->next();
3898 return true; 3897 return true;
3899 } 3898 }
3900 3899
3901 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() 3900 NullableCSSValue CSSPropertyParser::parseGridTemplateAreas()
3902 { 3901 {
3903 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { 3902 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) {
3904 m_valueList->next(); 3903 m_valueList->next();
3905 return cssValuePool().createIdentifierValue(CSSValueNone); 3904 return cssValuePool().createIdentifierValue(CSSValueNone);
3906 } 3905 }
3907 3906
3908 NamedGridAreaMap gridAreaMap; 3907 NamedGridAreaMap gridAreaMap;
3909 size_t rowCount = 0; 3908 size_t rowCount = 0;
3910 size_t columnCount = 0; 3909 size_t columnCount = 0;
3911 3910
3912 while (m_valueList->current()) { 3911 while (m_valueList->current()) {
3913 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 3912 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
3914 return nullptr; 3913 return nullptr;
3915 ++rowCount; 3914 ++rowCount;
3916 } 3915 }
3917 3916
3918 if (!rowCount || !columnCount) 3917 if (!rowCount || !columnCount)
3919 return nullptr; 3918 return nullptr;
3920 3919
3921 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ; 3920 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ;
3922 } 3921 }
3923 3922
3924 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV alueList& list) 3923 NullableCSSValue CSSPropertyParser::parseGridAutoFlow(CSSParserValueList& list)
3925 { 3924 {
3926 // [ row | column ] || dense 3925 // [ row | column ] || dense
3927 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3926 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3928 3927
3929 CSSParserValue* value = list.current(); 3928 CSSParserValue* value = list.current();
3930 if (!value) 3929 if (!value)
3931 return nullptr; 3930 return nullptr;
3932 3931
3933 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 3932 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated();
3934 3933
(...skipping 19 matching lines...) Expand all
3954 default: 3953 default:
3955 return parsedValues; 3954 return parsedValues;
3956 } 3955 }
3957 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); 3956 parsedValues->append(cssValuePool().createIdentifierValue(value->id));
3958 list.next(); 3957 list.next();
3959 } 3958 }
3960 3959
3961 return parsedValues; 3960 return parsedValues;
3962 } 3961 }
3963 3962
3964 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse rValueList* args, bool counters) 3963 NullableCSSValue CSSPropertyParser::parseCounterContent(CSSParserValueList* args , bool counters)
3965 { 3964 {
3966 unsigned numArgs = args->size(); 3965 unsigned numArgs = args->size();
3967 if (counters && numArgs != 3 && numArgs != 5) 3966 if (counters && numArgs != 3 && numArgs != 5)
3968 return nullptr; 3967 return nullptr;
3969 if (!counters && numArgs != 1 && numArgs != 3) 3968 if (!counters && numArgs != 1 && numArgs != 3)
3970 return nullptr; 3969 return nullptr;
3971 3970
3972 CSSParserValue* i = args->current(); 3971 CSSParserValue* i = args->current();
3973 if (i->unit != CSSPrimitiveValue::CSS_IDENT) 3972 if (i->unit != CSSPrimitiveValue::CSS_IDENT)
3974 return nullptr; 3973 return nullptr;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4232 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy ) 4231 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy )
4233 return false; 4232 return false;
4234 } else { 4233 } else {
4235 return false; 4234 return false;
4236 } 4235 }
4237 4236
4238 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt); 4237 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt);
4239 return !m_valueList->next(); 4238 return !m_valueList->next();
4240 } 4239 }
4241 4240
4242 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver flowPosition() 4241 NullableCSSValue CSSPropertyParser::parseContentDistributionOverflowPosition()
4243 { 4242 {
4244 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ] 4243 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ]
4245 // <baseline-position> = baseline | last-baseline; 4244 // <baseline-position> = baseline | last-baseline;
4246 // <content-distribution> = space-between | space-around | space-evenly | st retch; 4245 // <content-distribution> = space-between | space-around | space-evenly | st retch;
4247 // <content-position> = center | start | end | flex-start | flex-end | left | right; 4246 // <content-position> = center | start | end | flex-start | flex-end | left | right;
4248 // <overflow-position> = true | safe 4247 // <overflow-position> = true | safe
4249 4248
4250 // auto | <baseline-position> 4249 // auto | <baseline-position>
4251 CSSParserValue* value = m_valueList->current(); 4250 CSSParserValue* value = m_valueList->current();
4252 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { 4251 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4371 if (!args->currentIndex() && argument->id != CSSValueAt) { 4370 if (!args->currentIndex() && argument->id != CSSValueAt) {
4372 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius( argument)) { 4371 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius( argument)) {
4373 shape->setRadius(radius); 4372 shape->setRadius(radius);
4374 continue; 4373 continue;
4375 } 4374 }
4376 4375
4377 return nullptr; 4376 return nullptr;
4378 } 4377 }
4379 4378
4380 if (argument->id == CSSValueAt && args->next()) { 4379 if (argument->id == CSSValueAt && args->next()) {
4381 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4380 NullableCSSValue centerX;
4382 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4381 NullableCSSValue centerY;
4383 parseFillPosition(args, centerX, centerY); 4382 parseFillPosition(args, centerX, centerY);
4384 if (centerX && centerY && !args->current()) { 4383 if (centerX && centerY && !args->current()) {
4385 ASSERT(centerX->isPrimitiveValue()); 4384 ASSERT(centerX->isPrimitiveValue());
4386 ASSERT(centerY->isPrimitiveValue()); 4385 ASSERT(centerY->isPrimitiveValue());
4387 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); 4386 shape->setCenterX(toCSSPrimitiveValue(centerX));
4388 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); 4387 shape->setCenterY(toCSSPrimitiveValue(centerY));
4389 } else { 4388 } else {
4390 return nullptr; 4389 return nullptr;
4391 } 4390 }
4392 } else { 4391 } else {
4393 return nullptr; 4392 return nullptr;
4394 } 4393 }
4395 } 4394 }
4396 4395
4397 return shape; 4396 return shape;
4398 } 4397 }
(...skipping 24 matching lines...) Expand all
4423 else 4422 else
4424 shape->setRadiusY(radius); 4423 shape->setRadiusY(radius);
4425 continue; 4424 continue;
4426 } 4425 }
4427 4426
4428 return nullptr; 4427 return nullptr;
4429 } 4428 }
4430 4429
4431 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>) 4430 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>)
4432 return nullptr; 4431 return nullptr;
4433 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4432 NullableCSSValue centerX;
4434 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4433 NullableCSSValue centerY;
4435 parseFillPosition(args, centerX, centerY); 4434 parseFillPosition(args, centerX, centerY);
4436 if (!centerX || !centerY || args->current()) 4435 if (!centerX || !centerY || args->current())
4437 return nullptr; 4436 return nullptr;
4438 4437
4439 ASSERT(centerX->isPrimitiveValue()); 4438 ASSERT(centerX->isPrimitiveValue());
4440 ASSERT(centerY->isPrimitiveValue()); 4439 ASSERT(centerY->isPrimitiveValue());
4441 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); 4440 shape->setCenterX(toCSSPrimitiveValue(centerX));
4442 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); 4441 shape->setCenterY(toCSSPrimitiveValue(centerY));
4443 } 4442 }
4444 4443
4445 return shape; 4444 return shape;
4446 } 4445 }
4447 4446
4448 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args) 4447 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args)
4449 { 4448 {
4450 ASSERT(args); 4449 ASSERT(args);
4451 4450
4452 unsigned size = args->size(); 4451 unsigned size = args->size();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 case CSSValueBorderBox: 4499 case CSSValueBorderBox:
4501 case CSSValueMarginBox: 4500 case CSSValueMarginBox:
4502 return true; 4501 return true;
4503 default: 4502 default:
4504 break; 4503 break;
4505 } 4504 }
4506 4505
4507 return false; 4506 return false;
4508 } 4507 }
4509 4508
4510 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper tyID propId) 4509 NullableCSSValue CSSPropertyParser::parseShapeProperty(CSSPropertyID propId)
4511 { 4510 {
4512 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; 4511 NullableCSSValue imageValue;
4513 if (parseFillImage(m_valueList, imageValue)) { 4512 if (parseFillImage(m_valueList, imageValue)) {
4514 m_valueList->next(); 4513 m_valueList->next();
4515 return imageValue.release(); 4514 return imageValue;
4516 } 4515 }
4517 4516
4518 return parseBasicShapeAndOrBox(); 4517 return parseBasicShapeAndOrBox();
4519 } 4518 }
4520 4519
4521 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() 4520 NullableCSSValue CSSPropertyParser::parseBasicShapeAndOrBox()
4522 { 4521 {
4523 CSSParserValue* value = m_valueList->current(); 4522 CSSParserValue* value = m_valueList->current();
4524 4523
4525 bool shapeFound = false; 4524 bool shapeFound = false;
4526 bool boxFound = false; 4525 bool boxFound = false;
4527 CSSValueID valueId; 4526 CSSValueID valueId;
4528 4527
4529 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 4528 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
4530 for (unsigned i = 0; i < 2; ++i) { 4529 for (unsigned i = 0; i < 2; ++i) {
4531 if (!value) 4530 if (!value)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4643 return false; 4642 return false;
4644 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); 4643 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight();
4645 if (!lineHeight) 4644 if (!lineHeight)
4646 return false; 4645 return false;
4647 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); 4646 addProperty(CSSPropertyLineHeight, lineHeight.release(), important);
4648 } else { 4647 } else {
4649 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true); 4648 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true);
4650 } 4649 }
4651 4650
4652 // Font family must come now. 4651 // Font family must come now.
4653 RefPtrWillBeRawPtr<CSSValue> parsedFamilyValue = parseFontFamily(); 4652 NullableCSSValue parsedFamilyValue = parseFontFamily();
4654 if (!parsedFamilyValue) 4653 if (!parsedFamilyValue)
4655 return false; 4654 return false;
4656 4655
4657 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); 4656 addProperty(CSSPropertyFontFamily, *parsedFamilyValue, important);
4658 4657
4659 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir es that 4658 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir es that
4660 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values 4659 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values
4661 // but we don't seem to support them at the moment. They should also be adde d here once implemented. 4660 // but we don't seem to support them at the moment. They should also be adde d here once implemented.
4662 if (m_valueList->current()) 4661 if (m_valueList->current())
4663 return false; 4662 return false;
4664 4663
4665 return true; 4664 return true;
4666 } 4665 }
4667 4666
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
5336 5335
5337 if (context.allowBreak) { 5336 if (context.allowBreak) {
5338 context.commitValue(); 5337 context.commitValue();
5339 if (context.values && context.values->length()) 5338 if (context.values && context.values->length())
5340 return context.values.release(); 5339 return context.values.release();
5341 } 5340 }
5342 5341
5343 return nullptr; 5342 return nullptr;
5344 } 5343 }
5345 5344
5346 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() 5345 NullableCSSValue CSSPropertyParser::parseReflect()
5347 { 5346 {
5348 // box-reflect: <direction> <offset> <mask> 5347 // box-reflect: <direction> <offset> <mask>
5349 5348
5350 // Direction comes first. 5349 // Direction comes first.
5351 CSSParserValue* val = m_valueList->current(); 5350 CSSParserValue* val = m_valueList->current();
5352 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; 5351 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr;
5353 switch (val->id) { 5352 switch (val->id) {
5354 case CSSValueAbove: 5353 case CSSValueAbove:
5355 case CSSValueBelow: 5354 case CSSValueBelow:
5356 case CSSValueLeft: 5355 case CSSValueLeft:
5357 case CSSValueRight: 5356 case CSSValueRight:
5358 direction = cssValuePool().createIdentifierValue(val->id); 5357 direction = cssValuePool().createIdentifierValue(val->id);
5359 break; 5358 break;
5360 default: 5359 default:
5361 return nullptr; 5360 return nullptr;
5362 } 5361 }
5363 5362
5364 // The offset comes next. 5363 // The offset comes next.
5365 val = m_valueList->next(); 5364 val = m_valueList->next();
5366 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; 5365 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr;
5367 if (!val) 5366 if (!val)
5368 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); 5367 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
5369 else { 5368 else {
5370 if (!validUnit(val, FLength | FPercent)) 5369 if (!validUnit(val, FLength | FPercent))
5371 return nullptr; 5370 return nullptr;
5372 offset = createPrimitiveNumericValue(val); 5371 offset = createPrimitiveNumericValue(val);
5373 } 5372 }
5374 5373
5375 // Now for the mask. 5374 // Now for the mask.
5376 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; 5375 NullableCSSValue mask;
5377 val = m_valueList->next(); 5376 val = m_valueList->next();
5378 if (val) { 5377 if (val) {
5379 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); 5378 mask = parseBorderImage(CSSPropertyWebkitBoxReflect);
5380 if (!mask) 5379 if (!mask)
5381 return nullptr; 5380 return nullptr;
5382 } 5381 }
5383 5382
5384 return CSSReflectValue::create(direction.release(), offset.release(), mask.r elease()); 5383 return CSSReflectValue::create(direction.get(), offset.get(), mask);
5385 } 5384 }
5386 5385
5387 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse tValue, int argSize) 5386 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse tValue, int argSize)
5388 { 5387 {
5389 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; 5388 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3;
5390 } 5389 }
5391 5390
5392 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) 5391 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important)
5393 { 5392 {
5394 if (!args || !args->size() || args->size() > 3) 5393 if (!args || !args->size() || args->size() > 3)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5426 flexShrink = 1; 5425 flexShrink = 1;
5427 if (!flexBasis) 5426 if (!flexBasis)
5428 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT AGE); 5427 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT AGE);
5429 5428
5430 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f lexGrow), CSSPrimitiveValue::CSS_NUMBER), important); 5429 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f lexGrow), CSSPrimitiveValue::CSS_NUMBER), important);
5431 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float> (flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); 5430 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float> (flexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
5432 addProperty(CSSPropertyFlexBasis, flexBasis, important); 5431 addProperty(CSSPropertyFlexBasis, flexBasis, important);
5433 return true; 5432 return true;
5434 } 5433 }
5435 5434
5436 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue List* valueList) 5435 NullableCSSValue CSSPropertyParser::parsePosition(CSSParserValueList* valueList)
5437 { 5436 {
5438 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 5437 NullableCSSValue xValue;
5439 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 5438 NullableCSSValue yValue;
5440 parseFillPosition(valueList, xValue, yValue); 5439 parseFillPosition(valueList, xValue, yValue);
5440
5441 if (!xValue || !yValue) 5441 if (!xValue || !yValue)
5442 return nullptr; 5442 return nullptr;
5443 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim itiveValue(yValue.get()), Pair::KeepIdenticalValues); 5443 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue), toCSSPrimitiveV alue(yValue), Pair::KeepIdenticalValues);
5444 } 5444 }
5445 5445
5446 // Parses a list of comma separated positions. i.e., <position># 5446 // Parses a list of comma separated positions. i.e., <position>#
5447 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar serValueList* valueList) 5447 NullableCSSValue CSSPropertyParser::parsePositionList(CSSParserValueList* valueL ist)
5448 { 5448 {
5449 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted(); 5449 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted();
5450 while (true) { 5450 while (true) {
5451 // parsePosition consumes values until it reaches a separator [,/], 5451 // parsePosition consumes values until it reaches a separator [,/],
5452 // an invalid token, or end of the list 5452 // an invalid token, or end of the list
5453 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); 5453 NullableCSSValue position = parsePosition(valueList);
5454 if (!position) 5454 if (!position)
5455 return nullptr; 5455 return nullptr;
5456 positions->append(position); 5456 positions->append(*position);
5457 5457
5458 if (!valueList->current()) 5458 if (!valueList->current())
5459 break; 5459 break;
5460 if (!consumeComma(valueList) || !valueList->current()) 5460 if (!consumeComma(valueList) || !valueList->current())
5461 return nullptr; 5461 return nullptr;
5462 } 5462 }
5463 5463
5464 return positions.release(); 5464 return positions.release();
5465 } 5465 }
5466 5466
(...skipping 16 matching lines...) Expand all
5483 5483
5484 bool allowCommit() const { return m_allowCommit; } 5484 bool allowCommit() const { return m_allowCommit; }
5485 bool allowImage() const { return m_allowImage; } 5485 bool allowImage() const { return m_allowImage; }
5486 bool allowImageSlice() const { return m_allowImageSlice; } 5486 bool allowImageSlice() const { return m_allowImageSlice; }
5487 bool allowRepeat() const { return m_allowRepeat; } 5487 bool allowRepeat() const { return m_allowRepeat; }
5488 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; } 5488 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; }
5489 5489
5490 bool allowWidth() const { return m_allowWidth; } 5490 bool allowWidth() const { return m_allowWidth; }
5491 bool requireOutset() const { return m_requireOutset; } 5491 bool requireOutset() const { return m_requireOutset; }
5492 5492
5493 void commitImage(PassRefPtrWillBeRawPtr<CSSValue> image) 5493 void commitImage(CSSValue image)
5494 { 5494 {
5495 m_image = image; 5495 m_image = image;
5496 m_canAdvance = true; 5496 m_canAdvance = true;
5497 m_allowCommit = true; 5497 m_allowCommit = true;
5498 m_allowImage = false; 5498 m_allowImage = false;
5499 m_allowForwardSlashOperator = false; 5499 m_allowForwardSlashOperator = false;
5500 m_allowWidth = false; 5500 m_allowWidth = false;
5501 m_requireOutset = false; 5501 m_requireOutset = false;
5502 m_allowImageSlice = !m_imageSlice; 5502 m_allowImageSlice = !m_imageSlice;
5503 m_allowRepeat = !m_repeat; 5503 m_allowRepeat = !m_repeat;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5548 m_outset = outset; 5548 m_outset = outset;
5549 m_canAdvance = true; 5549 m_canAdvance = true;
5550 m_allowCommit = true; 5550 m_allowCommit = true;
5551 m_allowImageSlice = false; 5551 m_allowImageSlice = false;
5552 m_allowForwardSlashOperator = false; 5552 m_allowForwardSlashOperator = false;
5553 m_allowWidth = false; 5553 m_allowWidth = false;
5554 m_requireOutset = false; 5554 m_requireOutset = false;
5555 m_allowImage = !m_image; 5555 m_allowImage = !m_image;
5556 m_allowRepeat = !m_repeat; 5556 m_allowRepeat = !m_repeat;
5557 } 5557 }
5558 void commitRepeat(PassRefPtrWillBeRawPtr<CSSValue> repeat) 5558 void commitRepeat(CSSValue repeat)
5559 { 5559 {
5560 m_repeat = repeat; 5560 m_repeat = repeat;
5561 m_canAdvance = true; 5561 m_canAdvance = true;
5562 m_allowCommit = true; 5562 m_allowCommit = true;
5563 m_allowRepeat = false; 5563 m_allowRepeat = false;
5564 m_allowForwardSlashOperator = false; 5564 m_allowForwardSlashOperator = false;
5565 m_allowWidth = false; 5565 m_allowWidth = false;
5566 m_requireOutset = false; 5566 m_requireOutset = false;
5567 m_allowImageSlice = !m_imageSlice; 5567 m_allowImageSlice = !m_imageSlice;
5568 m_allowImage = !m_image; 5568 m_allowImage = !m_image;
5569 } 5569 }
5570 5570
5571 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() 5571 CSSValue commitCSSValue()
5572 { 5572 {
5573 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat.get()); 5573 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat);
5574 } 5574 }
5575 5575
5576 bool m_canAdvance; 5576 bool m_canAdvance;
5577 5577
5578 bool m_allowCommit; 5578 bool m_allowCommit;
5579 bool m_allowImage; 5579 bool m_allowImage;
5580 bool m_allowImageSlice; 5580 bool m_allowImageSlice;
5581 bool m_allowRepeat; 5581 bool m_allowRepeat;
5582 bool m_allowForwardSlashOperator; 5582 bool m_allowForwardSlashOperator;
5583 5583
5584 bool m_allowWidth; 5584 bool m_allowWidth;
5585 bool m_requireOutset; 5585 bool m_requireOutset;
5586 5586
5587 RefPtrWillBeMember<CSSValue> m_image; 5587 NullableCSSValue m_image;
5588 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; 5588 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice;
5589 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; 5589 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth;
5590 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; 5590 RefPtrWillBeMember<CSSPrimitiveValue> m_outset;
5591 5591
5592 RefPtrWillBeMember<CSSValue> m_repeat; 5592 NullableCSSValue m_repeat;
5593 }; 5593 };
5594 5594
5595 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context) 5595 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context)
5596 { 5596 {
5597 CSSPropertyParser::ShorthandScope scope(this, propId); 5597 CSSPropertyParser::ShorthandScope scope(this, propId);
5598 while (CSSParserValue* val = m_valueList->current()) { 5598 while (CSSParserValue* val = m_valueList->current()) {
5599 context.setCanAdvance(false); 5599 context.setCanAdvance(false);
5600 5600
5601 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val)) 5601 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val))
5602 context.commitForwardSlashOperator(); 5602 context.commitForwardSlashOperator();
5603 5603
5604 if (!context.canAdvance() && context.allowImage()) { 5604 if (!context.canAdvance() && context.allowImage()) {
5605 if (val->unit == CSSPrimitiveValue::CSS_URI) { 5605 if (val->unit == CSSPrimitiveValue::CSS_URI) {
5606 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string))); 5606 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string)));
5607 } else if (isGeneratedImageValue(val)) { 5607 } else if (isGeneratedImageValue(val)) {
5608 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 5608 NullableCSSValue value;
5609 if (parseGeneratedImage(m_valueList, value)) 5609 if (parseGeneratedImage(m_valueList, value))
5610 context.commitImage(value.release()); 5610 context.commitImage(*value);
5611 else 5611 else
5612 return false; 5612 return false;
5613 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) { 5613 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) {
5614 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); 5614 NullableCSSValue value = parseImageSet(m_valueList);
5615 if (value) 5615 if (value)
5616 context.commitImage(value.release()); 5616 context.commitImage(*value);
5617 else 5617 else
5618 return false; 5618 return false;
5619 } else if (val->id == CSSValueNone) 5619 } else if (val->id == CSSValueNone)
5620 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone)); 5620 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone));
5621 } 5621 }
5622 5622
5623 if (!context.canAdvance() && context.allowImageSlice()) { 5623 if (!context.canAdvance() && context.allowImageSlice()) {
5624 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; 5624 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr;
5625 if (parseBorderImageSlice(propId, imageSlice)) 5625 if (parseBorderImageSlice(propId, imageSlice))
5626 context.commitImageSlice(imageSlice.release()); 5626 context.commitImageSlice(imageSlice.release());
5627 } 5627 }
5628 5628
5629 if (!context.canAdvance() && context.allowRepeat()) { 5629 if (!context.canAdvance() && context.allowRepeat()) {
5630 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; 5630 NullableCSSValue repeat;
5631 if (parseBorderImageRepeat(repeat)) 5631 if (parseBorderImageRepeat(repeat))
5632 context.commitRepeat(repeat.release()); 5632 context.commitRepeat(*repeat);
5633 } 5633 }
5634 5634
5635 if (!context.canAdvance() && context.allowWidth()) { 5635 if (!context.canAdvance() && context.allowWidth()) {
5636 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; 5636 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr;
5637 if (parseBorderImageWidth(borderWidth)) 5637 if (parseBorderImageWidth(borderWidth))
5638 context.commitBorderWidth(borderWidth.release()); 5638 context.commitBorderWidth(borderWidth.release());
5639 } 5639 }
5640 5640
5641 if (!context.canAdvance() && context.requireOutset()) { 5641 if (!context.canAdvance() && context.requireOutset()) {
5642 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; 5642 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr;
5643 if (parseBorderImageOutset(borderOutset)) 5643 if (parseBorderImageOutset(borderOutset))
5644 context.commitBorderOutset(borderOutset.release()); 5644 context.commitBorderOutset(borderOutset.release());
5645 } 5645 }
5646 5646
5647 if (!context.canAdvance()) 5647 if (!context.canAdvance())
5648 return false; 5648 return false;
5649 5649
5650 m_valueList->next(); 5650 m_valueList->next();
5651 } 5651 }
5652 5652
5653 return context.allowCommit(); 5653 return context.allowCommit();
5654 } 5654 }
5655 5655
5656 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) 5656 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, Nullable CSSValue value, bool important)
5657 { 5657 {
5658 if (value) 5658 if (value)
5659 addProperty(propId, value, important); 5659 addProperty(propId, *value, important);
5660 else 5660 else
5661 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true); 5661 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true);
5662 } 5662 }
5663 5663
5664 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant) 5664 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant)
5665 { 5665 {
5666 BorderImageParseContext context; 5666 BorderImageParseContext context;
5667 if (buildBorderImageParseContext(propId, context)) { 5667 if (buildBorderImageParseContext(propId, context)) {
5668 switch (propId) { 5668 switch (propId) {
5669 case CSSPropertyWebkitMaskBoxImage: 5669 case CSSPropertyWebkitMaskBoxImage:
5670 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important); 5670 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important);
5671 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important); 5671 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important);
5672 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important); 5672 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important);
5673 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important); 5673 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important);
5674 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat.get(), important); 5674 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat, important);
5675 return true; 5675 return true;
5676 case CSSPropertyBorderImage: 5676 case CSSPropertyBorderImage:
5677 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important); 5677 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important);
5678 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important); 5678 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important);
5679 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important); 5679 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important);
5680 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important); 5680 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important);
5681 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important); 5681 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important);
5682 return true; 5682 return true;
5683 default: 5683 default:
5684 ASSERT_NOT_REACHED(); 5684 ASSERT_NOT_REACHED();
5685 return false; 5685 return false;
5686 } 5686 }
5687 } 5687 }
5688 return false; 5688 return false;
5689 } 5689 }
5690 5690
5691 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty ID propId) 5691 NullableCSSValue CSSPropertyParser::parseBorderImage(CSSPropertyID propId)
5692 { 5692 {
5693 BorderImageParseContext context; 5693 BorderImageParseContext context;
5694 if (buildBorderImageParseContext(propId, context)) { 5694 if (buildBorderImageParseContext(propId, context)) {
5695 return context.commitCSSValue(); 5695 return context.commitCSSValue();
5696 } 5696 }
5697 return nullptr; 5697 return nullptr;
5698 } 5698 }
5699 5699
5700 static bool isBorderImageRepeatKeyword(int id) 5700 static bool isBorderImageRepeatKeyword(int id)
5701 { 5701 {
5702 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound; 5702 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound;
5703 } 5703 }
5704 5704
5705 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res ult) 5705 bool CSSPropertyParser::parseBorderImageRepeat(NullableCSSValue& result)
5706 { 5706 {
5707 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; 5707 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr;
5708 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; 5708 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr;
5709 CSSParserValue* val = m_valueList->current(); 5709 CSSParserValue* val = m_valueList->current();
5710 if (!val) 5710 if (!val)
5711 return false; 5711 return false;
5712 if (isBorderImageRepeatKeyword(val->id)) 5712 if (isBorderImageRepeatKeyword(val->id))
5713 firstValue = cssValuePool().createIdentifierValue(val->id); 5713 firstValue = cssValuePool().createIdentifierValue(val->id);
5714 else 5714 else
5715 return false; 5715 return false;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 completeBorderRadii(radii[1]); 6004 completeBorderRadii(radii[1]);
6005 6005
6006 ImplicitScope implicitScope(this); 6006 ImplicitScope implicitScope(this);
6007 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important); 6007 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important);
6008 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important); 6008 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important);
6009 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important); 6009 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important);
6010 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important); 6010 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important);
6011 return true; 6011 return true;
6012 } 6012 }
6013 6013
6014 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu e) 6014 NullableCSSValue CSSPropertyParser::parseCounter(int defaultValue)
6015 { 6015 {
6016 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 6016 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
6017 6017
6018 while (m_valueList->current()) { 6018 while (m_valueList->current()) {
6019 CSSParserValue* val = m_valueList->current(); 6019 CSSParserValue* val = m_valueList->current();
6020 if (val->unit != CSSPrimitiveValue::CSS_IDENT) 6020 if (val->unit != CSSPrimitiveValue::CSS_IDENT)
6021 return nullptr; 6021 return nullptr;
6022 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val); 6022 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val);
6023 m_valueList->next(); 6023 m_valueList->next();
6024 6024
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 return false; 6104 return false;
6105 6105
6106 stop.m_color = parseDeprecatedGradientStopColor(args->current()); 6106 stop.m_color = parseDeprecatedGradientStopColor(args->current());
6107 if (!stop.m_color) 6107 if (!stop.m_color)
6108 return false; 6108 return false;
6109 } 6109 }
6110 6110
6111 return true; 6111 return true;
6112 } 6112 }
6113 6113
6114 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R efPtrWillBeRawPtr<CSSValue>& gradient) 6114 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, N ullableCSSValue& gradient)
6115 { 6115 {
6116 // Walk the arguments. 6116 // Walk the arguments.
6117 CSSParserValueList* args = valueList->current()->function->args.get(); 6117 CSSParserValueList* args = valueList->current()->function->args.get();
6118 if (!args || args->size() == 0) 6118 if (!args || args->size() == 0)
6119 return false; 6119 return false;
6120 6120
6121 // The first argument is the gradient type. It is an identifier. 6121 // The first argument is the gradient type. It is an identifier.
6122 CSSGradientType gradientType; 6122 CSSGradientType gradientType;
6123 CSSParserValue* a = args->current(); 6123 CSSParserValue* a = args->current();
6124 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) 6124 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6257 case CSSValueTop: 6257 case CSSValueTop:
6258 case CSSValueBottom: 6258 case CSSValueBottom:
6259 isHorizontal = false; 6259 isHorizontal = false;
6260 break; 6260 break;
6261 default: 6261 default:
6262 return nullptr; 6262 return nullptr;
6263 } 6263 }
6264 return cssValuePool().createIdentifierValue(a->id); 6264 return cssValuePool().createIdentifierValue(a->id);
6265 } 6265 }
6266 6266
6267 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6267 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, NullableCSSValue& gradient, CSSGradientRepeat repeating)
6268 { 6268 {
6269 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient); 6269 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient);
6270 6270
6271 // Walk the arguments. 6271 // Walk the arguments.
6272 CSSParserValueList* args = valueList->current()->function->args.get(); 6272 CSSParserValueList* args = valueList->current()->function->args.get();
6273 if (!args || !args->size()) 6273 if (!args || !args->size())
6274 return false; 6274 return false;
6275 6275
6276 CSSParserValue* a = args->current(); 6276 CSSParserValue* a = args->current();
6277 if (!a) 6277 if (!a)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6327 if (!parseGradientColorStops(args, result.get(), expectComma)) 6327 if (!parseGradientColorStops(args, result.get(), expectComma))
6328 return false; 6328 return false;
6329 6329
6330 if (!result->stopCount()) 6330 if (!result->stopCount())
6331 return false; 6331 return false;
6332 6332
6333 gradient = result.release(); 6333 gradient = result.release();
6334 return true; 6334 return true;
6335 } 6335 }
6336 6336
6337 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6337 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL ist, NullableCSSValue& gradient, CSSGradientRepeat repeating)
6338 { 6338 {
6339 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSPrefixedRadialGradient); 6339 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSPrefixedRadialGradient);
6340 6340
6341 // Walk the arguments. 6341 // Walk the arguments.
6342 CSSParserValueList* args = valueList->current()->function->args.get(); 6342 CSSParserValueList* args = valueList->current()->function->args.get();
6343 if (!args || !args->size()) 6343 if (!args || !args->size())
6344 return false; 6344 return false;
6345 6345
6346 CSSParserValue* a = args->current(); 6346 CSSParserValue* a = args->current();
6347 if (!a) 6347 if (!a)
6348 return false; 6348 return false;
6349 6349
6350 bool expectComma = false; 6350 bool expectComma = false;
6351 6351
6352 // Optional background-position 6352 // Optional background-position
6353 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 6353 NullableCSSValue centerX;
6354 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 6354 NullableCSSValue centerY;
6355 // parse2ValuesFillPosition advances the args next pointer. 6355 // parse2ValuesFillPosition advances the args next pointer.
6356 parse2ValuesFillPosition(args, centerX, centerY); 6356 parse2ValuesFillPosition(args, centerX, centerY);
6357 6357
6358 if ((centerX || centerY) && !consumeComma(args)) 6358 if ((centerX || centerY) && !consumeComma(args))
6359 return false; 6359 return false;
6360 6360
6361 a = args->current(); 6361 a = args->current();
6362 if (!a) 6362 if (!a)
6363 return false; 6363 return false;
6364 6364
6365 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6365 result->setFirstX(toCSSPrimitiveValue(centerX));
6366 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6366 result->setSecondX(toCSSPrimitiveValue(centerX));
6367 // CSS3 radial gradients always share the same start and end point. 6367 // CSS3 radial gradients always share the same start and end point.
6368 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6368 result->setFirstY(toCSSPrimitiveValue(centerY));
6369 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6369 result->setSecondY(toCSSPrimitiveValue(centerY));
6370 6370
6371 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; 6371 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr;
6372 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; 6372 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr;
6373 6373
6374 // Optional shape and/or size in any order. 6374 // Optional shape and/or size in any order.
6375 for (int i = 0; i < 2; ++i) { 6375 for (int i = 0; i < 2; ++i) {
6376 if (a->unit != CSSPrimitiveValue::CSS_IDENT) 6376 if (a->unit != CSSPrimitiveValue::CSS_IDENT)
6377 break; 6377 break;
6378 6378
6379 bool foundValue = false; 6379 bool foundValue = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6439 result->setEndHorizontalSize(horizontalSize); 6439 result->setEndHorizontalSize(horizontalSize);
6440 result->setEndVerticalSize(verticalSize); 6440 result->setEndVerticalSize(verticalSize);
6441 6441
6442 if (!parseGradientColorStops(args, result.get(), expectComma)) 6442 if (!parseGradientColorStops(args, result.get(), expectComma))
6443 return false; 6443 return false;
6444 6444
6445 gradient = result.release(); 6445 gradient = result.release();
6446 return true; 6446 return true;
6447 } 6447 }
6448 6448
6449 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6449 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, Nulla bleCSSValue& gradient, CSSGradientRepeat repeating)
6450 { 6450 {
6451 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSLinearGradient); 6451 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSLinearGradient);
6452 6452
6453 CSSParserFunction* function = valueList->current()->function; 6453 CSSParserFunction* function = valueList->current()->function;
6454 CSSParserValueList* args = function->args.get(); 6454 CSSParserValueList* args = function->args.get();
6455 if (!args || !args->size()) 6455 if (!args || !args->size())
6456 return false; 6456 return false;
6457 6457
6458 CSSParserValue* a = args->current(); 6458 CSSParserValue* a = args->current();
6459 if (!a) 6459 if (!a)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6513 if (!parseGradientColorStops(args, result.get(), expectComma)) 6513 if (!parseGradientColorStops(args, result.get(), expectComma))
6514 return false; 6514 return false;
6515 6515
6516 if (!result->stopCount()) 6516 if (!result->stopCount())
6517 return false; 6517 return false;
6518 6518
6519 gradient = result.release(); 6519 gradient = result.release();
6520 return true; 6520 return true;
6521 } 6521 }
6522 6522
6523 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6523 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, Nulla bleCSSValue& gradient, CSSGradientRepeat repeating)
6524 { 6524 {
6525 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSRadialGradient); 6525 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSRadialGradient);
6526 6526
6527 CSSParserValueList* args = valueList->current()->function->args.get(); 6527 CSSParserValueList* args = valueList->current()->function->args.get();
6528 if (!args || !args->size()) 6528 if (!args || !args->size())
6529 return false; 6529 return false;
6530 6530
6531 CSSParserValue* a = args->current(); 6531 CSSParserValue* a = args->current();
6532 if (!a) 6532 if (!a)
6533 return false; 6533 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
6605 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) 6605 if (!verticalSize && horizontalSize && horizontalSize->isPercentage())
6606 return false; 6606 return false;
6607 6607
6608 result->setShape(shapeValue); 6608 result->setShape(shapeValue);
6609 result->setSizingBehavior(sizeValue); 6609 result->setSizingBehavior(sizeValue);
6610 result->setEndHorizontalSize(horizontalSize); 6610 result->setEndHorizontalSize(horizontalSize);
6611 result->setEndVerticalSize(verticalSize); 6611 result->setEndVerticalSize(verticalSize);
6612 6612
6613 // Second part of grammar, the center-position clause: 6613 // Second part of grammar, the center-position clause:
6614 // at <position> 6614 // at <position>
6615 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 6615 NullableCSSValue centerX;
6616 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 6616 NullableCSSValue centerY;
6617 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) { 6617 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) {
6618 a = args->next(); 6618 a = args->next();
6619 if (!a) 6619 if (!a)
6620 return false; 6620 return false;
6621 6621
6622 parseFillPosition(args, centerX, centerY); 6622 parseFillPosition(args, centerX, centerY);
6623 if (!(centerX && centerY)) 6623 if (!(centerX && centerY))
6624 return false; 6624 return false;
6625 6625
6626 a = args->current(); 6626 a = args->current();
6627 if (!a) 6627 if (!a)
6628 return false; 6628 return false;
6629 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6629 result->setFirstX(toCSSPrimitiveValue(centerX));
6630 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6630 result->setFirstY(toCSSPrimitiveValue(centerY));
6631 // Right now, CSS radial gradients have the same start and end centers. 6631 // Right now, CSS radial gradients have the same start and end centers.
6632 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6632 result->setSecondX(toCSSPrimitiveValue(centerX));
6633 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6633 result->setSecondY(toCSSPrimitiveValue(centerY));
6634 } 6634 }
6635 6635
6636 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) 6636 if (shapeValue || sizeValue || horizontalSize || centerX || centerY)
6637 expectComma = true; 6637 expectComma = true;
6638 6638
6639 if (!parseGradientColorStops(args, result.get(), expectComma)) 6639 if (!parseGradientColorStops(args, result.get(), expectComma))
6640 return false; 6640 return false;
6641 6641
6642 gradient = result.release(); 6642 gradient = result.release();
6643 return true; 6643 return true;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6693 } 6693 }
6694 6694
6695 // The last color stop cannot be a color hint. 6695 // The last color stop cannot be a color hint.
6696 if (previousStopWasColorHint) 6696 if (previousStopWasColorHint)
6697 return false; 6697 return false;
6698 6698
6699 // Must have 2 or more stops to be valid. 6699 // Must have 2 or more stops to be valid.
6700 return gradient->stopCount() >= 2; 6700 return gradient->stopCount() >= 2;
6701 } 6701 }
6702 6702
6703 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& value) 6703 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, Nulla bleCSSValue& value)
6704 { 6704 {
6705 CSSParserValue* val = valueList->current(); 6705 CSSParserValue* val = valueList->current();
6706 6706
6707 if (val->unit != CSSParserValue::Function) 6707 if (val->unit != CSSParserValue::Function)
6708 return false; 6708 return false;
6709 6709
6710 if (val->function->id == CSSValueWebkitGradient) { 6710 if (val->function->id == CSSValueWebkitGradient) {
6711 // FIXME: This should send a deprecation message. 6711 // FIXME: This should send a deprecation message.
6712 if (m_context.useCounter()) 6712 if (m_context.useCounter())
6713 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); 6713 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6755 6755
6756 if (val->function->id == CSSValueWebkitCanvas) 6756 if (val->function->id == CSSValueWebkitCanvas)
6757 return parseCanvas(valueList, value); 6757 return parseCanvas(valueList, value);
6758 6758
6759 if (val->function->id == CSSValueWebkitCrossFade) 6759 if (val->function->id == CSSValueWebkitCrossFade)
6760 return parseCrossfade(valueList, value); 6760 return parseCrossfade(valueList, value);
6761 6761
6762 return false; 6762 return false;
6763 } 6763 }
6764 6764
6765 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& crossfade) 6765 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, NullableCS SValue& crossfade)
6766 { 6766 {
6767 // Walk the arguments. 6767 // Walk the arguments.
6768 CSSParserValueList* args = valueList->current()->function->args.get(); 6768 CSSParserValueList* args = valueList->current()->function->args.get();
6769 if (!args || args->size() != 5) 6769 if (!args || args->size() != 5)
6770 return false; 6770 return false;
6771 RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr; 6771 NullableCSSValue fromImageValue;
6772 RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr; 6772 NullableCSSValue toImageValue;
6773 6773
6774 // The first argument is the "from" image. It is a fill image. 6774 // The first argument is the "from" image. It is a fill image.
6775 if (!args->current() || !parseFillImage(args, fromImageValue)) 6775 if (!args->current() || !parseFillImage(args, fromImageValue))
6776 return false; 6776 return false;
6777 args->next(); 6777 args->next();
6778 6778
6779 if (!consumeComma(args)) 6779 if (!consumeComma(args))
6780 return false; 6780 return false;
6781 6781
6782 // The second argument is the "to" image. It is a fill image. 6782 // The second argument is the "to" image. It is a fill image.
(...skipping 10 matching lines...) Expand all
6793 if (!value) 6793 if (!value)
6794 return false; 6794 return false;
6795 6795
6796 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE) 6796 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
6797 percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER); 6797 percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
6798 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) 6798 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
6799 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0 , 1), CSSPrimitiveValue::CSS_NUMBER); 6799 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0 , 1), CSSPrimitiveValue::CSS_NUMBER);
6800 else 6800 else
6801 return false; 6801 return false;
6802 6802
6803 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fro mImageValue, toImageValue); 6803 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(*fr omImageValue, *toImageValue);
6804 result->setPercentage(percentage); 6804 result->setPercentage(percentage);
6805 6805
6806 crossfade = result; 6806 crossfade = result;
6807 6807
6808 return true; 6808 return true;
6809 } 6809 }
6810 6810
6811 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, RefPtrWillBeR awPtr<CSSValue>& canvas) 6811 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, NullableCSSVa lue& canvas)
6812 { 6812 {
6813 // Walk the arguments. 6813 // Walk the arguments.
6814 CSSParserValueList* args = valueList->current()->function->args.get(); 6814 CSSParserValueList* args = valueList->current()->function->args.get();
6815 if (!args || args->size() != 1) 6815 if (!args || args->size() != 1)
6816 return false; 6816 return false;
6817 6817
6818 // The first argument is the canvas name. It is an identifier. 6818 // The first argument is the canvas name. It is an identifier.
6819 CSSParserValue* value = args->current(); 6819 CSSParserValue* value = args->current();
6820 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) 6820 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT)
6821 return false; 6821 return false;
6822 6822
6823 canvas = CSSCanvasValue::create(value->string); 6823 canvas = CSSCanvasValue::create(value->string);
6824 return true; 6824 return true;
6825 } 6825 }
6826 6826
6827 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue List* valueList) 6827 NullableCSSValue CSSPropertyParser::parseImageSet(CSSParserValueList* valueList)
6828 { 6828 {
6829 CSSParserValue* function = valueList->current(); 6829 CSSParserValue* function = valueList->current();
6830 6830
6831 if (function->unit != CSSParserValue::Function) 6831 if (function->unit != CSSParserValue::Function)
6832 return nullptr; 6832 return nullptr;
6833 6833
6834 CSSParserValueList* functionArgs = valueList->current()->function->args.get( ); 6834 CSSParserValueList* functionArgs = valueList->current()->function->args.get( );
6835 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) 6835 if (!functionArgs || !functionArgs->size() || !functionArgs->current())
6836 return nullptr; 6836 return nullptr;
6837 6837
6838 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); 6838 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
6839 6839
6840 while (functionArgs->current()) { 6840 while (functionArgs->current()) {
6841 CSSParserValue* arg = functionArgs->current(); 6841 CSSParserValue* arg = functionArgs->current();
6842 if (arg->unit != CSSPrimitiveValue::CSS_URI) 6842 if (arg->unit != CSSPrimitiveValue::CSS_URI)
6843 return nullptr; 6843 return nullptr;
6844 6844
6845 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg ->string, completeURL(arg->string)); 6845 CSSValue image = createCSSImageValueWithReferrer(arg->string, completeUR L(arg->string));
6846 imageSet->append(image); 6846 imageSet->append(image);
6847 6847
6848 arg = functionArgs->next(); 6848 arg = functionArgs->next();
6849 if (!arg) 6849 if (!arg)
6850 return nullptr; 6850 return nullptr;
6851 6851
6852 if (arg->unit != CSSParserValue::DimensionList) 6852 if (arg->unit != CSSParserValue::DimensionList)
6853 return nullptr; 6853 return nullptr;
6854 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER ); 6854 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER );
6855 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT) ; 6855 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT) ;
(...skipping 10 matching lines...) Expand all
6866 break; 6866 break;
6867 6867
6868 // If there are more arguments, they should be after a comma. 6868 // If there are more arguments, they should be after a comma.
6869 if (!consumeComma(functionArgs)) 6869 if (!consumeComma(functionArgs))
6870 return nullptr; 6870 return nullptr;
6871 } 6871 }
6872 6872
6873 return imageSet.release(); 6873 return imageSet.release();
6874 } 6874 }
6875 6875
6876 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange() 6876 NullableCSSValue CSSPropertyParser::parseWillChange()
6877 { 6877 {
6878 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 6878 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
6879 if (m_valueList->current()->id == CSSValueAuto) { 6879 if (m_valueList->current()->id == CSSValueAuto) {
6880 // FIXME: This will be read back as an empty string instead of auto 6880 // FIXME: This will be read back as an empty string instead of auto
6881 return values.release(); 6881 return values.release();
6882 } 6882 }
6883 6883
6884 // Every comma-separated list of CSS_IDENTs is a valid will-change value, 6884 // Every comma-separated list of CSS_IDENTs is a valid will-change value,
6885 // unless the list includes an explicitly disallowed CSS_IDENT. 6885 // unless the list includes an explicitly disallowed CSS_IDENT.
6886 while (true) { 6886 while (true) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
7039 } 7039 }
7040 } 7040 }
7041 7041
7042 return list.release(); 7042 return list.release();
7043 } 7043 }
7044 7044
7045 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() 7045 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin()
7046 { 7046 {
7047 CSSParserValue* value = m_valueList->current(); 7047 CSSParserValue* value = m_valueList->current();
7048 CSSValueID id = value->id; 7048 CSSValueID id = value->id;
7049 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 7049 NullableCSSValue xValue;
7050 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 7050 NullableCSSValue yValue;
7051 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; 7051 NullableCSSValue zValue;
7052 if (id == CSSValueLeft || id == CSSValueRight) { 7052 if (id == CSSValueLeft || id == CSSValueRight) {
7053 xValue = cssValuePool().createIdentifierValue(id); 7053 xValue = cssValuePool().createIdentifierValue(id);
7054 } else if (id == CSSValueTop || id == CSSValueBottom) { 7054 } else if (id == CSSValueTop || id == CSSValueBottom) {
7055 yValue = cssValuePool().createIdentifierValue(id); 7055 yValue = cssValuePool().createIdentifierValue(id);
7056 } else if (id == CSSValueCenter) { 7056 } else if (id == CSSValueCenter) {
7057 // Unresolved as to whether this is X or Y. 7057 // Unresolved as to whether this is X or Y.
7058 } else if (validUnit(value, FPercent | FLength)) { 7058 } else if (validUnit(value, FPercent | FLength)) {
7059 xValue = createPrimitiveNumericValue(value); 7059 xValue = createPrimitiveNumericValue(value);
7060 } else { 7060 } else {
7061 return nullptr; 7061 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
7094 } 7094 }
7095 } else if (!xValue) { 7095 } else if (!xValue) {
7096 if (yValue) { 7096 if (yValue) {
7097 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE); 7097 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE);
7098 } else { 7098 } else {
7099 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); 7099 xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
7100 } 7100 }
7101 } 7101 }
7102 7102
7103 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7103 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7104 list->append(xValue.release()); 7104 list->append(*xValue);
7105 if (yValue) 7105 if (yValue)
7106 list->append(yValue.release()); 7106 list->append(*yValue);
7107 if (zValue) 7107 if (zValue)
7108 list->append(zValue.release()); 7108 list->append(*zValue);
7109 return list.release(); 7109 return list.release();
7110 } 7110 }
7111 7111
7112 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction() 7112 NullableCSSValue CSSPropertyParser::parseTouchAction()
7113 { 7113 {
7114 CSSParserValue* value = m_valueList->current(); 7114 CSSParserValue* value = m_valueList->current();
7115 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7115 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7116 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value ->id == CSSValueNone || value->id == CSSValueManipulation)) { 7116 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value ->id == CSSValueNone || value->id == CSSValueManipulation)) {
7117 list->append(cssValuePool().createIdentifierValue(value->id)); 7117 list->append(cssValuePool().createIdentifierValue(value->id));
7118 m_valueList->next(); 7118 m_valueList->next();
7119 return list.release(); 7119 return list.release();
7120 } 7120 }
7121 7121
7122 bool xSet = false; 7122 bool xSet = false;
7123 bool ySet = false; 7123 bool ySet = false;
7124 while (value) { 7124 while (value) {
7125 switch (value->id) { 7125 switch (value->id) {
7126 case CSSValuePanX: 7126 case CSSValuePanX:
7127 case CSSValuePanRight: 7127 case CSSValuePanRight:
7128 case CSSValuePanLeft: { 7128 case CSSValuePanLeft: {
7129 if (xSet) 7129 if (xSet)
7130 return nullptr; 7130 return nullptr;
7131 xSet = true; 7131 xSet = true;
7132 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled()) 7132 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled())
7133 return nullptr; 7133 return nullptr;
7134 7134
7135 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif ierValue(value->id); 7135 CSSValue panValue = cssValuePool().createIdentifierValue(value->id);
7136 list->append(panValue.release()); 7136 list->append(panValue);
7137 break; 7137 break;
7138 } 7138 }
7139 case CSSValuePanY: 7139 case CSSValuePanY:
7140 case CSSValuePanDown: 7140 case CSSValuePanDown:
7141 case CSSValuePanUp: { 7141 case CSSValuePanUp: {
7142 if (ySet) 7142 if (ySet)
7143 return nullptr; 7143 return nullptr;
7144 ySet = true; 7144 ySet = true;
7145 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled()) 7145 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled())
7146 return nullptr; 7146 return nullptr;
7147 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif ierValue(value->id); 7147 CSSValue panValue = cssValuePool().createIdentifierValue(value->id);
7148 list->append(panValue.release()); 7148 list->append(panValue);
7149 break; 7149 break;
7150 } 7150 }
7151 default: 7151 default:
7152 return nullptr; 7152 return nullptr;
7153 } 7153 }
7154 value = m_valueList->next(); 7154 value = m_valueList->next();
7155 } 7155 }
7156 7156
7157 if (list->length()) 7157 if (list->length())
7158 return list.release(); 7158 return list.release();
7159 7159
7160 return nullptr; 7160 return nullptr;
7161 } 7161 }
7162 7162
7163 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollBlocksOn() 7163 NullableCSSValue CSSPropertyParser::parseScrollBlocksOn()
7164 { 7164 {
7165 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7165 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7166 CSSParserValue* value = m_valueList->current(); 7166 CSSParserValue* value = m_valueList->current();
7167 while (value) { 7167 while (value) {
7168 switch (value->id) { 7168 switch (value->id) {
7169 case CSSValueStartTouch: 7169 case CSSValueStartTouch:
7170 case CSSValueWheelEvent: 7170 case CSSValueWheelEvent:
7171 case CSSValueScrollEvent: { 7171 case CSSValueScrollEvent: {
7172 RefPtrWillBeRawPtr<CSSValue> flagValue = cssValuePool().createIdenti fierValue(value->id); 7172 CSSValue flagValue = cssValuePool().createIdentifierValue(value->id) ;
7173 if (list->hasValue(flagValue.get())) 7173 if (list->hasValue(flagValue))
7174 return nullptr; 7174 return nullptr;
7175 list->append(flagValue.release()); 7175 list->append(flagValue);
7176 break; 7176 break;
7177 } 7177 }
7178 default: 7178 default:
7179 return nullptr; 7179 return nullptr;
7180 } 7180 }
7181 value = m_valueList->next(); 7181 value = m_valueList->next();
7182 } 7182 }
7183 7183
7184 ASSERT(list->length()); 7184 ASSERT(list->length());
7185 return list.release(); 7185 return list.release();
7186 } 7186 }
7187 7187
7188 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) 7188 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, CSSValue value, bool important)
7189 { 7189 {
7190 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set. 7190 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set.
7191 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { 7191 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) {
7192 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 7192 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
7193 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) 7193 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine)
7194 return; 7194 return;
7195 } 7195 }
7196 } 7196 }
7197 addProperty(propId, value, important); 7197 addProperty(propId, value, important);
7198 } 7198 }
(...skipping 29 matching lines...) Expand all
7228 7228
7229 // Values are either valid or in shorthand scope. 7229 // Values are either valid or in shorthand scope.
7230 if (list->length() && (isValid || inShorthand())) { 7230 if (list->length() && (isValid || inShorthand())) {
7231 addTextDecorationProperty(propId, list.release(), important); 7231 addTextDecorationProperty(propId, list.release(), important);
7232 return true; 7232 return true;
7233 } 7233 }
7234 7234
7235 return false; 7235 return false;
7236 } 7236 }
7237 7237
7238 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() 7238 NullableCSSValue CSSPropertyParser::parseTextEmphasisStyle()
7239 { 7239 {
7240 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; 7240 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
7241 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; 7241 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
7242 7242
7243 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7243 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7244 if (value->unit == CSSPrimitiveValue::CSS_STRING) { 7244 if (value->unit == CSSPrimitiveValue::CSS_STRING) {
7245 if (fill || shape) 7245 if (fill || shape)
7246 return nullptr; 7246 return nullptr;
7247 m_valueList->next(); 7247 m_valueList->next();
7248 return createPrimitiveStringValue(value); 7248 return createPrimitiveStringValue(value);
(...skipping 26 matching lines...) Expand all
7275 return parsedValues.release(); 7275 return parsedValues.release();
7276 } 7276 }
7277 if (fill) 7277 if (fill)
7278 return fill.release(); 7278 return fill.release();
7279 if (shape) 7279 if (shape)
7280 return shape.release(); 7280 return shape.release();
7281 7281
7282 return nullptr; 7282 return nullptr;
7283 } 7283 }
7284 7284
7285 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() 7285 NullableCSSValue CSSPropertyParser::parseTextIndent()
7286 { 7286 {
7287 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7287 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7288 7288
7289 bool hasLengthOrPercentage = false; 7289 bool hasLengthOrPercentage = false;
7290 bool hasEachLine = false; 7290 bool hasEachLine = false;
7291 bool hasHanging = false; 7291 bool hasHanging = false;
7292 7292
7293 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7293 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7294 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false 7294 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false
7295 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni tlessQuirk)) { 7295 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni tlessQuirk)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
7381 m_valueList->next(); 7381 m_valueList->next();
7382 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { 7382 } else if (value->id == CSSValueOn || value->id == CSSValueOff) {
7383 tagValue = value->id == CSSValueOn; 7383 tagValue = value->id == CSSValueOn;
7384 m_valueList->next(); 7384 m_valueList->next();
7385 } 7385 }
7386 } 7386 }
7387 settings->append(CSSFontFeatureValue::create(tag, tagValue)); 7387 settings->append(CSSFontFeatureValue::create(tag, tagValue));
7388 return true; 7388 return true;
7389 } 7389 }
7390 7390
7391 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() 7391 NullableCSSValue CSSPropertyParser::parseFontFeatureSettings()
7392 { 7392 {
7393 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat ed(); 7393 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat ed();
7394 while (true) { 7394 while (true) {
7395 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) 7395 if (!m_valueList->current() || !parseFontFeatureTag(settings.get()))
7396 return nullptr; 7396 return nullptr;
7397 if (!m_valueList->current()) 7397 if (!m_valueList->current())
7398 break; 7398 break;
7399 if (!consumeComma(m_valueList)) 7399 if (!consumeComma(m_valueList))
7400 return nullptr; 7400 return nullptr;
7401 } 7401 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7470 return false; 7470 return false;
7471 7471
7472 return true; 7472 return true;
7473 } 7473 }
7474 7474
7475 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) 7475 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId)
7476 { 7476 {
7477 CSSParserValue* value = m_valueList->current(); 7477 CSSParserValue* value = m_valueList->current();
7478 ASSERT(value); 7478 ASSERT(value);
7479 CSSValueID id = value->id; 7479 CSSValueID id = value->id;
7480 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7480 NullableCSSValue parsedValue;
7481 7481
7482 switch (propId) { 7482 switch (propId) {
7483 case CSSPropertyFontFamily: 7483 case CSSPropertyFontFamily:
7484 // <family-name> 7484 // <family-name>
7485 // TODO(rwlbuis): check there is only one family-name 7485 // TODO(rwlbuis): check there is only one family-name
7486 parsedValue = parseFontFamily(); 7486 parsedValue = parseFontFamily();
7487 break; 7487 break;
7488 case CSSPropertySrc: // This is a list of urls or local references. 7488 case CSSPropertySrc: // This is a list of urls or local references.
7489 parsedValue = parseFontFaceSrc(); 7489 parsedValue = parseFontFaceSrc();
7490 break; 7490 break;
(...skipping 20 matching lines...) Expand all
7511 parsedValue = parseFontFeatureSettings(); 7511 parsedValue = parseFontFeatureSettings();
7512 } 7512 }
7513 break; 7513 break;
7514 default: 7514 default:
7515 break; 7515 break;
7516 } 7516 }
7517 7517
7518 if (!parsedValue || m_valueList->current()) 7518 if (!parsedValue || m_valueList->current())
7519 return false; 7519 return false;
7520 7520
7521 addProperty(propId, parsedValue.release(), false); 7521 addProperty(propId, *parsedValue, false);
7522 return true; 7522 return true;
7523 } 7523 }
7524 7524
7525 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt) 7525 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt)
7526 { 7526 {
7527 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7527 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
7528 7528
7529 CSSParserValue* value = m_valueList->current(); 7529 CSSParserValue* value = m_valueList->current();
7530 if (!value) 7530 if (!value)
7531 return false; 7531 return false;
(...skipping 27 matching lines...) Expand all
7559 if (id == CSSValueZoom || id == CSSValueFixed) 7559 if (id == CSSValueZoom || id == CSSValueFixed)
7560 validPrimitive = true; 7560 validPrimitive = true;
7561 break; 7561 break;
7562 case CSSPropertyOrientation: // auto | portrait | landscape 7562 case CSSPropertyOrientation: // auto | portrait | landscape
7563 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc ape) 7563 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc ape)
7564 validPrimitive = true; 7564 validPrimitive = true;
7565 default: 7565 default:
7566 break; 7566 break;
7567 } 7567 }
7568 7568
7569 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7569 NullableCSSValue parsedValue;
7570 if (validPrimitive) { 7570 if (validPrimitive) {
7571 parsedValue = parseValidPrimitive(id, value); 7571 parsedValue = parseValidPrimitive(id, value);
7572 m_valueList->next(); 7572 m_valueList->next();
7573 } 7573 }
7574 7574
7575 if (parsedValue) { 7575 if (parsedValue) {
7576 if (!m_valueList->current() || inShorthand()) { 7576 if (!m_valueList->current() || inShorthand()) {
7577 addProperty(propId, parsedValue.release(), important); 7577 addProperty(propId, *parsedValue, important);
7578 return true; 7578 return true;
7579 } 7579 }
7580 } 7580 }
7581 7581
7582 return false; 7582 return false;
7583 } 7583 }
7584 7584
7585 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty ID first, CSSPropertyID second, bool important) 7585 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty ID first, CSSPropertyID second, bool important)
7586 { 7586 {
7587 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7587 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
7684 } 7684 }
7685 7685
7686 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) 7686 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
7687 { 7687 {
7688 CSSParserValue* value = m_valueList->current(); 7688 CSSParserValue* value = m_valueList->current();
7689 ASSERT(value); 7689 ASSERT(value);
7690 7690
7691 CSSValueID id = value->id; 7691 CSSValueID id = value->id;
7692 7692
7693 bool validPrimitive = false; 7693 bool validPrimitive = false;
7694 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7694 NullableCSSValue parsedValue;
7695 7695
7696 switch (propId) { 7696 switch (propId) {
7697 /* The comment to the right defines all valid value of these 7697 /* The comment to the right defines all valid value of these
7698 * properties as defined in SVG 1.1, Appendix N. Property index */ 7698 * properties as defined in SVG 1.1, Appendix N. Property index */
7699 case CSSPropertyAlignmentBaseline: 7699 case CSSPropertyAlignmentBaseline:
7700 // auto | baseline | before-edge | text-before-edge | middle | 7700 // auto | baseline | before-edge | text-before-edge | middle |
7701 // central | after-edge | text-after-edge | ideographic | alphabetic | 7701 // central | after-edge | text-after-edge | ideographic | alphabetic |
7702 // hanging | mathematical | inherit 7702 // hanging | mathematical | inherit
7703 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle 7703 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle
7704 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical)) 7704 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical))
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
7826 parsedValue = cssValuePool().createIdentifierValue(id); 7826 parsedValue = cssValuePool().createIdentifierValue(id);
7827 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 7827 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
7828 if (m_valueList->next()) { 7828 if (m_valueList->next()) {
7829 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea teSpaceSeparated(); 7829 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea teSpaceSeparated();
7830 values->append(CSSPrimitiveValue::create(value->string, CSSP rimitiveValue::CSS_URI)); 7830 values->append(CSSPrimitiveValue::create(value->string, CSSP rimitiveValue::CSS_URI));
7831 if (m_valueList->current()->id == CSSValueNone) 7831 if (m_valueList->current()->id == CSSValueNone)
7832 parsedValue = cssValuePool().createIdentifierValue(m_val ueList->current()->id); 7832 parsedValue = cssValuePool().createIdentifierValue(m_val ueList->current()->id);
7833 else 7833 else
7834 parsedValue = parseColor(m_valueList->current()); 7834 parsedValue = parseColor(m_valueList->current());
7835 if (parsedValue) { 7835 if (parsedValue) {
7836 values->append(parsedValue); 7836 values->append(*parsedValue);
7837 parsedValue = values; 7837 parsedValue = values;
7838 } 7838 }
7839 } 7839 }
7840 if (!parsedValue) 7840 if (!parsedValue)
7841 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr imitiveValue::CSS_URI); 7841 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr imitiveValue::CSS_URI);
7842 } else { 7842 } else {
7843 parsedValue = parseColor(m_valueList->current()); 7843 parsedValue = parseColor(m_valueList->current());
7844 } 7844 }
7845 7845
7846 if (parsedValue) 7846 if (parsedValue)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
7901 /* shorthand properties */ 7901 /* shorthand properties */
7902 case CSSPropertyMarker: { 7902 case CSSPropertyMarker: {
7903 ShorthandScope scope(this, propId); 7903 ShorthandScope scope(this, propId);
7904 CSSPropertyParser::ImplicitScope implicitScope(this); 7904 CSSPropertyParser::ImplicitScope implicitScope(this);
7905 if (!parseValue(CSSPropertyMarkerStart, important)) 7905 if (!parseValue(CSSPropertyMarkerStart, important))
7906 return false; 7906 return false;
7907 if (m_valueList->current()) { 7907 if (m_valueList->current()) {
7908 rollbackLastProperties(1); 7908 rollbackLastProperties(1);
7909 return false; 7909 return false;
7910 } 7910 }
7911 CSSValue* value = m_parsedProperties.last().value(); 7911 CSSValue value = m_parsedProperties.last().value();
7912 addProperty(CSSPropertyMarkerMid, value, important); 7912 addProperty(CSSPropertyMarkerMid, value, important);
7913 addProperty(CSSPropertyMarkerEnd, value, important); 7913 addProperty(CSSPropertyMarkerEnd, value, important);
7914 return true; 7914 return true;
7915 } 7915 }
7916 default: 7916 default:
7917 // If you crash here, it's because you added a css property and are not handling it 7917 // If you crash here, it's because you added a css property and are not handling it
7918 // in either this switch statement or the one in CSSPropertyParser::pars eValue 7918 // in either this switch statement or the one in CSSPropertyParser::pars eValue
7919 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); 7919 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId);
7920 return false; 7920 return false;
7921 } 7921 }
(...skipping 13 matching lines...) Expand all
7935 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie 7935 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie
7936 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se()); 7936 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se());
7937 m_parsedCalculation.release(); 7937 m_parsedCalculation.release();
7938 parsedValue = nullptr; 7938 parsedValue = nullptr;
7939 } 7939 }
7940 m_valueList->next(); 7940 m_valueList->next();
7941 } 7941 }
7942 if (!parsedValue || (m_valueList->current() && !inShorthand())) 7942 if (!parsedValue || (m_valueList->current() && !inShorthand()))
7943 return false; 7943 return false;
7944 7944
7945 addProperty(propId, parsedValue.release(), important); 7945 addProperty(propId, *parsedValue, important);
7946 return true; 7946 return true;
7947 } 7947 }
7948 7948
7949 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray() 7949 NullableCSSValue CSSPropertyParser::parseSVGStrokeDasharray()
7950 { 7950 {
7951 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); 7951 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated();
7952 CSSParserValue* value = m_valueList->current(); 7952 CSSParserValue* value = m_valueList->current();
7953 bool validPrimitive = true; 7953 bool validPrimitive = true;
7954 while (value) { 7954 while (value) {
7955 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri buteMode); 7955 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri buteMode);
7956 if (!validPrimitive) 7956 if (!validPrimitive)
7957 break; 7957 break;
7958 if (value->id) 7958 if (value->id)
7959 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); 7959 ret->append(CSSPrimitiveValue::createIdentifier(value->id));
7960 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) 7960 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
7961 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType) value->unit)); 7961 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType) value->unit));
7962 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS SPrimitiveValue::CSS_CHS) 7962 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS SPrimitiveValue::CSS_CHS)
7963 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType)value->unit)); 7963 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType)value->unit));
7964 value = m_valueList->next(); 7964 value = m_valueList->next();
7965 bool commaConsumed = consumeComma(m_valueList); 7965 bool commaConsumed = consumeComma(m_valueList);
7966 value = m_valueList->current(); 7966 value = m_valueList->current();
7967 if (commaConsumed && !value) 7967 if (commaConsumed && !value)
7968 return nullptr; 7968 return nullptr;
7969 } 7969 }
7970 if (!validPrimitive) 7970 if (!validPrimitive)
7971 return nullptr; 7971 return nullptr;
7972 return ret.release(); 7972 return ret.release();
7973 } 7973 }
7974 7974
7975 // normal | [ fill || stroke || markers ] 7975 // normal | [ fill || stroke || markers ]
7976 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const 7976 NullableCSSValue CSSPropertyParser::parsePaintOrder() const
7977 { 7977 {
7978 if (m_valueList->size() > 3) 7978 if (m_valueList->size() > 3)
7979 return nullptr; 7979 return nullptr;
7980 7980
7981 CSSParserValue* value = m_valueList->current(); 7981 CSSParserValue* value = m_valueList->current();
7982 ASSERT(value); 7982 ASSERT(value);
7983 7983
7984 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 7984 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated();
7985 7985
7986 // The default paint-order is: Fill, Stroke, Markers. 7986 // The default paint-order is: Fill, Stroke, Markers.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
8129 CSSPropertyParser::Units m_unit; 8129 CSSPropertyParser::Units m_unit;
8130 }; 8130 };
8131 8131
8132 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL egacyParsing) 8132 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL egacyParsing)
8133 { 8133 {
8134 if (!m_valueList) 8134 if (!m_valueList)
8135 return nullptr; 8135 return nullptr;
8136 8136
8137 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 8137 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
8138 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8138 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8139 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue( useLegacyParsing, value); 8139 NullableCSSValue parsedTransformValue = parseTransformValue(useLegacyPar sing, value);
8140 if (!parsedTransformValue) 8140 if (!parsedTransformValue)
8141 return nullptr; 8141 return nullptr;
8142 8142
8143 list->append(parsedTransformValue.release()); 8143 list->append(*parsedTransformValue);
8144 } 8144 }
8145 8145
8146 return list.release(); 8146 return list.release();
8147 } 8147 }
8148 8148
8149 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(bool use LegacyParsing, CSSParserValue *value) 8149 NullableCSSValue CSSPropertyParser::parseTransformValue(bool useLegacyParsing, C SSParserValue *value)
8150 { 8150 {
8151 if (value->unit != CSSParserValue::Function || !value->function) 8151 if (value->unit != CSSParserValue::Function || !value->function)
8152 return nullptr; 8152 return nullptr;
8153 8153
8154 // Every primitive requires at least one argument. 8154 // Every primitive requires at least one argument.
8155 CSSParserValueList* args = value->function->args.get(); 8155 CSSParserValueList* args = value->function->args.get();
8156 if (!args) 8156 if (!args)
8157 return nullptr; 8157 return nullptr;
8158 8158
8159 // See if the specified primitive is one we understand. 8159 // See if the specified primitive is one we understand.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
8211 if (!isComma(a)) 8211 if (!isComma(a))
8212 return nullptr; 8212 return nullptr;
8213 a = args->next(); 8213 a = args->next();
8214 8214
8215 argNumber++; 8215 argNumber++;
8216 } 8216 }
8217 8217
8218 return transformValue.release(); 8218 return transformValue.release();
8219 } 8219 }
8220 8220
8221 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() 8221 NullableCSSValue CSSPropertyParser::parseMotionPath()
8222 { 8222 {
8223 CSSParserValue* value = m_valueList->current(); 8223 CSSParserValue* value = m_valueList->current();
8224 8224
8225 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. 8225 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>.
8226 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath) 8226 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath)
8227 return nullptr; 8227 return nullptr;
8228 8228
8229 // FIXME: Add support for <fill-rule>. 8229 // FIXME: Add support for <fill-rule>.
8230 CSSParserValueList* functionArgs = value->function->args.get(); 8230 CSSParserValueList* functionArgs = value->function->args.get();
8231 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) 8231 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current())
8232 return nullptr; 8232 return nullptr;
8233 8233
8234 CSSParserValue* arg = functionArgs->current(); 8234 CSSParserValue* arg = functionArgs->current();
8235 if (arg->unit != CSSPrimitiveValue::CSS_STRING) 8235 if (arg->unit != CSSPrimitiveValue::CSS_STRING)
8236 return nullptr; 8236 return nullptr;
8237 8237
8238 String pathString = arg->string; 8238 String pathString = arg->string;
8239 Path path; 8239 Path path;
8240 if (!buildPathFromString(pathString, path)) 8240 if (!buildPathFromString(pathString, path))
8241 return nullptr; 8241 return nullptr;
8242 8242
8243 m_valueList->next(); 8243 m_valueList->next();
8244 return CSSPathValue::create(pathString); 8244 return CSSPathValue::create(pathString);
8245 } 8245 }
8246 8246
8247 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionRotation() 8247 NullableCSSValue CSSPropertyParser::parseMotionRotation()
8248 { 8248 {
8249 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 8249 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
8250 bool hasAutoOrReverse = false; 8250 bool hasAutoOrReverse = false;
8251 bool hasAngle = false; 8251 bool hasAngle = false;
8252 8252
8253 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8253 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8254 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA utoOrReverse) { 8254 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA utoOrReverse) {
8255 list->append(cssValuePool().createIdentifierValue(value->id)); 8255 list->append(cssValuePool().createIdentifierValue(value->id));
8256 hasAutoOrReverse = true; 8256 hasAutoOrReverse = true;
8257 } else if (validUnit(value, FAngle) && !hasAngle) { 8257 } else if (validUnit(value, FAngle) && !hasAngle) {
8258 list->append(createPrimitiveNumericValue(value)); 8258 list->append(createPrimitiveNumericValue(value));
8259 hasAngle = true; 8259 hasAngle = true;
8260 } else { 8260 } else {
8261 break; 8261 break;
8262 } 8262 }
8263 } 8263 }
8264 8264
8265 if (!list->length()) 8265 if (!list->length())
8266 return nullptr; 8266 return nullptr;
8267 8267
8268 return list.release(); 8268 return list.release();
8269 } 8269 }
8270 8270
8271 } // namespace blink 8271 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/parser/CSSPropertyParserTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698