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

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: . Created 3 years, 10 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;
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 do {
29 const auto& child_break_tokens = break_token_->ChildBreakTokens();
mstensho (USE GERRIT) 2017/02/22 13:11:30 Can be moved out of the do-while loop.
ikilpatrick 2017/02/22 18:47:19 Done.
30 NGBreakToken* child_break_token_candidate = nullptr;
31
32 if (child_token_idx_ < child_break_tokens.size()) {
mstensho (USE GERRIT) 2017/02/22 13:11:31 Looks like you could get out early here if you do:
ikilpatrick 2017/02/22 18:47:19 Done.
33 child_break_token_candidate = child_break_tokens[child_token_idx_];
34 }
35
36 if (child_break_token_candidate &&
37 child_break_token_candidate->InputNode() == child_) {
mstensho (USE GERRIT) 2017/02/22 13:11:31 And how about breaking early here if child_break_t
ikilpatrick 2017/02/22 18:47:19 Done.
38 ++child_token_idx_;
39
40 // We have only found a node if it's break token is unfinished.
mstensho (USE GERRIT) 2017/02/22 13:11:30 it's -> its
ikilpatrick 2017/02/22 18:47:19 Done.
41 if (!child_break_token_candidate->IsFinished()) {
42 child_break_token = child_break_token_candidate;
43 break;
mstensho (USE GERRIT) 2017/02/22 13:11:30 Let me see if I've got this right: Each child tha
ikilpatrick 2017/02/22 18:47:19 Yes thats exactly correct. I can try an encapsulat
mstensho (USE GERRIT) 2017/02/22 20:09:23 If it's a requirement that all finished nodes have
ikilpatrick 2017/02/22 22:25:21 Clarified comment on NGBlockBreakToken.
mstensho (USE GERRIT) 2017/02/23 08:31:40 Excellent! Thanks.
44 }
45 } else {
46 // This child break token candidate doesn't match the current node,
47 // this node must be unfinished.
48 break;
49 }
50 } while ((child_ = child_->NextSibling()));
51 }
52
53 child = child_;
54 if (child_)
55 child_ = child_->NextSibling();
56
57 return std::make_pair(child, child_break_token);
58 }
59
60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698