Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp

Issue 2039093003: [Typed OM] Implement CSSValue->CSSRotation conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to HEAD Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSRotation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSRotation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698