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 CSSScale_h | 5 #ifndef CSSScale_h |
6 #define CSSScale_h | 6 #define CSSScale_h |
7 | 7 |
8 #include "core/css/cssom/CSSMatrixTransformComponent.h" | 8 #include "core/css/cssom/CSSMatrixComponent.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 CORE_EXPORT CSSScale final : public CSSTransformComponent { | 13 class CORE_EXPORT CSSScale final : public CSSTransformComponent { |
14 WTF_MAKE_NONCOPYABLE(CSSScale); | 14 WTF_MAKE_NONCOPYABLE(CSSScale); |
15 DEFINE_WRAPPERTYPEINFO(); | 15 DEFINE_WRAPPERTYPEINFO(); |
16 | 16 |
17 public: | 17 public: |
18 static CSSScale* create(double x, double y) { return new CSSScale(x, y); } | 18 static CSSScale* create(double x, double y) { return new CSSScale(x, y); } |
19 | 19 |
20 static CSSScale* create(double x, double y, double z) { | 20 static CSSScale* create(double x, double y, double z) { |
21 return new CSSScale(x, y, z); | 21 return new CSSScale(x, y, z); |
22 } | 22 } |
23 | 23 |
24 static CSSScale* fromCSSValue(const CSSFunctionValue&); | 24 static CSSScale* fromCSSValue(const CSSFunctionValue&); |
25 | 25 |
26 double x() const { return m_x; } | 26 double x() const { return m_x; } |
27 double y() const { return m_y; } | 27 double y() const { return m_y; } |
28 double z() const { return m_z; } | 28 double z() const { return m_z; } |
29 | 29 |
30 TransformComponentType type() const override { | 30 TransformComponentType type() const override { |
31 return m_is2D ? ScaleType : Scale3DType; | 31 return m_is2D ? ScaleType : Scale3DType; |
32 } | 32 } |
33 | 33 |
34 CSSMatrixTransformComponent* asMatrix() const override { | 34 CSSMatrixComponent* asMatrix() const override { |
35 return m_is2D ? CSSMatrixTransformComponent::scale(m_x, m_y) | 35 return m_is2D ? CSSMatrixComponent::scale(m_x, m_y) |
36 : CSSMatrixTransformComponent::scale3d(m_x, m_y, m_z); | 36 : CSSMatrixComponent::scale3d(m_x, m_y, m_z); |
37 } | 37 } |
38 | 38 |
39 CSSFunctionValue* toCSSValue() const override; | 39 CSSFunctionValue* toCSSValue() const override; |
40 | 40 |
41 private: | 41 private: |
42 CSSScale(double x, double y) : m_x(x), m_y(y), m_z(1), m_is2D(true) {} | 42 CSSScale(double x, double y) : m_x(x), m_y(y), m_z(1), m_is2D(true) {} |
43 CSSScale(double x, double y, double z) | 43 CSSScale(double x, double y, double z) |
44 : m_x(x), m_y(y), m_z(z), m_is2D(false) {} | 44 : m_x(x), m_y(y), m_z(z), m_is2D(false) {} |
45 | 45 |
46 double m_x; | 46 double m_x; |
47 double m_y; | 47 double m_y; |
48 double m_z; | 48 double m_z; |
49 bool m_is2D; | 49 bool m_is2D; |
50 }; | 50 }; |
51 | 51 |
52 } // namespace blink | 52 } // namespace blink |
53 | 53 |
54 #endif | 54 #endif |
OLD | NEW |