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 CSSRotation_h | 5 #ifndef CSSRotation_h |
6 #define CSSRotation_h | 6 #define CSSRotation_h |
7 | 7 |
8 #include "core/css/cssom/CSSAngleValue.h" | |
9 #include "core/css/cssom/CSSMatrixComponent.h" | 8 #include "core/css/cssom/CSSMatrixComponent.h" |
| 9 #include "core/css/cssom/CSSNumericValue.h" |
10 #include "core/css/cssom/CSSTransformComponent.h" | 10 #include "core/css/cssom/CSSTransformComponent.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class CORE_EXPORT CSSRotation final : public CSSTransformComponent { | 14 class CORE_EXPORT CSSRotation final : public CSSTransformComponent { |
15 WTF_MAKE_NONCOPYABLE(CSSRotation); | 15 WTF_MAKE_NONCOPYABLE(CSSRotation); |
16 DEFINE_WRAPPERTYPEINFO(); | 16 DEFINE_WRAPPERTYPEINFO(); |
17 | 17 |
18 public: | 18 public: |
19 static CSSRotation* Create(const CSSAngleValue* angle_value) { | 19 static CSSRotation* Create(const CSSNumericValue* angle_value) { |
20 return new CSSRotation(angle_value); | 20 return new CSSRotation(angle_value); |
21 } | 21 } |
22 | 22 |
23 static CSSRotation* Create(double x, | 23 static CSSRotation* Create(double x, |
24 double y, | 24 double y, |
25 double z, | 25 double z, |
26 const CSSAngleValue* angle_value) { | 26 const CSSNumericValue* angle_value) { |
27 return new CSSRotation(x, y, z, angle_value); | 27 return new CSSRotation(x, y, z, angle_value); |
28 } | 28 } |
29 | 29 |
30 static CSSRotation* FromCSSValue(const CSSFunctionValue&); | 30 static CSSRotation* FromCSSValue(const CSSFunctionValue&); |
31 | 31 |
32 // Bindings requires returning non-const pointers. This is safe because | 32 // Bindings requires returning non-const pointers. This is safe because |
33 // CSSAngleValues are immutable. | 33 // CSSNumericValues are immutable. |
34 CSSAngleValue* angle() const { | 34 CSSNumericValue* angle() const { |
35 return const_cast<CSSAngleValue*>(angle_.Get()); | 35 return const_cast<CSSNumericValue*>(angle_.Get()); |
36 } | 36 } |
37 double x() const { return x_; } | 37 double x() const { return x_; } |
38 double y() const { return y_; } | 38 double y() const { return y_; } |
39 double z() const { return z_; } | 39 double z() const { return z_; } |
40 | 40 |
41 TransformComponentType GetType() const override { | 41 TransformComponentType GetType() const override { |
42 return is2d_ ? kRotationType : kRotation3DType; | 42 return is2d_ ? kRotationType : kRotation3DType; |
43 } | 43 } |
44 | 44 |
45 CSSMatrixComponent* asMatrix() const override { | 45 CSSMatrixComponent* asMatrix() const override { |
46 return is2d_ ? CSSMatrixComponent::Rotate(angle_->degrees()) | 46 return nullptr; |
47 : CSSMatrixComponent::Rotate3d(angle_->degrees(), x_, y_, z_); | 47 // TODO(meade): Implement. |
| 48 // return is2d_ |
| 49 // ? CSSMatrixComponent::Rotate( |
| 50 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) |
| 51 // : CSSMatrixComponent::Rotate3d( |
| 52 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), |
| 53 // x_, y_, z_); |
48 } | 54 } |
49 | 55 |
50 CSSFunctionValue* ToCSSValue() const override; | 56 CSSFunctionValue* ToCSSValue() const override; |
51 | 57 |
52 DEFINE_INLINE_VIRTUAL_TRACE() { | 58 DEFINE_INLINE_VIRTUAL_TRACE() { |
53 visitor->Trace(angle_); | 59 visitor->Trace(angle_); |
54 CSSTransformComponent::Trace(visitor); | 60 CSSTransformComponent::Trace(visitor); |
55 } | 61 } |
56 | 62 |
57 private: | 63 private: |
58 CSSRotation(const CSSAngleValue* angle) | 64 CSSRotation(const CSSNumericValue* angle) |
59 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {} | 65 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {} |
60 | 66 |
61 CSSRotation(double x, double y, double z, const CSSAngleValue* angle) | 67 CSSRotation(double x, double y, double z, const CSSNumericValue* angle) |
62 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {} | 68 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {} |
63 | 69 |
64 Member<const CSSAngleValue> angle_; | 70 Member<const CSSNumericValue> angle_; |
65 double x_; | 71 double x_; |
66 double y_; | 72 double y_; |
67 double z_; | 73 double z_; |
68 bool is2d_; | 74 bool is2d_; |
69 }; | 75 }; |
70 | 76 |
71 } // namespace blink | 77 } // namespace blink |
72 | 78 |
73 #endif | 79 #endif |
OLD | NEW |