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 GarbageCollectedFinalized<NGLayoutOpportunityTreeNode> { | 19 : public GarbageCollected<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 // Exclusions that splits apart this layout opportunity. | 44 // Exclusion that splits apart this layout opportunity. |
45 Vector<const NGExclusion*> exclusions; // Not owned. | 45 const NGExclusion* exclusion; // Not owned. |
46 | |
47 // Exclusion that represent all combined exclusions that | |
48 // split this node. | |
49 std::unique_ptr<NGExclusion> combined_exclusion; | |
50 | 46 |
51 // Whether this node is a leaf node. | 47 // Whether this node is a leaf node. |
52 // The node is a leaf if it doesn't have exclusions that split it apart. | 48 // The node is a leaf if it doesn't have an exclusion that splits it apart. |
53 bool IsLeafNode() const { return exclusions.isEmpty(); } | 49 bool IsLeafNode() const { return !exclusion; } |
54 | 50 |
55 String ToString() const; | 51 String ToString() const; |
56 | 52 |
57 DECLARE_TRACE(); | 53 DECLARE_TRACE(); |
58 }; | 54 }; |
59 | 55 |
60 inline std::ostream& operator<<(std::ostream& stream, | 56 inline std::ostream& operator<<(std::ostream& stream, |
61 const NGLayoutOpportunityTreeNode& value) { | 57 const NGLayoutOpportunityTreeNode& value) { |
62 return stream << value.ToString(); | 58 return stream << value.ToString(); |
63 } | 59 } |
64 | 60 |
65 inline std::ostream& operator<<(std::ostream& out, | 61 inline std::ostream& operator<<(std::ostream& out, |
66 const NGLayoutOpportunityTreeNode* value) { | 62 const NGLayoutOpportunityTreeNode* value) { |
67 return out << (value ? value->ToString() : "(null)"); | 63 return out << (value ? value->ToString() : "(null)"); |
68 } | 64 } |
69 | 65 |
70 } // namespace blink | 66 } // namespace blink |
71 #endif // NGLayoutOpportunityTreeNode_h | 67 #endif // NGLayoutOpportunityTreeNode_h |
OLD | NEW |