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