Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator.cc

Issue 2706353004: [LayoutNG] Introduce block child iterator. (Closed)
Patch Set: address comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/layout/ng/ng_block_child_iterator.h"
6
7 #include "core/layout/ng/ng_block_break_token.h"
8 #include "core/layout/ng/ng_layout_input_node.h"
9
10 namespace blink {
11
12 NGBlockChildIterator::NGBlockChildIterator(NGLayoutInputNode* first_child,
13 NGBlockBreakToken* break_token)
14 : child_(first_child), break_token_(break_token), child_token_idx_(0) {}
15
16 std::pair<NGLayoutInputNode*, NGBreakToken*> NGBlockChildIterator::NextChild() {
17 NGLayoutInputNode* child = nullptr;
Gleb Lanbin 2017/02/22 19:24:56 can you move this initialization to the line #52?
ikilpatrick 2017/02/22 20:25:27 Done.
18 NGBreakToken* child_break_token = nullptr;
19
20 if (break_token_) {
21 // If we're resuming layout after a fragmentainer break, we need to skip
22 // siblings that we're done with. We may have been able to fully lay out
23 // some node(s) preceding a node that we had to break inside (and therefore
24 // were not able to fully lay out). This happens when we have parallel
25 // flows [1], which are caused by floats, overflow, etc.
26 //
27 // [1] https://drafts.csswg.org/css-break/#parallel-flows
28 const auto& child_break_tokens = break_token_->ChildBreakTokens();
29
30 do {
31 // Early exit if we've exhausted our child break tokens.
32 if (child_token_idx_ >= child_break_tokens.size())
33 break;
34
35 // This child break token candidate doesn't match the current node, this
36 // node must be unfinished.
37 NGBreakToken* child_break_token_candidate =
38 child_break_tokens[child_token_idx_];
39 if (child_break_token_candidate->InputNode() != child_)
40 break;
41
42 ++child_token_idx_;
43
44 // We have only found a node if its break token is unfinished.
45 if (!child_break_token_candidate->IsFinished()) {
46 child_break_token = child_break_token_candidate;
47 break;
48 }
49 } while ((child_ = child_->NextSibling()));
50 }
51
52 child = child_;
53 if (child_)
54 child_ = child_->NextSibling();
55
56 return std::make_pair(child, child_break_token);
57 }
58
59 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698