| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/css/CSSValue.h" | 36 #include "core/css/CSSValue.h" |
| 37 #include "platform/CalculationValue.h" | 37 #include "platform/CalculationValue.h" |
| 38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
| 40 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 class CSSParserValueList; | 44 class CSSParserValueList; |
| 45 class CSSValueList; | 45 class CSSValueList; |
| 46 class CSSLengthData; |
| 46 class CalculationValue; | 47 class CalculationValue; |
| 47 class CalcExpressionNode; | 48 class CalcExpressionNode; |
| 48 class Length; | 49 class Length; |
| 49 | 50 |
| 50 enum CalculationCategory { | 51 enum CalculationCategory { |
| 51 CalcNumber = 0, | 52 CalcNumber = 0, |
| 52 CalcLength, | 53 CalcLength, |
| 53 CalcPercent, | 54 CalcPercent, |
| 54 CalcPercentNumber, | 55 CalcPercentNumber, |
| 55 CalcPercentLength, | 56 CalcPercentLength, |
| 56 CalcOther | 57 CalcOther |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 class CSSCalcExpressionNode : public RefCountedWillBeGarbageCollected<CSSCalcExp
ressionNode> { | 60 class CSSCalcExpressionNode : public RefCountedWillBeGarbageCollected<CSSCalcExp
ressionNode> { |
| 60 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode); | 61 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSCalcExpressionNode); |
| 61 public: | 62 public: |
| 62 enum Type { | 63 enum Type { |
| 63 CssCalcPrimitiveValue = 1, | 64 CssCalcPrimitiveValue = 1, |
| 64 CssCalcBinaryOperation | 65 CssCalcBinaryOperation |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 virtual bool isZero() const = 0; | 68 virtual bool isZero() const = 0; |
| 68 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi
onData&) const = 0; | 69 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi
onData&) const = 0; |
| 69 virtual double doubleValue() const = 0; | 70 virtual double doubleValue() const = 0; |
| 70 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0; | 71 virtual double computeLengthPx(const CSSLengthData*) const = 0; |
| 71 virtual String customCSSText() const = 0; | 72 virtual String customCSSText() const = 0; |
| 72 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat
egory == other.m_category && m_isInteger == other.m_isInteger; } | 73 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat
egory == other.m_category && m_isInteger == other.m_isInteger; } |
| 73 virtual Type type() const = 0; | 74 virtual Type type() const = 0; |
| 74 | 75 |
| 75 CalculationCategory category() const { return m_category; } | 76 CalculationCategory category() const { return m_category; } |
| 76 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0; | 77 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0; |
| 77 bool isInteger() const { return m_isInteger; } | 78 bool isInteger() const { return m_isInteger; } |
| 78 | 79 |
| 79 virtual void trace(Visitor*) { } | 80 virtual void trace(Visitor*) { } |
| 80 | 81 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 102 | 103 |
| 103 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const | 104 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co
nversionData) const |
| 104 { | 105 { |
| 105 return CalculationValue::create(m_expression->toCalcValue(conversionData
), m_nonNegative ? ValueRangeNonNegative : ValueRangeAll); | 106 return CalculationValue::create(m_expression->toCalcValue(conversionData
), m_nonNegative ? ValueRangeNonNegative : ValueRangeAll); |
| 106 } | 107 } |
| 107 CalculationCategory category() const { return m_expression->category(); } | 108 CalculationCategory category() const { return m_expression->category(); } |
| 108 bool isInt() const { return m_expression->isInteger(); } | 109 bool isInt() const { return m_expression->isInteger(); } |
| 109 double doubleValue() const; | 110 double doubleValue() const; |
| 110 bool isNegative() const { return m_expression->doubleValue() < 0; } | 111 bool isNegative() const { return m_expression->doubleValue() < 0; } |
| 111 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat
ive : ValueRangeAll; } | 112 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat
ive : ValueRangeAll; } |
| 112 double computeLengthPx(const CSSToLengthConversionData&) const; | 113 double computeLengthPx(const CSSLengthData*) const; |
| 113 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } | 114 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } |
| 114 | 115 |
| 115 String customCSSText() const; | 116 String customCSSText() const; |
| 116 bool equals(const CSSCalcValue&) const; | 117 bool equals(const CSSCalcValue&) const; |
| 117 | 118 |
| 118 void traceAfterDispatch(Visitor*); | 119 void traceAfterDispatch(Visitor*); |
| 119 | 120 |
| 120 private: | 121 private: |
| 121 CSSCalcValue(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, Value
Range range) | 122 CSSCalcValue(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, Value
Range range) |
| 122 : CSSValue(CalculationClass) | 123 : CSSValue(CalculationClass) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 136 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression; | 137 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression; |
| 137 const bool m_nonNegative; | 138 const bool m_nonNegative; |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); | 141 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); |
| 141 | 142 |
| 142 } // namespace WebCore | 143 } // namespace WebCore |
| 143 | 144 |
| 144 | 145 |
| 145 #endif // CSSCalculationValue_h | 146 #endif // CSSCalculationValue_h |
| OLD | NEW |