| Index: third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp b/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp
|
| index bb4783b3a0bd4ef643be1ccce4ce98c513a835bc..aac3f64c9562a4aba24c07d73778414c64ae7f58 100644
|
| --- a/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp
|
| +++ b/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp
|
| @@ -11,20 +11,27 @@
|
|
|
| namespace blink {
|
|
|
| +CSSMatrixComponent* CSSMatrixComponent::Create(DOMMatrixReadOnly* matrix) {
|
| + return new CSSMatrixComponent(matrix);
|
| +}
|
| +
|
| CSSFunctionValue* CSSMatrixComponent::ToCSSValue() const {
|
| CSSFunctionValue* result =
|
| CSSFunctionValue::Create(is2d_ ? CSSValueMatrix : CSSValueMatrix3d);
|
|
|
| if (is2d_) {
|
| - double values[6] = {a(), b(), c(), d(), e(), f()};
|
| + double values[6] = {matrix()->a(), matrix()->b(), matrix()->c(),
|
| + matrix()->d(), matrix()->e(), matrix()->f()};
|
| for (double value : values) {
|
| result->Append(*CSSPrimitiveValue::Create(
|
| value, CSSPrimitiveValue::UnitType::kNumber));
|
| }
|
| } else {
|
| - double values[16] = {m11(), m12(), m13(), m14(), m21(), m22(),
|
| - m23(), m24(), m31(), m32(), m33(), m34(),
|
| - m41(), m42(), m43(), m44()};
|
| + double values[16] = {
|
| + matrix()->m11(), matrix()->m12(), matrix()->m13(), matrix()->m14(),
|
| + matrix()->m21(), matrix()->m22(), matrix()->m23(), matrix()->m24(),
|
| + matrix()->m31(), matrix()->m32(), matrix()->m33(), matrix()->m34(),
|
| + matrix()->m41(), matrix()->m42(), matrix()->m43(), matrix()->m44()};
|
| for (double value : values) {
|
| result->Append(*CSSPrimitiveValue::Create(
|
| value, CSSPrimitiveValue::UnitType::kNumber));
|
| @@ -35,67 +42,96 @@ CSSFunctionValue* CSSMatrixComponent::ToCSSValue() const {
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Perspective(double length) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| if (length != 0)
|
| - matrix->SetM34(-1 / length);
|
| - return new CSSMatrixComponent(std::move(matrix), kPerspectiveType);
|
| + matrix->setM34(-1 / length);
|
| + return new CSSMatrixComponent(matrix, kPerspectiveType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Rotate(double angle) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->Rotate(angle);
|
| - return new CSSMatrixComponent(std::move(matrix), kRotationType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->rotateSelf(angle);
|
| + return new CSSMatrixComponent(matrix, kRotationType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Rotate3d(double angle,
|
| double x,
|
| double y,
|
| double z) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->Rotate3d(x, y, z, angle);
|
| - return new CSSMatrixComponent(std::move(matrix), kRotation3DType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->rotateAxisAngleSelf(x, y, z, angle);
|
| + return new CSSMatrixComponent(matrix, kRotation3DType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Scale(double x, double y) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->SetM11(x);
|
| - matrix->SetM22(y);
|
| - return new CSSMatrixComponent(std::move(matrix), kScaleType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->setM11(x);
|
| + matrix->setM22(y);
|
| + return new CSSMatrixComponent(matrix, kScaleType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Scale3d(double x, double y, double z) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->SetM11(x);
|
| - matrix->SetM22(y);
|
| - matrix->SetM33(z);
|
| - return new CSSMatrixComponent(std::move(matrix), kScale3DType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->setM11(x);
|
| + matrix->setM22(y);
|
| + matrix->setM33(z);
|
| + return new CSSMatrixComponent(matrix, kScale3DType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Skew(double ax, double ay) {
|
| double tan_ax = std::tan(deg2rad(ax));
|
| double tan_ay = std::tan(deg2rad(ay));
|
|
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->SetM12(tan_ay);
|
| - matrix->SetM21(tan_ax);
|
| - return new CSSMatrixComponent(std::move(matrix), kSkewType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->setM12(tan_ay);
|
| + matrix->setM21(tan_ax);
|
| + return new CSSMatrixComponent(matrix, kSkewType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Translate(double x, double y) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->SetM41(x);
|
| - matrix->SetM42(y);
|
| - return new CSSMatrixComponent(std::move(matrix), kTranslationType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->setM41(x);
|
| + matrix->setM42(y);
|
| + return new CSSMatrixComponent(matrix, kTranslationType);
|
| }
|
|
|
| CSSMatrixComponent* CSSMatrixComponent::Translate3d(double x,
|
| double y,
|
| double z) {
|
| - std::unique_ptr<TransformationMatrix> matrix = TransformationMatrix::Create();
|
| - matrix->SetM41(x);
|
| - matrix->SetM42(y);
|
| - matrix->SetM43(z);
|
| - return new CSSMatrixComponent(std::move(matrix), kTranslation3DType);
|
| + DOMMatrixInit init;
|
| + DOMMatrix* matrix = DOMMatrix::fromMatrix(init, ASSERT_NO_EXCEPTION);
|
| +
|
| + matrix->setM41(x);
|
| + matrix->setM42(y);
|
| + matrix->setM43(z);
|
| + return new CSSMatrixComponent(matrix, kTranslation3DType);
|
| +}
|
| +
|
| +CSSMatrixComponent::CSSMatrixComponent(DOMMatrixReadOnly* matrix)
|
| + : CSSTransformComponent() {
|
| + matrix_ = DOMMatrix::Create(matrix);
|
| + is2d_ = matrix->is2D();
|
| +}
|
| +
|
| +CSSMatrixComponent::CSSMatrixComponent(DOMMatrixReadOnly* matrix,
|
| + TransformComponentType from_type)
|
| + : CSSTransformComponent() {
|
| + matrix_ = DOMMatrix::Create(matrix);
|
| + is2d_ = Is2DComponentType(from_type);
|
| }
|
|
|
| } // namespace blink
|
|
|