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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSRotation.h

Issue 2935413002: [Typed OM] Add comments and consistent structure to all the CSSTransformComponent subclasses (Closed)
Patch Set: rebase Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 14
15 // Represents a rotation value in a CSSTransformValue used for properties like
16 // "transform".
17 // See CSSRotation.idl for more information about this class.
15 class CORE_EXPORT CSSRotation final : public CSSTransformComponent { 18 class CORE_EXPORT CSSRotation final : public CSSTransformComponent {
16 WTF_MAKE_NONCOPYABLE(CSSRotation); 19 WTF_MAKE_NONCOPYABLE(CSSRotation);
17 DEFINE_WRAPPERTYPEINFO(); 20 DEFINE_WRAPPERTYPEINFO();
18 21
19 public: 22 public:
23 // Constructors defined in the IDL.
20 static CSSRotation* Create(const CSSNumericValue* angle_value) { 24 static CSSRotation* Create(const CSSNumericValue* angle_value) {
21 return new CSSRotation(angle_value); 25 return new CSSRotation(angle_value);
22 } 26 }
23
24 static CSSRotation* Create(double x, 27 static CSSRotation* Create(double x,
25 double y, 28 double y,
26 double z, 29 double z,
27 const CSSNumericValue* angle_value) { 30 const CSSNumericValue* angle_value) {
28 return new CSSRotation(x, y, z, angle_value); 31 return new CSSRotation(x, y, z, angle_value);
29 } 32 }
30 33
34 // Blink-internal ways of creating CSSRotations.
31 static CSSRotation* FromCSSValue(const CSSFunctionValue&); 35 static CSSRotation* FromCSSValue(const CSSFunctionValue&);
32 36
37 // Getters and setters for attributes defined in the IDL.
33 // Bindings requires returning non-const pointers. This is safe because 38 // Bindings requires returning non-const pointers. This is safe because
34 // CSSNumericValues are immutable. 39 // CSSNumericValues are immutable.
35 CSSNumericValue* angle() const { 40 CSSNumericValue* angle() const {
36 return const_cast<CSSNumericValue*>(angle_.Get()); 41 return const_cast<CSSNumericValue*>(angle_.Get());
37 } 42 }
38 double x() const { return x_; } 43 double x() const { return x_; }
39 double y() const { return y_; } 44 double y() const { return y_; }
40 double z() const { return z_; } 45 double z() const { return z_; }
41 46
47 // Internal methods - from CSSTransformComponent.
42 TransformComponentType GetType() const override { 48 TransformComponentType GetType() const override {
43 return is2d_ ? kRotationType : kRotation3DType; 49 return is2d_ ? kRotationType : kRotation3DType;
44 } 50 }
45
46 DOMMatrix* AsMatrix() const override { 51 DOMMatrix* AsMatrix() const override {
47 return nullptr; 52 return nullptr;
48 // TODO(meade): Implement. 53 // TODO(meade): Implement.
49 // return is2d_ 54 // return is2d_
50 // ? CSSMatrixComponent::Rotate( 55 // ? CSSMatrixComponent::Rotate(
51 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) 56 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value())
52 // : CSSMatrixComponent::Rotate3d( 57 // : CSSMatrixComponent::Rotate3d(
53 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), 58 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(),
54 // x_, y_, z_); 59 // x_, y_, z_);
55 } 60 }
56
57 CSSFunctionValue* ToCSSValue() const override; 61 CSSFunctionValue* ToCSSValue() const override;
58 62
59 DEFINE_INLINE_VIRTUAL_TRACE() { 63 DEFINE_INLINE_VIRTUAL_TRACE() {
60 visitor->Trace(angle_); 64 visitor->Trace(angle_);
61 CSSTransformComponent::Trace(visitor); 65 CSSTransformComponent::Trace(visitor);
62 } 66 }
63 67
64 private: 68 private:
65 CSSRotation(const CSSNumericValue* angle) 69 CSSRotation(const CSSNumericValue* angle)
66 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {} 70 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {}
67 71
68 CSSRotation(double x, double y, double z, const CSSNumericValue* angle) 72 CSSRotation(double x, double y, double z, const CSSNumericValue* angle)
69 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {} 73 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {}
70 74
71 Member<const CSSNumericValue> angle_; 75 Member<const CSSNumericValue> angle_;
72 double x_; 76 double x_;
73 double y_; 77 double y_;
74 double z_; 78 double z_;
75 bool is2d_; 79 bool is2d_;
76 }; 80 };
77 81
78 } // namespace blink 82 } // namespace blink
79 83
80 #endif 84 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSPerspective.h ('k') | third_party/WebKit/Source/core/css/cssom/CSSScale.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698