Bug 1561130 [wpt PR 17447] - Handle null ::first-letter text layout object., a=testonly

Automatic update from web-platform-tests
Handle null ::first-letter text layout object.

Ideally, UpdateFirstLetterPseudoElement() will remove the ::first-letter
pseudo element from the DOM when there is no text which can contain the
first letter. Hence, we should not end up in a situation where we try to
AttachLayoutTree for the FirstLetterPseudoElement with a null
first_letter_text.

However, the layout tree is different in AttachLayoutTree() than in
UpdateFirstLetterPseudoElement() in the case where there already was a
::first-letter pseudo element, since we detached it right before
AttachLayoutTree. This means we may have different results for
FirstLetterTextLayoutObject() at those two points if the method has
bugs.

Such a bug was found here where a list item marker inside an anonymous
block had an out-of-flow sibling, but we were not able to traverse out
of the anonymous block to find the first letter text.

Add a DCHECK to let us trigger cases where FirstLetterTextLayoutObject()
is buggy, but also add if-tests to make sure we don't crash.

Bug: 977044
Change-Id: Id80f8aad5c04678d64927e7a7ca4d60cdb6a4b8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1672845
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671629}

--

wpt-commits: 53ebe42e282c9cd4c49d8e615b30eee06c2211a0
wpt-pr: 17447
This commit is contained in:
Rune Lillesveen 2019-07-19 12:40:04 +00:00 коммит произвёл James Graham
Родитель bac21dd67c
Коммит 73c5a11c8c
2 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,4 @@
<!doctype html>
<title>CSS Test Reference</title>
<p>The X below should be green.</p>
<div style="color:green">X</div>

Просмотреть файл

@ -0,0 +1,24 @@
<!doctype html>
<title>CSS Test: Move ::first-letter text node (required: list item, float, fixed, contenteditable).</title>
<link rel="match" href="first-letter-list-item-dynamic-001-ref.html">
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#first-letter-pseudo">
<link rel="help" href="https://crbug.com/977044">
<style>
#outer {
display: list-item;
overflow: auto; /* Triggers a crash in Blink see link to issue 977044 */
}
#outer::first-letter {
float: left;
color: green;
}
#fixed { position: fixed; }
#inner { float: left; }
</style>
<p>The X below should be green.</p>
<div id="outer" contenteditable="true">X<div id="fixed"></div><div id="inner"></div></div>
<script>
document.body.offsetTop;
inner.appendChild(outer.removeChild(outer.firstChild));
inner.removeAttribute("id");
</script>