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

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

Issue 1190303003: CL for perf tryjob on win (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CL for perf tryjob on mac 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // This doesn't count UA style sheets 115 // This doesn't count UA style sheets
116 if (parseSuccess && context.useCounter()) 116 if (parseSuccess && context.useCounter())
117 context.useCounter()->count(context, unresolvedProperty); 117 context.useCounter()->count(context, unresolvedProperty);
118 118
119 if (!parseSuccess) 119 if (!parseSuccess)
120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size); 120 parser.rollbackLastProperties(parsedProperties.size() - parsedProperties Size);
121 121
122 return parseSuccess; 122 return parseSuccess;
123 } 123 }
124 124
125 void CSSPropertyParser::addProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr <CSSValue> value, bool important, bool implicit) 125 void CSSPropertyParser::addProperty(CSSPropertyID propId, CSSValue value, bool i mportant, bool implicit)
126 { 126 {
127 ASSERT(!isPropertyAlias(propId)); 127 ASSERT(!isPropertyAlias(propId));
128 128
129 int shorthandIndex = 0; 129 int shorthandIndex = 0;
130 bool setFromShorthand = false; 130 bool setFromShorthand = false;
131 131
132 if (m_currentShorthand) { 132 if (m_currentShorthand) {
133 Vector<StylePropertyShorthand, 4> shorthands; 133 Vector<StylePropertyShorthand, 4> shorthands;
134 getMatchingShorthandsForLonghand(propId, &shorthands); 134 getMatchingShorthandsForLonghand(propId, &shorthands);
135 // Viewport descriptors have width and height as shorthands, but it does n't 135 // Viewport descriptors have width and height as shorthands, but it does n't
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 307 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
308 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG); 308 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI NG);
309 } 309 }
310 310
311 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value) 311 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit iveCustomIdentValue(CSSParserValue* value)
312 { 312 {
313 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT); 313 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri mitiveValue::CSS_IDENT);
314 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT); 314 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_CUST OM_IDENT);
315 } 315 }
316 316
317 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi thReferrer(const String& rawValue, const KURL& url) 317 inline CSSValue CSSPropertyParser::createCSSImageValueWithReferrer(const String& rawValue, const KURL& url)
318 { 318 {
319 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur l); 319 CSSValue imageValue = CSSImageValue::create(rawValue, url);
320 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); 320 toCSSImageValue(imageValue).setReferrer(m_context.referrer());
321 return imageValue; 321 return imageValue;
322 } 322 }
323 323
324 static inline bool isComma(CSSParserValue* value) 324 static inline bool isComma(CSSParserValue* value)
325 { 325 {
326 ASSERT(value); 326 ASSERT(value);
327 return value->unit == CSSParserValue::Operator && value->iValue == ','; 327 return value->unit == CSSParserValue::Operator && value->iValue == ',';
328 } 328 }
329 329
330 static bool consumeComma(CSSParserValueList* valueList) 330 static bool consumeComma(CSSParserValueList* valueList)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM) 389 if (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrimitiv eValue::CSS_DPCM)
390 return createPrimitiveNumericValue(value); 390 return createPrimitiveNumericValue(value);
391 if (value->unit == CSSPrimitiveValue::CSS_QEM) 391 if (value->unit == CSSPrimitiveValue::CSS_QEM)
392 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS); 392 return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPr imitiveValue::CSS_EMS);
393 if (isCalculation(value)) 393 if (isCalculation(value))
394 return CSSPrimitiveValue::create(m_parsedCalculation.release()); 394 return CSSPrimitiveValue::create(m_parsedCalculation.release());
395 395
396 return nullptr; 396 return nullptr;
397 } 397 }
398 398
399 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe fPtrWillBeRawPtr<CSSValue> prpValue, bool important) 399 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, CSSVal ue prpValue, bool important)
400 { 400 {
401 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); 401 const StylePropertyShorthand& shorthand = shorthandForProperty(propId);
402 unsigned shorthandLength = shorthand.length(); 402 unsigned shorthandLength = shorthand.length();
403 if (!shorthandLength) { 403 if (!shorthandLength) {
404 addProperty(propId, prpValue, important); 404 addProperty(propId, prpValue, important);
405 return; 405 return;
406 } 406 }
407 407
408 RefPtrWillBeRawPtr<CSSValue> value = prpValue; 408 CSSValue value = prpValue;
409 ShorthandScope scope(this, propId); 409 ShorthandScope scope(this, propId);
410 const CSSPropertyID* longhands = shorthand.properties(); 410 const CSSPropertyID* longhands = shorthand.properties();
411 for (unsigned i = 0; i < shorthandLength; ++i) 411 for (unsigned i = 0; i < shorthandLength; ++i)
412 addProperty(longhands[i], value, important); 412 addProperty(longhands[i], value, important);
413 } 413 }
414 414
415 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant) 415 bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import ant)
416 { 416 {
417 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); 417 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty);
418 418
(...skipping 28 matching lines...) Expand all
447 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) 447 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id))
448 return false; 448 return false;
449 if (m_valueList->next() && !inShorthand()) 449 if (m_valueList->next() && !inShorthand())
450 return false; 450 return false;
451 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ; 451 addProperty(propId, cssValuePool().createIdentifierValue(id), important) ;
452 return true; 452 return true;
453 } 453 }
454 454
455 bool validPrimitive = false; 455 bool validPrimitive = false;
456 Units unitless = FUnknown; 456 Units unitless = FUnknown;
457 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 457 NullableCSSValue parsedValue;
458 458
459 switch (propId) { 459 switch (propId) {
460 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ] 460 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
461 parsedValue = parseSize(); 461 parsedValue = parseSize();
462 break; 462 break;
463 case CSSPropertyQuotes: // [<string> <string>]+ | none 463 case CSSPropertyQuotes: // [<string> <string>]+ | none
464 if (id == CSSValueNone) 464 if (id == CSSValueNone)
465 validPrimitive = true; 465 validPrimitive = true;
466 else 466 else
467 parsedValue = parseQuotes(); 467 parsedValue = parseQuotes();
(...skipping 11 matching lines...) Expand all
479 break; 479 break;
480 480
481 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work 481 /* Start of supported CSS properties with validation. This is needed for par seShorthand to work
482 * correctly and allows optimization in blink::applyRule(..) 482 * correctly and allows optimization in blink::applyRule(..)
483 */ 483 */
484 case CSSPropertyOverflow: { 484 case CSSPropertyOverflow: {
485 ShorthandScope scope(this, propId); 485 ShorthandScope scope(this, propId);
486 if (num != 1 || !parseValue(CSSPropertyOverflowY, important)) 486 if (num != 1 || !parseValue(CSSPropertyOverflowY, important))
487 return false; 487 return false;
488 488
489 RefPtrWillBeRawPtr<CSSValue> overflowXValue = nullptr;
490
491 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I f this value has been 489 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I f this value has been
492 // set using the shorthand, then for now overflow-x will default to auto , but once we implement 490 // set using the shorthand, then for now overflow-x will default to auto , but once we implement
493 // pagination controls, it should default to hidden. If the overflow-y v alue is anything but 491 // pagination controls, it should default to hidden. If the overflow-y v alue is anything but
494 // paged-x or paged-y, then overflow-x and overflow-y should have the sa me value. 492 // paged-x or paged-y, then overflow-x and overflow-y should have the sa me value.
493 NullableCSSValue overflowXValue;
495 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) 494 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY)
496 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); 495 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto);
497 else 496 else
498 overflowXValue = m_parsedProperties.last().value(); 497 overflowXValue = m_parsedProperties.last().value();
499 addProperty(CSSPropertyOverflowX, overflowXValue.release(), important); 498 addProperty(CSSPropertyOverflowX, *overflowXValue, important);
500 return true; 499 return true;
501 } 500 }
502 501
503 case CSSPropertyTextAlign: 502 case CSSPropertyTextAlign:
504 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent 503 // left | right | center | justify | -webkit-left | -webkit-right | -web kit-center | -webkit-match-parent
505 // | start | end | <string> | inherit | -webkit-auto (converted to start ) 504 // | start | end | <string> | inherit | -webkit-auto (converted to start )
506 // FIXME: <string> not supported right now 505 // FIXME: <string> not supported right now
507 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) { 506 if ((id >= CSSValueWebkitAuto && id <= CSSValueWebkitMatchParent) || id == CSSValueStart || id == CSSValueEnd) {
508 validPrimitive = true; 507 validPrimitive = true;
509 } 508 }
510 break; 509 break;
511 510
512 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit 511 case CSSPropertyFontWeight: { // normal | bold | bolder | lighter | 100 | 2 00 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
513 if (m_valueList->size() != 1) 512 if (m_valueList->size() != 1)
514 return false; 513 return false;
515 return parseFontWeight(important); 514 return parseFontWeight(important);
516 } 515 }
517 516
518 case CSSPropertyBorderSpacing: { 517 case CSSPropertyBorderSpacing: {
519 if (num == 1) { 518 if (num == 1) {
520 ShorthandScope scope(this, CSSPropertyBorderSpacing); 519 ShorthandScope scope(this, CSSPropertyBorderSpacing);
521 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) ) 520 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) )
522 return false; 521 return false;
523 CSSValue* value = m_parsedProperties.last().value(); 522 CSSValue value = m_parsedProperties.last().value();
524 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important ); 523 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important );
525 return true; 524 return true;
526 } 525 }
527 else if (num == 2) { 526 else if (num == 2) {
528 ShorthandScope scope(this, CSSPropertyBorderSpacing); 527 ShorthandScope scope(this, CSSPropertyBorderSpacing);
529 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) 528 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important))
530 return false; 529 return false;
531 return true; 530 return true;
532 } 531 }
533 return false; 532 return false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 case CSSPropertyCursor: { 598 case CSSPropertyCursor: {
600 // Grammar defined by CSS3 UI and modified by CSS4 images: 599 // Grammar defined by CSS3 UI and modified by CSS4 images:
601 // [ [<image> [<x> <y>]?,]* 600 // [ [<image> [<x> <y>]?,]*
602 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize | 601 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
603 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 602 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
604 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help | 603 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help |
605 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll | 604 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll |
606 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit 605 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit
607 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; 606 RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
608 while (value) { 607 while (value) {
609 RefPtrWillBeRawPtr<CSSValue> image = nullptr; 608 NullableCSSValue image;
610 if (value->unit == CSSPrimitiveValue::CSS_URI) { 609 if (value->unit == CSSPrimitiveValue::CSS_URI) {
611 String uri = value->string; 610 String uri = value->string;
612 if (!uri.isNull()) 611 if (!uri.isNull())
613 image = createCSSImageValueWithReferrer(uri, completeURL(uri )); 612 image = createCSSImageValueWithReferrer(uri, completeURL(uri ));
614 } else if (value->unit == CSSParserValue::Function && value->functio n->id == CSSValueWebkitImageSet) { 613 } else if (value->unit == CSSParserValue::Function && value->functio n->id == CSSValueWebkitImageSet) {
615 image = parseImageSet(m_valueList); 614 image = parseImageSet(m_valueList);
616 if (!image) 615 if (!image)
617 break; 616 break;
618 } else 617 } else
619 break; 618 break;
(...skipping 11 matching lines...) Expand all
631 return false; 630 return false;
632 if (nrcoords == 2) { 631 if (nrcoords == 2) {
633 hotSpotSpecified = true; 632 hotSpotSpecified = true;
634 hotSpot = IntPoint(coords[0], coords[1]); 633 hotSpot = IntPoint(coords[0], coords[1]);
635 } 634 }
636 635
637 if (!list) 636 if (!list)
638 list = CSSValueList::createCommaSeparated(); 637 list = CSSValueList::createCommaSeparated();
639 638
640 if (image) 639 if (image)
641 list->append(CSSCursorImageValue::create(image, hotSpotSpecified , hotSpot)); 640 list->append(CSSCursorImageValue::create(*image, hotSpotSpecifie d, hotSpot));
642 641
643 if (!consumeComma(m_valueList)) 642 if (!consumeComma(m_valueList))
644 return false; 643 return false;
645 value = m_valueList->current(); 644 value = m_valueList->current();
646 } 645 }
647 if (value && m_context.useCounter()) { 646 if (value && m_context.useCounter()) {
648 if (value->id == CSSValueWebkitZoomIn) 647 if (value->id == CSSValueWebkitZoomIn)
649 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); 648 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn);
650 else if (value->id == CSSValueWebkitZoomOut) 649 else if (value->id == CSSValueWebkitZoomOut)
651 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ; 650 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 case CSSPropertyWebkitMaskImage: 692 case CSSPropertyWebkitMaskImage:
694 case CSSPropertyWebkitMaskOrigin: 693 case CSSPropertyWebkitMaskOrigin:
695 case CSSPropertyWebkitMaskPosition: 694 case CSSPropertyWebkitMaskPosition:
696 case CSSPropertyWebkitMaskPositionX: 695 case CSSPropertyWebkitMaskPositionX:
697 case CSSPropertyWebkitMaskPositionY: 696 case CSSPropertyWebkitMaskPositionY:
698 case CSSPropertyWebkitMaskSize: 697 case CSSPropertyWebkitMaskSize:
699 case CSSPropertyWebkitMaskRepeat: 698 case CSSPropertyWebkitMaskRepeat:
700 case CSSPropertyWebkitMaskRepeatX: 699 case CSSPropertyWebkitMaskRepeatX:
701 case CSSPropertyWebkitMaskRepeatY: 700 case CSSPropertyWebkitMaskRepeatY:
702 { 701 {
703 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 702 NullableCSSValue val1;
704 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 703 NullableCSSValue val2;
705 CSSPropertyID propId1, propId2; 704 CSSPropertyID propId1, propId2;
706 bool result = false; 705 bool result = false;
707 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2)) { 706 if (parseFillProperty(unresolvedProperty, propId1, propId2, val1, val2)) {
708 if (propId == CSSPropertyBackgroundPosition || 707 if (propId == CSSPropertyBackgroundPosition ||
709 propId == CSSPropertyBackgroundRepeat || 708 propId == CSSPropertyBackgroundRepeat ||
710 propId == CSSPropertyWebkitMaskPosition || 709 propId == CSSPropertyWebkitMaskPosition ||
711 propId == CSSPropertyWebkitMaskRepeat) { 710 propId == CSSPropertyWebkitMaskRepeat) {
712 ShorthandScope scope(this, propId); 711 ShorthandScope scope(this, propId);
713 addProperty(propId1, val1.release(), important); 712 addProperty(propId1, *val1, important);
714 if (val2) 713 if (val2)
715 addProperty(propId2, val2.release(), important); 714 addProperty(propId2, *val2, important);
716 } else { 715 } else {
717 addProperty(propId1, val1.release(), important); 716 addProperty(propId1, *val1, important);
718 if (val2) 717 if (val2)
719 addProperty(propId2, val2.release(), important); 718 addProperty(propId2, *val2, important);
720 } 719 }
721 result = true; 720 result = true;
722 } 721 }
723 m_implicitShorthand = false; 722 m_implicitShorthand = false;
724 return result; 723 return result;
725 } 724 }
726 case CSSPropertyObjectPosition: 725 case CSSPropertyObjectPosition:
727 parsedValue = parsePosition(m_valueList); 726 parsedValue = parsePosition(m_valueList);
728 break; 727 break;
729 case CSSPropertyListStyleImage: // <uri> | none | inherit 728 case CSSPropertyListStyleImage: // <uri> | none | inherit
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 case CSSPropertyUnicodeRange: 921 case CSSPropertyUnicodeRange:
923 /* @font-face only descriptors */ 922 /* @font-face only descriptors */
924 break; 923 break;
925 924
926 /* CSS3 properties */ 925 /* CSS3 properties */
927 926
928 case CSSPropertyBorderImage: 927 case CSSPropertyBorderImage:
929 case CSSPropertyWebkitMaskBoxImage: 928 case CSSPropertyWebkitMaskBoxImage:
930 return parseBorderImageShorthand(propId, important); 929 return parseBorderImageShorthand(propId, important);
931 case CSSPropertyWebkitBorderImage: { 930 case CSSPropertyWebkitBorderImage: {
932 if (RefPtrWillBeRawPtr<CSSValue> result = parseBorderImage(propId)) { 931 if (NullableCSSValue result = parseBorderImage(propId)) {
933 addProperty(propId, result, important); 932 addProperty(propId, *result, important);
934 return true; 933 return true;
935 } 934 }
936 return false; 935 return false;
937 } 936 }
938 937
939 case CSSPropertyBorderImageOutset: 938 case CSSPropertyBorderImageOutset:
940 case CSSPropertyWebkitMaskBoxImageOutset: { 939 case CSSPropertyWebkitMaskBoxImageOutset: {
941 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; 940 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr;
942 if (parseBorderImageOutset(result)) { 941 if (parseBorderImageOutset(result)) {
943 addProperty(propId, result, important); 942 addProperty(propId, result, important);
944 return true; 943 return true;
945 } 944 }
946 break; 945 break;
947 } 946 }
948 case CSSPropertyBorderImageRepeat: 947 case CSSPropertyBorderImageRepeat:
949 case CSSPropertyWebkitMaskBoxImageRepeat: { 948 case CSSPropertyWebkitMaskBoxImageRepeat: {
950 RefPtrWillBeRawPtr<CSSValue> result = nullptr; 949 NullableCSSValue result;
951 if (parseBorderImageRepeat(result)) { 950 if (parseBorderImageRepeat(result)) {
952 addProperty(propId, result, important); 951 addProperty(propId, *result, important);
953 return true; 952 return true;
954 } 953 }
955 break; 954 break;
956 } 955 }
957 case CSSPropertyBorderImageSlice: 956 case CSSPropertyBorderImageSlice:
958 case CSSPropertyWebkitMaskBoxImageSlice: { 957 case CSSPropertyWebkitMaskBoxImageSlice: {
959 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr; 958 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> result = nullptr;
960 if (parseBorderImageSlice(propId, result)) { 959 if (parseBorderImageSlice(propId, result)) {
961 addProperty(propId, result, important); 960 addProperty(propId, result, important);
962 return true; 961 return true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 case CSSPropertyWebkitBoxFlexGroup: 1035 case CSSPropertyWebkitBoxFlexGroup:
1037 validPrimitive = validUnit(value, FInteger | FNonNeg); 1036 validPrimitive = validUnit(value, FInteger | FNonNeg);
1038 break; 1037 break;
1039 case CSSPropertyWebkitBoxOrdinalGroup: 1038 case CSSPropertyWebkitBoxOrdinalGroup:
1040 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue; 1039 validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue;
1041 break; 1040 break;
1042 case CSSPropertyWebkitFilter: 1041 case CSSPropertyWebkitFilter:
1043 if (id == CSSValueNone) 1042 if (id == CSSValueNone)
1044 validPrimitive = true; 1043 validPrimitive = true;
1045 else { 1044 else {
1046 RefPtrWillBeRawPtr<CSSValue> val = parseFilter(); 1045 NullableCSSValue val = parseFilter();
1047 if (val) { 1046 if (val) {
1048 addProperty(propId, val, important); 1047 addProperty(propId, *val, important);
1049 return true; 1048 return true;
1050 } 1049 }
1051 return false; 1050 return false;
1052 } 1051 }
1053 break; 1052 break;
1054 case CSSPropertyFlex: { 1053 case CSSPropertyFlex: {
1055 ShorthandScope scope(this, propId); 1054 ShorthandScope scope(this, propId);
1056 if (id == CSSValueNone) { 1055 if (id == CSSValueNone) {
1057 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important); 1056 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPr imitiveValue::CSS_NUMBER), important);
1058 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important); 1057 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSS PrimitiveValue::CSS_NUMBER), important);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 1223
1225 case CSSPropertyGrid: 1224 case CSSPropertyGrid:
1226 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 1225 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
1227 return parseGridShorthand(important); 1226 return parseGridShorthand(important);
1228 1227
1229 case CSSPropertyWebkitMarginCollapse: { 1228 case CSSPropertyWebkitMarginCollapse: {
1230 if (num == 1) { 1229 if (num == 1) {
1231 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1230 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1232 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant)) 1231 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant))
1233 return false; 1232 return false;
1234 CSSValue* value = m_parsedProperties.last().value(); 1233 CSSValue value = m_parsedProperties.last().value();
1235 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important); 1234 addProperty(webkitMarginCollapseShorthand().properties()[1], value, important);
1236 return true; 1235 return true;
1237 } 1236 }
1238 else if (num == 2) { 1237 else if (num == 2) {
1239 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse); 1238 ShorthandScope scope(this, CSSPropertyWebkitMarginCollapse);
1240 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan t)) 1239 if (!parseValue(webkitMarginCollapseShorthand().properties()[0], imp ortant) || !parseValue(webkitMarginCollapseShorthand().properties()[1], importan t))
1241 return false; 1240 return false;
1242 return true; 1241 return true;
1243 } 1242 }
1244 return false; 1243 return false;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 else 1434 else
1436 return parseFontVariantLigatures(important); 1435 return parseFontVariantLigatures(important);
1437 break; 1436 break;
1438 case CSSPropertyWebkitClipPath: 1437 case CSSPropertyWebkitClipPath:
1439 if (id == CSSValueNone) { 1438 if (id == CSSValueNone) {
1440 validPrimitive = true; 1439 validPrimitive = true;
1441 } else if (value->unit == CSSParserValue::Function) { 1440 } else if (value->unit == CSSParserValue::Function) {
1442 parsedValue = parseBasicShape(); 1441 parsedValue = parseBasicShape();
1443 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 1442 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
1444 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV alue::CSS_URI); 1443 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveV alue::CSS_URI);
1445 addProperty(propId, parsedValue.release(), important); 1444 addProperty(propId, *parsedValue, important);
1446 return true; 1445 return true;
1447 } 1446 }
1448 break; 1447 break;
1449 case CSSPropertyShapeOutside: 1448 case CSSPropertyShapeOutside:
1450 if (id == CSSValueNone) 1449 if (id == CSSValueNone)
1451 validPrimitive = true; 1450 validPrimitive = true;
1452 else 1451 else
1453 parsedValue = parseShapeProperty(propId); 1452 parsedValue = parseShapeProperty(propId);
1454 break; 1453 break;
1455 case CSSPropertyShapeMargin: 1454 case CSSPropertyShapeMargin:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 return parseSVGValue(propId, important); 1506 return parseSVGValue(propId, important);
1508 } 1507 }
1509 1508
1510 if (validPrimitive) { 1509 if (validPrimitive) {
1511 parsedValue = parseValidPrimitive(id, value); 1510 parsedValue = parseValidPrimitive(id, value);
1512 m_valueList->next(); 1511 m_valueList->next();
1513 } 1512 }
1514 ASSERT(!m_parsedCalculation); 1513 ASSERT(!m_parsedCalculation);
1515 if (parsedValue) { 1514 if (parsedValue) {
1516 if (!m_valueList->current() || inShorthand()) { 1515 if (!m_valueList->current() || inShorthand()) {
1517 addProperty(propId, parsedValue.release(), important); 1516 addProperty(propId, *parsedValue, important);
1518 return true; 1517 return true;
1519 } 1518 }
1520 } 1519 }
1521 return false; 1520 return false;
1522 } 1521 }
1523 1522
1524 void CSSPropertyParser::addFillValue(RefPtrWillBeRawPtr<CSSValue>& lval, PassRef PtrWillBeRawPtr<CSSValue> rval) 1523 void CSSPropertyParser::addFillValue(NullableCSSValue& lval, CSSValue rval)
1525 { 1524 {
1526 if (lval) { 1525 if (lval) {
1527 if (lval->isBaseValueList()) 1526 if (lval->isBaseValueList())
1528 toCSSValueList(lval.get())->append(rval); 1527 toCSSValueList(lval)->append(rval);
1529 else { 1528 else {
1530 PassRefPtrWillBeRawPtr<CSSValue> oldlVal(lval.release());
1531 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated(); 1529 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated();
1532 list->append(oldlVal); 1530 list->append(*lval);
1533 list->append(rval); 1531 list->append(rval);
1534 lval = list; 1532 lval = list;
1535 } 1533 }
1536 } 1534 }
1537 else 1535 else
1538 lval = rval; 1536 lval = rval;
1539 } 1537 }
1540 1538
1541 static bool parseBackgroundClip(CSSParserValue* parserValue, RefPtrWillBeRawPtr< CSSValue>& cssValue) 1539 static bool parseBackgroundClip(CSSParserValue* parserValue, NullableCSSValue& c ssValue)
1542 { 1540 {
1543 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi ngBox 1541 if (parserValue->id == CSSValueBorderBox || parserValue->id == CSSValuePaddi ngBox
1544 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW ebkitText) { 1542 || parserValue->id == CSSValueContentBox || parserValue->id == CSSValueW ebkitText) {
1545 cssValue = cssValuePool().createIdentifierValue(parserValue->id); 1543 cssValue = cssValuePool().createIdentifierValue(parserValue->id);
1546 return true; 1544 return true;
1547 } 1545 }
1548 return false; 1546 return false;
1549 } 1547 }
1550 1548
1551 const int cMaxFillProperties = 9; 1549 const int cMaxFillProperties = 9;
1552 1550
1553 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper tyID* properties, int numProperties, bool important) 1551 bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper tyID* properties, int numProperties, bool important)
1554 { 1552 {
1555 ASSERT(numProperties <= cMaxFillProperties); 1553 ASSERT(numProperties <= cMaxFillProperties);
1556 if (numProperties > cMaxFillProperties) 1554 if (numProperties > cMaxFillProperties)
1557 return false; 1555 return false;
1558 1556
1559 ShorthandScope scope(this, propId); 1557 ShorthandScope scope(this, propId);
1560 1558
1561 bool parsedProperty[cMaxFillProperties] = { false }; 1559 bool parsedProperty[cMaxFillProperties] = { false };
1562 RefPtrWillBeRawPtr<CSSValue> values[cMaxFillProperties]; 1560 NullableCSSValue values[cMaxFillProperties];
1563 #if ENABLE(OILPAN) 1561 #if ENABLE(OILPAN)
1564 // Zero initialize the array of raw pointers. 1562 // Zero initialize the array of raw pointers.
1565 memset(&values, 0, sizeof(values)); 1563 memset(&values, 0, sizeof(values));
1566 #endif 1564 #endif
1567 RefPtrWillBeRawPtr<CSSValue> clipValue = nullptr; 1565 NullableCSSValue clipValue;
1568 RefPtrWillBeRawPtr<CSSValue> positionYValue = nullptr; 1566 NullableCSSValue positionYValue;
1569 RefPtrWillBeRawPtr<CSSValue> repeatYValue = nullptr; 1567 NullableCSSValue repeatYValue;
1570 bool foundClip = false; 1568 bool foundClip = false;
1571 int i; 1569 int i;
1572 bool foundPositionCSSProperty = false; 1570 bool foundPositionCSSProperty = false;
1573 1571
1574 while (m_valueList->current()) { 1572 while (m_valueList->current()) {
1575 CSSParserValue* val = m_valueList->current(); 1573 CSSParserValue* val = m_valueList->current();
1576 if (isComma(val)) { 1574 if (isComma(val)) {
1577 // We hit the end. Fill in all remaining values with the initial va lue. 1575 // We hit the end. Fill in all remaining values with the initial va lue.
1578 m_valueList->next(); 1576 m_valueList->next();
1579 for (i = 0; i < numProperties; ++i) { 1577 for (i = 0; i < numProperties; ++i) {
(...skipping 28 matching lines...) Expand all
1608 foundPositionCSSProperty = false; 1606 foundPositionCSSProperty = false;
1609 bool found = false; 1607 bool found = false;
1610 for (i = 0; !found && i < numProperties; ++i) { 1608 for (i = 0; !found && i < numProperties; ++i) {
1611 1609
1612 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou ndSize && properties[i] != CSSPropertyWebkitMaskSize)) 1610 if (sizeCSSPropertyExpected && (properties[i] != CSSPropertyBackgrou ndSize && properties[i] != CSSPropertyWebkitMaskSize))
1613 continue; 1611 continue;
1614 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro undSize || properties[i] == CSSPropertyWebkitMaskSize)) 1612 if (!sizeCSSPropertyExpected && (properties[i] == CSSPropertyBackgro undSize || properties[i] == CSSPropertyWebkitMaskSize))
1615 continue; 1613 continue;
1616 1614
1617 if (!parsedProperty[i]) { 1615 if (!parsedProperty[i]) {
1618 RefPtrWillBeRawPtr<CSSValue> val1 = nullptr; 1616 NullableCSSValue val1;
1619 RefPtrWillBeRawPtr<CSSValue> val2 = nullptr; 1617 NullableCSSValue val2;
1620 CSSPropertyID propId1, propId2; 1618 CSSPropertyID propId1, propId2;
1621 CSSParserValue* parserValue = m_valueList->current(); 1619 CSSParserValue* parserValue = m_valueList->current();
1622 // parseFillProperty() may modify m_implicitShorthand, so we MUS T reset it 1620 // parseFillProperty() may modify m_implicitShorthand, so we MUS T reset it
1623 // before EACH return below. 1621 // before EACH return below.
1624 if (parserValue && parseFillProperty(properties[i], propId1, pro pId2, val1, val2)) { 1622 if (parserValue && parseFillProperty(properties[i], propId1, pro pId2, val1, val2)) {
1625 parsedProperty[i] = found = true; 1623 parsedProperty[i] = found = true;
1626 addFillValue(values[i], val1.release()); 1624 addFillValue(values[i], *val1);
1627 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition) 1625 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition)
1628 addFillValue(positionYValue, val2.release()); 1626 addFillValue(positionYValue, *val2);
1629 if (properties[i] == CSSPropertyBackgroundRepeat || properti es[i] == CSSPropertyWebkitMaskRepeat) 1627 if (properties[i] == CSSPropertyBackgroundRepeat || properti es[i] == CSSPropertyWebkitMaskRepeat)
1630 addFillValue(repeatYValue, val2.release()); 1628 addFillValue(repeatYValue, *val2);
1631 if (properties[i] == CSSPropertyBackgroundOrigin || properti es[i] == CSSPropertyWebkitMaskOrigin) { 1629 if (properties[i] == CSSPropertyBackgroundOrigin || properti es[i] == CSSPropertyWebkitMaskOrigin) {
1632 // Reparse the value as a clip, and see if we succeed. 1630 // Reparse the value as a clip, and see if we succeed.
1633 if (parseBackgroundClip(parserValue, val1)) 1631 if (parseBackgroundClip(parserValue, val1))
1634 addFillValue(clipValue, val1.release()); // The prop erty parsed successfully. 1632 addFillValue(clipValue, *val1); // The property pars ed successfully.
1635 else 1633 else
1636 addFillValue(clipValue, cssValuePool().createImplici tInitialValue()); // Some value was used for origin that is not supported by cli p. Just reset clip instead. 1634 addFillValue(clipValue, cssValuePool().createImplici tInitialValue()); // Some value was used for origin that is not supported by cli p. Just reset clip instead.
1637 } 1635 }
1638 if (properties[i] == CSSPropertyBackgroundClip || properties [i] == CSSPropertyWebkitMaskClip) { 1636 if (properties[i] == CSSPropertyBackgroundClip || properties [i] == CSSPropertyWebkitMaskClip) {
1639 // Update clipValue 1637 // Update clipValue
1640 addFillValue(clipValue, val1.release()); 1638 addFillValue(clipValue, *val1);
1641 foundClip = true; 1639 foundClip = true;
1642 } 1640 }
1643 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition) 1641 if (properties[i] == CSSPropertyBackgroundPosition || proper ties[i] == CSSPropertyWebkitMaskPosition)
1644 foundPositionCSSProperty = true; 1642 foundPositionCSSProperty = true;
1645 } 1643 }
1646 } 1644 }
1647 } 1645 }
1648 1646
1649 // if we didn't find at least one match, this is an 1647 // if we didn't find at least one match, this is an
1650 // invalid shorthand and we have to ignore it 1648 // invalid shorthand and we have to ignore it
(...skipping 11 matching lines...) Expand all
1662 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition) 1660 if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
1663 addFillValue(positionYValue, cssValuePool().createImplicitInitia lValue()); 1661 addFillValue(positionYValue, cssValuePool().createImplicitInitia lValue());
1664 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat) 1662 if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
1665 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV alue()); 1663 addFillValue(repeatYValue, cssValuePool().createImplicitInitialV alue());
1666 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) { 1664 if (properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) {
1667 // If background-origin wasn't present, then reset background-cl ip also. 1665 // If background-origin wasn't present, then reset background-cl ip also.
1668 addFillValue(clipValue, cssValuePool().createImplicitInitialValu e()); 1666 addFillValue(clipValue, cssValuePool().createImplicitInitialValu e());
1669 } 1667 }
1670 } 1668 }
1671 if (properties[i] == CSSPropertyBackgroundPosition) { 1669 if (properties[i] == CSSPropertyBackgroundPosition) {
1672 addProperty(CSSPropertyBackgroundPositionX, values[i].release(), imp ortant); 1670 addProperty(CSSPropertyBackgroundPositionX, *values[i], important);
1673 // it's OK to call positionYValue.release() since we only see CSSPro pertyBackgroundPosition once 1671 // it's OK to call positionYValue.release() since we only see CSSPro pertyBackgroundPosition once
1674 addProperty(CSSPropertyBackgroundPositionY, positionYValue.release() , important); 1672 addProperty(CSSPropertyBackgroundPositionY, *positionYValue, importa nt);
1675 } else if (properties[i] == CSSPropertyWebkitMaskPosition) { 1673 } else if (properties[i] == CSSPropertyWebkitMaskPosition) {
1676 addProperty(CSSPropertyWebkitMaskPositionX, values[i].release(), imp ortant); 1674 addProperty(CSSPropertyWebkitMaskPositionX, *values[i], important);
1677 // it's OK to call positionYValue.release() since we only see CSSPro pertyWebkitMaskPosition once 1675 // it's OK to call positionYValue.release() since we only see CSSPro pertyWebkitMaskPosition once
1678 addProperty(CSSPropertyWebkitMaskPositionY, positionYValue.release() , important); 1676 addProperty(CSSPropertyWebkitMaskPositionY, *positionYValue, importa nt);
1679 } else if (properties[i] == CSSPropertyBackgroundRepeat) { 1677 } else if (properties[i] == CSSPropertyBackgroundRepeat) {
1680 addProperty(CSSPropertyBackgroundRepeatX, values[i].release(), impor tant); 1678 addProperty(CSSPropertyBackgroundRepeatX, *values[i], important);
1681 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once 1679 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once
1682 addProperty(CSSPropertyBackgroundRepeatY, repeatYValue.release(), im portant); 1680 addProperty(CSSPropertyBackgroundRepeatY, *repeatYValue, important);
1683 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) { 1681 } else if (properties[i] == CSSPropertyWebkitMaskRepeat) {
1684 addProperty(CSSPropertyWebkitMaskRepeatX, values[i].release(), impor tant); 1682 addProperty(CSSPropertyWebkitMaskRepeatX, *values[i], important);
1685 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once 1683 // it's OK to call repeatYValue.release() since we only see CSSPrope rtyBackgroundPosition once
1686 addProperty(CSSPropertyWebkitMaskRepeatY, repeatYValue.release(), im portant); 1684 addProperty(CSSPropertyWebkitMaskRepeatY, *repeatYValue, important);
1687 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip) 1685 } else if ((properties[i] == CSSPropertyBackgroundClip || properties[i] == CSSPropertyWebkitMaskClip) && !foundClip)
1688 // Value is already set while updating origin 1686 // Value is already set while updating origin
1689 continue; 1687 continue;
1690 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i ] && m_context.useLegacyBackgroundSizeShorthandBehavior()) 1688 else if (properties[i] == CSSPropertyBackgroundSize && !parsedProperty[i ] && m_context.useLegacyBackgroundSizeShorthandBehavior())
1691 continue; 1689 continue;
1692 else 1690 else
1693 addProperty(properties[i], values[i].release(), important); 1691 addProperty(properties[i], *values[i], important);
1694 1692
1695 // Add in clip values when we hit the corresponding origin property. 1693 // Add in clip values when we hit the corresponding origin property.
1696 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) 1694 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip)
1697 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan t); 1695 addProperty(CSSPropertyBackgroundClip, *clipValue, important);
1698 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) 1696 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip)
1699 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan t); 1697 addProperty(CSSPropertyWebkitMaskClip, *clipValue, important);
1700 } 1698 }
1701 1699
1702 m_implicitShorthand = false; 1700 m_implicitShorthand = false;
1703 return true; 1701 return true;
1704 } 1702 }
1705 1703
1706 static bool isValidTransitionPropertyList(CSSValueList* value) 1704 static bool isValidTransitionPropertyList(CSSValueList* value)
1707 { 1705 {
1708 if (value->length() < 2) 1706 if (value->length() < 2)
1709 return true; 1707 return true;
1710 for (auto& property : *value) { 1708 for (auto& property : *value) {
1711 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip 1709 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip
1712 if (property->isInitialValue()) 1710 if (property.isInitialValue())
1713 continue; 1711 continue;
1714 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(property.get()); 1712 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(property);
1715 if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSVa lueNone) 1713 if (primitiveValue.isValueID() && primitiveValue.getValueID() == CSSValu eNone)
1716 return false; 1714 return false;
1717 } 1715 }
1718 return true; 1716 return true;
1719 } 1717 }
1720 1718
1721 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant) 1719 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant)
1722 { 1720 {
1723 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing(); 1721 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing();
1724 const unsigned numProperties = 8; 1722 const unsigned numProperties = 8;
1725 1723
(...skipping 19 matching lines...) Expand all
1745 parsedProperty[i] = false; 1743 parsedProperty[i] = false;
1746 } 1744 }
1747 if (!m_valueList->current()) 1745 if (!m_valueList->current())
1748 break; 1746 break;
1749 } 1747 }
1750 1748
1751 bool found = false; 1749 bool found = false;
1752 for (size_t i = 0; i < numProperties; ++i) { 1750 for (size_t i = 0; i < numProperties; ++i) {
1753 if (parsedProperty[i]) 1751 if (parsedProperty[i])
1754 continue; 1752 continue;
1755 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(animat ionProperties.properties()[i], useLegacyparsing)) { 1753 if (NullableCSSValue val = parseAnimationProperty(animationPropertie s.properties()[i], useLegacyparsing)) {
1756 parsedProperty[i] = found = true; 1754 parsedProperty[i] = found = true;
1757 values[i]->append(val.release()); 1755 values[i]->append(*val);
1758 break; 1756 break;
1759 } 1757 }
1760 } 1758 }
1761 1759
1762 // if we didn't find at least one match, this is an 1760 // if we didn't find at least one match, this is an
1763 // invalid shorthand and we have to ignore it 1761 // invalid shorthand and we have to ignore it
1764 if (!found) 1762 if (!found)
1765 return false; 1763 return false;
1766 } 1764 }
1767 1765
(...skipping 30 matching lines...) Expand all
1798 parsedProperty[i] = false; 1796 parsedProperty[i] = false;
1799 } 1797 }
1800 if (!m_valueList->current()) 1798 if (!m_valueList->current())
1801 break; 1799 break;
1802 } 1800 }
1803 1801
1804 bool found = false; 1802 bool found = false;
1805 for (size_t i = 0; i < numProperties; ++i) { 1803 for (size_t i = 0; i < numProperties; ++i) {
1806 if (parsedProperty[i]) 1804 if (parsedProperty[i])
1807 continue; 1805 continue;
1808 if (RefPtrWillBeRawPtr<CSSValue> val = parseAnimationProperty(shorth and.properties()[i], false)) { 1806 if (NullableCSSValue val = parseAnimationProperty(shorthand.properti es()[i], false)) {
1809 parsedProperty[i] = found = true; 1807 parsedProperty[i] = found = true;
1810 values[i]->append(val.release()); 1808 values[i]->append(*val);
1811 break; 1809 break;
1812 } 1810 }
1813 } 1811 }
1814 1812
1815 // if we didn't find at least one match, this is an 1813 // if we didn't find at least one match, this is an
1816 // invalid shorthand and we have to ignore it 1814 // invalid shorthand and we have to ignore it
1817 if (!found) 1815 if (!found)
1818 return false; 1816 return false;
1819 } 1817 }
1820 1818
1821 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty); 1819 ASSERT(shorthand.properties()[3] == CSSPropertyTransitionProperty);
1822 if (!isValidTransitionPropertyList(values[3].get())) 1820 if (!isValidTransitionPropertyList(values[3].get()))
1823 return false; 1821 return false;
1824 1822
1825 // Fill in any remaining properties with the initial value and add 1823 // Fill in any remaining properties with the initial value and add
1826 for (size_t i = 0; i < numProperties; ++i) { 1824 for (size_t i = 0; i < numProperties; ++i) {
1827 if (!parsedProperty[i]) 1825 if (!parsedProperty[i])
1828 values[i]->append(cssValuePool().createImplicitInitialValue()); 1826 values[i]->append(cssValuePool().createImplicitInitialValue());
1829 addProperty(shorthand.properties()[i], values[i].release(), important); 1827 addProperty(shorthand.properties()[i], values[i].release(), important);
1830 } 1828 }
1831 1829
1832 return true; 1830 return true;
1833 } 1831 }
1834 1832
1835 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnWidth() 1833 NullableCSSValue CSSPropertyParser::parseColumnWidth()
1836 { 1834 {
1837 CSSParserValue* value = m_valueList->current(); 1835 CSSParserValue* value = m_valueList->current();
1838 // Always parse lengths in strict mode here, since it would be ambiguous oth erwise when used in 1836 // Always parse lengths in strict mode here, since it would be ambiguous oth erwise when used in
1839 // the 'columns' shorthand property. 1837 // the 'columns' shorthand property.
1840 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt andardMode) && (m_parsedCalculation || value->fValue != 0))) { 1838 if (value->id == CSSValueAuto || (validUnit(value, FLength | FNonNeg, HTMLSt andardMode) && (m_parsedCalculation || value->fValue != 0))) {
1841 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id , value); 1839 CSSValue parsedValue = parseValidPrimitive(value->id, value);
1842 m_valueList->next(); 1840 m_valueList->next();
1843 return parsedValue; 1841 return parsedValue;
1844 } 1842 }
1845 return nullptr; 1843 return nullptr;
1846 } 1844 }
1847 1845
1848 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount() 1846 NullableCSSValue CSSPropertyParser::parseColumnCount()
1849 { 1847 {
1850 CSSParserValue* value = m_valueList->current(); 1848 CSSParserValue* value = m_valueList->current();
1851 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) { 1849 if (value->id == CSSValueAuto || validUnit(value, FPositiveInteger)) {
1852 RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id , value); 1850 CSSValue parsedValue = parseValidPrimitive(value->id, value);
1853 m_valueList->next(); 1851 m_valueList->next();
1854 return parsedValue; 1852 return parsedValue;
1855 } 1853 }
1856 return nullptr; 1854 return nullptr;
1857 } 1855 }
1858 1856
1859 bool CSSPropertyParser::parseColumnsShorthand(bool important) 1857 bool CSSPropertyParser::parseColumnsShorthand(bool important)
1860 { 1858 {
1861 RefPtrWillBeRawPtr<CSSValue> columnWidth = nullptr; 1859 NullableCSSValue columnWidth;
1862 RefPtrWillBeRawPtr<CSSValue> columnCount = nullptr; 1860 NullableCSSValue columnCount;
1863 bool hasPendingExplicitAuto = false; 1861 bool hasPendingExplicitAuto = false;
1864 1862
1865 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) { 1863 for (unsigned propertiesParsed = 0; CSSParserValue* value = m_valueList->cur rent(); propertiesParsed++) {
1866 if (propertiesParsed >= 2) 1864 if (propertiesParsed >= 2)
1867 return false; // Too many values for this shorthand. Invalid declara tion. 1865 return false; // Too many values for this shorthand. Invalid declara tion.
1868 if (!propertiesParsed && value->id == CSSValueAuto) { 1866 if (!propertiesParsed && value->id == CSSValueAuto) {
1869 // 'auto' is a valid value for any of the two longhands, and at this point we 1867 // 'auto' is a valid value for any of the two longhands, and at this point we
1870 // don't know which one(s) it is meant for. We need to see if there are other 1868 // don't know which one(s) it is meant for. We need to see if there are other
1871 // values first. 1869 // values first.
1872 m_valueList->next(); 1870 m_valueList->next();
(...skipping 21 matching lines...) Expand all
1894 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); 1892 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto);
1895 } else { 1893 } else {
1896 ASSERT(!columnCount); 1894 ASSERT(!columnCount);
1897 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); 1895 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto);
1898 } 1896 }
1899 } 1897 }
1900 ASSERT(columnCount || columnWidth); 1898 ASSERT(columnCount || columnWidth);
1901 1899
1902 // Any unassigned property at this point will become implicit 'auto'. 1900 // Any unassigned property at this point will become implicit 'auto'.
1903 if (columnWidth) 1901 if (columnWidth)
1904 addProperty(CSSPropertyWebkitColumnWidth, columnWidth, important); 1902 addProperty(CSSPropertyWebkitColumnWidth, *columnWidth, important);
1905 else 1903 else
1906 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1904 addProperty(CSSPropertyWebkitColumnWidth, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1907 if (columnCount) 1905 if (columnCount)
1908 addProperty(CSSPropertyWebkitColumnCount, columnCount, important); 1906 addProperty(CSSPropertyWebkitColumnCount, *columnCount, important);
1909 else 1907 else
1910 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */); 1908 addProperty(CSSPropertyWebkitColumnCount, cssValuePool().createIdentifie rValue(CSSValueAuto), important, true /* implicit */);
1911 return true; 1909 return true;
1912 } 1910 }
1913 1911
1914 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important) 1912 bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty Shorthand& shorthand, bool important)
1915 { 1913 {
1916 // We try to match as many properties as possible 1914 // We try to match as many properties as possible
1917 // We set up an array of booleans to mark which property has been found, 1915 // We set up an array of booleans to mark which property has been found,
1918 // and we try to search for properties until it makes no longer any sense. 1916 // 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
1970 1968
1971 int num = inShorthand() ? 1 : m_valueList->size(); 1969 int num = inShorthand() ? 1 : m_valueList->size();
1972 1970
1973 ShorthandScope scope(this, propId); 1971 ShorthandScope scope(this, propId);
1974 1972
1975 // the order is top, right, bottom, left 1973 // the order is top, right, bottom, left
1976 switch (num) { 1974 switch (num) {
1977 case 1: { 1975 case 1: {
1978 if (!parseValue(properties[0], important)) 1976 if (!parseValue(properties[0], important))
1979 return false; 1977 return false;
1980 CSSValue* value = m_parsedProperties.last().value(); 1978 CSSValue value = m_parsedProperties.last().value();
1981 ImplicitScope implicitScope(this); 1979 ImplicitScope implicitScope(this);
1982 addProperty(properties[1], value, important); 1980 addProperty(properties[1], value, important);
1983 addProperty(properties[2], value, important); 1981 addProperty(properties[2], value, important);
1984 addProperty(properties[3], value, important); 1982 addProperty(properties[3], value, important);
1985 break; 1983 break;
1986 } 1984 }
1987 case 2: { 1985 case 2: {
1988 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important)) 1986 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important))
1989 return false; 1987 return false;
1990 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2]. value(); 1988 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue();
1991 ImplicitScope implicitScope(this); 1989 ImplicitScope implicitScope(this);
1992 addProperty(properties[2], value, important); 1990 addProperty(properties[2], value, important);
1993 value = m_parsedProperties[m_parsedProperties.size() - 2].value(); 1991 value = m_parsedProperties[m_parsedProperties.size() - 2].value();
1994 addProperty(properties[3], value, important); 1992 addProperty(properties[3], value, important);
1995 break; 1993 break;
1996 } 1994 }
1997 case 3: { 1995 case 3: {
1998 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important)) 1996 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important))
1999 return false; 1997 return false;
2000 CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2]. value(); 1998 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue();
2001 ImplicitScope implicitScope(this); 1999 ImplicitScope implicitScope(this);
2002 addProperty(properties[3], value, important); 2000 addProperty(properties[3], value, important);
2003 break; 2001 break;
2004 } 2002 }
2005 case 4: { 2003 case 4: {
2006 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || 2004 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) ||
2007 !parseValue(properties[2], important) || !parseValue(properties[ 3], important)) 2005 !parseValue(properties[2], important) || !parseValue(properties[ 3], important))
2008 return false; 2006 return false;
2009 break; 2007 break;
2010 } 2008 }
2011 default: { 2009 default: {
2012 return false; 2010 return false;
2013 } 2011 }
2014 } 2012 }
2015 2013
2016 return true; 2014 return true;
2017 } 2015 }
2018 2016
2019 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() 2017 NullableCSSValue CSSPropertyParser::parseScrollSnapPoints()
2020 { 2018 {
2021 CSSParserValue* value = m_valueList->current(); 2019 CSSParserValue* value = m_valueList->current();
2022 2020
2023 if (value->id == CSSValueNone) { 2021 if (value->id == CSSValueNone) {
2024 m_valueList->next(); 2022 m_valueList->next();
2025 return cssValuePool().createIdentifierValue(CSSValueNone); 2023 return cssValuePool().createIdentifierValue(CSSValueNone);
2026 } 2024 }
2027 2025
2028 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) { 2026 if (value->unit == CSSParserValue::Function && value->function->id == CSSVal ueRepeat) {
2029 // The spec defines the following grammar: repeat( <length>) 2027 // The spec defines the following grammar: repeat( <length>)
2030 CSSParserValueList* arguments = value->function->args.get(); 2028 CSSParserValueList* arguments = value->function->args.get();
2031 if (!arguments || arguments->size() != 1) 2029 if (!arguments || arguments->size() != 1)
2032 return nullptr; 2030 return nullptr;
2033 2031
2034 CSSParserValue* repeatValue = arguments->valueAt(0); 2032 CSSParserValue* repeatValue = arguments->valueAt(0);
2035 if (!validUnit(repeatValue, FNonNeg | FLength | FPercent)) 2033 if (!validUnit(repeatValue, FNonNeg | FLength | FPercent))
2036 return nullptr; 2034 return nullptr;
2037 2035
2038 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueRepeat); 2036 RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(C SSValueRepeat);
2039 result->append(parseValidPrimitive(repeatValue->id, repeatValue)); 2037 result->append(parseValidPrimitive(repeatValue->id, repeatValue));
2040 m_valueList->next(); 2038 m_valueList->next();
2041 return result.release(); 2039 return result.release();
2042 } 2040 }
2043 2041
2044 return nullptr; 2042 return nullptr;
2045 } 2043 }
2046 2044
2047 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() 2045 NullableCSSValue CSSPropertyParser::parseScrollSnapCoordinate()
2048 { 2046 {
2049 if (m_valueList->current()->id == CSSValueNone) { 2047 if (m_valueList->current()->id == CSSValueNone) {
2050 m_valueList->next(); 2048 m_valueList->next();
2051 return cssValuePool().createIdentifierValue(CSSValueNone); 2049 return cssValuePool().createIdentifierValue(CSSValueNone);
2052 } 2050 }
2053 2051
2054 return parsePositionList(m_valueList); 2052 return parsePositionList(m_valueList);
2055 } 2053 }
2056 2054
2057 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() 2055 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage()
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 parsedValues->append(createPrimitiveNumericValue(value)); 2125 parsedValues->append(createPrimitiveNumericValue(value));
2128 return Length; 2126 return Length;
2129 } 2127 }
2130 return None; 2128 return None;
2131 default: 2129 default:
2132 return None; 2130 return None;
2133 } 2131 }
2134 } 2132 }
2135 2133
2136 // [ <string> <string> ]+ | none, but none is handled in parseValue 2134 // [ <string> <string> ]+ | none, but none is handled in parseValue
2137 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes() 2135 NullableCSSValue CSSPropertyParser::parseQuotes()
2138 { 2136 {
2139 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 2137 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
2140 while (CSSParserValue* val = m_valueList->current()) { 2138 while (CSSParserValue* val = m_valueList->current()) {
2141 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 2139 NullableCSSValue parsedValue;
2142 if (val->unit != CSSPrimitiveValue::CSS_STRING) 2140 if (val->unit != CSSPrimitiveValue::CSS_STRING)
2143 return nullptr; 2141 return nullptr;
2144 parsedValue = createPrimitiveStringValue(val); 2142 parsedValue = createPrimitiveStringValue(val);
2145 values->append(parsedValue.release()); 2143 values->append(*parsedValue);
2146 m_valueList->next(); 2144 m_valueList->next();
2147 } 2145 }
2148 if (values->length() && values->length() % 2 == 0) 2146 if (values->length() && values->length() % 2 == 0)
2149 return values.release(); 2147 return values.release();
2150 return nullptr; 2148 return nullptr;
2151 } 2149 }
2152 2150
2153 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit 2151 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open -quote | no-close-quote ]+ | inherit
2154 // in CSS 2.1 this got somewhat reduced: 2152 // in CSS 2.1 this got somewhat reduced:
2155 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit 2153 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit
2156 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent() 2154 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseContent()
2157 { 2155 {
2158 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 2156 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
2159 2157
2160 while (CSSParserValue* val = m_valueList->current()) { 2158 while (CSSParserValue* val = m_valueList->current()) {
2161 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 2159 NullableCSSValue parsedValue;
2162 if (val->unit == CSSPrimitiveValue::CSS_URI) { 2160 if (val->unit == CSSPrimitiveValue::CSS_URI) {
2163 // url 2161 // url
2164 parsedValue = createCSSImageValueWithReferrer(val->string, completeU RL(val->string)); 2162 parsedValue = createCSSImageValueWithReferrer(val->string, completeU RL(val->string));
2165 } else if (val->unit == CSSParserValue::Function) { 2163 } else if (val->unit == CSSParserValue::Function) {
2166 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...) 2164 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...)
2167 CSSParserValueList* args = val->function->args.get(); 2165 CSSParserValueList* args = val->function->args.get();
2168 if (!args) 2166 if (!args)
2169 return nullptr; 2167 return nullptr;
2170 if (val->function->id == CSSValueAttr) { 2168 if (val->function->id == CSSValueAttr) {
2171 parsedValue = parseAttr(args); 2169 parsedValue = parseAttr(args);
(...skipping 17 matching lines...) Expand all
2189 case CSSValueNormal: 2187 case CSSValueNormal:
2190 parsedValue = cssValuePool().createIdentifierValue(val->id); 2188 parsedValue = cssValuePool().createIdentifierValue(val->id);
2191 default: 2189 default:
2192 break; 2190 break;
2193 } 2191 }
2194 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) { 2192 } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
2195 parsedValue = createPrimitiveStringValue(val); 2193 parsedValue = createPrimitiveStringValue(val);
2196 } 2194 }
2197 if (!parsedValue) 2195 if (!parsedValue)
2198 return nullptr; 2196 return nullptr;
2199 values->append(parsedValue.release()); 2197 values->append(*parsedValue);
2200 m_valueList->next(); 2198 m_valueList->next();
2201 } 2199 }
2202 2200
2203 return values.release(); 2201 return values.release();
2204 } 2202 }
2205 2203
2206 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAttr(CSSParserValueList * args) 2204 NullableCSSValue CSSPropertyParser::parseAttr(CSSParserValueList* args)
2207 { 2205 {
2208 if (args->size() != 1) 2206 if (args->size() != 1)
2209 return nullptr; 2207 return nullptr;
2210 2208
2211 CSSParserValue* a = args->current(); 2209 CSSParserValue* a = args->current();
2212 2210
2213 if (a->unit != CSSPrimitiveValue::CSS_IDENT) 2211 if (a->unit != CSSPrimitiveValue::CSS_IDENT)
2214 return nullptr; 2212 return nullptr;
2215 2213
2216 String attrName = a->string; 2214 String attrName = a->string;
2217 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". 2215 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image".
2218 // But HTML attribute names can't have those characters, and we should not 2216 // But HTML attribute names can't have those characters, and we should not
2219 // even parse them inside attr(). 2217 // even parse them inside attr().
2220 if (attrName[0] == '-') 2218 if (attrName[0] == '-')
2221 return nullptr; 2219 return nullptr;
2222 2220
2223 if (m_context.isHTMLDocument()) 2221 if (m_context.isHTMLDocument())
2224 attrName = attrName.lower(); 2222 attrName = attrName.lower();
2225 2223
2226 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR); 2224 return cssValuePool().createValue(attrName, CSSPrimitiveValue::CSS_ATTR);
2227 } 2225 }
2228 2226
2229 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBackgroundColor() 2227 NullableCSSValue CSSPropertyParser::parseBackgroundColor()
2230 { 2228 {
2231 CSSValueID id = m_valueList->current()->id; 2229 CSSValueID id = m_valueList->current()->id;
2232 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt ext) || id == CSSValueMenu || id == CSSValueCurrentcolor || 2230 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt ext) || id == CSSValueMenu || id == CSSValueCurrentcolor ||
2233 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode())) 2231 (id >= CSSValueGrey && id < CSSValueWebkitText && inQuirksMode()))
2234 return cssValuePool().createIdentifierValue(id); 2232 return cssValuePool().createIdentifierValue(id);
2235 return parseColor(); 2233 return parseColor();
2236 } 2234 }
2237 2235
2238 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& value) 2236 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, NullableCS SValue& value)
2239 { 2237 {
2240 if (valueList->current()->id == CSSValueNone) { 2238 if (valueList->current()->id == CSSValueNone) {
2241 value = cssValuePool().createIdentifierValue(CSSValueNone); 2239 value = cssValuePool().createIdentifierValue(CSSValueNone);
2242 return true; 2240 return true;
2243 } 2241 }
2244 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { 2242 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
2245 value = createCSSImageValueWithReferrer(valueList->current()->string, co mpleteURL(valueList->current()->string)); 2243 value = createCSSImageValueWithReferrer(valueList->current()->string, co mpleteURL(valueList->current()->string));
2246 return true; 2244 return true;
2247 } 2245 }
2248 2246
2249 if (isGeneratedImageValue(valueList->current())) 2247 if (isGeneratedImageValue(valueList->current()))
2250 return parseGeneratedImage(valueList, value); 2248 return parseGeneratedImage(valueList, value);
2251 2249
2252 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur rent()->function->id == CSSValueWebkitImageSet) { 2250 if (valueList->current()->unit == CSSParserValue::Function && valueList->cur rent()->function->id == CSSValueWebkitImageSet) {
2253 value = parseImageSet(m_valueList); 2251 value = parseImageSet(m_valueList);
2254 if (value) 2252 if (value)
2255 return true; 2253 return true;
2256 } 2254 }
2257 2255
2258 return false; 2256 return false;
2259 } 2257 }
2260 2258
2261 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionX(CSSParser ValueList* valueList) 2259 NullableCSSValue CSSPropertyParser::parseFillPositionX(CSSParserValueList* value List)
2262 { 2260 {
2263 int id = valueList->current()->id; 2261 int id = valueList->current()->id;
2264 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) { 2262 if (id == CSSValueLeft || id == CSSValueRight || id == CSSValueCenter) {
2265 int percent = 0; 2263 int percent = 0;
2266 if (id == CSSValueRight) 2264 if (id == CSSValueRight)
2267 percent = 100; 2265 percent = 100;
2268 else if (id == CSSValueCenter) 2266 else if (id == CSSValueCenter)
2269 percent = 50; 2267 percent = 50;
2270 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE); 2268 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE);
2271 } 2269 }
2272 if (validUnit(valueList->current(), FPercent | FLength)) 2270 if (validUnit(valueList->current(), FPercent | FLength))
2273 return createPrimitiveNumericValue(valueList->current()); 2271 return createPrimitiveNumericValue(valueList->current());
2274 return nullptr; 2272 return nullptr;
2275 } 2273 }
2276 2274
2277 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillPositionY(CSSParser ValueList* valueList) 2275 NullableCSSValue CSSPropertyParser::parseFillPositionY(CSSParserValueList* value List)
2278 { 2276 {
2279 int id = valueList->current()->id; 2277 int id = valueList->current()->id;
2280 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) { 2278 if (id == CSSValueTop || id == CSSValueBottom || id == CSSValueCenter) {
2281 int percent = 0; 2279 int percent = 0;
2282 if (id == CSSValueBottom) 2280 if (id == CSSValueBottom)
2283 percent = 100; 2281 percent = 100;
2284 else if (id == CSSValueCenter) 2282 else if (id == CSSValueCenter)
2285 percent = 50; 2283 percent = 50;
2286 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE); 2284 return cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCEN TAGE);
2287 } 2285 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 return true; 2346 return true;
2349 2347
2350 return false; 2348 return false;
2351 } 2349 }
2352 2350
2353 static bool isFillPositionKeyword(CSSValueID value) 2351 static bool isFillPositionKeyword(CSSValueID value)
2354 { 2352 {
2355 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter; 2353 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter;
2356 } 2354 }
2357 2355
2358 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2356 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu e2)
2359 { 2357 {
2360 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ] 2358 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ]
2361 // In the case of 4 values <position> requires the second value to be a leng th or a percentage. 2359 // In the case of 4 values <position> requires the second value to be a leng th or a percentage.
2362 if (isFillPositionKeyword(parsedValue2->getValueID())) 2360 if (isFillPositionKeyword(parsedValue2->getValueID()))
2363 return; 2361 return;
2364 2362
2365 unsigned cumulativeFlags = 0; 2363 unsigned cumulativeFlags = 0;
2366 FillPositionFlag value3Flag = InvalidFillPosition; 2364 FillPositionFlag value3Flag = InvalidFillPosition;
2367 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); 2365 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword);
2368 if (!value3) 2366 if (!value3)
(...skipping 27 matching lines...) Expand all
2396 return; 2394 return;
2397 2395
2398 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); 2396 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2);
2399 value2 = createPrimitiveValuePair(value3, value4); 2397 value2 = createPrimitiveValuePair(value3, value4);
2400 2398
2401 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) 2399 if (ident1 == CSSValueTop || ident1 == CSSValueBottom)
2402 value1.swap(value2); 2400 value1.swap(value2);
2403 2401
2404 valueList->next(); 2402 valueList->next();
2405 } 2403 }
2406 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2404 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValu e2)
2407 { 2405 {
2408 unsigned cumulativeFlags = 0; 2406 unsigned cumulativeFlags = 0;
2409 FillPositionFlag value3Flag = InvalidFillPosition; 2407 FillPositionFlag value3Flag = InvalidFillPosition;
2410 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword); 2408 RefPtrWillBeRawPtr<CSSPrimitiveValue> value3 = parseFillPositionComponent(va lueList, cumulativeFlags, value3Flag, ResolveValuesAsKeyword);
2411 2409
2412 // value3 is not an expected value, we return. 2410 // value3 is not an expected value, we return.
2413 if (!value3) 2411 if (!value3)
2414 return; 2412 return;
2415 2413
2416 valueList->next(); 2414 valueList->next();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 return; 2476 return;
2479 2477
2480 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); 2478 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue);
2481 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue); 2479 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue);
2482 } 2480 }
2483 2481
2484 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) 2482 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded)
2485 value1.swap(value2); 2483 value1.swap(value2);
2486 2484
2487 #if ENABLE(ASSERT) 2485 #if ENABLE(ASSERT)
2488 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); 2486 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1);
2489 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); 2487 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2);
2490 ident1 = first->getPairValue()->first()->getValueID(); 2488 ident1 = first->getPairValue()->first()->getValueID();
2491 ident2 = second->getPairValue()->first()->getValueID(); 2489 ident2 = second->getPairValue()->first()->getValueID();
2492 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); 2490 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight);
2493 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); 2491 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop);
2494 #endif 2492 #endif
2495 } 2493 }
2496 2494
2497 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) 2495 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value)
2498 { 2496 {
2499 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue); 2497 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue);
2500 } 2498 }
2501 2499
2502 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW illBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Units unitl ess) 2500 void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, Nullabl eCSSValue& value1, NullableCSSValue& value2, Units unitless)
2503 { 2501 {
2504 unsigned numberOfValues = 0; 2502 unsigned numberOfValues = 0;
2505 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n umberOfValues) { 2503 for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++n umberOfValues) {
2506 CSSParserValue* current = valueList->valueAt(i); 2504 CSSParserValue* current = valueList->valueAt(i);
2507 if (!current || isComma(current) || isForwardSlashOperator(current) || ! isPotentialPositionValue(current)) 2505 if (!current || isComma(current) || isForwardSlashOperator(current) || ! isPotentialPositionValue(current))
2508 break; 2506 break;
2509 } 2507 }
2510 2508
2511 if (numberOfValues > 4) 2509 if (numberOfValues > 4)
2512 return; 2510 return;
(...skipping 22 matching lines...) Expand all
2535 2533
2536 valueList->next(); 2534 valueList->next();
2537 2535
2538 // In case we are parsing more than two values, relax the check inside of pa rseFillPositionComponent. top 20px is 2536 // In case we are parsing more than two values, relax the check inside of pa rseFillPositionComponent. top 20px is
2539 // a valid start for <position>. 2537 // a valid start for <position>.
2540 cumulativeFlags = AmbiguousFillPosition; 2538 cumulativeFlags = AmbiguousFillPosition;
2541 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword); 2539 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword);
2542 if (value2) 2540 if (value2)
2543 valueList->next(); 2541 valueList->next();
2544 else { 2542 else {
2545 value1.clear(); 2543 value1 = nullptr;
2546 return; 2544 return;
2547 } 2545 }
2548 2546
2549 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val ue1.get()); 2547 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(val ue1);
2550 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val ue2.get()); 2548 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(val ue2);
2551 2549
2552 value1.clear(); 2550 value1 = nullptr;
2553 value2.clear(); 2551 value2 = nullptr;
2554 2552
2555 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow. 2553 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow.
2556 if (parsedValue2->getValueID() == CSSValueCenter) 2554 if (parsedValue2->getValueID() == CSSValueCenter)
2557 return; 2555 return;
2558 2556
2559 if (numberOfValues == 3) 2557 if (numberOfValues == 3)
2560 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1.release (), parsedValue2.release()); 2558 parse3ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed Value2);
2561 else 2559 else
2562 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1.release (), parsedValue2.release()); 2560 parse4ValuesFillPosition(valueList, value1, value2, parsedValue1, parsed Value2);
2563 } 2561 }
2564 2562
2565 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Unit s unitless) 2563 void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, Units unitless)
2566 { 2564 {
2567 // Parse the first value. We're just making sure that it is one of the vali d keywords or a percentage/length. 2565 // Parse the first value. We're just making sure that it is one of the vali d keywords or a percentage/length.
2568 unsigned cumulativeFlags = 0; 2566 unsigned cumulativeFlags = 0;
2569 FillPositionFlag value1Flag = InvalidFillPosition; 2567 FillPositionFlag value1Flag = InvalidFillPosition;
2570 FillPositionFlag value2Flag = InvalidFillPosition; 2568 FillPositionFlag value2Flag = InvalidFillPosition;
2571 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag, ResolveValuesAsPercent, unitless); 2569 value1 = parseFillPositionComponent(valueList, cumulativeFlags, value1Flag, ResolveValuesAsPercent, unitless);
2572 if (!value1) 2570 if (!value1)
2573 return; 2571 return;
2574 2572
2575 // It only takes one value for background-position to be correctly parsed if it was specified in a shorthand (since we 2573 // It only takes one value for background-position to be correctly parsed if it was specified in a shorthand (since we
2576 // can assume that any other values belong to the rest of the shorthand). I f we're not parsing a shorthand, though, the 2574 // can assume that any other values belong to the rest of the shorthand). I f we're not parsing a shorthand, though, the
2577 // value was explicitly specified for our property. 2575 // value was explicitly specified for our property.
2578 CSSParserValue* value = valueList->next(); 2576 CSSParserValue* value = valueList->next();
2579 2577
2580 // First check for the comma. If so, we are finished parsing this value or value pair. 2578 // First check for the comma. If so, we are finished parsing this value or value pair.
2581 if (value && isComma(value)) 2579 if (value && isComma(value))
2582 value = 0; 2580 value = 0;
2583 2581
2584 if (value) { 2582 if (value) {
2585 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl ag, ResolveValuesAsPercent, unitless); 2583 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Fl ag, ResolveValuesAsPercent, unitless);
2586 if (value2) 2584 if (value2)
2587 valueList->next(); 2585 valueList->next();
2588 else { 2586 else {
2589 if (!inShorthand()) { 2587 if (!inShorthand()) {
2590 value1.clear(); 2588 value1 = nullptr;
2591 return; 2589 return;
2592 } 2590 }
2593 } 2591 }
2594 } 2592 }
2595 2593
2596 if (!value2) 2594 if (!value2)
2597 // Only one value was specified. If that value was not a keyword, then i t sets the x position, and the y position 2595 // Only one value was specified. If that value was not a keyword, then i t sets the x position, and the y position
2598 // is simply 50%. This is our default. 2596 // is simply 50%. This is our default.
2599 // For keywords, the keyword was either an x-keyword (left/right), a y-k eyword (top/bottom), or an ambiguous keyword (center). 2597 // For keywords, the keyword was either an x-keyword (left/right), a y-k eyword (top/bottom), or an ambiguous keyword (center).
2600 // For left/right/center, the default of 50% in the y is still correct. 2598 // For left/right/center, the default of 50% in the y is still correct.
2601 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG E); 2599 value2 = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCENTAG E);
2602 2600
2603 if (value1Flag == YFillPosition || value2Flag == XFillPosition) 2601 if (value1Flag == YFillPosition || value2Flag == XFillPosition)
2604 value1.swap(value2); 2602 value1.swap(value2);
2605 } 2603 }
2606 2604
2607 void CSSPropertyParser::parseFillRepeat(RefPtrWillBeRawPtr<CSSValue>& value1, Re fPtrWillBeRawPtr<CSSValue>& value2) 2605 void CSSPropertyParser::parseFillRepeat(NullableCSSValue& value1, NullableCSSVal ue& value2)
2608 { 2606 {
2609 CSSValueID id = m_valueList->current()->id; 2607 CSSValueID id = m_valueList->current()->id;
2610 if (id == CSSValueRepeatX) { 2608 if (id == CSSValueRepeatX) {
2611 m_implicitShorthand = true; 2609 m_implicitShorthand = true;
2612 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat); 2610 value1 = cssValuePool().createIdentifierValue(CSSValueRepeat);
2613 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat); 2611 value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
2614 m_valueList->next(); 2612 m_valueList->next();
2615 return; 2613 return;
2616 } 2614 }
2617 if (id == CSSValueRepeatY) { 2615 if (id == CSSValueRepeatY) {
(...skipping 17 matching lines...) Expand all
2635 id = value->id; 2633 id = value->id;
2636 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun d || id == CSSValueSpace) { 2634 if (id == CSSValueRepeat || id == CSSValueNoRepeat || id == CSSValueRoun d || id == CSSValueSpace) {
2637 value2 = cssValuePool().createIdentifierValue(id); 2635 value2 = cssValuePool().createIdentifierValue(id);
2638 m_valueList->next(); 2636 m_valueList->next();
2639 return; 2637 return;
2640 } 2638 }
2641 } 2639 }
2642 2640
2643 // If only one value was specified, value2 is the same as value1. 2641 // If only one value was specified, value2 is the same as value1.
2644 m_implicitShorthand = true; 2642 m_implicitShorthand = true;
2645 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get ())->getValueID()); 2643 value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1)->g etValueID());
2646 } 2644 }
2647 2645
2648 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProperty) 2646 NullableCSSValue CSSPropertyParser::parseFillSize(CSSPropertyID unresolvedProper ty)
2649 { 2647 {
2650 CSSParserValue* value = m_valueList->current(); 2648 CSSParserValue* value = m_valueList->current();
2651 m_valueList->next(); 2649 m_valueList->next();
2652 2650
2653 if (value->id == CSSValueContain || value->id == CSSValueCover) 2651 if (value->id == CSSValueContain || value->id == CSSValueCover)
2654 return cssValuePool().createIdentifierValue(value->id); 2652 return cssValuePool().createIdentifierValue(value->id);
2655 2653
2656 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr; 2654 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1 = nullptr;
2657 2655
2658 if (value->id == CSSValueAuto) 2656 if (value->id == CSSValueAuto)
(...skipping 21 matching lines...) Expand all
2680 parsedValue2 = parsedValue1; 2678 parsedValue2 = parsedValue1;
2681 } 2679 }
2682 2680
2683 if (!parsedValue2) 2681 if (!parsedValue2)
2684 return parsedValue1; 2682 return parsedValue1;
2685 2683
2686 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues); 2684 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues);
2687 } 2685 }
2688 2686
2689 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, 2687 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2,
2690 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa lue2) 2688 NullableCSSValue& retValue1, NullableCSSValue& retValue2)
2691 { 2689 {
2692 // We initially store the first value in value/value2, and only create 2690 // We initially store the first value in value/value2, and only create
2693 // CSSValueLists if we have more values. 2691 // CSSValueLists if we have more values.
2694 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; 2692 RefPtrWillBeRawPtr<CSSValueList> values = nullptr;
2695 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; 2693 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr;
2696 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 2694 NullableCSSValue value;
2697 RefPtrWillBeRawPtr<CSSValue> value2 = nullptr; 2695 NullableCSSValue value2;
2698 2696
2699 retValue1 = retValue2 = nullptr; 2697 retValue1 = nullptr;
2698 retValue2 = nullptr;
2700 propId1 = resolveCSSPropertyID(propId); 2699 propId1 = resolveCSSPropertyID(propId);
2701 propId2 = propId1; 2700 propId2 = propId1;
2702 if (propId == CSSPropertyBackgroundPosition) { 2701 if (propId == CSSPropertyBackgroundPosition) {
2703 propId1 = CSSPropertyBackgroundPositionX; 2702 propId1 = CSSPropertyBackgroundPositionX;
2704 propId2 = CSSPropertyBackgroundPositionY; 2703 propId2 = CSSPropertyBackgroundPositionY;
2705 } else if (propId == CSSPropertyWebkitMaskPosition) { 2704 } else if (propId == CSSPropertyWebkitMaskPosition) {
2706 propId1 = CSSPropertyWebkitMaskPositionX; 2705 propId1 = CSSPropertyWebkitMaskPositionX;
2707 propId2 = CSSPropertyWebkitMaskPositionY; 2706 propId2 = CSSPropertyWebkitMaskPositionY;
2708 } else if (propId == CSSPropertyBackgroundRepeat) { 2707 } else if (propId == CSSPropertyBackgroundRepeat) {
2709 propId1 = CSSPropertyBackgroundRepeatX; 2708 propId1 = CSSPropertyBackgroundRepeatX;
2710 propId2 = CSSPropertyBackgroundRepeatY; 2709 propId2 = CSSPropertyBackgroundRepeatY;
2711 } else if (propId == CSSPropertyWebkitMaskRepeat) { 2710 } else if (propId == CSSPropertyWebkitMaskRepeat) {
2712 propId1 = CSSPropertyWebkitMaskRepeatX; 2711 propId1 = CSSPropertyWebkitMaskRepeatX;
2713 propId2 = CSSPropertyWebkitMaskRepeatY; 2712 propId2 = CSSPropertyWebkitMaskRepeatY;
2714 } 2713 }
2715 2714
2716 while (true) { 2715 while (true) {
2717 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; 2716 NullableCSSValue currValue;
2718 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; 2717 NullableCSSValue currValue2;
2719 2718
2720 Units unitless = FUnknown; 2719 Units unitless = FUnknown;
2721 CSSParserValue* val = m_valueList->current(); 2720 CSSParserValue* val = m_valueList->current();
2722 ASSERT(val); 2721 ASSERT(val);
2723 2722
2724 switch (propId) { 2723 switch (propId) {
2725 case CSSPropertyBackgroundColor: 2724 case CSSPropertyBackgroundColor:
2726 currValue = parseBackgroundColor(); 2725 currValue = parseBackgroundColor();
2727 if (currValue) 2726 if (currValue)
2728 m_valueList->next(); 2727 m_valueList->next();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 break; 2823 break;
2825 } 2824 }
2826 default: 2825 default:
2827 break; 2826 break;
2828 } 2827 }
2829 if (!currValue) 2828 if (!currValue)
2830 return false; 2829 return false;
2831 2830
2832 if (value && !values) { 2831 if (value && !values) {
2833 values = CSSValueList::createCommaSeparated(); 2832 values = CSSValueList::createCommaSeparated();
2834 values->append(value.release()); 2833 values->append(*value);
2835 } 2834 }
2836 2835
2837 if (value2 && !values2) { 2836 if (value2 && !values2) {
2838 values2 = CSSValueList::createCommaSeparated(); 2837 values2 = CSSValueList::createCommaSeparated();
2839 values2->append(value2.release()); 2838 values2->append(*value2);
2840 } 2839 }
2841 2840
2842 if (values) 2841 if (values)
2843 values->append(currValue.release()); 2842 values->append(*currValue);
2844 else 2843 else
2845 value = currValue.release(); 2844 value = currValue;
2846 if (currValue2) { 2845 if (currValue2) {
2847 if (values2) 2846 if (values2)
2848 values2->append(currValue2.release()); 2847 values2->append(*currValue2);
2849 else 2848 else
2850 value2 = currValue2.release(); 2849 value2 = currValue2;
2851 } 2850 }
2852 2851
2853 // When parsing any fill shorthand property, we let it handle building u p the lists for all 2852 // When parsing any fill shorthand property, we let it handle building u p the lists for all
2854 // properties. 2853 // properties.
2855 if (inShorthand()) 2854 if (inShorthand())
2856 break; 2855 break;
2857 2856
2858 if (!m_valueList->current()) 2857 if (!m_valueList->current())
2859 break; 2858 break;
2860 if (!consumeComma(m_valueList) || !m_valueList->current()) 2859 if (!consumeComma(m_valueList) || !m_valueList->current())
2861 return false; 2860 return false;
2862 } 2861 }
2863 2862
2864 if (values) { 2863 if (values) {
2865 ASSERT(values->length()); 2864 ASSERT(values->length());
2866 retValue1 = values.release(); 2865 retValue1 = values.release();
2867 if (values2) { 2866 if (values2) {
2868 ASSERT(values2->length()); 2867 ASSERT(values2->length());
2869 retValue2 = values2.release(); 2868 retValue2 = values2.release();
2870 } 2869 }
2871 } else { 2870 } else {
2872 ASSERT(value); 2871 ASSERT(value);
2873 retValue1 = value.release(); 2872 retValue1 = value;
2874 retValue2 = value2.release(); 2873 retValue2 = value2;
2875 } 2874 }
2876 2875
2877 return true; 2876 return true;
2878 } 2877 }
2879 2878
2880 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDelay() 2879 NullableCSSValue CSSPropertyParser::parseAnimationDelay()
2881 { 2880 {
2882 CSSParserValue* value = m_valueList->current(); 2881 CSSParserValue* value = m_valueList->current();
2883 if (validUnit(value, FTime)) 2882 if (validUnit(value, FTime))
2884 return createPrimitiveNumericValue(value); 2883 return createPrimitiveNumericValue(value);
2885 return nullptr; 2884 return nullptr;
2886 } 2885 }
2887 2886
2888 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDirection() 2887 NullableCSSValue CSSPropertyParser::parseAnimationDirection()
2889 { 2888 {
2890 CSSParserValue* value = m_valueList->current(); 2889 CSSParserValue* value = m_valueList->current();
2891 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse) 2890 if (value->id == CSSValueNormal || value->id == CSSValueAlternate || value-> id == CSSValueReverse || value->id == CSSValueAlternateReverse)
2892 return cssValuePool().createIdentifierValue(value->id); 2891 return cssValuePool().createIdentifierValue(value->id);
2893 return nullptr; 2892 return nullptr;
2894 } 2893 }
2895 2894
2896 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationDuration() 2895 NullableCSSValue CSSPropertyParser::parseAnimationDuration()
2897 { 2896 {
2898 CSSParserValue* value = m_valueList->current(); 2897 CSSParserValue* value = m_valueList->current();
2899 if (validUnit(value, FTime | FNonNeg)) 2898 if (validUnit(value, FTime | FNonNeg))
2900 return createPrimitiveNumericValue(value); 2899 return createPrimitiveNumericValue(value);
2901 return nullptr; 2900 return nullptr;
2902 } 2901 }
2903 2902
2904 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationFillMode() 2903 NullableCSSValue CSSPropertyParser::parseAnimationFillMode()
2905 { 2904 {
2906 CSSParserValue* value = m_valueList->current(); 2905 CSSParserValue* value = m_valueList->current();
2907 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth) 2906 if (value->id == CSSValueNone || value->id == CSSValueForwards || value->id == CSSValueBackwards || value->id == CSSValueBoth)
2908 return cssValuePool().createIdentifierValue(value->id); 2907 return cssValuePool().createIdentifierValue(value->id);
2909 return nullptr; 2908 return nullptr;
2910 } 2909 }
2911 2910
2912 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationIterationCount () 2911 NullableCSSValue CSSPropertyParser::parseAnimationIterationCount()
2913 { 2912 {
2914 CSSParserValue* value = m_valueList->current(); 2913 CSSParserValue* value = m_valueList->current();
2915 if (value->id == CSSValueInfinite) 2914 if (value->id == CSSValueInfinite)
2916 return cssValuePool().createIdentifierValue(value->id); 2915 return cssValuePool().createIdentifierValue(value->id);
2917 if (validUnit(value, FNumber | FNonNeg)) 2916 if (validUnit(value, FNumber | FNonNeg))
2918 return createPrimitiveNumericValue(value); 2917 return createPrimitiveNumericValue(value);
2919 return nullptr; 2918 return nullptr;
2920 } 2919 }
2921 2920
2922 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationName(bool allo wQuotedName) 2921 NullableCSSValue CSSPropertyParser::parseAnimationName(bool allowQuotedName)
2923 { 2922 {
2924 CSSParserValue* value = m_valueList->current(); 2923 CSSParserValue* value = m_valueList->current();
2925 2924
2926 if (value->id == CSSValueNone) 2925 if (value->id == CSSValueNone)
2927 return cssValuePool().createIdentifierValue(CSSValueNone); 2926 return cssValuePool().createIdentifierValue(CSSValueNone);
2928 2927
2929 if (value->unit == CSSPrimitiveValue::CSS_IDENT) 2928 if (value->unit == CSSPrimitiveValue::CSS_IDENT)
2930 return createPrimitiveCustomIdentValue(value); 2929 return createPrimitiveCustomIdentValue(value);
2931 2930
2932 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) { 2931 if (allowQuotedName && value->unit == CSSPrimitiveValue::CSS_STRING) {
2933 // Legacy support for strings in prefixed animations 2932 // Legacy support for strings in prefixed animations
2934 if (m_context.useCounter()) 2933 if (m_context.useCounter())
2935 m_context.useCounter()->count(UseCounter::QuotedAnimationName); 2934 m_context.useCounter()->count(UseCounter::QuotedAnimationName);
2936 if (equalIgnoringCase(value->string, "none")) 2935 if (equalIgnoringCase(value->string, "none"))
2937 return cssValuePool().createIdentifierValue(CSSValueNone); 2936 return cssValuePool().createIdentifierValue(CSSValueNone);
2938 return createPrimitiveCustomIdentValue(value); 2937 return createPrimitiveCustomIdentValue(value);
2939 } 2938 }
2940 2939
2941 return nullptr; 2940 return nullptr;
2942 } 2941 }
2943 2942
2944 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationPlayState() 2943 NullableCSSValue CSSPropertyParser::parseAnimationPlayState()
2945 { 2944 {
2946 CSSParserValue* value = m_valueList->current(); 2945 CSSParserValue* value = m_valueList->current();
2947 if (value->id == CSSValueRunning || value->id == CSSValuePaused) 2946 if (value->id == CSSValueRunning || value->id == CSSValuePaused)
2948 return cssValuePool().createIdentifierValue(value->id); 2947 return cssValuePool().createIdentifierValue(value->id);
2949 return nullptr; 2948 return nullptr;
2950 } 2949 }
2951 2950
2952 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty() 2951 NullableCSSValue CSSPropertyParser::parseAnimationProperty()
2953 { 2952 {
2954 CSSParserValue* value = m_valueList->current(); 2953 CSSParserValue* value = m_valueList->current();
2955 if (value->unit != CSSPrimitiveValue::CSS_IDENT) 2954 if (value->unit != CSSPrimitiveValue::CSS_IDENT)
2956 return nullptr; 2955 return nullptr;
2957 // Since all is valid css property keyword, cssPropertyID for all 2956 // Since all is valid css property keyword, cssPropertyID for all
2958 // returns non-null value. We need to check "all" before 2957 // returns non-null value. We need to check "all" before
2959 // cssPropertyID check. 2958 // cssPropertyID check.
2960 if (value->id == CSSValueAll) 2959 if (value->id == CSSValueAll)
2961 return cssValuePool().createIdentifierValue(CSSValueAll); 2960 return cssValuePool().createIdentifierValue(CSSValueAll);
2962 CSSPropertyID property = unresolvedCSSPropertyID(value->string); 2961 CSSPropertyID property = unresolvedCSSPropertyID(value->string);
(...skipping 14 matching lines...) Expand all
2977 if (!validUnit(v, FNumber)) 2976 if (!validUnit(v, FNumber))
2978 return false; 2977 return false;
2979 result = v->fValue; 2978 result = v->fValue;
2980 v = args->next(); 2979 v = args->next();
2981 if (!v) 2980 if (!v)
2982 // The last number in the function has no comma after it, so we're done. 2981 // The last number in the function has no comma after it, so we're done.
2983 return true; 2982 return true;
2984 return consumeComma(args); 2983 return consumeComma(args);
2985 } 2984 }
2986 2985
2987 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction () 2986 NullableCSSValue CSSPropertyParser::parseAnimationTimingFunction()
2988 { 2987 {
2989 CSSParserValue* value = m_valueList->current(); 2988 CSSParserValue* value = m_valueList->current();
2990 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut 2989 if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
2991 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd 2990 || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || v alue->id == CSSValueStepEnd
2992 || value->id == CSSValueStepMiddle) 2991 || value->id == CSSValueStepMiddle)
2993 return cssValuePool().createIdentifierValue(value->id); 2992 return cssValuePool().createIdentifierValue(value->id);
2994 2993
2995 // We must be a function. 2994 // We must be a function.
2996 if (value->unit != CSSParserValue::Function) 2995 if (value->unit != CSSParserValue::Function)
2997 return nullptr; 2996 return nullptr;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 return nullptr; 3057 return nullptr;
3059 if (!parseCubicBezierTimingFunctionValue(args, y2)) 3058 if (!parseCubicBezierTimingFunctionValue(args, y2))
3060 return nullptr; 3059 return nullptr;
3061 3060
3062 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2); 3061 return CSSCubicBezierTimingFunctionValue::create(x1, y1, x2, y2);
3063 } 3062 }
3064 3063
3065 return nullptr; 3064 return nullptr;
3066 } 3065 }
3067 3066
3068 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty(CSSPr opertyID propId, bool useLegacyParsing) 3067 NullableCSSValue CSSPropertyParser::parseAnimationProperty(CSSPropertyID propId, bool useLegacyParsing)
3069 { 3068 {
3070 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 3069 NullableCSSValue value;
3071 switch (propId) { 3070 switch (propId) {
3072 case CSSPropertyAnimationDelay: 3071 case CSSPropertyAnimationDelay:
3073 case CSSPropertyTransitionDelay: 3072 case CSSPropertyTransitionDelay:
3074 value = parseAnimationDelay(); 3073 value = parseAnimationDelay();
3075 break; 3074 break;
3076 case CSSPropertyAnimationDirection: 3075 case CSSPropertyAnimationDirection:
3077 value = parseAnimationDirection(); 3076 value = parseAnimationDirection();
3078 break; 3077 break;
3079 case CSSPropertyAnimationDuration: 3078 case CSSPropertyAnimationDuration:
3080 case CSSPropertyTransitionDuration: 3079 case CSSPropertyTransitionDuration:
(...skipping 18 matching lines...) Expand all
3099 case CSSPropertyTransitionTimingFunction: 3098 case CSSPropertyTransitionTimingFunction:
3100 value = parseAnimationTimingFunction(); 3099 value = parseAnimationTimingFunction();
3101 break; 3100 break;
3102 default: 3101 default:
3103 ASSERT_NOT_REACHED(); 3102 ASSERT_NOT_REACHED();
3104 return nullptr; 3103 return nullptr;
3105 } 3104 }
3106 3105
3107 if (value) 3106 if (value)
3108 m_valueList->next(); 3107 m_valueList->next();
3109 return value.release(); 3108 return value;
3110 } 3109 }
3111 3110
3112 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi st(CSSPropertyID propId, bool useLegacyParsing) 3111 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseAnimationPropertyLi st(CSSPropertyID propId, bool useLegacyParsing)
3113 { 3112 {
3114 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 3113 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
3115 while (true) { 3114 while (true) {
3116 RefPtrWillBeRawPtr<CSSValue> value = parseAnimationProperty(propId, useL egacyParsing); 3115 NullableCSSValue value = parseAnimationProperty(propId, useLegacyParsing );
3117 if (!value) 3116 if (!value)
3118 return nullptr; 3117 return nullptr;
3119 list->append(value.release()); 3118 list->append(*value);
3120 if (!m_valueList->current()) 3119 if (!m_valueList->current())
3121 break; 3120 break;
3122 if (!consumeComma(m_valueList) || !m_valueList->current()) 3121 if (!consumeComma(m_valueList) || !m_valueList->current())
3123 return nullptr; 3122 return nullptr;
3124 } 3123 }
3125 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get())) 3124 if (propId == CSSPropertyTransitionProperty && !isValidTransitionPropertyLis t(list.get()))
3126 return nullptr; 3125 return nullptr;
3127 ASSERT(list->length()); 3126 ASSERT(list->length());
3128 return list.release(); 3127 return list.release();
3129 } 3128 }
(...skipping 29 matching lines...) Expand all
3159 if (value && validUnit(value, FInteger) && value->fValue) { 3158 if (value && validUnit(value, FInteger) && value->fValue) {
3160 numericValue = createPrimitiveNumericValue(value); 3159 numericValue = createPrimitiveNumericValue(value);
3161 m_valueList->next(); 3160 m_valueList->next();
3162 } 3161 }
3163 return true; 3162 return true;
3164 } 3163 }
3165 3164
3166 return false; 3165 return false;
3167 } 3166 }
3168 3167
3169 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridPosition() 3168 NullableCSSValue CSSPropertyParser::parseGridPosition()
3170 { 3169 {
3171 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3170 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3172 3171
3173 CSSParserValue* value = m_valueList->current(); 3172 CSSParserValue* value = m_valueList->current();
3174 if (value->id == CSSValueAuto) { 3173 if (value->id == CSSValueAuto) {
3175 m_valueList->next(); 3174 m_valueList->next();
3176 return cssValuePool().createIdentifierValue(CSSValueAuto); 3175 return cssValuePool().createIdentifierValue(CSSValueAuto);
3177 } 3176 }
3178 3177
3179 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr; 3178 RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = nullptr;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3215 if (hasSeenSpanKeyword) 3214 if (hasSeenSpanKeyword)
3216 values->append(cssValuePool().createIdentifierValue(CSSValueSpan)); 3215 values->append(cssValuePool().createIdentifierValue(CSSValueSpan));
3217 if (numericValue) 3216 if (numericValue)
3218 values->append(numericValue.release()); 3217 values->append(numericValue.release());
3219 if (gridLineName) 3218 if (gridLineName)
3220 values->append(gridLineName.release()); 3219 values->append(gridLineName.release());
3221 ASSERT(values->length()); 3220 ASSERT(values->length());
3222 return values.release(); 3221 return values.release();
3223 } 3222 }
3224 3223
3225 static PassRefPtrWillBeRawPtr<CSSValue> gridMissingGridPositionValue(CSSValue* v alue) 3224 static CSSValue gridMissingGridPositionValue(CSSValue value)
3226 { 3225 {
3227 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isCustomIdent() ) 3226 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isCustomIdent())
3228 return value; 3227 return value;
3229 3228
3230 return cssValuePool().createIdentifierValue(CSSValueAuto); 3229 return cssValuePool().createIdentifierValue(CSSValueAuto);
3231 } 3230 }
3232 3231
3233 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId , bool important) 3232 bool CSSPropertyParser::parseGridItemPositionShorthand(CSSPropertyID shorthandId , bool important)
3234 { 3233 {
3235 ShorthandScope scope(this, shorthandId); 3234 ShorthandScope scope(this, shorthandId);
3236 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); 3235 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId);
3237 ASSERT(shorthand.length() == 2); 3236 ASSERT(shorthand.length() == 2);
3238 3237
3239 RefPtrWillBeRawPtr<CSSValue> startValue = parseGridPosition(); 3238 NullableCSSValue startValue = parseGridPosition();
3240 if (!startValue) 3239 if (!startValue)
3241 return false; 3240 return false;
3242 3241
3243 RefPtrWillBeRawPtr<CSSValue> endValue = nullptr; 3242 NullableCSSValue endValue;
3244 if (m_valueList->current()) { 3243 if (m_valueList->current()) {
3245 if (!isForwardSlashOperator(m_valueList->current())) 3244 if (!isForwardSlashOperator(m_valueList->current()))
3246 return false; 3245 return false;
3247 3246
3248 if (!m_valueList->next()) 3247 if (!m_valueList->next())
3249 return false; 3248 return false;
3250 3249
3251 endValue = parseGridPosition(); 3250 endValue = parseGridPosition();
3252 if (!endValue || m_valueList->current()) 3251 if (!endValue || m_valueList->current())
3253 return false; 3252 return false;
3254 } else { 3253 } else {
3255 endValue = gridMissingGridPositionValue(startValue.get()); 3254 endValue = gridMissingGridPositionValue(*startValue);
3256 } 3255 }
3257 3256
3258 addProperty(shorthand.properties()[0], startValue, important); 3257 addProperty(shorthand.properties()[0], *startValue, important);
3259 addProperty(shorthand.properties()[1], endValue, important); 3258 addProperty(shorthand.properties()[1], *endValue, important);
3260 return true; 3259 return true;
3261 } 3260 }
3262 3261
3263 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS Value> templateColumns, bool important) 3262 bool CSSPropertyParser::parseGridTemplateRowsAndAreas(NullableCSSValue templateC olumns, bool important)
3264 { 3263 {
3265 NamedGridAreaMap gridAreaMap; 3264 NamedGridAreaMap gridAreaMap;
3266 size_t rowCount = 0; 3265 size_t rowCount = 0;
3267 size_t columnCount = 0; 3266 size_t columnCount = 0;
3268 bool trailingIdentWasAdded = false; 3267 bool trailingIdentWasAdded = false;
3269 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated(); 3268 RefPtrWillBeRawPtr<CSSValueList> templateRows = CSSValueList::createSpaceSep arated();
3270 3269
3271 // At least template-areas strings must be defined. 3270 // At least template-areas strings must be defined.
3272 if (!m_valueList->current()) 3271 if (!m_valueList->current())
3273 return false; 3272 return false;
3274 3273
3275 while (m_valueList->current()) { 3274 while (m_valueList->current()) {
3276 // Handle leading <custom-ident>*. 3275 // Handle leading <custom-ident>*.
3277 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(templateRows->item(templateRows->length() - 1)) : n ullptr)) 3276 if (!parseGridLineNames(*m_valueList, *templateRows, trailingIdentWasAdd ed ? toCSSGridLineNamesValue(NullableCSSValue(templateRows->item(templateRows->l ength() - 1))) : nullptr))
3278 return false; 3277 return false;
3279 3278
3280 // Handle a template-area's row. 3279 // Handle a template-area's row.
3281 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 3280 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
3282 return false; 3281 return false;
3283 ++rowCount; 3282 ++rowCount;
3284 3283
3285 // Handle template-rows's track-size. 3284 // Handle template-rows's track-size.
3286 if (m_valueList->current() && m_valueList->current()->unit != CSSPrimiti veValue::CSS_STRING) { 3285 if (m_valueList->current() && m_valueList->current()->unit != CSSPrimiti veValue::CSS_STRING) {
3287 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 3286 NullableCSSValue value = parseGridTrackSize(*m_valueList);
3288 if (!value) 3287 if (!value)
3289 return false; 3288 return false;
3290 templateRows->append(value); 3289 templateRows->append(*value);
3291 } else { 3290 } else {
3292 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to)); 3291 templateRows->append(cssValuePool().createIdentifierValue(CSSValueAu to));
3293 } 3292 }
3294 3293
3295 // This will handle the trailing/leading <custom-ident>* in the grammar. 3294 // This will handle the trailing/leading <custom-ident>* in the grammar.
3296 if (!parseGridLineNames(*m_valueList, *templateRows)) 3295 if (!parseGridLineNames(*m_valueList, *templateRows))
3297 return false; 3296 return false;
3298 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1)-> isGridLineNamesValue(); 3297 trailingIdentWasAdded = templateRows->item(templateRows->length() - 1).i sGridLineNamesValue();
3299 } 3298 }
3300 3299
3301 // [<track-list> /]? 3300 // [<track-list> /]?
3302 if (templateColumns) 3301 if (templateColumns)
3303 addProperty(CSSPropertyGridTemplateColumns, templateColumns, important); 3302 addProperty(CSSPropertyGridTemplateColumns, *templateColumns, important) ;
3304 else 3303 else
3305 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important); 3304 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdenti fierValue(CSSValueNone), important);
3306 3305
3307 // [<line-names>? <string> [<track-size> <line-names>]? ]+ 3306 // [<line-names>? <string> [<track-size> <line-names>]? ]+
3308 RefPtrWillBeRawPtr<CSSValue> templateAreas = CSSGridTemplateAreasValue::crea te(gridAreaMap, rowCount, columnCount); 3307 CSSValue templateAreas = CSSGridTemplateAreasValue::create(gridAreaMap, rowC ount, columnCount);
3309 addProperty(CSSPropertyGridTemplateAreas, templateAreas.release(), important ); 3308 addProperty(CSSPropertyGridTemplateAreas, templateAreas, important);
3310 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important); 3309 addProperty(CSSPropertyGridTemplateRows, templateRows.release(), important);
3311 3310
3312 return true; 3311 return true;
3313 } 3312 }
3314 3313
3315 3314
3316 bool CSSPropertyParser::parseGridTemplateShorthand(bool important) 3315 bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
3317 { 3316 {
3318 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3317 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3319 3318
3320 ShorthandScope scope(this, CSSPropertyGridTemplate); 3319 ShorthandScope scope(this, CSSPropertyGridTemplate);
3321 ASSERT(gridTemplateShorthand().length() == 3); 3320 ASSERT(gridTemplateShorthand().length() == 3);
3322 3321
3323 // At least "none" must be defined. 3322 // At least "none" must be defined.
3324 if (!m_valueList->current()) 3323 if (!m_valueList->current())
3325 return false; 3324 return false;
3326 3325
3327 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone; 3326 bool firstValueIsNone = m_valueList->current()->id == CSSValueNone;
3328 3327
3329 // 1- 'none' case. 3328 // 1- 'none' case.
3330 if (firstValueIsNone && !m_valueList->next()) { 3329 if (firstValueIsNone && !m_valueList->next()) {
3331 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important); 3330 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif ierValue(CSSValueNone), important);
3332 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important); 3331 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier Value(CSSValueNone), important);
3333 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important); 3332 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie rValue(CSSValueNone), important);
3334 return true; 3333 return true;
3335 } 3334 }
3336 3335
3337 unsigned index = 0; 3336 unsigned index = 0;
3338 RefPtrWillBeRawPtr<CSSValue> columnsValue = nullptr; 3337 NullableCSSValue columnsValue;
3339 if (firstValueIsNone) { 3338 if (firstValueIsNone) {
3340 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); 3339 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone);
3341 } else { 3340 } else {
3342 columnsValue = parseGridTrackList(); 3341 columnsValue = parseGridTrackList();
3343 } 3342 }
3344 3343
3345 // 2- <grid-template-columns> / <grid-template-columns> syntax. 3344 // 2- <grid-template-columns> / <grid-template-columns> syntax.
3346 if (columnsValue) { 3345 if (columnsValue) {
3347 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next())) 3346 if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->curr ent()) && m_valueList->next()))
3348 return false; 3347 return false;
3349 index = m_valueList->currentIndex(); 3348 index = m_valueList->currentIndex();
3350 if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) { 3349 if (NullableCSSValue rowsValue = parseGridTrackList()) {
3351 if (m_valueList->current()) 3350 if (m_valueList->current())
3352 return false; 3351 return false;
3353 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important) ; 3352 addProperty(CSSPropertyGridTemplateColumns, *columnsValue, important );
3354 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); 3353 addProperty(CSSPropertyGridTemplateRows, *rowsValue, important);
3355 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important); 3354 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdent ifierValue(CSSValueNone), important);
3356 return true; 3355 return true;
3357 } 3356 }
3358 } 3357 }
3359 3358
3360 3359
3361 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax. 3360 // 3- [<track-list> /]? [<line-names>? <string> [<track-size> <line-names>]? ]+ syntax.
3362 // The template-columns <track-list> can't be 'none'. 3361 // The template-columns <track-list> can't be 'none'.
3363 if (firstValueIsNone) 3362 if (firstValueIsNone)
3364 return false; 3363 return false;
(...skipping 17 matching lines...) Expand all
3382 return true; 3381 return true;
3383 } 3382 }
3384 3383
3385 // Need to rewind parsing to explore the alternative syntax of this shorthan d. 3384 // Need to rewind parsing to explore the alternative syntax of this shorthan d.
3386 m_valueList->setCurrentIndex(0); 3385 m_valueList->setCurrentIndex(0);
3387 3386
3388 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ] 3387 // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ]
3389 if (!parseValue(CSSPropertyGridAutoFlow, important)) 3388 if (!parseValue(CSSPropertyGridAutoFlow, important))
3390 return false; 3389 return false;
3391 3390
3392 RefPtrWillBeRawPtr<CSSValue> autoColumnsValue = nullptr; 3391 NullableCSSValue autoColumnsValue;
3393 RefPtrWillBeRawPtr<CSSValue> autoRowsValue = nullptr; 3392 NullableCSSValue autoRowsValue;
3394 3393
3395 if (m_valueList->current()) { 3394 if (m_valueList->current()) {
3396 autoColumnsValue = parseGridTrackSize(*m_valueList); 3395 autoColumnsValue = parseGridTrackSize(*m_valueList);
3397 if (!autoColumnsValue) 3396 if (!autoColumnsValue)
3398 return false; 3397 return false;
3399 if (m_valueList->current()) { 3398 if (m_valueList->current()) {
3400 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next()) 3399 if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList- >next())
3401 return false; 3400 return false;
3402 autoRowsValue = parseGridTrackSize(*m_valueList); 3401 autoRowsValue = parseGridTrackSize(*m_valueList);
3403 if (!autoRowsValue) 3402 if (!autoRowsValue)
3404 return false; 3403 return false;
3405 } 3404 }
3406 if (m_valueList->current()) 3405 if (m_valueList->current())
3407 return false; 3406 return false;
3408 } else { 3407 } else {
3409 // Other omitted values are set to their initial values. 3408 // Other omitted values are set to their initial values.
3410 autoColumnsValue = cssValuePool().createImplicitInitialValue(); 3409 autoColumnsValue = cssValuePool().createImplicitInitialValue();
3411 autoRowsValue = cssValuePool().createImplicitInitialValue(); 3410 autoRowsValue = cssValuePool().createImplicitInitialValue();
3412 } 3411 }
3413 3412
3414 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns. 3413 // if <grid-auto-rows> value is omitted, it is set to the value specified fo r grid-auto-columns.
3415 if (!autoRowsValue) 3414 if (!autoRowsValue)
3416 autoRowsValue = autoColumnsValue; 3415 autoRowsValue = autoColumnsValue;
3417 3416
3418 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); 3417 addProperty(CSSPropertyGridAutoColumns, *autoColumnsValue, important);
3419 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); 3418 addProperty(CSSPropertyGridAutoRows, *autoRowsValue, important);
3420 3419
3421 // It can only be specified the explicit or the implicit grid properties in a single grid declaration. 3420 // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
3422 // The sub-properties not specified are set to their initial value, as norma l for shorthands. 3421 // The sub-properties not specified are set to their initial value, as norma l for shorthands.
3423 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important); 3422 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni tialValue(), important);
3424 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important); 3423 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia lValue(), important);
3425 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important); 3424 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti alValue(), important);
3426 3425
3427 return true; 3426 return true;
3428 } 3427 }
3429 3428
3430 bool CSSPropertyParser::parseGridAreaShorthand(bool important) 3429 bool CSSPropertyParser::parseGridAreaShorthand(bool important)
3431 { 3430 {
3432 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3431 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3433 3432
3434 ShorthandScope scope(this, CSSPropertyGridArea); 3433 ShorthandScope scope(this, CSSPropertyGridArea);
3435 const StylePropertyShorthand& shorthand = gridAreaShorthand(); 3434 const StylePropertyShorthand& shorthand = gridAreaShorthand();
3436 ASSERT_UNUSED(shorthand, shorthand.length() == 4); 3435 ASSERT_UNUSED(shorthand, shorthand.length() == 4);
3437 3436
3438 RefPtrWillBeRawPtr<CSSValue> rowStartValue = parseGridPosition(); 3437 NullableCSSValue rowStartValue = parseGridPosition();
3439 if (!rowStartValue) 3438 if (!rowStartValue)
3440 return false; 3439 return false;
3441 3440
3442 RefPtrWillBeRawPtr<CSSValue> columnStartValue = nullptr; 3441 NullableCSSValue columnStartValue;
3443 if (!parseSingleGridAreaLonghand(columnStartValue)) 3442 if (!parseSingleGridAreaLonghand(columnStartValue))
3444 return false; 3443 return false;
3445 3444
3446 RefPtrWillBeRawPtr<CSSValue> rowEndValue = nullptr; 3445 NullableCSSValue rowEndValue;
3447 if (!parseSingleGridAreaLonghand(rowEndValue)) 3446 if (!parseSingleGridAreaLonghand(rowEndValue))
3448 return false; 3447 return false;
3449 3448
3450 RefPtrWillBeRawPtr<CSSValue> columnEndValue = nullptr; 3449 NullableCSSValue columnEndValue;
3451 if (!parseSingleGridAreaLonghand(columnEndValue)) 3450 if (!parseSingleGridAreaLonghand(columnEndValue))
3452 return false; 3451 return false;
3453 3452
3454 if (!columnStartValue) 3453 if (!columnStartValue)
3455 columnStartValue = gridMissingGridPositionValue(rowStartValue.get()); 3454 columnStartValue = gridMissingGridPositionValue(*rowStartValue);
3456 3455
3457 if (!rowEndValue) 3456 if (!rowEndValue)
3458 rowEndValue = gridMissingGridPositionValue(rowStartValue.get()); 3457 rowEndValue = gridMissingGridPositionValue(*rowStartValue);
3459 3458
3460 if (!columnEndValue) 3459 if (!columnEndValue)
3461 columnEndValue = gridMissingGridPositionValue(columnStartValue.get()); 3460 columnEndValue = gridMissingGridPositionValue(*columnStartValue);
3462 3461
3463 addProperty(CSSPropertyGridRowStart, rowStartValue, important); 3462 addProperty(CSSPropertyGridRowStart, *rowStartValue, important);
3464 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); 3463 addProperty(CSSPropertyGridColumnStart, *columnStartValue, important);
3465 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); 3464 addProperty(CSSPropertyGridRowEnd, *rowEndValue, important);
3466 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); 3465 addProperty(CSSPropertyGridColumnEnd, *columnEndValue, important);
3467 return true; 3466 return true;
3468 } 3467 }
3469 3468
3470 bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtrWillBeRawPtr<CSSValue> & property) 3469 bool CSSPropertyParser::parseSingleGridAreaLonghand(NullableCSSValue& property)
3471 { 3470 {
3472 if (!m_valueList->current()) 3471 if (!m_valueList->current())
3473 return true; 3472 return true;
3474 3473
3475 if (!isForwardSlashOperator(m_valueList->current())) 3474 if (!isForwardSlashOperator(m_valueList->current()))
3476 return false; 3475 return false;
3477 3476
3478 if (!m_valueList->next()) 3477 if (!m_valueList->next())
3479 return false; 3478 return false;
3480 3479
3481 property = parseGridPosition(); 3480 property = parseGridPosition();
3482 return true; 3481 return true;
3483 } 3482 }
3484 3483
3485 static inline bool isClosingBracket(const CSSParserValue& value) 3484 static inline bool isClosingBracket(const CSSParserValue& value)
3486 { 3485 {
3487 return value.unit == CSSParserValue::Operator && value.iValue == ']'; 3486 return value.unit == CSSParserValue::Operator && value.iValue == ']';
3488 } 3487 }
3489 3488
3490 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames) 3489 bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal ueList& valueList, NullableCSSValue previousNamedAreaTrailingLineNames)
3491 { 3490 {
3492 if (!inputList.current() || inputList.current()->unit != CSSParserValue::Ope rator || inputList.current()->iValue != '[') 3491 if (!inputList.current() || inputList.current()->unit != CSSParserValue::Ope rator || inputList.current()->iValue != '[')
3493 return true; 3492 return true;
3494 3493
3495 // Skip '[' 3494 // Skip '['
3496 inputList.next(); 3495 inputList.next();
3497 3496
3498 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = previousNamedAreaTrail ingLineNames; 3497 RefPtrWillBeRawPtr<CSSGridLineNamesValue> lineNames = toCSSGridLineNamesValu e(previousNamedAreaTrailingLineNames);
3499 if (!lineNames) 3498 if (!lineNames)
3500 lineNames = CSSGridLineNamesValue::create(); 3499 lineNames = CSSGridLineNamesValue::create();
3501 3500
3502 while (CSSParserValue* identValue = inputList.current()) { 3501 while (CSSParserValue* identValue = inputList.current()) {
3503 if (isClosingBracket(*identValue)) 3502 if (isClosingBracket(*identValue))
3504 break; 3503 break;
3505 3504
3506 if (!isValidCustomIdentForGridPositions(*identValue)) 3505 if (!isValidCustomIdentForGridPositions(*identValue))
3507 return false; 3506 return false;
3508 3507
3509 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId entValue(identValue); 3508 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineName = createPrimitiveCustomId entValue(identValue);
3510 lineNames->append(lineName.release()); 3509 lineNames->append(lineName.release());
3511 inputList.next(); 3510 inputList.next();
3512 } 3511 }
3513 3512
3514 if (!inputList.current() || !isClosingBracket(*inputList.current())) 3513 if (!inputList.current() || !isClosingBracket(*inputList.current()))
3515 return false; 3514 return false;
3516 3515
3517 if (!previousNamedAreaTrailingLineNames) 3516 if (!previousNamedAreaTrailingLineNames)
3518 valueList.append(lineNames.release()); 3517 valueList.append(lineNames.release());
3519 3518
3520 // Consume ']' 3519 // Consume ']'
3521 inputList.next(); 3520 inputList.next();
3522 return true; 3521 return true;
3523 } 3522 }
3524 3523
3525 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList() 3524 NullableCSSValue CSSPropertyParser::parseGridTrackList()
3526 { 3525 {
3527 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3526 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3528 3527
3529 CSSParserValue* value = m_valueList->current(); 3528 CSSParserValue* value = m_valueList->current();
3530 if (value->id == CSSValueNone) { 3529 if (value->id == CSSValueNone) {
3531 m_valueList->next(); 3530 m_valueList->next();
3532 return cssValuePool().createIdentifierValue(CSSValueNone); 3531 return cssValuePool().createIdentifierValue(CSSValueNone);
3533 } 3532 }
3534 3533
3535 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated (); 3534 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated ();
3536 // Handle leading <custom-ident>*. 3535 // Handle leading <custom-ident>*.
3537 if (!parseGridLineNames(*m_valueList, *values)) 3536 if (!parseGridLineNames(*m_valueList, *values))
3538 return nullptr; 3537 return nullptr;
3539 3538
3540 bool seenTrackSizeOrRepeatFunction = false; 3539 bool seenTrackSizeOrRepeatFunction = false;
3541 while (CSSParserValue* currentValue = m_valueList->current()) { 3540 while (CSSParserValue* currentValue = m_valueList->current()) {
3542 if (isForwardSlashOperator(currentValue)) 3541 if (isForwardSlashOperator(currentValue))
3543 break; 3542 break;
3544 if (currentValue->unit == CSSParserValue::Function && currentValue->func tion->id == CSSValueRepeat) { 3543 if (currentValue->unit == CSSParserValue::Function && currentValue->func tion->id == CSSValueRepeat) {
3545 if (!parseGridTrackRepeatFunction(*values)) 3544 if (!parseGridTrackRepeatFunction(*values))
3546 return nullptr; 3545 return nullptr;
3547 seenTrackSizeOrRepeatFunction = true; 3546 seenTrackSizeOrRepeatFunction = true;
3548 } else { 3547 } else {
3549 RefPtrWillBeRawPtr<CSSValue> value = parseGridTrackSize(*m_valueList ); 3548 NullableCSSValue value = parseGridTrackSize(*m_valueList);
3550 if (!value) 3549 if (!value)
3551 return nullptr; 3550 return nullptr;
3552 values->append(value); 3551 values->append(*value);
3553 seenTrackSizeOrRepeatFunction = true; 3552 seenTrackSizeOrRepeatFunction = true;
3554 } 3553 }
3555 // This will handle the trailing <custom-ident>* in the grammar. 3554 // This will handle the trailing <custom-ident>* in the grammar.
3556 if (!parseGridLineNames(*m_valueList, *values)) 3555 if (!parseGridLineNames(*m_valueList, *values))
3557 return nullptr; 3556 return nullptr;
3558 } 3557 }
3559 3558
3560 // We should have found a <track-size> or else it is not a valid <track-list > 3559 // We should have found a <track-size> or else it is not a valid <track-list >
3561 if (!seenTrackSizeOrRepeatFunction) 3560 if (!seenTrackSizeOrRepeatFunction)
3562 return nullptr; 3561 return nullptr;
(...skipping 13 matching lines...) Expand all
3576 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated(); 3575 RefPtrWillBeRawPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceS eparated();
3577 arguments->next(); // Skip the repetition count. 3576 arguments->next(); // Skip the repetition count.
3578 arguments->next(); // Skip the comma. 3577 arguments->next(); // Skip the comma.
3579 3578
3580 // Handle leading <custom-ident>*. 3579 // Handle leading <custom-ident>*.
3581 if (!parseGridLineNames(*arguments, *repeatedValues)) 3580 if (!parseGridLineNames(*arguments, *repeatedValues))
3582 return false; 3581 return false;
3583 3582
3584 size_t numberOfTracks = 0; 3583 size_t numberOfTracks = 0;
3585 while (arguments->current()) { 3584 while (arguments->current()) {
3586 RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 3585 NullableCSSValue trackSize = parseGridTrackSize(*arguments);
3587 if (!trackSize) 3586 if (!trackSize)
3588 return false; 3587 return false;
3589 3588
3590 repeatedValues->append(trackSize); 3589 repeatedValues->append(*trackSize);
3591 ++numberOfTracks; 3590 ++numberOfTracks;
3592 3591
3593 // This takes care of any trailing <custom-ident>* in the grammar. 3592 // This takes care of any trailing <custom-ident>* in the grammar.
3594 if (!parseGridLineNames(*arguments, *repeatedValues)) 3593 if (!parseGridLineNames(*arguments, *repeatedValues))
3595 return false; 3594 return false;
3596 } 3595 }
3597 3596
3598 // We should have found at least one <track-size> or else it is not a valid <track-list>. 3597 // We should have found at least one <track-size> or else it is not a valid <track-list>.
3599 if (!numberOfTracks) 3598 if (!numberOfTracks)
3600 return false; 3599 return false;
3601 3600
3602 // We clamp the number of repetitions to a multiple of the repeat() track li st's size, while staying below the max 3601 // We clamp the number of repetitions to a multiple of the repeat() track li st's size, while staying below the max
3603 // grid size. 3602 // grid size.
3604 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); 3603 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks);
3605 3604
3606 for (size_t i = 0; i < repetitions; ++i) { 3605 for (size_t i = 0; i < repetitions; ++i) {
3607 for (size_t j = 0; j < repeatedValues->length(); ++j) 3606 for (size_t j = 0; j < repeatedValues->length(); ++j)
3608 list.append(repeatedValues->item(j)); 3607 list.append(repeatedValues->item(j));
3609 } 3608 }
3610 3609
3611 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue. 3610 // parseGridTrackSize iterated over the repeat arguments, move to the next v alue.
3612 m_valueList->next(); 3611 m_valueList->next();
3613 return true; 3612 return true;
3614 } 3613 }
3615 3614
3616 3615
3617 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParser ValueList& inputList) 3616 NullableCSSValue CSSPropertyParser::parseGridTrackSize(CSSParserValueList& input List)
3618 { 3617 {
3619 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3618 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3620 3619
3621 CSSParserValue* currentValue = inputList.current(); 3620 CSSParserValue* currentValue = inputList.current();
3622 inputList.next(); 3621 inputList.next();
3623 3622
3624 if (currentValue->id == CSSValueAuto) 3623 if (currentValue->id == CSSValueAuto)
3625 return cssValuePool().createIdentifierValue(CSSValueAuto); 3624 return cssValuePool().createIdentifierValue(CSSValueAuto);
3626 3625
3627 if (currentValue->unit == CSSParserValue::Function && currentValue->function ->id == CSSValueMinmax) { 3626 if (currentValue->unit == CSSParserValue::Function && currentValue->function ->id == CSSValueMinmax) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3761 3760
3762 ++gridCoordinate.rows.resolvedFinalPosition; 3761 ++gridCoordinate.rows.resolvedFinalPosition;
3763 } 3762 }
3764 currentCol = lookAheadCol; 3763 currentCol = lookAheadCol;
3765 } 3764 }
3766 3765
3767 m_valueList->next(); 3766 m_valueList->next();
3768 return true; 3767 return true;
3769 } 3768 }
3770 3769
3771 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTemplateAreas() 3770 NullableCSSValue CSSPropertyParser::parseGridTemplateAreas()
3772 { 3771 {
3773 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) { 3772 if (m_valueList->current() && m_valueList->current()->id == CSSValueNone) {
3774 m_valueList->next(); 3773 m_valueList->next();
3775 return cssValuePool().createIdentifierValue(CSSValueNone); 3774 return cssValuePool().createIdentifierValue(CSSValueNone);
3776 } 3775 }
3777 3776
3778 NamedGridAreaMap gridAreaMap; 3777 NamedGridAreaMap gridAreaMap;
3779 size_t rowCount = 0; 3778 size_t rowCount = 0;
3780 size_t columnCount = 0; 3779 size_t columnCount = 0;
3781 3780
3782 while (m_valueList->current()) { 3781 while (m_valueList->current()) {
3783 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount)) 3782 if (!parseGridTemplateAreasRow(gridAreaMap, rowCount, columnCount))
3784 return nullptr; 3783 return nullptr;
3785 ++rowCount; 3784 ++rowCount;
3786 } 3785 }
3787 3786
3788 if (!rowCount || !columnCount) 3787 if (!rowCount || !columnCount)
3789 return nullptr; 3788 return nullptr;
3790 3789
3791 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ; 3790 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount) ;
3792 } 3791 }
3793 3792
3794 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridAutoFlow(CSSParserV alueList& list) 3793 NullableCSSValue CSSPropertyParser::parseGridAutoFlow(CSSParserValueList& list)
3795 { 3794 {
3796 // [ row | column ] || dense 3795 // [ row | column ] || dense
3797 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3796 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
3798 3797
3799 CSSParserValue* value = list.current(); 3798 CSSParserValue* value = list.current();
3800 if (!value) 3799 if (!value)
3801 return nullptr; 3800 return nullptr;
3802 3801
3803 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 3802 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated();
3804 3803
(...skipping 19 matching lines...) Expand all
3824 default: 3823 default:
3825 return parsedValues; 3824 return parsedValues;
3826 } 3825 }
3827 parsedValues->append(cssValuePool().createIdentifierValue(value->id)); 3826 parsedValues->append(cssValuePool().createIdentifierValue(value->id));
3828 list.next(); 3827 list.next();
3829 } 3828 }
3830 3829
3831 return parsedValues; 3830 return parsedValues;
3832 } 3831 }
3833 3832
3834 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse rValueList* args, bool counters) 3833 NullableCSSValue CSSPropertyParser::parseCounterContent(CSSParserValueList* args , bool counters)
3835 { 3834 {
3836 unsigned numArgs = args->size(); 3835 unsigned numArgs = args->size();
3837 if (counters && numArgs != 3 && numArgs != 5) 3836 if (counters && numArgs != 3 && numArgs != 5)
3838 return nullptr; 3837 return nullptr;
3839 if (!counters && numArgs != 1 && numArgs != 3) 3838 if (!counters && numArgs != 1 && numArgs != 3)
3840 return nullptr; 3839 return nullptr;
3841 3840
3842 CSSParserValue* i = args->current(); 3841 CSSParserValue* i = args->current();
3843 if (i->unit != CSSPrimitiveValue::CSS_IDENT) 3842 if (i->unit != CSSPrimitiveValue::CSS_IDENT)
3844 return nullptr; 3843 return nullptr;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy ) 4101 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy )
4103 return false; 4102 return false;
4104 } else { 4103 } else {
4105 return false; 4104 return false;
4106 } 4105 }
4107 4106
4108 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt); 4107 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt);
4109 return !m_valueList->next(); 4108 return !m_valueList->next();
4110 } 4109 }
4111 4110
4112 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver flowPosition() 4111 NullableCSSValue CSSPropertyParser::parseContentDistributionOverflowPosition()
4113 { 4112 {
4114 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ] 4113 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ]
4115 // <baseline-position> = baseline | last-baseline; 4114 // <baseline-position> = baseline | last-baseline;
4116 // <content-distribution> = space-between | space-around | space-evenly | st retch; 4115 // <content-distribution> = space-between | space-around | space-evenly | st retch;
4117 // <content-position> = center | start | end | flex-start | flex-end | left | right; 4116 // <content-position> = center | start | end | flex-start | flex-end | left | right;
4118 // <overflow-position> = true | safe 4117 // <overflow-position> = true | safe
4119 4118
4120 // auto | <baseline-position> 4119 // auto | <baseline-position>
4121 CSSParserValue* value = m_valueList->current(); 4120 CSSParserValue* value = m_valueList->current();
4122 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) { 4121 if (value->id == CSSValueAuto || isBaselinePositionKeyword(value->id)) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4241 if (!args->currentIndex() && argument->id != CSSValueAt) { 4240 if (!args->currentIndex() && argument->id != CSSValueAt) {
4242 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius( argument)) { 4241 if (RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = parseShapeRadius( argument)) {
4243 shape->setRadius(radius); 4242 shape->setRadius(radius);
4244 continue; 4243 continue;
4245 } 4244 }
4246 4245
4247 return nullptr; 4246 return nullptr;
4248 } 4247 }
4249 4248
4250 if (argument->id == CSSValueAt && args->next()) { 4249 if (argument->id == CSSValueAt && args->next()) {
4251 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4250 NullableCSSValue centerX;
4252 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4251 NullableCSSValue centerY;
4253 parseFillPosition(args, centerX, centerY); 4252 parseFillPosition(args, centerX, centerY);
4254 if (centerX && centerY && !args->current()) { 4253 if (centerX && centerY && !args->current()) {
4255 ASSERT(centerX->isPrimitiveValue()); 4254 ASSERT(centerX->isPrimitiveValue());
4256 ASSERT(centerY->isPrimitiveValue()); 4255 ASSERT(centerY->isPrimitiveValue());
4257 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); 4256 shape->setCenterX(toCSSPrimitiveValue(centerX));
4258 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); 4257 shape->setCenterY(toCSSPrimitiveValue(centerY));
4259 } else { 4258 } else {
4260 return nullptr; 4259 return nullptr;
4261 } 4260 }
4262 } else { 4261 } else {
4263 return nullptr; 4262 return nullptr;
4264 } 4263 }
4265 } 4264 }
4266 4265
4267 return shape; 4266 return shape;
4268 } 4267 }
(...skipping 24 matching lines...) Expand all
4293 else 4292 else
4294 shape->setRadiusY(radius); 4293 shape->setRadiusY(radius);
4295 continue; 4294 continue;
4296 } 4295 }
4297 4296
4298 return nullptr; 4297 return nullptr;
4299 } 4298 }
4300 4299
4301 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>) 4300 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>)
4302 return nullptr; 4301 return nullptr;
4303 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4302 NullableCSSValue centerX;
4304 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4303 NullableCSSValue centerY;
4305 parseFillPosition(args, centerX, centerY); 4304 parseFillPosition(args, centerX, centerY);
4306 if (!centerX || !centerY || args->current()) 4305 if (!centerX || !centerY || args->current())
4307 return nullptr; 4306 return nullptr;
4308 4307
4309 ASSERT(centerX->isPrimitiveValue()); 4308 ASSERT(centerX->isPrimitiveValue());
4310 ASSERT(centerY->isPrimitiveValue()); 4309 ASSERT(centerY->isPrimitiveValue());
4311 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); 4310 shape->setCenterX(toCSSPrimitiveValue(centerX));
4312 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); 4311 shape->setCenterY(toCSSPrimitiveValue(centerY));
4313 } 4312 }
4314 4313
4315 return shape; 4314 return shape;
4316 } 4315 }
4317 4316
4318 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args) 4317 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args)
4319 { 4318 {
4320 ASSERT(args); 4319 ASSERT(args);
4321 4320
4322 unsigned size = args->size(); 4321 unsigned size = args->size();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4370 case CSSValueBorderBox: 4369 case CSSValueBorderBox:
4371 case CSSValueMarginBox: 4370 case CSSValueMarginBox:
4372 return true; 4371 return true;
4373 default: 4372 default:
4374 break; 4373 break;
4375 } 4374 }
4376 4375
4377 return false; 4376 return false;
4378 } 4377 }
4379 4378
4380 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper tyID propId) 4379 NullableCSSValue CSSPropertyParser::parseShapeProperty(CSSPropertyID propId)
4381 { 4380 {
4382 RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr; 4381 NullableCSSValue imageValue;
4383 if (parseFillImage(m_valueList, imageValue)) { 4382 if (parseFillImage(m_valueList, imageValue)) {
4384 m_valueList->next(); 4383 m_valueList->next();
4385 return imageValue.release(); 4384 return imageValue;
4386 } 4385 }
4387 4386
4388 return parseBasicShapeAndOrBox(); 4387 return parseBasicShapeAndOrBox();
4389 } 4388 }
4390 4389
4391 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBasicShapeAndOrBox() 4390 NullableCSSValue CSSPropertyParser::parseBasicShapeAndOrBox()
4392 { 4391 {
4393 CSSParserValue* value = m_valueList->current(); 4392 CSSParserValue* value = m_valueList->current();
4394 4393
4395 bool shapeFound = false; 4394 bool shapeFound = false;
4396 bool boxFound = false; 4395 bool boxFound = false;
4397 CSSValueID valueId; 4396 CSSValueID valueId;
4398 4397
4399 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 4398 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
4400 for (unsigned i = 0; i < 2; ++i) { 4399 for (unsigned i = 0; i < 2; ++i) {
4401 if (!value) 4400 if (!value)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4513 return false; 4512 return false;
4514 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight(); 4513 RefPtrWillBeRawPtr<CSSPrimitiveValue> lineHeight = parseLineHeight();
4515 if (!lineHeight) 4514 if (!lineHeight)
4516 return false; 4515 return false;
4517 addProperty(CSSPropertyLineHeight, lineHeight.release(), important); 4516 addProperty(CSSPropertyLineHeight, lineHeight.release(), important);
4518 } else { 4517 } else {
4519 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true); 4518 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue( CSSValueNormal), important, true);
4520 } 4519 }
4521 4520
4522 // Font family must come now. 4521 // Font family must come now.
4523 RefPtrWillBeRawPtr<CSSValue> parsedFamilyValue = parseFontFamily(); 4522 NullableCSSValue parsedFamilyValue = parseFontFamily();
4524 if (!parsedFamilyValue) 4523 if (!parsedFamilyValue)
4525 return false; 4524 return false;
4526 4525
4527 addProperty(CSSPropertyFontFamily, parsedFamilyValue.release(), important); 4526 addProperty(CSSPropertyFontFamily, *parsedFamilyValue, important);
4528 4527
4529 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir es that 4528 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir es that
4530 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values 4529 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their initial values
4531 // but we don't seem to support them at the moment. They should also be adde d here once implemented. 4530 // but we don't seem to support them at the moment. They should also be adde d here once implemented.
4532 if (m_valueList->current()) 4531 if (m_valueList->current())
4533 return false; 4532 return false;
4534 4533
4535 return true; 4534 return true;
4536 } 4535 }
4537 4536
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 5224
5226 if (context.allowBreak) { 5225 if (context.allowBreak) {
5227 context.commitValue(); 5226 context.commitValue();
5228 if (context.values && context.values->length()) 5227 if (context.values && context.values->length())
5229 return context.values.release(); 5228 return context.values.release();
5230 } 5229 }
5231 5230
5232 return nullptr; 5231 return nullptr;
5233 } 5232 }
5234 5233
5235 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect() 5234 NullableCSSValue CSSPropertyParser::parseReflect()
5236 { 5235 {
5237 // box-reflect: <direction> <offset> <mask> 5236 // box-reflect: <direction> <offset> <mask>
5238 5237
5239 // Direction comes first. 5238 // Direction comes first.
5240 CSSParserValue* val = m_valueList->current(); 5239 CSSParserValue* val = m_valueList->current();
5241 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr; 5240 RefPtrWillBeRawPtr<CSSPrimitiveValue> direction = nullptr;
5242 switch (val->id) { 5241 switch (val->id) {
5243 case CSSValueAbove: 5242 case CSSValueAbove:
5244 case CSSValueBelow: 5243 case CSSValueBelow:
5245 case CSSValueLeft: 5244 case CSSValueLeft:
5246 case CSSValueRight: 5245 case CSSValueRight:
5247 direction = cssValuePool().createIdentifierValue(val->id); 5246 direction = cssValuePool().createIdentifierValue(val->id);
5248 break; 5247 break;
5249 default: 5248 default:
5250 return nullptr; 5249 return nullptr;
5251 } 5250 }
5252 5251
5253 // The offset comes next. 5252 // The offset comes next.
5254 val = m_valueList->next(); 5253 val = m_valueList->next();
5255 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr; 5254 RefPtrWillBeRawPtr<CSSPrimitiveValue> offset = nullptr;
5256 if (!val) 5255 if (!val)
5257 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); 5256 offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
5258 else { 5257 else {
5259 if (!validUnit(val, FLength | FPercent)) 5258 if (!validUnit(val, FLength | FPercent))
5260 return nullptr; 5259 return nullptr;
5261 offset = createPrimitiveNumericValue(val); 5260 offset = createPrimitiveNumericValue(val);
5262 } 5261 }
5263 5262
5264 // Now for the mask. 5263 // Now for the mask.
5265 RefPtrWillBeRawPtr<CSSValue> mask = nullptr; 5264 NullableCSSValue mask;
5266 val = m_valueList->next(); 5265 val = m_valueList->next();
5267 if (val) { 5266 if (val) {
5268 mask = parseBorderImage(CSSPropertyWebkitBoxReflect); 5267 mask = parseBorderImage(CSSPropertyWebkitBoxReflect);
5269 if (!mask) 5268 if (!mask)
5270 return nullptr; 5269 return nullptr;
5271 } 5270 }
5272 5271
5273 return CSSReflectValue::create(direction.release(), offset.release(), mask.r elease()); 5272 return CSSReflectValue::create(direction.get(), offset.get(), mask);
5274 } 5273 }
5275 5274
5276 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse tValue, int argSize) 5275 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unse tValue, int argSize)
5277 { 5276 {
5278 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3; 5277 return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3;
5279 } 5278 }
5280 5279
5281 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important) 5280 bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important)
5282 { 5281 {
5283 if (!args || !args->size() || args->size() > 3) 5282 if (!args || !args->size() || args->size() > 3)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 flexShrink = 1; 5314 flexShrink = 1;
5316 if (!flexBasis) 5315 if (!flexBasis)
5317 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT AGE); 5316 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENT AGE);
5318 5317
5319 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f lexGrow), CSSPrimitiveValue::CSS_NUMBER), important); 5318 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f lexGrow), CSSPrimitiveValue::CSS_NUMBER), important);
5320 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float> (flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); 5319 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float> (flexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
5321 addProperty(CSSPropertyFlexBasis, flexBasis, important); 5320 addProperty(CSSPropertyFlexBasis, flexBasis, important);
5322 return true; 5321 return true;
5323 } 5322 }
5324 5323
5325 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue List* valueList) 5324 NullableCSSValue CSSPropertyParser::parsePosition(CSSParserValueList* valueList)
5326 { 5325 {
5327 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 5326 NullableCSSValue xValue;
5328 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 5327 NullableCSSValue yValue;
5329 parseFillPosition(valueList, xValue, yValue); 5328 parseFillPosition(valueList, xValue, yValue);
5329
5330 if (!xValue || !yValue) 5330 if (!xValue || !yValue)
5331 return nullptr; 5331 return nullptr;
5332 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim itiveValue(yValue.get()), Pair::KeepIdenticalValues); 5332 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue), toCSSPrimitiveV alue(yValue), Pair::KeepIdenticalValues);
5333 } 5333 }
5334 5334
5335 // Parses a list of comma separated positions. i.e., <position># 5335 // Parses a list of comma separated positions. i.e., <position>#
5336 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar serValueList* valueList) 5336 NullableCSSValue CSSPropertyParser::parsePositionList(CSSParserValueList* valueL ist)
5337 { 5337 {
5338 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted(); 5338 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted();
5339 while (true) { 5339 while (true) {
5340 // parsePosition consumes values until it reaches a separator [,/], 5340 // parsePosition consumes values until it reaches a separator [,/],
5341 // an invalid token, or end of the list 5341 // an invalid token, or end of the list
5342 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); 5342 NullableCSSValue position = parsePosition(valueList);
5343 if (!position) 5343 if (!position)
5344 return nullptr; 5344 return nullptr;
5345 positions->append(position); 5345 positions->append(*position);
5346 5346
5347 if (!valueList->current()) 5347 if (!valueList->current())
5348 break; 5348 break;
5349 if (!consumeComma(valueList) || !valueList->current()) 5349 if (!consumeComma(valueList) || !valueList->current())
5350 return nullptr; 5350 return nullptr;
5351 } 5351 }
5352 5352
5353 return positions.release(); 5353 return positions.release();
5354 } 5354 }
5355 5355
(...skipping 16 matching lines...) Expand all
5372 5372
5373 bool allowCommit() const { return m_allowCommit; } 5373 bool allowCommit() const { return m_allowCommit; }
5374 bool allowImage() const { return m_allowImage; } 5374 bool allowImage() const { return m_allowImage; }
5375 bool allowImageSlice() const { return m_allowImageSlice; } 5375 bool allowImageSlice() const { return m_allowImageSlice; }
5376 bool allowRepeat() const { return m_allowRepeat; } 5376 bool allowRepeat() const { return m_allowRepeat; }
5377 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; } 5377 bool allowForwardSlashOperator() const { return m_allowForwardSlashOperator; }
5378 5378
5379 bool allowWidth() const { return m_allowWidth; } 5379 bool allowWidth() const { return m_allowWidth; }
5380 bool requireOutset() const { return m_requireOutset; } 5380 bool requireOutset() const { return m_requireOutset; }
5381 5381
5382 void commitImage(PassRefPtrWillBeRawPtr<CSSValue> image) 5382 void commitImage(CSSValue image)
5383 { 5383 {
5384 m_image = image; 5384 m_image = image;
5385 m_canAdvance = true; 5385 m_canAdvance = true;
5386 m_allowCommit = true; 5386 m_allowCommit = true;
5387 m_allowImage = false; 5387 m_allowImage = false;
5388 m_allowForwardSlashOperator = false; 5388 m_allowForwardSlashOperator = false;
5389 m_allowWidth = false; 5389 m_allowWidth = false;
5390 m_requireOutset = false; 5390 m_requireOutset = false;
5391 m_allowImageSlice = !m_imageSlice; 5391 m_allowImageSlice = !m_imageSlice;
5392 m_allowRepeat = !m_repeat; 5392 m_allowRepeat = !m_repeat;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 m_outset = outset; 5437 m_outset = outset;
5438 m_canAdvance = true; 5438 m_canAdvance = true;
5439 m_allowCommit = true; 5439 m_allowCommit = true;
5440 m_allowImageSlice = false; 5440 m_allowImageSlice = false;
5441 m_allowForwardSlashOperator = false; 5441 m_allowForwardSlashOperator = false;
5442 m_allowWidth = false; 5442 m_allowWidth = false;
5443 m_requireOutset = false; 5443 m_requireOutset = false;
5444 m_allowImage = !m_image; 5444 m_allowImage = !m_image;
5445 m_allowRepeat = !m_repeat; 5445 m_allowRepeat = !m_repeat;
5446 } 5446 }
5447 void commitRepeat(PassRefPtrWillBeRawPtr<CSSValue> repeat) 5447 void commitRepeat(CSSValue repeat)
5448 { 5448 {
5449 m_repeat = repeat; 5449 m_repeat = repeat;
5450 m_canAdvance = true; 5450 m_canAdvance = true;
5451 m_allowCommit = true; 5451 m_allowCommit = true;
5452 m_allowRepeat = false; 5452 m_allowRepeat = false;
5453 m_allowForwardSlashOperator = false; 5453 m_allowForwardSlashOperator = false;
5454 m_allowWidth = false; 5454 m_allowWidth = false;
5455 m_requireOutset = false; 5455 m_requireOutset = false;
5456 m_allowImageSlice = !m_imageSlice; 5456 m_allowImageSlice = !m_imageSlice;
5457 m_allowImage = !m_image; 5457 m_allowImage = !m_image;
5458 } 5458 }
5459 5459
5460 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() 5460 CSSValue commitCSSValue()
5461 { 5461 {
5462 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat.get()); 5462 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat);
5463 } 5463 }
5464 5464
5465 bool m_canAdvance; 5465 bool m_canAdvance;
5466 5466
5467 bool m_allowCommit; 5467 bool m_allowCommit;
5468 bool m_allowImage; 5468 bool m_allowImage;
5469 bool m_allowImageSlice; 5469 bool m_allowImageSlice;
5470 bool m_allowRepeat; 5470 bool m_allowRepeat;
5471 bool m_allowForwardSlashOperator; 5471 bool m_allowForwardSlashOperator;
5472 5472
5473 bool m_allowWidth; 5473 bool m_allowWidth;
5474 bool m_requireOutset; 5474 bool m_requireOutset;
5475 5475
5476 RefPtrWillBeMember<CSSValue> m_image; 5476 NullableCSSValue m_image;
5477 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; 5477 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice;
5478 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; 5478 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth;
5479 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; 5479 RefPtrWillBeMember<CSSPrimitiveValue> m_outset;
5480 5480
5481 RefPtrWillBeMember<CSSValue> m_repeat; 5481 NullableCSSValue m_repeat;
5482 }; 5482 };
5483 5483
5484 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context) 5484 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context)
5485 { 5485 {
5486 CSSPropertyParser::ShorthandScope scope(this, propId); 5486 CSSPropertyParser::ShorthandScope scope(this, propId);
5487 while (CSSParserValue* val = m_valueList->current()) { 5487 while (CSSParserValue* val = m_valueList->current()) {
5488 context.setCanAdvance(false); 5488 context.setCanAdvance(false);
5489 5489
5490 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val)) 5490 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val))
5491 context.commitForwardSlashOperator(); 5491 context.commitForwardSlashOperator();
5492 5492
5493 if (!context.canAdvance() && context.allowImage()) { 5493 if (!context.canAdvance() && context.allowImage()) {
5494 if (val->unit == CSSPrimitiveValue::CSS_URI) { 5494 if (val->unit == CSSPrimitiveValue::CSS_URI) {
5495 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string))); 5495 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string)));
5496 } else if (isGeneratedImageValue(val)) { 5496 } else if (isGeneratedImageValue(val)) {
5497 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 5497 NullableCSSValue value;
5498 if (parseGeneratedImage(m_valueList, value)) 5498 if (parseGeneratedImage(m_valueList, value))
5499 context.commitImage(value.release()); 5499 context.commitImage(*value);
5500 else 5500 else
5501 return false; 5501 return false;
5502 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) { 5502 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) {
5503 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); 5503 NullableCSSValue value = parseImageSet(m_valueList);
5504 if (value) 5504 if (value)
5505 context.commitImage(value.release()); 5505 context.commitImage(*value);
5506 else 5506 else
5507 return false; 5507 return false;
5508 } else if (val->id == CSSValueNone) 5508 } else if (val->id == CSSValueNone)
5509 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone)); 5509 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone));
5510 } 5510 }
5511 5511
5512 if (!context.canAdvance() && context.allowImageSlice()) { 5512 if (!context.canAdvance() && context.allowImageSlice()) {
5513 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; 5513 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr;
5514 if (parseBorderImageSlice(propId, imageSlice)) 5514 if (parseBorderImageSlice(propId, imageSlice))
5515 context.commitImageSlice(imageSlice.release()); 5515 context.commitImageSlice(imageSlice.release());
5516 } 5516 }
5517 5517
5518 if (!context.canAdvance() && context.allowRepeat()) { 5518 if (!context.canAdvance() && context.allowRepeat()) {
5519 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; 5519 NullableCSSValue repeat;
5520 if (parseBorderImageRepeat(repeat)) 5520 if (parseBorderImageRepeat(repeat))
5521 context.commitRepeat(repeat.release()); 5521 context.commitRepeat(*repeat);
5522 } 5522 }
5523 5523
5524 if (!context.canAdvance() && context.allowWidth()) { 5524 if (!context.canAdvance() && context.allowWidth()) {
5525 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; 5525 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr;
5526 if (parseBorderImageWidth(borderWidth)) 5526 if (parseBorderImageWidth(borderWidth))
5527 context.commitBorderWidth(borderWidth.release()); 5527 context.commitBorderWidth(borderWidth.release());
5528 } 5528 }
5529 5529
5530 if (!context.canAdvance() && context.requireOutset()) { 5530 if (!context.canAdvance() && context.requireOutset()) {
5531 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; 5531 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr;
5532 if (parseBorderImageOutset(borderOutset)) 5532 if (parseBorderImageOutset(borderOutset))
5533 context.commitBorderOutset(borderOutset.release()); 5533 context.commitBorderOutset(borderOutset.release());
5534 } 5534 }
5535 5535
5536 if (!context.canAdvance()) 5536 if (!context.canAdvance())
5537 return false; 5537 return false;
5538 5538
5539 m_valueList->next(); 5539 m_valueList->next();
5540 } 5540 }
5541 5541
5542 return context.allowCommit(); 5542 return context.allowCommit();
5543 } 5543 }
5544 5544
5545 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) 5545 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, Nullable CSSValue value, bool important)
5546 { 5546 {
5547 if (value) 5547 if (value)
5548 addProperty(propId, value, important); 5548 addProperty(propId, *value, important);
5549 else 5549 else
5550 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true); 5550 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true);
5551 } 5551 }
5552 5552
5553 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant) 5553 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant)
5554 { 5554 {
5555 BorderImageParseContext context; 5555 BorderImageParseContext context;
5556 if (buildBorderImageParseContext(propId, context)) { 5556 if (buildBorderImageParseContext(propId, context)) {
5557 switch (propId) { 5557 switch (propId) {
5558 case CSSPropertyWebkitMaskBoxImage: 5558 case CSSPropertyWebkitMaskBoxImage:
5559 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important); 5559 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important);
5560 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important); 5560 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important);
5561 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important); 5561 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important);
5562 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important); 5562 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important);
5563 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat.get(), important); 5563 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat, important);
5564 return true; 5564 return true;
5565 case CSSPropertyBorderImage: 5565 case CSSPropertyBorderImage:
5566 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important); 5566 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important);
5567 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important); 5567 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important);
5568 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important); 5568 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important);
5569 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important); 5569 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important);
5570 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important); 5570 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important);
5571 return true; 5571 return true;
5572 default: 5572 default:
5573 ASSERT_NOT_REACHED(); 5573 ASSERT_NOT_REACHED();
5574 return false; 5574 return false;
5575 } 5575 }
5576 } 5576 }
5577 return false; 5577 return false;
5578 } 5578 }
5579 5579
5580 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty ID propId) 5580 NullableCSSValue CSSPropertyParser::parseBorderImage(CSSPropertyID propId)
5581 { 5581 {
5582 BorderImageParseContext context; 5582 BorderImageParseContext context;
5583 if (buildBorderImageParseContext(propId, context)) { 5583 if (buildBorderImageParseContext(propId, context)) {
5584 return context.commitCSSValue(); 5584 return context.commitCSSValue();
5585 } 5585 }
5586 return nullptr; 5586 return nullptr;
5587 } 5587 }
5588 5588
5589 static bool isBorderImageRepeatKeyword(int id) 5589 static bool isBorderImageRepeatKeyword(int id)
5590 { 5590 {
5591 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound; 5591 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound;
5592 } 5592 }
5593 5593
5594 bool CSSPropertyParser::parseBorderImageRepeat(RefPtrWillBeRawPtr<CSSValue>& res ult) 5594 bool CSSPropertyParser::parseBorderImageRepeat(NullableCSSValue& result)
5595 { 5595 {
5596 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr; 5596 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstValue = nullptr;
5597 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr; 5597 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondValue = nullptr;
5598 CSSParserValue* val = m_valueList->current(); 5598 CSSParserValue* val = m_valueList->current();
5599 if (!val) 5599 if (!val)
5600 return false; 5600 return false;
5601 if (isBorderImageRepeatKeyword(val->id)) 5601 if (isBorderImageRepeatKeyword(val->id))
5602 firstValue = cssValuePool().createIdentifierValue(val->id); 5602 firstValue = cssValuePool().createIdentifierValue(val->id);
5603 else 5603 else
5604 return false; 5604 return false;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
5893 completeBorderRadii(radii[1]); 5893 completeBorderRadii(radii[1]);
5894 5894
5895 ImplicitScope implicitScope(this); 5895 ImplicitScope implicitScope(this);
5896 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important); 5896 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important);
5897 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important); 5897 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important);
5898 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important); 5898 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important);
5899 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important); 5899 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important);
5900 return true; 5900 return true;
5901 } 5901 }
5902 5902
5903 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu e) 5903 NullableCSSValue CSSPropertyParser::parseCounter(int defaultValue)
5904 { 5904 {
5905 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 5905 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
5906 5906
5907 while (m_valueList->current()) { 5907 while (m_valueList->current()) {
5908 CSSParserValue* val = m_valueList->current(); 5908 CSSParserValue* val = m_valueList->current();
5909 if (val->unit != CSSPrimitiveValue::CSS_IDENT) 5909 if (val->unit != CSSPrimitiveValue::CSS_IDENT)
5910 return nullptr; 5910 return nullptr;
5911 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val); 5911 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val);
5912 m_valueList->next(); 5912 m_valueList->next();
5913 5913
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
6002 stop.m_color = cssValuePool().createIdentifierValue(id); 6002 stop.m_color = cssValuePool().createIdentifierValue(id);
6003 else 6003 else
6004 stop.m_color = parseColor(stopArg); 6004 stop.m_color = parseColor(stopArg);
6005 if (!stop.m_color) 6005 if (!stop.m_color)
6006 return false; 6006 return false;
6007 } 6007 }
6008 6008
6009 return true; 6009 return true;
6010 } 6010 }
6011 6011
6012 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R efPtrWillBeRawPtr<CSSValue>& gradient) 6012 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, N ullableCSSValue& gradient)
6013 { 6013 {
6014 // Walk the arguments. 6014 // Walk the arguments.
6015 CSSParserValueList* args = valueList->current()->function->args.get(); 6015 CSSParserValueList* args = valueList->current()->function->args.get();
6016 if (!args || args->size() == 0) 6016 if (!args || args->size() == 0)
6017 return false; 6017 return false;
6018 6018
6019 // The first argument is the gradient type. It is an identifier. 6019 // The first argument is the gradient type. It is an identifier.
6020 CSSGradientType gradientType; 6020 CSSGradientType gradientType;
6021 CSSParserValue* a = args->current(); 6021 CSSParserValue* a = args->current();
6022 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT) 6022 if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6155 case CSSValueTop: 6155 case CSSValueTop:
6156 case CSSValueBottom: 6156 case CSSValueBottom:
6157 isHorizontal = false; 6157 isHorizontal = false;
6158 break; 6158 break;
6159 default: 6159 default:
6160 return nullptr; 6160 return nullptr;
6161 } 6161 }
6162 return cssValuePool().createIdentifierValue(a->id); 6162 return cssValuePool().createIdentifierValue(a->id);
6163 } 6163 }
6164 6164
6165 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6165 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, NullableCSSValue& gradient, CSSGradientRepeat repeating)
6166 { 6166 {
6167 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient); 6167 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient);
6168 6168
6169 // Walk the arguments. 6169 // Walk the arguments.
6170 CSSParserValueList* args = valueList->current()->function->args.get(); 6170 CSSParserValueList* args = valueList->current()->function->args.get();
6171 if (!args || !args->size()) 6171 if (!args || !args->size())
6172 return false; 6172 return false;
6173 6173
6174 CSSParserValue* a = args->current(); 6174 CSSParserValue* a = args->current();
6175 if (!a) 6175 if (!a)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6225 if (!parseGradientColorStops(args, result.get(), expectComma)) 6225 if (!parseGradientColorStops(args, result.get(), expectComma))
6226 return false; 6226 return false;
6227 6227
6228 if (!result->stopCount()) 6228 if (!result->stopCount())
6229 return false; 6229 return false;
6230 6230
6231 gradient = result.release(); 6231 gradient = result.release();
6232 return true; 6232 return true;
6233 } 6233 }
6234 6234
6235 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6235 bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL ist, NullableCSSValue& gradient, CSSGradientRepeat repeating)
6236 { 6236 {
6237 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSPrefixedRadialGradient); 6237 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSPrefixedRadialGradient);
6238 6238
6239 // Walk the arguments. 6239 // Walk the arguments.
6240 CSSParserValueList* args = valueList->current()->function->args.get(); 6240 CSSParserValueList* args = valueList->current()->function->args.get();
6241 if (!args || !args->size()) 6241 if (!args || !args->size())
6242 return false; 6242 return false;
6243 6243
6244 CSSParserValue* a = args->current(); 6244 CSSParserValue* a = args->current();
6245 if (!a) 6245 if (!a)
6246 return false; 6246 return false;
6247 6247
6248 bool expectComma = false; 6248 bool expectComma = false;
6249 6249
6250 // Optional background-position 6250 // Optional background-position
6251 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 6251 NullableCSSValue centerX;
6252 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 6252 NullableCSSValue centerY;
6253 // parse2ValuesFillPosition advances the args next pointer. 6253 // parse2ValuesFillPosition advances the args next pointer.
6254 parse2ValuesFillPosition(args, centerX, centerY); 6254 parse2ValuesFillPosition(args, centerX, centerY);
6255 6255
6256 if ((centerX || centerY) && !consumeComma(args)) 6256 if ((centerX || centerY) && !consumeComma(args))
6257 return false; 6257 return false;
6258 6258
6259 a = args->current(); 6259 a = args->current();
6260 if (!a) 6260 if (!a)
6261 return false; 6261 return false;
6262 6262
6263 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6263 result->setFirstX(toCSSPrimitiveValue(centerX));
6264 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6264 result->setSecondX(toCSSPrimitiveValue(centerX));
6265 // CSS3 radial gradients always share the same start and end point. 6265 // CSS3 radial gradients always share the same start and end point.
6266 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6266 result->setFirstY(toCSSPrimitiveValue(centerY));
6267 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6267 result->setSecondY(toCSSPrimitiveValue(centerY));
6268 6268
6269 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr; 6269 RefPtrWillBeRawPtr<CSSPrimitiveValue> shapeValue = nullptr;
6270 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr; 6270 RefPtrWillBeRawPtr<CSSPrimitiveValue> sizeValue = nullptr;
6271 6271
6272 // Optional shape and/or size in any order. 6272 // Optional shape and/or size in any order.
6273 for (int i = 0; i < 2; ++i) { 6273 for (int i = 0; i < 2; ++i) {
6274 if (a->unit != CSSPrimitiveValue::CSS_IDENT) 6274 if (a->unit != CSSPrimitiveValue::CSS_IDENT)
6275 break; 6275 break;
6276 6276
6277 bool foundValue = false; 6277 bool foundValue = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6337 result->setEndHorizontalSize(horizontalSize); 6337 result->setEndHorizontalSize(horizontalSize);
6338 result->setEndVerticalSize(verticalSize); 6338 result->setEndVerticalSize(verticalSize);
6339 6339
6340 if (!parseGradientColorStops(args, result.get(), expectComma)) 6340 if (!parseGradientColorStops(args, result.get(), expectComma))
6341 return false; 6341 return false;
6342 6342
6343 gradient = result.release(); 6343 gradient = result.release();
6344 return true; 6344 return true;
6345 } 6345 }
6346 6346
6347 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6347 bool CSSPropertyParser::parseLinearGradient(CSSParserValueList* valueList, Nulla bleCSSValue& gradient, CSSGradientRepeat repeating)
6348 { 6348 {
6349 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSLinearGradient); 6349 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSLinearGradient);
6350 6350
6351 CSSParserFunction* function = valueList->current()->function; 6351 CSSParserFunction* function = valueList->current()->function;
6352 CSSParserValueList* args = function->args.get(); 6352 CSSParserValueList* args = function->args.get();
6353 if (!args || !args->size()) 6353 if (!args || !args->size())
6354 return false; 6354 return false;
6355 6355
6356 CSSParserValue* a = args->current(); 6356 CSSParserValue* a = args->current();
6357 if (!a) 6357 if (!a)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6411 if (!parseGradientColorStops(args, result.get(), expectComma)) 6411 if (!parseGradientColorStops(args, result.get(), expectComma))
6412 return false; 6412 return false;
6413 6413
6414 if (!result->stopCount()) 6414 if (!result->stopCount())
6415 return false; 6415 return false;
6416 6416
6417 gradient = result.release(); 6417 gradient = result.release();
6418 return true; 6418 return true;
6419 } 6419 }
6420 6420
6421 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) 6421 bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, Nulla bleCSSValue& gradient, CSSGradientRepeat repeating)
6422 { 6422 {
6423 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSRadialGradient); 6423 RefPtrWillBeRawPtr<CSSRadialGradientValue> result = CSSRadialGradientValue:: create(repeating, CSSRadialGradient);
6424 6424
6425 CSSParserValueList* args = valueList->current()->function->args.get(); 6425 CSSParserValueList* args = valueList->current()->function->args.get();
6426 if (!args || !args->size()) 6426 if (!args || !args->size())
6427 return false; 6427 return false;
6428 6428
6429 CSSParserValue* a = args->current(); 6429 CSSParserValue* a = args->current();
6430 if (!a) 6430 if (!a)
6431 return false; 6431 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
6503 if (!verticalSize && horizontalSize && horizontalSize->isPercentage()) 6503 if (!verticalSize && horizontalSize && horizontalSize->isPercentage())
6504 return false; 6504 return false;
6505 6505
6506 result->setShape(shapeValue); 6506 result->setShape(shapeValue);
6507 result->setSizingBehavior(sizeValue); 6507 result->setSizingBehavior(sizeValue);
6508 result->setEndHorizontalSize(horizontalSize); 6508 result->setEndHorizontalSize(horizontalSize);
6509 result->setEndVerticalSize(verticalSize); 6509 result->setEndVerticalSize(verticalSize);
6510 6510
6511 // Second part of grammar, the center-position clause: 6511 // Second part of grammar, the center-position clause:
6512 // at <position> 6512 // at <position>
6513 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 6513 NullableCSSValue centerX;
6514 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 6514 NullableCSSValue centerY;
6515 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) { 6515 if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) {
6516 a = args->next(); 6516 a = args->next();
6517 if (!a) 6517 if (!a)
6518 return false; 6518 return false;
6519 6519
6520 parseFillPosition(args, centerX, centerY); 6520 parseFillPosition(args, centerX, centerY);
6521 if (!(centerX && centerY)) 6521 if (!(centerX && centerY))
6522 return false; 6522 return false;
6523 6523
6524 a = args->current(); 6524 a = args->current();
6525 if (!a) 6525 if (!a)
6526 return false; 6526 return false;
6527 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6527 result->setFirstX(toCSSPrimitiveValue(centerX));
6528 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6528 result->setFirstY(toCSSPrimitiveValue(centerY));
6529 // Right now, CSS radial gradients have the same start and end centers. 6529 // Right now, CSS radial gradients have the same start and end centers.
6530 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6530 result->setSecondX(toCSSPrimitiveValue(centerX));
6531 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6531 result->setSecondY(toCSSPrimitiveValue(centerY));
6532 } 6532 }
6533 6533
6534 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) 6534 if (shapeValue || sizeValue || horizontalSize || centerX || centerY)
6535 expectComma = true; 6535 expectComma = true;
6536 6536
6537 if (!parseGradientColorStops(args, result.get(), expectComma)) 6537 if (!parseGradientColorStops(args, result.get(), expectComma))
6538 return false; 6538 return false;
6539 6539
6540 gradient = result.release(); 6540 gradient = result.release();
6541 return true; 6541 return true;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
6596 } 6596 }
6597 6597
6598 // The last color stop cannot be a color hint. 6598 // The last color stop cannot be a color hint.
6599 if (previousStopWasColorHint) 6599 if (previousStopWasColorHint)
6600 return false; 6600 return false;
6601 6601
6602 // Must have 2 or more stops to be valid. 6602 // Must have 2 or more stops to be valid.
6603 return gradient->stopCount() >= 2; 6603 return gradient->stopCount() >= 2;
6604 } 6604 }
6605 6605
6606 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt rWillBeRawPtr<CSSValue>& value) 6606 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, Nulla bleCSSValue& value)
6607 { 6607 {
6608 CSSParserValue* val = valueList->current(); 6608 CSSParserValue* val = valueList->current();
6609 6609
6610 if (val->unit != CSSParserValue::Function) 6610 if (val->unit != CSSParserValue::Function)
6611 return false; 6611 return false;
6612 6612
6613 if (val->function->id == CSSValueWebkitGradient) { 6613 if (val->function->id == CSSValueWebkitGradient) {
6614 // FIXME: This should send a deprecation message. 6614 // FIXME: This should send a deprecation message.
6615 if (m_context.useCounter()) 6615 if (m_context.useCounter())
6616 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient); 6616 m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6658 6658
6659 if (val->function->id == CSSValueWebkitCanvas) 6659 if (val->function->id == CSSValueWebkitCanvas)
6660 return parseCanvas(valueList, value); 6660 return parseCanvas(valueList, value);
6661 6661
6662 if (val->function->id == CSSValueWebkitCrossFade) 6662 if (val->function->id == CSSValueWebkitCrossFade)
6663 return parseCrossfade(valueList, value); 6663 return parseCrossfade(valueList, value);
6664 6664
6665 return false; 6665 return false;
6666 } 6666 }
6667 6667
6668 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& crossfade) 6668 bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, NullableCS SValue& crossfade)
6669 { 6669 {
6670 // Walk the arguments. 6670 // Walk the arguments.
6671 CSSParserValueList* args = valueList->current()->function->args.get(); 6671 CSSParserValueList* args = valueList->current()->function->args.get();
6672 if (!args || args->size() != 5) 6672 if (!args || args->size() != 5)
6673 return false; 6673 return false;
6674 RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr; 6674 NullableCSSValue fromImageValue;
6675 RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr; 6675 NullableCSSValue toImageValue;
6676 6676
6677 // The first argument is the "from" image. It is a fill image. 6677 // The first argument is the "from" image. It is a fill image.
6678 if (!args->current() || !parseFillImage(args, fromImageValue)) 6678 if (!args->current() || !parseFillImage(args, fromImageValue))
6679 return false; 6679 return false;
6680 args->next(); 6680 args->next();
6681 6681
6682 if (!consumeComma(args)) 6682 if (!consumeComma(args))
6683 return false; 6683 return false;
6684 6684
6685 // The second argument is the "to" image. It is a fill image. 6685 // The second argument is the "to" image. It is a fill image.
(...skipping 10 matching lines...) Expand all
6696 if (!value) 6696 if (!value)
6697 return false; 6697 return false;
6698 6698
6699 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE) 6699 if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
6700 percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER); 6700 percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
6701 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) 6701 else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
6702 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0 , 1), CSSPrimitiveValue::CSS_NUMBER); 6702 percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0 , 1), CSSPrimitiveValue::CSS_NUMBER);
6703 else 6703 else
6704 return false; 6704 return false;
6705 6705
6706 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(fro mImageValue, toImageValue); 6706 RefPtrWillBeRawPtr<CSSCrossfadeValue> result = CSSCrossfadeValue::create(*fr omImageValue, *toImageValue);
6707 result->setPercentage(percentage); 6707 result->setPercentage(percentage);
6708 6708
6709 crossfade = result; 6709 crossfade = result;
6710 6710
6711 return true; 6711 return true;
6712 } 6712 }
6713 6713
6714 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, RefPtrWillBeR awPtr<CSSValue>& canvas) 6714 bool CSSPropertyParser::parseCanvas(CSSParserValueList* valueList, NullableCSSVa lue& canvas)
6715 { 6715 {
6716 // Walk the arguments. 6716 // Walk the arguments.
6717 CSSParserValueList* args = valueList->current()->function->args.get(); 6717 CSSParserValueList* args = valueList->current()->function->args.get();
6718 if (!args || args->size() != 1) 6718 if (!args || args->size() != 1)
6719 return false; 6719 return false;
6720 6720
6721 // The first argument is the canvas name. It is an identifier. 6721 // The first argument is the canvas name. It is an identifier.
6722 CSSParserValue* value = args->current(); 6722 CSSParserValue* value = args->current();
6723 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT) 6723 if (!value || value->unit != CSSPrimitiveValue::CSS_IDENT)
6724 return false; 6724 return false;
6725 6725
6726 canvas = CSSCanvasValue::create(value->string); 6726 canvas = CSSCanvasValue::create(value->string);
6727 return true; 6727 return true;
6728 } 6728 }
6729 6729
6730 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue List* valueList) 6730 NullableCSSValue CSSPropertyParser::parseImageSet(CSSParserValueList* valueList)
6731 { 6731 {
6732 CSSParserValue* function = valueList->current(); 6732 CSSParserValue* function = valueList->current();
6733 6733
6734 if (function->unit != CSSParserValue::Function) 6734 if (function->unit != CSSParserValue::Function)
6735 return nullptr; 6735 return nullptr;
6736 6736
6737 CSSParserValueList* functionArgs = valueList->current()->function->args.get( ); 6737 CSSParserValueList* functionArgs = valueList->current()->function->args.get( );
6738 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) 6738 if (!functionArgs || !functionArgs->size() || !functionArgs->current())
6739 return nullptr; 6739 return nullptr;
6740 6740
6741 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); 6741 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
6742 6742
6743 while (functionArgs->current()) { 6743 while (functionArgs->current()) {
6744 CSSParserValue* arg = functionArgs->current(); 6744 CSSParserValue* arg = functionArgs->current();
6745 if (arg->unit != CSSPrimitiveValue::CSS_URI) 6745 if (arg->unit != CSSPrimitiveValue::CSS_URI)
6746 return nullptr; 6746 return nullptr;
6747 6747
6748 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg ->string, completeURL(arg->string)); 6748 CSSValue image = createCSSImageValueWithReferrer(arg->string, completeUR L(arg->string));
6749 imageSet->append(image); 6749 imageSet->append(image);
6750 6750
6751 arg = functionArgs->next(); 6751 arg = functionArgs->next();
6752 if (!arg) 6752 if (!arg)
6753 return nullptr; 6753 return nullptr;
6754 6754
6755 if (arg->unit != CSSParserValue::DimensionList) 6755 if (arg->unit != CSSParserValue::DimensionList)
6756 return nullptr; 6756 return nullptr;
6757 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER ); 6757 ASSERT(arg->valueList->valueAt(0)->unit == CSSPrimitiveValue::CSS_NUMBER );
6758 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT) ; 6758 ASSERT(arg->valueList->valueAt(1)->unit == CSSPrimitiveValue::CSS_IDENT) ;
(...skipping 10 matching lines...) Expand all
6769 break; 6769 break;
6770 6770
6771 // If there are more arguments, they should be after a comma. 6771 // If there are more arguments, they should be after a comma.
6772 if (!consumeComma(functionArgs)) 6772 if (!consumeComma(functionArgs))
6773 return nullptr; 6773 return nullptr;
6774 } 6774 }
6775 6775
6776 return imageSet.release(); 6776 return imageSet.release();
6777 } 6777 }
6778 6778
6779 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange() 6779 NullableCSSValue CSSPropertyParser::parseWillChange()
6780 { 6780 {
6781 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 6781 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
6782 if (m_valueList->current()->id == CSSValueAuto) { 6782 if (m_valueList->current()->id == CSSValueAuto) {
6783 // FIXME: This will be read back as an empty string instead of auto 6783 // FIXME: This will be read back as an empty string instead of auto
6784 return values.release(); 6784 return values.release();
6785 } 6785 }
6786 6786
6787 // Every comma-separated list of CSS_IDENTs is a valid will-change value, 6787 // Every comma-separated list of CSS_IDENTs is a valid will-change value,
6788 // unless the list includes an explicitly disallowed CSS_IDENT. 6788 // unless the list includes an explicitly disallowed CSS_IDENT.
6789 while (true) { 6789 while (true) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
6942 } 6942 }
6943 } 6943 }
6944 6944
6945 return list.release(); 6945 return list.release();
6946 } 6946 }
6947 6947
6948 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() 6948 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin()
6949 { 6949 {
6950 CSSParserValue* value = m_valueList->current(); 6950 CSSParserValue* value = m_valueList->current();
6951 CSSValueID id = value->id; 6951 CSSValueID id = value->id;
6952 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 6952 NullableCSSValue xValue;
6953 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 6953 NullableCSSValue yValue;
6954 RefPtrWillBeRawPtr<CSSValue> zValue = nullptr; 6954 NullableCSSValue zValue;
6955 if (id == CSSValueLeft || id == CSSValueRight) { 6955 if (id == CSSValueLeft || id == CSSValueRight) {
6956 xValue = cssValuePool().createIdentifierValue(id); 6956 xValue = cssValuePool().createIdentifierValue(id);
6957 } else if (id == CSSValueTop || id == CSSValueBottom) { 6957 } else if (id == CSSValueTop || id == CSSValueBottom) {
6958 yValue = cssValuePool().createIdentifierValue(id); 6958 yValue = cssValuePool().createIdentifierValue(id);
6959 } else if (id == CSSValueCenter) { 6959 } else if (id == CSSValueCenter) {
6960 // Unresolved as to whether this is X or Y. 6960 // Unresolved as to whether this is X or Y.
6961 } else if (validUnit(value, FPercent | FLength)) { 6961 } else if (validUnit(value, FPercent | FLength)) {
6962 xValue = createPrimitiveNumericValue(value); 6962 xValue = createPrimitiveNumericValue(value);
6963 } else { 6963 } else {
6964 return nullptr; 6964 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6997 } 6997 }
6998 } else if (!xValue) { 6998 } else if (!xValue) {
6999 if (yValue) { 6999 if (yValue) {
7000 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE); 7000 xValue = cssValuePool().createValue(50, CSSPrimitiveValue::CSS_PERCE NTAGE);
7001 } else { 7001 } else {
7002 xValue = cssValuePool().createIdentifierValue(CSSValueCenter); 7002 xValue = cssValuePool().createIdentifierValue(CSSValueCenter);
7003 } 7003 }
7004 } 7004 }
7005 7005
7006 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7006 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7007 list->append(xValue.release()); 7007 list->append(*xValue);
7008 if (yValue) 7008 if (yValue)
7009 list->append(yValue.release()); 7009 list->append(*yValue);
7010 if (zValue) 7010 if (zValue)
7011 list->append(zValue.release()); 7011 list->append(*zValue);
7012 return list.release(); 7012 return list.release();
7013 } 7013 }
7014 7014
7015 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction() 7015 NullableCSSValue CSSPropertyParser::parseTouchAction()
7016 { 7016 {
7017 CSSParserValue* value = m_valueList->current(); 7017 CSSParserValue* value = m_valueList->current();
7018 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7018 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7019 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value ->id == CSSValueNone || value->id == CSSValueManipulation)) { 7019 if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value ->id == CSSValueNone || value->id == CSSValueManipulation)) {
7020 list->append(cssValuePool().createIdentifierValue(value->id)); 7020 list->append(cssValuePool().createIdentifierValue(value->id));
7021 m_valueList->next(); 7021 m_valueList->next();
7022 return list.release(); 7022 return list.release();
7023 } 7023 }
7024 7024
7025 bool xSet = false; 7025 bool xSet = false;
7026 bool ySet = false; 7026 bool ySet = false;
7027 while (value) { 7027 while (value) {
7028 switch (value->id) { 7028 switch (value->id) {
7029 case CSSValuePanX: 7029 case CSSValuePanX:
7030 case CSSValuePanRight: 7030 case CSSValuePanRight:
7031 case CSSValuePanLeft: { 7031 case CSSValuePanLeft: {
7032 if (xSet) 7032 if (xSet)
7033 return nullptr; 7033 return nullptr;
7034 xSet = true; 7034 xSet = true;
7035 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled()) 7035 if (value->id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled())
7036 return nullptr; 7036 return nullptr;
7037 7037
7038 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif ierValue(value->id); 7038 CSSValue panValue = cssValuePool().createIdentifierValue(value->id);
7039 list->append(panValue.release()); 7039 list->append(panValue);
7040 break; 7040 break;
7041 } 7041 }
7042 case CSSValuePanY: 7042 case CSSValuePanY:
7043 case CSSValuePanDown: 7043 case CSSValuePanDown:
7044 case CSSValuePanUp: { 7044 case CSSValuePanUp: {
7045 if (ySet) 7045 if (ySet)
7046 return nullptr; 7046 return nullptr;
7047 ySet = true; 7047 ySet = true;
7048 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled()) 7048 if (value->id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchAc tionPanDirectionsEnabled())
7049 return nullptr; 7049 return nullptr;
7050 RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentif ierValue(value->id); 7050 CSSValue panValue = cssValuePool().createIdentifierValue(value->id);
7051 list->append(panValue.release()); 7051 list->append(panValue);
7052 break; 7052 break;
7053 } 7053 }
7054 default: 7054 default:
7055 return nullptr; 7055 return nullptr;
7056 } 7056 }
7057 value = m_valueList->next(); 7057 value = m_valueList->next();
7058 } 7058 }
7059 7059
7060 if (list->length()) 7060 if (list->length())
7061 return list.release(); 7061 return list.release();
7062 7062
7063 return nullptr; 7063 return nullptr;
7064 } 7064 }
7065 7065
7066 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollBlocksOn() 7066 NullableCSSValue CSSPropertyParser::parseScrollBlocksOn()
7067 { 7067 {
7068 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7068 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7069 CSSParserValue* value = m_valueList->current(); 7069 CSSParserValue* value = m_valueList->current();
7070 while (value) { 7070 while (value) {
7071 switch (value->id) { 7071 switch (value->id) {
7072 case CSSValueStartTouch: 7072 case CSSValueStartTouch:
7073 case CSSValueWheelEvent: 7073 case CSSValueWheelEvent:
7074 case CSSValueScrollEvent: { 7074 case CSSValueScrollEvent: {
7075 RefPtrWillBeRawPtr<CSSValue> flagValue = cssValuePool().createIdenti fierValue(value->id); 7075 CSSValue flagValue = cssValuePool().createIdentifierValue(value->id) ;
7076 if (list->hasValue(flagValue.get())) 7076 if (list->hasValue(flagValue))
7077 return nullptr; 7077 return nullptr;
7078 list->append(flagValue.release()); 7078 list->append(flagValue);
7079 break; 7079 break;
7080 } 7080 }
7081 default: 7081 default:
7082 return nullptr; 7082 return nullptr;
7083 } 7083 }
7084 value = m_valueList->next(); 7084 value = m_valueList->next();
7085 } 7085 }
7086 7086
7087 ASSERT(list->length()); 7087 ASSERT(list->length());
7088 return list.release(); 7088 return list.release();
7089 } 7089 }
7090 7090
7091 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) 7091 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, CSSValue value, bool important)
7092 { 7092 {
7093 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set. 7093 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set.
7094 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) { 7094 if (propId == CSSPropertyTextDecoration && !important && !inShorthand()) {
7095 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 7095 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
7096 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine) 7096 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine)
7097 return; 7097 return;
7098 } 7098 }
7099 } 7099 }
7100 addProperty(propId, value, important); 7100 addProperty(propId, value, important);
7101 } 7101 }
(...skipping 29 matching lines...) Expand all
7131 7131
7132 // Values are either valid or in shorthand scope. 7132 // Values are either valid or in shorthand scope.
7133 if (list->length() && (isValid || inShorthand())) { 7133 if (list->length() && (isValid || inShorthand())) {
7134 addTextDecorationProperty(propId, list.release(), important); 7134 addTextDecorationProperty(propId, list.release(), important);
7135 return true; 7135 return true;
7136 } 7136 }
7137 7137
7138 return false; 7138 return false;
7139 } 7139 }
7140 7140
7141 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() 7141 NullableCSSValue CSSPropertyParser::parseTextEmphasisStyle()
7142 { 7142 {
7143 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; 7143 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
7144 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; 7144 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
7145 7145
7146 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7146 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7147 if (value->unit == CSSPrimitiveValue::CSS_STRING) { 7147 if (value->unit == CSSPrimitiveValue::CSS_STRING) {
7148 if (fill || shape) 7148 if (fill || shape)
7149 return nullptr; 7149 return nullptr;
7150 m_valueList->next(); 7150 m_valueList->next();
7151 return createPrimitiveStringValue(value); 7151 return createPrimitiveStringValue(value);
(...skipping 26 matching lines...) Expand all
7178 return parsedValues.release(); 7178 return parsedValues.release();
7179 } 7179 }
7180 if (fill) 7180 if (fill)
7181 return fill.release(); 7181 return fill.release();
7182 if (shape) 7182 if (shape)
7183 return shape.release(); 7183 return shape.release();
7184 7184
7185 return nullptr; 7185 return nullptr;
7186 } 7186 }
7187 7187
7188 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextIndent() 7188 NullableCSSValue CSSPropertyParser::parseTextIndent()
7189 { 7189 {
7190 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 7190 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
7191 7191
7192 bool hasLengthOrPercentage = false; 7192 bool hasLengthOrPercentage = false;
7193 bool hasEachLine = false; 7193 bool hasEachLine = false;
7194 bool hasHanging = false; 7194 bool hasHanging = false;
7195 7195
7196 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 7196 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
7197 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false 7197 // <length> | <percentage> | inherit when RuntimeEnabledFeatures::css3Te xtEnabled() returns false
7198 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni tlessQuirk)) { 7198 if (!hasLengthOrPercentage && validUnit(value, FLength | FPercent | FUni tlessQuirk)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
7284 m_valueList->next(); 7284 m_valueList->next();
7285 } else if (value->id == CSSValueOn || value->id == CSSValueOff) { 7285 } else if (value->id == CSSValueOn || value->id == CSSValueOff) {
7286 tagValue = value->id == CSSValueOn; 7286 tagValue = value->id == CSSValueOn;
7287 m_valueList->next(); 7287 m_valueList->next();
7288 } 7288 }
7289 } 7289 }
7290 settings->append(CSSFontFeatureValue::create(tag, tagValue)); 7290 settings->append(CSSFontFeatureValue::create(tag, tagValue));
7291 return true; 7291 return true;
7292 } 7292 }
7293 7293
7294 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseFontFeatureSettings() 7294 NullableCSSValue CSSPropertyParser::parseFontFeatureSettings()
7295 { 7295 {
7296 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat ed(); 7296 RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparat ed();
7297 while (true) { 7297 while (true) {
7298 if (!m_valueList->current() || !parseFontFeatureTag(settings.get())) 7298 if (!m_valueList->current() || !parseFontFeatureTag(settings.get()))
7299 return nullptr; 7299 return nullptr;
7300 if (!m_valueList->current()) 7300 if (!m_valueList->current())
7301 break; 7301 break;
7302 if (!consumeComma(m_valueList)) 7302 if (!consumeComma(m_valueList))
7303 return nullptr; 7303 return nullptr;
7304 } 7304 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7373 return false; 7373 return false;
7374 7374
7375 return true; 7375 return true;
7376 } 7376 }
7377 7377
7378 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) 7378 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId)
7379 { 7379 {
7380 CSSParserValue* value = m_valueList->current(); 7380 CSSParserValue* value = m_valueList->current();
7381 ASSERT(value); 7381 ASSERT(value);
7382 CSSValueID id = value->id; 7382 CSSValueID id = value->id;
7383 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7383 NullableCSSValue parsedValue;
7384 7384
7385 switch (propId) { 7385 switch (propId) {
7386 case CSSPropertyFontFamily: 7386 case CSSPropertyFontFamily:
7387 // <family-name> 7387 // <family-name>
7388 // TODO(rwlbuis): check there is only one family-name 7388 // TODO(rwlbuis): check there is only one family-name
7389 parsedValue = parseFontFamily(); 7389 parsedValue = parseFontFamily();
7390 break; 7390 break;
7391 case CSSPropertySrc: // This is a list of urls or local references. 7391 case CSSPropertySrc: // This is a list of urls or local references.
7392 parsedValue = parseFontFaceSrc(); 7392 parsedValue = parseFontFaceSrc();
7393 break; 7393 break;
(...skipping 20 matching lines...) Expand all
7414 parsedValue = parseFontFeatureSettings(); 7414 parsedValue = parseFontFeatureSettings();
7415 } 7415 }
7416 break; 7416 break;
7417 default: 7417 default:
7418 break; 7418 break;
7419 } 7419 }
7420 7420
7421 if (!parsedValue || m_valueList->current()) 7421 if (!parsedValue || m_valueList->current())
7422 return false; 7422 return false;
7423 7423
7424 addProperty(propId, parsedValue.release(), false); 7424 addProperty(propId, *parsedValue, false);
7425 return true; 7425 return true;
7426 } 7426 }
7427 7427
7428 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt) 7428 bool CSSPropertyParser::parseViewportProperty(CSSPropertyID propId, bool importa nt)
7429 { 7429 {
7430 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7430 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
7431 7431
7432 CSSParserValue* value = m_valueList->current(); 7432 CSSParserValue* value = m_valueList->current();
7433 if (!value) 7433 if (!value)
7434 return false; 7434 return false;
(...skipping 27 matching lines...) Expand all
7462 if (id == CSSValueZoom || id == CSSValueFixed) 7462 if (id == CSSValueZoom || id == CSSValueFixed)
7463 validPrimitive = true; 7463 validPrimitive = true;
7464 break; 7464 break;
7465 case CSSPropertyOrientation: // auto | portrait | landscape 7465 case CSSPropertyOrientation: // auto | portrait | landscape
7466 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc ape) 7466 if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandsc ape)
7467 validPrimitive = true; 7467 validPrimitive = true;
7468 default: 7468 default:
7469 break; 7469 break;
7470 } 7470 }
7471 7471
7472 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7472 NullableCSSValue parsedValue;
7473 if (validPrimitive) { 7473 if (validPrimitive) {
7474 parsedValue = parseValidPrimitive(id, value); 7474 parsedValue = parseValidPrimitive(id, value);
7475 m_valueList->next(); 7475 m_valueList->next();
7476 } 7476 }
7477 7477
7478 if (parsedValue) { 7478 if (parsedValue) {
7479 if (!m_valueList->current() || inShorthand()) { 7479 if (!m_valueList->current() || inShorthand()) {
7480 addProperty(propId, parsedValue.release(), important); 7480 addProperty(propId, *parsedValue, important);
7481 return true; 7481 return true;
7482 } 7482 }
7483 } 7483 }
7484 7484
7485 return false; 7485 return false;
7486 } 7486 }
7487 7487
7488 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty ID first, CSSPropertyID second, bool important) 7488 bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty ID first, CSSPropertyID second, bool important)
7489 { 7489 {
7490 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode())); 7490 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_c ontext.mode()));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
7592 } 7592 }
7593 7593
7594 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important) 7594 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
7595 { 7595 {
7596 CSSParserValue* value = m_valueList->current(); 7596 CSSParserValue* value = m_valueList->current();
7597 ASSERT(value); 7597 ASSERT(value);
7598 7598
7599 CSSValueID id = value->id; 7599 CSSValueID id = value->id;
7600 7600
7601 bool validPrimitive = false; 7601 bool validPrimitive = false;
7602 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; 7602 NullableCSSValue parsedValue;
7603 7603
7604 switch (propId) { 7604 switch (propId) {
7605 /* The comment to the right defines all valid value of these 7605 /* The comment to the right defines all valid value of these
7606 * properties as defined in SVG 1.1, Appendix N. Property index */ 7606 * properties as defined in SVG 1.1, Appendix N. Property index */
7607 case CSSPropertyAlignmentBaseline: 7607 case CSSPropertyAlignmentBaseline:
7608 // auto | baseline | before-edge | text-before-edge | middle | 7608 // auto | baseline | before-edge | text-before-edge | middle |
7609 // central | after-edge | text-after-edge | ideographic | alphabetic | 7609 // central | after-edge | text-after-edge | ideographic | alphabetic |
7610 // hanging | mathematical | inherit 7610 // hanging | mathematical | inherit
7611 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle 7611 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle
7612 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical)) 7612 || (id >= CSSValueBeforeEdge && id <= CSSValueMathematical))
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
7737 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 7737 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
7738 RGBA32 c = Color::transparent; 7738 RGBA32 c = Color::transparent;
7739 if (m_valueList->next()) { 7739 if (m_valueList->next()) {
7740 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea teSpaceSeparated(); 7740 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::crea teSpaceSeparated();
7741 values->append(CSSPrimitiveValue::create(value->string, CSSP rimitiveValue::CSS_URI)); 7741 values->append(CSSPrimitiveValue::create(value->string, CSSP rimitiveValue::CSS_URI));
7742 if (parseColorFromValue(m_valueList->current(), c)) 7742 if (parseColorFromValue(m_valueList->current(), c))
7743 parsedValue = cssValuePool().createColorValue(c); 7743 parsedValue = cssValuePool().createColorValue(c);
7744 else if (m_valueList->current()->id == CSSValueNone || m_val ueList->current()->id == CSSValueCurrentcolor) 7744 else if (m_valueList->current()->id == CSSValueNone || m_val ueList->current()->id == CSSValueCurrentcolor)
7745 parsedValue = cssValuePool().createIdentifierValue(m_val ueList->current()->id); 7745 parsedValue = cssValuePool().createIdentifierValue(m_val ueList->current()->id);
7746 if (parsedValue) { 7746 if (parsedValue) {
7747 values->append(parsedValue); 7747 values->append(*parsedValue);
7748 parsedValue = values; 7748 parsedValue = values;
7749 } 7749 }
7750 } 7750 }
7751 if (!parsedValue) 7751 if (!parsedValue)
7752 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr imitiveValue::CSS_URI); 7752 parsedValue = CSSPrimitiveValue::create(value->string, CSSPr imitiveValue::CSS_URI);
7753 } else { 7753 } else {
7754 parsedValue = parseColor(); 7754 parsedValue = parseColor();
7755 } 7755 }
7756 7756
7757 if (parsedValue) 7757 if (parsedValue)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
7818 /* shorthand properties */ 7818 /* shorthand properties */
7819 case CSSPropertyMarker: { 7819 case CSSPropertyMarker: {
7820 ShorthandScope scope(this, propId); 7820 ShorthandScope scope(this, propId);
7821 CSSPropertyParser::ImplicitScope implicitScope(this); 7821 CSSPropertyParser::ImplicitScope implicitScope(this);
7822 if (!parseValue(CSSPropertyMarkerStart, important)) 7822 if (!parseValue(CSSPropertyMarkerStart, important))
7823 return false; 7823 return false;
7824 if (m_valueList->current()) { 7824 if (m_valueList->current()) {
7825 rollbackLastProperties(1); 7825 rollbackLastProperties(1);
7826 return false; 7826 return false;
7827 } 7827 }
7828 CSSValue* value = m_parsedProperties.last().value(); 7828 CSSValue value = m_parsedProperties.last().value();
7829 addProperty(CSSPropertyMarkerMid, value, important); 7829 addProperty(CSSPropertyMarkerMid, value, important);
7830 addProperty(CSSPropertyMarkerEnd, value, important); 7830 addProperty(CSSPropertyMarkerEnd, value, important);
7831 return true; 7831 return true;
7832 } 7832 }
7833 default: 7833 default:
7834 // If you crash here, it's because you added a css property and are not handling it 7834 // If you crash here, it's because you added a css property and are not handling it
7835 // in either this switch statement or the one in CSSPropertyParser::pars eValue 7835 // in either this switch statement or the one in CSSPropertyParser::pars eValue
7836 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId); 7836 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId);
7837 return false; 7837 return false;
7838 } 7838 }
(...skipping 13 matching lines...) Expand all
7852 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie 7852 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie
7853 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se()); 7853 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se());
7854 m_parsedCalculation.release(); 7854 m_parsedCalculation.release();
7855 parsedValue = nullptr; 7855 parsedValue = nullptr;
7856 } 7856 }
7857 m_valueList->next(); 7857 m_valueList->next();
7858 } 7858 }
7859 if (!parsedValue || (m_valueList->current() && !inShorthand())) 7859 if (!parsedValue || (m_valueList->current() && !inShorthand()))
7860 return false; 7860 return false;
7861 7861
7862 addProperty(propId, parsedValue.release(), important); 7862 addProperty(propId, *parsedValue, important);
7863 return true; 7863 return true;
7864 } 7864 }
7865 7865
7866 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray() 7866 NullableCSSValue CSSPropertyParser::parseSVGStrokeDasharray()
7867 { 7867 {
7868 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); 7868 RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated();
7869 CSSParserValue* value = m_valueList->current(); 7869 CSSParserValue* value = m_valueList->current();
7870 bool validPrimitive = true; 7870 bool validPrimitive = true;
7871 while (value) { 7871 while (value) {
7872 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri buteMode); 7872 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg, SVGAttri buteMode);
7873 if (!validPrimitive) 7873 if (!validPrimitive)
7874 break; 7874 break;
7875 if (value->id) 7875 if (value->id)
7876 ret->append(CSSPrimitiveValue::createIdentifier(value->id)); 7876 ret->append(CSSPrimitiveValue::createIdentifier(value->id));
7877 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) 7877 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
7878 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType) value->unit)); 7878 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType) value->unit));
7879 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS SPrimitiveValue::CSS_CHS) 7879 else if (value->unit == CSSPrimitiveValue::CSS_REMS || value->unit == CS SPrimitiveValue::CSS_CHS)
7880 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType)value->unit)); 7880 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveVa lue::UnitType)value->unit));
7881 value = m_valueList->next(); 7881 value = m_valueList->next();
7882 bool commaConsumed = consumeComma(m_valueList); 7882 bool commaConsumed = consumeComma(m_valueList);
7883 value = m_valueList->current(); 7883 value = m_valueList->current();
7884 if (commaConsumed && !value) 7884 if (commaConsumed && !value)
7885 return nullptr; 7885 return nullptr;
7886 } 7886 }
7887 if (!validPrimitive) 7887 if (!validPrimitive)
7888 return nullptr; 7888 return nullptr;
7889 return ret.release(); 7889 return ret.release();
7890 } 7890 }
7891 7891
7892 // normal | [ fill || stroke || markers ] 7892 // normal | [ fill || stroke || markers ]
7893 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const 7893 NullableCSSValue CSSPropertyParser::parsePaintOrder() const
7894 { 7894 {
7895 if (m_valueList->size() > 3) 7895 if (m_valueList->size() > 3)
7896 return nullptr; 7896 return nullptr;
7897 7897
7898 CSSParserValue* value = m_valueList->current(); 7898 CSSParserValue* value = m_valueList->current();
7899 ASSERT(value); 7899 ASSERT(value);
7900 7900
7901 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated(); 7901 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSep arated();
7902 7902
7903 // The default paint-order is: Fill, Stroke, Markers. 7903 // The default paint-order is: Fill, Stroke, Markers.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
8046 CSSPropertyParser::Units m_unit; 8046 CSSPropertyParser::Units m_unit;
8047 }; 8047 };
8048 8048
8049 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL egacyParsing) 8049 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransform(bool useL egacyParsing)
8050 { 8050 {
8051 if (!m_valueList) 8051 if (!m_valueList)
8052 return nullptr; 8052 return nullptr;
8053 8053
8054 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 8054 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
8055 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8055 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8056 RefPtrWillBeRawPtr<CSSValue> parsedTransformValue = parseTransformValue( useLegacyParsing, value); 8056 NullableCSSValue parsedTransformValue = parseTransformValue(useLegacyPar sing, value);
8057 if (!parsedTransformValue) 8057 if (!parsedTransformValue)
8058 return nullptr; 8058 return nullptr;
8059 8059
8060 list->append(parsedTransformValue.release()); 8060 list->append(*parsedTransformValue);
8061 } 8061 }
8062 8062
8063 return list.release(); 8063 return list.release();
8064 } 8064 }
8065 8065
8066 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(bool use LegacyParsing, CSSParserValue *value) 8066 NullableCSSValue CSSPropertyParser::parseTransformValue(bool useLegacyParsing, C SSParserValue *value)
8067 { 8067 {
8068 if (value->unit != CSSParserValue::Function || !value->function) 8068 if (value->unit != CSSParserValue::Function || !value->function)
8069 return nullptr; 8069 return nullptr;
8070 8070
8071 // Every primitive requires at least one argument. 8071 // Every primitive requires at least one argument.
8072 CSSParserValueList* args = value->function->args.get(); 8072 CSSParserValueList* args = value->function->args.get();
8073 if (!args) 8073 if (!args)
8074 return nullptr; 8074 return nullptr;
8075 8075
8076 // See if the specified primitive is one we understand. 8076 // See if the specified primitive is one we understand.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
8128 if (!isComma(a)) 8128 if (!isComma(a))
8129 return nullptr; 8129 return nullptr;
8130 a = args->next(); 8130 a = args->next();
8131 8131
8132 argNumber++; 8132 argNumber++;
8133 } 8133 }
8134 8134
8135 return transformValue.release(); 8135 return transformValue.release();
8136 } 8136 }
8137 8137
8138 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionPath() 8138 NullableCSSValue CSSPropertyParser::parseMotionPath()
8139 { 8139 {
8140 CSSParserValue* value = m_valueList->current(); 8140 CSSParserValue* value = m_valueList->current();
8141 8141
8142 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. 8142 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>.
8143 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath) 8143 if (value->unit != CSSParserValue::Function || value->function->id != CSSVal uePath)
8144 return nullptr; 8144 return nullptr;
8145 8145
8146 // FIXME: Add support for <fill-rule>. 8146 // FIXME: Add support for <fill-rule>.
8147 CSSParserValueList* functionArgs = value->function->args.get(); 8147 CSSParserValueList* functionArgs = value->function->args.get();
8148 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current()) 8148 if (!functionArgs || functionArgs->size() != 1 || !functionArgs->current())
8149 return nullptr; 8149 return nullptr;
8150 8150
8151 CSSParserValue* arg = functionArgs->current(); 8151 CSSParserValue* arg = functionArgs->current();
8152 if (arg->unit != CSSPrimitiveValue::CSS_STRING) 8152 if (arg->unit != CSSPrimitiveValue::CSS_STRING)
8153 return nullptr; 8153 return nullptr;
8154 8154
8155 String pathString = arg->string; 8155 String pathString = arg->string;
8156 Path path; 8156 Path path;
8157 if (!buildPathFromString(pathString, path)) 8157 if (!buildPathFromString(pathString, path))
8158 return nullptr; 8158 return nullptr;
8159 8159
8160 m_valueList->next(); 8160 m_valueList->next();
8161 return CSSPathValue::create(pathString); 8161 return CSSPathValue::create(pathString);
8162 } 8162 }
8163 8163
8164 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseMotionRotation() 8164 NullableCSSValue CSSPropertyParser::parseMotionRotation()
8165 { 8165 {
8166 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 8166 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
8167 bool hasAutoOrReverse = false; 8167 bool hasAutoOrReverse = false;
8168 bool hasAngle = false; 8168 bool hasAngle = false;
8169 8169
8170 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8170 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8171 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA utoOrReverse) { 8171 if ((value->id == CSSValueAuto || value->id == CSSValueReverse) && !hasA utoOrReverse) {
8172 list->append(cssValuePool().createIdentifierValue(value->id)); 8172 list->append(cssValuePool().createIdentifierValue(value->id));
8173 hasAutoOrReverse = true; 8173 hasAutoOrReverse = true;
8174 } else if (validUnit(value, FAngle) && !hasAngle) { 8174 } else if (validUnit(value, FAngle) && !hasAngle) {
8175 list->append(createPrimitiveNumericValue(value)); 8175 list->append(createPrimitiveNumericValue(value));
8176 hasAngle = true; 8176 hasAngle = true;
8177 } else { 8177 } else {
8178 break; 8178 break;
8179 } 8179 }
8180 } 8180 }
8181 8181
8182 if (!list->length()) 8182 if (!list->length())
8183 return nullptr; 8183 return nullptr;
8184 8184
8185 return list.release(); 8185 return list.release();
8186 } 8186 }
8187 8187
8188 } // namespace blink 8188 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/parser/CSSPropertyParserTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698