OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_layout_coordinator.h" | |
6 | |
7 #include "core/layout/ng/ng_layout_input_node.h" | |
8 #include "core/layout/ng/ng_physical_fragment.h" | |
9 | |
10 namespace blink { | |
11 | |
12 NGLayoutCoordinator::NGLayoutCoordinator(NGLayoutInputNode* input_node, | |
13 NGConstraintSpace* constraint_space) { | |
14 layout_algorithms_.push_back( | |
15 NGLayoutInputNode::AlgorithmForInputNode(input_node, constraint_space)); | |
16 } | |
17 | |
18 bool NGLayoutCoordinator::Tick(NGPhysicalFragment** out_fragment) { | |
19 NGLayoutAlgorithm* child_algorithm; | |
20 | |
21 // Tick should never be called without a layout algorithm on the stack. | |
22 DCHECK(layout_algorithms_.size()); | |
23 | |
24 NGPhysicalFragment* fragment; | |
25 NGPhysicalFragment* in_fragment = fragment_; | |
26 fragment_ = nullptr; | |
27 | |
28 switch (layout_algorithms_.back()->Layout(in_fragment, &fragment, | |
29 &child_algorithm)) { | |
30 case kNotFinished: | |
31 return false; | |
32 case kNewFragment: | |
33 layout_algorithms_.pop_back(); | |
34 if (layout_algorithms_.size() == 0) { | |
35 *out_fragment = fragment; | |
36 return true; | |
37 } | |
38 fragment_ = fragment; | |
39 return false; | |
40 case kChildAlgorithmRequired: | |
41 layout_algorithms_.push_back(child_algorithm); | |
42 return false; | |
43 } | |
44 | |
45 NOTREACHED(); | |
46 return false; | |
47 } | |
48 | |
49 DEFINE_TRACE(NGLayoutCoordinator) { | |
50 visitor->trace(layout_algorithms_); | |
51 visitor->trace(fragment_); | |
52 } | |
53 } | |
OLD | NEW |