Skip to content

Commit

Permalink
LibWeb: Clear grapheme segmenter when invalidating TextNode text
Browse files Browse the repository at this point in the history
We only set the grapheme segmenter's text once after creating a new
segmenter, so we also need to clear it whenever we invalidate the text.

(cherry picked from commit 25516e351e46104ff445216e7835aaab9f9b9535)
  • Loading branch information
gmta authored and nico committed Nov 27, 2024
1 parent 7d85d03 commit 7ad5025
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html><textarea>a
b</textarea>
9 changes: 9 additions & 0 deletions Tests/LibWeb/Ref/textnode-segmenter-invalidation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<head><link rel="match" href="reference/textnode-segmenter-invalidation.html" /></head>
<textarea id="output"></textarea>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.body.offsetWidth // Force layout
document.getElementById('output').value = 'a\nb';
});
</script>
1 change: 1 addition & 0 deletions Userland/Libraries/LibWeb/Layout/TextNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ static ErrorOr<String> apply_text_transform(String const& string, CSS::TextTrans
void TextNode::invalidate_text_for_rendering()
{
m_text_for_rendering = {};
m_grapheme_segmenter.clear();
}

String const& TextNode::text_for_rendering() const
Expand Down

0 comments on commit 7ad5025

Please sign in to comment.