diff options
Diffstat (limited to 'Source/WebCore/css/CSSCalculationValue.cpp')
-rw-r--r-- | Source/WebCore/css/CSSCalculationValue.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp index b42a520c2..60fd22adf 100644 --- a/Source/WebCore/css/CSSCalculationValue.cpp +++ b/Source/WebCore/css/CSSCalculationValue.cpp @@ -57,8 +57,6 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type) case CSSPrimitiveValue::CSS_NUMBER: case CSSPrimitiveValue::CSS_PARSER_INTEGER: return CalcNumber; - case CSSPrimitiveValue::CSS_PERCENTAGE: - return CalcPercent; case CSSPrimitiveValue::CSS_EMS: case CSSPrimitiveValue::CSS_EXS: case CSSPrimitiveValue::CSS_PX: @@ -70,6 +68,19 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type) case CSSPrimitiveValue::CSS_REMS: case CSSPrimitiveValue::CSS_CHS: return CalcLength; + case CSSPrimitiveValue::CSS_PERCENTAGE: + return CalcPercent; + case CSSPrimitiveValue::CSS_DEG: + case CSSPrimitiveValue::CSS_RAD: + case CSSPrimitiveValue::CSS_GRAD: + case CSSPrimitiveValue::CSS_TURN: + return CalcAngle; + case CSSPrimitiveValue::CSS_MS: + case CSSPrimitiveValue::CSS_S: + return CalcTime; + case CSSPrimitiveValue::CSS_HZ: + case CSSPrimitiveValue::CSS_KHZ: + return CalcFrequency; #if ENABLE(CSS_VARIABLES) case CSSPrimitiveValue::CSS_VARIABLE_NAME: return CalcVariable; @@ -254,6 +265,9 @@ public: // Only types that could be part of a Length expression can be converted // to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length. case CalcPercentNumber: + case CalcAngle: + case CalcTime: + case CalcFrequency: #if ENABLE(CSS_VARIABLES) case CalcVariable: #endif @@ -281,6 +295,9 @@ public: return m_value->getDoubleValue(); case CalcPercentLength: case CalcPercentNumber: + case CalcAngle: + case CalcTime: + case CalcFrequency: #if ENABLE(CSS_VARIABLES) case CalcVariable: #endif @@ -316,7 +333,7 @@ private: RefPtr<CSSPrimitiveValue> m_value; }; -static const CalculationCategory addSubtractResult[CalcOther][CalcOther] = { +static const CalculationCategory addSubtractResult[CalcAngle][CalcAngle] = { // CalcNumber CalcLength CalcPercent CalcPercentNumber CalcPercentLength { CalcNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther }, // CalcNumber { CalcOther, CalcLength, CalcPercentLength, CalcOther, CalcPercentLength }, // CalcLength @@ -341,7 +358,11 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi switch (op) { case CalcAdd: case CalcSubtract: - return addSubtractResult[leftCategory][rightCategory]; + if (leftCategory < CalcAngle || rightCategory < CalcAngle) + return addSubtractResult[leftCategory][rightCategory]; + if (leftCategory == rightCategory) + return leftCategory; + return CalcOther; case CalcMultiply: if (leftCategory != CalcNumber && rightCategory != CalcNumber) return CalcOther; @@ -532,6 +553,12 @@ public: #endif case CalcPercentLength: case CalcPercentNumber: + case CalcAngle: + return CSSPrimitiveValue::CSS_DEG; + case CalcTime: + return CSSPrimitiveValue::CSS_MS; + case CalcFrequency: + return CSSPrimitiveValue::CSS_HZ; case CalcOther: return CSSPrimitiveValue::CSS_UNKNOWN; } |