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..2197a95f38dce64c03bdf1dd3dc7c48996e5f225 100644 |
--- a/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp |
+++ b/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp |
@@ -4,10 +4,57 @@ |
#include "core/css/cssom/CSSRotation.h" |
+#include "core/css/CSSFunctionValue.h" |
#include "core/css/CSSPrimitiveValue.h" |
namespace blink { |
+namespace { |
+ |
+bool isAngleValue(const CSSValue& value) |
+{ |
+ if (!value.isPrimitiveValue()) |
+ return false; |
+ return toCSSPrimitiveValue(value).isAngle(); |
+} |
+ |
+bool isNumberValue(const CSSValue& value) |
+{ |
+ if (!value.isPrimitiveValue()) |
+ return false; |
+ return toCSSPrimitiveValue(value).isNumber(); |
+} |
+ |
+} // namespace |
+ |
+CSSRotation* CSSRotation::fromCSSValue(const CSSFunctionValue& value) |
+{ |
+ if (value.functionType() == CSSValueRotate) { |
Timothy Loh
2016/06/15 08:36:26
This also needs to support rotatex/y/z, and test f
meade_UTC10
2016/06/23 21:51:44
Done.
|
+ if (value.length() != 1) |
Timothy Loh
2016/06/15 08:36:26
All of these checks should just be assertions beca
meade_UTC10
2016/06/23 21:51:44
Done.
|
+ return nullptr; |
+ if (!isAngleValue(value.item(0))) |
+ return nullptr; |
+ return CSSRotation::create(toCSSPrimitiveValue(value.item(0)).computeDegrees()); |
+ } |
+ |
+ if (value.functionType() == CSSValueRotate3d) { |
+ if (value.length() != 4) |
+ return nullptr; |
+ if (!isNumberValue(value.item(0)) |
+ || !isNumberValue(value.item(1)) |
+ || !isNumberValue(value.item(2)) |
+ || !isAngleValue(value.item(3))) |
+ return nullptr; |
+ 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); |
+ } |
+ |
+ return nullptr; |
+} |
+ |
CSSFunctionValue* CSSRotation::toCSSValue() const |
{ |
CSSFunctionValue* result = CSSFunctionValue::create(m_is2D ? CSSValueRotate : CSSValueRotate3d); |