Index: Source/WebCore/platform/CalculationValue.h |
=================================================================== |
--- Source/WebCore/platform/CalculationValue.h (revision 118280) |
+++ Source/WebCore/platform/CalculationValue.h (working copy) |
@@ -51,20 +51,43 @@ |
CalculationRangeAll, |
CalculationRangeNonNegative |
}; |
+ |
+enum CalcExpressionNodeType { |
+ CalcExpressionNodeUndefined, |
+ CalcExpressionNodeNumber, |
+ CalcExpressionNodeLength, |
+ CalcExpressionNodeBinaryOperation |
+}; |
class CalcExpressionNode { |
public: |
+ CalcExpressionNode() |
+ : m_type(CalcExpressionNodeUndefined) |
+ { |
+ } |
+ |
virtual ~CalcExpressionNode() |
{ |
} |
virtual float evaluate(float maxValue) const = 0; |
+ virtual bool operator==(const CalcExpressionNode&) const = 0; |
+ |
+ CalcExpressionNodeType type() const { return m_type; } |
+ |
+protected: |
+ CalcExpressionNodeType m_type; |
}; |
class CalculationValue : public RefCounted<CalculationValue> { |
public: |
static PassRefPtr<CalculationValue> create(PassOwnPtr<CalcExpressionNode> value, CalculationPermittedValueRange); |
float evaluate(float maxValue) const; |
+ |
+ bool operator==(const CalculationValue& o) const |
+ { |
+ return m_value == o.m_value || *(m_value.get()) == *(o.m_value.get()); |
+ } |
private: |
CalculationValue(PassOwnPtr<CalcExpressionNode> value, CalculationPermittedValueRange range) |
@@ -82,8 +105,19 @@ |
explicit CalcExpressionNumber(float value) |
: m_value(value) |
{ |
+ m_type = CalcExpressionNodeNumber; |
} |
+ bool operator==(const CalcExpressionNumber& o) const |
+ { |
+ return m_value == o.m_value; |
+ } |
+ |
+ virtual bool operator==(const CalcExpressionNode& o) const |
+ { |
+ return type() == o.type() && *this == static_cast<const CalcExpressionNumber&>(o); |
+ } |
+ |
virtual float evaluate(float) const |
{ |
return m_value; |
@@ -98,8 +132,19 @@ |
explicit CalcExpressionLength(Length length) |
: m_length(length) |
{ |
+ m_type = CalcExpressionNodeLength; |
} |
+ bool operator==(const CalcExpressionLength& o) const |
+ { |
+ return m_length == o.m_length; |
+ } |
+ |
+ virtual bool operator==(const CalcExpressionNode& o) const |
+ { |
+ return type() == o.type() && *this == static_cast<const CalcExpressionLength&>(o); |
+ } |
+ |
virtual float evaluate(float maxValue) const |
{ |
return floatValueForLength(m_length, maxValue); |
@@ -116,8 +161,20 @@ |
, m_rightSide(rightSide) |
, m_operator(op) |
{ |
+ m_type = CalcExpressionNodeBinaryOperation; |
} |
+ bool operator==(const CalcExpressionBinaryOperation& o) const |
+ { |
+ return m_operator == o.m_operator && *m_leftSide == *o.m_leftSide && *m_rightSide == *o.m_rightSide; |
+ } |
+ |
+ virtual bool operator==(const CalcExpressionNode& o) const |
+ { |
+ return type() == o.type() && *this == static_cast<const CalcExpressionBinaryOperation&>(o); |
+ } |
+ |
+ |
virtual float evaluate(float) const; |
private: |