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

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

Issue 2893493003: Respect the clearance while positioning pending floats. (Closed)
Patch Set: git rebase-update 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
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"
11 #include "core/layout/ng/ng_constraint_space_builder.h" 11 #include "core/layout/ng/ng_constraint_space_builder.h"
12 #include "core/layout/ng/ng_floats_utils.h" 12 #include "core/layout/ng/ng_floats_utils.h"
13 #include "core/layout/ng/ng_fragment.h" 13 #include "core/layout/ng/ng_fragment.h"
14 #include "core/layout/ng/ng_fragment_builder.h" 14 #include "core/layout/ng/ng_fragment_builder.h"
15 #include "core/layout/ng/ng_layout_opportunity_iterator.h" 15 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
16 #include "core/layout/ng/ng_layout_result.h" 16 #include "core/layout/ng/ng_layout_result.h"
17 #include "core/layout/ng/ng_length_utils.h" 17 #include "core/layout/ng/ng_length_utils.h"
18 #include "core/layout/ng/ng_out_of_flow_layout_part.h" 18 #include "core/layout/ng/ng_out_of_flow_layout_part.h"
19 #include "core/layout/ng/ng_space_utils.h" 19 #include "core/layout/ng/ng_space_utils.h"
20 #include "core/style/ComputedStyle.h" 20 #include "core/style/ComputedStyle.h"
21 #include "platform/LengthFunctions.h" 21 #include "platform/LengthFunctions.h"
22 #include "platform/wtf/Optional.h" 22 #include "platform/wtf/Optional.h"
23 23
24 namespace blink { 24 namespace blink {
25 namespace { 25 namespace {
26 26
27 // Adjusts {@code offset} to the clearance line.
28 void AdjustToClearance(const WTF::Optional<LayoutUnit>& clearance_offset,
29 NGLogicalOffset* offset) {
30 DCHECK(offset);
31 if (clearance_offset) {
32 offset->block_offset =
33 std::max(clearance_offset.value(), offset->block_offset);
34 }
35 }
36
37 // Returns if a child may be affected by its clear property. I.e. it will 27 // Returns if a child may be affected by its clear property. I.e. it will
38 // actually clear a float. 28 // actually clear a float.
39 bool ClearanceMayAffectLayout( 29 bool ClearanceMayAffectLayout(
40 const NGConstraintSpace& space, 30 const NGConstraintSpace& space,
41 const Vector<RefPtr<NGUnpositionedFloat>>& unpositioned_floats, 31 const Vector<RefPtr<NGUnpositionedFloat>>& unpositioned_floats,
42 const ComputedStyle& child_style) { 32 const ComputedStyle& child_style) {
43 const NGExclusions& exclusions = *space.Exclusions(); 33 const NGExclusions& exclusions = *space.Exclusions();
44 EClear clear = child_style.Clear(); 34 EClear clear = child_style.Clear();
45 bool should_clear_left = (clear == EClear::kBoth || clear == EClear::kLeft); 35 bool should_clear_left = (clear == EClear::kBoth || clear == EClear::kLeft);
46 bool should_clear_right = (clear == EClear::kBoth || clear == EClear::kRight); 36 bool should_clear_right = (clear == EClear::kBoth || clear == EClear::kRight);
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 637 }
648 638
649 if (child.IsInline()) { 639 if (child.IsInline()) {
650 // TODO(kojii): Setup space_builder appropriately for inline child. 640 // TODO(kojii): Setup space_builder appropriately for inline child.
651 space_builder.SetClearanceOffset(ConstraintSpace().ClearanceOffset()); 641 space_builder.SetClearanceOffset(ConstraintSpace().ClearanceOffset());
652 return space_builder.ToConstraintSpace( 642 return space_builder.ToConstraintSpace(
653 FromPlatformWritingMode(Style().GetWritingMode())); 643 FromPlatformWritingMode(Style().GetWritingMode()));
654 } 644 }
655 645
656 space_builder 646 space_builder
657 .SetClearanceOffset( 647 .SetClearanceOffset(GetClearanceOffset(constraint_space_->Exclusions(),
658 GetClearanceOffset(constraint_space_->Exclusions(), child_style)) 648 child_style.Clear()))
659 .SetIsShrinkToFit(ShouldShrinkToFit(Style(), child_style)) 649 .SetIsShrinkToFit(ShouldShrinkToFit(Style(), child_style))
660 .SetTextDirection(child_style.Direction()); 650 .SetTextDirection(child_style.Direction());
661 651
662 LayoutUnit space_available; 652 LayoutUnit space_available;
663 if (constraint_space_->HasBlockFragmentation()) { 653 if (constraint_space_->HasBlockFragmentation()) {
664 space_available = ConstraintSpace().FragmentainerSpaceAvailable(); 654 space_available = ConstraintSpace().FragmentainerSpaceAvailable();
665 // If a block establishes a new formatting context we must know our 655 // If a block establishes a new formatting context we must know our
666 // position in the formatting context, and are able to adjust the 656 // position in the formatting context, and are able to adjust the
667 // fragmentation line. 657 // fragmentation line.
668 if (is_new_bfc) { 658 if (is_new_bfc) {
669 space_available -= child_bfc_offset.block_offset; 659 space_available -= child_bfc_offset.block_offset;
670 } 660 }
671 } 661 }
672 space_builder.SetFragmentainerSpaceAvailable(space_available); 662 space_builder.SetFragmentainerSpaceAvailable(space_available);
673 663
674 return space_builder.ToConstraintSpace( 664 return space_builder.ToConstraintSpace(
675 FromPlatformWritingMode(child_style.GetWritingMode())); 665 FromPlatformWritingMode(child_style.GetWritingMode()));
676 } 666 }
677 } // namespace blink 667 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | third_party/WebKit/Source/core/layout/ng/ng_floats_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698