| 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 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // Getters and setters for attributes defined in the IDL. | 32 // Getters and setters for attributes defined in the IDL. |
| 33 double x() const { return x_; } | 33 double x() const { return x_; } |
| 34 double y() const { return y_; } | 34 double y() const { return y_; } |
| 35 double z() const { return z_; } | 35 double z() const { return z_; } |
| 36 void setX(double x) { x_ = x; } | 36 void setX(double x) { x_ = x; } |
| 37 void setY(double y) { y_ = y; } | 37 void setY(double y) { y_ = y; } |
| 38 void setZ(double z) { z_ = z; } | 38 void setZ(double z) { z_ = z; } |
| 39 | 39 |
| 40 // Internal methods - from CSSTransformComponent. | 40 // Internal methods - from CSSTransformComponent. |
| 41 TransformComponentType GetType() const override { | 41 TransformComponentType GetType() const final { return kScaleType; } |
| 42 return is2d_ ? kScaleType : kScale3DType; | 42 DOMMatrix* AsMatrix() const final { |
| 43 } | |
| 44 DOMMatrix* AsMatrix() const override { | |
| 45 DOMMatrix* result = DOMMatrix::Create(); | 43 DOMMatrix* result = DOMMatrix::Create(); |
| 46 return result->scaleSelf(x_, y_, z_); | 44 return result->scaleSelf(x_, y_, z_); |
| 47 } | 45 } |
| 48 CSSFunctionValue* ToCSSValue() const override; | 46 CSSFunctionValue* ToCSSValue() const final; |
| 49 | 47 |
| 50 private: | 48 private: |
| 51 CSSScale(double x, double y) : x_(x), y_(y), z_(1), is2d_(true) {} | 49 CSSScale(double x, double y) |
| 52 CSSScale(double x, double y, double z) : x_(x), y_(y), z_(z), is2d_(false) {} | 50 : CSSTransformComponent(true /* is2D */), x_(x), y_(y), z_(1) {} |
| 51 CSSScale(double x, double y, double z) |
| 52 : CSSTransformComponent(false /* is2D */), x_(x), y_(y), z_(z) {} |
| 53 | 53 |
| 54 double x_; | 54 double x_; |
| 55 double y_; | 55 double y_; |
| 56 double z_; | 56 double z_; |
| 57 bool is2d_; | |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 } // namespace blink | 59 } // namespace blink |
| 61 | 60 |
| 62 #endif | 61 #endif |
| OLD | NEW |