OLD | NEW |
(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 NGBlockChildIterator::Entry NGBlockChildIterator::NextChild() { |
| 17 NGBreakToken* child_break_token = nullptr; |
| 18 |
| 19 if (break_token_) { |
| 20 // If we're resuming layout after a fragmentainer break, we need to skip |
| 21 // siblings that we're done with. We may have been able to fully lay out |
| 22 // some node(s) preceding a node that we had to break inside (and therefore |
| 23 // were not able to fully lay out). This happens when we have parallel |
| 24 // flows [1], which are caused by floats, overflow, etc. |
| 25 // |
| 26 // [1] https://drafts.csswg.org/css-break/#parallel-flows |
| 27 const auto& child_break_tokens = break_token_->ChildBreakTokens(); |
| 28 |
| 29 do { |
| 30 // Early exit if we've exhausted our child break tokens. |
| 31 if (child_token_idx_ >= child_break_tokens.size()) |
| 32 break; |
| 33 |
| 34 // This child break token candidate doesn't match the current node, this |
| 35 // node must be unfinished. |
| 36 NGBreakToken* child_break_token_candidate = |
| 37 child_break_tokens[child_token_idx_]; |
| 38 if (child_break_token_candidate->InputNode() != child_) |
| 39 break; |
| 40 |
| 41 ++child_token_idx_; |
| 42 |
| 43 // We have only found a node if its break token is unfinished. |
| 44 if (!child_break_token_candidate->IsFinished()) { |
| 45 child_break_token = child_break_token_candidate; |
| 46 break; |
| 47 } |
| 48 } while ((child_ = child_->NextSibling())); |
| 49 } |
| 50 |
| 51 NGLayoutInputNode* child = child_; |
| 52 if (child_) |
| 53 child_ = child_->NextSibling(); |
| 54 |
| 55 return Entry(child, child_break_token); |
| 56 } |
| 57 |
| 58 } // namespace blink |
OLD | NEW |