Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 TransformPaintPropertyNode_h | 5 #ifndef TransformPaintPropertyNode_h |
| 6 #define TransformPaintPropertyNode_h | 6 #define TransformPaintPropertyNode_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/geometry/FloatPoint3D.h" | 9 #include "platform/geometry/FloatPoint3D.h" |
| 10 #include "platform/transforms/TransformationMatrix.h" | 10 #include "platform/transforms/TransformationMatrix.h" |
| 11 #include "wtf/PassRefPtr.h" | 11 #include "wtf/PassRefPtr.h" |
| 12 #include "wtf/RefCounted.h" | 12 #include "wtf/RefCounted.h" |
| 13 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 14 | 14 |
| 15 #include <iosfwd> | 15 #include <iosfwd> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 // A transform created by a css property such as "transform" or "perspective" | 19 // A transform created by a css property such as "transform" or "perspective" |
| 20 // along with a reference to the parent TransformPaintPropertyNode, or nullptr | 20 // along with a reference to the parent TransformPaintPropertyNode, or nullptr |
| 21 // for the root. | 21 // for the root. |
| 22 class PLATFORM_EXPORT TransformPaintPropertyNode : public RefCounted<TransformPa intPropertyNode> { | 22 class PLATFORM_EXPORT TransformPaintPropertyNode : public RefCounted<TransformPa intPropertyNode> { |
| 23 public: | 23 public: |
| 24 struct Value { | |
| 25 Value() { } | |
| 26 Value(const TransformationMatrix& matrix, const FloatPoint3D& origin) : matrix(matrix), origin(origin) { } | |
| 27 bool operator ==(const Value& other) const { return matrix == other.matr ix && origin == other.origin; } | |
|
pdr.
2016/07/21 21:34:07
Nit: no space between operator and ==
Xianzhu
2016/07/22 01:14:05
No more applicable.
| |
| 28 | |
| 29 TransformationMatrix matrix; | |
| 30 FloatPoint3D origin; | |
| 31 }; | |
| 32 | |
| 24 static PassRefPtr<TransformPaintPropertyNode> create(const TransformationMat rix& matrix, const FloatPoint3D& origin, PassRefPtr<TransformPaintPropertyNode> parent = nullptr) | 33 static PassRefPtr<TransformPaintPropertyNode> create(const TransformationMat rix& matrix, const FloatPoint3D& origin, PassRefPtr<TransformPaintPropertyNode> parent = nullptr) |
| 25 { | 34 { |
| 26 return adoptRef(new TransformPaintPropertyNode(matrix, origin, parent)); | 35 return adoptRef(new TransformPaintPropertyNode(Value(matrix, origin), pa rent)); |
| 27 } | 36 } |
| 28 | 37 |
| 29 const TransformationMatrix& matrix() const { return m_matrix; } | 38 // This form is required by PaintPropertyTreeBuilder::updateObjectPaintPrope rties(). |
| 30 const FloatPoint3D& origin() const { return m_origin; } | 39 static PassRefPtr<TransformPaintPropertyNode> create(const Value& value, Pas sRefPtr<TransformPaintPropertyNode> parent) |
| 40 { | |
| 41 return adoptRef(new TransformPaintPropertyNode(value, parent)); | |
| 42 } | |
| 43 | |
| 44 const Value& value() const { return m_value; } | |
| 45 const TransformationMatrix& matrix() const { return m_value.matrix; } | |
| 46 const FloatPoint3D& origin() const { return m_value.origin; } | |
| 31 | 47 |
| 32 // Parent transform that this transform is relative to, or nullptr if this | 48 // Parent transform that this transform is relative to, or nullptr if this |
| 33 // is the root transform. | 49 // is the root transform. |
| 34 TransformPaintPropertyNode* parent() const { return m_parent.get(); } | 50 TransformPaintPropertyNode* parent() const { return m_parent.get(); } |
| 35 | 51 |
| 52 // Moves this node and its subtrees under another parent. | |
| 53 void setParent(PassRefPtr<TransformPaintPropertyNode> parent) { m_parent = p arent; } | |
|
pdr.
2016/07/21 21:34:07
What do you think of restricting setters to PaintP
Xianzhu
2016/07/22 01:14:05
Changed this to update() method. I think 'const' i
| |
| 54 | |
| 36 private: | 55 private: |
| 56 TransformPaintPropertyNode(const Value& value, PassRefPtr<TransformPaintProp ertyNode> parent) | |
| 57 : m_value(value), m_parent(parent) { } | |
| 37 | 58 |
| 38 TransformPaintPropertyNode(const TransformationMatrix& matrix, const FloatPo int3D& origin, PassRefPtr<TransformPaintPropertyNode> parent) | 59 Value m_value; |
| 39 : m_matrix(matrix), m_origin(origin), m_parent(parent) { } | |
| 40 | |
| 41 const TransformationMatrix m_matrix; | |
| 42 const FloatPoint3D m_origin; | |
| 43 RefPtr<TransformPaintPropertyNode> m_parent; | 60 RefPtr<TransformPaintPropertyNode> m_parent; |
| 44 }; | 61 }; |
| 45 | 62 |
| 46 // Redeclared here to avoid ODR issues. | 63 // Redeclared here to avoid ODR issues. |
| 47 // See platform/testing/PaintPrinters.h. | 64 // See platform/testing/PaintPrinters.h. |
| 48 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); | 65 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); |
| 49 | 66 |
| 50 } // namespace blink | 67 } // namespace blink |
| 51 | 68 |
| 52 #endif // TransformPaintPropertyNode_h | 69 #endif // TransformPaintPropertyNode_h |
| OLD | NEW |