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