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> </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/+/2466279Reviewed-by:Koji Ishii <kojii@chromium.org> Commit-Queue: Oriol Brufau <obrufau@igalia.com> Cr-Commit-Position: refs/heads/master@{#816641}
Showing
Please register or sign in to comment