| 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 16 matching lines...) Expand all Loading... |
| 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 #ifndef CSSCalculationValue_h | 31 #ifndef CSSCalculationValue_h |
| 32 #define CSSCalculationValue_h | 32 #define CSSCalculationValue_h |
| 33 | 33 |
| 34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
| 35 #include "core/css/CSSPrimitiveValue.h" | 35 #include "core/css/CSSPrimitiveValue.h" |
| 36 #include "core/css/CSSValue.h" | 36 #include "core/css/CSSValue.h" |
| 37 #include "core/css/parser/CSSParserTokenRange.h" |
| 37 #include "core/css/parser/CSSParserValues.h" | 38 #include "core/css/parser/CSSParserValues.h" |
| 38 #include "platform/CalculationValue.h" | 39 #include "platform/CalculationValue.h" |
| 39 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
| 40 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
| 41 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 class CSSParserValueList; | |
| 46 class CalculationValue; | 46 class CalculationValue; |
| 47 | 47 |
| 48 enum CalcOperator { | 48 enum CalcOperator { |
| 49 CalcAdd = '+', | 49 CalcAdd = '+', |
| 50 CalcSubtract = '-', | 50 CalcSubtract = '-', |
| 51 CalcMultiply = '*', | 51 CalcMultiply = '*', |
| 52 CalcDivide = '/' | 52 CalcDivide = '/' |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // The order of this enum should not change since its elements are used as indic
es | 55 // The order of this enum should not change since its elements are used as indic
es |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 { | 96 { |
| 97 ASSERT(category != CalcOther); | 97 ASSERT(category != CalcOther); |
| 98 } | 98 } |
| 99 | 99 |
| 100 CalculationCategory m_category; | 100 CalculationCategory m_category; |
| 101 bool m_isInteger; | 101 bool m_isInteger; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 class CORE_EXPORT CSSCalcValue : public CSSValue { | 104 class CORE_EXPORT CSSCalcValue : public CSSValue { |
| 105 public: | 105 public: |
| 106 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(CSSParserValueList*, Valu
eRange); | 106 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(const CSSParserTokenRange
&, ValueRange); |
| 107 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(PassRefPtrWillBeRawPtr<CS
SCalcExpressionNode>, ValueRange = ValueRangeAll); | 107 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(PassRefPtrWillBeRawPtr<CS
SCalcExpressionNode>, ValueRange = ValueRangeAll); |
| 108 | 108 |
| 109 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa
ssRefPtrWillBeRawPtr<CSSPrimitiveValue>, bool isInteger = false); | 109 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa
ssRefPtrWillBeRawPtr<CSSPrimitiveValue>, bool isInteger = false); |
| 110 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa
ssRefPtrWillBeRawPtr<CSSCalcExpressionNode>, PassRefPtrWillBeRawPtr<CSSCalcExpre
ssionNode>, CalcOperator); | 110 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa
ssRefPtrWillBeRawPtr<CSSCalcExpressionNode>, PassRefPtrWillBeRawPtr<CSSCalcExpre
ssionNode>, CalcOperator); |
| 111 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(do
uble pixels, double percent); | 111 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(do
uble pixels, double percent); |
| 112 | 112 |
| 113 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const | 113 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const |
| 114 { | 114 { |
| 115 PixelsAndPercent value(0, 0); | 115 PixelsAndPercent value(0, 0); |
| 116 m_expression->accumulatePixelsAndPercent(conversionData, value); | 116 m_expression->accumulatePixelsAndPercent(conversionData, value); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 143 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression; | 143 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression; |
| 144 const bool m_nonNegative; | 144 const bool m_nonNegative; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); | 147 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); |
| 148 | 148 |
| 149 } // namespace blink | 149 } // namespace blink |
| 150 | 150 |
| 151 | 151 |
| 152 #endif // CSSCalculationValue_h | 152 #endif // CSSCalculationValue_h |
| OLD | NEW |