Bug 1671140 [wpt PR 26101] - Avoid DCHECK failure when reusing space and newline with white-space:pre, a=testonly

Automatic update from web-platform-tests
Avoid DCHECK failure when reusing space and newline with white-space:pre

Consider this code:
  <style>i { white-space: pre-line }</style>
  X<i> </i><i>&#10;</i>

The first time that NGInlineNode::CollectInlines runs, the text data
will be "X", then "X ", and then AppendForcedBreakCollapseWhitespace
will remove the trailing whitespace before inserting the forced break,
so we get "X\n".

But if some text is appended dynamically, CollectInlines will run again,
and this time it will try to reuse existing items in AppendTextReusing.
Before this patch, this would produce "X \n", which would trigger a
DCHECK failure in ComputeOffsetMapping because it's a different string.

Therefore, this patch prevents AppendTextReusing from reusing existing
items if the last item to collapse with ends with collapsible spaces and
the first item to reuse has 'white-space:pre' and begins with a newline.

Bug: 1136688

TEST=external/wpt/css/css-text/white-space/pre-line-with-space-and-newline.html

Change-Id: I0ff71b125b66256ec3b5c263605c3c116f9ac55f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2466279
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Oriol Brufau <obrufau@igalia.com>
Cr-Commit-Position: refs/heads/master@{#816641}

--

wpt-commits: 5b6e508729caf23ab70c4db695315aef951c3d50
wpt-pr: 26101
This commit is contained in:
Oriol Brufau 2020-10-16 09:58:49 +00:00 коммит произвёл moz-wptsync-bot
Родитель 78ca91ad18
Коммит 69270edb78
1 изменённых файлов: 44 добавлений и 0 удалений

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

@ -0,0 +1,44 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Test: 'white-space: pre-line' with space and newline</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-text/#white-space-phase-1">
<link rel="help" href="https://crbug.com/1136688">
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
<meta name="assert" content="
Checks that collapsible spaces immediately preceding a sequent break are removed.
That still applies if they are separated into different inline elements.
Also, if some text is inserted dynamically, the browser should not crash.">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
span {
font: 25px/1 Ahem;
background: red;
color: green;
}
i {
white-space: pre-line;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="static together">
<span>XXXXXXXX<i> &#10;</i>XXXXXXXX</span>
</div>
<div class="static separated">
<span>XXXXXXXX<i> </i><i>&#10;</i>XXXXXXXX</span>
</div>
<div class="dynamic together">
<span>XXXXXXXX<i> &#10;</i></span>
</div>
<div class="dynamic separated">
<span>XXXXXXXX<i> </i><i>&#10;</i></span>
</div>
<script>
// Force layout
document.body.offsetLeft;
// Insert text, should not crash
for (let span of document.querySelectorAll(".dynamic > span")) {
span.append("XXXXXXXX");
}
</script>