| 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 reference to the transform space the clip rect is based on, | 20 // Along with a reference to the transform space the clip rect is based on, |
| 21 // and an (optional) parent ClipPaintPropertyNode for inherited clips. | 21 // and a parent ClipPaintPropertyNode for inherited clips. |
| 22 // |
| 23 // The clip tree is rooted at a node with no parent. This root node should |
| 24 // not be modified. |
| 22 class PLATFORM_EXPORT ClipPaintPropertyNode : public RefCounted<ClipPaintPropert
yNode> { | 25 class PLATFORM_EXPORT ClipPaintPropertyNode : public RefCounted<ClipPaintPropert
yNode> { |
| 23 public: | 26 public: |
| 24 static PassRefPtr<ClipPaintPropertyNode> create( | 27 static PassRefPtr<ClipPaintPropertyNode> create( |
| 25 PassRefPtr<const ClipPaintPropertyNode> parent, | 28 PassRefPtr<const ClipPaintPropertyNode> parent, |
| 26 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 29 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 27 const FloatRoundedRect& clipRect) | 30 const FloatRoundedRect& clipRect) |
| 28 { | 31 { |
| 29 return adoptRef(new ClipPaintPropertyNode(std::move(parent), std::move(l
ocalTransformSpace), clipRect)); | 32 return adoptRef(new ClipPaintPropertyNode(std::move(parent), std::move(l
ocalTransformSpace), clipRect)); |
| 30 } | 33 } |
| 31 | 34 |
| 32 void update(PassRefPtr<const ClipPaintPropertyNode> parent, PassRefPtr<const
TransformPaintPropertyNode> localTransformSpace, const FloatRoundedRect& clipRe
ct) | 35 void update(PassRefPtr<const ClipPaintPropertyNode> parent, PassRefPtr<const
TransformPaintPropertyNode> localTransformSpace, const FloatRoundedRect& clipRe
ct) |
| 33 { | 36 { |
| 37 DCHECK(!isRoot()); |
| 34 DCHECK(parent != this); | 38 DCHECK(parent != this); |
| 35 m_parent = parent; | 39 m_parent = parent; |
| 36 m_localTransformSpace = localTransformSpace; | 40 m_localTransformSpace = localTransformSpace; |
| 37 m_clipRect = clipRect; | 41 m_clipRect = clipRect; |
| 38 } | 42 } |
| 39 | 43 |
| 40 const TransformPaintPropertyNode* localTransformSpace() const { return m_loc
alTransformSpace.get(); } | 44 const TransformPaintPropertyNode* localTransformSpace() const { return m_loc
alTransformSpace.get(); } |
| 41 const FloatRoundedRect& clipRect() const { return m_clipRect; } | 45 const FloatRoundedRect& clipRect() const { return m_clipRect; } |
| 42 | 46 |
| 43 // Reference to inherited clips, or nullptr if this is the only clip. | 47 // Reference to inherited clips, or nullptr if this is the only clip. |
| 44 const ClipPaintPropertyNode* parent() const { return m_parent.get(); } | 48 const ClipPaintPropertyNode* parent() const { return m_parent.get(); } |
| 45 bool isRoot() const { return !m_parent; } | 49 bool isRoot() const { return !m_parent; } |
| 46 | 50 |
| 47 private: | 51 private: |
| 48 ClipPaintPropertyNode(PassRefPtr<const ClipPaintPropertyNode> parent, PassRe
fPtr<const TransformPaintPropertyNode> localTransformSpace, const FloatRoundedRe
ct& clipRect) | 52 ClipPaintPropertyNode(PassRefPtr<const ClipPaintPropertyNode> parent, PassRe
fPtr<const TransformPaintPropertyNode> localTransformSpace, const FloatRoundedRe
ct& clipRect) |
| 49 : m_parent(parent), m_localTransformSpace(localTransformSpace), m_clipRe
ct(clipRect) { } | 53 : m_parent(parent), m_localTransformSpace(localTransformSpace), m_clipRe
ct(clipRect) { } |
| 50 | 54 |
| 51 RefPtr<const ClipPaintPropertyNode> m_parent; | 55 RefPtr<const ClipPaintPropertyNode> m_parent; |
| 52 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | 56 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; |
| 53 FloatRoundedRect m_clipRect; | 57 FloatRoundedRect m_clipRect; |
| 54 }; | 58 }; |
| 55 | 59 |
| 56 // Redeclared here to avoid ODR issues. | 60 // Redeclared here to avoid ODR issues. |
| 57 // See platform/testing/PaintPrinters.h. | 61 // See platform/testing/PaintPrinters.h. |
| 58 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); | 62 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); |
| 59 | 63 |
| 60 } // namespace blink | 64 } // namespace blink |
| 61 | 65 |
| 62 #endif // ClipPaintPropertyNode_h | 66 #endif // ClipPaintPropertyNode_h |
| OLD | NEW |