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 NGLayoutOpportunityTreeNode_h | 5 #ifndef NGLayoutOpportunityTreeNode_h |
6 #define NGLayoutOpportunityTreeNode_h | 6 #define NGLayoutOpportunityTreeNode_h |
7 | 7 |
8 #include "core/layout/ng/geometry/ng_edge.h" | 8 #include "core/layout/ng/geometry/ng_edge.h" |
9 #include "core/layout/ng/geometry/ng_logical_rect.h" | 9 #include "core/layout/ng/geometry/ng_logical_rect.h" |
10 #include "core/layout/ng/ng_exclusion.h" | 10 #include "core/layout/ng/ng_exclusion.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 // 3 node R-Tree that represents available space(left, bottom, right) or | 15 // 3 node R-Tree that represents available space(left, bottom, right) or |
16 // layout opportunity after the parent spatial rectangle is split by the | 16 // layout opportunity after the parent spatial rectangle is split by the |
17 // exclusion rectangle. | 17 // exclusion rectangle. |
18 struct CORE_EXPORT NGLayoutOpportunityTreeNode | 18 struct CORE_EXPORT NGLayoutOpportunityTreeNode |
19 : public GarbageCollected<NGLayoutOpportunityTreeNode> { | 19 : public GarbageCollectedFinalized<NGLayoutOpportunityTreeNode> { |
20 public: | 20 public: |
21 // Default constructor. | 21 // Default constructor. |
22 // Creates a Layout Opportunity tree node that is limited by it's own edge | 22 // Creates a Layout Opportunity tree node that is limited by it's own edge |
23 // from above. | 23 // from above. |
24 // @param opportunity The layout opportunity for this node. | 24 // @param opportunity The layout opportunity for this node. |
25 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity); | 25 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity); |
26 | 26 |
27 // Constructor that creates a node with explicitly set exclusion edge. | 27 // Constructor that creates a node with explicitly set exclusion edge. |
28 // @param opportunity The layout opportunity for this node. | 28 // @param opportunity The layout opportunity for this node. |
29 // @param exclusion_edge Edge that limits this node's opportunity from above. | 29 // @param exclusion_edge Edge that limits this node's opportunity from above. |
30 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity, | 30 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity, |
31 NGEdge exclusion_edge); | 31 NGEdge exclusion_edge); |
32 | 32 |
33 // Children of the node. | 33 // Children of the node. |
34 Member<NGLayoutOpportunityTreeNode> left; | 34 Member<NGLayoutOpportunityTreeNode> left; |
35 Member<NGLayoutOpportunityTreeNode> bottom; | 35 Member<NGLayoutOpportunityTreeNode> bottom; |
36 Member<NGLayoutOpportunityTreeNode> right; | 36 Member<NGLayoutOpportunityTreeNode> right; |
37 | 37 |
38 // The top layout opportunity associated with this node. | 38 // The top layout opportunity associated with this node. |
39 NGLogicalRect opportunity; | 39 NGLogicalRect opportunity; |
40 | 40 |
41 // Edge that limits this layout opportunity from above. | 41 // Edge that limits this layout opportunity from above. |
42 NGEdge exclusion_edge; | 42 NGEdge exclusion_edge; |
43 | 43 |
44 // Exclusion that splits apart this layout opportunity. | 44 // Exclusions that splits apart this layout opportunity. |
45 const NGExclusion* exclusion; // Not owned. | 45 Vector<const NGExclusion*> exclusions; // Not owned. |
| 46 |
| 47 // Exclusion that represent all combined exclusions that |
| 48 // split this node. |
| 49 std::unique_ptr<NGExclusion> combined_exclusion; |
46 | 50 |
47 // Whether this node is a leaf node. | 51 // Whether this node is a leaf node. |
48 // The node is a leaf if it doesn't have an exclusion that splits it apart. | 52 // The node is a leaf if it doesn't have exclusions that split it apart. |
49 bool IsLeafNode() const { return !exclusion; } | 53 bool IsLeafNode() const { return exclusions.isEmpty(); } |
50 | 54 |
51 String ToString() const; | 55 String ToString() const; |
52 | 56 |
53 DECLARE_TRACE(); | 57 DECLARE_TRACE(); |
54 }; | 58 }; |
55 | 59 |
56 inline std::ostream& operator<<(std::ostream& stream, | 60 inline std::ostream& operator<<(std::ostream& stream, |
57 const NGLayoutOpportunityTreeNode& value) { | 61 const NGLayoutOpportunityTreeNode& value) { |
58 return stream << value.ToString(); | 62 return stream << value.ToString(); |
59 } | 63 } |
60 | 64 |
61 inline std::ostream& operator<<(std::ostream& out, | 65 inline std::ostream& operator<<(std::ostream& out, |
62 const NGLayoutOpportunityTreeNode* value) { | 66 const NGLayoutOpportunityTreeNode* value) { |
63 return out << (value ? value->ToString() : "(null)"); | 67 return out << (value ? value->ToString() : "(null)"); |
64 } | 68 } |
65 | 69 |
66 } // namespace blink | 70 } // namespace blink |
67 #endif // NGLayoutOpportunityTreeNode_h | 71 #endif // NGLayoutOpportunityTreeNode_h |
OLD | NEW |