OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | |
79 { | |
80 return cssValuePool().createValue(Pair::create(first, second, identicalValue
sPolicy)); | |
81 } | |
82 | |
83 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, | 78 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, |
84 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP
roperties, | 79 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP
roperties, |
85 StyleRule::Type ruleType) | 80 StyleRule::Type ruleType) |
86 : m_valueList(valueList) | 81 : m_valueList(valueList) |
87 , m_context(context) | 82 , m_context(context) |
88 , m_parsedProperties(parsedProperties) | 83 , m_parsedProperties(parsedProperties) |
89 , m_ruleType(ruleType) | 84 , m_ruleType(ruleType) |
90 , m_inParseShorthand(0) | 85 , m_inParseShorthand(0) |
91 , m_currentShorthand(CSSPropertyInvalid) | 86 , m_currentShorthand(CSSPropertyInvalid) |
92 , m_implicitShorthand(false) | 87 , m_implicitShorthand(false) |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 if (value) { | 975 if (value) { |
981 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); | 976 validPrimitive = validUnit(value, FLength | FPercent | FNonNeg); |
982 if (!validPrimitive) | 977 if (!validPrimitive) |
983 return false; | 978 return false; |
984 parsedValue2 = createPrimitiveNumericValue(value); | 979 parsedValue2 = createPrimitiveNumericValue(value); |
985 } else | 980 } else |
986 parsedValue2 = parsedValue1; | 981 parsedValue2 = parsedValue1; |
987 | 982 |
988 if (m_valueList->next()) | 983 if (m_valueList->next()) |
989 return false; | 984 return false; |
990 addProperty(propId, createPrimitiveValuePair(parsedValue1.release(), par
sedValue2.release()), important); | 985 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV
alue2.release(), CSSValuePair::DropIdenticalValues), important); |
991 return true; | 986 return true; |
992 } | 987 } |
993 case CSSPropertyTabSize: | 988 case CSSPropertyTabSize: |
994 // May be specified as a unit-less non-negative integer or length indica
ting number of space characters. | 989 // 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); | 990 validPrimitive = validUnit(value, FInteger | FLength | FNonNeg); |
996 break; | 991 break; |
997 case CSSPropertyBorderRadius: | 992 case CSSPropertyBorderRadius: |
998 case CSSPropertyAliasWebkitBorderRadius: | 993 case CSSPropertyAliasWebkitBorderRadius: |
999 return parseBorderRadius(unresolvedProperty, important); | 994 return parseBorderRadius(unresolvedProperty, important); |
1000 case CSSPropertyOutlineOffset: | 995 case CSSPropertyOutlineOffset: |
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2492 cumulativeFlags = 0; | 2487 cumulativeFlags = 0; |
2493 FillPositionFlag value4Flag = InvalidFillPosition; | 2488 FillPositionFlag value4Flag = InvalidFillPosition; |
2494 RefPtrWillBeRawPtr<CSSPrimitiveValue> value4 = parseFillPositionComponent(va
lueList, cumulativeFlags, value4Flag, ResolveValuesAsKeyword); | 2489 RefPtrWillBeRawPtr<CSSPrimitiveValue> value4 = parseFillPositionComponent(va
lueList, cumulativeFlags, value4Flag, ResolveValuesAsKeyword); |
2495 if (!value4) | 2490 if (!value4) |
2496 return; | 2491 return; |
2497 | 2492 |
2498 // 4th value must be a length or a percentage. | 2493 // 4th value must be a length or a percentage. |
2499 if (isFillPositionKeyword(value4->getValueID())) | 2494 if (isFillPositionKeyword(value4->getValueID())) |
2500 return; | 2495 return; |
2501 | 2496 |
2502 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); | 2497 value1 = CSSValuePair::create(parsedValue1, parsedValue2, CSSValuePair::Drop
IdenticalValues); |
2503 value2 = createPrimitiveValuePair(value3, value4); | 2498 value2 = CSSValuePair::create(value3, value4, CSSValuePair::DropIdenticalVal
ues); |
2504 | 2499 |
2505 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) | 2500 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) |
2506 value1.swap(value2); | 2501 value1.swap(value2); |
2507 | 2502 |
2508 valueList->next(); | 2503 valueList->next(); |
2509 } | 2504 } |
2510 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass
RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue2) | 2505 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList,
RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, Pass
RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue1, PassRefPtrWillBeRawPtr<CSSPr
imitiveValue> parsedValue2) |
2511 { | 2506 { |
2512 unsigned cumulativeFlags = 0; | 2507 unsigned cumulativeFlags = 0; |
2513 FillPositionFlag value3Flag = InvalidFillPosition; | 2508 FillPositionFlag value3Flag = InvalidFillPosition; |
(...skipping 20 matching lines...) Expand all Loading... |
2534 | 2529 |
2535 // If 'center' is the first keyword then the last one needs to be a leng
th. | 2530 // If 'center' is the first keyword then the last one needs to be a leng
th. |
2536 if (isFillPositionKeyword(ident3)) | 2531 if (isFillPositionKeyword(ident3)) |
2537 return; | 2532 return; |
2538 | 2533 |
2539 firstPositionKeyword = CSSValueLeft; | 2534 firstPositionKeyword = CSSValueLeft; |
2540 if (ident2 == CSSValueLeft || ident2 == CSSValueRight) { | 2535 if (ident2 == CSSValueLeft || ident2 == CSSValueRight) { |
2541 firstPositionKeyword = CSSValueTop; | 2536 firstPositionKeyword = CSSValueTop; |
2542 swapNeeded = true; | 2537 swapNeeded = true; |
2543 } | 2538 } |
2544 value1 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(f
irstPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitType
::Percentage)); | 2539 value1 = CSSValuePair::create(cssValuePool().createIdentifierValue(first
PositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Pe
rcentage), CSSValuePair::DropIdenticalValues); |
2545 value2 = createPrimitiveValuePair(parsedValue2, value3); | 2540 value2 = CSSValuePair::create(parsedValue2, value3, CSSValuePair::DropId
enticalValues); |
2546 } else if (ident3 == CSSValueCenter) { | 2541 } else if (ident3 == CSSValueCenter) { |
2547 if (isFillPositionKeyword(ident2)) | 2542 if (isFillPositionKeyword(ident2)) |
2548 return; | 2543 return; |
2549 | 2544 |
2550 secondPositionKeyword = CSSValueTop; | 2545 secondPositionKeyword = CSSValueTop; |
2551 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) { | 2546 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) { |
2552 secondPositionKeyword = CSSValueLeft; | 2547 secondPositionKeyword = CSSValueLeft; |
2553 swapNeeded = true; | 2548 swapNeeded = true; |
2554 } | 2549 } |
2555 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); | 2550 value1 = CSSValuePair::create(parsedValue1, parsedValue2, CSSValuePair::
DropIdenticalValues); |
2556 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s
econdPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitTyp
e::Percentage)); | 2551 value2 = CSSValuePair::create(cssValuePool().createIdentifierValue(secon
dPositionKeyword), cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::P
ercentage), CSSValuePair::DropIdenticalValues); |
2557 } else { | 2552 } else { |
2558 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPositionValue = nullptr; | 2553 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPositionValue = nullptr; |
2559 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPositionValue = nullptr; | 2554 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPositionValue = nullptr; |
2560 | 2555 |
2561 if (isFillPositionKeyword(ident2)) { | 2556 if (isFillPositionKeyword(ident2)) { |
2562 // To match CSS grammar, we should only accept: [ center | left | ri
ght | bottom | top ] [ left | right | top | bottom ] [ <percentage> | <length> ]
. | 2557 // To match CSS grammar, we should only accept: [ center | left | ri
ght | bottom | top ] [ left | right | top | bottom ] [ <percentage> | <length> ]
. |
2563 ASSERT(ident2 != CSSValueCenter); | 2558 ASSERT(ident2 != CSSValueCenter); |
2564 | 2559 |
2565 if (isFillPositionKeyword(ident3)) | 2560 if (isFillPositionKeyword(ident3)) |
2566 return; | 2561 return; |
2567 | 2562 |
2568 secondPositionValue = value3; | 2563 secondPositionValue = value3; |
2569 secondPositionKeyword = ident2; | 2564 secondPositionKeyword = ident2; |
2570 firstPositionValue = cssValuePool().createValue(0, CSSPrimitiveValue
::UnitType::Percentage); | 2565 firstPositionValue = cssValuePool().createValue(0, CSSPrimitiveValue
::UnitType::Percentage); |
2571 } else { | 2566 } else { |
2572 // Per CSS, we should only accept: [ right | left | top | bottom ] [
<percentage> | <length> ] [ center | left | right | bottom | top ]. | 2567 // Per CSS, we should only accept: [ right | left | top | bottom ] [
<percentage> | <length> ] [ center | left | right | bottom | top ]. |
2573 if (!isFillPositionKeyword(ident3)) | 2568 if (!isFillPositionKeyword(ident3)) |
2574 return; | 2569 return; |
2575 | 2570 |
2576 firstPositionValue = parsedValue2; | 2571 firstPositionValue = parsedValue2; |
2577 secondPositionKeyword = ident3; | 2572 secondPositionKeyword = ident3; |
2578 secondPositionValue = cssValuePool().createValue(0, CSSPrimitiveValu
e::UnitType::Percentage); | 2573 secondPositionValue = cssValuePool().createValue(0, CSSPrimitiveValu
e::UnitType::Percentage); |
2579 } | 2574 } |
2580 | 2575 |
2581 if (isValueConflictingWithCurrentEdge(ident1, secondPositionKeyword)) | 2576 if (isValueConflictingWithCurrentEdge(ident1, secondPositionKeyword)) |
2582 return; | 2577 return; |
2583 | 2578 |
2584 value1 = createPrimitiveValuePair(parsedValue1, firstPositionValue); | 2579 value1 = CSSValuePair::create(parsedValue1, firstPositionValue, CSSValue
Pair::DropIdenticalValues); |
2585 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s
econdPositionKeyword), secondPositionValue); | 2580 value2 = CSSValuePair::create(cssValuePool().createIdentifierValue(secon
dPositionKeyword), secondPositionValue, CSSValuePair::DropIdenticalValues); |
2586 } | 2581 } |
2587 | 2582 |
2588 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) | 2583 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) |
2589 value1.swap(value2); | 2584 value1.swap(value2); |
2590 | 2585 |
2591 #if ENABLE(ASSERT) | 2586 #if ENABLE(ASSERT) |
2592 CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get()); | 2587 const CSSValuePair* first = toCSSValuePair(value1.get()); |
2593 CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get()); | 2588 const CSSValuePair* second = toCSSValuePair(value2.get()); |
2594 ident1 = first->getPairValue()->first()->getValueID(); | 2589 ident1 = toCSSPrimitiveValue(first->first())->getValueID(); |
2595 ident2 = second->getPairValue()->first()->getValueID(); | 2590 ident2 = toCSSPrimitiveValue(second->first())->getValueID(); |
2596 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); | 2591 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); |
2597 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); | 2592 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); |
2598 #endif | 2593 #endif |
2599 } | 2594 } |
2600 | 2595 |
2601 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) | 2596 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) |
2602 { | 2597 { |
2603 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); | 2598 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng
th, ReleaseParsedCalcValue); |
2604 } | 2599 } |
2605 | 2600 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { | 2776 } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { |
2782 // For backwards compatibility we set the second value to the first if i
t is omitted. | 2777 // For backwards compatibility we set the second value to the first if i
t is omitted. |
2783 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match | 2778 // We only need to do this for -webkit-background-size. It should be saf
e to let masks match |
2784 // the real property. | 2779 // the real property. |
2785 parsedValue2 = parsedValue1; | 2780 parsedValue2 = parsedValue1; |
2786 } | 2781 } |
2787 | 2782 |
2788 if (!parsedValue2) | 2783 if (!parsedValue2) |
2789 return parsedValue1; | 2784 return parsedValue1; |
2790 | 2785 |
2791 return createPrimitiveValuePair(parsedValue1.release(), parsedValue2.release
(), Pair::KeepIdenticalValues); | 2786 return CSSValuePair::create(parsedValue1.release(), parsedValue2.release(),
CSSValuePair::KeepIdenticalValues); |
2792 } | 2787 } |
2793 | 2788 |
2794 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, | 2789 bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
ropId1, CSSPropertyID& propId2, |
2795 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa
lue2) | 2790 RefPtrWillBeRawPtr<CSSValue>& retValue1, RefPtrWillBeRawPtr<CSSValue>& retVa
lue2) |
2796 { | 2791 { |
2797 // We initially store the first value in value/value2, and only create | 2792 // We initially store the first value in value/value2, and only create |
2798 // CSSValueLists if we have more values. | 2793 // CSSValueLists if we have more values. |
2799 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; | 2794 RefPtrWillBeRawPtr<CSSValueList> values = nullptr; |
2800 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; | 2795 RefPtrWillBeRawPtr<CSSValueList> values2 = nullptr; |
2801 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 2796 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4099 radii[1][i - indexAfterSlash] = radius.release(); | 4094 radii[1][i - indexAfterSlash] = radius.release(); |
4100 } | 4095 } |
4101 | 4096 |
4102 if (!indexAfterSlash) { | 4097 if (!indexAfterSlash) { |
4103 completeBorderRadii(radii[0]); | 4098 completeBorderRadii(radii[0]); |
4104 for (unsigned i = 0; i < 4; ++i) | 4099 for (unsigned i = 0; i < 4; ++i) |
4105 radii[1][i] = radii[0][i]; | 4100 radii[1][i] = radii[0][i]; |
4106 } else { | 4101 } else { |
4107 completeBorderRadii(radii[1]); | 4102 completeBorderRadii(radii[1]); |
4108 } | 4103 } |
4109 shape->setTopLeftRadius(createPrimitiveValuePair(radii[0][0].release(), radi
i[1][0].release())); | 4104 shape->setTopLeftRadius(CSSValuePair::create(radii[0][0].release(), radii[1]
[0].release(), CSSValuePair::DropIdenticalValues)); |
4110 shape->setTopRightRadius(createPrimitiveValuePair(radii[0][1].release(), rad
ii[1][1].release())); | 4105 shape->setTopRightRadius(CSSValuePair::create(radii[0][1].release(), radii[1
][1].release(), CSSValuePair::DropIdenticalValues)); |
4111 shape->setBottomRightRadius(createPrimitiveValuePair(radii[0][2].release(),
radii[1][2].release())); | 4106 shape->setBottomRightRadius(CSSValuePair::create(radii[0][2].release(), radi
i[1][2].release(), CSSValuePair::DropIdenticalValues)); |
4112 shape->setBottomLeftRadius(createPrimitiveValuePair(radii[0][3].release(), r
adii[1][3].release())); | 4107 shape->setBottomLeftRadius(CSSValuePair::create(radii[0][3].release(), radii
[1][3].release(), CSSValuePair::DropIdenticalValues)); |
4113 | 4108 |
4114 return shape; | 4109 return shape; |
4115 } | 4110 } |
4116 | 4111 |
4117 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS
SParserValueList* args) | 4112 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS
SParserValueList* args) |
4118 { | 4113 { |
4119 ASSERT(args); | 4114 ASSERT(args); |
4120 | 4115 |
4121 RefPtrWillBeRawPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create(); | 4116 RefPtrWillBeRawPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create(); |
4122 | 4117 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4207 return false; | 4202 return false; |
4208 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->i
d != CSSValueRight) | 4203 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->i
d != CSSValueRight) |
4209 return false; | 4204 return false; |
4210 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value
->id == CSSValueRight) { | 4205 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value
->id == CSSValueRight) { |
4211 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) | 4206 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy
) |
4212 return false; | 4207 return false; |
4213 } else { | 4208 } else { |
4214 return false; | 4209 return false; |
4215 } | 4210 } |
4216 | 4211 |
4217 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifier
Value(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), importa
nt); | 4212 addProperty(propId, CSSValuePair::create(cssValuePool().createIdentifierValu
e(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id), CSSValuePair
::DropIdenticalValues), important); |
4218 return !m_valueList->next(); | 4213 return !m_valueList->next(); |
4219 } | 4214 } |
4220 | 4215 |
4221 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver
flowPosition() | 4216 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseContentDistributionOver
flowPosition() |
4222 { | 4217 { |
4223 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] | 4218 // auto | <baseline-position> | <content-distribution> || [ <overflow-positi
on>? && <content-position> ] |
4224 // <baseline-position> = baseline | last-baseline; | 4219 // <baseline-position> = baseline | last-baseline; |
4225 // <content-distribution> = space-between | space-around | space-evenly | st
retch; | 4220 // <content-distribution> = space-between | space-around | space-evenly | st
retch; |
4226 // <content-position> = center | start | end | flex-start | flex-end | left
| right; | 4221 // <content-position> = center | start | end | flex-start | flex-end | left
| right; |
4227 // <overflow-position> = true | safe | 4222 // <overflow-position> = true | safe |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4305 return false; | 4300 return false; |
4306 } else { | 4301 } else { |
4307 return false; | 4302 return false; |
4308 } | 4303 } |
4309 | 4304 |
4310 if (m_valueList->next()) | 4305 if (m_valueList->next()) |
4311 return false; | 4306 return false; |
4312 | 4307 |
4313 ASSERT(position); | 4308 ASSERT(position); |
4314 if (overflowAlignmentKeyword) | 4309 if (overflowAlignmentKeyword) |
4315 addProperty(propId, createPrimitiveValuePair(position, overflowAlignment
Keyword), important); | 4310 addProperty(propId, CSSValuePair::create(position, overflowAlignmentKeyw
ord, CSSValuePair::DropIdenticalValues), important); |
4316 else | 4311 else |
4317 addProperty(propId, position.release(), important); | 4312 addProperty(propId, position.release(), important); |
4318 | 4313 |
4319 return true; | 4314 return true; |
4320 } | 4315 } |
4321 | 4316 |
4322 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) | 4317 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseShapeRadius(CS
SParserValue* value) |
4323 { | 4318 { |
4324 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) | 4319 if (value->id == CSSValueClosestSide || value->id == CSSValueFarthestSide) |
4325 return cssValuePool().createIdentifierValue(value->id); | 4320 return cssValuePool().createIdentifierValue(value->id); |
(...skipping 28 matching lines...) Expand all Loading... |
4354 } | 4349 } |
4355 | 4350 |
4356 return nullptr; | 4351 return nullptr; |
4357 } | 4352 } |
4358 | 4353 |
4359 if (argument->id == CSSValueAt && args->next()) { | 4354 if (argument->id == CSSValueAt && args->next()) { |
4360 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 4355 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; |
4361 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 4356 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; |
4362 parseFillPosition(args, centerX, centerY); | 4357 parseFillPosition(args, centerX, centerY); |
4363 if (centerX && centerY && !args->current()) { | 4358 if (centerX && centerY && !args->current()) { |
4364 ASSERT(centerX->isPrimitiveValue()); | 4359 shape->setCenterX(centerX); |
4365 ASSERT(centerY->isPrimitiveValue()); | 4360 shape->setCenterY(centerY); |
4366 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | |
4367 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | |
4368 } else { | 4361 } else { |
4369 return nullptr; | 4362 return nullptr; |
4370 } | 4363 } |
4371 } else { | 4364 } else { |
4372 return nullptr; | 4365 return nullptr; |
4373 } | 4366 } |
4374 } | 4367 } |
4375 | 4368 |
4376 return shape; | 4369 return shape; |
4377 } | 4370 } |
(...skipping 30 matching lines...) Expand all Loading... |
4408 } | 4401 } |
4409 | 4402 |
4410 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) | 4403 if (argument->id != CSSValueAt || !args->next()) // expecting ellipse(..
at <position>) |
4411 return nullptr; | 4404 return nullptr; |
4412 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; | 4405 RefPtrWillBeRawPtr<CSSValue> centerX = nullptr; |
4413 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; | 4406 RefPtrWillBeRawPtr<CSSValue> centerY = nullptr; |
4414 parseFillPosition(args, centerX, centerY); | 4407 parseFillPosition(args, centerX, centerY); |
4415 if (!centerX || !centerY || args->current()) | 4408 if (!centerX || !centerY || args->current()) |
4416 return nullptr; | 4409 return nullptr; |
4417 | 4410 |
4418 ASSERT(centerX->isPrimitiveValue()); | 4411 shape->setCenterX(centerX); |
4419 ASSERT(centerY->isPrimitiveValue()); | 4412 shape->setCenterY(centerY); |
4420 shape->setCenterX(toCSSPrimitiveValue(centerX.get())); | |
4421 shape->setCenterY(toCSSPrimitiveValue(centerY.get())); | |
4422 } | 4413 } |
4423 | 4414 |
4424 return shape; | 4415 return shape; |
4425 } | 4416 } |
4426 | 4417 |
4427 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) | 4418 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
CSSParserValueList* args) |
4428 { | 4419 { |
4429 ASSERT(args); | 4420 ASSERT(args); |
4430 | 4421 |
4431 unsigned size = args->size(); | 4422 unsigned size = args->size(); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5411 return true; | 5402 return true; |
5412 } | 5403 } |
5413 | 5404 |
5414 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue
List* valueList) | 5405 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValue
List* valueList) |
5415 { | 5406 { |
5416 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 5407 RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; |
5417 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 5408 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; |
5418 parseFillPosition(valueList, xValue, yValue); | 5409 parseFillPosition(valueList, xValue, yValue); |
5419 if (!xValue || !yValue) | 5410 if (!xValue || !yValue) |
5420 return nullptr; | 5411 return nullptr; |
5421 return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrim
itiveValue(yValue.get()), Pair::KeepIdenticalValues); | 5412 return CSSValuePair::create(xValue.release(), yValue.release(), CSSValuePair
::KeepIdenticalValues); |
5422 } | 5413 } |
5423 | 5414 |
5424 // Parses a list of comma separated positions. i.e., <position># | 5415 // Parses a list of comma separated positions. i.e., <position># |
5425 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar
serValueList* valueList) | 5416 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parsePositionList(CSSPar
serValueList* valueList) |
5426 { | 5417 { |
5427 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara
ted(); | 5418 RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createCommaSepara
ted(); |
5428 while (true) { | 5419 while (true) { |
5429 // parsePosition consumes values until it reaches a separator [,/], | 5420 // parsePosition consumes values until it reaches a separator [,/], |
5430 // an invalid token, or end of the list | 5421 // an invalid token, or end of the list |
5431 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); | 5422 RefPtrWillBeRawPtr<CSSValue> position = parsePosition(valueList); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5701 return false; | 5692 return false; |
5702 } else { | 5693 } else { |
5703 // We need to rewind the value list, so that when its advanced we'll | 5694 // We need to rewind the value list, so that when its advanced we'll |
5704 // end up back at this value. | 5695 // end up back at this value. |
5705 m_valueList->previous(); | 5696 m_valueList->previous(); |
5706 secondValue = firstValue; | 5697 secondValue = firstValue; |
5707 } | 5698 } |
5708 } else | 5699 } else |
5709 secondValue = firstValue; | 5700 secondValue = firstValue; |
5710 | 5701 |
5711 result = createPrimitiveValuePair(firstValue, secondValue); | 5702 result = CSSValuePair::create(firstValue, secondValue, CSSValuePair::DropIde
nticalValues); |
5712 return true; | 5703 return true; |
5713 } | 5704 } |
5714 | 5705 |
5715 class BorderImageSliceParseContext { | 5706 class BorderImageSliceParseContext { |
5716 STACK_ALLOCATED(); | 5707 STACK_ALLOCATED(); |
5717 public: | 5708 public: |
5718 BorderImageSliceParseContext() | 5709 BorderImageSliceParseContext() |
5719 : m_allowNumber(true) | 5710 : m_allowNumber(true) |
5720 , m_allowFill(true) | 5711 , m_allowFill(true) |
5721 , m_allowFinalCommit(false) | 5712 , m_allowFinalCommit(false) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5959 } | 5950 } |
5960 | 5951 |
5961 if (!indexAfterSlash) { | 5952 if (!indexAfterSlash) { |
5962 completeBorderRadii(radii[0]); | 5953 completeBorderRadii(radii[0]); |
5963 for (unsigned i = 0; i < 4; ++i) | 5954 for (unsigned i = 0; i < 4; ++i) |
5964 radii[1][i] = radii[0][i]; | 5955 radii[1][i] = radii[0][i]; |
5965 } else | 5956 } else |
5966 completeBorderRadii(radii[1]); | 5957 completeBorderRadii(radii[1]); |
5967 | 5958 |
5968 ImplicitScope implicitScope(this); | 5959 ImplicitScope implicitScope(this); |
5969 addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0
][0].release(), radii[1][0].release()), important); | 5960 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0][0]
.release(), radii[1][0].release(), CSSValuePair::DropIdenticalValues), important
); |
5970 addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[
0][1].release(), radii[1][1].release()), important); | 5961 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[0][1
].release(), radii[1][1].release(), CSSValuePair::DropIdenticalValues), importan
t); |
5971 addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(rad
ii[0][2].release(), radii[1][2].release()), important); | 5962 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(radii[0
][2].release(), radii[1][2].release(), CSSValuePair::DropIdenticalValues), impor
tant); |
5972 addProperty(CSSPropertyBorderBottomLeftRadius, createPrimitiveValuePair(radi
i[0][3].release(), radii[1][3].release()), important); | 5963 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radii[0]
[3].release(), radii[1][3].release(), CSSValuePair::DropIdenticalValues), import
ant); |
5973 return true; | 5964 return true; |
5974 } | 5965 } |
5975 | 5966 |
5976 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu
e) | 5967 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu
e) |
5977 { | 5968 { |
5978 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 5969 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
5979 | 5970 |
5980 while (m_valueList->current()) { | 5971 while (m_valueList->current()) { |
5981 CSSParserValue* val = m_valueList->current(); | 5972 CSSParserValue* val = m_valueList->current(); |
5982 if (val->m_unit != CSSParserValue::Identifier) | 5973 if (val->m_unit != CSSParserValue::Identifier) |
5983 return nullptr; | 5974 return nullptr; |
5984 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto
mIdentValue(val); | 5975 RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveCusto
mIdentValue(val); |
5985 m_valueList->next(); | 5976 m_valueList->next(); |
5986 | 5977 |
5987 val = m_valueList->current(); | 5978 val = m_valueList->current(); |
5988 int i = defaultValue; | 5979 int i = defaultValue; |
5989 if (val && validUnit(val, FInteger)) { | 5980 if (val && validUnit(val, FInteger)) { |
5990 i = clampTo<int>(val->fValue); | 5981 i = clampTo<int>(val->fValue); |
5991 m_valueList->next(); | 5982 m_valueList->next(); |
5992 } | 5983 } |
5993 | 5984 |
5994 list->append(createPrimitiveValuePair(counterName.release(), | 5985 list->append(CSSValuePair::create(counterName.release(), |
5995 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number)))
; | 5986 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number), |
| 5987 CSSValuePair::DropIdenticalValues)); |
5996 } | 5988 } |
5997 | 5989 |
5998 if (!list->length()) | 5990 if (!list->length()) |
5999 return nullptr; | 5991 return nullptr; |
6000 return list.release(); | 5992 return list.release(); |
6001 } | 5993 } |
6002 | 5994 |
6003 // This should go away once we drop support for -webkit-gradient | 5995 // This should go away once we drop support for -webkit-gradient |
6004 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) | 5996 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) |
6005 { | 5997 { |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6590 if (!a) | 6582 if (!a) |
6591 return false; | 6583 return false; |
6592 | 6584 |
6593 parseFillPosition(args, centerX, centerY); | 6585 parseFillPosition(args, centerX, centerY); |
6594 if (!(centerX && centerY)) | 6586 if (!(centerX && centerY)) |
6595 return false; | 6587 return false; |
6596 | 6588 |
6597 a = args->current(); | 6589 a = args->current(); |
6598 if (!a) | 6590 if (!a) |
6599 return false; | 6591 return false; |
6600 result->setFirstX(toCSSPrimitiveValue(centerX.get())); | 6592 result->setFirstX(centerX); |
6601 result->setFirstY(toCSSPrimitiveValue(centerY.get())); | 6593 result->setFirstY(centerY); |
6602 // Right now, CSS radial gradients have the same start and end centers. | 6594 // Right now, CSS radial gradients have the same start and end centers. |
6603 result->setSecondX(toCSSPrimitiveValue(centerX.get())); | 6595 result->setSecondX(centerX); |
6604 result->setSecondY(toCSSPrimitiveValue(centerY.get())); | 6596 result->setSecondY(centerY); |
6605 } | 6597 } |
6606 | 6598 |
6607 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) | 6599 if (shapeValue || sizeValue || horizontalSize || centerX || centerY) |
6608 expectComma = true; | 6600 expectComma = true; |
6609 | 6601 |
6610 if (!parseGradientColorStops(args, result.get(), expectComma)) | 6602 if (!parseGradientColorStops(args, result.get(), expectComma)) |
6611 return false; | 6603 return false; |
6612 | 6604 |
6613 gradient = result.release(); | 6605 gradient = result.release(); |
6614 return true; | 6606 return true; |
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8100 } | 8092 } |
8101 } | 8093 } |
8102 | 8094 |
8103 if (!list->length()) | 8095 if (!list->length()) |
8104 return nullptr; | 8096 return nullptr; |
8105 | 8097 |
8106 return list.release(); | 8098 return list.release(); |
8107 } | 8099 } |
8108 | 8100 |
8109 } // namespace blink | 8101 } // namespace blink |
OLD | NEW |