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/CSSMatrixComponent.h" | |
9 #include "core/css/cssom/CSSTransformComponent.h" | 8 #include "core/css/cssom/CSSTransformComponent.h" |
| 9 #include "core/geometry/DOMMatrix.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 x_; } | 26 double x() const { return x_; } |
27 double y() const { return y_; } | 27 double y() const { return y_; } |
28 double z() const { return z_; } | 28 double z() const { return z_; } |
29 | 29 |
30 void setX(double x) { x_ = x; } | 30 void setX(double x) { x_ = x; } |
31 void setY(double y) { y_ = y; } | 31 void setY(double y) { y_ = y; } |
32 void setZ(double z) { z_ = z; } | 32 void setZ(double z) { z_ = z; } |
33 | 33 |
34 TransformComponentType GetType() const override { | 34 TransformComponentType GetType() const override { |
35 return is2d_ ? kScaleType : kScale3DType; | 35 return is2d_ ? kScaleType : kScale3DType; |
36 } | 36 } |
37 | 37 |
38 CSSMatrixComponent* asMatrix() const override { | 38 DOMMatrix* AsMatrix() const override { |
39 return is2d_ ? CSSMatrixComponent::Scale(x_, y_) | 39 DOMMatrix* result = DOMMatrix::Create(); |
40 : CSSMatrixComponent::Scale3d(x_, y_, z_); | 40 return result->scaleSelf(x_, y_, z_); |
41 } | 41 } |
42 | 42 |
43 CSSFunctionValue* ToCSSValue() const override; | 43 CSSFunctionValue* ToCSSValue() const override; |
44 | 44 |
45 private: | 45 private: |
46 CSSScale(double x, double y) : x_(x), y_(y), z_(1), is2d_(true) {} | 46 CSSScale(double x, double y) : x_(x), y_(y), z_(1), is2d_(true) {} |
47 CSSScale(double x, double y, double z) : x_(x), y_(y), z_(z), is2d_(false) {} | 47 CSSScale(double x, double y, double z) : x_(x), y_(y), z_(z), is2d_(false) {} |
48 | 48 |
49 double x_; | 49 double x_; |
50 double y_; | 50 double y_; |
51 double z_; | 51 double z_; |
52 bool is2d_; | 52 bool is2d_; |
53 }; | 53 }; |
54 | 54 |
55 } // namespace blink | 55 } // namespace blink |
56 | 56 |
57 #endif | 57 #endif |
OLD | NEW |