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

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

Issue 2851983002: [LayoutNG] Change anonymous LayoutBlockFlow to LayoutNGBlockFlow (Closed)
Patch Set: fix test expectations. Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/inline/ng_inline_node.h" 7 #include "core/layout/ng/inline/ng_inline_node.h"
8 #include "core/layout/ng/ng_absolute_utils.h" 8 #include "core/layout/ng/ng_absolute_utils.h"
9 #include "core/layout/ng/ng_block_child_iterator.h" 9 #include "core/layout/ng/ng_block_child_iterator.h"
10 #include "core/layout/ng/ng_constraint_space.h" 10 #include "core/layout/ng/ng_constraint_space.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Append the current margin strut with child's block start margin. 340 // Append the current margin strut with child's block start margin.
341 // Non empty border/padding, and new FC use cases are handled inside of the 341 // Non empty border/padding, and new FC use cases are handled inside of the
342 // child's layout. 342 // child's layout.
343 if (!IsNewFormattingContextForBlockLevelChild(Style(), *child)) 343 if (!IsNewFormattingContextForBlockLevelChild(Style(), *child))
344 curr_margin_strut_.Append(curr_child_margins_.block_start); 344 curr_margin_strut_.Append(curr_child_margins_.block_start);
345 } 345 }
346 346
347 bool is_legacy_block = 347 bool is_legacy_block =
348 child->IsBlock() && !ToNGBlockNode(child)->CanUseNewLayout(); 348 child->IsBlock() && !ToNGBlockNode(child)->CanUseNewLayout();
349 349
350 // Should collapse margins if inline or legacy block 350 // TODO(crbug.com/716930): We should also collapse margins below once we
351 if (child->IsInline() || is_legacy_block) { 351 // remove LayoutInline splitting.
352
353 // Should collapse margins if our child is a legacy block.
354 if (is_legacy_block) {
352 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); 355 curr_bfc_offset_.block_offset += curr_margin_strut_.Sum();
353 MaybeUpdateFragmentBfcOffset(ConstraintSpace(), curr_bfc_offset_, 356 MaybeUpdateFragmentBfcOffset(ConstraintSpace(), curr_bfc_offset_,
354 &container_builder_); 357 &container_builder_);
355 PositionPendingFloats(curr_bfc_offset_.block_offset, &container_builder_, 358 PositionPendingFloats(curr_bfc_offset_.block_offset, &container_builder_,
356 MutableConstraintSpace()); 359 MutableConstraintSpace());
357 curr_margin_strut_ = {}; 360 curr_margin_strut_ = {};
358 } 361 }
359 child_bfc_offset.block_offset = curr_bfc_offset_.block_offset; 362 child_bfc_offset.block_offset = curr_bfc_offset_.block_offset;
360 return child_bfc_offset; 363 return child_bfc_offset;
361 } 364 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 RefPtr<NGConstraintSpace> NGBlockLayoutAlgorithm::CreateConstraintSpaceForChild( 559 RefPtr<NGConstraintSpace> NGBlockLayoutAlgorithm::CreateConstraintSpaceForChild(
557 const NGLogicalOffset& child_bfc_offset, 560 const NGLogicalOffset& child_bfc_offset,
558 NGLayoutInputNode* child) { 561 NGLayoutInputNode* child) {
559 DCHECK(child); 562 DCHECK(child);
560 563
561 const ComputedStyle& child_style = child->Style(); 564 const ComputedStyle& child_style = child->Style();
562 bool is_new_bfc = IsNewFormattingContextForBlockLevelChild(Style(), *child); 565 bool is_new_bfc = IsNewFormattingContextForBlockLevelChild(Style(), *child);
563 space_builder_.SetIsNewFormattingContext(is_new_bfc) 566 space_builder_.SetIsNewFormattingContext(is_new_bfc)
564 .SetBfcOffset(child_bfc_offset); 567 .SetBfcOffset(child_bfc_offset);
565 568
569 // Float's margins are not included in child's space because:
570 // 1) Floats do not participate in margins collapsing.
571 // 2) Floats margins are used separately to calculate floating exclusions.
572 space_builder_.SetMarginStrut(child->IsFloating() ? NGMarginStrut()
573 : curr_margin_strut_);
574
566 if (child->IsInline()) { 575 if (child->IsInline()) {
567 // TODO(kojii): Setup space_builder_ appropriately for inline child. 576 // TODO(kojii): Setup space_builder_ appropriately for inline child.
568 space_builder_.SetClearanceOffset(ConstraintSpace().ClearanceOffset()); 577 space_builder_.SetClearanceOffset(ConstraintSpace().ClearanceOffset());
569 return space_builder_.ToConstraintSpace( 578 return space_builder_.ToConstraintSpace(
570 FromPlatformWritingMode(Style().GetWritingMode())); 579 FromPlatformWritingMode(Style().GetWritingMode()));
571 } 580 }
572 581
573 space_builder_ 582 space_builder_
574 .SetClearanceOffset( 583 .SetClearanceOffset(
575 GetClearanceOffset(constraint_space_->Exclusions(), child_style)) 584 GetClearanceOffset(constraint_space_->Exclusions(), child_style))
576 .SetIsShrinkToFit(ShouldShrinkToFit(Style(), child_style)) 585 .SetIsShrinkToFit(ShouldShrinkToFit(Style(), child_style))
577 .SetTextDirection(child_style.Direction()); 586 .SetTextDirection(child_style.Direction());
578 587
579 // Float's margins are not included in child's space because:
580 // 1) Floats do not participate in margins collapsing.
581 // 2) Floats margins are used separately to calculate floating exclusions.
582 space_builder_.SetMarginStrut(child->IsFloating() ? NGMarginStrut()
583 : curr_margin_strut_);
584
585 LayoutUnit space_available; 588 LayoutUnit space_available;
586 if (constraint_space_->HasBlockFragmentation()) { 589 if (constraint_space_->HasBlockFragmentation()) {
587 space_available = ConstraintSpace().FragmentainerSpaceAvailable(); 590 space_available = ConstraintSpace().FragmentainerSpaceAvailable();
588 // If a block establishes a new formatting context we must know our 591 // If a block establishes a new formatting context we must know our
589 // position in the formatting context, and are able to adjust the 592 // position in the formatting context, and are able to adjust the
590 // fragmentation line. 593 // fragmentation line.
591 if (is_new_bfc) { 594 if (is_new_bfc) {
592 space_available -= child_bfc_offset.block_offset; 595 space_available -= child_bfc_offset.block_offset;
593 } 596 }
594 } 597 }
595 space_builder_.SetFragmentainerSpaceAvailable(space_available); 598 space_builder_.SetFragmentainerSpaceAvailable(space_available);
596 599
597 return space_builder_.ToConstraintSpace( 600 return space_builder_.ToConstraintSpace(
598 FromPlatformWritingMode(child_style.GetWritingMode())); 601 FromPlatformWritingMode(child_style.GetWritingMode()));
599 } 602 }
600 } // namespace blink 603 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698