Commit 4a7c779e authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Add checks for anonymous boxes being of table part.

Anonymous inline wrappers for display:contents were mistakenly assumed
to be anonymous table parts.

Bug: 792439, 792946, 792550
Change-Id: Ib7017ff67a8658135d2e08c47f93966d5dbfa5bc
Reviewed-on: https://chromium-review.googlesource.com/817564
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523069}
parent a66ae460
...@@ -525,4 +525,102 @@ TEST_F(LayoutObjectTest, DisplayContentsWrapperPerTextNode) { ...@@ -525,4 +525,102 @@ TEST_F(LayoutObjectTest, DisplayContentsWrapperPerTextNode) {
text2->GetLayoutObject()->Parent()); text2->GetLayoutObject()->Parent());
} }
TEST_F(LayoutObjectTest, DisplayContentsWrapperInTable) {
SetBodyInnerHTML(R"HTML(
<div id='table' style='display:table'>
<div id='none' style='display:none'></div>
<div id='contents' style='display:contents;color:green'>Green</div>
</div>
)HTML");
Element* none = GetDocument().getElementById("none");
Element* contents = GetDocument().getElementById("contents");
ExpectAnonymousInlineWrapperFor<true>(contents->firstChild());
none->SetInlineStyleProperty(CSSPropertyDisplay, "inline");
GetDocument().View()->UpdateAllLifecyclePhases();
ASSERT_TRUE(none->GetLayoutObject());
LayoutObject* inline_parent = none->GetLayoutObject()->Parent();
ASSERT_TRUE(inline_parent);
LayoutObject* wrapper_parent =
contents->firstChild()->GetLayoutObject()->Parent()->Parent();
ASSERT_TRUE(wrapper_parent);
EXPECT_EQ(wrapper_parent, inline_parent);
EXPECT_TRUE(inline_parent->IsTableCell());
EXPECT_TRUE(inline_parent->IsAnonymous());
}
TEST_F(LayoutObjectTest, DisplayContentsWrapperInTableSection) {
SetBodyInnerHTML(R"HTML(
<div id='section' style='display:table-row-group'>
<div id='none' style='display:none'></div>
<div id='contents' style='display:contents;color:green'>Green</div>
</div>
)HTML");
Element* none = GetDocument().getElementById("none");
Element* contents = GetDocument().getElementById("contents");
ExpectAnonymousInlineWrapperFor<true>(contents->firstChild());
none->SetInlineStyleProperty(CSSPropertyDisplay, "inline");
GetDocument().View()->UpdateAllLifecyclePhases();
ASSERT_TRUE(none->GetLayoutObject());
LayoutObject* inline_parent = none->GetLayoutObject()->Parent();
ASSERT_TRUE(inline_parent);
LayoutObject* wrapper_parent =
contents->firstChild()->GetLayoutObject()->Parent()->Parent();
ASSERT_TRUE(wrapper_parent);
EXPECT_EQ(wrapper_parent, inline_parent);
EXPECT_TRUE(inline_parent->IsTableCell());
EXPECT_TRUE(inline_parent->IsAnonymous());
}
TEST_F(LayoutObjectTest, DisplayContentsWrapperInTableRow) {
SetBodyInnerHTML(R"HTML(
<div id='row' style='display:table-row'>
<div id='none' style='display:none'></div>
<div id='contents' style='display:contents;color:green'>Green</div>
</div>
)HTML");
Element* none = GetDocument().getElementById("none");
Element* contents = GetDocument().getElementById("contents");
ExpectAnonymousInlineWrapperFor<true>(contents->firstChild());
none->SetInlineStyleProperty(CSSPropertyDisplay, "inline");
GetDocument().View()->UpdateAllLifecyclePhases();
ASSERT_TRUE(none->GetLayoutObject());
LayoutObject* inline_parent = none->GetLayoutObject()->Parent();
ASSERT_TRUE(inline_parent);
LayoutObject* wrapper_parent =
contents->firstChild()->GetLayoutObject()->Parent()->Parent();
ASSERT_TRUE(wrapper_parent);
EXPECT_EQ(wrapper_parent, inline_parent);
EXPECT_TRUE(inline_parent->IsTableCell());
EXPECT_TRUE(inline_parent->IsAnonymous());
}
TEST_F(LayoutObjectTest, DisplayContentsWrapperInTableCell) {
SetBodyInnerHTML(R"HTML(
<div id='cell' style='display:table-cell'>
<div id='none' style='display:none'></div>
<div id='contents' style='display:contents;color:green'>Green</div>
</div>
)HTML");
Element* cell = GetDocument().getElementById("cell");
Element* none = GetDocument().getElementById("none");
Element* contents = GetDocument().getElementById("contents");
ExpectAnonymousInlineWrapperFor<true>(contents->firstChild());
none->SetInlineStyleProperty(CSSPropertyDisplay, "inline");
GetDocument().View()->UpdateAllLifecyclePhases();
ASSERT_TRUE(none->GetLayoutObject());
EXPECT_EQ(cell->GetLayoutObject(), none->GetLayoutObject()->Parent());
}
} // namespace blink } // namespace blink
...@@ -215,7 +215,8 @@ void LayoutTable::AddChild(LayoutObject* child, LayoutObject* before_child) { ...@@ -215,7 +215,8 @@ void LayoutTable::AddChild(LayoutObject* child, LayoutObject* before_child) {
while (last_box && last_box->Parent()->IsAnonymous() && while (last_box && last_box->Parent()->IsAnonymous() &&
!last_box->IsTableSection() && NeedsTableSection(last_box)) !last_box->IsTableSection() && NeedsTableSection(last_box))
last_box = last_box->Parent(); last_box = last_box->Parent();
if (last_box && last_box->IsAnonymous() && !IsAfterContent(last_box)) { if (last_box && last_box->IsAnonymous() && last_box->IsTablePart() &&
!IsAfterContent(last_box)) {
if (before_child == last_box) if (before_child == last_box)
before_child = last_box->SlowFirstChild(); before_child = last_box->SlowFirstChild();
last_box->AddChild(child, before_child); last_box->AddChild(child, before_child);
......
...@@ -144,7 +144,8 @@ void LayoutTableSection::AddChild(LayoutObject* child, ...@@ -144,7 +144,8 @@ void LayoutTableSection::AddChild(LayoutObject* child,
LayoutObject* last = before_child; LayoutObject* last = before_child;
if (!last) if (!last)
last = LastRow(); last = LastRow();
if (last && last->IsAnonymous() && !last->IsBeforeOrAfterContent()) { if (last && last->IsAnonymous() && last->IsTablePart() &&
!last->IsBeforeOrAfterContent()) {
if (before_child == last) if (before_child == last)
before_child = last->SlowFirstChild(); before_child = last->SlowFirstChild();
last->AddChild(child, before_child); last->AddChild(child, before_child);
......
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