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/geometry/LayoutRect.h" |
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
11 #include "wtf/PassRefPtr.h" | |
12 #include "wtf/RefCounted.h" | |
13 #include "wtf/RefPtr.h" | |
14 | 12 |
15 #include <iosfwd> | 13 #include <iosfwd> |
16 | 14 |
17 namespace blink { | 15 namespace blink { |
18 | 16 |
19 // A clip rect created by a css property such as "overflow" or "clip". | 17 // 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, | 18 // Along with a refernce to the transform space the clip rect is based on, |
21 // and an (optional) parent ClipPaintPropertyNode for inherited clips. | 19 // and an (optional) parent ClipPaintPropertyNode for inherited clips. |
22 class PLATFORM_EXPORT ClipPaintPropertyNode : public RefCounted<ClipPaintPropert
yNode> { | 20 class PLATFORM_EXPORT ClipPaintPropertyNode : public PaintPropertyNode<ClipPaint
PropertyNode> { |
23 public: | 21 public: |
24 using Value = FloatRoundedRect; | 22 using Value = FloatRoundedRect; |
25 | 23 |
26 static PassRefPtr<ClipPaintPropertyNode> create( | 24 static PassRefPtr<ClipPaintPropertyNode> create( |
27 PassRefPtr<TransformPaintPropertyNode> localTransformSpace, | 25 PassRefPtr<TransformPaintPropertyNode> localTransformSpace, |
28 const FloatRoundedRect& clipRect, | 26 const FloatRoundedRect& clipRect, |
29 PassRefPtr<ClipPaintPropertyNode> parent = nullptr) | 27 PassRefPtr<ClipPaintPropertyNode> parent = nullptr) |
30 { | 28 { |
31 return adoptRef(new ClipPaintPropertyNode(localTransformSpace, clipRect,
parent)); | 29 return adoptRef(new ClipPaintPropertyNode(localTransformSpace, clipRect,
parent)); |
32 } | 30 } |
33 | 31 |
34 // This form is required by PaintPropertyTreeBuilder::updateObjectPaintPrope
rties(). | 32 // This form is required by PaintPropertyTreeBuilder::updateObjectPaintPrope
rties(). |
35 static PassRefPtr<ClipPaintPropertyNode> create(const Value& value, PassRefP
tr<ClipPaintPropertyNode> parent) | 33 static PassRefPtr<ClipPaintPropertyNode> create(const Value& value, PassRefP
tr<ClipPaintPropertyNode> parent) |
36 { | 34 { |
37 return adoptRef(new ClipPaintPropertyNode(nullptr, value, parent)); | 35 return adoptRef(new ClipPaintPropertyNode(nullptr, value, parent)); |
38 } | 36 } |
39 | 37 |
40 const TransformPaintPropertyNode* localTransformSpace() const { return m_loc
alTransformSpace.get(); } | 38 const TransformPaintPropertyNode* localTransformSpace() const { return m_loc
alTransformSpace.get(); } |
41 const Value& value() const { return m_clipRect; } | 39 const Value& value() const { return m_clipRect; } |
42 const FloatRoundedRect& clipRect() const { return m_clipRect; } | 40 const FloatRoundedRect& clipRect() const { return m_clipRect; } |
43 | 41 |
44 // Reference to inherited clips, or nullptr if this is the only clip. | |
45 const ClipPaintPropertyNode* parent() const { return m_parent.get(); } | |
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
: | 42 // 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 | 43 // 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; | 44 // property node classes, so that they can be used in the same template; |
53 // 2. to allow to reuse an existing node in a new tree. | 45 // 2. to allow to reuse an existing node in a new tree. |
54 void setLocalTransformSpace(PassRefPtr<TransformPaintPropertyNode> localTran
sformSpace) { m_localTransformSpace = localTransformSpace; } | 46 void setLocalTransformSpace(PassRefPtr<TransformPaintPropertyNode> localTran
sformSpace) { m_localTransformSpace = localTransformSpace; } |
55 | 47 |
56 private: | 48 private: |
57 ClipPaintPropertyNode(PassRefPtr<TransformPaintPropertyNode> localTransformS
pace, const FloatRoundedRect& clipRect, PassRefPtr<ClipPaintPropertyNode> parent
) | 49 ClipPaintPropertyNode(PassRefPtr<TransformPaintPropertyNode> localTransformS
pace, const FloatRoundedRect& clipRect, PassRefPtr<ClipPaintPropertyNode> parent
) |
58 : m_localTransformSpace(localTransformSpace), m_clipRect(clipRect), m_pa
rent(parent) { } | 50 : PaintPropertyNode(parent), m_localTransformSpace(localTransformSpace),
m_clipRect(clipRect) { } |
59 | 51 |
60 RefPtr<TransformPaintPropertyNode> m_localTransformSpace; | 52 RefPtr<TransformPaintPropertyNode> m_localTransformSpace; |
61 const FloatRoundedRect m_clipRect; | 53 const FloatRoundedRect m_clipRect; |
62 RefPtr<ClipPaintPropertyNode> m_parent; | |
63 }; | 54 }; |
64 | 55 |
65 // Redeclared here to avoid ODR issues. | 56 // Redeclared here to avoid ODR issues. |
66 // See platform/testing/PaintPrinters.h. | 57 // See platform/testing/PaintPrinters.h. |
67 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); | 58 void PrintTo(const ClipPaintPropertyNode&, std::ostream*); |
68 | 59 |
69 } // namespace blink | 60 } // namespace blink |
70 | 61 |
71 #endif // ClipPaintPropertyNode_h | 62 #endif // ClipPaintPropertyNode_h |
OLD | NEW |