Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp |
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp b/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp |
| index cfd66913b82358efa92a20fa69bd0a14e9f2a4ce..0af914aeddd8872758fd76106048a1b45c035ca1 100644 |
| --- a/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp |
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp |
| @@ -6,15 +6,53 @@ |
| #include "core/css/CSSFunctionValue.h" |
| #include "core/css/CSSPrimitiveValue.h" |
| +#include "core/css/cssom/CSSAngleValue.h" |
| namespace blink { |
| +CSSSkew* CSSSkew::fromCSSValue(const CSSFunctionValue& value) { |
| + const CSSPrimitiveValue& xValue = toCSSPrimitiveValue(value.item(0)); |
| + if (xValue.isCalculated()) { |
|
Timothy Loh
2016/11/29 03:49:37
Maybe add a TODO to handle this and the below calc
meade_UTC10
2016/11/29 05:18:03
Done.
|
| + return nullptr; |
| + } |
| + DCHECK(xValue.isAngle()); |
| + switch (value.functionType()) { |
| + case CSSValueSkew: |
| + if (value.length() == 2U) { |
| + const CSSPrimitiveValue& yValue = toCSSPrimitiveValue(value.item(1)); |
| + if (yValue.isCalculated()) { |
| + return nullptr; |
| + } |
| + DCHECK(yValue.isAngle()); |
| + return CSSSkew::create( |
| + CSSAngleValue::create(xValue.getDoubleValue(), |
| + xValue.typeWithCalcResolved()), |
| + CSSAngleValue::create(yValue.getDoubleValue(), |
| + yValue.typeWithCalcResolved())); |
| + } |
| + // Else fall through; skew(ax) == skewX(ax). |
| + case CSSValueSkewX: |
| + DCHECK_EQ(value.length(), 1U); |
| + return CSSSkew::create( |
| + CSSAngleValue::create(xValue.getDoubleValue(), |
| + xValue.typeWithCalcResolved()), |
| + CSSAngleValue::create(0, CSSPrimitiveValue::UnitType::Degrees)); |
| + case CSSValueSkewY: |
| + DCHECK_EQ(value.length(), 1U); |
| + return CSSSkew::create( |
| + CSSAngleValue::create(0, CSSPrimitiveValue::UnitType::Degrees), |
| + CSSAngleValue::create(xValue.getDoubleValue(), |
| + xValue.typeWithCalcResolved())); |
| + default: |
| + NOTREACHED(); |
| + return nullptr; |
| + } |
| +} |
| + |
| CSSFunctionValue* CSSSkew::toCSSValue() const { |
| CSSFunctionValue* result = CSSFunctionValue::create(CSSValueSkew); |
| - result->append(*CSSPrimitiveValue::create( |
| - m_ax->degrees(), CSSPrimitiveValue::UnitType::Number)); |
| - result->append(*CSSPrimitiveValue::create( |
| - m_ay->degrees(), CSSPrimitiveValue::UnitType::Number)); |
| + result->append(*CSSPrimitiveValue::create(m_ax->value(), m_ax->unit())); |
| + result->append(*CSSPrimitiveValue::create(m_ay->value(), m_ay->unit())); |
| return result; |
| } |