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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 double CSSCalcValue::clampToPermittedRange(double value) const | 162 double CSSCalcValue::clampToPermittedRange(double value) const |
163 { | 163 { |
164 return m_nonNegative && value < 0 ? 0 : value; | 164 return m_nonNegative && value < 0 ? 0 : value; |
165 } | 165 } |
166 | 166 |
167 double CSSCalcValue::doubleValue() const | 167 double CSSCalcValue::doubleValue() const |
168 { | 168 { |
169 return clampToPermittedRange(m_expression->doubleValue()); | 169 return clampToPermittedRange(m_expression->doubleValue()); |
170 } | 170 } |
171 | 171 |
172 double CSSCalcValue::computeLengthPx(const CSSToLengthConversionData& conversion
Data) const | 172 double CSSCalcValue::computeLengthPx(const CSSLengthData* lengthData) const |
173 { | 173 { |
174 return clampToPermittedRange(m_expression->computeLengthPx(conversionData)); | 174 return clampToPermittedRange(m_expression->computeLengthPx(lengthData)); |
175 } | 175 } |
176 | 176 |
177 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode) | 177 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode) |
178 | 178 |
179 class CSSCalcPrimitiveValue FINAL : public CSSCalcExpressionNode { | 179 class CSSCalcPrimitiveValue FINAL : public CSSCalcExpressionNode { |
180 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 180 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
181 public: | 181 public: |
182 | 182 |
183 static PassRefPtrWillBeRawPtr<CSSCalcPrimitiveValue> create(PassRefPtrWillBe
RawPtr<CSSPrimitiveValue> value, bool isInteger) | 183 static PassRefPtrWillBeRawPtr<CSSCalcPrimitiveValue> create(PassRefPtrWillBe
RawPtr<CSSPrimitiveValue> value, bool isInteger) |
184 { | 184 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 222 } |
223 | 223 |
224 virtual double doubleValue() const OVERRIDE | 224 virtual double doubleValue() const OVERRIDE |
225 { | 225 { |
226 if (hasDoubleValue(primitiveType())) | 226 if (hasDoubleValue(primitiveType())) |
227 return m_value->getDoubleValue(); | 227 return m_value->getDoubleValue(); |
228 ASSERT_NOT_REACHED(); | 228 ASSERT_NOT_REACHED(); |
229 return 0; | 229 return 0; |
230 } | 230 } |
231 | 231 |
232 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa
ta) const OVERRIDE | 232 virtual double computeLengthPx(const CSSLengthData* lengthData) const OVERRI
DE |
233 { | 233 { |
234 switch (m_category) { | 234 switch (m_category) { |
235 case CalcLength: | 235 case CalcLength: |
236 return m_value->computeLength<double>(conversionData); | 236 return m_value->computeLength<double>(*lengthData); |
237 case CalcPercent: | 237 case CalcPercent: |
238 case CalcNumber: | 238 case CalcNumber: |
239 return m_value->getDoubleValue(); | 239 return m_value->getDoubleValue(); |
240 case CalcPercentLength: | 240 case CalcPercentLength: |
241 case CalcPercentNumber: | 241 case CalcPercentNumber: |
242 case CalcOther: | 242 case CalcOther: |
243 ASSERT_NOT_REACHED(); | 243 ASSERT_NOT_REACHED(); |
244 break; | 244 break; |
245 } | 245 } |
246 ASSERT_NOT_REACHED(); | 246 ASSERT_NOT_REACHED(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 if (!right) | 405 if (!right) |
406 return nullptr; | 406 return nullptr; |
407 return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right.
release(), m_operator)); | 407 return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right.
release(), m_operator)); |
408 } | 408 } |
409 | 409 |
410 virtual double doubleValue() const OVERRIDE | 410 virtual double doubleValue() const OVERRIDE |
411 { | 411 { |
412 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); | 412 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); |
413 } | 413 } |
414 | 414 |
415 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa
ta) const OVERRIDE | 415 virtual double computeLengthPx(const CSSLengthData* lengthData) const OVERRI
DE |
416 { | 416 { |
417 const double leftValue = m_leftSide->computeLengthPx(conversionData); | 417 const double leftValue = m_leftSide->computeLengthPx(lengthData); |
418 const double rightValue = m_rightSide->computeLengthPx(conversionData); | 418 const double rightValue = m_rightSide->computeLengthPx(lengthData); |
419 return evaluate(leftValue, rightValue); | 419 return evaluate(leftValue, rightValue); |
420 } | 420 } |
421 | 421 |
422 static String buildCSSText(const String& leftExpression, const String& right
Expression, CalcOperator op) | 422 static String buildCSSText(const String& leftExpression, const String& right
Expression, CalcOperator op) |
423 { | 423 { |
424 StringBuilder result; | 424 StringBuilder result; |
425 result.append('('); | 425 result.append('('); |
426 result.append(leftExpression); | 426 result.append(leftExpression); |
427 result.append(' '); | 427 result.append(' '); |
428 result.append(static_cast<char>(op)); | 428 result.append(static_cast<char>(op)); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 return adoptRefWillBeRefCountedGarbageCollected(new CSSCalcValue(expression,
range)); | 758 return adoptRefWillBeRefCountedGarbageCollected(new CSSCalcValue(expression,
range)); |
759 } | 759 } |
760 | 760 |
761 void CSSCalcValue::traceAfterDispatch(Visitor* visitor) | 761 void CSSCalcValue::traceAfterDispatch(Visitor* visitor) |
762 { | 762 { |
763 visitor->trace(m_expression); | 763 visitor->trace(m_expression); |
764 CSSValue::traceAfterDispatch(visitor); | 764 CSSValue::traceAfterDispatch(visitor); |
765 } | 765 } |
766 | 766 |
767 } // namespace WebCore | 767 } // namespace WebCore |
OLD | NEW |