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/CSSNumericValue.h" | 8 #include "core/css/cssom/CSSNumericValue.h" |
9 #include "core/css/cssom/CSSTransformComponent.h" | 9 #include "core/css/cssom/CSSTransformComponent.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class DOMMatrix; | 13 class DOMMatrix; |
14 class ExceptionState; | 14 class ExceptionState; |
15 | 15 |
16 // Represents a rotation value in a CSSTransformValue used for properties like | 16 // Represents a rotation value in a CSSTransformValue used for properties like |
17 // "transform". | 17 // "transform". |
18 // See CSSRotation.idl for more information about this class. | 18 // See CSSRotation.idl for more information about this class. |
19 class CORE_EXPORT CSSRotation final : public CSSTransformComponent { | 19 class CORE_EXPORT CSSRotation final : public CSSTransformComponent { |
20 WTF_MAKE_NONCOPYABLE(CSSRotation); | 20 WTF_MAKE_NONCOPYABLE(CSSRotation); |
21 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
22 | 22 |
23 public: | 23 public: |
24 // Constructors defined in the IDL. | 24 // Constructors defined in the IDL. |
25 static CSSRotation* Create(CSSNumericValue* angle, | 25 static CSSRotation* Create(CSSNumericValue* angle, ExceptionState&); |
26 ExceptionState& exception_state) { | |
27 return Create(0, 0, 1, angle, exception_state); | |
28 } | |
29 static CSSRotation* Create(double x, | 26 static CSSRotation* Create(double x, |
30 double y, | 27 double y, |
31 double z, | 28 double z, |
32 CSSNumericValue* angle, | 29 CSSNumericValue* angle, |
33 ExceptionState&); | 30 ExceptionState&); |
34 | 31 |
35 // Blink-internal ways of creating CSSRotations. | 32 // Blink-internal ways of creating CSSRotations. |
36 static CSSRotation* Create(CSSNumericValue* angle) { | 33 static CSSRotation* Create(CSSNumericValue* angle); |
37 return Create(0, 0, 1, angle); | |
38 } | |
39 static CSSRotation* Create(double x, | 34 static CSSRotation* Create(double x, |
40 double y, | 35 double y, |
41 double z, | 36 double z, |
42 CSSNumericValue* angle); | 37 CSSNumericValue* angle); |
43 static CSSRotation* FromCSSValue(const CSSFunctionValue&); | 38 static CSSRotation* FromCSSValue(const CSSFunctionValue&); |
44 | 39 |
45 // Getters and setters for attributes defined in the IDL. | 40 // Getters and setters for attributes defined in the IDL. |
46 CSSNumericValue* angle() { return angle_.Get(); } | 41 CSSNumericValue* angle() { return angle_.Get(); } |
47 double x() const { return x_; } | 42 double x() const { return x_; } |
48 double y() const { return y_; } | 43 double y() const { return y_; } |
49 double z() const { return z_; } | 44 double z() const { return z_; } |
50 void setAngle(CSSNumericValue* angle, ExceptionState&); | 45 void setAngle(CSSNumericValue* angle, ExceptionState&); |
51 void setX(double x) { x_ = x; } | 46 void setX(double x) { x_ = x; } |
52 void setY(double y) { y_ = y; } | 47 void setY(double y) { y_ = y; } |
53 void setZ(double z) { z_ = z; } | 48 void setZ(double z) { z_ = z; } |
54 | 49 |
55 // Internal methods - from CSSTransformComponent. | 50 // Internal methods - from CSSTransformComponent. |
56 TransformComponentType GetType() const final { | 51 TransformComponentType GetType() const final { return kRotationType; } |
57 return z_ == 1 ? kRotationType : kRotation3DType; | |
58 } | |
59 DOMMatrix* AsMatrix() const final { | 52 DOMMatrix* AsMatrix() const final { |
60 return nullptr; | 53 return nullptr; |
61 // TODO(meade): Implement. | 54 // TODO(meade): Implement. |
62 // return z_ == 1 ? | 55 // return z_ == 1 ? |
63 // ? CSSMatrixComponent::Rotate( | 56 // ? CSSMatrixComponent::Rotate( |
64 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) | 57 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) |
65 // : CSSMatrixComponent::Rotate3d( | 58 // : CSSMatrixComponent::Rotate3d( |
66 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), | 59 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), |
67 // x_, y_, z_); | 60 // x_, y_, z_); |
68 } | 61 } |
69 CSSFunctionValue* ToCSSValue() const final; | 62 CSSFunctionValue* ToCSSValue() const final; |
70 | 63 |
71 DEFINE_INLINE_VIRTUAL_TRACE() { | 64 DEFINE_INLINE_VIRTUAL_TRACE() { |
72 visitor->Trace(angle_); | 65 visitor->Trace(angle_); |
73 CSSTransformComponent::Trace(visitor); | 66 CSSTransformComponent::Trace(visitor); |
74 } | 67 } |
75 | 68 |
76 private: | 69 private: |
77 CSSRotation(double x, double y, double z, CSSNumericValue* angle) | 70 CSSRotation(double x, double y, double z, CSSNumericValue* angle, bool is2D) |
78 : angle_(angle), x_(x), y_(y), z_(z) {} | 71 : CSSTransformComponent(is2D), angle_(angle), x_(x), y_(y), z_(z) {} |
79 | 72 |
80 Member<CSSNumericValue> angle_; | 73 Member<CSSNumericValue> angle_; |
81 double x_; | 74 double x_; |
82 double y_; | 75 double y_; |
83 double z_; | 76 double z_; |
84 }; | 77 }; |
85 | 78 |
86 } // namespace blink | 79 } // namespace blink |
87 | 80 |
88 #endif | 81 #endif |
OLD | NEW |