Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc

Issue 2954953002: [LayoutNG] Abort a layout once the BFC offset is resolved. (Closed)
Patch Set: rebase. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, 125 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space,
126 NGBreakToken* break_token) { 126 NGBreakToken* break_token) {
127 // Use the old layout code and synthesize a fragment. 127 // Use the old layout code and synthesize a fragment.
128 if (!CanUseNewLayout()) { 128 if (!CanUseNewLayout()) {
129 return RunOldLayout(*constraint_space); 129 return RunOldLayout(*constraint_space);
130 } 130 }
131 131
132 RefPtr<NGLayoutResult> layout_result = 132 RefPtr<NGLayoutResult> layout_result =
133 LayoutWithAlgorithm(Style(), *this, constraint_space, break_token); 133 LayoutWithAlgorithm(Style(), *this, constraint_space, break_token);
134 134
135 CopyFragmentDataToLayoutBox(*constraint_space, layout_result.Get()); 135 if (layout_result->Status() == NGLayoutResult::kSuccess &&
136 layout_result->UnpositionedFloats().IsEmpty())
137 CopyFragmentDataToLayoutBox(*constraint_space, layout_result.Get());
138
136 return layout_result; 139 return layout_result;
137 } 140 }
138 141
139 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() { 142 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() {
140 MinMaxContentSize sizes; 143 MinMaxContentSize sizes;
141 if (!CanUseNewLayout()) { 144 if (!CanUseNewLayout()) {
142 // TODO(layout-ng): This could be somewhat optimized by directly calling 145 // TODO(layout-ng): This could be somewhat optimized by directly calling
143 // computeIntrinsicLogicalWidths, but that function is currently private. 146 // computeIntrinsicLogicalWidths, but that function is currently private.
144 // Consider doing that if this becomes a performance issue. 147 // Consider doing that if this becomes a performance issue.
145 LayoutUnit border_and_padding = box_->BorderAndPaddingLogicalWidth(); 148 LayoutUnit border_and_padding = box_->BorderAndPaddingLogicalWidth();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 ToLayoutBlockFlow(box_)->RemoveFloatingObjects(); 276 ToLayoutBlockFlow(box_)->RemoveFloatingObjects();
274 } 277 }
275 for (const NGPositionedFloat& positioned_float : 278 for (const NGPositionedFloat& positioned_float :
276 physical_fragment->PositionedFloats()) 279 physical_fragment->PositionedFloats())
277 FloatingObjectPositionedUpdated(positioned_float, box_); 280 FloatingObjectPositionedUpdated(positioned_float, box_);
278 281
279 for (const auto& child_fragment : physical_fragment->Children()) { 282 for (const auto& child_fragment : physical_fragment->Children()) {
280 if (child_fragment->IsPlaced()) 283 if (child_fragment->IsPlaced())
281 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment)); 284 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment));
282 285
283 for (const NGPositionedFloat& positioned_float : 286 if (child_fragment->GetLayoutObject()->IsLayoutBlockFlow())
284 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) { 287 ToLayoutBlockFlow(child_fragment->GetLayoutObject())
285 FloatingObjectPositionedUpdated( 288 ->AddOverflowFromFloats();
286 positioned_float, ToLayoutBox(child_fragment->GetLayoutObject())); 289
290 if (child_fragment->GetLayoutObject() == box_) {
291 for (const NGPositionedFloat& positioned_float :
292 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) {
293 FloatingObjectPositionedUpdated(
294 positioned_float, ToLayoutBox(child_fragment->GetLayoutObject()));
295 }
287 } 296 }
288 } 297 }
289 298
290 if (box_->IsLayoutBlock()) { 299 if (box_->IsLayoutBlock()) {
291 ToLayoutBlock(box_)->LayoutPositionedObjects(true); 300 ToLayoutBlock(box_)->LayoutPositionedObjects(true);
292 NGWritingMode writing_mode = 301 NGWritingMode writing_mode =
293 FromPlatformWritingMode(Style().GetWritingMode()); 302 FromPlatformWritingMode(Style().GetWritingMode());
294 NGBoxFragment fragment(writing_mode, physical_fragment); 303 NGBoxFragment fragment(writing_mode, physical_fragment);
295 ToLayoutBlock(box_)->ComputeOverflow(fragment.OverflowSize().block_size - 304 ToLayoutBlock(box_)->ComputeOverflow(fragment.OverflowSize().block_size -
296 border_scrollbar_padding.block_end); 305 border_scrollbar_padding.block_end);
297 } 306 }
298 307
299 box_->UpdateAfterLayout(); 308 box_->UpdateAfterLayout();
300 box_->ClearNeedsLayout(); 309 box_->ClearNeedsLayout();
301 310
302 if (box_->IsLayoutBlockFlow()) { 311 if (box_->IsLayoutBlockFlow()) {
303 ToLayoutBlockFlow(box_)->UpdateIsSelfCollapsing(); 312 LayoutBlockFlow* block_flow = ToLayoutBlockFlow(box_);
313 block_flow->UpdateIsSelfCollapsing();
314
315 if (block_flow->CreatesNewFormattingContext())
316 block_flow->AddOverflowFromFloats();
304 } 317 }
305 } 318 }
306 319
307 RefPtr<NGLayoutResult> NGBlockNode::RunOldLayout( 320 RefPtr<NGLayoutResult> NGBlockNode::RunOldLayout(
308 const NGConstraintSpace& constraint_space) { 321 const NGConstraintSpace& constraint_space) {
309 NGLogicalSize available_size = constraint_space.PercentageResolutionSize(); 322 NGLogicalSize available_size = constraint_space.PercentageResolutionSize();
310 LayoutObject* containing_block = box_->ContainingBlock(); 323 LayoutObject* containing_block = box_->ContainingBlock();
311 NGWritingMode writing_mode = 324 NGWritingMode writing_mode =
312 FromPlatformWritingMode(Style().GetWritingMode()); 325 FromPlatformWritingMode(Style().GetWritingMode());
313 bool parallel_writing_mode; 326 bool parallel_writing_mode;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 435
423 // Save static position for legacy AbsPos layout. 436 // Save static position for legacy AbsPos layout.
424 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 437 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
425 DCHECK(box_->IsOutOfFlowPositioned()); 438 DCHECK(box_->IsOutOfFlowPositioned());
426 DCHECK(box_->Layer()); 439 DCHECK(box_->Layer());
427 box_->Layer()->SetStaticBlockPosition(offset.block_offset); 440 box_->Layer()->SetStaticBlockPosition(offset.block_offset);
428 box_->Layer()->SetStaticInlinePosition(offset.inline_offset); 441 box_->Layer()->SetStaticInlinePosition(offset.inline_offset);
429 } 442 }
430 443
431 } // namespace blink 444 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698