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 NGLayoutOpportunityIterator_h | 5 #ifndef NGLayoutOpportunityIterator_h |
6 #define NGLayoutOpportunityIterator_h | 6 #define NGLayoutOpportunityIterator_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/ng_constraint_space.h" | 9 #include "core/layout/ng/ng_constraint_space.h" |
10 #include "core/layout/ng/ng_layout_opportunity_tree_node.h" | 10 #include "core/layout/ng/ng_layout_opportunity_tree_node.h" |
11 #include "core/layout/ng/ng_units.h" | 11 #include "core/layout/ng/ng_units.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 #include "wtf/Optional.h" | 13 #include "wtf/Optional.h" |
14 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 typedef NGLogicalRect NGLayoutOpportunity; | 18 typedef NGLogicalRect NGLayoutOpportunity; |
19 typedef Vector<NGLayoutOpportunity> NGLayoutOpportunities; | 19 typedef Vector<NGLayoutOpportunity> NGLayoutOpportunities; |
20 | 20 |
21 class CORE_EXPORT NGLayoutOpportunityIterator final | 21 class CORE_EXPORT NGLayoutOpportunityIterator final { |
22 : public GarbageCollectedFinalized<NGLayoutOpportunityIterator> { | 22 STACK_ALLOCATED(); |
| 23 |
23 public: | 24 public: |
24 // Default constructor. | 25 // Default constructor. |
25 // | 26 // |
26 // @param space Constraint space with exclusions for which this iterator needs | 27 // @param space Constraint space with exclusions for which this iterator needs |
27 // to generate layout opportunities. | 28 // to generate layout opportunities. |
28 // @param opt_origin_point Optional origin_point parameter that is used as a | 29 // @param opt_origin_point Optional origin_point parameter that is used as a |
29 // default start point for layout opportunities. | 30 // default start point for layout opportunities. |
30 // @param opt_leader_point Optional 'leader' parameter that is used to specify | 31 // @param opt_leader_point Optional 'leader' parameter that is used to specify |
31 // the ending point of temporary excluded rectangle | 32 // the ending point of temporary excluded rectangle |
32 // which starts from 'origin'. This rectangle may | 33 // which starts from 'origin'. This rectangle may |
33 // represent a text fragment for example. | 34 // represent a text fragment for example. |
34 NGLayoutOpportunityIterator( | 35 NGLayoutOpportunityIterator( |
35 NGConstraintSpace* space, | 36 NGConstraintSpace* space, |
36 const WTF::Optional<NGLogicalOffset>& opt_origin_point = WTF::nullopt, | 37 const WTF::Optional<NGLogicalOffset>& opt_origin_point = WTF::nullopt, |
37 const WTF::Optional<NGLogicalOffset>& opt_leader_point = WTF::nullopt); | 38 const WTF::Optional<NGLogicalOffset>& opt_leader_point = WTF::nullopt); |
38 | 39 |
39 // Gets the next Layout Opportunity or nullptr if the search is exhausted. | 40 // Gets the next Layout Opportunity or nullptr if the search is exhausted. |
40 // TODO(chrome-layout-team): Refactor with using C++ <iterator> library. | 41 // TODO(chrome-layout-team): Refactor with using C++ <iterator> library. |
41 const NGLayoutOpportunity Next(); | 42 const NGLayoutOpportunity Next(); |
42 | 43 |
43 DEFINE_INLINE_VIRTUAL_TRACE() { | |
44 visitor->trace(constraint_space_); | |
45 visitor->trace(opportunity_tree_root_); | |
46 } | |
47 | |
48 private: | 44 private: |
49 // Mutable Getters. | 45 // Mutable Getters. |
50 NGLayoutOpportunityTreeNode* MutableOpportunityTreeRoot() { | 46 NGLayoutOpportunityTreeNode* MutableOpportunityTreeRoot() { |
51 return opportunity_tree_root_.get(); | 47 return opportunity_tree_root_.get(); |
52 } | 48 } |
53 | 49 |
54 // Read-only Getters. | 50 // Read-only Getters. |
55 const NGLayoutOpportunityTreeNode* OpportunityTreeRoot() const { | 51 const NGLayoutOpportunityTreeNode* OpportunityTreeRoot() const { |
56 return opportunity_tree_root_.get(); | 52 return opportunity_tree_root_.get(); |
57 } | 53 } |
58 | 54 |
59 Member<NGConstraintSpace> constraint_space_; | 55 Persistent<NGConstraintSpace> constraint_space_; |
60 | 56 |
61 NGLayoutOpportunities opportunities_; | 57 NGLayoutOpportunities opportunities_; |
62 NGLayoutOpportunities::const_iterator opportunity_iter_; | 58 NGLayoutOpportunities::const_iterator opportunity_iter_; |
63 Member<NGLayoutOpportunityTreeNode> opportunity_tree_root_; | 59 Persistent<NGLayoutOpportunityTreeNode> opportunity_tree_root_; |
64 }; | 60 }; |
65 | 61 |
66 } // namespace blink | 62 } // namespace blink |
67 | 63 |
68 #endif // NGLayoutOpportunityIterator_h | 64 #endif // NGLayoutOpportunityIterator_h |
OLD | NEW |