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

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

Issue 2942183002: [CSS Typed OM] Make CSSRotation attributes mutable. (Closed)
Patch Set: rebase Created 3 years, 5 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 class ExceptionState;
14 15
15 // Represents a rotation value in a CSSTransformValue used for properties like 16 // Represents a rotation value in a CSSTransformValue used for properties like
16 // "transform". 17 // "transform".
17 // See CSSRotation.idl for more information about this class. 18 // See CSSRotation.idl for more information about this class.
18 class CORE_EXPORT CSSRotation final : public CSSTransformComponent { 19 class CORE_EXPORT CSSRotation final : public CSSTransformComponent {
19 WTF_MAKE_NONCOPYABLE(CSSRotation); 20 WTF_MAKE_NONCOPYABLE(CSSRotation);
20 DEFINE_WRAPPERTYPEINFO(); 21 DEFINE_WRAPPERTYPEINFO();
21 22
22 public: 23 public:
23 // Constructors defined in the IDL. 24 // Constructors defined in the IDL.
(...skipping 11 matching lines...) Expand all
35 static CSSRotation* Create(CSSNumericValue* angle) { 36 static CSSRotation* Create(CSSNumericValue* angle) {
36 return Create(0, 0, 1, angle); 37 return Create(0, 0, 1, angle);
37 } 38 }
38 static CSSRotation* Create(double x, 39 static CSSRotation* Create(double x,
39 double y, 40 double y,
40 double z, 41 double z,
41 CSSNumericValue* angle); 42 CSSNumericValue* angle);
42 static CSSRotation* FromCSSValue(const CSSFunctionValue&); 43 static CSSRotation* FromCSSValue(const CSSFunctionValue&);
43 44
44 // Getters and setters for attributes defined in the IDL. 45 // Getters and setters for attributes defined in the IDL.
45 // Bindings requires returning non-const pointers. This is safe because 46 CSSNumericValue* angle() { return angle_.Get(); }
46 // CSSNumericValues are immutable.
47 CSSNumericValue* angle() const {
48 return const_cast<CSSNumericValue*>(angle_.Get());
49 }
50 double x() const { return x_; } 47 double x() const { return x_; }
51 double y() const { return y_; } 48 double y() const { return y_; }
52 double z() const { return z_; } 49 double z() const { return z_; }
50 void setAngle(CSSNumericValue* angle, ExceptionState&);
51 void setX(double x) { x_ = x; }
52 void setY(double y) { y_ = y; }
53 void setZ(double z) { z_ = z; }
53 54
54 // Internal methods - from CSSTransformComponent. 55 // Internal methods - from CSSTransformComponent.
55 TransformComponentType GetType() const override { 56 TransformComponentType GetType() const final {
56 return is2d_ ? kRotationType : kRotation3DType; 57 return z_ == 1 ? kRotationType : kRotation3DType;
57 } 58 }
58 DOMMatrix* AsMatrix() const override { 59 DOMMatrix* AsMatrix() const final {
59 return nullptr; 60 return nullptr;
60 // TODO(meade): Implement. 61 // TODO(meade): Implement.
61 // return is2d_ 62 // return z_ == 1 ?
62 // ? CSSMatrixComponent::Rotate( 63 // ? CSSMatrixComponent::Rotate(
63 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) 64 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value())
64 // : CSSMatrixComponent::Rotate3d( 65 // : CSSMatrixComponent::Rotate3d(
65 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), 66 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(),
66 // x_, y_, z_); 67 // x_, y_, z_);
67 } 68 }
68 CSSFunctionValue* ToCSSValue() const override; 69 CSSFunctionValue* ToCSSValue() const final;
69 70
70 DEFINE_INLINE_VIRTUAL_TRACE() { 71 DEFINE_INLINE_VIRTUAL_TRACE() {
71 visitor->Trace(angle_); 72 visitor->Trace(angle_);
72 CSSTransformComponent::Trace(visitor); 73 CSSTransformComponent::Trace(visitor);
73 } 74 }
74 75
75 private: 76 private:
76 CSSRotation(const CSSNumericValue* angle) 77 CSSRotation(double x, double y, double z, CSSNumericValue* angle)
77 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {} 78 : angle_(angle), x_(x), y_(y), z_(z) {}
78 79
79 CSSRotation(double x, double y, double z, const CSSNumericValue* angle) 80 Member<CSSNumericValue> angle_;
80 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {}
81
82 Member<const CSSNumericValue> angle_;
83 double x_; 81 double x_;
84 double y_; 82 double y_;
85 double z_; 83 double z_;
86 bool is2d_;
87 }; 84 };
88 85
89 } // namespace blink 86 } // namespace blink
90 87
91 #endif 88 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698