| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 CalcLength, | 58 CalcLength, |
| 59 CalcPercent, | 59 CalcPercent, |
| 60 CalcPercentNumber, | 60 CalcPercentNumber, |
| 61 CalcPercentLength, | 61 CalcPercentLength, |
| 62 CalcAngle, | 62 CalcAngle, |
| 63 CalcTime, | 63 CalcTime, |
| 64 CalcFrequency, | 64 CalcFrequency, |
| 65 CalcOther | 65 CalcOther |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class CSSCalcExpressionNode : public RefCountedWillBeGarbageCollected<CSSCalcExp
ressionNode> { | 68 class CSSCalcExpressionNode : public GarbageCollected<CSSCalcExpressionNode> { |
| 69 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode); | |
| 70 public: | 69 public: |
| 71 enum Type { | 70 enum Type { |
| 72 CssCalcPrimitiveValue = 1, | 71 CssCalcPrimitiveValue = 1, |
| 73 CssCalcBinaryOperation | 72 CssCalcBinaryOperation |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 virtual bool isZero() const = 0; | 75 virtual bool isZero() const = 0; |
| 77 virtual double doubleValue() const = 0; | 76 virtual double doubleValue() const = 0; |
| 78 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0; | 77 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0; |
| 79 virtual void accumulateLengthArray(CSSLengthArray&, CSSLengthTypeArray&, dou
ble multiplier) const = 0; | 78 virtual void accumulateLengthArray(CSSLengthArray&, CSSLengthTypeArray&, dou
ble multiplier) const = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 : m_category(category) | 92 : m_category(category) |
| 94 , m_isInteger(isInteger) | 93 , m_isInteger(isInteger) |
| 95 { | 94 { |
| 96 ASSERT(category != CalcOther); | 95 ASSERT(category != CalcOther); |
| 97 } | 96 } |
| 98 | 97 |
| 99 CalculationCategory m_category; | 98 CalculationCategory m_category; |
| 100 bool m_isInteger; | 99 bool m_isInteger; |
| 101 }; | 100 }; |
| 102 | 101 |
| 103 class CORE_EXPORT CSSCalcValue : public RefCountedWillBeGarbageCollected<CSSCalc
Value> { | 102 class CORE_EXPORT CSSCalcValue : public GarbageCollected<CSSCalcValue> { |
| 104 public: | 103 public: |
| 105 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(const CSSParserTokenRange
&, ValueRange); | 104 static RawPtr<CSSCalcValue> create(const CSSParserTokenRange&, ValueRange); |
| 106 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(PassRefPtrWillBeRawPtr<CS
SCalcExpressionNode>, ValueRange = ValueRangeAll); | 105 static RawPtr<CSSCalcValue> create(RawPtr<CSSCalcExpressionNode>, ValueRange
= ValueRangeAll); |
| 107 | 106 |
| 108 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa
ssRefPtrWillBeRawPtr<CSSPrimitiveValue>, bool isInteger = false); | 107 static RawPtr<CSSCalcExpressionNode> createExpressionNode(RawPtr<CSSPrimitiv
eValue>, bool isInteger = false); |
| 109 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa
ssRefPtrWillBeRawPtr<CSSCalcExpressionNode>, PassRefPtrWillBeRawPtr<CSSCalcExpre
ssionNode>, CalcOperator); | 108 static RawPtr<CSSCalcExpressionNode> createExpressionNode(RawPtr<CSSCalcExpr
essionNode>, RawPtr<CSSCalcExpressionNode>, CalcOperator); |
| 110 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(do
uble pixels, double percent); | 109 static RawPtr<CSSCalcExpressionNode> createExpressionNode(double pixels, dou
ble percent); |
| 111 | 110 |
| 112 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const | 111 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const |
| 113 { | 112 { |
| 114 PixelsAndPercent value(0, 0); | 113 PixelsAndPercent value(0, 0); |
| 115 m_expression->accumulatePixelsAndPercent(conversionData, value); | 114 m_expression->accumulatePixelsAndPercent(conversionData, value); |
| 116 return CalculationValue::create(value, m_nonNegative ? ValueRangeNonNega
tive : ValueRangeAll); | 115 return CalculationValue::create(value, m_nonNegative ? ValueRangeNonNega
tive : ValueRangeAll); |
| 117 } | 116 } |
| 118 CalculationCategory category() const { return m_expression->category(); } | 117 CalculationCategory category() const { return m_expression->category(); } |
| 119 bool isInt() const { return m_expression->isInteger(); } | 118 bool isInt() const { return m_expression->isInteger(); } |
| 120 double doubleValue() const; | 119 double doubleValue() const; |
| 121 bool isNegative() const { return m_expression->doubleValue() < 0; } | 120 bool isNegative() const { return m_expression->doubleValue() < 0; } |
| 122 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat
ive : ValueRangeAll; } | 121 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat
ive : ValueRangeAll; } |
| 123 double computeLengthPx(const CSSToLengthConversionData&) const; | 122 double computeLengthPx(const CSSToLengthConversionData&) const; |
| 124 void accumulateLengthArray(CSSLengthArray& lengthArray, CSSLengthTypeArray&
lengthTypeArray, double multiplier) const { m_expression->accumulateLengthArray(
lengthArray, lengthTypeArray, multiplier); } | 123 void accumulateLengthArray(CSSLengthArray& lengthArray, CSSLengthTypeArray&
lengthTypeArray, double multiplier) const { m_expression->accumulateLengthArray(
lengthArray, lengthTypeArray, multiplier); } |
| 125 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } | 124 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } |
| 126 | 125 |
| 127 String customCSSText() const; | 126 String customCSSText() const; |
| 128 bool equals(const CSSCalcValue&) const; | 127 bool equals(const CSSCalcValue&) const; |
| 129 | 128 |
| 130 DEFINE_INLINE_TRACE() | 129 DEFINE_INLINE_TRACE() |
| 131 { | 130 { |
| 132 visitor->trace(m_expression); | 131 visitor->trace(m_expression); |
| 133 } | 132 } |
| 134 | 133 |
| 135 private: | 134 private: |
| 136 CSSCalcValue(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, Value
Range range) | 135 CSSCalcValue(RawPtr<CSSCalcExpressionNode> expression, ValueRange range) |
| 137 : m_expression(expression) | 136 : m_expression(expression) |
| 138 , m_nonNegative(range == ValueRangeNonNegative) | 137 , m_nonNegative(range == ValueRangeNonNegative) |
| 139 { | 138 { |
| 140 } | 139 } |
| 141 | 140 |
| 142 double clampToPermittedRange(double) const; | 141 double clampToPermittedRange(double) const; |
| 143 | 142 |
| 144 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression; | 143 const Member<CSSCalcExpressionNode> m_expression; |
| 145 const bool m_nonNegative; | 144 const bool m_nonNegative; |
| 146 }; | 145 }; |
| 147 | 146 |
| 148 } // namespace blink | 147 } // namespace blink |
| 149 | 148 |
| 150 #endif // CSSCalculationValue_h | 149 #endif // CSSCalculationValue_h |
| OLD | NEW |