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

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

Issue 2646853006: [LayoutNG] Pull out of flow candidate loop into out of flow layout part. (Closed)
Patch Set: rebase Created 3 years, 10 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_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/layout/ng/ng_absolute_utils.h" 7 #include "core/layout/ng/ng_absolute_utils.h"
8 #include "core/layout/ng/ng_block_break_token.h" 8 #include "core/layout/ng/ng_block_break_token.h"
9 #include "core/layout/ng/ng_box_fragment.h" 9 #include "core/layout/ng/ng_box_fragment.h"
10 #include "core/layout/ng/ng_column_mapper.h" 10 #include "core/layout/ng/ng_column_mapper.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 break; 301 break;
302 } 302 }
303 303
304 content_size_ += border_and_padding_.block_end; 304 content_size_ += border_and_padding_.block_end;
305 305
306 // Recompute the block-axis size now that we know our content size. 306 // Recompute the block-axis size now that we know our content size.
307 block_size = 307 block_size =
308 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_); 308 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), content_size_);
309 builder_->SetBlockSize(block_size); 309 builder_->SetBlockSize(block_size);
310 310
311 LayoutOutOfFlowChildren(); 311 // Layout our absolute and fixed positioned children.
312 NGOutOfFlowLayoutPart(Style(), builder_).Run();
312 313
313 builder_->SetInlineOverflow(max_inline_size_).SetBlockOverflow(content_size_); 314 builder_->SetInlineOverflow(max_inline_size_).SetBlockOverflow(content_size_);
314 315
315 if (ConstraintSpace().HasBlockFragmentation()) 316 if (ConstraintSpace().HasBlockFragmentation())
316 FinalizeForFragmentation(); 317 FinalizeForFragmentation();
317 318
318 NGPhysicalFragment* fragment = builder_->ToBoxFragment(); 319 NGPhysicalFragment* fragment = builder_->ToBoxFragment();
319 320
320 return fragment; 321 return fragment;
321 } 322 }
(...skipping 10 matching lines...) Expand all
332 fragment->InlineSize(), &child_margins); 333 fragment->InlineSize(), &child_margins);
333 fragment_offset = PositionFragment(*fragment, child_margins); 334 fragment_offset = PositionFragment(*fragment, child_margins);
334 } 335 }
335 if (fragmentainer_mapper_) 336 if (fragmentainer_mapper_)
336 fragmentainer_mapper_->ToVisualOffset(fragment_offset); 337 fragmentainer_mapper_->ToVisualOffset(fragment_offset);
337 else 338 else
338 fragment_offset.block_offset -= PreviousBreakOffset(); 339 fragment_offset.block_offset -= PreviousBreakOffset();
339 builder_->AddChild(fragment, fragment_offset); 340 builder_->AddChild(fragment, fragment_offset);
340 } 341 }
341 342
342 void NGBlockLayoutAlgorithm::LayoutOutOfFlowChildren() {
343 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_candidates;
344 Vector<NGStaticPosition> out_of_flow_candidate_positions;
345 builder_->GetAndClearOutOfFlowDescendantCandidates(
346 &out_of_flow_candidates, &out_of_flow_candidate_positions);
347
348 Member<NGOutOfFlowLayoutPart> out_of_flow_layout =
349 new NGOutOfFlowLayoutPart(&Style(), builder_->Size());
350 size_t candidate_positions_index = 0;
351
352 for (auto& child : out_of_flow_candidates) {
353 NGStaticPosition static_position =
354 out_of_flow_candidate_positions[candidate_positions_index++];
355
356 if (IsContainingBlockForAbsoluteChild(Style(), *child->Style())) {
357 NGFragment* fragment;
358 NGLogicalOffset offset;
359 out_of_flow_layout->Layout(*child, static_position, &fragment, &offset);
360 // TODO(atotic) Need to adjust size of overflow rect per spec.
361 builder_->AddChild(fragment, offset);
362 } else {
363 builder_->AddOutOfFlowDescendant(child, static_position);
364 }
365 }
366 }
367
368 bool NGBlockLayoutAlgorithm::ProceedToNextUnfinishedSibling( 343 bool NGBlockLayoutAlgorithm::ProceedToNextUnfinishedSibling(
369 NGPhysicalFragment* child_fragment) { 344 NGPhysicalFragment* child_fragment) {
370 DCHECK(current_child_); 345 DCHECK(current_child_);
371 NGBlockNode* finished_child = current_child_; 346 NGBlockNode* finished_child = current_child_;
372 current_child_ = current_child_->NextSibling(); 347 current_child_ = current_child_->NextSibling();
373 if (!ConstraintSpace().HasBlockFragmentation() && !fragmentainer_mapper_) 348 if (!ConstraintSpace().HasBlockFragmentation() && !fragmentainer_mapper_)
374 return true; 349 return true;
375 // If we're resuming layout after a fragmentainer break, we need to skip 350 // If we're resuming layout after a fragmentainer break, we need to skip
376 // siblings that we're done with. We may have been able to fully lay out some 351 // siblings that we're done with. We may have been able to fully lay out some
377 // node(s) preceding a node that we had to break inside (and therefore were 352 // node(s) preceding a node that we had to break inside (and therefore were
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 visitor->trace(constraint_space_); 662 visitor->trace(constraint_space_);
688 visitor->trace(break_token_); 663 visitor->trace(break_token_);
689 visitor->trace(builder_); 664 visitor->trace(builder_);
690 visitor->trace(space_builder_); 665 visitor->trace(space_builder_);
691 visitor->trace(space_for_current_child_); 666 visitor->trace(space_for_current_child_);
692 visitor->trace(current_child_); 667 visitor->trace(current_child_);
693 visitor->trace(fragmentainer_mapper_); 668 visitor->trace(fragmentainer_mapper_);
694 } 669 }
695 670
696 } // namespace blink 671 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698