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

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

Issue 1317523002: Changed Pair to be a CSSValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@add_const_to_primvalue
Patch Set: Fixed some callsites from bad rebase Created 5 years, 3 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "core/css/CSSPathValue.h" 45 #include "core/css/CSSPathValue.h"
46 #include "core/css/CSSPrimitiveValueMappings.h" 46 #include "core/css/CSSPrimitiveValueMappings.h"
47 #include "core/css/CSSProperty.h" 47 #include "core/css/CSSProperty.h"
48 #include "core/css/CSSPropertyMetadata.h" 48 #include "core/css/CSSPropertyMetadata.h"
49 #include "core/css/CSSQuadValue.h" 49 #include "core/css/CSSQuadValue.h"
50 #include "core/css/CSSReflectValue.h" 50 #include "core/css/CSSReflectValue.h"
51 #include "core/css/CSSSVGDocumentValue.h" 51 #include "core/css/CSSSVGDocumentValue.h"
52 #include "core/css/CSSShadowValue.h" 52 #include "core/css/CSSShadowValue.h"
53 #include "core/css/CSSTimingFunctionValue.h" 53 #include "core/css/CSSTimingFunctionValue.h"
54 #include "core/css/CSSUnicodeRangeValue.h" 54 #include "core/css/CSSUnicodeRangeValue.h"
55 #include "core/css/CSSValuePair.h"
55 #include "core/css/CSSValuePool.h" 56 #include "core/css/CSSValuePool.h"
56 #include "core/css/HashTools.h" 57 #include "core/css/HashTools.h"
57 #include "core/css/Pair.h"
58 #include "core/css/parser/CSSParserFastPaths.h" 58 #include "core/css/parser/CSSParserFastPaths.h"
59 #include "core/css/parser/CSSParserValues.h" 59 #include "core/css/parser/CSSParserValues.h"
60 #include "core/frame/UseCounter.h" 60 #include "core/frame/UseCounter.h"
61 #include "core/layout/LayoutTheme.h" 61 #include "core/layout/LayoutTheme.h"
62 #include "core/style/GridCoordinate.h" 62 #include "core/style/GridCoordinate.h"
63 #include "core/svg/SVGPathUtilities.h" 63 #include "core/svg/SVGPathUtilities.h"
64 #include "platform/RuntimeEnabledFeatures.h" 64 #include "platform/RuntimeEnabledFeatures.h"
65 65
66 namespace blink { 66 namespace blink {
67 67
68 template <unsigned N> 68 template <unsigned N>
69 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) 69 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N])
70 { 70 {
71 unsigned length = N - 1; // Ignore the trailing null character 71 unsigned length = N - 1; // Ignore the trailing null character
72 if (a.length() != length) 72 if (a.length() != length)
73 return false; 73 return false;
74 74
75 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF ::equalIgnoringCase(b, a.characters16(), length); 75 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF ::equalIgnoringCase(b, a.characters16(), length);
76 } 76 }
77 77
78 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRe fPtrWillBeRawPtr<CSSPrimitiveValue> first, PassRefPtrWillBeRawPtr<CSSPrimitiveVa lue> second, Pair::IdenticalValuesPolicy identicalValuesPolicy = Pair::DropIdent icalValues) 78 static PassRefPtrWillBeRawPtr<CSSValuePair> createCSSValuePair(PassRefPtrWillBeR awPtr<CSSValue> first, PassRefPtrWillBeRawPtr<CSSValue> second, CSSValuePair::Id enticalValuesPolicy identicalValuesPolicy = CSSValuePair::DropIdenticalValues)
Timothy Loh 2015/08/28 05:51:46 I would probably just drop this function, all it d
sashab 2015/08/31 00:33:51 Was thinking the same thing actually. Done. Shoul
Timothy Loh 2015/08/31 01:08:04 It's probably fine to add the using statement to t
sashab 2015/08/31 01:29:47 Sure, just left it. Makes for some long lines in t
79 { 79 {
80 return cssValuePool().createValue(Pair::create(first, second, identicalValue sPolicy)); 80 return CSSValuePair::create(first, second, identicalValuesPolicy);
81 } 81 }
82 82
83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, 83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList,
84 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP roperties, 84 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP roperties,
85 StyleRule::Type ruleType) 85 StyleRule::Type ruleType)
86 : m_valueList(valueList) 86 : m_valueList(valueList)
87 , m_context(context) 87 , m_context(context)
88 , m_parsedProperties(parsedProperties) 88 , m_parsedProperties(parsedProperties)
89 , m_ruleType(ruleType) 89 , m_ruleType(ruleType)
90 , m_inParseShorthand(0) 90 , m_inParseShorthand(0)
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 if (value) { 980 if (value) {
981 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); 981 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg);
982 if (!validPrimitive) 982 if (!validPrimitive)
983 return false; 983 return false;
984 parsedValue2 = createPrimitiveNumericValue(value); 984 parsedValue2 = createPrimitiveNumericValue(value);
985 } else 985 } else
986 parsedValue2 = parsedValue1; 986 parsedValue2 = parsedValue1;
987 987
988 if (m_valueList->next()) 988 if (m_valueList->next())
989 return false; 989 return false;
990 addProperty(propId, createPrimitiveValuePair(parsedValue1.release(), par sedValue2.release()), important); 990 addProperty(propId, createCSSValuePair(parsedValue1.release(), parsedVal ue2.release()), important);
991 return true; 991 return true;
992 } 992 }
993 case CSSPropertyTabSize: 993 case CSSPropertyTabSize:
994 // May be specified as a unit-less non-negative integer or length indica ting number of space characters. 994 // May be specified as a unit-less non-negative integer or length indica ting number of space characters.
995 validPrimitive = validUnit(value, FInteger | FLength | FNonNeg); 995 validPrimitive = validUnit(value, FInteger | FLength | FNonNeg);
996 break; 996 break;
997 case CSSPropertyBorderRadius: 997 case CSSPropertyBorderRadius:
998 case CSSPropertyAliasWebkitBorderRadius: 998 case CSSPropertyAliasWebkitBorderRadius:
999 return parseBorderRadius(unresolvedProperty, important); 999 return parseBorderRadius(unresolvedProperty, important);
1000 case CSSPropertyOutlineOffset: 1000 case CSSPropertyOutlineOffset:
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 cumulativeFlags = 0; 2489 cumulativeFlags = 0;
2490 FillPositionFlag value4Flag = InvalidFillPosition; 2490 FillPositionFlag value4Flag = InvalidFillPosition;
2491 RefPtrWillBeRawPtr<CSSPrimitiveValue> value4 = parseFillPositionComponent(va lueList, cumulativeFlags, value4Flag, ResolveValuesAsKeyword); 2491 RefPtrWillBeRawPtr<CSSPrimitiveValue> value4 = parseFillPositionComponent(va lueList, cumulativeFlags, value4Flag, ResolveValuesAsKeyword);
2492 if (!value4) 2492 if (!value4)
2493 return; 2493 return;
2494 2494
2495 // 4th value must be a length or a percentage. 2495 // 4th value must be a length or a percentage.
2496 if (isFillPositionKeyword(value4->getValueID())) 2496 if (isFillPositionKeyword(value4->getValueID()))
2497 return; 2497 return;
2498 2498
2499 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); 2499 value1 = createCSSValuePair(parsedValue1, parsedValue2);
2500 value2 = createPrimitiveValuePair(value3, value4); 2500 value2 = createCSSValuePair(value3, value4);
2501 2501
2502 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) 2502 if (ident1 == CSSValueTop || ident1 == CSSValueBottom)
2503 value1.swap(value2); 2503 value1.swap(value2);
2504 2504
2505 valueList->next(); 2505 valueList->next();
2506 } 2506 }
2507 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2) 2507 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr imitiveValue> parsedValue2)
2508 { 2508 {
2509 unsigned cumulativeFlags = 0; 2509 unsigned cumulativeFlags = 0;
2510 FillPositionFlag value3Flag = InvalidFillPosition; 2510 FillPositionFlag value3Flag = InvalidFillPosition;
(...skipping 20 matching lines...) Expand all
2531 2531
2532 // If 'center' is the first keyword then the last one needs to be a leng th. 2532 // If 'center' is the first keyword then the last one needs to be a leng th.
2533 if (isFillPositionKeyword(ident3)) 2533 if (isFillPositionKeyword(ident3))
2534 return; 2534 return;
2535 2535
2536 firstPositionKeyword = CSSValueLeft; 2536 firstPositionKeyword = CSSValueLeft;
2537 if (ident2 == CSSValueLeft || ident2 == CSSValueRight) { 2537 if (ident2 == CSSValueLeft || ident2 == CSSValueRight) {
2538 firstPositionKeyword = CSSValueTop; 2538 firstPositionKeyword = CSSValueTop;
2539 swapNeeded = true; 2539 swapNeeded = true;
2540 } 2540 }
2541 value1 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(f irstPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitType ::Percentage)); 2541 value1 = createCSSValuePair(cssValuePool().createIdentifierValue(firstPo sitionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Perc entage));
2542 value2 = createPrimitiveValuePair(parsedValue2, value3); 2542 value2 = createCSSValuePair(parsedValue2, value3);
2543 } else if (ident3 == CSSValueCenter) { 2543 } else if (ident3 == CSSValueCenter) {
2544 if (isFillPositionKeyword(ident2)) 2544 if (isFillPositionKeyword(ident2))
2545 return; 2545 return;
2546 2546
2547 secondPositionKeyword = CSSValueTop; 2547 secondPositionKeyword = CSSValueTop;
2548 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) { 2548 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) {
2549 secondPositionKeyword = CSSValueLeft; 2549 secondPositionKeyword = CSSValueLeft;
2550 swapNeeded = true; 2550 swapNeeded = true;
2551 } 2551 }
2552 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); 2552 value1 = createCSSValuePair(parsedValue1, parsedValue2);
2553 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitTyp e::Percentage)); 2553 value2 = createCSSValuePair(cssValuePool().createIdentifierValue(secondP ositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Per centage));
2554 } else { 2554 } else {
2555 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPositionValue = nullptr; 2555 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPositionValue = nullptr;
2556 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPositionValue = nullptr; 2556 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPositionValue = nullptr;
2557 2557
2558 if (isFillPositionKeyword(ident2)) { 2558 if (isFillPositionKeyword(ident2)) {
2559 // To match CSS grammar, we should only accept: [ center | left | ri ght | bottom | top ] [ left | right | top | bottom ] [ <percentage> | <length> ] . 2559 // To match CSS grammar, we should only accept: [ center | left | ri ght | bottom | top ] [ left | right | top | bottom ] [ <percentage> | <length> ] .
2560 ASSERT(ident2 != CSSValueCenter); 2560 ASSERT(ident2 != CSSValueCenter);
2561 2561
2562 if (isFillPositionKeyword(ident3)) 2562 if (isFillPositionKeyword(ident3))
2563 return; 2563 return;
2564 2564
2565 secondPositionValue = value3; 2565 secondPositionValue = value3;
2566 secondPositionKeyword = ident2; 2566 secondPositionKeyword = ident2;
2567 firstPositionValue = cssValuePool().createValue(0, CSSPrimitiveValue ::UnitType::Percentage); 2567 firstPositionValue = cssValuePool().createValue(0, CSSPrimitiveValue ::UnitType::Percentage);
2568 } else { 2568 } else {
2569 // Per CSS, we should only accept: [ right | left | top | bottom ] [ <percentage> | <length> ] [ center | left | right | bottom | top ]. 2569 // Per CSS, we should only accept: [ right | left | top | bottom ] [ <percentage> | <length> ] [ center | left | right | bottom | top ].
2570 if (!isFillPositionKeyword(ident3)) 2570 if (!isFillPositionKeyword(ident3))
2571 return; 2571 return;
2572 2572
2573 firstPositionValue = parsedValue2; 2573 firstPositionValue = parsedValue2;
2574 secondPositionKeyword = ident3; 2574 secondPositionKeyword = ident3;
2575 secondPositionValue = cssValuePool().createValue(0, CSSPrimitiveValu e::UnitType::Percentage); 2575 secondPositionValue = cssValuePool().createValue(0, CSSPrimitiveValu e::UnitType::Percentage);
2576 } 2576 }
2577 2577
2578 if (isValueConflictingWithCurrentEdge(ident1, secondPositionKeyword)) 2578 if (isValueConflictingWithCurrentEdge(ident1, secondPositionKeyword))
2579 return; 2579 return;
2580 2580
2581 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); 2581 value1 = createCSSValuePair(parsedValue1, firstPositionValue);
2582 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), secondPositionValue); 2582 value2 = createCSSValuePair(cssValuePool().createIdentifierValue(secondP ositionKeyword), secondPositionValue);
2583 } 2583 }
2584 2584
2585 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) 2585 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded)
2586 value1.swap(value2); 2586 value1.swap(value2);
2587 2587
2588 #if ENABLE(ASSERT) 2588 #if ENABLE(ASSERT)
2589 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); 2589 const CSSValuePair* first = toCSSValuePair(value1.get());
2590 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); 2590 const CSSValuePair* second = toCSSValuePair(value2.get());
2591 ident1 = first->getPairValue()->first()->getValueID(); 2591 ident1 = toCSSPrimitiveValue(first->first())->getValueID();
2592 ident2 = second->getPairValue()->first()->getValueID(); 2592 ident2 = toCSSPrimitiveValue(second->first())->getValueID();
2593 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); 2593 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight);
2594 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); 2594 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop);
2595 #endif 2595 #endif
2596 } 2596 }
2597 2597
2598 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) 2598 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value)
2599 { 2599 {
2600 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue); 2600 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue);
2601 } 2601 }
2602 2602
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { 2778 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) {
2779 // For backwards compatibility we set the second value to the first if i t is omitted. 2779 // For backwards compatibility we set the second value to the first if i t is omitted.
2780 // We only need to do this for -webkit-background-size. It should be saf e to let masks match 2780 // We only need to do this for -webkit-background-size. It should be saf e to let masks match
2781 // the real property. 2781 // the real property.
2782 parsedValue2 = parsedValue1; 2782 parsedValue2 = parsedValue1;
2783 } 2783 }
2784 2784
2785 if (!parsedValue2) 2785 if (!parsedValue2)
2786 return parsedValue1; 2786 return parsedValue1;
2787 2787
2788 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release (), Pair::KeepIdenticalValues); 2788 return createCSSValuePair(parsedValue1.release(), parsedValue2.release(), CS SValuePair::KeepIdenticalValues);
2789 } 2789 }
2790 2790
2791 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2, 2791 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p ropId1, CSSPropertyID& propId2,
2792 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa lue2) 2792 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa lue2)
2793 { 2793 {
2794 // We initially store the first value in value/value2, and only create 2794 // We initially store the first value in value/value2, and only create
2795 // CSSValueLists if we have more values. 2795 // CSSValueLists if we have more values.
2796 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; 2796 RefPtrWillBeRawPtr<CSSValueList> values = nullptr;
2797 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; 2797 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr;
2798 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 2798 RefPtrWillBeRawPtr<CSSValue> value = nullptr;
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4091 radii[1][i - indexAfterSlash] = radius.release(); 4091 radii[1][i - indexAfterSlash] = radius.release();
4092 } 4092 }
4093 4093
4094 if (!indexAfterSlash) { 4094 if (!indexAfterSlash) {
4095 completeBorderRadii(radii[0]); 4095 completeBorderRadii(radii[0]);
4096 for (unsigned i = 0; i < 4; ++i) 4096 for (unsigned i = 0; i < 4; ++i)
4097 radii[1][i] = radii[0][i]; 4097 radii[1][i] = radii[0][i];
4098 } else { 4098 } else {
4099 completeBorderRadii(radii[1]); 4099 completeBorderRadii(radii[1]);
4100 } 4100 }
4101 shape->setTopLeftRadius(createPrimitiveValuePair(radii[0][0].release(), radi i[1][0].release())); 4101 shape->setTopLeftRadius(createCSSValuePair(radii[0][0].release(), radii[1][0 ].release()));
4102 shape->setTopRightRadius(createPrimitiveValuePair(radii[0][1].release(), rad ii[1][1].release())); 4102 shape->setTopRightRadius(createCSSValuePair(radii[0][1].release(), radii[1][ 1].release()));
4103 shape->setBottomRightRadius(createPrimitiveValuePair(radii[0][2].release(), radii[1][2].release())); 4103 shape->setBottomRightRadius(createCSSValuePair(radii[0][2].release(), radii[ 1][2].release()));
4104 shape->setBottomLeftRadius(createPrimitiveValuePair(radii[0][3].release(), r adii[1][3].release())); 4104 shape->setBottomLeftRadius(createCSSValuePair(radii[0][3].release(), radii[1 ][3].release()));
4105 4105
4106 return shape; 4106 return shape;
4107 } 4107 }
4108 4108
4109 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS SParserValueList* args) 4109 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS SParserValueList* args)
4110 { 4110 {
4111 ASSERT(args); 4111 ASSERT(args);
4112 4112
4113 RefPtrWillBeRawPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create(); 4113 RefPtrWillBeRawPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create();
4114 4114
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 return false; 4199 return false;
4200 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->i d != CSSValueRight) 4200 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->i d != CSSValueRight)
4201 return false; 4201 return false;
4202 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value ->id == CSSValueRight) { 4202 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value ->id == CSSValueRight) {
4203 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy ) 4203 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy )
4204 return false; 4204 return false;
4205 } else { 4205 } else {
4206 return false; 4206 return false;
4207 } 4207 }
4208 4208
4209 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa nt); 4209 addProperty(propId, createCSSValuePair(cssValuePool().createIdentifierValue( CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), important);
4210 return !m_valueList->next(); 4210 return !m_valueList->next();
4211 } 4211 }
4212 4212
4213 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver flowPosition() 4213 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver flowPosition()
4214 { 4214 {
4215 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ] 4215 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi on>? && <content-position> ]
4216 // <baseline-position> = baseline | last-baseline; 4216 // <baseline-position> = baseline | last-baseline;
4217 // <content-distribution> = space-between | space-around | space-evenly | st retch; 4217 // <content-distribution> = space-between | space-around | space-evenly | st retch;
4218 // <content-position> = center | start | end | flex-start | flex-end | left | right; 4218 // <content-position> = center | start | end | flex-start | flex-end | left | right;
4219 // <overflow-position> = true | safe 4219 // <overflow-position> = true | safe
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4297 return false; 4297 return false;
4298 } else { 4298 } else {
4299 return false; 4299 return false;
4300 } 4300 }
4301 4301
4302 if (m_valueList->next()) 4302 if (m_valueList->next())
4303 return false; 4303 return false;
4304 4304
4305 ASSERT(position); 4305 ASSERT(position);
4306 if (overflowAlignmentKeyword) 4306 if (overflowAlignmentKeyword)
4307 addProperty(propId, createPrimitiveValuePair(position, overflowAlignment Keyword), important); 4307 addProperty(propId, createCSSValuePair(position, overflowAlignmentKeywor d), important);
4308 else 4308 else
4309 addProperty(propId, position.release(), important); 4309 addProperty(propId, position.release(), important);
4310 4310
4311 return true; 4311 return true;
4312 } 4312 }
4313 4313
4314 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS SParserValue* value) 4314 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS SParserValue* value)
4315 { 4315 {
4316 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) 4316 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide)
4317 return cssValuePool().createIdentifierValue(value->id); 4317 return cssValuePool().createIdentifierValue(value->id);
(...skipping 28 matching lines...) Expand all
4346 } 4346 }
4347 4347
4348 return nullptr; 4348 return nullptr;
4349 } 4349 }
4350 4350
4351 if (argument->id == CSSValueAt && args->next()) { 4351 if (argument->id == CSSValueAt && args->next()) {
4352 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4352 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr;
4353 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4353 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr;
4354 parseFillPosition(args, centerX, centerY); 4354 parseFillPosition(args, centerX, centerY);
4355 if (centerX && centerY && !args->current()) { 4355 if (centerX && centerY && !args->current()) {
4356 ASSERT(centerX->isPrimitiveValue()); 4356 shape->setCenterX(centerX);
4357 ASSERT(centerY->isPrimitiveValue()); 4357 shape->setCenterY(centerY);
4358 shape->setCenterX(toCSSPrimitiveValue(centerX.get()));
4359 shape->setCenterY(toCSSPrimitiveValue(centerY.get()));
4360 } else { 4358 } else {
4361 return nullptr; 4359 return nullptr;
4362 } 4360 }
4363 } else { 4361 } else {
4364 return nullptr; 4362 return nullptr;
4365 } 4363 }
4366 } 4364 }
4367 4365
4368 return shape; 4366 return shape;
4369 } 4367 }
(...skipping 30 matching lines...) Expand all
4400 } 4398 }
4401 4399
4402 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>) 4400 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(.. at <position>)
4403 return nullptr; 4401 return nullptr;
4404 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; 4402 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr;
4405 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; 4403 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr;
4406 parseFillPosition(args, centerX, centerY); 4404 parseFillPosition(args, centerX, centerY);
4407 if (!centerX || !centerY || args->current()) 4405 if (!centerX || !centerY || args->current())
4408 return nullptr; 4406 return nullptr;
4409 4407
4410 ASSERT(centerX->isPrimitiveValue()); 4408 shape->setCenterX(centerX);
4411 ASSERT(centerY->isPrimitiveValue()); 4409 shape->setCenterY(centerY);
4412 shape->setCenterX(toCSSPrimitiveValue(centerX.get()));
4413 shape->setCenterY(toCSSPrimitiveValue(centerY.get()));
4414 } 4410 }
4415 4411
4416 return shape; 4412 return shape;
4417 } 4413 }
4418 4414
4419 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args) 4415 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon( CSSParserValueList* args)
4420 { 4416 {
4421 ASSERT(args); 4417 ASSERT(args);
4422 4418
4423 unsigned size = args->size(); 4419 unsigned size = args->size();
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
5403 return true; 5399 return true;
5404 } 5400 }
5405 5401
5406 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue List* valueList) 5402 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue List* valueList)
5407 { 5403 {
5408 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; 5404 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr;
5409 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 5405 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr;
5410 parseFillPosition(valueList, xValue, yValue); 5406 parseFillPosition(valueList, xValue, yValue);
5411 if (!xValue || !yValue) 5407 if (!xValue || !yValue)
5412 return nullptr; 5408 return nullptr;
5413 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim itiveValue(yValue.get()), Pair::KeepIdenticalValues); 5409 return createCSSValuePair(xValue.release(), yValue.release(), CSSValuePair:: KeepIdenticalValues);
5414 } 5410 }
5415 5411
5416 // Parses a list of comma separated positions. i.e., <position># 5412 // Parses a list of comma separated positions. i.e., <position>#
5417 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar serValueList* valueList) 5413 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar serValueList* valueList)
5418 { 5414 {
5419 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted(); 5415 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara ted();
5420 while (true) { 5416 while (true) {
5421 // parsePosition consumes values until it reaches a separator [,/], 5417 // parsePosition consumes values until it reaches a separator [,/],
5422 // an invalid token, or end of the list 5418 // an invalid token, or end of the list
5423 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); 5419 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
5693 return false; 5689 return false;
5694 } else { 5690 } else {
5695 // We need to rewind the value list, so that when its advanced we'll 5691 // We need to rewind the value list, so that when its advanced we'll
5696 // end up back at this value. 5692 // end up back at this value.
5697 m_valueList->previous(); 5693 m_valueList->previous();
5698 secondValue = firstValue; 5694 secondValue = firstValue;
5699 } 5695 }
5700 } else 5696 } else
5701 secondValue = firstValue; 5697 secondValue = firstValue;
5702 5698
5703 result = createPrimitiveValuePair(firstValue, secondValue); 5699 result = createCSSValuePair(firstValue, secondValue);
5704 return true; 5700 return true;
5705 } 5701 }
5706 5702
5707 class BorderImageSliceParseContext { 5703 class BorderImageSliceParseContext {
5708 STACK_ALLOCATED(); 5704 STACK_ALLOCATED();
5709 public: 5705 public:
5710 BorderImageSliceParseContext() 5706 BorderImageSliceParseContext()
5711 : m_allowNumber(true) 5707 : m_allowNumber(true)
5712 , m_allowFill(true) 5708 , m_allowFill(true)
5713 , m_allowFinalCommit(false) 5709 , m_allowFinalCommit(false)
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
5951 } 5947 }
5952 5948
5953 if (!indexAfterSlash) { 5949 if (!indexAfterSlash) {
5954 completeBorderRadii(radii[0]); 5950 completeBorderRadii(radii[0]);
5955 for (unsigned i = 0; i < 4; ++i) 5951 for (unsigned i = 0; i < 4; ++i)
5956 radii[1][i] = radii[0][i]; 5952 radii[1][i] = radii[0][i];
5957 } else 5953 } else
5958 completeBorderRadii(radii[1]); 5954 completeBorderRadii(radii[1]);
5959 5955
5960 ImplicitScope implicitScope(this); 5956 ImplicitScope implicitScope(this);
5961 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0 ][0].release(), radii[1][0].release()), important); 5957 addProperty(CSSPropertyBorderTopLeftRadius, createCSSValuePair(radii[0][0].r elease(), radii[1][0].release()), important);
5962 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[ 0][1].release(), radii[1][1].release()), important); 5958 addProperty(CSSPropertyBorderTopRightRadius, createCSSValuePair(radii[0][1]. release(), radii[1][1].release()), important);
5963 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad ii[0][2].release(), radii[1][2].release()), important); 5959 addProperty(CSSPropertyBorderBottomRightRadius, createCSSValuePair(radii[0][ 2].release(), radii[1][2].release()), important);
5964 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi i[0][3].release(), radii[1][3].release()), important); 5960 addProperty(CSSPropertyBorderBottomLeftRadius, createCSSValuePair(radii[0][3 ].release(), radii[1][3].release()), important);
5965 return true; 5961 return true;
5966 } 5962 }
5967 5963
5968 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu e) 5964 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu e)
5969 { 5965 {
5970 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ; 5966 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
5971 5967
5972 while (m_valueList->current()) { 5968 while (m_valueList->current()) {
5973 CSSParserValue* val = m_valueList->current(); 5969 CSSParserValue* val = m_valueList->current();
5974 if (val->m_unit != CSSParserValue::Identifier) 5970 if (val->m_unit != CSSParserValue::Identifier)
5975 return nullptr; 5971 return nullptr;
5976 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val); 5972 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto mIdentValue(val);
5977 m_valueList->next(); 5973 m_valueList->next();
5978 5974
5979 val = m_valueList->current(); 5975 val = m_valueList->current();
5980 int i = defaultValue; 5976 int i = defaultValue;
5981 if (val && validUnit(val, FInteger)) { 5977 if (val && validUnit(val, FInteger)) {
5982 i = clampTo<int>(val->fValue); 5978 i = clampTo<int>(val->fValue);
5983 m_valueList->next(); 5979 m_valueList->next();
5984 } 5980 }
5985 5981
5986 list->append(createPrimitiveValuePair(counterName.release(), 5982 list->append(createCSSValuePair(counterName.release(),
5987 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number))) ; 5983 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number))) ;
5988 } 5984 }
5989 5985
5990 if (!list->length()) 5986 if (!list->length())
5991 return nullptr; 5987 return nullptr;
5992 return list.release(); 5988 return list.release();
5993 } 5989 }
5994 5990
5995 // This should go away once we drop support for -webkit-gradient 5991 // This should go away once we drop support for -webkit-gradient
5996 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS SParserValue* a, bool horizontal) 5992 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS SParserValue* a, bool horizontal)
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
6582 if (!a) 6578 if (!a)
6583 return false; 6579 return false;
6584 6580
6585 parseFillPosition(args, centerX, centerY); 6581 parseFillPosition(args, centerX, centerY);
6586 if (!(centerX && centerY)) 6582 if (!(centerX && centerY))
6587 return false; 6583 return false;
6588 6584
6589 a = args->current(); 6585 a = args->current();
6590 if (!a) 6586 if (!a)
6591 return false; 6587 return false;
6592 result->setFirstX(toCSSPrimitiveValue(centerX.get())); 6588 result->setFirstX(centerX);
6593 result->setFirstY(toCSSPrimitiveValue(centerY.get())); 6589 result->setFirstY(centerY);
6594 // Right now, CSS radial gradients have the same start and end centers. 6590 // Right now, CSS radial gradients have the same start and end centers.
6595 result->setSecondX(toCSSPrimitiveValue(centerX.get())); 6591 result->setSecondX(centerX);
6596 result->setSecondY(toCSSPrimitiveValue(centerY.get())); 6592 result->setSecondY(centerY);
6597 } 6593 }
6598 6594
6599 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) 6595 if (shapeValue || sizeValue || horizontalSize || centerX || centerY)
6600 expectComma = true; 6596 expectComma = true;
6601 6597
6602 if (!parseGradientColorStops(args, result.get(), expectComma)) 6598 if (!parseGradientColorStops(args, result.get(), expectComma))
6603 return false; 6599 return false;
6604 6600
6605 gradient = result.release(); 6601 gradient = result.release();
6606 return true; 6602 return true;
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
8092 } 8088 }
8093 } 8089 }
8094 8090
8095 if (!list->length()) 8091 if (!list->length())
8096 return nullptr; 8092 return nullptr;
8097 8093
8098 return list.release(); 8094 return list.release();
8099 } 8095 }
8100 8096
8101 } // namespace blink 8097 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698