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

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

Issue 2453463008: Take into account fragment's margins while searching opportunities. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
index f9d1fa9804d88f916d6569abbfc44f3e9e196369..4fc7e0525b6c5b08f4621e364eba4d8346dd4502 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
@@ -55,10 +55,12 @@ NGExclusion* CreateExclusion(const NGFragment& fragment,
// @param space Constraint space that is used to find layout opportunity for
// the fragment.
// @param fragment Fragment that needs to be placed.
+// @param margins Margins of the fragment.
// @return Layout opportunity for the fragment.
const NGLayoutOpportunity FindLayoutOpportunityForFragment(
const Member<NGConstraintSpace>& space,
- const NGFragment& fragment) {
+ const NGFragment& fragment,
+ const NGBoxStrut& margins) {
NGLayoutOpportunityIterator* opportunity_iter = space->LayoutOpportunities();
NGLayoutOpportunity opportunity;
NGLayoutOpportunity opportunity_candidate = opportunity_iter->Next();
@@ -67,7 +69,8 @@ const NGLayoutOpportunity FindLayoutOpportunityForFragment(
opportunity = opportunity_candidate;
// Checking opportunity's block size is not necessary as a float cannot be
// positioned on top of another float inside of the same constraint space.
- if (opportunity.size.inline_size > fragment.InlineSize())
+ auto fragment_inline_size = fragment.InlineSize() + margins.InlineSum();
+ if (opportunity.size.inline_size > fragment_inline_size)
break;
opportunity_candidate = opportunity_iter->Next();
@@ -327,7 +330,7 @@ NGLogicalOffset NGBlockLayoutAlgorithm::PositionFloatFragment(
// TODO(glebl@chromium.org): Support the top edge alignment rule.
// Find a layout opportunity that will fit our float.
const NGLayoutOpportunity opportunity = FindLayoutOpportunityForFragment(
- constraint_space_for_children_, fragment);
+ constraint_space_for_children_, fragment, margins);
DCHECK(!opportunity.IsEmpty()) << "Opportunity is empty but it shouldn't be";
// Calculate the float offset if needed.
@@ -337,7 +340,7 @@ NGLogicalOffset NGBlockLayoutAlgorithm::PositionFloatFragment(
}
// Add the float as an exclusion.
- NGExclusion* exclusion =
+ const NGExclusion* exclusion =
CreateExclusion(fragment, opportunity, float_offset, margins);
constraint_space_for_children_->AddExclusion(exclusion);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698