| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CSSMatrixComponent_h | 5 #ifndef CSSMatrixComponent_h |
| 6 #define CSSMatrixComponent_h | 6 #define CSSMatrixComponent_h |
| 7 | 7 |
| 8 #include <memory> | |
| 9 #include "core/css/cssom/CSSTransformComponent.h" | 8 #include "core/css/cssom/CSSTransformComponent.h" |
| 10 #include "core/geometry/DOMMatrix.h" | 9 #include "core/geometry/DOMMatrix.h" |
| 11 #include "platform/transforms/TransformationMatrix.h" | |
| 12 | 10 |
| 13 namespace blink { | 11 namespace blink { |
| 14 | 12 |
| 15 class DOMMatrixReadOnly; | 13 class DOMMatrixReadOnly; |
| 16 | 14 |
| 17 class CORE_EXPORT CSSMatrixComponent final : public CSSTransformComponent { | 15 class CORE_EXPORT CSSMatrixComponent final : public CSSTransformComponent { |
| 18 WTF_MAKE_NONCOPYABLE(CSSMatrixComponent); | 16 WTF_MAKE_NONCOPYABLE(CSSMatrixComponent); |
| 19 DEFINE_WRAPPERTYPEINFO(); | 17 DEFINE_WRAPPERTYPEINFO(); |
| 20 | 18 |
| 21 public: | 19 public: |
| 22 static CSSMatrixComponent* Create(DOMMatrixReadOnly*); | 20 static CSSMatrixComponent* Create(DOMMatrixReadOnly*); |
| 23 | 21 |
| 24 static CSSMatrixComponent* FromCSSValue(const CSSFunctionValue& value) { | 22 static CSSMatrixComponent* FromCSSValue(const CSSFunctionValue& value) { |
| 25 return nullptr; | 23 return nullptr; |
| 26 } | 24 } |
| 27 | 25 |
| 28 DOMMatrix* matrix() const { return matrix_; } | 26 DOMMatrix* matrix() const { return matrix_; } |
| 29 | 27 |
| 30 void setMatrix(DOMMatrix* matrix) { matrix_ = matrix; } | 28 void setMatrix(DOMMatrix* matrix) { matrix_ = matrix; } |
| 31 | 29 |
| 32 TransformComponentType GetType() const override { | 30 TransformComponentType GetType() const override { |
| 33 return is2d_ ? kMatrixType : kMatrix3DType; | 31 return is2d_ ? kMatrixType : kMatrix3DType; |
| 34 } | 32 } |
| 35 | 33 |
| 36 // Bindings require a non const return value. | 34 DOMMatrix* AsMatrix() const override { return matrix(); } |
| 37 CSSMatrixComponent* asMatrix() const override { | |
| 38 return const_cast<CSSMatrixComponent*>(this); | |
| 39 } | |
| 40 | 35 |
| 41 CSSFunctionValue* ToCSSValue() const override; | 36 CSSFunctionValue* ToCSSValue() const override; |
| 42 | 37 |
| 43 static CSSMatrixComponent* Perspective(double length); | |
| 44 | |
| 45 static CSSMatrixComponent* Rotate(double angle); | |
| 46 static CSSMatrixComponent* Rotate3d(double angle, | |
| 47 double x, | |
| 48 double y, | |
| 49 double z); | |
| 50 | |
| 51 static CSSMatrixComponent* Scale(double x, double y); | |
| 52 static CSSMatrixComponent* Scale3d(double x, double y, double z); | |
| 53 | |
| 54 static CSSMatrixComponent* Skew(double x, double y); | |
| 55 | |
| 56 static CSSMatrixComponent* Translate(double x, double y); | |
| 57 static CSSMatrixComponent* Translate3d(double x, double y, double z); | |
| 58 | |
| 59 DEFINE_INLINE_VIRTUAL_TRACE() { | 38 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 60 visitor->Trace(matrix_); | 39 visitor->Trace(matrix_); |
| 61 CSSTransformComponent::Trace(visitor); | 40 CSSTransformComponent::Trace(visitor); |
| 62 } | 41 } |
| 63 | 42 |
| 64 private: | 43 private: |
| 65 CSSMatrixComponent(DOMMatrixReadOnly*); | 44 CSSMatrixComponent(DOMMatrixReadOnly*); |
| 66 CSSMatrixComponent(DOMMatrixReadOnly*, TransformComponentType); | |
| 67 | 45 |
| 68 Member<DOMMatrix> matrix_; | 46 Member<DOMMatrix> matrix_; |
| 69 bool is2d_; | 47 bool is2d_; |
| 70 }; | 48 }; |
| 71 | 49 |
| 72 } // namespace blink | 50 } // namespace blink |
| 73 | 51 |
| 74 #endif | 52 #endif |
| OLD | NEW |