Skip to content

Commit

Permalink
Missing initialization of force_legacy_layout.
Browse files Browse the repository at this point in the history
AttachContext.force_legacy_layout was not initialized for slot elements
when attaching for assigned flat tree children. We did not fall back to
legacy layout for children of a slot styled as a multicol container.

Bug: 1127874
Change-Id: I092ce2bb6f1af6a0af67c47d692f8f41284eedb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410487
Commit-Queue: Rune Lillesveen <[email protected]>
Reviewed-by: Morten Stenshorne <[email protected]>
Cr-Commit-Position: refs/heads/master@{#807405}
GitOrigin-RevId: 006d6e80175126c646f089ee68c791bc7d24e1dc
  • Loading branch information
Rune Lillesveen authored and copybara-github committed Sep 16, 2020
1 parent ffc10a6 commit c3f9f43
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blink/renderer/core/html/html_slot_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ void HTMLSlotElement::AttachLayoutTree(AttachContext& context) {
if (SupportsAssignment()) {
LayoutObject* layout_object = GetLayoutObject();
AttachContext children_context(context);
if (ShouldForceLegacyLayout())
children_context.force_legacy_layout = true;
const ComputedStyle* style = GetComputedStyle();
if (layout_object || !style || style->IsEnsuredInDisplayNone()) {
children_context.previous_in_flow = nullptr;
Expand Down
26 changes: 26 additions & 0 deletions blink/renderer/core/layout/force_legacy_layout_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,30 @@ TEST_F(ForceLegacyLayoutTest, ForceLegacyBfcRecalcAncestorStyle) {
EXPECT_EQ(UsesNGLayout(*child), EditingNGEnabled());
}

TEST_F(ForceLegacyLayoutTest, ForceLegacyMulticolSlot) {
if (!RuntimeEnabledFeatures::LayoutNGEnabled())
return;
if (RuntimeEnabledFeatures::LayoutNGBlockFragmentationEnabled())
return;

SetBodyInnerHTML(R"HTML(
<div id="host">
<p id="slotted"></p>
</div>
)HTML");

Element* host = GetDocument().getElementById("host");
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
shadow_root.setInnerHTML(R"HTML(
<style>
slot { columns: 2; display: block }
</style>
<slot></slot>
)HTML");

UpdateAllLifecyclePhasesForTest();
EXPECT_FALSE(UsesNGLayout(*GetDocument().getElementById("slotted")));
}

} // namespace blink

0 comments on commit c3f9f43

Please sign in to comment.