LibWeb: Skip styleless nodes for rendered text

Rendered text collection needs computed style only for nodes that are
being rendered. A stale layout node can remain without style or a styled
parent, so treat that as not rendered instead of asserting while reading
innerText or outerText.

Add reduced crash coverage for reading outerText from a style element
after disabling and adopting it into another document.
This commit is contained in:
Andreas Kling 2026-06-06 23:49:15 +02:00 committed by Andreas Kling
parent 3fcd95327e
commit 613a04e4df
2 changed files with 10 additions and 0 deletions

View file

@ -314,6 +314,8 @@ static Vector<Variant<Utf16String, RequiredLineBreakCount>> rendered_text_collec
auto* layout_node = node.layout_node();
if (!layout_node)
return items;
if (!layout_node->has_style_or_parent_with_style())
return items;
auto const& computed_values = layout_node->computed_values();

View file

@ -0,0 +1,8 @@
<!doctype html>
<style id="style">div { color: red }</style>
<script>
document.body.offsetTop;
style.disabled = true;
document.implementation.createHTMLDocument("x").adoptNode(style);
style.outerText;
</script>