Commit 81f9e4d6 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Check that first-letter text is not null before attaching.

Under certain combinations of whitespace-reattachment after removing
nodes, parent element being display:contents triggering anonymous
inline boxes for such parents, and ::first-letter being marked for re-
attachment, we can end up with a calculated first-letter text node
changing from non-null to null between style recalc and layout tree
rebuild. Make sure we check that the first-letter text node is still
non-null early in UpdateFirstLetterPseudoElement during the
kRebuildLayoutTree so that we nuke the first-letter pseudo instead of
re-attaching without first-letter text.

Bug: 908253
Change-Id: Ifaac75b34edce21467581b5a9e78f5287a842fe5
Reviewed-on: https://chromium-review.googlesource.com/c/1356714
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613076}
parent e558a735
...@@ -3958,13 +3958,6 @@ void Element::UpdateFirstLetterPseudoElement(StyleUpdatePhase phase) { ...@@ -3958,13 +3958,6 @@ void Element::UpdateFirstLetterPseudoElement(StyleUpdatePhase phase) {
return; return;
} }
if (phase == StyleUpdatePhase::kRebuildLayoutTree &&
element->NeedsReattachLayoutTree()) {
// We were already updated in RecalcStyle and ready for reattach.
DCHECK(element->GetNonAttachedStyle());
return;
}
if (!CanGeneratePseudoElement(kPseudoIdFirstLetter)) { if (!CanGeneratePseudoElement(kPseudoIdFirstLetter)) {
GetElementRareData()->SetPseudoElement(kPseudoIdFirstLetter, nullptr); GetElementRareData()->SetPseudoElement(kPseudoIdFirstLetter, nullptr);
return; return;
...@@ -3978,6 +3971,13 @@ void Element::UpdateFirstLetterPseudoElement(StyleUpdatePhase phase) { ...@@ -3978,6 +3971,13 @@ void Element::UpdateFirstLetterPseudoElement(StyleUpdatePhase phase) {
return; return;
} }
if (phase == StyleUpdatePhase::kRebuildLayoutTree &&
element->NeedsReattachLayoutTree()) {
// We were already updated in RecalcStyle and ready for reattach.
DCHECK(element->GetNonAttachedStyle());
return;
}
bool text_node_changed = bool text_node_changed =
remaining_text_layout_object != remaining_text_layout_object !=
ToFirstLetterPseudoElement(element)->RemainingTextLayoutObject(); ToFirstLetterPseudoElement(element)->RemainingTextLayoutObject();
......
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