Commit 06e79cf3 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Skip empty text nodes for whitespace attachment.

Setting empty text nodes as the last seen text node for the
WhitespaceAttacher leads to subsequent whitespace nodes not being re-
attached. Just skip empty text nodes as if they weren't there.

Bug: 428313
Change-Id: I79a6382d7215ec46bfb9165c04b1acb190e6357a
Reviewed-on: https://chromium-review.googlesource.com/1252467Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595350}
parent 39046b91
<!DOCTYPE html>
<p>There should be a space between "Two" and "words".</p>
Two words
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-rules">
<link rel="match" href="reference/white-space-empty-text-sibling-ref.html">
<p>There should be a space between "Two" and "words".</p>
<div id="block"> <span>words</span></div>
<script>
block.insertBefore(document.createTextNode(""), block.firstChild);
block.insertBefore(document.createTextNode(""), block.firstChild);
block.offsetTop;
block.firstChild.data = "Two";
</script>
...@@ -55,6 +55,8 @@ void WhitespaceAttacher::DidReattachElement(Element* element, ...@@ -55,6 +55,8 @@ void WhitespaceAttacher::DidReattachElement(Element* element,
void WhitespaceAttacher::DidVisitText(Text* text) { void WhitespaceAttacher::DidVisitText(Text* text) {
DCHECK(text); DCHECK(text);
if (!last_text_node_ || !last_text_node_needs_reattach_) { if (!last_text_node_ || !last_text_node_needs_reattach_) {
if (text->data().IsEmpty())
return;
SetLastTextNode(text); SetLastTextNode(text);
if (reattach_all_whitespace_nodes_ && text->ContainsOnlyWhitespace()) if (reattach_all_whitespace_nodes_ && text->ContainsOnlyWhitespace())
last_text_node_needs_reattach_ = true; last_text_node_needs_reattach_ = true;
......
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