| 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/CSSTransformComponent.h" | 8 #include "core/css/cssom/CSSTransformComponent.h" |
| 9 #include "core/geometry/DOMMatrix.h" | 9 #include "core/geometry/DOMMatrix.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class DOMMatrix; |
| 14 |
| 15 // Represents a scale value in a CSSTransformValue used for properties like |
| 16 // "transform". |
| 17 // See CSSScale.idl for more information about this class. |
| 13 class CORE_EXPORT CSSScale final : public CSSTransformComponent { | 18 class CORE_EXPORT CSSScale final : public CSSTransformComponent { |
| 14 WTF_MAKE_NONCOPYABLE(CSSScale); | 19 WTF_MAKE_NONCOPYABLE(CSSScale); |
| 15 DEFINE_WRAPPERTYPEINFO(); | 20 DEFINE_WRAPPERTYPEINFO(); |
| 16 | 21 |
| 17 public: | 22 public: |
| 23 // Constructors defined in the IDL. |
| 18 static CSSScale* Create(double x, double y) { return new CSSScale(x, y); } | 24 static CSSScale* Create(double x, double y) { return new CSSScale(x, y); } |
| 19 | |
| 20 static CSSScale* Create(double x, double y, double z) { | 25 static CSSScale* Create(double x, double y, double z) { |
| 21 return new CSSScale(x, y, z); | 26 return new CSSScale(x, y, z); |
| 22 } | 27 } |
| 23 | 28 |
| 29 // Blink-internal ways of creating CSSScales. |
| 24 static CSSScale* FromCSSValue(const CSSFunctionValue&); | 30 static CSSScale* FromCSSValue(const CSSFunctionValue&); |
| 25 | 31 |
| 32 // Getters and setters for attributes defined in the IDL. |
| 26 double x() const { return x_; } | 33 double x() const { return x_; } |
| 27 double y() const { return y_; } | 34 double y() const { return y_; } |
| 28 double z() const { return z_; } | 35 double z() const { return z_; } |
| 29 | |
| 30 void setX(double x) { x_ = x; } | 36 void setX(double x) { x_ = x; } |
| 31 void setY(double y) { y_ = y; } | 37 void setY(double y) { y_ = y; } |
| 32 void setZ(double z) { z_ = z; } | 38 void setZ(double z) { z_ = z; } |
| 33 | 39 |
| 40 // Internal methods - from CSSTransformComponent. |
| 34 TransformComponentType GetType() const override { | 41 TransformComponentType GetType() const override { |
| 35 return is2d_ ? kScaleType : kScale3DType; | 42 return is2d_ ? kScaleType : kScale3DType; |
| 36 } | 43 } |
| 37 | |
| 38 DOMMatrix* AsMatrix() const override { | 44 DOMMatrix* AsMatrix() const override { |
| 39 DOMMatrix* result = DOMMatrix::Create(); | 45 DOMMatrix* result = DOMMatrix::Create(); |
| 40 return result->scaleSelf(x_, y_, z_); | 46 return result->scaleSelf(x_, y_, z_); |
| 41 } | 47 } |
| 42 | |
| 43 CSSFunctionValue* ToCSSValue() const override; | 48 CSSFunctionValue* ToCSSValue() const override; |
| 44 | 49 |
| 45 private: | 50 private: |
| 46 CSSScale(double x, double y) : x_(x), y_(y), z_(1), is2d_(true) {} | 51 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) {} | 52 CSSScale(double x, double y, double z) : x_(x), y_(y), z_(z), is2d_(false) {} |
| 48 | 53 |
| 49 double x_; | 54 double x_; |
| 50 double y_; | 55 double y_; |
| 51 double z_; | 56 double z_; |
| 52 bool is2d_; | 57 bool is2d_; |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 } // namespace blink | 60 } // namespace blink |
| 56 | 61 |
| 57 #endif | 62 #endif |
| OLD | NEW |