LibWeb: Fix handling of find-in-page with pseudo-element content

This change makes find-in-page ignore content that’s been added to the
document using CSS ::after or ::before pseudo-elements. Ignoring such
pseudo-element content for find-in-page matches the behavior in Chrome
and Safari (though not in Firefox).

Otherwise, without this change, find-in-page doesn’t ignore the
pseudo-element content, and we instead crash in
DOM::Range::common_ancestor_container after hitting an assert, due to
the start container and end container for the matched range not having a
common ancestor.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/514
This commit is contained in:
sideshowbarker 2024-07-09 16:10:24 +09:00 committed by Tim Ledbetter
commit 0a55e36403
Notes: sideshowbarker 2024-07-17 02:29:45 +09:00

View file

@ -57,7 +57,7 @@ void Viewport::update_text_blocks()
if (layout_node.display().is_none() || !layout_node.paintable() || !layout_node.paintable()->is_visible())
return TraversalDecision::Continue;
if (layout_node.is_box()) {
if (layout_node.is_box() || layout_node.is_generated()) {
if (!builder.is_empty()) {
text_blocks.append({ builder.to_string_without_validation(), text_positions });
current_start_position = 0;