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

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

Issue 1233363002: CSSValue Immediates: Replace CSSPrimitiveValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_4_attempt_2
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/CSSToStyleMap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 CSSPrimitiveValue createPrimitiveValuePair(CSSPrimitiveValue first, CSSPr imitiveValue second, Pair::IdenticalValuesPolicy identicalValuesPolicy = Pair::D ropIdenticalValues) 78 static CSSPrimitiveValue createPrimitiveValuePair(const CSSPrimitiveValue& first , const CSSPrimitiveValue& second, Pair::IdenticalValuesPolicy identicalValuesPo licy = Pair::DropIdenticalValues)
79 { 79 {
80 return cssValuePool().createValue(Pair::create(first, second, identicalValue sPolicy)); 80 return cssValuePool().createValue(Pair::create(first, second, identicalValue sPolicy));
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)
(...skipping 26 matching lines...) Expand all
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, CSSValue value, bool i mportant, bool implicit) 125 void CSSPropertyParser::addProperty(CSSPropertyID propId, const CSSValue& value, bool important, 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 if (m_valueList->size() != 1) 512 if (m_valueList->size() != 1)
513 return false; 513 return false;
514 return parseFontWeight(important); 514 return parseFontWeight(important);
515 } 515 }
516 516
517 case CSSPropertyBorderSpacing: { 517 case CSSPropertyBorderSpacing: {
518 if (num == 1) { 518 if (num == 1) {
519 ShorthandScope scope(this, CSSPropertyBorderSpacing); 519 ShorthandScope scope(this, CSSPropertyBorderSpacing);
520 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) ) 520 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) )
521 return false; 521 return false;
522 CSSValue value = m_parsedProperties.last().value(); 522 const CSSValue& value = m_parsedProperties.last().value();
523 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important ); 523 addProperty(CSSPropertyWebkitBorderVerticalSpacing, value, important );
524 return true; 524 return true;
525 } 525 }
526 else if (num == 2) { 526 else if (num == 2) {
527 ShorthandScope scope(this, CSSPropertyBorderSpacing); 527 ShorthandScope scope(this, CSSPropertyBorderSpacing);
528 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important)) 528 if (!parseValue(CSSPropertyWebkitBorderHorizontalSpacing, important) || !parseValue(CSSPropertyWebkitBorderVerticalSpacing, important))
529 return false; 529 return false;
530 return true; 530 return true;
531 } 531 }
532 return false; 532 return false;
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 ASSERT(!m_parsedCalculation); 1554 ASSERT(!m_parsedCalculation);
1555 if (parsedValue) { 1555 if (parsedValue) {
1556 if (!m_valueList->current() || inShorthand()) { 1556 if (!m_valueList->current() || inShorthand()) {
1557 addProperty(propId, *parsedValue, important); 1557 addProperty(propId, *parsedValue, important);
1558 return true; 1558 return true;
1559 } 1559 }
1560 } 1560 }
1561 return false; 1561 return false;
1562 } 1562 }
1563 1563
1564 void CSSPropertyParser::addFillValue(NullableCSSValue& lval, CSSValue rval) 1564 void CSSPropertyParser::addFillValue(NullableCSSValue& lval, const CSSValue& rva l)
1565 { 1565 {
1566 if (lval) { 1566 if (lval) {
1567 if (lval->isBaseValueList()) 1567 if (lval->isBaseValueList())
1568 toCSSValueList(lval)->append(rval); 1568 toCSSValueList(lval)->append(rval);
1569 else { 1569 else {
1570 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated(); 1570 PassRefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createComm aSeparated();
1571 list->append(*lval); 1571 list->append(*lval);
1572 list->append(rval); 1572 list->append(rval);
1573 lval = list; 1573 lval = list;
1574 } 1574 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 } 1743 }
1744 1744
1745 static bool isValidTransitionPropertyList(CSSValueList* value) 1745 static bool isValidTransitionPropertyList(CSSValueList* value)
1746 { 1746 {
1747 if (value->length() < 2) 1747 if (value->length() < 2)
1748 return true; 1748 return true;
1749 for (auto& property : *value) { 1749 for (auto& property : *value) {
1750 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip 1750 // FIXME: Shorthand parsing shouldn't add initial to the list since it w on't round-trip
1751 if (property.isInitialValue()) 1751 if (property.isInitialValue())
1752 continue; 1752 continue;
1753 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(property); 1753 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(property);
1754 if (primitiveValue.isValueID() && primitiveValue.getValueID() == CSSValu eNone) 1754 if (primitiveValue.isValueID() && primitiveValue.getValueID() == CSSValu eNone)
1755 return false; 1755 return false;
1756 } 1756 }
1757 return true; 1757 return true;
1758 } 1758 }
1759 1759
1760 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant) 1760 bool CSSPropertyParser::parseAnimationShorthand(bool useLegacyparsing, bool impo rtant)
1761 { 1761 {
1762 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing(); 1762 const StylePropertyShorthand& animationProperties = animationShorthandForPar sing();
1763 const unsigned numProperties = 8; 1763 const unsigned numProperties = 8;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 2009
2010 int num = inShorthand() ? 1 : m_valueList->size(); 2010 int num = inShorthand() ? 1 : m_valueList->size();
2011 2011
2012 ShorthandScope scope(this, propId); 2012 ShorthandScope scope(this, propId);
2013 2013
2014 // the order is top, right, bottom, left 2014 // the order is top, right, bottom, left
2015 switch (num) { 2015 switch (num) {
2016 case 1: { 2016 case 1: {
2017 if (!parseValue(properties[0], important)) 2017 if (!parseValue(properties[0], important))
2018 return false; 2018 return false;
2019 CSSValue value = m_parsedProperties.last().value(); 2019 const CSSValue& value = m_parsedProperties.last().value();
2020 ImplicitScope implicitScope(this); 2020 ImplicitScope implicitScope(this);
2021 addProperty(properties[1], value, important); 2021 addProperty(properties[1], value, important);
2022 addProperty(properties[2], value, important); 2022 addProperty(properties[2], value, important);
2023 addProperty(properties[3], value, important); 2023 addProperty(properties[3], value, important);
2024 break; 2024 break;
2025 } 2025 }
2026 case 2: { 2026 case 2: {
2027 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important)) 2027 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important))
2028 return false; 2028 return false;
2029 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue(); 2029 const CSSValue& value = m_parsedProperties[m_parsedProperties.size() - 2].value();
2030 ImplicitScope implicitScope(this); 2030 ImplicitScope implicitScope(this);
2031 addProperty(properties[2], value, important); 2031 addProperty(properties[2], value, important);
2032 value = m_parsedProperties[m_parsedProperties.size() - 2].value();
2033 addProperty(properties[3], value, important); 2032 addProperty(properties[3], value, important);
2034 break; 2033 break;
2035 } 2034 }
2036 case 3: { 2035 case 3: {
2037 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important)) 2036 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || !parseValue(properties[2], important))
2038 return false; 2037 return false;
2039 CSSValue value = m_parsedProperties[m_parsedProperties.size() - 2].v alue(); 2038 const CSSValue& value = m_parsedProperties[m_parsedProperties.size() - 2].value();
2040 ImplicitScope implicitScope(this); 2039 ImplicitScope implicitScope(this);
2041 addProperty(properties[3], value, important); 2040 addProperty(properties[3], value, important);
2042 break; 2041 break;
2043 } 2042 }
2044 case 4: { 2043 case 4: {
2045 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) || 2044 if (!parseValue(properties[0], important) || !parseValue(properties[ 1], important) ||
2046 !parseValue(properties[2], important) || !parseValue(properties[ 3], important)) 2045 !parseValue(properties[2], important) || !parseValue(properties[ 3], important))
2047 return false; 2046 return false;
2048 break; 2047 break;
2049 } 2048 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 return true; 2475 return true;
2477 2476
2478 return false; 2477 return false;
2479 } 2478 }
2480 2479
2481 static bool isFillPositionKeyword(CSSValueID value) 2480 static bool isFillPositionKeyword(CSSValueID value)
2482 { 2481 {
2483 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter; 2482 return value == CSSValueLeft || value == CSSValueTop || value == CSSValueBot tom || value == CSSValueRight || value == CSSValueCenter;
2484 } 2483 }
2485 2484
2486 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, CSSPrimitiveValue parsedValu e1, CSSPrimitiveValue parsedValue2) 2485 void CSSPropertyParser::parse4ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, const CSSPrimitiveValue& par sedValue1, const CSSPrimitiveValue& parsedValue2)
2487 { 2486 {
2488 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ] 2487 // [ left | right ] [ <percentage] | <length> ] && [ top | bottom ] [ <perce ntage> | <length> ]
2489 // In the case of 4 values <position> requires the second value to be a leng th or a percentage. 2488 // In the case of 4 values <position> requires the second value to be a leng th or a percentage.
2490 if (isFillPositionKeyword(parsedValue2.getValueID())) 2489 if (isFillPositionKeyword(parsedValue2.getValueID()))
2491 return; 2490 return;
2492 2491
2493 unsigned cumulativeFlags = 0; 2492 unsigned cumulativeFlags = 0;
2494 FillPositionFlag value3Flag = InvalidFillPosition; 2493 FillPositionFlag value3Flag = InvalidFillPosition;
2495 NullableCSSValue value3 = parseFillPositionComponent(valueList, cumulativeFl ags, value3Flag, ResolveValuesAsKeyword); 2494 NullableCSSValue value3 = parseFillPositionComponent(valueList, cumulativeFl ags, value3Flag, ResolveValuesAsKeyword);
2496 if (!value3) 2495 if (!value3)
(...skipping 27 matching lines...) Expand all
2524 return; 2523 return;
2525 2524
2526 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2); 2525 value1 = createPrimitiveValuePair(parsedValue1, parsedValue2);
2527 value2 = createPrimitiveValuePair(toCSSPrimitiveValue(*value3), toCSSPrimiti veValue(*value4)); 2526 value2 = createPrimitiveValuePair(toCSSPrimitiveValue(*value3), toCSSPrimiti veValue(*value4));
2528 2527
2529 if (ident1 == CSSValueTop || ident1 == CSSValueBottom) 2528 if (ident1 == CSSValueTop || ident1 == CSSValueBottom)
2530 value1.swap(value2); 2529 value1.swap(value2);
2531 2530
2532 valueList->next(); 2531 valueList->next();
2533 } 2532 }
2534 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, CSSPrimitiveValue parsedValu e1, CSSPrimitiveValue parsedValue2) 2533 void CSSPropertyParser::parse3ValuesFillPosition(CSSParserValueList* valueList, NullableCSSValue& value1, NullableCSSValue& value2, const CSSPrimitiveValue& par sedValue1, const CSSPrimitiveValue& parsedValue2)
2535 { 2534 {
2536 unsigned cumulativeFlags = 0; 2535 unsigned cumulativeFlags = 0;
2537 FillPositionFlag value3Flag = InvalidFillPosition; 2536 FillPositionFlag value3Flag = InvalidFillPosition;
2538 NullableCSSValue value3 = parseFillPositionComponent(valueList, cumulativeFl ags, value3Flag, ResolveValuesAsKeyword); 2537 NullableCSSValue value3 = parseFillPositionComponent(valueList, cumulativeFl ags, value3Flag, ResolveValuesAsKeyword);
2539 2538
2540 // value3 is not an expected value, we return. 2539 // value3 is not an expected value, we return.
2541 if (!value3) 2540 if (!value3)
2542 return; 2541 return;
2543 2542
2544 valueList->next(); 2543 valueList->next();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 return; 2605 return;
2607 2606
2608 value1 = createPrimitiveValuePair(parsedValue1, toCSSPrimitiveValue(*fir stPositionValue)); 2607 value1 = createPrimitiveValuePair(parsedValue1, toCSSPrimitiveValue(*fir stPositionValue));
2609 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), toCSSPrimitiveValue(*secondPositionValue)); 2608 value2 = createPrimitiveValuePair(cssValuePool().createIdentifierValue(s econdPositionKeyword), toCSSPrimitiveValue(*secondPositionValue));
2610 } 2609 }
2611 2610
2612 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded) 2611 if (ident1 == CSSValueTop || ident1 == CSSValueBottom || swapNeeded)
2613 value1.swap(value2); 2612 value1.swap(value2);
2614 2613
2615 #if ENABLE(ASSERT) 2614 #if ENABLE(ASSERT)
2616 CSSPrimitiveValue first = toCSSPrimitiveValue(*value1); 2615 const CSSPrimitiveValue& first = toCSSPrimitiveValue(*value1);
2617 CSSPrimitiveValue second = toCSSPrimitiveValue(*value2); 2616 const CSSPrimitiveValue& second = toCSSPrimitiveValue(*value2);
2618 ident1 = toCSSPrimitiveValue(*first.getPairValue()->first()).getValueID(); 2617 ident1 = first.getPairValue()->first().getValueID();
2619 ident2 = toCSSPrimitiveValue(*second.getPairValue()->first()).getValueID(); 2618 ident2 = second.getPairValue()->first().getValueID();
2620 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight); 2619 ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight);
2621 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop); 2620 ASSERT(ident2 == CSSValueBottom || ident2 == CSSValueTop);
2622 #endif 2621 #endif
2623 } 2622 }
2624 2623
2625 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value) 2624 inline bool CSSPropertyParser::isPotentialPositionValue(CSSParserValue* value)
2626 { 2625 {
2627 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue); 2626 return isFillPositionKeyword(value->id) || validUnit(value, FPercent | FLeng th, ReleaseParsedCalcValue);
2628 } 2627 }
2629 2628
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 // a valid start for <position>. 2666 // a valid start for <position>.
2668 cumulativeFlags = AmbiguousFillPosition; 2667 cumulativeFlags = AmbiguousFillPosition;
2669 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword); 2668 value2 = parseFillPositionComponent(valueList, cumulativeFlags, value2Flag, ResolveValuesAsKeyword);
2670 if (value2) 2669 if (value2)
2671 valueList->next(); 2670 valueList->next();
2672 else { 2671 else {
2673 value1 = nullptr; 2672 value1 = nullptr;
2674 return; 2673 return;
2675 } 2674 }
2676 2675
2676 // Explicitly make copies.
2677 CSSPrimitiveValue parsedValue1 = toCSSPrimitiveValue(*value1); 2677 CSSPrimitiveValue parsedValue1 = toCSSPrimitiveValue(*value1);
2678 CSSPrimitiveValue parsedValue2 = toCSSPrimitiveValue(*value2); 2678 CSSPrimitiveValue parsedValue2 = toCSSPrimitiveValue(*value2);
2679 2679
2680 value1 = nullptr; 2680 value1 = nullptr;
2681 value2 = nullptr; 2681 value2 = nullptr;
2682 2682
2683 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow. 2683 // Per CSS3 syntax, <position> can't have 'center' as its second keyword as we have more arguments to follow.
2684 if (parsedValue2.getValueID() == CSSValueCenter) 2684 if (parsedValue2.getValueID() == CSSValueCenter)
2685 return; 2685 return;
2686 2686
(...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after
5211 5211
5212 allowX = true; 5212 allowX = true;
5213 allowColor = true; 5213 allowColor = true;
5214 allowBreak = true; 5214 allowBreak = true;
5215 allowY = false; 5215 allowY = false;
5216 allowBlur = false; 5216 allowBlur = false;
5217 allowSpread = false; 5217 allowSpread = false;
5218 allowStyle = property == CSSPropertyBoxShadow; 5218 allowStyle = property == CSSPropertyBoxShadow;
5219 } 5219 }
5220 5220
5221 void commitLength(CSSPrimitiveValue val) 5221 void commitLength(const CSSPrimitiveValue& val)
5222 { 5222 {
5223 if (allowX) { 5223 if (allowX) {
5224 x = val; 5224 x = val;
5225 allowX = false; 5225 allowX = false;
5226 allowY = true; 5226 allowY = true;
5227 allowColor = false; 5227 allowColor = false;
5228 allowStyle = false; 5228 allowStyle = false;
5229 allowBreak = false; 5229 allowBreak = false;
5230 } else if (allowY) { 5230 } else if (allowY) {
5231 y = val; 5231 y = val;
5232 allowY = false; 5232 allowY = false;
5233 allowBlur = true; 5233 allowBlur = true;
5234 allowColor = true; 5234 allowColor = true;
5235 allowStyle = property == CSSPropertyBoxShadow; 5235 allowStyle = property == CSSPropertyBoxShadow;
5236 allowBreak = true; 5236 allowBreak = true;
5237 } else if (allowBlur) { 5237 } else if (allowBlur) {
5238 blur = val; 5238 blur = val;
5239 allowBlur = false; 5239 allowBlur = false;
5240 allowSpread = property == CSSPropertyBoxShadow; 5240 allowSpread = property == CSSPropertyBoxShadow;
5241 } else if (allowSpread) { 5241 } else if (allowSpread) {
5242 spread = val; 5242 spread = val;
5243 allowSpread = false; 5243 allowSpread = false;
5244 } 5244 }
5245 } 5245 }
5246 5246
5247 void commitColor(CSSPrimitiveValue val) 5247 void commitColor(const CSSPrimitiveValue& val)
5248 { 5248 {
5249 color = val; 5249 color = val;
5250 allowColor = false; 5250 allowColor = false;
5251 if (allowX) { 5251 if (allowX) {
5252 allowStyle = false; 5252 allowStyle = false;
5253 allowBreak = false; 5253 allowBreak = false;
5254 } else { 5254 } else {
5255 allowBlur = false; 5255 allowBlur = false;
5256 allowSpread = false; 5256 allowSpread = false;
5257 allowStyle = property == CSSPropertyBoxShadow; 5257 allowStyle = property == CSSPropertyBoxShadow;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
5524 if (!m_borderWidth && !m_allowWidth) { 5524 if (!m_borderWidth && !m_allowWidth) {
5525 m_allowForwardSlashOperator = true; 5525 m_allowForwardSlashOperator = true;
5526 m_allowWidth = true; 5526 m_allowWidth = true;
5527 m_requireOutset = false; 5527 m_requireOutset = false;
5528 } else { 5528 } else {
5529 m_allowForwardSlashOperator = false; 5529 m_allowForwardSlashOperator = false;
5530 m_requireOutset = true; 5530 m_requireOutset = true;
5531 m_allowWidth = false; 5531 m_allowWidth = false;
5532 } 5532 }
5533 } 5533 }
5534 void commitBorderWidth(CSSPrimitiveValue width) 5534 void commitBorderWidth(const CSSPrimitiveValue& width)
5535 { 5535 {
5536 m_borderWidth = width; 5536 m_borderWidth = width;
5537 m_canAdvance = true; 5537 m_canAdvance = true;
5538 m_allowCommit = true; 5538 m_allowCommit = true;
5539 m_allowForwardSlashOperator = true; 5539 m_allowForwardSlashOperator = true;
5540 m_allowImageSlice = false; 5540 m_allowImageSlice = false;
5541 m_allowWidth = false; 5541 m_allowWidth = false;
5542 m_requireOutset = false; 5542 m_requireOutset = false;
5543 m_allowImage = !m_image; 5543 m_allowImage = !m_image;
5544 m_allowRepeat = !m_repeat; 5544 m_allowRepeat = !m_repeat;
5545 } 5545 }
5546 void commitBorderOutset(CSSPrimitiveValue outset) 5546 void commitBorderOutset(const CSSPrimitiveValue& outset)
5547 { 5547 {
5548 m_outset = outset; 5548 m_outset = outset;
5549 m_canAdvance = true; 5549 m_canAdvance = true;
5550 m_allowCommit = true; 5550 m_allowCommit = true;
5551 m_allowImageSlice = false; 5551 m_allowImageSlice = false;
5552 m_allowForwardSlashOperator = false; 5552 m_allowForwardSlashOperator = false;
5553 m_allowWidth = false; 5553 m_allowWidth = false;
5554 m_requireOutset = false; 5554 m_requireOutset = false;
5555 m_allowImage = !m_image; 5555 m_allowImage = !m_image;
5556 m_allowRepeat = !m_repeat; 5556 m_allowRepeat = !m_repeat;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
5646 5646
5647 if (!context.canAdvance()) 5647 if (!context.canAdvance())
5648 return false; 5648 return false;
5649 5649
5650 m_valueList->next(); 5650 m_valueList->next();
5651 } 5651 }
5652 5652
5653 return context.allowCommit(); 5653 return context.allowCommit();
5654 } 5654 }
5655 5655
5656 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, Nullable CSSValue value, bool important) 5656 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, const Nu llableCSSValue& value, bool important)
5657 { 5657 {
5658 if (value) 5658 if (value)
5659 addProperty(propId, *value, important); 5659 addProperty(propId, *value, important);
5660 else 5660 else
5661 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true); 5661 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true);
5662 } 5662 }
5663 5663
5664 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant) 5664 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant)
5665 { 5665 {
5666 BorderImageParseContext context; 5666 BorderImageParseContext context;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
5740 BorderImageSliceParseContext() 5740 BorderImageSliceParseContext()
5741 : m_allowNumber(true) 5741 : m_allowNumber(true)
5742 , m_allowFill(true) 5742 , m_allowFill(true)
5743 , m_allowFinalCommit(false) 5743 , m_allowFinalCommit(false)
5744 , m_fill(false) 5744 , m_fill(false)
5745 { } 5745 { }
5746 5746
5747 bool allowNumber() const { return m_allowNumber; } 5747 bool allowNumber() const { return m_allowNumber; }
5748 bool allowFill() const { return m_allowFill; } 5748 bool allowFill() const { return m_allowFill; }
5749 bool allowFinalCommit() const { return m_allowFinalCommit; } 5749 bool allowFinalCommit() const { return m_allowFinalCommit; }
5750 NullableCSSValue top() const { return m_top; } 5750 const NullableCSSValue& top() const { return m_top; }
5751 5751
5752 void commitNumber(CSSPrimitiveValue val) 5752 void commitNumber(const CSSPrimitiveValue& val)
5753 { 5753 {
5754 if (!m_top) 5754 if (!m_top)
5755 m_top = val; 5755 m_top = val;
5756 else if (!m_right) 5756 else if (!m_right)
5757 m_right = val; 5757 m_right = val;
5758 else if (!m_bottom) 5758 else if (!m_bottom)
5759 m_bottom = val; 5759 m_bottom = val;
5760 else { 5760 else {
5761 ASSERT(!m_left); 5761 ASSERT(!m_left);
5762 m_left = val; 5762 m_left = val;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
5846 class BorderImageQuadParseContext { 5846 class BorderImageQuadParseContext {
5847 STACK_ALLOCATED(); 5847 STACK_ALLOCATED();
5848 public: 5848 public:
5849 BorderImageQuadParseContext() 5849 BorderImageQuadParseContext()
5850 : m_allowNumber(true) 5850 : m_allowNumber(true)
5851 , m_allowFinalCommit(false) 5851 , m_allowFinalCommit(false)
5852 { } 5852 { }
5853 5853
5854 bool allowNumber() const { return m_allowNumber; } 5854 bool allowNumber() const { return m_allowNumber; }
5855 bool allowFinalCommit() const { return m_allowFinalCommit; } 5855 bool allowFinalCommit() const { return m_allowFinalCommit; }
5856 NullableCSSValue top() const { return m_top; } 5856 const NullableCSSValue& top() const { return m_top; }
5857 5857
5858 void commitNumber(CSSPrimitiveValue val) 5858 void commitNumber(const CSSPrimitiveValue& val)
5859 { 5859 {
5860 if (!m_top) 5860 if (!m_top)
5861 m_top = val; 5861 m_top = val;
5862 else if (!m_right) 5862 else if (!m_right)
5863 m_right = val; 5863 m_right = val;
5864 else if (!m_bottom) 5864 else if (!m_bottom)
5865 m_bottom = val; 5865 m_bottom = val;
5866 else { 5866 else {
5867 ASSERT(!m_left); 5867 ASSERT(!m_left);
5868 m_left = val; 5868 m_left = val;
5869 } 5869 }
5870 5870
5871 m_allowNumber = !m_left; 5871 m_allowNumber = !m_left;
5872 m_allowFinalCommit = true; 5872 m_allowFinalCommit = true;
5873 } 5873 }
5874 5874
5875 void setTop(CSSPrimitiveValue val) { m_top = val; } 5875 void setTop(const CSSPrimitiveValue& val) { m_top = val; }
5876 5876
5877 CSSPrimitiveValue commitBorderImageQuad() 5877 const CSSPrimitiveValue commitBorderImageQuad()
5878 { 5878 {
5879 // We need to clone and repeat values for any omissions. 5879 // We need to clone and repeat values for any omissions.
5880 ASSERT(m_top); 5880 ASSERT(m_top);
5881 if (!m_right) { 5881 if (!m_right) {
5882 m_right = m_top; 5882 m_right = m_top;
5883 m_bottom = m_top; 5883 m_bottom = m_top;
5884 m_left = m_top; 5884 m_left = m_top;
5885 } 5885 }
5886 if (!m_bottom) { 5886 if (!m_bottom) {
5887 m_bottom = m_top; 5887 m_bottom = m_top;
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after
8263 } 8263 }
8264 } 8264 }
8265 8265
8266 if (!list->length()) 8266 if (!list->length())
8267 return nullptr; 8267 return nullptr;
8268 8268
8269 return list.release(); 8269 return list.release();
8270 } 8270 }
8271 8271
8272 } // namespace blink 8272 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | Source/core/css/resolver/CSSToStyleMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698