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

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

Issue 2368153003: Compute margin block start for 1st block in LayoutNG root constraint space (Closed)
Patch Set: rename IsNewBfc -> IsNewFormattingContext Created 4 years, 3 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 2c9789afc08cec3ded1ab824f738533f80f753cb..c56b00f30e04912ed9ef24b3e2aa87c185af54b2 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
@@ -125,9 +125,6 @@ LayoutUnit NGBlockLayoutAlgorithm::CollapseMargins(
const NGConstraintSpace& space,
const NGBoxStrut& margins,
const NGFragment& fragment) {
- // TODO(chrome-layout-team): Do not collapse margins for elements that
- // establish new block formatting contexts
-
// Zero-height boxes are ignored and do not participate in margin collapsing.
bool is_zero_height_box = !fragment.BlockSize() && margins.IsEmpty();
if (is_zero_height_box)
@@ -160,15 +157,19 @@ LayoutUnit NGBlockLayoutAlgorithm::CollapseMargins(
curr_margin_strut.SetMarginBlockEnd(margins.block_end);
}
- // Update the parent fragment's margin strut
- UpdateMarginStrut(curr_margin_strut);
-
- // Compute the margin block start for adjoining blocks.
+ // Compute the margin block start for
+ // 1) adjoining blocks
+ // 2) 1st block in the newly established formatting context.
LayoutUnit margin_block_start;
- if (is_fragment_margin_strut_block_start_updated_) {
+ if (is_fragment_margin_strut_block_start_updated_ ||
+ space.IsNewFormattingContext()) {
margin_block_start = ComputeCollapsedMarginBlockStart(
prev_child_margin_strut_, curr_margin_strut);
}
+
+ // Update the parent fragment's margin strut
+ UpdateMarginStrut(curr_margin_strut);
+
prev_child_margin_strut_ = curr_margin_strut;
return margin_block_start;
}
« 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