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

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: (Hopefully) Builds with oilpan now Created 5 years, 6 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // This doesn't count UA style sheets 118 // This doesn't count UA style sheets
119 if (parseSuccess && context.useCounter()) 119 if (parseSuccess && context.useCounter())
120 context.useCounter()->count(context, unresolvedProperty); 120 context.useCounter()->count(context, unresolvedProperty);
121 121
122 if (!parseSuccess) 122 if (!parseSuccess)
123 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size); 123 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size);
124 124
125 return parseSuccess; 125 return parseSuccess;
126 } 126 }
127 127
128 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr <CSSValue> value, bool important, bool implicit) 128 void CSSPropertyParser::addProperty(CSSPropertyID propId, CSSValue value, bool i mportant, bool implicit)
129 { 129 {
130 ASSERT(!isPropertyAlias(propId)); 130 ASSERT(!isPropertyAlias(propId));
131 131
132 int shorthandIndex = 0; 132 int shorthandIndex = 0;
133 bool setFromShorthand = false; 133 bool setFromShorthand = false;
134 134
135 if (m_currentShorthand) { 135 if (m_currentShorthand) {
136 Vector<StylePropertyShorthand, 4> shorthands; 136 Vector<StylePropertyShorthand, 4> shorthands;
137 getMatchingShorthandsForLonghand(propId, &shorthands); 137 getMatchingShorthandsForLonghand(propId, &shorthands);
138 // Viewport descriptors have width and height as shorthands, but it does n't 138 // Viewport descriptors have width and height as shorthands, but it does n't
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 310 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
311 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG); 311 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG);
312 } 312 }
313 313
314 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value) 314 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value)
315 { 315 {
316 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 316 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
317 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT); 317 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT);
318 } 318 }
319 319
320 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi thReferrer(const String& rawValue, const KURL& url) 320 inline CSSValue CSSPropertyParser::createCSSImageValueWithReferrer(const String& rawValue, const KURL& url)
321 { 321 {
322 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur l); 322 CSSValue imageValue = CSSImageValue::create(rawValue, url);
323 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); 323 toCSSImageValue(imageValue).setReferrer(m_context.referrer());
324 return imageValue; 324 return imageValue;
325 } 325 }
326 326
327 static inline bool isComma(CSSParserValue* value) 327 static inline bool isComma(CSSParserValue* value)
328 { 328 {
329 ASSERT(value); 329 ASSERT(value);
330 return value->unit == CSSParserValue::Operator && value->iValue == ','; 330 return value->unit == CSSParserValue::Operator && value->iValue == ',';
331 } 331 }
332 332
333 static bool consumeComma(CSSParserValueList* valueList) 333 static bool consumeComma(CSSParserValueList* valueList)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) 392 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM)
393 return createPrimitiveNumericValue(value); 393 return createPrimitiveNumericValue(value);
394 if (value->unit >= CSSParserValue::Q_EMS) 394 if (value->unit >= CSSParserValue::Q_EMS)
395 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); 395 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS);
396 if (isCalculation(value)) 396 if (isCalculation(value))
397 return CSSPrimitiveValue::create(m_parsedCalculation.release()); 397 return CSSPrimitiveValue::create(m_parsedCalculation.release());
398 398
399 return nullptr; 399 return nullptr;
400 } 400 }
401 401
402 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe fPtrWillBeRawPtr<CSSValue> prpValue, bool important) 402 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, CSSVal ue prpValue, bool important)
403 { 403 {
404 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); 404 const StylePropertyShorthand& shorthand = shorthandForProperty(propId);
405 unsigned shorthandLength = shorthand.length(); 405 unsigned shorthandLength = shorthand.length();
406 if (!shorthandLength) { 406 if (!shorthandLength) {
407 addProperty(propId, prpValue, important); 407 addProperty(propId, prpValue, important);
408 return; 408 return;
409 } 409 }
410 410
411 RefPtrWillBeRawPtr<CSSValue> value = prpValue; 411 CSSValue value = prpValue;
412 ShorthandScope scope(this, propId); 412 ShorthandScope scope(this, propId);
413 const CSSPropertyID* longhands = shorthand.properties(); 413 const CSSPropertyID* longhands = shorthand.properties();
414 for (unsigned i = 0; i < shorthandLength; ++i) 414 for (unsigned i = 0; i < shorthandLength; ++i)
415 addProperty(longhands[i], value, important); 415 addProperty(longhands[i], value, important);
416 } 416 }
417 417
418 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant) 418 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant)
419 { 419 {
420 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); 420 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty);
421 421
(...skipping 28 matching lines...) Expand all
450 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) 450 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id))
451 return false; 451 return false;
452 if (m_valueList->next() && !inShorthand()) 452 if (m_valueList->next() && !inShorthand())
453 return false; 453 return false;
454 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; 454 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ;
455 return true; 455 return true;
456 } 456 }
457 457
458 bool validPrimitive = false; 458 bool validPrimitive = false;
459 Units unitless = FUnknown; 459 Units unitless = FUnknown;
460 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 460 NullableCSSValue parsedValue;
461 461
462 switch (propId) { 462 switch (propId) {
463 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] 463 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
464 parsedValue = parseSize(); 464 parsedValue = parseSize();
465 break; 465 break;
466 case CSSPropertyQuotes: // [<string> <string>]+ | none 466 case CSSPropertyQuotes: // [<string> <string>]+ | none
467 if (id == CSSValueNone) 467 if (id == CSSValueNone)
468 validPrimitive = true; 468 validPrimitive = true;
469 else 469 else
470 parsedValue = parseQuotes(); 470 parsedValue = parseQuotes();
(...skipping 11 matching lines...) Expand all
482 break; 482 break;
483 483
484 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work 484 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work
485 * correctly and allows optimization in blink::applyRule(..) 485 * correctly and allows optimization in blink::applyRule(..)
486 */ 486 */
487 case CSSPropertyOverflow: { 487 case CSSPropertyOverflow: {
488 ShorthandScope scope(this, propId); 488 ShorthandScope scope(this, propId);
489 if (num != 1 || !parseValue(CSSPropertyOverflowY, important)) 489 if (num != 1 || !parseValue(CSSPropertyOverflowY, important))
490 return false; 490 return false;
491 491
492 RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr;
493
494 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I f this value has been 492 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I f this value has been
495 // set using the shorthand, then for now overflow-x will default to auto , but once we implement 493 // set using the shorthand, then for now overflow-x will default to auto , but once we implement
496 // pagination controls, it should default to hidden. If the overflow-y v alue is anything but 494 // pagination controls, it should default to hidden. If the overflow-y v alue is anything but
497 // paged-x or paged-y, then overflow-x and overflow-y should have the sa me value. 495 // paged-x or paged-y, then overflow-x and overflow-y should have the sa me value.
496 NullableCSSValue overflowXValue;
498 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) 497 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY)
499 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); 498 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto);
500 else 499 else
501 overflowXValue = m_parsedProperties.last().value(); 500 overflowXValue = m_parsedProperties.last().value();
502 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); 501 addProperty(CSSPropertyOverflowX, *overflowXValue, important);
503 return true; 502 return true;
504 } 503 }
505 504
506 case CSSPropertyTextAlign: 505 case CSSPropertyTextAlign:
507 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent 506 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent
508 // | start | end | <string> | inherit | -webkit-auto (converted to start ) 507 // | start | end | <string> | inherit | -webkit-auto (converted to start )
509 // FIXME: <string> not supported right now 508 // FIXME: <string> not supported right now
510 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) { 509 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) {
511 validPrimitive = true; 510 validPrimitive = true;
512 } 511 }
513 break; 512 break;
514 513
515 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit 514 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
516 if (m_valueList->size() != 1) 515 if (m_valueList->size() != 1)
517 return false; 516 return false;
518 return parseFontWeight(important); 517 return parseFontWeight(important);
519 } 518 }
520 519
521 case CSSPropertyBorderSpacing: { 520 case CSSPropertyBorderSpacing: {
522 if (num == 1) { 521 if (num == 1) {
523 ShorthandScope scope(this, CSSPropertyBorderSpacing); 522 ShorthandScope scope(this, CSSPropertyBorderSpacing);
524 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) ) 523 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) )
525 return false; 524 return false;
526 CSSValue* value = m_parsedProperties.last().value(); 525 CSSValue value = m_parsedProperties.last().value();
527 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important ); 526 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important );
528 return true; 527 return true;
529 } 528 }
530 else if (num == 2) { 529 else if (num == 2) {
531 ShorthandScope scope(this, CSSPropertyBorderSpacing); 530 ShorthandScope scope(this, CSSPropertyBorderSpacing);
532 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) 531 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important))
533 return false; 532 return false;
534 return true; 533 return true;
535 } 534 }
536 return false; 535 return false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 case CSSPropertyCursor: { 601 case CSSPropertyCursor: {
603 // Grammar defined by CSS3 UI and modified by CSS4 images: 602 // Grammar defined by CSS3 UI and modified by CSS4 images:
604 // [ [<image> [<x> <y>]?,]* 603 // [ [<image> [<x> <y>]?,]*
605 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize | 604 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
606 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 605 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
607 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help | 606 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help |
608 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll | 607 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll |
609 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit 608 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit
610 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; 609 RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
611 while (value) { 610 while (value) {
612 RefPtrWillBeRawPtr<CSSValue> image = nullptr; 611 NullableCSSValue image;
613 if (value->unit == CSSPrimitiveValue::CSS_URI) { 612 if (value->unit == CSSPrimitiveValue::CSS_URI) {
614 String uri = value->string; 613 String uri = value->string;
615 if (!uri.isNull()) 614 if (!uri.isNull())
616 image = createCSSImageValueWithReferrer(uri, completeURL(uri )); 615 image = createCSSImageValueWithReferrer(uri, completeURL(uri ));
617 } else if (value->unit == CSSParserValue::Function && value->functio n->id == CSSValueWebkitImageSet) { 616 } else if (value->unit == CSSParserValue::Function && value->functio n->id == CSSValueWebkitImageSet) {
618 image = parseImageSet(m_valueList); 617 image = parseImageSet(m_valueList);
619 if (!image) 618 if (!image)
620 break; 619 break;
621 } else 620 } else
622 break; 621 break;
(...skipping 11 matching lines...) Expand all
634 return false; 633 return false;
635 if (nrcoords == 2) { 634 if (nrcoords == 2) {
636 hotSpotSpecified = true; 635 hotSpotSpecified = true;
637 hotSpot = IntPoint(coords[0], coords[1]); 636 hotSpot = IntPoint(coords[0], coords[1]);
638 } 637 }
639 638
640 if (!list) 639 if (!list)
641 list = CSSValueList::createCommaSeparated(); 640 list = CSSValueList::createCommaSeparated();
642 641
643 if (image) 642 if (image)
644 list->append(CSSCursorImageValue::create(image, hotSpotSpecified , hotSpot)); 643 list->append(CSSCursorImageValue::create(*image, hotSpotSpecifie d, hotSpot));
645 644
646 if (!consumeComma(m_valueList)) 645 if (!consumeComma(m_valueList))
647 return false; 646 return false;
648 value = m_valueList->current(); 647 value = m_valueList->current();
649 } 648 }
650 if (value && m_context.useCounter()) { 649 if (value && m_context.useCounter()) {
651 if (value->id == CSSValueWebkitZoomIn) 650 if (value->id == CSSValueWebkitZoomIn)
652 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); 651 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn);
653 else if (value->id == CSSValueWebkitZoomOut) 652 else if (value->id == CSSValueWebkitZoomOut)
654 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ; 653 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 case CSSPropertyWebkitMaskImage: 695 case CSSPropertyWebkitMaskImage:
697 case CSSPropertyWebkitMaskOrigin: 696 case CSSPropertyWebkitMaskOrigin:
698 case CSSPropertyWebkitMaskPosition: 697 case CSSPropertyWebkitMaskPosition:
699 case CSSPropertyWebkitMaskPositionX: 698 case CSSPropertyWebkitMaskPositionX:
700 case CSSPropertyWebkitMaskPositionY: 699 case CSSPropertyWebkitMaskPositionY:
701 case CSSPropertyWebkitMaskSize: 700 case CSSPropertyWebkitMaskSize:
702 case CSSPropertyWebkitMaskRepeat: 701 case CSSPropertyWebkitMaskRepeat:
703 case CSSPropertyWebkitMaskRepeatX: 702 case CSSPropertyWebkitMaskRepeatX:
704 case CSSPropertyWebkitMaskRepeatY: 703 case CSSPropertyWebkitMaskRepeatY:
705 { 704 {
706 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 705 NullableCSSValue val1;
707 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 706 NullableCSSValue val2;
708 CSSPropertyID propId1, propId2; 707 CSSPropertyID propId1, propId2;
709 bool result = false; 708 bool result = false;
710 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2)) { 709 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2)) {
711 if (propId == CSSPropertyBackgroundPosition || 710 if (propId == CSSPropertyBackgroundPosition ||
712 propId == CSSPropertyBackgroundRepeat || 711 propId == CSSPropertyBackgroundRepeat ||
713 propId == CSSPropertyWebkitMaskPosition || 712 propId == CSSPropertyWebkitMaskPosition ||
714 propId == CSSPropertyWebkitMaskRepeat) { 713 propId == CSSPropertyWebkitMaskRepeat) {
715 ShorthandScope scope(this, propId); 714 ShorthandScope scope(this, propId);
716 addProperty(propId1, val1.release(), important); 715 addProperty(propId1, *val1, important);
717 if (val2) 716 if (val2)
718 addProperty(propId2, val2.release(), important); 717 addProperty(propId2, *val2, important);
719 } else { 718 } else {
720 addProperty(propId1, val1.release(), important); 719 addProperty(propId1, *val1, important);
721 if (val2) 720 if (val2)
722 addProperty(propId2, val2.release(), important); 721 addProperty(propId2, *val2, important);
723 } 722 }
724 result = true; 723 result = true;
725 } 724 }
726 m_implicitShorthand = false; 725 m_implicitShorthand = false;
727 return result; 726 return result;
728 } 727 }
729 case CSSPropertyObjectPosition: 728 case CSSPropertyObjectPosition:
730 parsedValue = parsePosition(m_valueList); 729 parsedValue = parsePosition(m_valueList);
731 break; 730 break;
732 case CSSPropertyListStyleImage: // <uri> | none | inherit 731 case CSSPropertyListStyleImage: // <uri> | none | inherit
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 case CSSPropertyUnicodeRange: 924 case CSSPropertyUnicodeRange:
926 /* @font-face only descriptors */ 925 /* @font-face only descriptors */
927 break; 926 break;
928 927
929 /* CSS3 properties */ 928 /* CSS3 properties */
930 929
931 case CSSPropertyBorderImage: 930 case CSSPropertyBorderImage:
932 case CSSPropertyWebkitMaskBoxImage: 931 case CSSPropertyWebkitMaskBoxImage:
933 return parseBorderImageShorthand(propId, important); 932 return parseBorderImageShorthand(propId, important);
934 case CSSPropertyWebkitBorderImage: { 933 case CSSPropertyWebkitBorderImage: {
935 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { 934 if (NullableCSSValue result = parseBorderImage(propId)) {
936 addProperty(propId, result, important); 935 addProperty(propId, *result, important);
937 return true; 936 return true;
938 } 937 }
939 return false; 938 return false;
940 } 939 }
941 940
942 case CSSPropertyBorderImageOutset: 941 case CSSPropertyBorderImageOutset:
943 case CSSPropertyWebkitMaskBoxImageOutset: { 942 case CSSPropertyWebkitMaskBoxImageOutset: {
944 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; 943 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr;
945 if (parseBorderImageOutset(result)) { 944 if (parseBorderImageOutset(result)) {
946 addProperty(propId, result, important); 945 addProperty(propId, result, important);
947 return true; 946 return true;
948 } 947 }
949 break; 948 break;
950 } 949 }
951 case CSSPropertyBorderImageRepeat: 950 case CSSPropertyBorderImageRepeat:
952 case CSSPropertyWebkitMaskBoxImageRepeat: { 951 case CSSPropertyWebkitMaskBoxImageRepeat: {
953 RefPtrWillBeRawPtr<CSSValue> result = nullptr; 952 NullableCSSValue result;
954 if (parseBorderImageRepeat(result)) { 953 if (parseBorderImageRepeat(result)) {
955 addProperty(propId, result, important); 954 addProperty(propId, *result, important);
956 return true; 955 return true;
957 } 956 }
958 break; 957 break;
959 } 958 }
960 case CSSPropertyBorderImageSlice: 959 case CSSPropertyBorderImageSlice:
961 case CSSPropertyWebkitMaskBoxImageSlice: { 960 case CSSPropertyWebkitMaskBoxImageSlice: {
962 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr; 961 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr;
963 if (parseBorderImageSlice(propId, result)) { 962 if (parseBorderImageSlice(propId, result)) {
964 addProperty(propId, result, important); 963 addProperty(propId, result, important);
965 return true; 964 return true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 case CSSPropertyWebkitBoxFlexGroup: 1038 case CSSPropertyWebkitBoxFlexGroup:
1040 validPrimitive = validUnit(value, FInteger | FNonNeg); 1039 validPrimitive = validUnit(value, FInteger | FNonNeg);
1041 break; 1040 break;
1042 case CSSPropertyWebkitBoxOrdinalGroup: 1041 case CSSPropertyWebkitBoxOrdinalGroup:
1043 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; 1042 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue;
1044 break; 1043 break;
1045 case CSSPropertyWebkitFilter: 1044 case CSSPropertyWebkitFilter:
1046 if (id == CSSValueNone) 1045 if (id == CSSValueNone)
1047 validPrimitive = true; 1046 validPrimitive = true;
1048 else { 1047 else {
1049 RefPtrWillBeRawPtr<CSSValue> val = parseFilter(); 1048 NullableCSSValue val = parseFilter();
1050 if (val) { 1049 if (val) {
1051 addProperty(propId, val, important); 1050 addProperty(propId, *val, important);
1052 return true; 1051 return true;
1053 } 1052 }
1054 return false; 1053 return false;
1055 } 1054 }
1056 break; 1055 break;
1057 case CSSPropertyFlex: { 1056 case CSSPropertyFlex: {
1058 ShorthandScope scope(this, propId); 1057 ShorthandScope scope(this, propId);
1059 if (id == CSSValueNone) { 1058 if (id == CSSValueNone) {
1060 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important); 1059 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important);
1061 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important); 1060 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 1226
1228 case CSSPropertyGrid: 1227 case CSSPropertyGrid:
1229 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 1228 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
1230 return parseGridShorthand(important); 1229 return parseGridShorthand(important);
1231 1230
1232 case CSSPropertyWebkitMarginCollapse: { 1231 case CSSPropertyWebkitMarginCollapse: {
1233 if (num == 1) { 1232 if (num == 1) {
1234 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1233 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1235 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) 1234 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant))
1236 return false; 1235 return false;
1237 CSSValue* value = m_parsedProperties.last().value(); 1236 CSSValue value = m_parsedProperties.last().value();
1238 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); 1237 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important);
1239 return true; 1238 return true;
1240 } 1239 }
1241 else if (num == 2) { 1240 else if (num == 2) {
1242 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1241 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1243 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan t)) 1242 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan t))
1244 return false; 1243 return false;
1245 return true; 1244 return true;
1246 } 1245 }
1247 return false; 1246 return false;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 else 1437 else
1439 return parseFontVariantLigatures(important); 1438 return parseFontVariantLigatures(important);
1440 break; 1439 break;
1441 case CSSPropertyWebkitClipPath: 1440 case CSSPropertyWebkitClipPath:
1442 if (id == CSSValueNone) { 1441 if (id == CSSValueNone) {
1443 validPrimitive = true; 1442 validPrimitive = true;
1444 } else if (value->unit == CSSParserValue::Function) { 1443 } else if (value->unit == CSSParserValue::Function) {
1445 parsedValue = parseBasicShape(); 1444 parsedValue = parseBasicShape();
1446 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 1445 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
1447 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV alue::CSS_URI); 1446 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV alue::CSS_URI);
1448 addProperty(propId, parsedValue.release(), important); 1447 addProperty(propId, *parsedValue, important);
1449 return true; 1448 return true;
1450 } 1449 }
1451 break; 1450 break;
1452 case CSSPropertyShapeOutside: 1451 case CSSPropertyShapeOutside:
1453 if (id == CSSValueNone) 1452 if (id == CSSValueNone)
1454 validPrimitive = true; 1453 validPrimitive = true;
1455 else 1454 else
1456 parsedValue = parseShapeProperty(propId); 1455 parsedValue = parseShapeProperty(propId);
1457 break; 1456 break;
1458 case CSSPropertyShapeMargin: 1457 case CSSPropertyShapeMargin:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 return parseSVGValue(propId, important); 1509 return parseSVGValue(propId, important);
1511 } 1510 }
1512 1511
1513 if (validPrimitive) { 1512 if (validPrimitive) {
1514 parsedValue = parseValidPrimitive(id, value); 1513 parsedValue = parseValidPrimitive(id, value);
1515 m_valueList->next(); 1514 m_valueList->next();
1516 } 1515 }
1517 ASSERT(!m_parsedCalculation); 1516 ASSERT(!m_parsedCalculation);
1518 if (parsedValue) { 1517 if (parsedValue) {
1519 if (!m_valueList->current() || inShorthand()) { 1518 if (!m_valueList->current() || inShorthand()) {
1520 addProperty(propId, parsedValue.release(), important); 1519 addProperty(propId, *parsedValue, important);
1521 return true; 1520 return true;
1522 } 1521 }
1523 } 1522 }
1524 return false; 1523 return false;
1525 } 1524 }
1526 1525
1527 void CSSPropertyParser::addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRef PtrWillBeRawPtr<CSSValue> rval) 1526 void CSSPropertyParser::addFillValue(NullableCSSValue& lval, CSSValue rval)
1528 { 1527 {
1529 if (lval) { 1528 if (lval) {
1530 if (lval->isBaseValueList()) 1529 if (lval->isBaseValueList())
1531 toCSSValueList(lval.get())->append(rval); 1530 toCSSValueList(lval)->append(rval);
1532 else { 1531 else {
1533 PassRefPtrWillBeRawPtr<CSSValue> oldlVal(lval.release());
1534 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated(); 1532 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated();
1535 list->append(oldlVal); 1533 list->append(*lval);
1536 list->append(rval); 1534 list->append(rval);
1537 lval = list; 1535 lval = list;
1538 } 1536 }
1539 } 1537 }
1540 else 1538 else
1541 lval = rval; 1539 lval = rval;
1542 } 1540 }
1543 1541
1544 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtrWillBeRawPtr< CSSValue>& cssValue) 1542 static bool parseBackgroundClip(CSSParserValue* parserValue, NullableCSSValue& c ssValue)
1545 { 1543 {
1546 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi ngBox 1544 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi ngBox
1547 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW ebkitText) { 1545 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW ebkitText) {
1548 cssValue = cssValuePool().createIdentifierValue(parserValue->id); 1546 cssValue = cssValuePool().createIdentifierValue(parserValue->id);
1549 return true; 1547 return true;
1550 } 1548 }
1551 return false; 1549 return false;
1552 } 1550 }
1553 1551
1554 const int cMaxFillProperties = 9; 1552 const int cMaxFillProperties = 9;
1555 1553
1556 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper tyID* properties, int numProperties, bool important) 1554 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper tyID* properties, int numProperties, bool important)
1557 { 1555 {
1558 ASSERT(numProperties <= cMaxFillProperties); 1556 ASSERT(numProperties <= cMaxFillProperties);
1559 if (numProperties > cMaxFillProperties) 1557 if (numProperties > cMaxFillProperties)
1560 return false; 1558 return false;
1561 1559
1562 ShorthandScope scope(this, propId); 1560 ShorthandScope scope(this, propId);
1563 1561
1564 bool parsedProperty[cMaxFillProperties] = { false }; 1562 bool parsedProperty[cMaxFillProperties] = { false };
1565 RefPtrWillBeRawPtr<CSSValue> values[cMaxFillProperties]; 1563 NullableCSSValue values[cMaxFillProperties];
1566 #if ENABLE(OILPAN) 1564 #if ENABLE(OILPAN)
1567 // Zero initialize the array of raw pointers. 1565 // Zero initialize the array of raw pointers.
1568 memset(&values, 0, sizeof(values)); 1566 memset(&values, 0, sizeof(values));
1569 #endif 1567 #endif
1570 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; 1568 NullableCSSValue clipValue;
1571 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; 1569 NullableCSSValue positionYValue;
1572 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; 1570 NullableCSSValue repeatYValue;
1573 bool foundClip = false; 1571 bool foundClip = false;
1574 int i; 1572 int i;
1575 bool foundPositionCSSProperty = false; 1573 bool foundPositionCSSProperty = false;
1576 1574
1577 while (m_valueList->current()) { 1575 while (m_valueList->current()) {
1578 CSSParserValue* val = m_valueList->current(); 1576 CSSParserValue* val = m_valueList->current();
1579 if (isComma(val)) { 1577 if (isComma(val)) {
1580 // We hit the end. Fill in all remaining values with the initial va lue. 1578 // We hit the end. Fill in all remaining values with the initial va lue.
1581 m_valueList->next(); 1579 m_valueList->next();
1582 for (i = 0; i < numProperties; ++i) { 1580 for (i = 0; i < numProperties; ++i) {
(...skipping 28 matching lines...) Expand all
1611 foundPositionCSSProperty = false; 1609 foundPositionCSSProperty = false;
1612 bool found = false; 1610 bool found = false;
1613 for (i = 0; !found && i < numProperties; ++i) { 1611 for (i = 0; !found && i < numProperties; ++i) {
1614 1612
1615 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou ndSize && properties[i] != CSSPropertyWebkitMaskSize)) 1613 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou ndSize && properties[i] != CSSPropertyWebkitMaskSize))
1616 continue; 1614 continue;
1617 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro undSize || properties[i] == CSSPropertyWebkitMaskSize)) 1615 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro undSize || properties[i] == CSSPropertyWebkitMaskSize))
1618 continue; 1616 continue;
1619 1617
1620 if (!parsedProperty[i]) { 1618 if (!parsedProperty[i]) {
1621 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 1619 NullableCSSValue val1;
1622 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 1620 NullableCSSValue val2;
1623 CSSPropertyID propId1, propId2; 1621 CSSPropertyID propId1, propId2;
1624 CSSParserValue* parserValue = m_valueList->current(); 1622 CSSParserValue* parserValue = m_valueList->current();
1625 // parseFillProperty() may modify m_implicitShorthand, so we MUS T reset it 1623 // parseFillProperty() may modify m_implicitShorthand, so we MUS T reset it
1626 // before EACH return below. 1624 // before EACH return below.
1627 if (parserValue && parseFillProperty(properties[i], propId1, pro pId2, val1, val2)) { 1625 if (parserValue && parseFillProperty(properties[i], propId1, pro pId2, val1, val2)) {
1628 parsedProperty[i] = found = true; 1626 parsedProperty[i] = found = true;
1629 addFillValue(values[i], val1.release()); 1627 addFillValue(values[i], *val1);
1630 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition) 1628 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition)
1631 addFillValue(positionYValue, val2.release()); 1629 addFillValue(positionYValue, *val2);
1632 if (properties[i] == CSSPropertyBackgroundRepeat || properti es[i] == CSSPropertyWebkitMaskRepeat) 1630 if (properties[i] == CSSPropertyBackgroundRepeat || properti es[i] == CSSPropertyWebkitMaskRepeat)
1633 addFillValue(repeatYValue, val2.release()); 1631 addFillValue(repeatYValue, *val2);
1634 if (properties[i] == CSSPropertyBackgroundOrigin || properti es[i] == CSSPropertyWebkitMaskOrigin) { 1632 if (properties[i] == CSSPropertyBackgroundOrigin || properti es[i] == CSSPropertyWebkitMaskOrigin) {
1635 // Reparse the value as a clip, and see if we succeed. 1633 // Reparse the value as a clip, and see if we succeed.
1636 if (parseBackgroundClip(parserValue, val1)) 1634 if (parseBackgroundClip(parserValue, val1))
1637 addFillValue(clipValue, val1.release()); // The prop erty parsed successfully. 1635 addFillValue(clipValue, *val1); // The property pars ed successfully.
1638 else 1636 else
1639 addFillValue(clipValue, cssValuePool().createImplici tInitialValue()); // Some value was used for origin that is not supported by cli p. Just reset clip instead. 1637 addFillValue(clipValue, cssValuePool().createImplici tInitialValue()); // Some value was used for origin that is not supported by cli p. Just reset clip instead.
1640 } 1638 }
1641 if (properties[i] == CSSPropertyBackgroundClip || properties [i] == CSSPropertyWebkitMaskClip) { 1639 if (properties[i] == CSSPropertyBackgroundClip || properties [i] == CSSPropertyWebkitMaskClip) {
1642 // Update clipValue 1640 // Update clipValue
1643 addFillValue(clipValue, val1.release()); 1641 addFillValue(clipValue, *val1);
1644 foundClip = true; 1642 foundClip = true;
1645 } 1643 }
1646 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition) 1644 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition)
1647 foundPositionCSSProperty = true; 1645 foundPositionCSSProperty = true;
1648 } 1646 }
1649 } 1647 }
1650 } 1648 }
1651 1649
1652 // if we didn't find at least one match, this is an 1650 // if we didn't find at least one match, this is an
1653 // invalid shorthand and we have to ignore it 1651 // invalid shorthand and we have to ignore it
(...skipping 11 matching lines...) Expand all
1665 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition) 1663 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
1666 addFillValue(positionYValue, cssValuePool().createImplicitInitia lValue()); 1664 addFillValue(positionYValue, cssValuePool().createImplicitInitia lValue());
1667 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat) 1665 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
1668 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV alue()); 1666 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV alue());
1669 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) { 1667 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
1670 // If background-origin wasn't present, then reset background-cl ip also. 1668 // If background-origin wasn't present, then reset background-cl ip also.
1671 addFillValue(clipValue, cssValuePool().createImplicitInitialValu e()); 1669 addFillValue(clipValue, cssValuePool().createImplicitInitialValu e());
1672 } 1670 }
1673 } 1671 }
1674 if (properties[i] == CSSPropertyBackgroundPosition) { 1672 if (properties[i] == CSSPropertyBackgroundPosition) {
1675 addProperty(CSSPropertyBackgroundPositionX, values[i].release(), imp ortant); 1673 addProperty(CSSPropertyBackgroundPositionX, *values[i], important);
1676 // it's OK to call positionYValue.release() since we only see CSSPro pertyBackgroundPosition once 1674 // it's OK to call positionYValue.release() since we only see CSSPro pertyBackgroundPosition once
1677 addProperty(CSSPropertyBackgroundPositionY, positionYValue.release() , important); 1675 addProperty(CSSPropertyBackgroundPositionY, *positionYValue, importa nt);
1678 } else if (properties[i] == CSSPropertyWebkitMaskPosition) { 1676 } else if (properties[i] == CSSPropertyWebkitMaskPosition) {
1679 addProperty(CSSPropertyWebkitMaskPositionX, values[i].release(), imp ortant); 1677 addProperty(CSSPropertyWebkitMaskPositionX, *values[i], important);
1680 // it's OK to call positionYValue.release() since we only see CSSPro pertyWebkitMaskPosition once 1678 // it's OK to call positionYValue.release() since we only see CSSPro pertyWebkitMaskPosition once
1681 addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release() , important); 1679 addProperty(CSSPropertyWebkitMaskPositionY, *positionYValue, importa nt);
1682 } else if (properties[i] == CSSPropertyBackgroundRepeat) { 1680 } else if (properties[i] == CSSPropertyBackgroundRepeat) {
1683 addProperty(CSSPropertyBackgroundRepeatX, values[i].release(), impor tant); 1681 addProperty(CSSPropertyBackgroundRepeatX, *values[i], important);
1684 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once 1682 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once
1685 addProperty(CSSPropertyBackgroundRepeatY, repeatYValue.release(), im portant); 1683 addProperty(CSSPropertyBackgroundRepeatY, *repeatYValue, important);
1686 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) { 1684 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) {
1687 addProperty(CSSPropertyWebkitMaskRepeatX, values[i].release(), impor tant); 1685 addProperty(CSSPropertyWebkitMaskRepeatX, *values[i], important);
1688 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once 1686 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once
1689 addProperty(CSSPropertyWebkitMaskRepeatY, repeatYValue.release(), im portant); 1687 addProperty(CSSPropertyWebkitMaskRepeatY, *repeatYValue, important);
1690 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip) 1688 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip)
1691 // Value is already set while updating origin 1689 // Value is already set while updating origin
1692 continue; 1690 continue;
1693 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i ] && m_context.useLegacyBackgroundSizeShorthandBehavior()) 1691 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i ] && m_context.useLegacyBackgroundSizeShorthandBehavior())
1694 continue; 1692 continue;
1695 else 1693 else
1696 addProperty(properties[i], values[i].release(), important); 1694 addProperty(properties[i], *values[i], important);
1697 1695
1698 // Add in clip values when we hit the corresponding origin property. 1696 // Add in clip values when we hit the corresponding origin property.
1699 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) 1697 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip)
1700 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan t); 1698 addProperty(CSSPropertyBackgroundClip, *clipValue, important);
1701 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) 1699 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip)
1702 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan t); 1700 addProperty(CSSPropertyWebkitMaskClip, *clipValue, important);
1703 } 1701 }
1704 1702
1705 m_implicitShorthand = false; 1703 m_implicitShorthand = false;
1706 return true; 1704 return true;
1707 } 1705 }
1708 1706
1709 static bool isValidTransitionPropertyList(CSSValueList* value) 1707 static bool isValidTransitionPropertyList(CSSValueList* value)
1710 { 1708 {
1711 if (value->length() < 2) 1709 if (value->length() < 2)
1712 return true; 1710 return true;
1713 for (auto& property : *value) { 1711 for (auto& property : *value) {
1714 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip 1712 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip
1715 if (property->isInitialValue()) 1713 if (property.isInitialValue())
1716 continue; 1714 continue;
1717 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(property.get()); 1715 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(property);
1718 if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSVa lueNone) 1716 if (primitiveValue.isValueID() && primitiveValue.getValueID() == CSSValu eNone)
1719 return false; 1717 return false;
1720 } 1718 }
1721 return true; 1719 return true;
1722 } 1720 }
1723 1721
1724 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant) 1722 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant)
1725 { 1723 {
1726 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing(); 1724 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing();
1727 const unsigned numProperties = 8; 1725 const unsigned numProperties = 8;
1728 1726
(...skipping 19 matching lines...) Expand all
1748 parsedProperty[i] = false; 1746 parsedProperty[i] = false;
1749 } 1747 }
1750 if (!m_valueList->current()) 1748 if (!m_valueList->current())
1751 break; 1749 break;
1752 } 1750 }
1753 1751
1754 bool found = false; 1752 bool found = false;
1755 for (size_t i = 0; i < numProperties; ++i) { 1753 for (size_t i = 0; i < numProperties; ++i) {
1756 if (parsedProperty[i]) 1754 if (parsedProperty[i])
1757 continue; 1755 continue;
1758 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(animat ionProperties.properties()[i], useLegacyparsing)) { 1756 if (NullableCSSValue val = parseAnimationProperty(animationPropertie s.properties()[i], useLegacyparsing)) {
1759 parsedProperty[i] = found = true; 1757 parsedProperty[i] = found = true;
1760 values[i]->append(val.release()); 1758 values[i]->append(*val);
1761 break; 1759 break;
1762 } 1760 }
1763 } 1761 }
1764 1762
1765 // if we didn't find at least one match, this is an 1763 // if we didn't find at least one match, this is an
1766 // invalid shorthand and we have to ignore it 1764 // invalid shorthand and we have to ignore it
1767 if (!found) 1765 if (!found)
1768 return false; 1766 return false;
1769 } 1767 }
1770 1768
(...skipping 30 matching lines...) Expand all
1801 parsedProperty[i] = false; 1799 parsedProperty[i] = false;
1802 } 1800 }
1803 if (!m_valueList->current()) 1801 if (!m_valueList->current())
1804 break; 1802 break;
1805 } 1803 }
1806 1804
1807 bool found = false; 1805 bool found = false;
1808 for (size_t i = 0; i < numProperties; ++i) { 1806 for (size_t i = 0; i < numProperties; ++i) {
1809 if (parsedProperty[i]) 1807 if (parsedProperty[i])
1810 continue; 1808 continue;
1811 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(shorth and.properties()[i], false)) { 1809 if (NullableCSSValue val = parseAnimationProperty(shorthand.properti es()[i], false)) {
1812 parsedProperty[i] = found = true; 1810 parsedProperty[i] = found = true;
1813 values[i]->append(val.release()); 1811 values[i]->append(*val);
1814 break; 1812 break;
1815 } 1813 }
1816 } 1814 }
1817 1815
1818 // if we didn't find at least one match, this is an 1816 // if we didn't find at least one match, this is an
1819 // invalid shorthand and we have to ignore it 1817 // invalid shorthand and we have to ignore it
1820 if (!found) 1818 if (!found)
1821 return false; 1819 return false;
1822 } 1820 }
1823 1821
1824 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); 1822 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty);
1825 if (!isValidTransitionPropertyList(values[3].get())) 1823 if (!isValidTransitionPropertyList(values[3].get()))
1826 return false; 1824 return false;
1827 1825
1828 // Fill in any remaining properties with the initial value and add 1826 // Fill in any remaining properties with the initial value and add
1829 for (size_t i = 0; i < numProperties; ++i) { 1827 for (size_t i = 0; i < numProperties; ++i) {
1830 if (!parsedProperty[i]) 1828 if (!parsedProperty[i])
1831 values[i]->append(cssValuePool().createImplicitInitialValue()); 1829 values[i]->append(cssValuePool().createImplicitInitialValue());
1832 addProperty(shorthand.properties()[i], values[i].release(), important); 1830 addProperty(shorthand.properties()[i], values[i].release(), important);
1833 } 1831 }
1834 1832
1835 return true; 1833 return true;
1836 } 1834 }
1837 1835
1838 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() 1836 NullableCSSValue CSSPropertyParser::parseColumnWidth()
1839 { 1837 {
1840 CSSParserValue* value = m_valueList->current(); 1838 CSSParserValue* value = m_valueList->current();
1841 // Always parse lengths in strict mode here, since it would be ambiguous oth erwise when used in 1839 // Always parse lengths in strict mode here, since it would be ambiguous oth erwise when used in
1842 // the 'columns' shorthand property. 1840 // the 'columns' shorthand property.
1843 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt andardMode) && (m_parsedCalculation || value->fValue != 0))) { 1841 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt andardMode) && (m_parsedCalculation || value->fValue != 0))) {
1844 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id , value); 1842 CSSValue parsedValue = parseValidPrimitive(value->id, value);
1845 m_valueList->next(); 1843 m_valueList->next();
1846 return parsedValue; 1844 return parsedValue;
1847 } 1845 }
1848 return nullptr; 1846 return nullptr;
1849 } 1847 }
1850 1848
1851 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() 1849 NullableCSSValue CSSPropertyParser::parseColumnCount()
1852 { 1850 {
1853 CSSParserValue* value = m_valueList->current(); 1851 CSSParserValue* value = m_valueList->current();
1854 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { 1852 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) {
1855 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id , value); 1853 CSSValue parsedValue = parseValidPrimitive(value->id, value);
1856 m_valueList->next(); 1854 m_valueList->next();
1857 return parsedValue; 1855 return parsedValue;
1858 } 1856 }
1859 return nullptr; 1857 return nullptr;
1860 } 1858 }
1861 1859
1862 bool CSSPropertyParser::parseColumnsShorthand(bool important) 1860 bool CSSPropertyParser::parseColumnsShorthand(bool important)
1863 { 1861 {
1864 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; 1862 NullableCSSValue columnWidth;
1865 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; 1863 NullableCSSValue columnCount;
1866 bool hasPendingExplicitAuto = false; 1864 bool hasPendingExplicitAuto = false;
1867 1865
1868 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) { 1866 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) {
1869 if (propertiesParsed >= 2) 1867 if (propertiesParsed >= 2)
1870 return false; // Too many values for this shorthand. Invalid declara tion. 1868 return false; // Too many values for this shorthand. Invalid declara tion.
1871 if (!propertiesParsed && value->id == CSSValueAuto) { 1869 if (!propertiesParsed && value->id == CSSValueAuto) {
1872 // 'auto' is a valid value for any of the two longhands, and at this point we 1870 // 'auto' is a valid value for any of the two longhands, and at this point we
1873 // don't know which one(s) it is meant for. We need to see if there are other 1871 // don't know which one(s) it is meant for. We need to see if there are other
1874 // values first. 1872 // values first.
1875 m_valueList->next(); 1873 m_valueList->next();
(...skipping 21 matching lines...) Expand all
1897 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); 1895 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto);
1898 } else { 1896 } else {
1899 ASSERT(!columnCount); 1897 ASSERT(!columnCount);
1900 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); 1898 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto);
1901 } 1899 }
1902 } 1900 }
1903 ASSERT(columnCount || columnWidth); 1901 ASSERT(columnCount || columnWidth);
1904 1902
1905 // Any unassigned property at this point will become implicit 'auto'. 1903 // Any unassigned property at this point will become implicit 'auto'.
1906 if (columnWidth) 1904 if (columnWidth)
1907 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); 1905 addProperty(CSSPropertyWebkitColumnWidth, *columnWidth, important);
1908 else 1906 else
1909 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1907 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1910 if (columnCount) 1908 if (columnCount)
1911 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); 1909 addProperty(CSSPropertyWebkitColumnCount, *columnCount, important);
1912 else 1910 else
1913 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1911 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1914 return true; 1912 return true;
1915 } 1913 }
1916 1914
1917 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important) 1915 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important)
1918 { 1916 {
1919 // We try to match as many properties as possible 1917 // We try to match as many properties as possible
1920 // We set up an array of booleans to mark which property has been found, 1918 // We set up an array of booleans to mark which property has been found,
1921 // and we try to search for properties until it makes no longer any sense. 1919 // 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
1973 1971
1974 int num = inShorthand() ? 1 : m_valueList->size(); 1972 int num = inShorthand() ? 1 : m_valueList->size();
1975 1973
1976 ShorthandScope scope(this, propId); 1974 ShorthandScope scope(this, propId);
1977 1975
1978 // the order is top, right, bottom, left 1976 // the order is top, right, bottom, left
1979 switch (num) { 1977 switch (num) {
1980 case 1: { 1978 case 1: {
1981 if (!parseValue(properties[0], important)) 1979 if (!parseValue(properties[0], important))
1982 return false; 1980 return false;
1983 CSSValue* value = m_parsedProperties.last().value(); 1981 CSSValue value = m_parsedProperties.last().value();
1984 ImplicitScope implicitScope(this); 1982 ImplicitScope implicitScope(this);
1985 addProperty(properties[1], value, important); 1983 addProperty(properties[1], value, important);
1986 addProperty(properties[2], value, important); 1984 addProperty(properties[2], value, important);
1987 addProperty(properties[3], value, important); 1985 addProperty(properties[3], value, important);
1988 break; 1986 break;
1989 } 1987 }
1990 case 2: { 1988 case 2: {
1991 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important)) 1989 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important))
1992 return false; 1990 return false;
1993 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2]. value(); 1991 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue();
1994 ImplicitScope implicitScope(this); 1992 ImplicitScope implicitScope(this);
1995 addProperty(properties[2], value, important); 1993 addProperty(properties[2], value, important);
1996 value = m_parsedProperties[m_parsedProperties.size() - 2].value(); 1994 value = m_parsedProperties[m_parsedProperties.size() - 2].value();
1997 addProperty(properties[3], value, important); 1995 addProperty(properties[3], value, important);
1998 break; 1996 break;
1999 } 1997 }
2000 case 3: { 1998 case 3: {
2001 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important)) 1999 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important))
2002 return false; 2000 return false;
2003 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2]. value(); 2001 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue();
2004 ImplicitScope implicitScope(this); 2002 ImplicitScope implicitScope(this);
2005 addProperty(properties[3], value, important); 2003 addProperty(properties[3], value, important);
2006 break; 2004 break;
2007 } 2005 }
2008 case 4: { 2006 case 4: {
2009 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || 2007 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) ||
2010 !parseValue(properties[2], important) || !parseValue(properties[ 3], important)) 2008 !parseValue(properties[2], important) || !parseValue(properties[ 3], important))
2011 return false; 2009 return false;
2012 break; 2010 break;
2013 } 2011 }
2014 default: { 2012 default: {
2015 return false; 2013 return false;
2016 } 2014 }
2017 } 2015 }
2018 2016
2019 return true; 2017 return true;
2020 } 2018 }
2021 2019
2022 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() 2020 NullableCSSValue CSSPropertyParser::parseScrollSnapPoints()
2023 { 2021 {
2024 CSSParserValue* value = m_valueList->current(); 2022 CSSParserValue* value = m_valueList->current();
2025 2023
2026 if (value->id == CSSValueNone) { 2024 if (value->id == CSSValueNone) {
2027 m_valueList->next(); 2025 m_valueList->next();
2028 return cssValuePool().createIdentifierValue(CSSValueNone); 2026 return cssValuePool().createIdentifierValue(CSSValueNone);
2029 } 2027 }
2030 2028
2031 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) { 2029 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) {
2032 // The spec defines the following grammar: repeat( <length>) 2030 // The spec defines the following grammar: repeat( <length>)
2033 CSSParserValueList* arguments = value->function->args.get(); 2031 CSSParserValueList* arguments = value->function->args.get();
2034 if (!arguments || arguments->size() != 1) 2032 if (!arguments || arguments->size() != 1)
2035 return nullptr; 2033 return nullptr;
2036 2034
2037 CSSParserValue* repeatValue = arguments->valueAt(0); 2035 CSSParserValue* repeatValue = arguments->valueAt(0);
2038 if (!validUnit(repeatValue, FNonNeg | FLength | FPercent)) 2036 if (!validUnit(repeatValue, FNonNeg | FLength | FPercent))
2039 return nullptr; 2037 return nullptr;
2040 2038
2041 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueRepeat); 2039 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueRepeat);
2042 result->append(parseValidPrimitive(repeatValue->id, repeatValue)); 2040 result->append(parseValidPrimitive(repeatValue->id, repeatValue));
2043 m_valueList->next(); 2041 m_valueList->next();
2044 return result.release(); 2042 return result.release();
2045 } 2043 }
2046 2044
2047 return nullptr; 2045 return nullptr;
2048 } 2046 }
2049 2047
2050 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() 2048 NullableCSSValue CSSPropertyParser::parseScrollSnapCoordinate()
2051 { 2049 {
2052 if (m_valueList->current()->id == CSSValueNone) { 2050 if (m_valueList->current()->id == CSSValueNone) {
2053 m_valueList->next(); 2051 m_valueList->next();
2054 return cssValuePool().createIdentifierValue(CSSValueNone); 2052 return cssValuePool().createIdentifierValue(CSSValueNone);
2055 } 2053 }
2056 2054
2057 return parsePositionList(m_valueList); 2055 return parsePositionList(m_valueList);
2058 } 2056 }
2059 2057
2060 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() 2058 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage()
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 parsedValues->append(createPrimitiveNumericValue(value)); 2128 parsedValues->append(createPrimitiveNumericValue(value));
2131 return Length; 2129 return Length;
2132 } 2130 }
2133 return None; 2131 return None;
2134 default: 2132 default:
2135 return None; 2133 return None;
2136 } 2134 }
2137 } 2135 }
2138 2136
2139 // [ <string> <string> ]+ | none, but none is handled in parseValue 2137 // [ <string> <string> ]+ | none, but none is handled in parseValue
2140 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() 2138 NullableCSSValue CSSPropertyParser::parseQuotes()
2141 { 2139 {
2142 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 2140 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
2143 while (CSSParserValue* val = m_valueList->current()) { 2141 while (CSSParserValue* val = m_valueList->current()) {
2144 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 2142 NullableCSSValue parsedValue;
2145 if (val->unit != CSSPrimitiveValue::CSS_STRING) 2143 if (val->unit != CSSPrimitiveValue::CSS_STRING)
2146 return nullptr; 2144 return nullptr;
2147 parsedValue = createPrimitiveStringValue(val); 2145 parsedValue = createPrimitiveStringValue(val);
2148 values->append(parsedValue.release()); 2146 values->append(*parsedValue);
2149 m_valueList->next(); 2147 m_valueList->next();
2150 } 2148 }
2151 if (values->length() && values->length() % 2 == 0) 2149 if (values->length() && values->length() % 2 == 0)
2152 return values.release(); 2150 return values.release();
2153 return nullptr; 2151 return nullptr;
2154 } 2152 }
2155 2153
2156 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit 2154 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit
2157 // in CSS 2.1 this got somewhat reduced: 2155 // in CSS 2.1 this got somewhat reduced:
2158 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit 2156 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit
2159 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() 2157 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent()
2160 { 2158 {
2161 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 2159 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
2162 2160
2163 while (CSSParserValue* val = m_valueList->current()) { 2161 while (CSSParserValue* val = m_valueList->current()) {
2164 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 2162 NullableCSSValue parsedValue;
2165 if (val->unit == CSSPrimitiveValue::CSS_URI) { 2163 if (val->unit == CSSPrimitiveValue::CSS_URI) {
2166 // url 2164 // url
2167 parsedValue = createCSSImageValueWithReferrer(val->string, completeU RL(val->string)); 2165 parsedValue = createCSSImageValueWithReferrer(val->string, completeU RL(val->string));
2168 } else if (val->unit == CSSParserValue::Function) { 2166 } else if (val->unit == CSSParserValue::Function) {
2169 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...) 2167 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...)
2170 CSSParserValueList* args = val->function->args.get(); 2168 CSSParserValueList* args = val->function->args.get();
2171 if (!args) 2169 if (!args)
2172 return nullptr; 2170 return nullptr;
2173 if (val->function->id == CSSValueAttr) { 2171 if (val->function->id == CSSValueAttr) {
2174 parsedValue = parseAttr(args); 2172 parsedValue = parseAttr(args);
(...skipping 17 matching lines...) Expand all
2192 case CSSValueNormal: 2190 case CSSValueNormal:
2193 parsedValue = cssValuePool().createIdentifierValue(val->id); 2191 parsedValue = cssValuePool().createIdentifierValue(val->id);
2194 default: 2192 default:
2195 break; 2193 break;
2196 } 2194 }
2197 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { 2195 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
2198 parsedValue = createPrimitiveStringValue(val); 2196 parsedValue = createPrimitiveStringValue(val);
2199 } 2197 }
2200 if (!parsedValue) 2198 if (!parsedValue)
2201 return nullptr; 2199 return nullptr;
2202 values->append(parsedValue.release()); 2200 values->append(*parsedValue);
2203 m_valueList->next(); 2201 m_valueList->next();
2204 } 2202 }
2205 2203
2206 return values.release(); 2204 return values.release();
2207 } 2205 }
2208 2206
2209 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList * args) 2207 NullableCSSValue CSSPropertyParser::parseAttr(CSSParserValueList* args)
2210 { 2208 {
2211 if (args->size() != 1) 2209 if (args->size() != 1)
2212 return nullptr; 2210 return nullptr;
2213 2211
2214 CSSParserValue* a = args->current(); 2212 CSSParserValue* a = args->current();
2215 2213
2216 if (a->unit != CSSPrimitiveValue::CSS_IDENT) 2214 if (a->unit != CSSPrimitiveValue::CSS_IDENT)
2217 return nullptr; 2215 return nullptr;
2218 2216
2219 String attrName = a->string; 2217 String attrName = a->string;
2220 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". 2218 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image".
2221 // But HTML attribute names can't have those characters, and we should not 2219 // But HTML attribute names can't have those characters, and we should not
2222 // even parse them inside attr(). 2220 // even parse them inside attr().
2223 if (attrName[0] == '-') 2221 if (attrName[0] == '-')
2224 return nullptr; 2222 return nullptr;
2225 2223
2226 if (m_context.isHTMLDocument()) 2224 if (m_context.isHTMLDocument())
2227 attrName = attrName.lower(); 2225 attrName = attrName.lower();
2228 2226
2229 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); 2227 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR);
2230 } 2228 }
2231 2229
2232 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBackgroundColor() 2230 NullableCSSValue CSSPropertyParser::parseBackgroundColor()
2233 { 2231 {
2234 CSSValueID id = m_valueList->current()->id; 2232 CSSValueID id = m_valueList->current()->id;
2235 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt ext) || id == CSSValueMenu || id == CSSValueCurrentcolor || 2233 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt ext) || id == CSSValueMenu || id == CSSValueCurrentcolor ||
2236 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode())) 2234 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode()))
2237 return cssValuePool().createIdentifierValue(id); 2235 return cssValuePool().createIdentifierValue(id);
2238 return parseColor(); 2236 return parseColor();
2239 } 2237 }
2240 2238
2241 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& value) 2239 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, NullableCS SValue& value)
2242 { 2240 {
2243 if (valueList->current()->id == CSSValueNone) { 2241 if (valueList->current()->id == CSSValueNone) {
2244 value = cssValuePool().createIdentifierValue(CSSValueNone); 2242 value = cssValuePool().createIdentifierValue(CSSValueNone);
2245 return true; 2243 return true;
2246 } 2244 }
2247 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { 2245 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
2248 value = createCSSImageValueWithReferrer(valueList->current()->string, co mpleteURL(valueList->current()->string)); 2246 value = createCSSImageValueWithReferrer(valueList->current()->string, co mpleteURL(valueList->current()->string));
2249 return true; 2247 return true;
2250 } 2248 }
2251 2249
2252 if (isGeneratedImageValue(valueList->current())) 2250 if (isGeneratedImageValue(valueList->current()))
2253 return parseGeneratedImage(valueList, value); 2251 return parseGeneratedImage(valueList, value);
2254 2252
2255 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur rent()->function->id == CSSValueWebkitImageSet) { 2253 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur rent()->function->id == CSSValueWebkitImageSet) {
2256 value = parseImageSet(m_valueList); 2254 value = parseImageSet(m_valueList);
2257 if (value) 2255 if (value)
2258 return true; 2256 return true;
2259 } 2257 }
2260 2258
2261 return false; 2259 return false;
2262 } 2260 }
2263 2261
2264 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser ValueList* valueList) 2262 NullableCSSValue CSSPropertyParser::parseFillPositionX(CSSParserValueList* value List)
2265 { 2263 {
2266 int id = valueList->current()->id; 2264 int id = valueList->current()->id;
2267 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { 2265 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) {
2268 int percent = 0; 2266 int percent = 0;
2269 if (id == CSSValueRight) 2267 if (id == CSSValueRight)
2270 percent = 100; 2268 percent = 100;
2271 else if (id == CSSValueCenter) 2269 else if (id == CSSValueCenter)
2272 percent = 50; 2270 percent = 50;
2273 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE); 2271 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE);
2274 } 2272 }
2275 if (validUnit(valueList->current(), FPercent | FLength)) 2273 if (validUnit(valueList->current(), FPercent | FLength))
2276 return createPrimitiveNumericValue(valueList->current()); 2274 return createPrimitiveNumericValue(valueList->current());
2277 return nullptr; 2275 return nullptr;
2278 } 2276 }
2279 2277
2280 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser ValueList* valueList) 2278 NullableCSSValue CSSPropertyParser::parseFillPositionY(CSSParserValueList* value List)
2281 { 2279 {
2282 int id = valueList->current()->id; 2280 int id = valueList->current()->id;
2283 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { 2281 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) {
2284 int percent = 0; 2282 int percent = 0;
2285 if (id == CSSValueBottom) 2283 if (id == CSSValueBottom)
2286 percent = 100; 2284 percent = 100;
2287 else if (id == CSSValueCenter) 2285 else if (id == CSSValueCenter)
2288 percent = 50; 2286 percent = 50;
2289 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE); 2287 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE);
2290 } 2288 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 return true; 2349 return true;
2352 2350
2353 return false; 2351 return false;
2354 } 2352 }
2355 2353
2356 static bool isFillPositionKeyword(CSSValueID value) 2354 static bool isFillPositionKeyword(CSSValueID value)
2357 { 2355 {
2358 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter; 2356 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter;
2359 } 2357 }
2360 2358
2361 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2359 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu e2)
2362 { 2360 {
2363 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ] 2361 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ]
2364 // In the case of 4 values <position> requires the second value to be a leng th or a percentage. 2362 // In the case of 4 values <position> requires the second value to be a leng th or a percentage.
2365 if (isFillPositionKeyword(parsedValue2->getValueID())) 2363 if (isFillPositionKeyword(parsedValue2->getValueID()))
2366 return; 2364 return;
2367 2365
2368 unsigned cumulativeFlags = 0; 2366 unsigned cumulativeFlags = 0;
2369 FillPositionFlag value3Flag = InvalidFillPosition; 2367 FillPositionFlag value3Flag = InvalidFillPosition;
2370 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); 2368 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword);
2371 if (!value3) 2369 if (!value3)
(...skipping 27 matching lines...) Expand all
2399 return; 2397 return;
2400 2398
2401 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); 2399 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2);
2402 value2 = createPrimitiveValuePair(value3, value4); 2400 value2 = createPrimitiveValuePair(value3, value4);
2403 2401
2404 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) 2402 if (ident1 == CSSValueTop || ident1 == CSSValueBottom)
2405 value1.swap(value2); 2403 value1.swap(value2);
2406 2404
2407 valueList->next(); 2405 valueList->next();
2408 } 2406 }
2409 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2407 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu e2)
2410 { 2408 {
2411 unsigned cumulativeFlags = 0; 2409 unsigned cumulativeFlags = 0;
2412 FillPositionFlag value3Flag = InvalidFillPosition; 2410 FillPositionFlag value3Flag = InvalidFillPosition;
2413 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); 2411 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword);
2414 2412
2415 // value3 is not an expected value, we return. 2413 // value3 is not an expected value, we return.
2416 if (!value3) 2414 if (!value3)
2417 return; 2415 return;
2418 2416
2419 valueList->next(); 2417 valueList->next();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 return; 2479 return;
2482 2480
2483 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); 2481 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue);
2484 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue); 2482 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue);
2485 } 2483 }
2486 2484
2487 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) 2485 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded)
2488 value1.swap(value2); 2486 value1.swap(value2);
2489 2487
2490 #if ENABLE(ASSERT) 2488 #if ENABLE(ASSERT)
2491 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); 2489 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1);
2492 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); 2490 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2);
2493 ident1 = first->getPairValue()->first()->getValueID(); 2491 ident1 = first->getPairValue()->first()->getValueID();
2494 ident2 = second->getPairValue()->first()->getValueID(); 2492 ident2 = second->getPairValue()->first()->getValueID();
2495 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); 2493 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight);
2496 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); 2494 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop);
2497 #endif 2495 #endif
2498 } 2496 }
2499 2497
2500 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) 2498 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value)
2501 { 2499 {
2502 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue); 2500 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue);
2503 } 2501 }
2504 2502
2505 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl ess) 2503 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, Nullabl eCSSValue& value1, NullableCSSValue& value2, Units unitless)
2506 { 2504 {
2507 unsigned numberOfValues = 0; 2505 unsigned numberOfValues = 0;
2508 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n umberOfValues) { 2506 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n umberOfValues) {
2509 CSSParserValue* current = valueList->valueAt(i); 2507 CSSParserValue* current = valueList->valueAt(i);
2510 if (!current || isComma(current) || isForwardSlashOperator(current) || ! isPotentialPositionValue(current)) 2508 if (!current || isComma(current) || isForwardSlashOperator(current) || ! isPotentialPositionValue(current))
2511 break; 2509 break;
2512 } 2510 }
2513 2511
2514 if (numberOfValues > 4) 2512 if (numberOfValues > 4)
2515 return; 2513 return;
(...skipping 22 matching lines...) Expand all
2538 2536
2539 valueList->next(); 2537 valueList->next();
2540 2538
2541 // In case we are parsing more than two values, relax the check inside of pa rseFillPositionComponent. top 20px is 2539 // In case we are parsing more than two values, relax the check inside of pa rseFillPositionComponent. top 20px is
2542 // a valid start for <position>. 2540 // a valid start for <position>.
2543 cumulativeFlags = AmbiguousFillPosition; 2541 cumulativeFlags = AmbiguousFillPosition;
2544 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword); 2542 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword);
2545 if (value2) 2543 if (value2)
2546 valueList->next(); 2544 valueList->next();
2547 else { 2545 else {
2548 value1.clear(); 2546 value1 = nullptr;
2549 return; 2547 return;
2550 } 2548 }
2551 2549
2552 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val ue1.get()); 2550 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val ue1);
2553 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val ue2.get()); 2551 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val ue2);
2554 2552
2555 value1.clear(); 2553 value1 = nullptr;
2556 value2.clear(); 2554 value2 = nullptr;
2557 2555
2558 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow. 2556 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow.
2559 if (parsedValue2->getValueID() == CSSValueCenter) 2557 if (parsedValue2->getValueID() == CSSValueCenter)
2560 return; 2558 return;
2561 2559
2562 if (numberOfValues == 3) 2560 if (numberOfValues == 3)
2563 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release (), parsedValue2.release()); 2561 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed Value2);
2564 else 2562 else
2565 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release (), parsedValue2.release()); 2563 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed Value2);
2566 } 2564 }
2567 2565
2568 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Unit s unitless) 2566 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, Units unitless)
2569 { 2567 {
2570 // Parse the first value. We're just making sure that it is one of the vali d keywords or a percentage/length. 2568 // Parse the first value. We're just making sure that it is one of the vali d keywords or a percentage/length.
2571 unsigned cumulativeFlags = 0; 2569 unsigned cumulativeFlags = 0;
2572 FillPositionFlag value1Flag = InvalidFillPosition; 2570 FillPositionFlag value1Flag = InvalidFillPosition;
2573 FillPositionFlag value2Flag = InvalidFillPosition; 2571 FillPositionFlag value2Flag = InvalidFillPosition;
2574 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag, ResolveValuesAsPercent, unitless); 2572 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag, ResolveValuesAsPercent, unitless);
2575 if (!value1) 2573 if (!value1)
2576 return; 2574 return;
2577 2575
2578 // It only takes one value for background-position to be correctly parsed if it was specified in a shorthand (since we 2576 // It only takes one value for background-position to be correctly parsed if it was specified in a shorthand (since we
2579 // can assume that any other values belong to the rest of the shorthand). I f we're not parsing a shorthand, though, the 2577 // can assume that any other values belong to the rest of the shorthand). I f we're not parsing a shorthand, though, the
2580 // value was explicitly specified for our property. 2578 // value was explicitly specified for our property.
2581 CSSParserValue* value = valueList->next(); 2579 CSSParserValue* value = valueList->next();
2582 2580
2583 // First check for the comma. If so, we are finished parsing this value or value pair. 2581 // First check for the comma. If so, we are finished parsing this value or value pair.
2584 if (value && isComma(value)) 2582 if (value && isComma(value))
2585 value = 0; 2583 value = 0;
2586 2584
2587 if (value) { 2585 if (value) {
2588 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl ag, ResolveValuesAsPercent, unitless); 2586 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl ag, ResolveValuesAsPercent, unitless);
2589 if (value2) 2587 if (value2)
2590 valueList->next(); 2588 valueList->next();
2591 else { 2589 else {
2592 if (!inShorthand()) { 2590 if (!inShorthand()) {
2593 value1.clear(); 2591 value1 = nullptr;
2594 return; 2592 return;
2595 } 2593 }
2596 } 2594 }
2597 } 2595 }
2598 2596
2599 if (!value2) 2597 if (!value2)
2600 // Only one value was specified. If that value was not a keyword, then i t sets the x position, and the y position 2598 // Only one value was specified. If that value was not a keyword, then i t sets the x position, and the y position
2601 // is simply 50%. This is our default. 2599 // is simply 50%. This is our default.
2602 // For keywords, the keyword was either an x-keyword (left/right), a y-k eyword (top/bottom), or an ambiguous keyword (center). 2600 // For keywords, the keyword was either an x-keyword (left/right), a y-k eyword (top/bottom), or an ambiguous keyword (center).
2603 // For left/right/center, the default of 50% in the y is still correct. 2601 // For left/right/center, the default of 50% in the y is still correct.
2604 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG E); 2602 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG E);
2605 2603
2606 if (value1Flag == YFillPosition || value2Flag == XFillPosition) 2604 if (value1Flag == YFillPosition || value2Flag == XFillPosition)
2607 value1.swap(value2); 2605 value1.swap(value2);
2608 } 2606 }
2609 2607
2610 void CSSPropertyParser::parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>& value1, Re fPtrWillBeRawPtr<CSSValue>& value2) 2608 void CSSPropertyParser::parseFillRepeat(NullableCSSValue& value1, NullableCSSVal ue& value2)
2611 { 2609 {
2612 CSSValueID id = m_valueList->current()->id; 2610 CSSValueID id = m_valueList->current()->id;
2613 if (id == CSSValueRepeatX) { 2611 if (id == CSSValueRepeatX) {
2614 m_implicitShorthand = true; 2612 m_implicitShorthand = true;
2615 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); 2613 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat);
2616 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); 2614 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
2617 m_valueList->next(); 2615 m_valueList->next();
2618 return; 2616 return;
2619 } 2617 }
2620 if (id == CSSValueRepeatY) { 2618 if (id == CSSValueRepeatY) {
(...skipping 17 matching lines...) Expand all
2638 id = value->id; 2636 id = value->id;
2639 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun d || id == CSSValueSpace) { 2637 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun d || id == CSSValueSpace) {
2640 value2 = cssValuePool().createIdentifierValue(id); 2638 value2 = cssValuePool().createIdentifierValue(id);
2641 m_valueList->next(); 2639 m_valueList->next();
2642 return; 2640 return;
2643 } 2641 }
2644 } 2642 }
2645 2643
2646 // If only one value was specified, value2 is the same as value1. 2644 // If only one value was specified, value2 is the same as value1.
2647 m_implicitShorthand = true; 2645 m_implicitShorthand = true;
2648 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get ())->getValueID()); 2646 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1)->g etValueID());
2649 } 2647 }
2650 2648
2651 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProperty) 2649 NullableCSSValue CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProper ty)
2652 { 2650 {
2653 CSSParserValue* value = m_valueList->current(); 2651 CSSParserValue* value = m_valueList->current();
2654 m_valueList->next(); 2652 m_valueList->next();
2655 2653
2656 if (value->id == CSSValueContain || value->id == CSSValueCover) 2654 if (value->id == CSSValueContain || value->id == CSSValueCover)
2657 return cssValuePool().createIdentifierValue(value->id); 2655 return cssValuePool().createIdentifierValue(value->id);
2658 2656
2659 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr; 2657 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr;
2660 2658
2661 if (value->id == CSSValueAuto) 2659 if (value->id == CSSValueAuto)
(...skipping 21 matching lines...) Expand all
2683 parsedValue2 = parsedValue1; 2681 parsedValue2 = parsedValue1;
2684 } 2682 }
2685 2683
2686 if (!parsedValue2) 2684 if (!parsedValue2)
2687 return parsedValue1; 2685 return parsedValue1;
2688 2686
2689 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues); 2687 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues);
2690 } 2688 }
2691 2689
2692 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, 2690 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2,
2693 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa lue2) 2691 NullableCSSValue& retValue1, NullableCSSValue& retValue2)
2694 { 2692 {
2695 // We initially store the first value in value/value2, and only create 2693 // We initially store the first value in value/value2, and only create
2696 // CSSValueLists if we have more values. 2694 // CSSValueLists if we have more values.
2697 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; 2695 RefPtrWillBeRawPtr<CSSValueList> values = nullptr;
2698 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; 2696 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr;
2699 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 2697 NullableCSSValue value;
2700 RefPtrWillBeRawPtr<CSSValue> value2 = nullptr; 2698 NullableCSSValue value2;
2701 2699
2702 retValue1 = retValue2 = nullptr; 2700 retValue1 = nullptr;
2701 retValue2 = nullptr;
2703 propId1 = resolveCSSPropertyID(propId); 2702 propId1 = resolveCSSPropertyID(propId);
2704 propId2 = propId1; 2703 propId2 = propId1;
2705 if (propId == CSSPropertyBackgroundPosition) { 2704 if (propId == CSSPropertyBackgroundPosition) {
2706 propId1 = CSSPropertyBackgroundPositionX; 2705 propId1 = CSSPropertyBackgroundPositionX;
2707 propId2 = CSSPropertyBackgroundPositionY; 2706 propId2 = CSSPropertyBackgroundPositionY;
2708 } else if (propId == CSSPropertyWebkitMaskPosition) { 2707 } else if (propId == CSSPropertyWebkitMaskPosition) {
2709 propId1 = CSSPropertyWebkitMaskPositionX; 2708 propId1 = CSSPropertyWebkitMaskPositionX;
2710 propId2 = CSSPropertyWebkitMaskPositionY; 2709 propId2 = CSSPropertyWebkitMaskPositionY;
2711 } else if (propId == CSSPropertyBackgroundRepeat) { 2710 } else if (propId == CSSPropertyBackgroundRepeat) {
2712 propId1 = CSSPropertyBackgroundRepeatX; 2711 propId1 = CSSPropertyBackgroundRepeatX;
2713 propId2 = CSSPropertyBackgroundRepeatY; 2712 propId2 = CSSPropertyBackgroundRepeatY;
2714 } else if (propId == CSSPropertyWebkitMaskRepeat) { 2713 } else if (propId == CSSPropertyWebkitMaskRepeat) {
2715 propId1 = CSSPropertyWebkitMaskRepeatX; 2714 propId1 = CSSPropertyWebkitMaskRepeatX;
2716 propId2 = CSSPropertyWebkitMaskRepeatY; 2715 propId2 = CSSPropertyWebkitMaskRepeatY;
2717 } 2716 }
2718 2717
2719 while (true) { 2718 while (true) {
2720 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; 2719 NullableCSSValue currValue;
2721 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; 2720 NullableCSSValue currValue2;
2722 2721
2723 Units unitless = FUnknown; 2722 Units unitless = FUnknown;
2724 CSSParserValue* val = m_valueList->current(); 2723 CSSParserValue* val = m_valueList->current();
2725 ASSERT(val); 2724 ASSERT(val);
2726 2725
2727 switch (propId) { 2726 switch (propId) {
2728 case CSSPropertyBackgroundColor: 2727 case CSSPropertyBackgroundColor:
2729 currValue = parseBackgroundColor(); 2728 currValue = parseBackgroundColor();
2730 if (currValue) 2729 if (currValue)
2731 m_valueList->next(); 2730 m_valueList->next();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 break; 2826 break;
2828 } 2827 }
2829 default: 2828 default:
2830 break; 2829 break;
2831 } 2830 }
2832 if (!currValue) 2831 if (!currValue)
2833 return false; 2832 return false;
2834 2833
2835 if (value && !values) { 2834 if (value && !values) {
2836 values = CSSValueList::createCommaSeparated(); 2835 values = CSSValueList::createCommaSeparated();
2837 values->append(value.release()); 2836 values->append(*value);
2838 } 2837 }
2839 2838
2840 if (value2 && !values2) { 2839 if (value2 && !values2) {
2841 values2 = CSSValueList::createCommaSeparated(); 2840 values2 = CSSValueList::createCommaSeparated();
2842 values2->append(value2.release()); 2841 values2->append(*value2);
2843 } 2842 }
2844 2843
2845 if (values) 2844 if (values)
2846 values->append(currValue.release()); 2845 values->append(*currValue);
2847 else 2846 else
2848 value = currValue.release(); 2847 value = currValue;
2849 if (currValue2) { 2848 if (currValue2) {
2850 if (values2) 2849 if (values2)
2851 values2->append(currValue2.release()); 2850 values2->append(*currValue2);
2852 else 2851 else
2853 value2 = currValue2.release(); 2852 value2 = currValue2;
2854 } 2853 }
2855 2854
2856 // When parsing any fill shorthand property, we let it handle building u p the lists for all 2855 // When parsing any fill shorthand property, we let it handle building u p the lists for all
2857 // properties. 2856 // properties.
2858 if (inShorthand()) 2857 if (inShorthand())
2859 break; 2858 break;
2860 2859
2861 if (!m_valueList->current()) 2860 if (!m_valueList->current())
2862 break; 2861 break;
2863 if (!consumeComma(m_valueList) || !m_valueList->current()) 2862 if (!consumeComma(m_valueList) || !m_valueList->current())
2864 return false; 2863 return false;
2865 } 2864 }
2866 2865
2867 if (values) { 2866 if (values) {
2868 ASSERT(values->length()); 2867 ASSERT(values->length());
2869 retValue1 = values.release(); 2868 retValue1 = values.release();
2870 if (values2) { 2869 if (values2) {
2871 ASSERT(values2->length()); 2870 ASSERT(values2->length());
2872 retValue2 = values2.release(); 2871 retValue2 = values2.release();
2873 } 2872 }
2874 } else { 2873 } else {
2875 ASSERT(value); 2874 ASSERT(value);
2876 retValue1 = value.release(); 2875 retValue1 = value;
2877 retValue2 = value2.release(); 2876 retValue2 = value2;
2878 } 2877 }
2879 2878
2880 return true; 2879 return true;
2881 } 2880 }
2882 2881
2883 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() 2882 NullableCSSValue CSSPropertyParser::parseAnimationDelay()
2884 { 2883 {
2885 CSSParserValue* value = m_valueList->current(); 2884 CSSParserValue* value = m_valueList->current();
2886 if (validUnit(value, FTime)) 2885 if (validUnit(value, FTime))
2887 return createPrimitiveNumericValue(value); 2886 return createPrimitiveNumericValue(value);
2888 return nullptr; 2887 return nullptr;
2889 } 2888 }
2890 2889
2891 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() 2890 NullableCSSValue CSSPropertyParser::parseAnimationDirection()
2892 { 2891 {
2893 CSSParserValue* value = m_valueList->current(); 2892 CSSParserValue* value = m_valueList->current();
2894 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse) 2893 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse)
2895 return cssValuePool().createIdentifierValue(value->id); 2894 return cssValuePool().createIdentifierValue(value->id);
2896 return nullptr; 2895 return nullptr;
2897 } 2896 }
2898 2897
2899 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() 2898 NullableCSSValue CSSPropertyParser::parseAnimationDuration()
2900 { 2899 {
2901 CSSParserValue* value = m_valueList->current(); 2900 CSSParserValue* value = m_valueList->current();
2902 if (validUnit(value, FTime | FNonNeg)) 2901 if (validUnit(value, FTime | FNonNeg))
2903 return createPrimitiveNumericValue(value); 2902 return createPrimitiveNumericValue(value);
2904 return nullptr; 2903 return nullptr;
2905 } 2904 }
2906 2905
2907 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() 2906 NullableCSSValue CSSPropertyParser::parseAnimationFillMode()
2908 { 2907 {
2909 CSSParserValue* value = m_valueList->current(); 2908 CSSParserValue* value = m_valueList->current();
2910 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth) 2909 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth)
2911 return cssValuePool().createIdentifierValue(value->id); 2910 return cssValuePool().createIdentifierValue(value->id);
2912 return nullptr; 2911 return nullptr;
2913 } 2912 }
2914 2913
2915 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount () 2914 NullableCSSValue CSSPropertyParser::parseAnimationIterationCount()
2916 { 2915 {
2917 CSSParserValue* value = m_valueList->current(); 2916 CSSParserValue* value = m_valueList->current();
2918 if (value->id == CSSValueInfinite) 2917 if (value->id == CSSValueInfinite)
2919 return cssValuePool().createIdentifierValue(value->id); 2918 return cssValuePool().createIdentifierValue(value->id);
2920 if (validUnit(value, FNumber | FNonNeg)) 2919 if (validUnit(value, FNumber | FNonNeg))
2921 return createPrimitiveNumericValue(value); 2920 return createPrimitiveNumericValue(value);
2922 return nullptr; 2921 return nullptr;
2923 } 2922 }
2924 2923
2925 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo wQuotedName) 2924 NullableCSSValue CSSPropertyParser::parseAnimationName(bool allowQuotedName)
2926 { 2925 {
2927 CSSParserValue* value = m_valueList->current(); 2926 CSSParserValue* value = m_valueList->current();
2928 2927
2929 if (value->id == CSSValueNone) 2928 if (value->id == CSSValueNone)
2930 return cssValuePool().createIdentifierValue(CSSValueNone); 2929 return cssValuePool().createIdentifierValue(CSSValueNone);
2931 2930
2932 if (value->unit == CSSPrimitiveValue::CSS_IDENT) 2931 if (value->unit == CSSPrimitiveValue::CSS_IDENT)
2933 return createPrimitiveCustomIdentValue(value); 2932 return createPrimitiveCustomIdentValue(value);
2934 2933
2935 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) { 2934 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) {
2936 // Legacy support for strings in prefixed animations 2935 // Legacy support for strings in prefixed animations
2937 if (m_context.useCounter()) 2936 if (m_context.useCounter())
2938 m_context.useCounter()->count(UseCounter::QuotedAnimationName); 2937 m_context.useCounter()->count(UseCounter::QuotedAnimationName);
2939 if (equalIgnoringCase(value->string, "none")) 2938 if (equalIgnoringCase(value->string, "none"))
2940 return cssValuePool().createIdentifierValue(CSSValueNone); 2939 return cssValuePool().createIdentifierValue(CSSValueNone);
2941 return createPrimitiveCustomIdentValue(value); 2940 return createPrimitiveCustomIdentValue(value);
2942 } 2941 }
2943 2942
2944 return nullptr; 2943 return nullptr;
2945 } 2944 }
2946 2945
2947 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() 2946 NullableCSSValue CSSPropertyParser::parseAnimationPlayState()
2948 { 2947 {
2949 CSSParserValue* value = m_valueList->current(); 2948 CSSParserValue* value = m_valueList->current();
2950 if (value->id == CSSValueRunning || value->id == CSSValuePaused) 2949 if (value->id == CSSValueRunning || value->id == CSSValuePaused)
2951 return cssValuePool().createIdentifierValue(value->id); 2950 return cssValuePool().createIdentifierValue(value->id);
2952 return nullptr; 2951 return nullptr;
2953 } 2952 }
2954 2953
2955 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() 2954 NullableCSSValue CSSPropertyParser::parseAnimationProperty()
2956 { 2955 {
2957 CSSParserValue* value = m_valueList->current(); 2956 CSSParserValue* value = m_valueList->current();
2958 if (value->unit != CSSPrimitiveValue::CSS_IDENT) 2957 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
2959 return nullptr; 2958 return nullptr;
2960 // Since all is valid css property keyword, cssPropertyID for all 2959 // Since all is valid css property keyword, cssPropertyID for all
2961 // returns non-null value. We need to check "all" before 2960 // returns non-null value. We need to check "all" before
2962 // cssPropertyID check. 2961 // cssPropertyID check.
2963 if (value->id == CSSValueAll) 2962 if (value->id == CSSValueAll)
2964 return cssValuePool().createIdentifierValue(CSSValueAll); 2963 return cssValuePool().createIdentifierValue(CSSValueAll);
2965 CSSPropertyID property = unresolvedCSSPropertyID(value->string); 2964 CSSPropertyID property = unresolvedCSSPropertyID(value->string);
(...skipping 14 matching lines...) Expand all
2980 if (!validUnit(v, FNumber)) 2979 if (!validUnit(v, FNumber))
2981 return false; 2980 return false;
2982 result = v->fValue; 2981 result = v->fValue;
2983 v = args->next(); 2982 v = args->next();
2984 if (!v) 2983 if (!v)
2985 // The last number in the function has no comma after it, so we're done. 2984 // The last number in the function has no comma after it, so we're done.
2986 return true; 2985 return true;
2987 return consumeComma(args); 2986 return consumeComma(args);
2988 } 2987 }
2989 2988
2990 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction () 2989 NullableCSSValue CSSPropertyParser::parseAnimationTimingFunction()
2991 { 2990 {
2992 CSSParserValue* value = m_valueList->current(); 2991 CSSParserValue* value = m_valueList->current();
2993 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut 2992 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
2994 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd 2993 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd
2995 || value->id == CSSValueStepMiddle) 2994 || value->id == CSSValueStepMiddle)
2996 return cssValuePool().createIdentifierValue(value->id); 2995 return cssValuePool().createIdentifierValue(value->id);
2997 2996
2998 // We must be a function. 2997 // We must be a function.
2999 if (value->unit != CSSParserValue::Function) 2998 if (value->unit != CSSParserValue::Function)
3000 return nullptr; 2999 return nullptr;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3061 return nullptr; 3060 return nullptr;
3062 if (!parseCubicBezierTimingFunctionValue(args, y2)) 3061 if (!parseCubicBezierTimingFunctionValue(args, y2))
3063 return nullptr; 3062 return nullptr;
3064 3063
3065 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); 3064 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2);
3066 } 3065 }
3067 3066
3068 return nullptr; 3067 return nullptr;
3069 } 3068 }
3070 3069
3071 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPr opertyID propId, bool useLegacyParsing) 3070 NullableCSSValue CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId, bool useLegacyParsing)
3072 { 3071 {
3073 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 3072 NullableCSSValue value;
3074 switch (propId) { 3073 switch (propId) {
3075 case CSSPropertyAnimationDelay: 3074 case CSSPropertyAnimationDelay:
3076 case CSSPropertyTransitionDelay: 3075 case CSSPropertyTransitionDelay:
3077 value = parseAnimationDelay(); 3076 value = parseAnimationDelay();
3078 break; 3077 break;
3079 case CSSPropertyAnimationDirection: 3078 case CSSPropertyAnimationDirection:
3080 value = parseAnimationDirection(); 3079 value = parseAnimationDirection();
3081 break; 3080 break;
3082 case CSSPropertyAnimationDuration: 3081 case CSSPropertyAnimationDuration:
3083 case CSSPropertyTransitionDuration: 3082 case CSSPropertyTransitionDuration:
(...skipping 18 matching lines...) Expand all
3102 case CSSPropertyTransitionTimingFunction: 3101 case CSSPropertyTransitionTimingFunction:
3103 value = parseAnimationTimingFunction(); 3102 value = parseAnimationTimingFunction();
3104 break; 3103 break;
3105 default: 3104 default:
3106 ASSERT_NOT_REACHED(); 3105 ASSERT_NOT_REACHED();
3107 return nullptr; 3106 return nullptr;
3108 } 3107 }
3109 3108
3110 if (value) 3109 if (value)
3111 m_valueList->next(); 3110 m_valueList->next();
3112 return value.release(); 3111 return value;
3113 } 3112 }
3114 3113
3115 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi st(CSSPropertyID propId, bool useLegacyParsing) 3114 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi st(CSSPropertyID propId, bool useLegacyParsing)
3116 { 3115 {
3117 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 3116 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
3118 while (true) { 3117 while (true) {
3119 RefPtrWillBeRawPtr<CSSValue> value = parseAnimationProperty(propId, useL egacyParsing); 3118 NullableCSSValue value = parseAnimationProperty(propId, useLegacyParsing );
3120 if (!value) 3119 if (!value)
3121 return nullptr; 3120 return nullptr;
3122 list->append(value.release()); 3121 list->append(*value);
3123 if (!m_valueList->current()) 3122 if (!m_valueList->current())
3124 break; 3123 break;
3125 if (!consumeComma(m_valueList) || !m_valueList->current()) 3124 if (!consumeComma(m_valueList) || !m_valueList->current())
3126 return nullptr; 3125 return nullptr;
3127 } 3126 }
3128 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get())) 3127 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get()))
3129 return nullptr; 3128 return nullptr;
3130 ASSERT(list->length()); 3129 ASSERT(list->length());
3131 return list.release(); 3130 return list.release();
3132 } 3131 }
(...skipping 29 matching lines...) Expand all
3162 if (value && validUnit(value, FInteger) && value->fValue) { 3161 if (value && validUnit(value, FInteger) && value->fValue) {
3163 numericValue = createPrimitiveNumericValue(value); 3162 numericValue = createPrimitiveNumericValue(value);
3164 m_valueList->next(); 3163 m_valueList->next();
3165 } 3164 }
3166 return true; 3165 return true;
3167 } 3166 }
3168 3167
3169 return false; 3168 return false;
3170 } 3169 }
3171 3170
3172 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition() 3171 NullableCSSValue CSSPropertyParser::parseGridPosition()
3173 { 3172 {
3174 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3173 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3175 3174
3176 CSSParserValue* value = m_valueList->current(); 3175 CSSParserValue* value = m_valueList->current();
3177 if (value->id == CSSValueAuto) { 3176 if (value->id == CSSValueAuto) {
3178 m_valueList->next(); 3177 m_valueList->next();
3179 return cssValuePool().createIdentifierValue(CSSValueAuto); 3178 return cssValuePool().createIdentifierValue(CSSValueAuto);
3180 } 3179 }
3181 3180
3182 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr; 3181 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 if (hasSeenSpanKeyword) 3217 if (hasSeenSpanKeyword)
3219 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); 3218 values->append(cssValuePool().createIdentifierValue(CSSValueSpan));
3220 if (numericValue) 3219 if (numericValue)
3221 values->append(numericValue.release()); 3220 values->append(numericValue.release());
3222 if (gridLineName) 3221 if (gridLineName)
3223 values->append(gridLineName.release()); 3222 values->append(gridLineName.release());
3224 ASSERT(values->length()); 3223 ASSERT(values->length());
3225 return values.release(); 3224 return values.release();
3226 } 3225 }
3227 3226
3228 static PassRefPtrWillBeRawPtr<CSSValue> gridMissingGridPositionValue(CSSValue* v alue) 3227 static CSSValue gridMissingGridPositionValue(CSSValue value)
3229 { 3228 {
3230 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isString()) 3229 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isString())
3231 return value; 3230 return value;
3232 3231
3233 return cssValuePool().createIdentifierValue(CSSValueAuto); 3232 return cssValuePool().createIdentifierValue(CSSValueAuto);
3234 } 3233 }
3235 3234
3236 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId , bool important) 3235 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId , bool important)
3237 { 3236 {
3238 ShorthandScope scope(this, shorthandId); 3237 ShorthandScope scope(this, shorthandId);
3239 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); 3238 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId);
3240 ASSERT(shorthand.length() == 2); 3239 ASSERT(shorthand.length() == 2);
3241 3240
3242 RefPtrWillBeRawPtr<CSSValue> startValue = parseGridPosition(); 3241 NullableCSSValue startValue = parseGridPosition();
3243 if (!startValue) 3242 if (!startValue)
3244 return false; 3243 return false;
3245 3244
3246 RefPtrWillBeRawPtr<CSSValue> endValue = nullptr; 3245 NullableCSSValue endValue;
3247 if (m_valueList->current()) { 3246 if (m_valueList->current()) {
3248 if (!isForwardSlashOperator(m_valueList->current())) 3247 if (!isForwardSlashOperator(m_valueList->current()))
3249 return false; 3248 return false;
3250 3249
3251 if (!m_valueList->next()) 3250 if (!m_valueList->next())
3252 return false; 3251 return false;
3253 3252
3254 endValue = parseGridPosition(); 3253 endValue = parseGridPosition();
3255 if (!endValue || m_valueList->current()) 3254 if (!endValue || m_valueList->current())
3256 return false; 3255 return false;
3257 } else { 3256 } else {
3258 endValue = gridMissingGridPositionValue(startValue.get()); 3257 endValue = gridMissingGridPositionValue(*startValue);
3259 } 3258 }
3260 3259
3261 addProperty(shorthand.properties()[0], startValue, important); 3260 addProperty(shorthand.properties()[0], *startValue, important);
3262 addProperty(shorthand.properties()[1], endValue, important); 3261 addProperty(shorthand.properties()[1], *endValue, important);
3263 return true; 3262 return true;
3264 } 3263 }
3265 3264
3266 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS Value> templateColumns, bool important) 3265 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(NullableCSSValue templateC olumns, bool important)
3267 { 3266 {
3268 NamedGridAreaMap gridAreaMap; 3267 NamedGridAreaMap gridAreaMap;
3269 size_t rowCount = 0; 3268 size_t rowCount = 0;
3270 size_t columnCount = 0; 3269 size_t columnCount = 0;
3271 bool trailingIdentWasAdded = false; 3270 bool trailingIdentWasAdded = false;
3272 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated(); 3271 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated();
3273 3272
3274 // At least template-areas strings must be defined. 3273 // At least template-areas strings must be defined.
3275 if (!m_valueList->current()) 3274 if (!m_valueList->current())
3276 return false; 3275 return false;
3277 3276
3278 while (m_valueList->current()) { 3277 while (m_valueList->current()) {
3279 // Handle leading <custom-ident>*. 3278 // Handle leading <custom-ident>*.
3280 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n ullptr)) 3279 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(NullableCSSValue(templateRows->item(templateRows->l ength() - 1))) : nullptr))
3281 return false; 3280 return false;
3282 3281
3283 // Handle a template-area's row. 3282 // Handle a template-area's row.
3284 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 3283 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
3285 return false; 3284 return false;
3286 ++rowCount; 3285 ++rowCount;
3287 3286
3288 // Handle template-rows's track-size. 3287 // Handle template-rows's track-size.
3289 if (m_valueList->current() && m_valueList->current()->unit != CSSPrimiti veValue::CSS_STRING) { 3288 if (m_valueList->current() && m_valueList->current()->unit != CSSPrimiti veValue::CSS_STRING) {
3290 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 3289 NullableCSSValue value = parseGridTrackSize(*m_valueList);
3291 if (!value) 3290 if (!value)
3292 return false; 3291 return false;
3293 templateRows->append(value); 3292 templateRows->append(*value);
3294 } else { 3293 } else {
3295 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); 3294 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to));
3296 } 3295 }
3297 3296
3298 // This will handle the trailing/leading <custom-ident>* in the grammar. 3297 // This will handle the trailing/leading <custom-ident>* in the grammar.
3299 if (!parseGridLineNames(*m_valueList, *templateRows)) 3298 if (!parseGridLineNames(*m_valueList, *templateRows))
3300 return false; 3299 return false;
3301 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)-> isGridLineNamesValue(); 3300 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1).i sGridLineNamesValue();
3302 } 3301 }
3303 3302
3304 // [<track-list> /]? 3303 // [<track-list> /]?
3305 if (templateColumns) 3304 if (templateColumns)
3306 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); 3305 addProperty(CSSPropertyGridTemplateColumns, *templateColumns, important) ;
3307 else 3306 else
3308 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important); 3307 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important);
3309 3308
3310 // [<line-names>? <string> [<track-size> <line-names>]? ]+ 3309 // [<line-names>? <string> [<track-size> <line-names>]? ]+
3311 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea te(gridAreaMap, rowCount, columnCount); 3310 CSSValue templateAreas = CSSGridTemplateAreasValue::create(gridAreaMap, rowC ount, columnCount);
3312 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important ); 3311 addProperty(CSSPropertyGridTemplateAreas, templateAreas, important);
3313 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); 3312 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
3314 3313
3315 return true; 3314 return true;
3316 } 3315 }
3317 3316
3318 3317
3319 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) 3318 bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
3320 { 3319 {
3321 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3320 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3322 3321
3323 ShorthandScope scope(this, CSSPropertyGridTemplate); 3322 ShorthandScope scope(this, CSSPropertyGridTemplate);
3324 ASSERT(gridTemplateShorthand().length() == 3); 3323 ASSERT(gridTemplateShorthand().length() == 3);
3325 3324
3326 // At least "none" must be defined. 3325 // At least "none" must be defined.
3327 if (!m_valueList->current()) 3326 if (!m_valueList->current())
3328 return false; 3327 return false;
3329 3328
3330 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; 3329 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone;
3331 3330
3332 // 1- 'none' case. 3331 // 1- 'none' case.
3333 if (firstValueIsNone && !m_valueList->next()) { 3332 if (firstValueIsNone && !m_valueList->next()) {
3334 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important); 3333 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important);
3335 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important); 3334 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important);
3336 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important); 3335 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important);
3337 return true; 3336 return true;
3338 } 3337 }
3339 3338
3340 unsigned index = 0; 3339 unsigned index = 0;
3341 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr; 3340 NullableCSSValue columnsValue;
3342 if (firstValueIsNone) { 3341 if (firstValueIsNone) {
3343 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); 3342 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone);
3344 } else { 3343 } else {
3345 columnsValue = parseGridTrackList(); 3344 columnsValue = parseGridTrackList();
3346 } 3345 }
3347 3346
3348 // 2- <grid-template-columns> / <grid-template-columns> syntax. 3347 // 2- <grid-template-columns> / <grid-template-columns> syntax.
3349 if (columnsValue) { 3348 if (columnsValue) {
3350 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next())) 3349 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next()))
3351 return false; 3350 return false;
3352 index = m_valueList->currentIndex(); 3351 index = m_valueList->currentIndex();
3353 if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) { 3352 if (NullableCSSValue rowsValue = parseGridTrackList()) {
3354 if (m_valueList->current()) 3353 if (m_valueList->current())
3355 return false; 3354 return false;
3356 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important) ; 3355 addProperty(CSSPropertyGridTemplateColumns, *columnsValue, important );
3357 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); 3356 addProperty(CSSPropertyGridTemplateRows, *rowsValue, important);
3358 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important); 3357 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important);
3359 return true; 3358 return true;
3360 } 3359 }
3361 } 3360 }
3362 3361
3363 3362
3364 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax. 3363 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
3365 // The template-columns <track-list> can't be 'none'. 3364 // The template-columns <track-list> can't be 'none'.
3366 if (firstValueIsNone) 3365 if (firstValueIsNone)
3367 return false; 3366 return false;
(...skipping 17 matching lines...) Expand all
3385 return true; 3384 return true;
3386 } 3385 }
3387 3386
3388 // Need to rewind parsing to explore the alternative syntax of this shorthan d. 3387 // Need to rewind parsing to explore the alternative syntax of this shorthan d.
3389 m_valueList->setCurrentIndex(0); 3388 m_valueList->setCurrentIndex(0);
3390 3389
3391 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] 3390 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ]
3392 if (!parseValue(CSSPropertyGridAutoFlow, important)) 3391 if (!parseValue(CSSPropertyGridAutoFlow, important))
3393 return false; 3392 return false;
3394 3393
3395 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = nullptr; 3394 NullableCSSValue autoColumnsValue;
3396 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr; 3395 NullableCSSValue autoRowsValue;
3397 3396
3398 if (m_valueList->current()) { 3397 if (m_valueList->current()) {
3399 autoColumnsValue = parseGridTrackSize(*m_valueList); 3398 autoColumnsValue = parseGridTrackSize(*m_valueList);
3400 if (!autoColumnsValue) 3399 if (!autoColumnsValue)
3401 return false; 3400 return false;
3402 if (m_valueList->current()) { 3401 if (m_valueList->current()) {
3403 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next()) 3402 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next())
3404 return false; 3403 return false;
3405 autoRowsValue = parseGridTrackSize(*m_valueList); 3404 autoRowsValue = parseGridTrackSize(*m_valueList);
3406 if (!autoRowsValue) 3405 if (!autoRowsValue)
3407 return false; 3406 return false;
3408 } 3407 }
3409 if (m_valueList->current()) 3408 if (m_valueList->current())
3410 return false; 3409 return false;
3411 } else { 3410 } else {
3412 // Other omitted values are set to their initial values. 3411 // Other omitted values are set to their initial values.
3413 autoColumnsValue = cssValuePool().createImplicitInitialValue(); 3412 autoColumnsValue = cssValuePool().createImplicitInitialValue();
3414 autoRowsValue = cssValuePool().createImplicitInitialValue(); 3413 autoRowsValue = cssValuePool().createImplicitInitialValue();
3415 } 3414 }
3416 3415
3417 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns. 3416 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns.
3418 if (!autoRowsValue) 3417 if (!autoRowsValue)
3419 autoRowsValue = autoColumnsValue; 3418 autoRowsValue = autoColumnsValue;
3420 3419
3421 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); 3420 addProperty(CSSPropertyGridAutoColumns, *autoColumnsValue, important);
3422 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); 3421 addProperty(CSSPropertyGridAutoRows, *autoRowsValue, important);
3423 3422
3424 // It can only be specified the explicit or the implicit grid properties in a single grid declaration. 3423 // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
3425 // The sub-properties not specified are set to their initial value, as norma l for shorthands. 3424 // The sub-properties not specified are set to their initial value, as norma l for shorthands.
3426 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important); 3425 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important);
3427 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important); 3426 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important);
3428 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important); 3427 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important);
3429 3428
3430 return true; 3429 return true;
3431 } 3430 }
3432 3431
3433 bool CSSPropertyParser::parseGridAreaShorthand(bool important) 3432 bool CSSPropertyParser::parseGridAreaShorthand(bool important)
3434 { 3433 {
3435 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3434 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3436 3435
3437 ShorthandScope scope(this, CSSPropertyGridArea); 3436 ShorthandScope scope(this, CSSPropertyGridArea);
3438 const StylePropertyShorthand& shorthand = gridAreaShorthand(); 3437 const StylePropertyShorthand& shorthand = gridAreaShorthand();
3439 ASSERT_UNUSED(shorthand, shorthand.length() == 4); 3438 ASSERT_UNUSED(shorthand, shorthand.length() == 4);
3440 3439
3441 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); 3440 NullableCSSValue rowStartValue = parseGridPosition();
3442 if (!rowStartValue) 3441 if (!rowStartValue)
3443 return false; 3442 return false;
3444 3443
3445 RefPtrWillBeRawPtr<CSSValue> columnStartValue = nullptr; 3444 NullableCSSValue columnStartValue;
3446 if (!parseSingleGridAreaLonghand(columnStartValue)) 3445 if (!parseSingleGridAreaLonghand(columnStartValue))
3447 return false; 3446 return false;
3448 3447
3449 RefPtrWillBeRawPtr<CSSValue> rowEndValue = nullptr; 3448 NullableCSSValue rowEndValue;
3450 if (!parseSingleGridAreaLonghand(rowEndValue)) 3449 if (!parseSingleGridAreaLonghand(rowEndValue))
3451 return false; 3450 return false;
3452 3451
3453 RefPtrWillBeRawPtr<CSSValue> columnEndValue = nullptr; 3452 NullableCSSValue columnEndValue;
3454 if (!parseSingleGridAreaLonghand(columnEndValue)) 3453 if (!parseSingleGridAreaLonghand(columnEndValue))
3455 return false; 3454 return false;
3456 3455
3457 if (!columnStartValue) 3456 if (!columnStartValue)
3458 columnStartValue = gridMissingGridPositionValue(rowStartValue.get()); 3457 columnStartValue = gridMissingGridPositionValue(*rowStartValue);
3459 3458
3460 if (!rowEndValue) 3459 if (!rowEndValue)
3461 rowEndValue = gridMissingGridPositionValue(rowStartValue.get()); 3460 rowEndValue = gridMissingGridPositionValue(*rowStartValue);
3462 3461
3463 if (!columnEndValue) 3462 if (!columnEndValue)
3464 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); 3463 columnEndValue = gridMissingGridPositionValue(*columnStartValue);
3465 3464
3466 addProperty(CSSPropertyGridRowStart, rowStartValue, important); 3465 addProperty(CSSPropertyGridRowStart, *rowStartValue, important);
3467 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); 3466 addProperty(CSSPropertyGridColumnStart, *columnStartValue, important);
3468 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); 3467 addProperty(CSSPropertyGridRowEnd, *rowEndValue, important);
3469 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); 3468 addProperty(CSSPropertyGridColumnEnd, *columnEndValue, important);
3470 return true; 3469 return true;
3471 } 3470 }
3472 3471
3473 bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtrWillBeRawPtr<CSSValue> & property) 3472 bool CSSPropertyParser::parseSingleGridAreaLonghand(NullableCSSValue& property)
3474 { 3473 {
3475 if (!m_valueList->current()) 3474 if (!m_valueList->current())
3476 return true; 3475 return true;
3477 3476
3478 if (!isForwardSlashOperator(m_valueList->current())) 3477 if (!isForwardSlashOperator(m_valueList->current()))
3479 return false; 3478 return false;
3480 3479
3481 if (!m_valueList->next()) 3480 if (!m_valueList->next())
3482 return false; 3481 return false;
3483 3482
3484 property = parseGridPosition(); 3483 property = parseGridPosition();
3485 return true; 3484 return true;
3486 } 3485 }
3487 3486
3488 static inline bool isClosingBracket(const CSSParserValue& value) 3487 static inline bool isClosingBracket(const CSSParserValue& value)
3489 { 3488 {
3490 return value.unit == CSSParserValue::Operator && value.iValue == ']'; 3489 return value.unit == CSSParserValue::Operator && value.iValue == ']';
3491 } 3490 }
3492 3491
3493 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames) 3492 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, NullableCSSValue previousNamedAreaTrailingLineNames)
3494 { 3493 {
3495 if (!inputList.current() || inputList.current()->unit != CSSParserValue::Ope rator || inputList.current()->iValue != '[') 3494 if (!inputList.current() || inputList.current()->unit != CSSParserValue::Ope rator || inputList.current()->iValue != '[')
3496 return true; 3495 return true;
3497 3496
3498 // Skip '[' 3497 // Skip '['
3499 inputList.next(); 3498 inputList.next();
3500 3499
3501 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = previousNamedAreaTrail ingLineNames; 3500 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = toCSSGridLineNamesValu e(previousNamedAreaTrailingLineNames);
3502 if (!lineNames) 3501 if (!lineNames)
3503 lineNames = CSSGridLineNamesValue::create(); 3502 lineNames = CSSGridLineNamesValue::create();
3504 3503
3505 while (CSSParserValue* identValue = inputList.current()) { 3504 while (CSSParserValue* identValue = inputList.current()) {
3506 if (isClosingBracket(*identValue)) 3505 if (isClosingBracket(*identValue))
3507 break; 3506 break;
3508 3507
3509 if (!isValidCustomIdentForGridPositions(*identValue)) 3508 if (!isValidCustomIdentForGridPositions(*identValue))
3510 return false; 3509 return false;
3511 3510
3512 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId entValue(identValue); 3511 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId entValue(identValue);
3513 lineNames->append(lineName.release()); 3512 lineNames->append(lineName.release());
3514 inputList.next(); 3513 inputList.next();
3515 } 3514 }
3516 3515
3517 if (!inputList.current() || !isClosingBracket(*inputList.current())) 3516 if (!inputList.current() || !isClosingBracket(*inputList.current()))
3518 return false; 3517 return false;
3519 3518
3520 if (!previousNamedAreaTrailingLineNames) 3519 if (!previousNamedAreaTrailingLineNames)
3521 valueList.append(lineNames.release()); 3520 valueList.append(lineNames.release());
3522 3521
3523 // Consume ']' 3522 // Consume ']'
3524 inputList.next(); 3523 inputList.next();
3525 return true; 3524 return true;
3526 } 3525 }
3527 3526
3528 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList() 3527 NullableCSSValue CSSPropertyParser::parseGridTrackList()
3529 { 3528 {
3530 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3529 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3531 3530
3532 CSSParserValue* value = m_valueList->current(); 3531 CSSParserValue* value = m_valueList->current();
3533 if (value->id == CSSValueNone) { 3532 if (value->id == CSSValueNone) {
3534 m_valueList->next(); 3533 m_valueList->next();
3535 return cssValuePool().createIdentifierValue(CSSValueNone); 3534 return cssValuePool().createIdentifierValue(CSSValueNone);
3536 } 3535 }
3537 3536
3538 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 3537 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
3539 // Handle leading <custom-ident>*. 3538 // Handle leading <custom-ident>*.
3540 if (!parseGridLineNames(*m_valueList, *values)) 3539 if (!parseGridLineNames(*m_valueList, *values))
3541 return nullptr; 3540 return nullptr;
3542 3541
3543 bool seenTrackSizeOrRepeatFunction = false; 3542 bool seenTrackSizeOrRepeatFunction = false;
3544 while (CSSParserValue* currentValue = m_valueList->current()) { 3543 while (CSSParserValue* currentValue = m_valueList->current()) {
3545 if (isForwardSlashOperator(currentValue)) 3544 if (isForwardSlashOperator(currentValue))
3546 break; 3545 break;
3547 if (currentValue->unit == CSSParserValue::Function && currentValue->func tion->id == CSSValueRepeat) { 3546 if (currentValue->unit == CSSParserValue::Function && currentValue->func tion->id == CSSValueRepeat) {
3548 if (!parseGridTrackRepeatFunction(*values)) 3547 if (!parseGridTrackRepeatFunction(*values))
3549 return nullptr; 3548 return nullptr;
3550 seenTrackSizeOrRepeatFunction = true; 3549 seenTrackSizeOrRepeatFunction = true;
3551 } else { 3550 } else {
3552 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 3551 NullableCSSValue value = parseGridTrackSize(*m_valueList);
3553 if (!value) 3552 if (!value)
3554 return nullptr; 3553 return nullptr;
3555 values->append(value); 3554 values->append(*value);
3556 seenTrackSizeOrRepeatFunction = true; 3555 seenTrackSizeOrRepeatFunction = true;
3557 } 3556 }
3558 // This will handle the trailing <custom-ident>* in the grammar. 3557 // This will handle the trailing <custom-ident>* in the grammar.
3559 if (!parseGridLineNames(*m_valueList, *values)) 3558 if (!parseGridLineNames(*m_valueList, *values))
3560 return nullptr; 3559 return nullptr;
3561 } 3560 }
3562 3561
3563 // We should have found a <track-size> or else it is not a valid <track-list > 3562 // We should have found a <track-size> or else it is not a valid <track-list >
3564 if (!seenTrackSizeOrRepeatFunction) 3563 if (!seenTrackSizeOrRepeatFunction)
3565 return nullptr; 3564 return nullptr;
(...skipping 13 matching lines...) Expand all
3579 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); 3578 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated();
3580 arguments->next(); // Skip the repetition count. 3579 arguments->next(); // Skip the repetition count.
3581 arguments->next(); // Skip the comma. 3580 arguments->next(); // Skip the comma.
3582 3581
3583 // Handle leading <custom-ident>*. 3582 // Handle leading <custom-ident>*.
3584 if (!parseGridLineNames(*arguments, *repeatedValues)) 3583 if (!parseGridLineNames(*arguments, *repeatedValues))
3585 return false; 3584 return false;
3586 3585
3587 size_t numberOfTracks = 0; 3586 size_t numberOfTracks = 0;
3588 while (arguments->current()) { 3587 while (arguments->current()) {
3589 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 3588 NullableCSSValue trackSize = parseGridTrackSize(*arguments);
3590 if (!trackSize) 3589 if (!trackSize)
3591 return false; 3590 return false;
3592 3591
3593 repeatedValues->append(trackSize); 3592 repeatedValues->append(*trackSize);
3594 ++numberOfTracks; 3593 ++numberOfTracks;
3595 3594
3596 // This takes care of any trailing <custom-ident>* in the grammar. 3595 // This takes care of any trailing <custom-ident>* in the grammar.
3597 if (!parseGridLineNames(*arguments, *repeatedValues)) 3596 if (!parseGridLineNames(*arguments, *repeatedValues))
3598 return false; 3597 return false;
3599 } 3598 }
3600 3599
3601 // We should have found at least one <track-size> or else it is not a valid <track-list>. 3600 // We should have found at least one <track-size> or else it is not a valid <track-list>.
3602 if (!numberOfTracks) 3601 if (!numberOfTracks)
3603 return false; 3602 return false;
3604 3603
3605 // We clamp the number of repetitions to a multiple of the repeat() track li st's size, while staying below the max 3604 // We clamp the number of repetitions to a multiple of the repeat() track li st's size, while staying below the max
3606 // grid size. 3605 // grid size.
3607 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); 3606 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks);
3608 3607
3609 for (size_t i = 0; i < repetitions; ++i) { 3608 for (size_t i = 0; i < repetitions; ++i) {
3610 for (size_t j = 0; j < repeatedValues->length(); ++j) 3609 for (size_t j = 0; j < repeatedValues->length(); ++j)
3611 list.append(repeatedValues->item(j)); 3610 list.append(repeatedValues->item(j));
3612 } 3611 }
3613 3612
3614 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. 3613 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue.
3615 m_valueList->next(); 3614 m_valueList->next();
3616 return true; 3615 return true;
3617 } 3616 }
3618 3617
3619 3618
3620 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParser ValueList& inputList) 3619 NullableCSSValue CSSPropertyParser::parseGridTrackSize(CSSParserValueList& input List)
3621 { 3620 {
3622 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3621 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3623 3622
3624 CSSParserValue* currentValue = inputList.current(); 3623 CSSParserValue* currentValue = inputList.current();
3625 inputList.next(); 3624 inputList.next();
3626 3625
3627 if (currentValue->id == CSSValueAuto) 3626 if (currentValue->id == CSSValueAuto)
3628 return cssValuePool().createIdentifierValue(CSSValueAuto); 3627 return cssValuePool().createIdentifierValue(CSSValueAuto);
3629 3628
3630 if (currentValue->unit == CSSParserValue::Function && currentValue->function ->id == CSSValueMinmax) { 3629 if (currentValue->unit == CSSParserValue::Function && currentValue->function ->id == CSSValueMinmax) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3738 3737
3739 ++gridCoordinate.rows.resolvedFinalPosition; 3738 ++gridCoordinate.rows.resolvedFinalPosition;
3740 } 3739 }
3741 currentCol = lookAheadCol; 3740 currentCol = lookAheadCol;
3742 } 3741 }
3743 3742
3744 m_valueList->next(); 3743 m_valueList->next();
3745 return true; 3744 return true;
3746 } 3745 }
3747 3746
3748 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() 3747 NullableCSSValue CSSPropertyParser::parseGridTemplateAreas()
3749 { 3748 {
3750 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { 3749 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) {
3751 m_valueList->next(); 3750 m_valueList->next();
3752 return cssValuePool().createIdentifierValue(CSSValueNone); 3751 return cssValuePool().createIdentifierValue(CSSValueNone);
3753 } 3752 }
3754 3753
3755 NamedGridAreaMap gridAreaMap; 3754 NamedGridAreaMap gridAreaMap;
3756 size_t rowCount = 0; 3755 size_t rowCount = 0;
3757 size_t columnCount = 0; 3756 size_t columnCount = 0;
3758 3757
3759 while (m_valueList->current()) { 3758 while (m_valueList->current()) {
3760 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 3759 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
3761 return nullptr; 3760 return nullptr;
3762 ++rowCount; 3761 ++rowCount;
3763 } 3762 }
3764 3763
3765 if (!rowCount || !columnCount) 3764 if (!rowCount || !columnCount)
3766 return nullptr; 3765 return nullptr;
3767 3766
3768 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ; 3767 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ;
3769 } 3768 }
3770 3769
3771 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV alueList& list) 3770 NullableCSSValue CSSPropertyParser::parseGridAutoFlow(CSSParserValueList& list)
3772 { 3771 {
3773 // [ row | column ] || dense 3772 // [ row | column ] || dense
3774 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3773 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3775 3774
3776 CSSParserValue* value = list.current(); 3775 CSSParserValue* value = list.current();
3777 if (!value) 3776 if (!value)
3778 return nullptr; 3777 return nullptr;
3779 3778
3780 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 3779 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated();
3781 3780
(...skipping 19 matching lines...) Expand all
3801 default: 3800 default:
3802 return parsedValues; 3801 return parsedValues;
3803 } 3802 }
3804 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); 3803 parsedValues->append(cssValuePool().createIdentifierValue(value->id));
3805 list.next(); 3804 list.next();
3806 } 3805 }
3807 3806
3808 return parsedValues; 3807 return parsedValues;
3809 } 3808 }
3810 3809
3811 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse rValueList* args, bool counters) 3810 NullableCSSValue CSSPropertyParser::parseCounterContent(CSSParserValueList* args , bool counters)
3812 { 3811 {
3813 unsigned numArgs = args->size(); 3812 unsigned numArgs = args->size();
3814 if (counters && numArgs != 3 && numArgs != 5) 3813 if (counters && numArgs != 3 && numArgs != 5)
3815 return nullptr; 3814 return nullptr;
3816 if (!counters && numArgs != 1 && numArgs != 3) 3815 if (!counters && numArgs != 1 && numArgs != 3)
3817 return nullptr; 3816 return nullptr;
3818 3817
3819 CSSParserValue* i = args->current(); 3818 CSSParserValue* i = args->current();
3820 if (i->unit != CSSPrimitiveValue::CSS_IDENT) 3819 if (i->unit != CSSPrimitiveValue::CSS_IDENT)
3821 return nullptr; 3820 return nullptr;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4079 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy ) 4078 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy )
4080 return false; 4079 return false;
4081 } else { 4080 } else {
4082 return false; 4081 return false;
4083 } 4082 }
4084 4083
4085 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt); 4084 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt);
4086 return !m_valueList->next(); 4085 return !m_valueList->next();
4087 } 4086 }
4088 4087
4089 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver flowPosition() 4088 NullableCSSValue CSSPropertyParser::parseContentDistributionOverflowPosition()
4090 { 4089 {
4091 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ] 4090 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ]
4092 // <baseline-position> = baseline | last-baseline; 4091 // <baseline-position> = baseline | last-baseline;
4093 // <content-distribution> = space-between | space-around | space-evenly | st retch; 4092 // <content-distribution> = space-between | space-around | space-evenly | st retch;
4094 // <content-position> = center | start | end | flex-start | flex-end | left | right; 4093 // <content-position> = center | start | end | flex-start | flex-end | left | right;
4095 // <overflow-position> = true | safe 4094 // <overflow-position> = true | safe
4096 4095
4097 // auto | <baseline-position> 4096 // auto | <baseline-position>
4098 CSSParserValue* value = m_valueList->current(); 4097 CSSParserValue* value = m_valueList->current();
4099 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { 4098 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4218 if (!args->currentIndex() && argument->id != CSSValueAt) { 4217 if (!args->currentIndex() && argument->id != CSSValueAt) {
4219 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius( argument)) { 4218 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius( argument)) {
4220 shape->setRadius(radius); 4219 shape->setRadius(radius);
4221 continue; 4220 continue;
4222 } 4221 }
4223 4222
4224 return nullptr; 4223 return nullptr;
4225 } 4224 }
4226 4225
4227 if (argument->id == CSSValueAt && args->next()) { 4226 if (argument->id == CSSValueAt && args->next()) {
4228 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4227 NullableCSSValue centerX;
4229 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4228 NullableCSSValue centerY;
4230 parseFillPosition(args, centerX, centerY); 4229 parseFillPosition(args, centerX, centerY);
4231 if (centerX && centerY && !args->current()) { 4230 if (centerX && centerY && !args->current()) {
4232 ASSERT(centerX->isPrimitiveValue()); 4231 ASSERT(centerX->isPrimitiveValue());
4233 ASSERT(centerY->isPrimitiveValue()); 4232 ASSERT(centerY->isPrimitiveValue());
4234 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); 4233 shape->setCenterX(toCSSPrimitiveValue(centerX));
4235 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); 4234 shape->setCenterY(toCSSPrimitiveValue(centerY));
4236 } else { 4235 } else {
4237 return nullptr; 4236 return nullptr;
4238 } 4237 }
4239 } else { 4238 } else {
4240 return nullptr; 4239 return nullptr;
4241 } 4240 }
4242 } 4241 }
4243 4242
4244 return shape; 4243 return shape;
4245 } 4244 }
(...skipping 24 matching lines...) Expand all
4270 else 4269 else
4271 shape->setRadiusY(radius); 4270 shape->setRadiusY(radius);
4272 continue; 4271 continue;
4273 } 4272 }
4274 4273
4275 return nullptr; 4274 return nullptr;
4276 } 4275 }
4277 4276
4278 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>) 4277 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>)
4279 return nullptr; 4278 return nullptr;
4280 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4279 NullableCSSValue centerX;
4281 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4280 NullableCSSValue centerY;
4282 parseFillPosition(args, centerX, centerY); 4281 parseFillPosition(args, centerX, centerY);
4283 if (!centerX || !centerY || args->current()) 4282 if (!centerX || !centerY || args->current())
4284 return nullptr; 4283 return nullptr;
4285 4284
4286 ASSERT(centerX->isPrimitiveValue()); 4285 ASSERT(centerX->isPrimitiveValue());
4287 ASSERT(centerY->isPrimitiveValue()); 4286 ASSERT(centerY->isPrimitiveValue());
4288 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); 4287 shape->setCenterX(toCSSPrimitiveValue(centerX));
4289 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); 4288 shape->setCenterY(toCSSPrimitiveValue(centerY));
4290 } 4289 }
4291 4290
4292 return shape; 4291 return shape;
4293 } 4292 }
4294 4293
4295 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args) 4294 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args)
4296 { 4295 {
4297 ASSERT(args); 4296 ASSERT(args);
4298 4297
4299 unsigned size = args->size(); 4298 unsigned size = args->size();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4347 case CSSValueBorderBox: 4346 case CSSValueBorderBox:
4348 case CSSValueMarginBox: 4347 case CSSValueMarginBox:
4349 return true; 4348 return true;
4350 default: 4349 default:
4351 break; 4350 break;
4352 } 4351 }
4353 4352
4354 return false; 4353 return false;
4355 } 4354 }
4356 4355
4357 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper tyID propId) 4356 NullableCSSValue CSSPropertyParser::parseShapeProperty(CSSPropertyID propId)
4358 { 4357 {
4359 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; 4358 NullableCSSValue imageValue;
4360 if (parseFillImage(m_valueList, imageValue)) { 4359 if (parseFillImage(m_valueList, imageValue)) {
4361 m_valueList->next(); 4360 m_valueList->next();
4362 return imageValue.release(); 4361 return imageValue;
4363 } 4362 }
4364 4363
4365 return parseBasicShapeAndOrBox(); 4364 return parseBasicShapeAndOrBox();
4366 } 4365 }
4367 4366
4368 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() 4367 NullableCSSValue CSSPropertyParser::parseBasicShapeAndOrBox()
4369 { 4368 {
4370 CSSParserValue* value = m_valueList->current(); 4369 CSSParserValue* value = m_valueList->current();
4371 4370
4372 bool shapeFound = false; 4371 bool shapeFound = false;
4373 bool boxFound = false; 4372 bool boxFound = false;
4374 CSSValueID valueId; 4373 CSSValueID valueId;
4375 4374
4376 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 4375 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
4377 for (unsigned i = 0; i < 2; ++i) { 4376 for (unsigned i = 0; i < 2; ++i) {
4378 if (!value) 4377 if (!value)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4490 return false; 4489 return false;
4491 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); 4490 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight();
4492 if (!lineHeight) 4491 if (!lineHeight)
4493 return false; 4492 return false;
4494 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); 4493 addProperty(CSSPropertyLineHeight, lineHeight.release(), important);
4495 } else { 4494 } else {
4496 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true); 4495 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true);
4497 } 4496 }
4498 4497
4499 // Font family must come now. 4498 // Font family must come now.
4500 RefPtrWillBeRawPtr<CSSValue> parsedFamilyValue = parseFontFamily(); 4499 NullableCSSValue parsedFamilyValue = parseFontFamily();
4501 if (!parsedFamilyValue) 4500 if (!parsedFamilyValue)
4502 return false; 4501 return false;
4503 4502
4504 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); 4503 addProperty(CSSPropertyFontFamily, *parsedFamilyValue, important);
4505 4504
4506 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir es that 4505 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir es that
4507 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values 4506 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values
4508 // but we don't seem to support them at the moment. They should also be adde d here once implemented. 4507 // but we don't seem to support them at the moment. They should also be adde d here once implemented.
4509 if (m_valueList->current()) 4508 if (m_valueList->current())
4510 return false; 4509 return false;
4511 4510
4512 return true; 4511 return true;
4513 } 4512 }
4514 4513
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
5511 5510
5512 if (context.allowBreak) { 5511 if (context.allowBreak) {
5513 context.commitValue(); 5512 context.commitValue();
5514 if (context.values && context.values->length()) 5513 if (context.values && context.values->length())
5515 return context.values.release(); 5514 return context.values.release();
5516 } 5515 }
5517 5516
5518 return nullptr; 5517 return nullptr;
5519 } 5518 }
5520 5519
5521 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() 5520 NullableCSSValue CSSPropertyParser::parseReflect()
5522 { 5521 {
5523 // box-reflect: <direction> <offset> <mask> 5522 // box-reflect: <direction> <offset> <mask>
5524 5523
5525 // Direction comes first. 5524 // Direction comes first.
5526 CSSParserValue* val = m_valueList->current(); 5525 CSSParserValue* val = m_valueList->current();
5527 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; 5526 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr;
5528 switch (val->id) { 5527 switch (val->id) {
5529 case CSSValueAbove: 5528 case CSSValueAbove:
5530 case CSSValueBelow: 5529 case CSSValueBelow:
5531 case CSSValueLeft: 5530 case CSSValueLeft:
5532 case CSSValueRight: 5531 case CSSValueRight:
5533 direction = cssValuePool().createIdentifierValue(val->id); 5532 direction = cssValuePool().createIdentifierValue(val->id);
5534 break; 5533 break;
5535 default: 5534 default:
5536 return nullptr; 5535 return nullptr;
5537 } 5536 }
5538 5537
5539 // The offset comes next. 5538 // The offset comes next.
5540 val = m_valueList->next(); 5539 val = m_valueList->next();
5541 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; 5540 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr;
5542 if (!val) 5541 if (!val)
5543 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); 5542 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
5544 else { 5543 else {
5545 if (!validUnit(val, FLength | FPercent)) 5544 if (!validUnit(val, FLength | FPercent))
5546 return nullptr; 5545 return nullptr;
5547 offset = createPrimitiveNumericValue(val); 5546 offset = createPrimitiveNumericValue(val);
5548 } 5547 }
5549 5548
5550 // Now for the mask. 5549 // Now for the mask.
5551 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; 5550 NullableCSSValue mask;
5552 val = m_valueList->next(); 5551 val = m_valueList->next();
5553 if (val) { 5552 if (val) {
5554 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); 5553 mask = parseBorderImage(CSSPropertyWebkitBoxReflect);
5555 if (!mask) 5554 if (!mask)
5556 return nullptr; 5555 return nullptr;
5557 } 5556 }
5558 5557
5559 return CSSReflectValue::create(direction.release(), offset.release(), mask.r elease()); 5558 return CSSReflectValue::create(direction.get(), offset.get(), mask);
5560 } 5559 }
5561 5560
5562 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse tValue, int argSize) 5561 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse tValue, int argSize)
5563 { 5562 {
5564 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; 5563 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3;
5565 } 5564 }
5566 5565
5567 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) 5566 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important)
5568 { 5567 {
5569 if (!args || !args->size() || args->size() > 3) 5568 if (!args || !args->size() || args->size() > 3)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5601 flexShrink = 1; 5600 flexShrink = 1;
5602 if (!flexBasis) 5601 if (!flexBasis)
5603 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT AGE); 5602 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT AGE);
5604 5603
5605 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f lexGrow), CSSPrimitiveValue::CSS_NUMBER), important); 5604 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f lexGrow), CSSPrimitiveValue::CSS_NUMBER), important);
5606 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float> (flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); 5605 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float> (flexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
5607 addProperty(CSSPropertyFlexBasis, flexBasis, important); 5606 addProperty(CSSPropertyFlexBasis, flexBasis, important);
5608 return true; 5607 return true;
5609 } 5608 }
5610 5609
5611 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue List* valueList) 5610 NullableCSSValue CSSPropertyParser::parsePosition(CSSParserValueList* valueList)
5612 { 5611 {
5613 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 5612 NullableCSSValue xValue;
5614 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 5613 NullableCSSValue yValue;
5615 parseFillPosition(valueList, xValue, yValue); 5614 parseFillPosition(valueList, xValue, yValue);
5615
5616 if (!xValue || !yValue) 5616 if (!xValue || !yValue)
5617 return nullptr; 5617 return nullptr;
5618 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim itiveValue(yValue.get()), Pair::KeepIdenticalValues); 5618 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue), toCSSPrimitiveV alue(yValue), Pair::KeepIdenticalValues);
5619 } 5619 }
5620 5620
5621 // Parses a list of comma separated positions. i.e., <position># 5621 // Parses a list of comma separated positions. i.e., <position>#
5622 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar serValueList* valueList) 5622 NullableCSSValue CSSPropertyParser::parsePositionList(CSSParserValueList* valueL ist)
5623 { 5623 {
5624 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted(); 5624 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted();
5625 while (true) { 5625 while (true) {
5626 // parsePosition consumes values until it reaches a separator [,/], 5626 // parsePosition consumes values until it reaches a separator [,/],
5627 // an invalid token, or end of the list 5627 // an invalid token, or end of the list
5628 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); 5628 NullableCSSValue position = parsePosition(valueList);
5629 if (!position) 5629 if (!position)
5630 return nullptr; 5630 return nullptr;
5631 positions->append(position); 5631 positions->append(*position);
5632 5632
5633 if (!valueList->current()) 5633 if (!valueList->current())
5634 break; 5634 break;
5635 if (!consumeComma(valueList) || !valueList->current()) 5635 if (!consumeComma(valueList) || !valueList->current())
5636 return nullptr; 5636 return nullptr;
5637 } 5637 }
5638 5638
5639 return positions.release(); 5639 return positions.release();
5640 } 5640 }
5641 5641
(...skipping 16 matching lines...) Expand all
5658 5658
5659 bool allowCommit() const { return m_allowCommit; } 5659 bool allowCommit() const { return m_allowCommit; }
5660 bool allowImage() const { return m_allowImage; } 5660 bool allowImage() const { return m_allowImage; }
5661 bool allowImageSlice() const { return m_allowImageSlice; } 5661 bool allowImageSlice() const { return m_allowImageSlice; }
5662 bool allowRepeat() const { return m_allowRepeat; } 5662 bool allowRepeat() const { return m_allowRepeat; }
5663 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; } 5663 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; }
5664 5664
5665 bool allowWidth() const { return m_allowWidth; } 5665 bool allowWidth() const { return m_allowWidth; }
5666 bool requireOutset() const { return m_requireOutset; } 5666 bool requireOutset() const { return m_requireOutset; }
5667 5667
5668 void commitImage(PassRefPtrWillBeRawPtr<CSSValue> image) 5668 void commitImage(CSSValue image)
5669 { 5669 {
5670 m_image = image; 5670 m_image = image;
5671 m_canAdvance = true; 5671 m_canAdvance = true;
5672 m_allowCommit = true; 5672 m_allowCommit = true;
5673 m_allowImage = false; 5673 m_allowImage = false;
5674 m_allowForwardSlashOperator = false; 5674 m_allowForwardSlashOperator = false;
5675 m_allowWidth = false; 5675 m_allowWidth = false;
5676 m_requireOutset = false; 5676 m_requireOutset = false;
5677 m_allowImageSlice = !m_imageSlice; 5677 m_allowImageSlice = !m_imageSlice;
5678 m_allowRepeat = !m_repeat; 5678 m_allowRepeat = !m_repeat;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5723 m_outset = outset; 5723 m_outset = outset;
5724 m_canAdvance = true; 5724 m_canAdvance = true;
5725 m_allowCommit = true; 5725 m_allowCommit = true;
5726 m_allowImageSlice = false; 5726 m_allowImageSlice = false;
5727 m_allowForwardSlashOperator = false; 5727 m_allowForwardSlashOperator = false;
5728 m_allowWidth = false; 5728 m_allowWidth = false;
5729 m_requireOutset = false; 5729 m_requireOutset = false;
5730 m_allowImage = !m_image; 5730 m_allowImage = !m_image;
5731 m_allowRepeat = !m_repeat; 5731 m_allowRepeat = !m_repeat;
5732 } 5732 }
5733 void commitRepeat(PassRefPtrWillBeRawPtr<CSSValue> repeat) 5733 void commitRepeat(CSSValue repeat)
5734 { 5734 {
5735 m_repeat = repeat; 5735 m_repeat = repeat;
5736 m_canAdvance = true; 5736 m_canAdvance = true;
5737 m_allowCommit = true; 5737 m_allowCommit = true;
5738 m_allowRepeat = false; 5738 m_allowRepeat = false;
5739 m_allowForwardSlashOperator = false; 5739 m_allowForwardSlashOperator = false;
5740 m_allowWidth = false; 5740 m_allowWidth = false;
5741 m_requireOutset = false; 5741 m_requireOutset = false;
5742 m_allowImageSlice = !m_imageSlice; 5742 m_allowImageSlice = !m_imageSlice;
5743 m_allowImage = !m_image; 5743 m_allowImage = !m_image;
5744 } 5744 }
5745 5745
5746 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() 5746 CSSValue commitCSSValue()
5747 { 5747 {
5748 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat.get()); 5748 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat);
5749 } 5749 }
5750 5750
5751 bool m_canAdvance; 5751 bool m_canAdvance;
5752 5752
5753 bool m_allowCommit; 5753 bool m_allowCommit;
5754 bool m_allowImage; 5754 bool m_allowImage;
5755 bool m_allowImageSlice; 5755 bool m_allowImageSlice;
5756 bool m_allowRepeat; 5756 bool m_allowRepeat;
5757 bool m_allowForwardSlashOperator; 5757 bool m_allowForwardSlashOperator;
5758 5758
5759 bool m_allowWidth; 5759 bool m_allowWidth;
5760 bool m_requireOutset; 5760 bool m_requireOutset;
5761 5761
5762 RefPtrWillBeMember<CSSValue> m_image; 5762 NullableCSSValue m_image;
5763 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; 5763 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice;
5764 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; 5764 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth;
5765 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; 5765 RefPtrWillBeMember<CSSPrimitiveValue> m_outset;
5766 5766
5767 RefPtrWillBeMember<CSSValue> m_repeat; 5767 NullableCSSValue m_repeat;
5768 }; 5768 };
5769 5769
5770 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context) 5770 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context)
5771 { 5771 {
5772 CSSPropertyParser::ShorthandScope scope(this, propId); 5772 CSSPropertyParser::ShorthandScope scope(this, propId);
5773 while (CSSParserValue* val = m_valueList->current()) { 5773 while (CSSParserValue* val = m_valueList->current()) {
5774 context.setCanAdvance(false); 5774 context.setCanAdvance(false);
5775 5775
5776 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val)) 5776 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val))
5777 context.commitForwardSlashOperator(); 5777 context.commitForwardSlashOperator();
5778 5778
5779 if (!context.canAdvance() && context.allowImage()) { 5779 if (!context.canAdvance() && context.allowImage()) {
5780 if (val->unit == CSSPrimitiveValue::CSS_URI) { 5780 if (val->unit == CSSPrimitiveValue::CSS_URI) {
5781 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string))); 5781 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string)));
5782 } else if (isGeneratedImageValue(val)) { 5782 } else if (isGeneratedImageValue(val)) {
5783 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 5783 NullableCSSValue value;
5784 if (parseGeneratedImage(m_valueList, value)) 5784 if (parseGeneratedImage(m_valueList, value))
5785 context.commitImage(value.release()); 5785 context.commitImage(*value);
5786 else 5786 else
5787 return false; 5787 return false;
5788 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) { 5788 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) {
5789 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); 5789 NullableCSSValue value = parseImageSet(m_valueList);
5790 if (value) 5790 if (value)
5791 context.commitImage(value.release()); 5791 context.commitImage(*value);
5792 else 5792 else
5793 return false; 5793 return false;
5794 } else if (val->id == CSSValueNone) 5794 } else if (val->id == CSSValueNone)
5795 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone)); 5795 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone));
5796 } 5796 }
5797 5797
5798 if (!context.canAdvance() && context.allowImageSlice()) { 5798 if (!context.canAdvance() && context.allowImageSlice()) {
5799 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; 5799 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr;
5800 if (parseBorderImageSlice(propId, imageSlice)) 5800 if (parseBorderImageSlice(propId, imageSlice))
5801 context.commitImageSlice(imageSlice.release()); 5801 context.commitImageSlice(imageSlice.release());
5802 } 5802 }
5803 5803
5804 if (!context.canAdvance() && context.allowRepeat()) { 5804 if (!context.canAdvance() && context.allowRepeat()) {
5805 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; 5805 NullableCSSValue repeat;
5806 if (parseBorderImageRepeat(repeat)) 5806 if (parseBorderImageRepeat(repeat))
5807 context.commitRepeat(repeat.release()); 5807 context.commitRepeat(*repeat);
5808 } 5808 }
5809 5809
5810 if (!context.canAdvance() && context.allowWidth()) { 5810 if (!context.canAdvance() && context.allowWidth()) {
5811 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; 5811 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr;
5812 if (parseBorderImageWidth(borderWidth)) 5812 if (parseBorderImageWidth(borderWidth))
5813 context.commitBorderWidth(borderWidth.release()); 5813 context.commitBorderWidth(borderWidth.release());
5814 } 5814 }
5815 5815
5816 if (!context.canAdvance() && context.requireOutset()) { 5816 if (!context.canAdvance() && context.requireOutset()) {
5817 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; 5817 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr;
5818 if (parseBorderImageOutset(borderOutset)) 5818 if (parseBorderImageOutset(borderOutset))
5819 context.commitBorderOutset(borderOutset.release()); 5819 context.commitBorderOutset(borderOutset.release());
5820 } 5820 }
5821 5821
5822 if (!context.canAdvance()) 5822 if (!context.canAdvance())
5823 return false; 5823 return false;
5824 5824
5825 m_valueList->next(); 5825 m_valueList->next();
5826 } 5826 }
5827 5827
5828 return context.allowCommit(); 5828 return context.allowCommit();
5829 } 5829 }
5830 5830
5831 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) 5831 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, Nullable CSSValue value, bool important)
5832 { 5832 {
5833 if (value) 5833 if (value)
5834 addProperty(propId, value, important); 5834 addProperty(propId, *value, important);
5835 else 5835 else
5836 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true); 5836 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true);
5837 } 5837 }
5838 5838
5839 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant) 5839 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant)
5840 { 5840 {
5841 BorderImageParseContext context; 5841 BorderImageParseContext context;
5842 if (buildBorderImageParseContext(propId, context)) { 5842 if (buildBorderImageParseContext(propId, context)) {
5843 switch (propId) { 5843 switch (propId) {
5844 case CSSPropertyWebkitMaskBoxImage: 5844 case CSSPropertyWebkitMaskBoxImage:
5845 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important); 5845 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important);
5846 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important); 5846 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important);
5847 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important); 5847 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important);
5848 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important); 5848 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important);
5849 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat.get(), important); 5849 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat, important);
5850 return true; 5850 return true;
5851 case CSSPropertyBorderImage: 5851 case CSSPropertyBorderImage:
5852 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important); 5852 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important);
5853 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important); 5853 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important);
5854 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important); 5854 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important);
5855 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important); 5855 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important);
5856 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important); 5856 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important);
5857 return true; 5857 return true;
5858 default: 5858 default:
5859 ASSERT_NOT_REACHED(); 5859 ASSERT_NOT_REACHED();
5860 return false; 5860 return false;
5861 } 5861 }
5862 } 5862 }
5863 return false; 5863 return false;
5864 } 5864 }
5865 5865
5866 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty ID propId) 5866 NullableCSSValue CSSPropertyParser::parseBorderImage(CSSPropertyID propId)
5867 { 5867 {
5868 BorderImageParseContext context; 5868 BorderImageParseContext context;
5869 if (buildBorderImageParseContext(propId, context)) { 5869 if (buildBorderImageParseContext(propId, context)) {
5870 return context.commitCSSValue(); 5870 return context.commitCSSValue();
5871 } 5871 }
5872 return nullptr; 5872 return nullptr;
5873 } 5873 }
5874 5874
5875 static bool isBorderImageRepeatKeyword(int id) 5875 static bool isBorderImageRepeatKeyword(int id)
5876 { 5876 {
5877 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound; 5877 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound;
5878 } 5878 }
5879 5879
5880 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res ult) 5880 bool CSSPropertyParser::parseBorderImageRepeat(NullableCSSValue& result)
5881 { 5881 {
5882 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; 5882 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr;
5883 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; 5883 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr;
5884 CSSParserValue* val = m_valueList->current(); 5884 CSSParserValue* val = m_valueList->current();
5885 if (!val) 5885 if (!val)
5886 return false; 5886 return false;
5887 if (isBorderImageRepeatKeyword(val->id)) 5887 if (isBorderImageRepeatKeyword(val->id))
5888 firstValue = cssValuePool().createIdentifierValue(val->id); 5888 firstValue = cssValuePool().createIdentifierValue(val->id);
5889 else 5889 else
5890 return false; 5890 return false;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
6179 completeBorderRadii(radii[1]); 6179 completeBorderRadii(radii[1]);
6180 6180
6181 ImplicitScope implicitScope(this); 6181 ImplicitScope implicitScope(this);
6182 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important); 6182 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important);
6183 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important); 6183 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important);
6184 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important); 6184 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important);
6185 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important); 6185 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important);
6186 return true; 6186 return true;
6187 } 6187 }
6188 6188
6189 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu e) 6189 NullableCSSValue CSSPropertyParser::parseCounter(int defaultValue)
6190 { 6190 {
6191 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 6191 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
6192 6192
6193 while (m_valueList->current()) { 6193 while (m_valueList->current()) {
6194 CSSParserValue* val = m_valueList->current(); 6194 CSSParserValue* val = m_valueList->current();
6195 if (val->unit != CSSPrimitiveValue::CSS_IDENT) 6195 if (val->unit != CSSPrimitiveValue::CSS_IDENT)
6196 return nullptr; 6196 return nullptr;
6197 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val); 6197 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val);
6198 m_valueList->next(); 6198 m_valueList->next();
6199 6199
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
6288 stop.m_color = cssValuePool().createIdentifierValue(id); 6288 stop.m_color = cssValuePool().createIdentifierValue(id);
6289 else 6289 else
6290 stop.m_color = parseColor(stopArg); 6290 stop.m_color = parseColor(stopArg);
6291 if (!stop.m_color) 6291 if (!stop.m_color)
6292 return false; 6292 return false;
6293 } 6293 }
6294 6294
6295 return true; 6295 return true;
6296 } 6296 }
6297 6297
6298 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R efPtrWillBeRawPtr<CSSValue>& gradient) 6298 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, N ullableCSSValue& gradient)
6299 { 6299 {
6300 // Walk the arguments. 6300 // Walk the arguments.
6301 CSSParserValueList* args = valueList->current()->function->args.get(); 6301 CSSParserValueList* args = valueList->current()->function->args.get();
6302 if (!args || args->size() == 0) 6302 if (!args || args->size() == 0)
6303 return false; 6303 return false;
6304 6304
6305 // The first argument is the gradient type. It is an identifier. 6305 // The first argument is the gradient type. It is an identifier.
6306 CSSGradientType gradientType; 6306 CSSGradientType gradientType;
6307 CSSParserValue* a = args->current(); 6307 CSSParserValue* a = args->current();
6308 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) 6308 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6441 case CSSValueTop: 6441 case CSSValueTop:
6442 case CSSValueBottom: 6442 case CSSValueBottom:
6443 isHorizontal = false; 6443 isHorizontal = false;
6444 break; 6444 break;
6445 default: 6445 default:
6446 return nullptr; 6446 return nullptr;
6447 } 6447 }
6448 return cssValuePool().createIdentifierValue(a->id); 6448 return cssValuePool().createIdentifierValue(a->id);
6449 } 6449 }
6450 6450
6451 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6451 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, NullableCSSValue& gradient, CSSGradientRepeat repeating)
6452 { 6452 {
6453 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient); 6453 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient);
6454 6454
6455 // Walk the arguments. 6455 // Walk the arguments.
6456 CSSParserValueList* args = valueList->current()->function->args.get(); 6456 CSSParserValueList* args = valueList->current()->function->args.get();
6457 if (!args || !args->size()) 6457 if (!args || !args->size())
6458 return false; 6458 return false;
6459 6459
6460 CSSParserValue* a = args->current(); 6460 CSSParserValue* a = args->current();
6461 if (!a) 6461 if (!a)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6511 if (!parseGradientColorStops(args, result.get(), expectComma)) 6511 if (!parseGradientColorStops(args, result.get(), expectComma))
6512 return false; 6512 return false;
6513 6513
6514 if (!result->stopCount()) 6514 if (!result->stopCount())
6515 return false; 6515 return false;
6516 6516
6517 gradient = result.release(); 6517 gradient = result.release();
6518 return true; 6518 return true;
6519 } 6519 }
6520 6520
6521 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6521 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL ist, NullableCSSValue& gradient, CSSGradientRepeat repeating)
6522 { 6522 {
6523 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSPrefixedRadialGradient); 6523 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSPrefixedRadialGradient);
6524 6524
6525 // Walk the arguments. 6525 // Walk the arguments.
6526 CSSParserValueList* args = valueList->current()->function->args.get(); 6526 CSSParserValueList* args = valueList->current()->function->args.get();
6527 if (!args || !args->size()) 6527 if (!args || !args->size())
6528 return false; 6528 return false;
6529 6529
6530 CSSParserValue* a = args->current(); 6530 CSSParserValue* a = args->current();
6531 if (!a) 6531 if (!a)
6532 return false; 6532 return false;
6533 6533
6534 bool expectComma = false; 6534 bool expectComma = false;
6535 6535
6536 // Optional background-position 6536 // Optional background-position
6537 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 6537 NullableCSSValue centerX;
6538 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 6538 NullableCSSValue centerY;
6539 // parse2ValuesFillPosition advances the args next pointer. 6539 // parse2ValuesFillPosition advances the args next pointer.
6540 parse2ValuesFillPosition(args, centerX, centerY); 6540 parse2ValuesFillPosition(args, centerX, centerY);
6541 6541
6542 if ((centerX || centerY) && !consumeComma(args)) 6542 if ((centerX || centerY) && !consumeComma(args))
6543 return false; 6543 return false;
6544 6544
6545 a = args->current(); 6545 a = args->current();
6546 if (!a) 6546 if (!a)
6547 return false; 6547 return false;
6548 6548
6549 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6549 result->setFirstX(toCSSPrimitiveValue(centerX));
6550 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6550 result->setSecondX(toCSSPrimitiveValue(centerX));
6551 // CSS3 radial gradients always share the same start and end point. 6551 // CSS3 radial gradients always share the same start and end point.
6552 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6552 result->setFirstY(toCSSPrimitiveValue(centerY));
6553 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6553 result->setSecondY(toCSSPrimitiveValue(centerY));
6554 6554
6555 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; 6555 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr;
6556 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; 6556 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr;
6557 6557
6558 // Optional shape and/or size in any order. 6558 // Optional shape and/or size in any order.
6559 for (int i = 0; i < 2; ++i) { 6559 for (int i = 0; i < 2; ++i) {
6560 if (a->unit != CSSPrimitiveValue::CSS_IDENT) 6560 if (a->unit != CSSPrimitiveValue::CSS_IDENT)
6561 break; 6561 break;
6562 6562
6563 bool foundValue = false; 6563 bool foundValue = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6623 result->setEndHorizontalSize(horizontalSize); 6623 result->setEndHorizontalSize(horizontalSize);
6624 result->setEndVerticalSize(verticalSize); 6624 result->setEndVerticalSize(verticalSize);
6625 6625
6626 if (!parseGradientColorStops(args, result.get(), expectComma)) 6626 if (!parseGradientColorStops(args, result.get(), expectComma))
6627 return false; 6627 return false;
6628 6628
6629 gradient = result.release(); 6629 gradient = result.release();
6630 return true; 6630 return true;
6631 } 6631 }
6632 6632
6633 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6633 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, Nulla bleCSSValue& gradient, CSSGradientRepeat repeating)
6634 { 6634 {
6635 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSLinearGradient); 6635 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSLinearGradient);
6636 6636
6637 CSSParserFunction* function = valueList->current()->function; 6637 CSSParserFunction* function = valueList->current()->function;
6638 CSSParserValueList* args = function->args.get(); 6638 CSSParserValueList* args = function->args.get();
6639 if (!args || !args->size()) 6639 if (!args || !args->size())
6640 return false; 6640 return false;
6641 6641
6642 CSSParserValue* a = args->current(); 6642 CSSParserValue* a = args->current();
6643 if (!a) 6643 if (!a)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6697 if (!parseGradientColorStops(args, result.get(), expectComma)) 6697 if (!parseGradientColorStops(args, result.get(), expectComma))
6698 return false; 6698 return false;
6699 6699
6700 if (!result->stopCount()) 6700 if (!result->stopCount())
6701 return false; 6701 return false;
6702 6702
6703 gradient = result.release(); 6703 gradient = result.release();
6704 return true; 6704 return true;
6705 } 6705 }
6706 6706
6707 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6707 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, Nulla bleCSSValue& gradient, CSSGradientRepeat repeating)
6708 { 6708 {
6709 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSRadialGradient); 6709 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSRadialGradient);
6710 6710
6711 CSSParserValueList* args = valueList->current()->function->args.get(); 6711 CSSParserValueList* args = valueList->current()->function->args.get();
6712 if (!args || !args->size()) 6712 if (!args || !args->size())
6713 return false; 6713 return false;
6714 6714
6715 CSSParserValue* a = args->current(); 6715 CSSParserValue* a = args->current();
6716 if (!a) 6716 if (!a)
6717 return false; 6717 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
6789 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) 6789 if (!verticalSize && horizontalSize && horizontalSize->isPercentage())
6790 return false; 6790 return false;
6791 6791
6792 result->setShape(shapeValue); 6792 result->setShape(shapeValue);
6793 result->setSizingBehavior(sizeValue); 6793 result->setSizingBehavior(sizeValue);
6794 result->setEndHorizontalSize(horizontalSize); 6794 result->setEndHorizontalSize(horizontalSize);
6795 result->setEndVerticalSize(verticalSize); 6795 result->setEndVerticalSize(verticalSize);
6796 6796
6797 // Second part of grammar, the center-position clause: 6797 // Second part of grammar, the center-position clause:
6798 // at <position> 6798 // at <position>
6799 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 6799 NullableCSSValue centerX;
6800 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 6800 NullableCSSValue centerY;
6801 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) { 6801 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) {
6802 a = args->next(); 6802 a = args->next();
6803 if (!a) 6803 if (!a)
6804 return false; 6804 return false;
6805 6805
6806 parseFillPosition(args, centerX, centerY); 6806 parseFillPosition(args, centerX, centerY);
6807 if (!(centerX && centerY)) 6807 if (!(centerX && centerY))
6808 return false; 6808 return false;
6809 6809
6810 a = args->current(); 6810 a = args->current();
6811 if (!a) 6811 if (!a)
6812 return false; 6812 return false;
6813 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6813 result->setFirstX(toCSSPrimitiveValue(centerX));
6814 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6814 result->setFirstY(toCSSPrimitiveValue(centerY));
6815 // Right now, CSS radial gradients have the same start and end centers. 6815 // Right now, CSS radial gradients have the same start and end centers.
6816 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6816 result->setSecondX(toCSSPrimitiveValue(centerX));
6817 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6817 result->setSecondY(toCSSPrimitiveValue(centerY));
6818 } 6818 }
6819 6819
6820 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) 6820 if (shapeValue || sizeValue || horizontalSize || centerX || centerY)
6821 expectComma = true; 6821 expectComma = true;
6822 6822
6823 if (!parseGradientColorStops(args, result.get(), expectComma)) 6823 if (!parseGradientColorStops(args, result.get(), expectComma))
6824 return false; 6824 return false;
6825 6825
6826 gradient = result.release(); 6826 gradient = result.release();
6827 return true; 6827 return true;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
6882 } 6882 }
6883 6883
6884 // The last color stop cannot be a color hint. 6884 // The last color stop cannot be a color hint.
6885 if (previousStopWasColorHint) 6885 if (previousStopWasColorHint)
6886 return false; 6886 return false;
6887 6887
6888 // Must have 2 or more stops to be valid. 6888 // Must have 2 or more stops to be valid.
6889 return gradient->stopCount() >= 2; 6889 return gradient->stopCount() >= 2;
6890 } 6890 }
6891 6891
6892 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& value) 6892 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, Nulla bleCSSValue& value)
6893 { 6893 {
6894 CSSParserValue* val = valueList->current(); 6894 CSSParserValue* val = valueList->current();
6895 6895
6896 if (val->unit != CSSParserValue::Function) 6896 if (val->unit != CSSParserValue::Function)
6897 return false; 6897 return false;
6898 6898
6899 if (val->function->id == CSSValueWebkitGradient) { 6899 if (val->function->id == CSSValueWebkitGradient) {
6900 // FIXME: This should send a deprecation message. 6900 // FIXME: This should send a deprecation message.
6901 if (m_context.useCounter()) 6901 if (m_context.useCounter())
6902 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); 6902 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6944 6944
6945 if (val->function->id == CSSValueWebkitCanvas) 6945 if (val->function->id == CSSValueWebkitCanvas)
6946 return parseCanvas(valueList, value); 6946 return parseCanvas(valueList, value);
6947 6947
6948 if (val->function->id == CSSValueWebkitCrossFade) 6948 if (val->function->id == CSSValueWebkitCrossFade)
6949 return parseCrossfade(valueList, value); 6949 return parseCrossfade(valueList, value);
6950 6950
6951 return false; 6951 return false;
6952 } 6952 }
6953 6953
6954 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& crossfade) 6954 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, NullableCS SValue& crossfade)
6955 { 6955 {
6956 // Walk the arguments. 6956 // Walk the arguments.
6957 CSSParserValueList* args = valueList->current()->function->args.get(); 6957 CSSParserValueList* args = valueList->current()->function->args.get();
6958 if (!args || args->size() != 5) 6958 if (!args || args->size() != 5)
6959 return false; 6959 return false;
6960 RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr; 6960 NullableCSSValue fromImageValue;
6961 RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr; 6961 NullableCSSValue toImageValue;
6962 6962
6963 // The first argument is the "from" image. It is a fill image. 6963 // The first argument is the "from" image. It is a fill image.
6964 if (!args->current() || !parseFillImage(args, fromImageValue)) 6964 if (!args->current() || !parseFillImage(args, fromImageValue))
6965 return false; 6965 return false;
6966 args->next(); 6966 args->next();
6967 6967
6968 if (!consumeComma(args)) 6968 if (!consumeComma(args))
6969 return false; 6969 return false;
6970 6970
6971 // The second argument is the "to" image. It is a fill image. 6971 // The second argument is the "to" image. It is a fill image.
(...skipping 10 matching lines...) Expand all
6982 if (!value) 6982 if (!value)
6983 return false; 6983 return false;
6984 6984
6985 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE) 6985 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
6986 percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER); 6986 percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
6987 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) 6987 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
6988 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0 , 1), CSSPrimitiveValue::CSS_NUMBER); 6988 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0 , 1), CSSPrimitiveValue::CSS_NUMBER);
6989 else 6989 else
6990 return false; 6990 return false;
6991 6991
6992 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fro mImageValue, toImageValue); 6992 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(*fr omImageValue, *toImageValue);
6993 result->setPercentage(percentage); 6993 result->setPercentage(percentage);
6994 6994
6995 crossfade = result; 6995 crossfade = result;
6996 6996
6997 return true; 6997 return true;
6998 } 6998 }
6999 6999
7000 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, RefPtrWillBeR awPtr<CSSValue>& canvas) 7000 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, NullableCSSVa lue& canvas)
7001 { 7001 {
7002 // Walk the arguments. 7002 // Walk the arguments.
7003 CSSParserValueList* args = valueList->current()->function->args.get(); 7003 CSSParserValueList* args = valueList->current()->function->args.get();
7004 if (!args || args->size() != 1) 7004 if (!args || args->size() != 1)
7005 return false; 7005 return false;
7006 7006
7007 // The first argument is the canvas name. It is an identifier. 7007 // The first argument is the canvas name. It is an identifier.
7008 CSSParserValue* value = args->current(); 7008 CSSParserValue* value = args->current();
7009 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) 7009 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT)
7010 return false; 7010 return false;
7011 7011
7012 canvas = CSSCanvasValue::create(value->string); 7012 canvas = CSSCanvasValue::create(value->string);
7013 return true; 7013 return true;
7014 } 7014 }
7015 7015
7016 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue List* valueList) 7016 NullableCSSValue CSSPropertyParser::parseImageSet(CSSParserValueList* valueList)
7017 { 7017 {
7018 CSSParserValue* function = valueList->current(); 7018 CSSParserValue* function = valueList->current();
7019 7019
7020 if (function->unit != CSSParserValue::Function) 7020 if (function->unit != CSSParserValue::Function)
7021 return nullptr; 7021 return nullptr;
7022 7022
7023 CSSParserValueList* functionArgs = valueList->current()->function->args.get( ); 7023 CSSParserValueList* functionArgs = valueList->current()->function->args.get( );
7024 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) 7024 if (!functionArgs || !functionArgs->size() || !functionArgs->current())
7025 return nullptr; 7025 return nullptr;
7026 7026
7027 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); 7027 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
7028 7028
7029 while (functionArgs->current()) { 7029 while (functionArgs->current()) {
7030 CSSParserValue* arg = functionArgs->current(); 7030 CSSParserValue* arg = functionArgs->current();
7031 if (arg->unit != CSSPrimitiveValue::CSS_URI) 7031 if (arg->unit != CSSPrimitiveValue::CSS_URI)
7032 return nullptr; 7032 return nullptr;
7033 7033
7034 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg ->string, completeURL(arg->string)); 7034 CSSValue image = createCSSImageValueWithReferrer(arg->string, completeUR L(arg->string));
7035 imageSet->append(image); 7035 imageSet->append(image);
7036 7036
7037 arg = functionArgs->next(); 7037 arg = functionArgs->next();
7038 if (!arg) 7038 if (!arg)
7039 return nullptr; 7039 return nullptr;
7040 7040
7041 if (arg->unit != CSSParserValue::DimensionList) 7041 if (arg->unit != CSSParserValue::DimensionList)
7042 return nullptr; 7042 return nullptr;
7043 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER ); 7043 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER );
7044 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT) ; 7044 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT) ;
(...skipping 10 matching lines...) Expand all
7055 break; 7055 break;
7056 7056
7057 // If there are more arguments, they should be after a comma. 7057 // If there are more arguments, they should be after a comma.
7058 if (!consumeComma(functionArgs)) 7058 if (!consumeComma(functionArgs))
7059 return nullptr; 7059 return nullptr;
7060 } 7060 }
7061 7061
7062 return imageSet.release(); 7062 return imageSet.release();
7063 } 7063 }
7064 7064
7065 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange() 7065 NullableCSSValue CSSPropertyParser::parseWillChange()
7066 { 7066 {
7067 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 7067 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
7068 if (m_valueList->current()->id == CSSValueAuto) { 7068 if (m_valueList->current()->id == CSSValueAuto) {
7069 // FIXME: This will be read back as an empty string instead of auto 7069 // FIXME: This will be read back as an empty string instead of auto
7070 return values.release(); 7070 return values.release();
7071 } 7071 }
7072 7072
7073 // Every comma-separated list of CSS_IDENTs is a valid will-change value, 7073 // Every comma-separated list of CSS_IDENTs is a valid will-change value,
7074 // unless the list includes an explicitly disallowed CSS_IDENT. 7074 // unless the list includes an explicitly disallowed CSS_IDENT.
7075 while (true) { 7075 while (true) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
7228 } 7228 }
7229 } 7229 }
7230 7230
7231 return list.release(); 7231 return list.release();
7232 } 7232 }
7233 7233
7234 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() 7234 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin()
7235 { 7235 {
7236 CSSParserValue* value = m_valueList->current(); 7236 CSSParserValue* value = m_valueList->current();
7237 CSSValueID id = value->id; 7237 CSSValueID id = value->id;
7238 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 7238 NullableCSSValue xValue;
7239 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 7239 NullableCSSValue yValue;
7240 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; 7240 NullableCSSValue zValue;
7241 if (id == CSSValueLeft || id == CSSValueRight) { 7241 if (id == CSSValueLeft || id == CSSValueRight) {
7242 xValue = cssValuePool().createIdentifierValue(id); 7242 xValue = cssValuePool().createIdentifierValue(id);
7243 } else if (id == CSSValueTop || id == CSSValueBottom) { 7243 } else if (id == CSSValueTop || id == CSSValueBottom) {
7244 yValue = cssValuePool().createIdentifierValue(id); 7244 yValue = cssValuePool().createIdentifierValue(id);
7245 } else if (id == CSSValueCenter) { 7245 } else if (id == CSSValueCenter) {
7246 // Unresolved as to whether this is X or Y. 7246 // Unresolved as to whether this is X or Y.
7247 } else if (validUnit(value, FPercent | FLength)) { 7247 } else if (validUnit(value, FPercent | FLength)) {
7248 xValue = createPrimitiveNumericValue(value); 7248 xValue = createPrimitiveNumericValue(value);
7249 } else { 7249 } else {
7250 return nullptr; 7250 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
7283 } 7283 }
7284 } else if (!xValue) { 7284 } else if (!xValue) {
7285 if (yValue) { 7285 if (yValue) {
7286 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE); 7286 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE);
7287 } else { 7287 } else {
7288 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); 7288 xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
7289 } 7289 }
7290 } 7290 }
7291 7291
7292 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7292 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7293 list->append(xValue.release()); 7293 list->append(*xValue);
7294 if (yValue) 7294 if (yValue)
7295 list->append(yValue.release()); 7295 list->append(*yValue);
7296 if (zValue) 7296 if (zValue)
7297 list->append(zValue.release()); 7297 list->append(*zValue);
7298 return list.release(); 7298 return list.release();
7299 } 7299 }
7300 7300
7301 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction() 7301 NullableCSSValue CSSPropertyParser::parseTouchAction()
7302 { 7302 {
7303 CSSParserValue* value = m_valueList->current(); 7303 CSSParserValue* value = m_valueList->current();
7304 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7304 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7305 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value ->id == CSSValueNone || value->id == CSSValueManipulation)) { 7305 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value ->id == CSSValueNone || value->id == CSSValueManipulation)) {
7306 list->append(cssValuePool().createIdentifierValue(value->id)); 7306 list->append(cssValuePool().createIdentifierValue(value->id));
7307 m_valueList->next(); 7307 m_valueList->next();
7308 return list.release(); 7308 return list.release();
7309 } 7309 }
7310 7310
7311 bool xSet = false; 7311 bool xSet = false;
7312 bool ySet = false; 7312 bool ySet = false;
7313 while (value) { 7313 while (value) {
7314 switch (value->id) { 7314 switch (value->id) {
7315 case CSSValuePanX: 7315 case CSSValuePanX:
7316 case CSSValuePanRight: 7316 case CSSValuePanRight:
7317 case CSSValuePanLeft: { 7317 case CSSValuePanLeft: {
7318 if (xSet) 7318 if (xSet)
7319 return nullptr; 7319 return nullptr;
7320 xSet = true; 7320 xSet = true;
7321 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled()) 7321 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled())
7322 return nullptr; 7322 return nullptr;
7323 7323
7324 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif ierValue(value->id); 7324 CSSValue panValue = cssValuePool().createIdentifierValue(value->id);
7325 list->append(panValue.release()); 7325 list->append(panValue);
7326 break; 7326 break;
7327 } 7327 }
7328 case CSSValuePanY: 7328 case CSSValuePanY:
7329 case CSSValuePanDown: 7329 case CSSValuePanDown:
7330 case CSSValuePanUp: { 7330 case CSSValuePanUp: {
7331 if (ySet) 7331 if (ySet)
7332 return nullptr; 7332 return nullptr;
7333 ySet = true; 7333 ySet = true;
7334 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled()) 7334 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled())
7335 return nullptr; 7335 return nullptr;
7336 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif ierValue(value->id); 7336 CSSValue panValue = cssValuePool().createIdentifierValue(value->id);
7337 list->append(panValue.release()); 7337 list->append(panValue);
7338 break; 7338 break;
7339 } 7339 }
7340 default: 7340 default:
7341 return nullptr; 7341 return nullptr;
7342 } 7342 }
7343 value = m_valueList->next(); 7343 value = m_valueList->next();
7344 } 7344 }
7345 7345
7346 if (list->length()) 7346 if (list->length())
7347 return list.release(); 7347 return list.release();
7348 7348
7349 return nullptr; 7349 return nullptr;
7350 } 7350 }
7351 7351
7352 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollBlocksOn() 7352 NullableCSSValue CSSPropertyParser::parseScrollBlocksOn()
7353 { 7353 {
7354 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7354 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7355 CSSParserValue* value = m_valueList->current(); 7355 CSSParserValue* value = m_valueList->current();
7356 while (value) { 7356 while (value) {
7357 switch (value->id) { 7357 switch (value->id) {
7358 case CSSValueStartTouch: 7358 case CSSValueStartTouch:
7359 case CSSValueWheelEvent: 7359 case CSSValueWheelEvent:
7360 case CSSValueScrollEvent: { 7360 case CSSValueScrollEvent: {
7361 RefPtrWillBeRawPtr<CSSValue> flagValue = cssValuePool().createIdenti fierValue(value->id); 7361 CSSValue flagValue = cssValuePool().createIdentifierValue(value->id) ;
7362 if (list->hasValue(flagValue.get())) 7362 if (list->hasValue(flagValue))
7363 return nullptr; 7363 return nullptr;
7364 list->append(flagValue.release()); 7364 list->append(flagValue);
7365 break; 7365 break;
7366 } 7366 }
7367 default: 7367 default:
7368 return nullptr; 7368 return nullptr;
7369 } 7369 }
7370 value = m_valueList->next(); 7370 value = m_valueList->next();
7371 } 7371 }
7372 7372
7373 ASSERT(list->length()); 7373 ASSERT(list->length());
7374 return list.release(); 7374 return list.release();
7375 } 7375 }
7376 7376
7377 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) 7377 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, CSSValue value, bool important)
7378 { 7378 {
7379 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set. 7379 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set.
7380 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { 7380 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) {
7381 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 7381 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
7382 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) 7382 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine)
7383 return; 7383 return;
7384 } 7384 }
7385 } 7385 }
7386 addProperty(propId, value, important); 7386 addProperty(propId, value, important);
7387 } 7387 }
(...skipping 29 matching lines...) Expand all
7417 7417
7418 // Values are either valid or in shorthand scope. 7418 // Values are either valid or in shorthand scope.
7419 if (list->length() && (isValid || inShorthand())) { 7419 if (list->length() && (isValid || inShorthand())) {
7420 addTextDecorationProperty(propId, list.release(), important); 7420 addTextDecorationProperty(propId, list.release(), important);
7421 return true; 7421 return true;
7422 } 7422 }
7423 7423
7424 return false; 7424 return false;
7425 } 7425 }
7426 7426
7427 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() 7427 NullableCSSValue CSSPropertyParser::parseTextEmphasisStyle()
7428 { 7428 {
7429 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; 7429 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
7430 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; 7430 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
7431 7431
7432 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7432 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7433 if (value->unit == CSSPrimitiveValue::CSS_STRING) { 7433 if (value->unit == CSSPrimitiveValue::CSS_STRING) {
7434 if (fill || shape) 7434 if (fill || shape)
7435 return nullptr; 7435 return nullptr;
7436 m_valueList->next(); 7436 m_valueList->next();
7437 return createPrimitiveStringValue(value); 7437 return createPrimitiveStringValue(value);
(...skipping 26 matching lines...) Expand all
7464 return parsedValues.release(); 7464 return parsedValues.release();
7465 } 7465 }
7466 if (fill) 7466 if (fill)
7467 return fill.release(); 7467 return fill.release();
7468 if (shape) 7468 if (shape)
7469 return shape.release(); 7469 return shape.release();
7470 7470
7471 return nullptr; 7471 return nullptr;
7472 } 7472 }
7473 7473
7474 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() 7474 NullableCSSValue CSSPropertyParser::parseTextIndent()
7475 { 7475 {
7476 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7476 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7477 7477
7478 bool hasLengthOrPercentage = false; 7478 bool hasLengthOrPercentage = false;
7479 bool hasEachLine = false; 7479 bool hasEachLine = false;
7480 bool hasHanging = false; 7480 bool hasHanging = false;
7481 7481
7482 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7482 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7483 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false 7483 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false
7484 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni tlessQuirk)) { 7484 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni tlessQuirk)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
7570 m_valueList->next(); 7570 m_valueList->next();
7571 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { 7571 } else if (value->id == CSSValueOn || value->id == CSSValueOff) {
7572 tagValue = value->id == CSSValueOn; 7572 tagValue = value->id == CSSValueOn;
7573 m_valueList->next(); 7573 m_valueList->next();
7574 } 7574 }
7575 } 7575 }
7576 settings->append(CSSFontFeatureValue::create(tag, tagValue)); 7576 settings->append(CSSFontFeatureValue::create(tag, tagValue));
7577 return true; 7577 return true;
7578 } 7578 }
7579 7579
7580 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() 7580 NullableCSSValue CSSPropertyParser::parseFontFeatureSettings()
7581 { 7581 {
7582 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat ed(); 7582 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat ed();
7583 while (true) { 7583 while (true) {
7584 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) 7584 if (!m_valueList->current() || !parseFontFeatureTag(settings.get()))
7585 return nullptr; 7585 return nullptr;
7586 if (!m_valueList->current()) 7586 if (!m_valueList->current())
7587 break; 7587 break;
7588 if (!consumeComma(m_valueList)) 7588 if (!consumeComma(m_valueList))
7589 return nullptr; 7589 return nullptr;
7590 } 7590 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7659 return false; 7659 return false;
7660 7660
7661 return true; 7661 return true;
7662 } 7662 }
7663 7663
7664 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) 7664 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId)
7665 { 7665 {
7666 CSSParserValue* value = m_valueList->current(); 7666 CSSParserValue* value = m_valueList->current();
7667 ASSERT(value); 7667 ASSERT(value);
7668 CSSValueID id = value->id; 7668 CSSValueID id = value->id;
7669 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7669 NullableCSSValue parsedValue;
7670 7670
7671 switch (propId) { 7671 switch (propId) {
7672 case CSSPropertyFontFamily: 7672 case CSSPropertyFontFamily:
7673 // <family-name> 7673 // <family-name>
7674 // TODO(rwlbuis): check there is only one family-name 7674 // TODO(rwlbuis): check there is only one family-name
7675 parsedValue = parseFontFamily(); 7675 parsedValue = parseFontFamily();
7676 break; 7676 break;
7677 case CSSPropertySrc: // This is a list of urls or local references. 7677 case CSSPropertySrc: // This is a list of urls or local references.
7678 parsedValue = parseFontFaceSrc(); 7678 parsedValue = parseFontFaceSrc();
7679 break; 7679 break;
(...skipping 20 matching lines...) Expand all
7700 parsedValue = parseFontFeatureSettings(); 7700 parsedValue = parseFontFeatureSettings();
7701 } 7701 }
7702 break; 7702 break;
7703 default: 7703 default:
7704 break; 7704 break;
7705 } 7705 }
7706 7706
7707 if (!parsedValue || m_valueList->current()) 7707 if (!parsedValue || m_valueList->current())
7708 return false; 7708 return false;
7709 7709
7710 addProperty(propId, parsedValue.release(), false); 7710 addProperty(propId, *parsedValue, false);
7711 return true; 7711 return true;
7712 } 7712 }
7713 7713
7714 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt) 7714 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt)
7715 { 7715 {
7716 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7716 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
7717 7717
7718 CSSParserValue* value = m_valueList->current(); 7718 CSSParserValue* value = m_valueList->current();
7719 if (!value) 7719 if (!value)
7720 return false; 7720 return false;
(...skipping 27 matching lines...) Expand all
7748 if (id == CSSValueZoom || id == CSSValueFixed) 7748 if (id == CSSValueZoom || id == CSSValueFixed)
7749 validPrimitive = true; 7749 validPrimitive = true;
7750 break; 7750 break;
7751 case CSSPropertyOrientation: // auto | portrait | landscape 7751 case CSSPropertyOrientation: // auto | portrait | landscape
7752 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc ape) 7752 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc ape)
7753 validPrimitive = true; 7753 validPrimitive = true;
7754 default: 7754 default:
7755 break; 7755 break;
7756 } 7756 }
7757 7757
7758 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7758 NullableCSSValue parsedValue;
7759 if (validPrimitive) { 7759 if (validPrimitive) {
7760 parsedValue = parseValidPrimitive(id, value); 7760 parsedValue = parseValidPrimitive(id, value);
7761 m_valueList->next(); 7761 m_valueList->next();
7762 } 7762 }
7763 7763
7764 if (parsedValue) { 7764 if (parsedValue) {
7765 if (!m_valueList->current() || inShorthand()) { 7765 if (!m_valueList->current() || inShorthand()) {
7766 addProperty(propId, parsedValue.release(), important); 7766 addProperty(propId, *parsedValue, important);
7767 return true; 7767 return true;
7768 } 7768 }
7769 } 7769 }
7770 7770
7771 return false; 7771 return false;
7772 } 7772 }
7773 7773
7774 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty ID first, CSSPropertyID second, bool important) 7774 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty ID first, CSSPropertyID second, bool important)
7775 { 7775 {
7776 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7776 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
7889 } 7889 }
7890 7890
7891 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) 7891 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
7892 { 7892 {
7893 CSSParserValue* value = m_valueList->current(); 7893 CSSParserValue* value = m_valueList->current();
7894 ASSERT(value); 7894 ASSERT(value);
7895 7895
7896 CSSValueID id = value->id; 7896 CSSValueID id = value->id;
7897 7897
7898 bool validPrimitive = false; 7898 bool validPrimitive = false;
7899 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7899 NullableCSSValue parsedValue;
7900 7900
7901 switch (propId) { 7901 switch (propId) {
7902 /* The comment to the right defines all valid value of these 7902 /* The comment to the right defines all valid value of these
7903 * properties as defined in SVG 1.1, Appendix N. Property index */ 7903 * properties as defined in SVG 1.1, Appendix N. Property index */
7904 case CSSPropertyAlignmentBaseline: 7904 case CSSPropertyAlignmentBaseline:
7905 // auto | baseline | before-edge | text-before-edge | middle | 7905 // auto | baseline | before-edge | text-before-edge | middle |
7906 // central | after-edge | text-after-edge | ideographic | alphabetic | 7906 // central | after-edge | text-after-edge | ideographic | alphabetic |
7907 // hanging | mathematical | inherit 7907 // hanging | mathematical | inherit
7908 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle 7908 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle
7909 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical)) 7909 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical))
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
8034 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 8034 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
8035 RGBA32 c = Color::transparent; 8035 RGBA32 c = Color::transparent;
8036 if (m_valueList->next()) { 8036 if (m_valueList->next()) {
8037 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea teSpaceSeparated(); 8037 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea teSpaceSeparated();
8038 values->append(CSSPrimitiveValue::create(value->string, CSSP rimitiveValue::CSS_URI)); 8038 values->append(CSSPrimitiveValue::create(value->string, CSSP rimitiveValue::CSS_URI));
8039 if (parseColorFromValue(m_valueList->current(), c)) 8039 if (parseColorFromValue(m_valueList->current(), c))
8040 parsedValue = cssValuePool().createColorValue(c); 8040 parsedValue = cssValuePool().createColorValue(c);
8041 else if (m_valueList->current()->id == CSSValueNone || m_val ueList->current()->id == CSSValueCurrentcolor) 8041 else if (m_valueList->current()->id == CSSValueNone || m_val ueList->current()->id == CSSValueCurrentcolor)
8042 parsedValue = cssValuePool().createIdentifierValue(m_val ueList->current()->id); 8042 parsedValue = cssValuePool().createIdentifierValue(m_val ueList->current()->id);
8043 if (parsedValue) { 8043 if (parsedValue) {
8044 values->append(parsedValue); 8044 values->append(*parsedValue);
8045 parsedValue = values; 8045 parsedValue = values;
8046 } 8046 }
8047 } 8047 }
8048 if (!parsedValue) 8048 if (!parsedValue)
8049 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr imitiveValue::CSS_URI); 8049 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr imitiveValue::CSS_URI);
8050 } else { 8050 } else {
8051 parsedValue = parseColor(); 8051 parsedValue = parseColor();
8052 } 8052 }
8053 8053
8054 if (parsedValue) 8054 if (parsedValue)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
8115 /* shorthand properties */ 8115 /* shorthand properties */
8116 case CSSPropertyMarker: { 8116 case CSSPropertyMarker: {
8117 ShorthandScope scope(this, propId); 8117 ShorthandScope scope(this, propId);
8118 CSSPropertyParser::ImplicitScope implicitScope(this); 8118 CSSPropertyParser::ImplicitScope implicitScope(this);
8119 if (!parseValue(CSSPropertyMarkerStart, important)) 8119 if (!parseValue(CSSPropertyMarkerStart, important))
8120 return false; 8120 return false;
8121 if (m_valueList->current()) { 8121 if (m_valueList->current()) {
8122 rollbackLastProperties(1); 8122 rollbackLastProperties(1);
8123 return false; 8123 return false;
8124 } 8124 }
8125 CSSValue* value = m_parsedProperties.last().value(); 8125 CSSValue value = m_parsedProperties.last().value();
8126 addProperty(CSSPropertyMarkerMid, value, important); 8126 addProperty(CSSPropertyMarkerMid, value, important);
8127 addProperty(CSSPropertyMarkerEnd, value, important); 8127 addProperty(CSSPropertyMarkerEnd, value, important);
8128 return true; 8128 return true;
8129 } 8129 }
8130 default: 8130 default:
8131 // If you crash here, it's because you added a css property and are not handling it 8131 // If you crash here, it's because you added a css property and are not handling it
8132 // in either this switch statement or the one in CSSPropertyParser::pars eValue 8132 // in either this switch statement or the one in CSSPropertyParser::pars eValue
8133 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); 8133 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId);
8134 return false; 8134 return false;
8135 } 8135 }
(...skipping 13 matching lines...) Expand all
8149 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie 8149 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie
8150 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se()); 8150 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se());
8151 m_parsedCalculation.release(); 8151 m_parsedCalculation.release();
8152 parsedValue = nullptr; 8152 parsedValue = nullptr;
8153 } 8153 }
8154 m_valueList->next(); 8154 m_valueList->next();
8155 } 8155 }
8156 if (!parsedValue || (m_valueList->current() && !inShorthand())) 8156 if (!parsedValue || (m_valueList->current() && !inShorthand()))
8157 return false; 8157 return false;
8158 8158
8159 addProperty(propId, parsedValue.release(), important); 8159 addProperty(propId, *parsedValue, important);
8160 return true; 8160 return true;
8161 } 8161 }
8162 8162
8163 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray() 8163 NullableCSSValue CSSPropertyParser::parseSVGStrokeDasharray()
8164 { 8164 {
8165 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); 8165 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated();
8166 CSSParserValue* value = m_valueList->current(); 8166 CSSParserValue* value = m_valueList->current();
8167 bool validPrimitive = true; 8167 bool validPrimitive = true;
8168 while (value) { 8168 while (value) {
8169 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri buteMode); 8169 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri buteMode);
8170 if (!validPrimitive) 8170 if (!validPrimitive)
8171 break; 8171 break;
8172 if (value->id) 8172 if (value->id)
8173 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); 8173 ret->append(CSSPrimitiveValue::createIdentifier(value->id));
8174 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) 8174 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
8175 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType) value->unit)); 8175 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType) value->unit));
8176 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS SPrimitiveValue::CSS_CHS) 8176 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS SPrimitiveValue::CSS_CHS)
8177 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType)value->unit)); 8177 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType)value->unit));
8178 value = m_valueList->next(); 8178 value = m_valueList->next();
8179 bool commaConsumed = consumeComma(m_valueList); 8179 bool commaConsumed = consumeComma(m_valueList);
8180 value = m_valueList->current(); 8180 value = m_valueList->current();
8181 if (commaConsumed && !value) 8181 if (commaConsumed && !value)
8182 return nullptr; 8182 return nullptr;
8183 } 8183 }
8184 if (!validPrimitive) 8184 if (!validPrimitive)
8185 return nullptr; 8185 return nullptr;
8186 return ret.release(); 8186 return ret.release();
8187 } 8187 }
8188 8188
8189 // normal | [ fill || stroke || markers ] 8189 // normal | [ fill || stroke || markers ]
8190 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const 8190 NullableCSSValue CSSPropertyParser::parsePaintOrder() const
8191 { 8191 {
8192 if (m_valueList->size() > 3) 8192 if (m_valueList->size() > 3)
8193 return nullptr; 8193 return nullptr;
8194 8194
8195 CSSParserValue* value = m_valueList->current(); 8195 CSSParserValue* value = m_valueList->current();
8196 ASSERT(value); 8196 ASSERT(value);
8197 8197
8198 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 8198 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated();
8199 8199
8200 // The default paint-order is: Fill, Stroke, Markers. 8200 // The default paint-order is: Fill, Stroke, Markers.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
8343 CSSPropertyParser::Units m_unit; 8343 CSSPropertyParser::Units m_unit;
8344 }; 8344 };
8345 8345
8346 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL egacyParsing) 8346 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL egacyParsing)
8347 { 8347 {
8348 if (!m_valueList) 8348 if (!m_valueList)
8349 return nullptr; 8349 return nullptr;
8350 8350
8351 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 8351 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
8352 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8352 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8353 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue( useLegacyParsing, value); 8353 NullableCSSValue parsedTransformValue = parseTransformValue(useLegacyPar sing, value);
8354 if (!parsedTransformValue) 8354 if (!parsedTransformValue)
8355 return nullptr; 8355 return nullptr;
8356 8356
8357 list->append(parsedTransformValue.release()); 8357 list->append(*parsedTransformValue);
8358 } 8358 }
8359 8359
8360 return list.release(); 8360 return list.release();
8361 } 8361 }
8362 8362
8363 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(bool use LegacyParsing, CSSParserValue *value) 8363 NullableCSSValue CSSPropertyParser::parseTransformValue(bool useLegacyParsing, C SSParserValue *value)
8364 { 8364 {
8365 if (value->unit != CSSParserValue::Function || !value->function) 8365 if (value->unit != CSSParserValue::Function || !value->function)
8366 return nullptr; 8366 return nullptr;
8367 8367
8368 // Every primitive requires at least one argument. 8368 // Every primitive requires at least one argument.
8369 CSSParserValueList* args = value->function->args.get(); 8369 CSSParserValueList* args = value->function->args.get();
8370 if (!args) 8370 if (!args)
8371 return nullptr; 8371 return nullptr;
8372 8372
8373 // See if the specified primitive is one we understand. 8373 // See if the specified primitive is one we understand.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
8425 if (!isComma(a)) 8425 if (!isComma(a))
8426 return nullptr; 8426 return nullptr;
8427 a = args->next(); 8427 a = args->next();
8428 8428
8429 argNumber++; 8429 argNumber++;
8430 } 8430 }
8431 8431
8432 return transformValue.release(); 8432 return transformValue.release();
8433 } 8433 }
8434 8434
8435 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() 8435 NullableCSSValue CSSPropertyParser::parseMotionPath()
8436 { 8436 {
8437 CSSParserValue* value = m_valueList->current(); 8437 CSSParserValue* value = m_valueList->current();
8438 8438
8439 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. 8439 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>.
8440 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath) 8440 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath)
8441 return nullptr; 8441 return nullptr;
8442 8442
8443 // FIXME: Add support for <fill-rule>. 8443 // FIXME: Add support for <fill-rule>.
8444 CSSParserValueList* functionArgs = value->function->args.get(); 8444 CSSParserValueList* functionArgs = value->function->args.get();
8445 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) 8445 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current())
8446 return nullptr; 8446 return nullptr;
8447 8447
8448 CSSParserValue* arg = functionArgs->current(); 8448 CSSParserValue* arg = functionArgs->current();
8449 if (arg->unit != CSSPrimitiveValue::CSS_STRING) 8449 if (arg->unit != CSSPrimitiveValue::CSS_STRING)
8450 return nullptr; 8450 return nullptr;
8451 8451
8452 String pathString = arg->string; 8452 String pathString = arg->string;
8453 Path path; 8453 Path path;
8454 if (!buildPathFromString(pathString, path)) 8454 if (!buildPathFromString(pathString, path))
8455 return nullptr; 8455 return nullptr;
8456 8456
8457 m_valueList->next(); 8457 m_valueList->next();
8458 return CSSPathValue::create(pathString); 8458 return CSSPathValue::create(pathString);
8459 } 8459 }
8460 8460
8461 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionRotation() 8461 NullableCSSValue CSSPropertyParser::parseMotionRotation()
8462 { 8462 {
8463 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 8463 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
8464 bool hasAutoOrReverse = false; 8464 bool hasAutoOrReverse = false;
8465 bool hasAngle = false; 8465 bool hasAngle = false;
8466 8466
8467 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8467 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8468 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA utoOrReverse) { 8468 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA utoOrReverse) {
8469 list->append(cssValuePool().createIdentifierValue(value->id)); 8469 list->append(cssValuePool().createIdentifierValue(value->id));
8470 hasAutoOrReverse = true; 8470 hasAutoOrReverse = true;
8471 } else if (validUnit(value, FAngle) && !hasAngle) { 8471 } else if (validUnit(value, FAngle) && !hasAngle) {
8472 list->append(createPrimitiveNumericValue(value)); 8472 list->append(createPrimitiveNumericValue(value));
8473 hasAngle = true; 8473 hasAngle = true;
8474 } else { 8474 } else {
8475 break; 8475 break;
8476 } 8476 }
8477 } 8477 }
8478 8478
8479 if (!list->length()) 8479 if (!list->length())
8480 return nullptr; 8480 return nullptr;
8481 8481
8482 return list.release(); 8482 return list.release();
8483 } 8483 }
8484 8484
8485 } // namespace blink 8485 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698