OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/css/CSSCalculationValue.h" | 32 #include "core/css/CSSCalculationValue.h" |
33 | 33 |
34 #include "core/css/CSSPrimitiveValueMappings.h" | 34 #include "core/css/CSSPrimitiveValueMappings.h" |
35 #include "core/css/parser/CSSPropertyParser.h" | |
35 #include "core/css/resolver/StyleResolver.h" | 36 #include "core/css/resolver/StyleResolver.h" |
36 #include "wtf/MathExtras.h" | 37 #include "wtf/MathExtras.h" |
37 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
38 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
39 | 40 |
40 static const int maxExpressionDepth = 100; | 41 static const int maxExpressionDepth = 100; |
41 | 42 |
42 enum ParseState { | 43 enum ParseState { |
43 OK, | 44 OK, |
44 TooDeep, | 45 TooDeep, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 case CSSPrimitiveValue::CSS_RGBCOLOR: | 131 case CSSPrimitiveValue::CSS_RGBCOLOR: |
131 case CSSPrimitiveValue::CSS_PAIR: | 132 case CSSPrimitiveValue::CSS_PAIR: |
132 case CSSPrimitiveValue::CSS_SHAPE: | 133 case CSSPrimitiveValue::CSS_SHAPE: |
133 case CSSPrimitiveValue::CSS_QUAD: | 134 case CSSPrimitiveValue::CSS_QUAD: |
134 case CSSPrimitiveValue::CSS_CALC: | 135 case CSSPrimitiveValue::CSS_CALC: |
135 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER: | 136 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER: |
136 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH: | 137 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH: |
137 case CSSPrimitiveValue::CSS_PROPERTY_ID: | 138 case CSSPrimitiveValue::CSS_PROPERTY_ID: |
138 case CSSPrimitiveValue::CSS_VALUE_ID: | 139 case CSSPrimitiveValue::CSS_VALUE_ID: |
139 case CSSPrimitiveValue::CSS_QEM: | 140 case CSSPrimitiveValue::CSS_QEM: |
141 case CSSPrimitiveValue::CSS_VARIABLE_REFERENCE: | |
140 return false; | 142 return false; |
141 }; | 143 }; |
142 ASSERT_NOT_REACHED(); | 144 ASSERT_NOT_REACHED(); |
143 return false; | 145 return false; |
144 } | 146 } |
145 | 147 |
146 static String buildCSSText(const String& expression) | 148 static String buildCSSText(const String& expression) |
147 { | 149 { |
148 StringBuilder result; | 150 StringBuilder result; |
149 result.appendLiteral("calc"); | 151 result.appendLiteral("calc"); |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 CSSParserValue* value = tokens->valueAt(index); | 632 CSSParserValue* value = tokens->valueAt(index); |
631 if (value->unit != CSSParserValue::Operator) | 633 if (value->unit != CSSParserValue::Operator) |
632 return 0; | 634 return 0; |
633 | 635 |
634 return value->iValue; | 636 return value->iValue; |
635 } | 637 } |
636 | 638 |
637 bool parseValue(CSSParserValueList* tokens, unsigned* index, Value* result) | 639 bool parseValue(CSSParserValueList* tokens, unsigned* index, Value* result) |
638 { | 640 { |
639 CSSParserValue* parserValue = tokens->valueAt(*index); | 641 CSSParserValue* parserValue = tokens->valueAt(*index); |
642 | |
Timothy Loh
2015/07/23 08:11:46
not needed
leviw_travelin_and_unemployed
2015/08/04 00:42:20
Removed.
| |
640 if (parserValue->unit >= CSSParserValue::Operator) | 643 if (parserValue->unit >= CSSParserValue::Operator) |
641 return false; | 644 return false; |
642 | 645 |
643 CSSPrimitiveValue::UnitType type = static_cast<CSSPrimitiveValue::UnitTy pe>(parserValue->unit); | 646 CSSPrimitiveValue::UnitType type = static_cast<CSSPrimitiveValue::UnitTy pe>(parserValue->unit); |
647 | |
644 if (unitCategory(type) == CalcOther) | 648 if (unitCategory(type) == CalcOther) |
645 return false; | 649 return false; |
646 | 650 |
647 result->value = CSSCalcPrimitiveValue::create( | 651 result->value = CSSCalcPrimitiveValue::create( |
648 CSSPrimitiveValue::create(parserValue->fValue, type), parserValue->i sInt); | 652 CSSPrimitiveValue::create(parserValue->fValue, type), parserValue->i sInt); |
649 | 653 |
650 ++*index; | 654 ++*index; |
651 return true; | 655 return true; |
652 } | 656 } |
653 | 657 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 return adoptRefWillBeNoop(new CSSCalcValue(expression, range)); | 765 return adoptRefWillBeNoop(new CSSCalcValue(expression, range)); |
762 } | 766 } |
763 | 767 |
764 DEFINE_TRACE_AFTER_DISPATCH(CSSCalcValue) | 768 DEFINE_TRACE_AFTER_DISPATCH(CSSCalcValue) |
765 { | 769 { |
766 visitor->trace(m_expression); | 770 visitor->trace(m_expression); |
767 CSSValue::traceAfterDispatch(visitor); | 771 CSSValue::traceAfterDispatch(visitor); |
768 } | 772 } |
769 | 773 |
770 } // namespace blink | 774 } // namespace blink |
OLD | NEW |