| 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" | |
| 12 | 11 |
| 13 namespace blink { | 12 namespace blink { |
| 14 | 13 |
| 15 // 3 node R-Tree that represents available space(left, bottom, right) or | 14 // 3 node R-Tree that represents available space(left, bottom, right) or |
| 16 // layout opportunity after the parent spatial rectangle is split by the | 15 // layout opportunity after the parent spatial rectangle is split by the |
| 17 // exclusion rectangle. | 16 // exclusion rectangle. |
| 18 struct CORE_EXPORT NGLayoutOpportunityTreeNode | 17 struct CORE_EXPORT NGLayoutOpportunityTreeNode { |
| 19 : public GarbageCollectedFinalized<NGLayoutOpportunityTreeNode> { | |
| 20 public: | 18 public: |
| 21 // Default constructor. | 19 // Default constructor. |
| 22 // Creates a Layout Opportunity tree node that is limited by it's own edge | 20 // Creates a Layout Opportunity tree node that is limited by it's own edge |
| 23 // from above. | 21 // from above. |
| 24 // @param opportunity The layout opportunity for this node. | 22 // @param opportunity The layout opportunity for this node. |
| 25 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity); | 23 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity); |
| 26 | 24 |
| 27 // Constructor that creates a node with explicitly set exclusion edge. | 25 // Constructor that creates a node with explicitly set exclusion edge. |
| 28 // @param opportunity The layout opportunity for this node. | 26 // @param opportunity The layout opportunity for this node. |
| 29 // @param exclusion_edge Edge that limits this node's opportunity from above. | 27 // @param exclusion_edge Edge that limits this node's opportunity from above. |
| 30 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity, | 28 NGLayoutOpportunityTreeNode(const NGLogicalRect opportunity, |
| 31 NGEdge exclusion_edge); | 29 NGEdge exclusion_edge); |
| 32 | 30 |
| 33 // Children of the node. | 31 // Children of the node. |
| 34 Member<NGLayoutOpportunityTreeNode> left; | 32 std::unique_ptr<NGLayoutOpportunityTreeNode> left; |
| 35 Member<NGLayoutOpportunityTreeNode> bottom; | 33 std::unique_ptr<NGLayoutOpportunityTreeNode> bottom; |
| 36 Member<NGLayoutOpportunityTreeNode> right; | 34 std::unique_ptr<NGLayoutOpportunityTreeNode> right; |
| 37 | 35 |
| 38 // The top layout opportunity associated with this node. | 36 // The top layout opportunity associated with this node. |
| 39 NGLogicalRect opportunity; | 37 NGLogicalRect opportunity; |
| 40 | 38 |
| 41 // Edge that limits this layout opportunity from above. | 39 // Edge that limits this layout opportunity from above. |
| 42 NGEdge exclusion_edge; | 40 NGEdge exclusion_edge; |
| 43 | 41 |
| 44 // Exclusions that splits apart this layout opportunity. | 42 // Exclusions that splits apart this layout opportunity. |
| 45 Vector<const NGExclusion*> exclusions; // Not owned. | 43 Vector<const NGExclusion*> exclusions; // Not owned. |
| 46 | 44 |
| 47 // Exclusion that represent all combined exclusions that | 45 // Exclusion that represent all combined exclusions that |
| 48 // split this node. | 46 // split this node. |
| 49 std::unique_ptr<NGExclusion> combined_exclusion; | 47 std::unique_ptr<NGExclusion> combined_exclusion; |
| 50 | 48 |
| 51 // Whether this node is a leaf node. | 49 // Whether this node is a leaf node. |
| 52 // The node is a leaf if it doesn't have exclusions that split it apart. | 50 // The node is a leaf if it doesn't have exclusions that split it apart. |
| 53 bool IsLeafNode() const { return exclusions.isEmpty(); } | 51 bool IsLeafNode() const { return exclusions.isEmpty(); } |
| 54 | 52 |
| 55 String ToString() const; | 53 String ToString() const; |
| 56 | |
| 57 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 |