| Index: third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp b/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
|
| index 8e5e1a1a8b3caee3d8c49834814378c130295093..6e41630a86dd98bce9b9242cb26abc0db1835ade 100644
|
| --- a/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
|
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
|
| @@ -4,10 +4,76 @@
|
|
|
| #include "core/css/cssom/CSSRotation.h"
|
|
|
| +#include "core/css/CSSFunctionValue.h"
|
| #include "core/css/CSSPrimitiveValue.h"
|
|
|
| namespace blink {
|
|
|
| +namespace {
|
| +
|
| +bool isNumberValue(const CSSValue& value)
|
| +{
|
| + return value.isPrimitiveValue() && toCSSPrimitiveValue(value).isNumber();
|
| +}
|
| +
|
| +CSSRotation* fromCSSRotate(const CSSFunctionValue& value)
|
| +{
|
| + DCHECK_EQ(value.length(), 1UL);
|
| + return CSSRotation::create(toCSSPrimitiveValue(value.item(0)).computeDegrees());
|
| +}
|
| +
|
| +CSSRotation* fromCSSRotate3d(const CSSFunctionValue& value)
|
| +{
|
| + DCHECK_EQ(value.length(), 4UL);
|
| + DCHECK(isNumberValue(value.item(0)));
|
| + DCHECK(isNumberValue(value.item(1)));
|
| + DCHECK(isNumberValue(value.item(2)));
|
| + // computeDegrees asserts that value.item(3) is an angle.
|
| +
|
| + double x = toCSSPrimitiveValue(value.item(0)).getDoubleValue();
|
| + double y = toCSSPrimitiveValue(value.item(1)).getDoubleValue();
|
| + double z = toCSSPrimitiveValue(value.item(2)).getDoubleValue();
|
| + double angle = toCSSPrimitiveValue(value.item(3)).computeDegrees();
|
| + return CSSRotation::create(x, y, z, angle);
|
| +}
|
| +
|
| +CSSRotation* fromCSSRotateXYZ(const CSSFunctionValue& value)
|
| +{
|
| + DCHECK_EQ(value.length(), 1UL);
|
| + double angle = toCSSPrimitiveValue(value.item(0)).computeDegrees();
|
| +
|
| + switch (value.functionType()) {
|
| + case CSSValueRotateX:
|
| + return CSSRotation::create(1, 0, 0, angle);
|
| + case CSSValueRotateY:
|
| + return CSSRotation::create(0, 1, 0, angle);
|
| + case CSSValueRotateZ:
|
| + return CSSRotation::create(0, 0, 1, angle);
|
| + default:
|
| + NOTREACHED();
|
| + return nullptr;
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +CSSRotation* CSSRotation::fromCSSValue(const CSSFunctionValue& value)
|
| +{
|
| + switch (value.functionType()) {
|
| + case CSSValueRotate:
|
| + return fromCSSRotate(value);
|
| + case CSSValueRotate3d:
|
| + return fromCSSRotate3d(value);
|
| + case CSSValueRotateX:
|
| + case CSSValueRotateY:
|
| + case CSSValueRotateZ:
|
| + return fromCSSRotateXYZ(value);
|
| + default:
|
| + NOTREACHED();
|
| + return nullptr;
|
| + }
|
| +}
|
| +
|
| CSSFunctionValue* CSSRotation::toCSSValue() const
|
| {
|
| CSSFunctionValue* result = CSSFunctionValue::create(m_is2D ? CSSValueRotate : CSSValueRotate3d);
|
|
|