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

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

Issue 2417113002: [LayoutNG] Fix orthogonal writing mode child margin strut from being used in collapsing margins cal… (Closed)
Patch Set: address comments 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 ac0af34d59f0429de7399e6d29114ec0b3a432a7..83dc704dc140f08afb9ca7375eecc29a49f333ac 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
@@ -24,6 +24,41 @@ LayoutUnit ComputeCollapsedMarginBlockStart(
curr_margin_strut.negative_margin_block_start.abs());
}
+// Whether an in-flow block-level child creates a new formatting context.
+//
+// This will *NOT* check the following cases:
+// - The child is out-of-flow, e.g. floating or abs-pos.
+// - The child is a inline-level, e.g. "display: inline-block".
+// - The child establishes a new formatting context, but should be a child of
+// another layout algorithm, e.g. "display: table-caption" or flex-item.
+bool IsNewFormattingContextForInFlowBlockLevelChild(
+ const NGConstraintSpace& space,
+ const ComputedStyle& style) {
+ // TODO(layout-dev): This doesn't capture a few cases which can't be computed
+ // directly from style yet:
+ // - The child is a <fieldset>.
+ // - "column-span: all" is set on the child (requires knowledge that we are
+ // in a multi-col formatting context).
+ // (https://drafts.csswg.org/css-multicol-1/#valdef-column-span-all)
+
+ if (style.specifiesColumns() || style.containsPaint() ||
+ style.containsLayout())
+ return true;
+
+ if (!style.isOverflowVisible())
+ return true;
+
+ EDisplay display = style.display();
+ if (display == EDisplay::Grid || display == EDisplay::Flex ||
+ display == EDisplay::Box)
+ return true;
+
+ if (space.WritingMode() != FromPlatformWritingMode(style.getWritingMode()))
+ return true;
+
+ return false;
+}
+
} // namespace
NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
@@ -73,6 +108,10 @@ bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space,
}
case kStateChildLayout: {
if (current_child_) {
+ constraint_space_for_children_->SetIsNewFormattingContext(
+ IsNewFormattingContextForInFlowBlockLevelChild(
+ *constraint_space, *current_child_->Style()));
+
NGFragment* fragment;
if (!current_child_->Layout(constraint_space_for_children_, &fragment))
return false;
« 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