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_block_node.h" | 5 #include "core/layout/ng/ng_block_node.h" |
6 | 6 |
7 #include "core/layout/LayoutBlockFlow.h" | 7 #include "core/layout/LayoutBlockFlow.h" |
8 #include "core/layout/api/LineLayoutAPIShim.h" | 8 #include "core/layout/api/LineLayoutAPIShim.h" |
9 #include "core/layout/line/InlineIterator.h" | 9 #include "core/layout/line/InlineIterator.h" |
10 #include "core/layout/ng/layout_ng_block_flow.h" | 10 #include "core/layout/ng/layout_ng_block_flow.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 layout_box_(nullptr), | 79 layout_box_(nullptr), |
80 style_(style) { | 80 style_(style) { |
81 DCHECK(style_); | 81 DCHECK(style_); |
82 } | 82 } |
83 | 83 |
84 // Need an explicit destructor in the .cc file, or the MSWIN compiler will | 84 // Need an explicit destructor in the .cc file, or the MSWIN compiler will |
85 // produce an error when attempting to generate a default one, if the .h file is | 85 // produce an error when attempting to generate a default one, if the .h file is |
86 // included from a compilation unit that lacks the ComputedStyle definition. | 86 // included from a compilation unit that lacks the ComputedStyle definition. |
87 NGBlockNode::~NGBlockNode() {} | 87 NGBlockNode::~NGBlockNode() {} |
88 | 88 |
89 RefPtr<NGLayoutResult> NGBlockNode::Layout( | 89 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, |
90 NGConstraintSpace* constraint_space) { | 90 NGBreakToken* break_token) { |
91 // Use the old layout code and synthesize a fragment. | 91 // Use the old layout code and synthesize a fragment. |
92 if (!CanUseNewLayout()) { | 92 if (!CanUseNewLayout()) { |
93 DCHECK(layout_box_); | 93 DCHECK(layout_box_); |
94 layout_result_ = RunOldLayout(*constraint_space); | 94 layout_result_ = RunOldLayout(*constraint_space); |
95 return layout_result_; | 95 return layout_result_; |
96 } | 96 } |
97 | 97 |
98 layout_result_ = | 98 layout_result_ = NGBlockLayoutAlgorithm(this, constraint_space, |
99 NGBlockLayoutAlgorithm(this, constraint_space, CurrentBreakToken()) | 99 toNGBlockBreakToken(break_token)) |
100 .Layout(); | 100 .Layout(); |
101 | 101 |
102 CopyFragmentDataToLayoutBox(*constraint_space); | 102 CopyFragmentDataToLayoutBox(*constraint_space); |
103 return layout_result_; | 103 return layout_result_; |
104 } | 104 } |
105 | 105 |
106 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() { | 106 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() { |
107 MinAndMaxContentSizes sizes; | 107 MinAndMaxContentSizes sizes; |
108 if (!CanUseNewLayout()) { | 108 if (!CanUseNewLayout()) { |
109 DCHECK(layout_box_); | 109 DCHECK(layout_box_); |
110 // TODO(layout-ng): This could be somewhat optimized by directly calling | 110 // TODO(layout-ng): This could be somewhat optimized by directly calling |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 | 201 |
202 void NGBlockNode::SetNextSibling(NGLayoutInputNode* sibling) { | 202 void NGBlockNode::SetNextSibling(NGLayoutInputNode* sibling) { |
203 next_sibling_ = sibling; | 203 next_sibling_ = sibling; |
204 } | 204 } |
205 | 205 |
206 void NGBlockNode::SetFirstChild(NGLayoutInputNode* child) { | 206 void NGBlockNode::SetFirstChild(NGLayoutInputNode* child) { |
207 first_child_ = child; | 207 first_child_ = child; |
208 } | 208 } |
209 | 209 |
210 NGBreakToken* NGBlockNode::CurrentBreakToken() const { | |
211 return layout_result_ ? layout_result_->PhysicalFragment()->BreakToken() | |
212 : nullptr; | |
213 } | |
214 | |
215 DEFINE_TRACE(NGBlockNode) { | 210 DEFINE_TRACE(NGBlockNode) { |
216 visitor->trace(next_sibling_); | 211 visitor->trace(next_sibling_); |
217 visitor->trace(first_child_); | 212 visitor->trace(first_child_); |
218 NGLayoutInputNode::trace(visitor); | 213 NGLayoutInputNode::trace(visitor); |
219 } | 214 } |
220 | 215 |
221 bool NGBlockNode::CanUseNewLayout() { | 216 bool NGBlockNode::CanUseNewLayout() { |
222 if (!layout_box_) | 217 if (!layout_box_) |
223 return true; | 218 return true; |
224 if (!layout_box_->isLayoutBlockFlow()) | 219 if (!layout_box_->isLayoutBlockFlow()) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // Save static position for legacy AbsPos layout. | 364 // Save static position for legacy AbsPos layout. |
370 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { | 365 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { |
371 DCHECK(layout_box_); | 366 DCHECK(layout_box_); |
372 DCHECK(layout_box_->isOutOfFlowPositioned()); | 367 DCHECK(layout_box_->isOutOfFlowPositioned()); |
373 DCHECK(layout_box_->layer()); | 368 DCHECK(layout_box_->layer()); |
374 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); | 369 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); |
375 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); | 370 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); |
376 } | 371 } |
377 | 372 |
378 } // namespace blink | 373 } // namespace blink |
OLD | NEW |