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 ClipPaintPropertyNode_h | 5 #ifndef ClipPaintPropertyNode_h |
| 6 #define ClipPaintPropertyNode_h | 6 #define ClipPaintPropertyNode_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/geometry/FloatRoundedRect.h" | 9 #include "platform/geometry/FloatRoundedRect.h" |
| 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 10 #include "platform/graphics/paint/TransformPaintPropertyNode.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 clip rect created by a css property such as "overflow" or "clip". | 19 // A clip rect created by a css property such as "overflow" or "clip". |
| 20 // Along with a refernce to the transform space the clip rect is based on, | 20 // Along with a refernce to the transform space the clip rect is based on, |
| 21 // and an (optional) parent ClipPaintPropertyNode for inherited clips. | 21 // and an (optional) parent ClipPaintPropertyNode for inherited clips. |
| 22 class PLATFORM_EXPORT ClipPaintPropertyNode : public RefCounted<ClipPaintPropert yNode> { | 22 class PLATFORM_EXPORT ClipPaintPropertyNode : public RefCounted<ClipPaintPropert yNode> { |
| 23 public: | 23 public: |
| 24 using Value = FloatRoundedRect; | |
|
pdr.
2016/07/21 21:34:07
Can a refptr to the local transform space be inclu
| |
| 25 | |
| 24 static PassRefPtr<ClipPaintPropertyNode> create( | 26 static PassRefPtr<ClipPaintPropertyNode> create( |
| 25 PassRefPtr<TransformPaintPropertyNode> localTransformSpace, | 27 PassRefPtr<TransformPaintPropertyNode> localTransformSpace, |
| 26 const FloatRoundedRect& clipRect, | 28 const FloatRoundedRect& clipRect, |
| 27 PassRefPtr<ClipPaintPropertyNode> parent = nullptr) | 29 PassRefPtr<ClipPaintPropertyNode> parent = nullptr) |
| 28 { | 30 { |
| 29 return adoptRef(new ClipPaintPropertyNode(localTransformSpace, clipRect, parent)); | 31 return adoptRef(new ClipPaintPropertyNode(localTransformSpace, clipRect, parent)); |
| 30 } | 32 } |
| 31 | 33 |
| 34 // This form is required by PaintPropertyTreeBuilder::updateObjectPaintPrope rties(). | |
| 35 static PassRefPtr<ClipPaintPropertyNode> create(const Value& value, PassRefP tr<ClipPaintPropertyNode> parent) | |
| 36 { | |
| 37 return adoptRef(new ClipPaintPropertyNode(nullptr, value, parent)); | |
| 38 } | |
| 39 | |
| 32 const TransformPaintPropertyNode* localTransformSpace() const { return m_loc alTransformSpace.get(); } | 40 const TransformPaintPropertyNode* localTransformSpace() const { return m_loc alTransformSpace.get(); } |
| 41 const Value& value() const { return m_clipRect; } | |
| 33 const FloatRoundedRect& clipRect() const { return m_clipRect; } | 42 const FloatRoundedRect& clipRect() const { return m_clipRect; } |
| 34 | 43 |
| 35 // Reference to inherited clips, or nullptr if this is the only clip. | 44 // Reference to inherited clips, or nullptr if this is the only clip. |
| 36 const ClipPaintPropertyNode* parent() const { return m_parent.get(); } | 45 const ClipPaintPropertyNode* parent() const { return m_parent.get(); } |
| 37 | 46 |
| 47 // Moves this node and its subtrees under another parent. | |
| 48 void setParent(PassRefPtr<ClipPaintPropertyNode> parent) { m_parent = parent ; } | |
| 49 | |
| 50 // This is separate from the create() method for child node for two purposes : | |
| 51 // 1. to let the method have the same parameter list as the method of other paint | |
| 52 // property node classes, so that they can be used in the same template; | |
|
pdr.
2016/07/21 21:34:06
Nit: ; -> .
| |
| 53 // 2. to allow to reuse an existing node in a new tree. | |
| 54 void setLocalTransformSpace(PassRefPtr<TransformPaintPropertyNode> localTran sformSpace) { m_localTransformSpace = localTransformSpace; } | |
| 55 | |
| 38 private: | 56 private: |
| 39 ClipPaintPropertyNode(PassRefPtr<TransformPaintPropertyNode> localTransformS pace, const FloatRoundedRect& clipRect, PassRefPtr<ClipPaintPropertyNode> parent ) | 57 ClipPaintPropertyNode(PassRefPtr<TransformPaintPropertyNode> localTransformS pace, const FloatRoundedRect& clipRect, PassRefPtr<ClipPaintPropertyNode> parent ) |
| 40 : m_localTransformSpace(localTransformSpace), m_clipRect(clipRect), m_pa rent(parent) { } | 58 : m_localTransformSpace(localTransformSpace), m_clipRect(clipRect), m_pa rent(parent) { } |
| 41 | 59 |
| 42 RefPtr<TransformPaintPropertyNode> m_localTransformSpace; | 60 RefPtr<TransformPaintPropertyNode> m_localTransformSpace; |
| 43 const FloatRoundedRect m_clipRect; | 61 const FloatRoundedRect m_clipRect; |
| 44 RefPtr<ClipPaintPropertyNode> m_parent; | 62 RefPtr<ClipPaintPropertyNode> m_parent; |
| 45 }; | 63 }; |
| 46 | 64 |
| 47 // Redeclared here to avoid ODR issues. | 65 // Redeclared here to avoid ODR issues. |
| 48 // See platform/testing/PaintPrinters.h. | 66 // See platform/testing/PaintPrinters.h. |
| 49 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); | 67 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); |
| 50 | 68 |
| 51 } // namespace blink | 69 } // namespace blink |
| 52 | 70 |
| 53 #endif // ClipPaintPropertyNode_h | 71 #endif // ClipPaintPropertyNode_h |
| OLD | NEW |