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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 { | 94 { |
95 ASSERT(category != CalcOther); | 95 ASSERT(category != CalcOther); |
96 } | 96 } |
97 | 97 |
98 CalculationCategory m_category; | 98 CalculationCategory m_category; |
99 bool m_isInteger; | 99 bool m_isInteger; |
100 }; | 100 }; |
101 | 101 |
102 class CORE_EXPORT CSSCalcValue : public GarbageCollected<CSSCalcValue> { | 102 class CORE_EXPORT CSSCalcValue : public GarbageCollected<CSSCalcValue> { |
103 public: | 103 public: |
104 static RawPtr<CSSCalcValue> create(const CSSParserTokenRange&, ValueRange); | 104 static CSSCalcValue* create(const CSSParserTokenRange&, ValueRange); |
105 static RawPtr<CSSCalcValue> create(RawPtr<CSSCalcExpressionNode>, ValueRange
= ValueRangeAll); | 105 static CSSCalcValue* create(CSSCalcExpressionNode*, ValueRange = ValueRangeA
ll); |
106 | 106 |
107 static RawPtr<CSSCalcExpressionNode> createExpressionNode(RawPtr<CSSPrimitiv
eValue>, bool isInteger = false); | 107 static CSSCalcExpressionNode* createExpressionNode(CSSPrimitiveValue*, bool
isInteger = false); |
108 static RawPtr<CSSCalcExpressionNode> createExpressionNode(RawPtr<CSSCalcExpr
essionNode>, RawPtr<CSSCalcExpressionNode>, CalcOperator); | 108 static CSSCalcExpressionNode* createExpressionNode(CSSCalcExpressionNode*, C
SSCalcExpressionNode*, CalcOperator); |
109 static RawPtr<CSSCalcExpressionNode> createExpressionNode(double pixels, dou
ble percent); | 109 static CSSCalcExpressionNode* createExpressionNode(double pixels, double per
cent); |
110 | 110 |
111 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const | 111 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const |
112 { | 112 { |
113 PixelsAndPercent value(0, 0); | 113 PixelsAndPercent value(0, 0); |
114 m_expression->accumulatePixelsAndPercent(conversionData, value); | 114 m_expression->accumulatePixelsAndPercent(conversionData, value); |
115 return CalculationValue::create(value, m_nonNegative ? ValueRangeNonNega
tive : ValueRangeAll); | 115 return CalculationValue::create(value, m_nonNegative ? ValueRangeNonNega
tive : ValueRangeAll); |
116 } | 116 } |
117 CalculationCategory category() const { return m_expression->category(); } | 117 CalculationCategory category() const { return m_expression->category(); } |
118 bool isInt() const { return m_expression->isInteger(); } | 118 bool isInt() const { return m_expression->isInteger(); } |
119 double doubleValue() const; | 119 double doubleValue() const; |
120 bool isNegative() const { return m_expression->doubleValue() < 0; } | 120 bool isNegative() const { return m_expression->doubleValue() < 0; } |
121 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat
ive : ValueRangeAll; } | 121 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat
ive : ValueRangeAll; } |
122 double computeLengthPx(const CSSToLengthConversionData&) const; | 122 double computeLengthPx(const CSSToLengthConversionData&) const; |
123 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); } |
124 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } | 124 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } |
125 | 125 |
126 String customCSSText() const; | 126 String customCSSText() const; |
127 bool equals(const CSSCalcValue&) const; | 127 bool equals(const CSSCalcValue&) const; |
128 | 128 |
129 DEFINE_INLINE_TRACE() | 129 DEFINE_INLINE_TRACE() |
130 { | 130 { |
131 visitor->trace(m_expression); | 131 visitor->trace(m_expression); |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 CSSCalcValue(RawPtr<CSSCalcExpressionNode> expression, ValueRange range) | 135 CSSCalcValue(CSSCalcExpressionNode* expression, ValueRange range) |
136 : m_expression(expression) | 136 : m_expression(expression) |
137 , m_nonNegative(range == ValueRangeNonNegative) | 137 , m_nonNegative(range == ValueRangeNonNegative) |
138 { | 138 { |
139 } | 139 } |
140 | 140 |
141 double clampToPermittedRange(double) const; | 141 double clampToPermittedRange(double) const; |
142 | 142 |
143 const Member<CSSCalcExpressionNode> m_expression; | 143 const Member<CSSCalcExpressionNode> m_expression; |
144 const bool m_nonNegative; | 144 const bool m_nonNegative; |
145 }; | 145 }; |
146 | 146 |
147 } // namespace blink | 147 } // namespace blink |
148 | 148 |
149 #endif // CSSCalculationValue_h | 149 #endif // CSSCalculationValue_h |
OLD | NEW |