Chromium Code Reviews| 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 | 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. | |
| 38 // Bindings require a non const return value. | |
|
rjwright
2017/06/16 06:13:04
Duplicate with the line below?
meade_UTC10
2017/06/16 06:43:14
removed
| |
| 33 // Bindings requires returning non-const pointers. This is safe because | 39 // Bindings requires returning non-const pointers. This is safe because |
| 34 // CSSNumericValues are immutable. | 40 // CSSNumericValues are immutable. |
| 35 CSSNumericValue* angle() const { | 41 CSSNumericValue* angle() const { |
| 36 return const_cast<CSSNumericValue*>(angle_.Get()); | 42 return const_cast<CSSNumericValue*>(angle_.Get()); |
| 37 } | 43 } |
| 38 double x() const { return x_; } | 44 double x() const { return x_; } |
| 39 double y() const { return y_; } | 45 double y() const { return y_; } |
| 40 double z() const { return z_; } | 46 double z() const { return z_; } |
| 41 | 47 |
| 48 // Internal methods - from CSSTransformComponent. | |
| 42 TransformComponentType GetType() const override { | 49 TransformComponentType GetType() const override { |
| 43 return is2d_ ? kRotationType : kRotation3DType; | 50 return is2d_ ? kRotationType : kRotation3DType; |
| 44 } | 51 } |
| 45 | |
| 46 DOMMatrix* AsMatrix() const override { | 52 DOMMatrix* AsMatrix() const override { |
| 47 return nullptr; | 53 return nullptr; |
| 48 // TODO(meade): Implement. | 54 // TODO(meade): Implement. |
| 49 // return is2d_ | 55 // return is2d_ |
| 50 // ? CSSMatrixComponent::Rotate( | 56 // ? CSSMatrixComponent::Rotate( |
| 51 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) | 57 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value()) |
| 52 // : CSSMatrixComponent::Rotate3d( | 58 // : CSSMatrixComponent::Rotate3d( |
| 53 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), | 59 // angle_->to(CSSPrimitiveValue::UnitType::kDegrees)->value(), |
| 54 // x_, y_, z_); | 60 // x_, y_, z_); |
| 55 } | 61 } |
| 56 | |
| 57 CSSFunctionValue* ToCSSValue() const override; | 62 CSSFunctionValue* ToCSSValue() const override; |
| 58 | 63 |
| 59 DEFINE_INLINE_VIRTUAL_TRACE() { | 64 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 60 visitor->Trace(angle_); | 65 visitor->Trace(angle_); |
| 61 CSSTransformComponent::Trace(visitor); | 66 CSSTransformComponent::Trace(visitor); |
| 62 } | 67 } |
| 63 | 68 |
| 64 private: | 69 private: |
| 65 CSSRotation(const CSSNumericValue* angle) | 70 CSSRotation(const CSSNumericValue* angle) |
| 66 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {} | 71 : angle_(angle), x_(0), y_(0), z_(1), is2d_(true) {} |
| 67 | 72 |
| 68 CSSRotation(double x, double y, double z, const CSSNumericValue* angle) | 73 CSSRotation(double x, double y, double z, const CSSNumericValue* angle) |
| 69 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {} | 74 : angle_(angle), x_(x), y_(y), z_(z), is2d_(false) {} |
| 70 | 75 |
| 71 Member<const CSSNumericValue> angle_; | 76 Member<const CSSNumericValue> angle_; |
| 72 double x_; | 77 double x_; |
| 73 double y_; | 78 double y_; |
| 74 double z_; | 79 double z_; |
| 75 bool is2d_; | 80 bool is2d_; |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 } // namespace blink | 83 } // namespace blink |
| 79 | 84 |
| 80 #endif | 85 #endif |
| OLD | NEW |