| 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 CSSTranslation_h | 5 #ifndef CSSTranslation_h |
| 6 #define CSSTranslation_h | 6 #define CSSTranslation_h |
| 7 | 7 |
| 8 #include "core/css/cssom/CSSTransformComponent.h" | 8 #include "core/css/cssom/CSSTransformComponent.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 class CSSNumericValue; | 12 class CSSNumericValue; |
| 13 class DOMMatrix; | 13 class DOMMatrix; |
| 14 class ExceptionState; | 14 class ExceptionState; |
| 15 | 15 |
| 16 // Represents a translation value in a CSSTransformValue used for properties |
| 17 // like "transform". |
| 18 // See CSSTranslation.idl for more information about this class. |
| 16 class CORE_EXPORT CSSTranslation final : public CSSTransformComponent { | 19 class CORE_EXPORT CSSTranslation final : public CSSTransformComponent { |
| 17 WTF_MAKE_NONCOPYABLE(CSSTranslation); | 20 WTF_MAKE_NONCOPYABLE(CSSTranslation); |
| 18 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
| 19 | 22 |
| 20 public: | 23 public: |
| 24 // Constructors defined in the IDL. |
| 21 static CSSTranslation* Create(CSSNumericValue* x, | 25 static CSSTranslation* Create(CSSNumericValue* x, |
| 22 CSSNumericValue* y, | 26 CSSNumericValue* y, |
| 23 ExceptionState&) { | 27 ExceptionState&) { |
| 24 return new CSSTranslation(x, y, nullptr); | 28 return new CSSTranslation(x, y, nullptr); |
| 25 } | 29 } |
| 26 static CSSTranslation* Create(CSSNumericValue* x, | 30 static CSSTranslation* Create(CSSNumericValue* x, |
| 27 CSSNumericValue* y, | 31 CSSNumericValue* y, |
| 28 CSSNumericValue* z, | 32 CSSNumericValue* z, |
| 29 ExceptionState&); | 33 ExceptionState&); |
| 30 | 34 |
| 35 // Blink-internal ways of creating CSSTranslations. |
| 31 static CSSTranslation* FromCSSValue(const CSSFunctionValue& value) { | 36 static CSSTranslation* FromCSSValue(const CSSFunctionValue& value) { |
| 32 return nullptr; | 37 return nullptr; |
| 33 } | 38 } |
| 34 | 39 |
| 40 // Getters and setters for attributes defined in the IDL. |
| 35 CSSNumericValue* x() const { return x_; } | 41 CSSNumericValue* x() const { return x_; } |
| 36 CSSNumericValue* y() const { return y_; } | 42 CSSNumericValue* y() const { return y_; } |
| 37 CSSNumericValue* z() const { return z_; } | 43 CSSNumericValue* z() const { return z_; } |
| 38 | 44 |
| 45 // Internal methods - from CSSTransformComponent. |
| 39 TransformComponentType GetType() const override { | 46 TransformComponentType GetType() const override { |
| 40 return Is2D() ? kTranslationType : kTranslation3DType; | 47 return Is2D() ? kTranslationType : kTranslation3DType; |
| 41 } | 48 } |
| 42 | |
| 43 // TODO: Implement AsMatrix for CSSTranslation. | 49 // TODO: Implement AsMatrix for CSSTranslation. |
| 44 DOMMatrix* AsMatrix() const override { return nullptr; } | 50 DOMMatrix* AsMatrix() const override { return nullptr; } |
| 45 | |
| 46 CSSFunctionValue* ToCSSValue() const override; | 51 CSSFunctionValue* ToCSSValue() const override; |
| 47 | 52 |
| 48 DEFINE_INLINE_VIRTUAL_TRACE() { | 53 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 49 visitor->Trace(x_); | 54 visitor->Trace(x_); |
| 50 visitor->Trace(y_); | 55 visitor->Trace(y_); |
| 51 visitor->Trace(z_); | 56 visitor->Trace(z_); |
| 52 CSSTransformComponent::Trace(visitor); | 57 CSSTransformComponent::Trace(visitor); |
| 53 } | 58 } |
| 54 | 59 |
| 55 private: | 60 private: |
| 56 CSSTranslation(CSSNumericValue* x, CSSNumericValue* y, CSSNumericValue* z) | 61 CSSTranslation(CSSNumericValue* x, CSSNumericValue* y, CSSNumericValue* z) |
| 57 : CSSTransformComponent(), x_(x), y_(y), z_(z) {} | 62 : CSSTransformComponent(), x_(x), y_(y), z_(z) {} |
| 58 | 63 |
| 59 bool Is2D() const { return !z_; } | 64 bool Is2D() const { return !z_; } |
| 60 | 65 |
| 61 Member<CSSNumericValue> x_; | 66 Member<CSSNumericValue> x_; |
| 62 Member<CSSNumericValue> y_; | 67 Member<CSSNumericValue> y_; |
| 63 Member<CSSNumericValue> z_; | 68 Member<CSSNumericValue> z_; |
| 64 }; | 69 }; |
| 65 | 70 |
| 66 } // namespace blink | 71 } // namespace blink |
| 67 | 72 |
| 68 #endif | 73 #endif |
| OLD | NEW |