Commit 326bab28 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[TableNG] Force all table elements to Legacy

NG Tables assume that in a single table either all elements
are Legacy, or they are all NG.

This patch makes TABLE force legacy if cell is forced legacy.

Bug: 958381
Change-Id: I7fd7b943dc5a7df41a0d5b21d292e33654ec23ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898150
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713727}
parent a792a3e8
......@@ -4395,11 +4395,12 @@ void Element::UpdateForceLegacyLayout(const ComputedStyle& new_style,
void Element::ForceLegacyLayoutInFormattingContext(
const ComputedStyle& new_style) {
if (DefinitelyNewFormattingContext(*this, new_style))
return;
bool found_bfc = false;
for (Element* ancestor = this; !found_bfc;) {
// TableNG requires that table elements are either all NG, or all Legacy.
bool needs_traverse_to_table =
RuntimeEnabledFeatures::LayoutNGTableEnabled() &&
new_style.IsDisplayTableType();
bool found_bfc = DefinitelyNewFormattingContext(*this, new_style);
for (Element* ancestor = this; !found_bfc || needs_traverse_to_table;) {
ancestor =
DynamicTo<Element>(LayoutTreeBuilderTraversal::Parent(*ancestor));
if (!ancestor || ancestor->ShouldForceLegacyLayout())
......@@ -4407,7 +4408,17 @@ void Element::ForceLegacyLayoutInFormattingContext(
const ComputedStyle* style = ancestor->GetComputedStyle();
if (style->Display() == EDisplay::kNone)
break;
found_bfc = DefinitelyNewFormattingContext(*ancestor, *style);
found_bfc = found_bfc || DefinitelyNewFormattingContext(*ancestor, *style);
if (found_bfc && !needs_traverse_to_table) {
needs_traverse_to_table =
RuntimeEnabledFeatures::LayoutNGTableEnabled() &&
style->IsDisplayTableType();
}
if (needs_traverse_to_table) {
EDisplay display = style->Display();
if (display == EDisplay::kTable || display == EDisplay::kInlineTable)
needs_traverse_to_table = false;
}
ancestor->SetShouldForceLegacyLayoutForChild(true);
ancestor->SetNeedsReattachLayoutTree();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment