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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 case CSSPrimitiveValue::CSS_RGBCOLOR: | 129 case CSSPrimitiveValue::CSS_RGBCOLOR: |
129 case CSSPrimitiveValue::CSS_PAIR: | 130 case CSSPrimitiveValue::CSS_PAIR: |
130 case CSSPrimitiveValue::CSS_SHAPE: | 131 case CSSPrimitiveValue::CSS_SHAPE: |
131 case CSSPrimitiveValue::CSS_QUAD: | 132 case CSSPrimitiveValue::CSS_QUAD: |
132 case CSSPrimitiveValue::CSS_CALC: | 133 case CSSPrimitiveValue::CSS_CALC: |
133 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER: | 134 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER: |
134 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH: | 135 case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH: |
135 case CSSPrimitiveValue::CSS_PROPERTY_ID: | 136 case CSSPrimitiveValue::CSS_PROPERTY_ID: |
136 case CSSPrimitiveValue::CSS_VALUE_ID: | 137 case CSSPrimitiveValue::CSS_VALUE_ID: |
137 case CSSPrimitiveValue::CSS_QEM: | 138 case CSSPrimitiveValue::CSS_QEM: |
139 case CSSPrimitiveValue::CSS_VARIABLE_REFERENCE: | |
138 return false; | 140 return false; |
139 }; | 141 }; |
140 ASSERT_NOT_REACHED(); | 142 ASSERT_NOT_REACHED(); |
141 return false; | 143 return false; |
142 } | 144 } |
143 | 145 |
144 static String buildCSSText(const String& expression) | 146 static String buildCSSText(const String& expression) |
145 { | 147 { |
146 StringBuilder result; | 148 StringBuilder result; |
147 result.appendLiteral("calc"); | 149 result.appendLiteral("calc"); |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 CSSParserValue* value = tokens->valueAt(index); | 630 CSSParserValue* value = tokens->valueAt(index); |
629 if (value->unit != CSSParserValue::Operator) | 631 if (value->unit != CSSParserValue::Operator) |
630 return 0; | 632 return 0; |
631 | 633 |
632 return value->iValue; | 634 return value->iValue; |
633 } | 635 } |
634 | 636 |
635 bool parseValue(CSSParserValueList* tokens, unsigned* index, Value* result) | 637 bool parseValue(CSSParserValueList* tokens, unsigned* index, Value* result) |
636 { | 638 { |
637 CSSParserValue* parserValue = tokens->valueAt(*index); | 639 CSSParserValue* parserValue = tokens->valueAt(*index); |
638 if (parserValue->unit >= CSSParserValue::Operator) | 640 |
639 return false; | 641 if (parserValue->unit >= CSSParserValue::Operator) { |
642 // We still have to check for variables, which are parser values | |
643 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSPropertyPa rser::isVariableReference(parserValue)) | |
644 return false; | |
645 | |
646 result->value = CSSCalcPrimitiveValue::create( | |
alancutter (OOO until 2018)
2015/07/14 06:12:57
Is this ever hit? Don't we short circuit variable
| |
647 CSSPrimitiveValue::create(parserValue->function->args->valueAt(0 )->string, CSSPrimitiveValue::CSS_VARIABLE_REFERENCE), parserValue->isInt); | |
648 ++*index; | |
649 | |
650 return true; | |
651 } | |
640 | 652 |
641 CSSPrimitiveValue::UnitType type = static_cast<CSSPrimitiveValue::UnitTy pe>(parserValue->unit); | 653 CSSPrimitiveValue::UnitType type = static_cast<CSSPrimitiveValue::UnitTy pe>(parserValue->unit); |
654 | |
642 if (unitCategory(type) == CalcOther) | 655 if (unitCategory(type) == CalcOther) |
643 return false; | 656 return false; |
644 | 657 |
645 result->value = CSSCalcPrimitiveValue::create( | 658 result->value = CSSCalcPrimitiveValue::create( |
646 CSSPrimitiveValue::create(parserValue->fValue, type), parserValue->i sInt); | 659 CSSPrimitiveValue::create(parserValue->fValue, type), parserValue->i sInt); |
647 | 660 |
648 ++*index; | 661 ++*index; |
649 return true; | 662 return true; |
650 } | 663 } |
651 | 664 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 return adoptRefWillBeNoop(new CSSCalcValue(expression, range)); | 772 return adoptRefWillBeNoop(new CSSCalcValue(expression, range)); |
760 } | 773 } |
761 | 774 |
762 DEFINE_TRACE_AFTER_DISPATCH(CSSCalcValue) | 775 DEFINE_TRACE_AFTER_DISPATCH(CSSCalcValue) |
763 { | 776 { |
764 visitor->trace(m_expression); | 777 visitor->trace(m_expression); |
765 CSSValue::traceAfterDispatch(visitor); | 778 CSSValue::traceAfterDispatch(visitor); |
766 } | 779 } |
767 | 780 |
768 } // namespace blink | 781 } // namespace blink |
OLD | NEW |