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

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

Issue 1648853002: Typed CSS OM: implement TransformComponent::asMatrix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@asMatrixTransformMethod
Patch Set: Use TransformationMatrix::create Created 4 years, 10 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
Index: third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp b/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp
index 2c60e76e2b9db513ad928c275de8c85e71931873..b7295f8cf5f8cfda6620e890df4192f31b4783df 100644
--- a/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp
@@ -6,6 +6,8 @@
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValuePool.h"
+#include "wtf/MathExtras.h"
+#include <cmath>
namespace blink {
@@ -29,4 +31,71 @@ PassRefPtrWillBeRawPtr<CSSFunctionValue> MatrixTransformComponent::toCSSValue()
return result.release();
}
+MatrixTransformComponent* MatrixTransformComponent::perspective(double length)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ if (length != 0)
+ matrix->setM34(-1 / length);
+ return new MatrixTransformComponent(matrix.release(), PerspectiveType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::rotate(double angle)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->rotate(angle);
+ return new MatrixTransformComponent(matrix.release(), RotationType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::rotate3d(double angle, double x, double y, double z)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->rotate3d(x, y, z, angle);
+ return new MatrixTransformComponent(matrix.release(), Rotation3DType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::scale(double x, double y)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->setM11(x);
+ matrix->setM22(y);
+ return new MatrixTransformComponent(matrix.release(), ScaleType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::scale3d(double x, double y, double z)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->setM11(x);
+ matrix->setM22(y);
+ matrix->setM33(z);
+ return new MatrixTransformComponent(matrix.release(), Scale3DType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::skew(double ax, double ay)
+{
+ double tanAx = std::tan(deg2rad(ax));
+ double tanAy = std::tan(deg2rad(ay));
+
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->setM12(tanAy);
+ matrix->setM21(tanAx);
+ return new MatrixTransformComponent(matrix.release(), SkewType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::translate(double x, double y)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->setM41(x);
+ matrix->setM42(y);
+ return new MatrixTransformComponent(matrix.release(), TranslateType);
+}
+
+MatrixTransformComponent* MatrixTransformComponent::translate3d(double x, double y, double z)
+{
+ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create();
+ matrix->setM41(x);
+ matrix->setM42(y);
+ matrix->setM43(z);
+ return new MatrixTransformComponent(matrix.release(), Translate3DType);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698