LibWeb: Clear grapheme segmenter when invalidating TextNode text

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.
This commit is contained in:
Jelle Raaijmakers 2024-10-09 18:53:50 +02:00
parent 4fcaeabe1a
commit 25516e351e
Notes: github-actions[bot] 2024-10-09 21:08:10 +00:00
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,2 @@
<!DOCTYPE html><textarea>a
b</textarea>

View file

@ -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>

View file

@ -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