OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 NGBlockChildIterator_h | 5 #ifndef NGBlockChildIterator_h |
6 #define NGBlockChildIterator_h | 6 #define NGBlockChildIterator_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/ng_layout_input_node.h" |
9 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
10 #include "platform/wtf/RefPtr.h" | 11 #include "platform/wtf/RefPtr.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 class NGLayoutInputNode; | 15 class NGLayoutInputNode; |
15 class NGBreakToken; | 16 class NGBreakToken; |
16 class NGBlockBreakToken; | 17 class NGBlockBreakToken; |
17 | 18 |
18 // A utility class for block-flow layout which given the first child and a | 19 // A utility class for block-flow layout which given the first child and a |
19 // break token will iterate through unfinished children. | 20 // break token will iterate through unfinished children. |
20 // | 21 // |
21 // This class does not handle modifications to its arguments after it has been | 22 // This class does not handle modifications to its arguments after it has been |
22 // constructed. | 23 // constructed. |
23 class CORE_EXPORT NGBlockChildIterator { | 24 class CORE_EXPORT NGBlockChildIterator { |
24 STACK_ALLOCATED(); | 25 STACK_ALLOCATED(); |
25 | 26 |
26 public: | 27 public: |
27 NGBlockChildIterator(NGLayoutInputNode* first_child, | 28 NGBlockChildIterator(NGLayoutInputNode first_child, |
28 NGBlockBreakToken* break_token); | 29 NGBlockBreakToken* break_token); |
29 | 30 |
30 // Returns the next input node which should be laid out, along with its | 31 // Returns the next input node which should be laid out, along with its |
31 // respective break token. | 32 // respective break token. |
32 struct Entry; | 33 struct Entry; |
33 Entry NextChild(); | 34 Entry NextChild(); |
34 | 35 |
35 private: | 36 private: |
36 Persistent<NGLayoutInputNode> child_; | 37 NGLayoutInputNode child_; |
37 NGBlockBreakToken* break_token_; | 38 NGBlockBreakToken* break_token_; |
38 | 39 |
39 // An index into break_token_'s ChildBreakTokens() vector. Used for keeping | 40 // An index into break_token_'s ChildBreakTokens() vector. Used for keeping |
40 // track of the next child break token to inspect. | 41 // track of the next child break token to inspect. |
41 size_t child_token_idx_; | 42 size_t child_token_idx_; |
42 }; | 43 }; |
43 | 44 |
44 struct NGBlockChildIterator::Entry { | 45 struct NGBlockChildIterator::Entry { |
45 STACK_ALLOCATED(); | 46 STACK_ALLOCATED(); |
46 | 47 |
47 Entry(NGLayoutInputNode* node, NGBreakToken* token) | 48 Entry(NGLayoutInputNode node, NGBreakToken* token) |
48 : node(node), token(token) {} | 49 : node(node), token(token) {} |
49 | 50 |
50 Persistent<NGLayoutInputNode> node; | 51 NGLayoutInputNode node; |
51 NGBreakToken* token; | 52 NGBreakToken* token; |
52 | 53 |
53 bool operator==(const NGBlockChildIterator::Entry& other) const { | 54 bool operator==(const NGBlockChildIterator::Entry& other) const { |
54 return node == other.node && token == other.token; | 55 return node == other.node && token == other.token; |
55 } | 56 } |
56 }; | 57 }; |
57 | 58 |
58 } // namespace blink | 59 } // namespace blink |
59 | 60 |
60 #endif // NGBlockChildIterator_h | 61 #endif // NGBlockChildIterator_h |
OLD | NEW |