| 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/CSSLengthValue.h" | |
| 9 #include "core/css/cssom/CSSTransformComponent.h" | 8 #include "core/css/cssom/CSSTransformComponent.h" |
| 10 | 9 |
| 11 namespace blink { | 10 namespace blink { |
| 12 | 11 |
| 12 class CSSNumericValue; |
| 13 class ExceptionState; | 13 class ExceptionState; |
| 14 | 14 |
| 15 class CORE_EXPORT CSSTranslation final : public CSSTransformComponent { | 15 class CORE_EXPORT CSSTranslation final : public CSSTransformComponent { |
| 16 WTF_MAKE_NONCOPYABLE(CSSTranslation); | 16 WTF_MAKE_NONCOPYABLE(CSSTranslation); |
| 17 DEFINE_WRAPPERTYPEINFO(); | 17 DEFINE_WRAPPERTYPEINFO(); |
| 18 | 18 |
| 19 public: | 19 public: |
| 20 static CSSTranslation* Create(CSSLengthValue* x, | 20 static CSSTranslation* Create(CSSNumericValue* x, |
| 21 CSSLengthValue* y, | 21 CSSNumericValue* y, |
| 22 ExceptionState&) { | 22 ExceptionState&) { |
| 23 return new CSSTranslation(x, y, nullptr); | 23 return new CSSTranslation(x, y, nullptr); |
| 24 } | 24 } |
| 25 static CSSTranslation* Create(CSSLengthValue* x, | 25 static CSSTranslation* Create(CSSNumericValue* x, |
| 26 CSSLengthValue* y, | 26 CSSNumericValue* y, |
| 27 CSSLengthValue* z, | 27 CSSNumericValue* z, |
| 28 ExceptionState&); | 28 ExceptionState&); |
| 29 | 29 |
| 30 static CSSTranslation* FromCSSValue(const CSSFunctionValue& value) { | 30 static CSSTranslation* FromCSSValue(const CSSFunctionValue& value) { |
| 31 return nullptr; | 31 return nullptr; |
| 32 } | 32 } |
| 33 | 33 |
| 34 CSSLengthValue* x() const { return x_; } | 34 CSSNumericValue* x() const { return x_; } |
| 35 CSSLengthValue* y() const { return y_; } | 35 CSSNumericValue* y() const { return y_; } |
| 36 CSSLengthValue* z() const { return z_; } | 36 CSSNumericValue* z() const { return z_; } |
| 37 | 37 |
| 38 TransformComponentType GetType() const override { | 38 TransformComponentType GetType() const override { |
| 39 return Is2D() ? kTranslationType : kTranslation3DType; | 39 return Is2D() ? kTranslationType : kTranslation3DType; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // TODO: Implement asMatrix for CSSTranslation. | 42 // TODO: Implement asMatrix for CSSTranslation. |
| 43 CSSMatrixComponent* asMatrix() const override { return nullptr; } | 43 CSSMatrixComponent* asMatrix() const override { return nullptr; } |
| 44 | 44 |
| 45 CSSFunctionValue* ToCSSValue() const override; | 45 CSSFunctionValue* ToCSSValue() const override; |
| 46 | 46 |
| 47 DEFINE_INLINE_VIRTUAL_TRACE() { | 47 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 48 visitor->Trace(x_); | 48 visitor->Trace(x_); |
| 49 visitor->Trace(y_); | 49 visitor->Trace(y_); |
| 50 visitor->Trace(z_); | 50 visitor->Trace(z_); |
| 51 CSSTransformComponent::Trace(visitor); | 51 CSSTransformComponent::Trace(visitor); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 CSSTranslation(CSSLengthValue* x, CSSLengthValue* y, CSSLengthValue* z) | 55 CSSTranslation(CSSNumericValue* x, CSSNumericValue* y, CSSNumericValue* z) |
| 56 : CSSTransformComponent(), x_(x), y_(y), z_(z) {} | 56 : CSSTransformComponent(), x_(x), y_(y), z_(z) {} |
| 57 | 57 |
| 58 bool Is2D() const { return !z_; } | 58 bool Is2D() const { return !z_; } |
| 59 | 59 |
| 60 Member<CSSLengthValue> x_; | 60 Member<CSSNumericValue> x_; |
| 61 Member<CSSLengthValue> y_; | 61 Member<CSSNumericValue> y_; |
| 62 Member<CSSLengthValue> z_; | 62 Member<CSSNumericValue> z_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace blink | 65 } // namespace blink |
| 66 | 66 |
| 67 #endif | 67 #endif |
| OLD | NEW |