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/LayoutBlock.h" | 7 #include "core/layout/LayoutBlock.h" |
8 #include "core/layout/LayoutBlockFlow.h" | 8 #include "core/layout/LayoutBlockFlow.h" |
9 #include "core/layout/LayoutMultiColumnFlowThread.h" | 9 #include "core/layout/LayoutMultiColumnFlowThread.h" |
10 #include "core/layout/LayoutMultiColumnSet.h" | 10 #include "core/layout/LayoutMultiColumnSet.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, | 128 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, |
129 NGBreakToken* break_token) { | 129 NGBreakToken* break_token) { |
130 // Use the old layout code and synthesize a fragment. | 130 // Use the old layout code and synthesize a fragment. |
131 if (!CanUseNewLayout()) { | 131 if (!CanUseNewLayout()) { |
132 return RunOldLayout(*constraint_space); | 132 return RunOldLayout(*constraint_space); |
133 } | 133 } |
134 | 134 |
135 RefPtr<NGLayoutResult> layout_result = | 135 RefPtr<NGLayoutResult> layout_result = |
136 LayoutWithAlgorithm(Style(), *this, constraint_space, break_token); | 136 LayoutWithAlgorithm(Style(), *this, constraint_space, break_token); |
137 | 137 |
138 CopyFragmentDataToLayoutBox(*constraint_space, layout_result.Get()); | 138 if (layout_result->Status() == NGLayoutResult::kSuccess && |
139 layout_result->UnpositionedFloats().IsEmpty()) | |
140 CopyFragmentDataToLayoutBox(*constraint_space, layout_result.Get()); | |
141 | |
139 return layout_result; | 142 return layout_result; |
140 } | 143 } |
141 | 144 |
142 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() { | 145 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() { |
143 MinMaxContentSize sizes; | 146 MinMaxContentSize sizes; |
144 if (!CanUseNewLayout()) { | 147 if (!CanUseNewLayout()) { |
145 // TODO(layout-ng): This could be somewhat optimized by directly calling | 148 // TODO(layout-ng): This could be somewhat optimized by directly calling |
146 // computeIntrinsicLogicalWidths, but that function is currently private. | 149 // computeIntrinsicLogicalWidths, but that function is currently private. |
147 // Consider doing that if this becomes a performance issue. | 150 // Consider doing that if this becomes a performance issue. |
148 LayoutUnit border_and_padding = box_->BorderAndPaddingLogicalWidth(); | 151 LayoutUnit border_and_padding = box_->BorderAndPaddingLogicalWidth(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 ToLayoutBlockFlow(box_)->RemoveFloatingObjects(); | 279 ToLayoutBlockFlow(box_)->RemoveFloatingObjects(); |
277 } | 280 } |
278 for (const NGPositionedFloat& positioned_float : | 281 for (const NGPositionedFloat& positioned_float : |
279 physical_fragment->PositionedFloats()) | 282 physical_fragment->PositionedFloats()) |
280 FloatingObjectPositionedUpdated(positioned_float, box_); | 283 FloatingObjectPositionedUpdated(positioned_float, box_); |
281 | 284 |
282 for (const auto& child_fragment : physical_fragment->Children()) { | 285 for (const auto& child_fragment : physical_fragment->Children()) { |
283 if (child_fragment->IsPlaced()) | 286 if (child_fragment->IsPlaced()) |
284 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment)); | 287 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment)); |
285 | 288 |
286 for (const NGPositionedFloat& positioned_float : | 289 if (child_fragment->GetLayoutObject()->IsLayoutBlockFlow()) |
287 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) { | 290 ToLayoutBlockFlow(child_fragment->GetLayoutObject()) |
288 FloatingObjectPositionedUpdated( | 291 ->AddOverflowFromFloats(); |
289 positioned_float, ToLayoutBox(child_fragment->GetLayoutObject())); | 292 |
293 if (child_fragment->GetLayoutObject() == box_) { | |
eae
2017/07/10 23:27:49
When would this be false?
ikilpatrick
2017/07/11 17:20:41
So this is actually for the _child_, i.e.
NGBoxFr
| |
294 for (const NGPositionedFloat& positioned_float : | |
295 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) { | |
296 FloatingObjectPositionedUpdated( | |
297 positioned_float, ToLayoutBox(child_fragment->GetLayoutObject())); | |
298 } | |
290 } | 299 } |
291 } | 300 } |
292 | 301 |
293 if (box_->IsLayoutBlock()) { | 302 if (box_->IsLayoutBlock()) { |
294 ToLayoutBlock(box_)->LayoutPositionedObjects(true); | 303 ToLayoutBlock(box_)->LayoutPositionedObjects(true); |
295 NGWritingMode writing_mode = | 304 NGWritingMode writing_mode = |
296 FromPlatformWritingMode(Style().GetWritingMode()); | 305 FromPlatformWritingMode(Style().GetWritingMode()); |
297 NGBoxFragment fragment(writing_mode, physical_fragment); | 306 NGBoxFragment fragment(writing_mode, physical_fragment); |
298 ToLayoutBlock(box_)->ComputeOverflow(fragment.OverflowSize().block_size - | 307 ToLayoutBlock(box_)->ComputeOverflow(fragment.OverflowSize().block_size - |
299 border_scrollbar_padding.block_end); | 308 border_scrollbar_padding.block_end); |
300 } | 309 } |
301 | 310 |
302 box_->UpdateAfterLayout(); | 311 box_->UpdateAfterLayout(); |
303 box_->ClearNeedsLayout(); | 312 box_->ClearNeedsLayout(); |
304 | 313 |
305 if (box_->IsLayoutBlockFlow()) { | 314 if (box_->IsLayoutBlockFlow()) { |
306 ToLayoutBlockFlow(box_)->UpdateIsSelfCollapsing(); | 315 LayoutBlockFlow* block_flow = ToLayoutBlockFlow(box_); |
316 block_flow->UpdateIsSelfCollapsing(); | |
317 | |
318 if (block_flow->CreatesNewFormattingContext()) | |
319 block_flow->AddOverflowFromFloats(); | |
307 } | 320 } |
308 } | 321 } |
309 | 322 |
310 RefPtr<NGLayoutResult> NGBlockNode::RunOldLayout( | 323 RefPtr<NGLayoutResult> NGBlockNode::RunOldLayout( |
311 const NGConstraintSpace& constraint_space) { | 324 const NGConstraintSpace& constraint_space) { |
312 NGLogicalSize available_size = constraint_space.PercentageResolutionSize(); | 325 NGLogicalSize available_size = constraint_space.PercentageResolutionSize(); |
313 LayoutObject* containing_block = box_->ContainingBlock(); | 326 LayoutObject* containing_block = box_->ContainingBlock(); |
314 NGWritingMode writing_mode = | 327 NGWritingMode writing_mode = |
315 FromPlatformWritingMode(Style().GetWritingMode()); | 328 FromPlatformWritingMode(Style().GetWritingMode()); |
316 bool parallel_writing_mode; | 329 bool parallel_writing_mode; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 | 383 |
371 // Save static position for legacy AbsPos layout. | 384 // Save static position for legacy AbsPos layout. |
372 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { | 385 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { |
373 DCHECK(box_->IsOutOfFlowPositioned()); | 386 DCHECK(box_->IsOutOfFlowPositioned()); |
374 DCHECK(box_->Layer()); | 387 DCHECK(box_->Layer()); |
375 box_->Layer()->SetStaticBlockPosition(offset.block_offset); | 388 box_->Layer()->SetStaticBlockPosition(offset.block_offset); |
376 box_->Layer()->SetStaticInlinePosition(offset.inline_offset); | 389 box_->Layer()->SetStaticInlinePosition(offset.inline_offset); |
377 } | 390 } |
378 | 391 |
379 } // namespace blink | 392 } // namespace blink |
OLD | NEW |