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

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: fixed! 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
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 560b03f52028e2f1d1eb7b44394c1899681dd975..50398694384156150f65d13acfd9249f6585c17d 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());
}
+// Returns true if a in-flow block-level child creates a new formatting context.
Gleb Lanbin 2016/10/18 22:54:10 .nit if a function returns boolean then google3 co
ikilpatrick 2016/10/18 22:59:28 Done, thanks!
+//
+// 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;

Powered by Google App Engine
This is Rietveld 408576698