LibWeb: Don't search non-visible text for find in page results

Elements which are `display: none` or `visibility: hidden` are no
longer included in find in page results.
This commit is contained in:
Tim Ledbetter 2024-06-20 09:20:15 +01:00 committed by Andreas Kling
parent 23166b85d2
commit a3a7a65b1c
Notes: sideshowbarker 2024-07-17 03:05:16 +09:00

View File

@ -5129,6 +5129,9 @@ Vector<JS::Handle<DOM::Range>> Document::find_matching_text(String const& query,
Vector<TextPosition> text_positions;
Vector<TextBlock> text_blocks;
document_element()->layout_node()->for_each_in_inclusive_subtree([&](auto const& layout_node) {
if (layout_node.display().is_none() || !layout_node.paintable() || !layout_node.paintable()->is_visible())
return TraversalDecision::Continue;
if (layout_node.is_block_container()) {
if (!builder.is_empty()) {
text_blocks.append({ builder.to_string_without_validation(), text_positions });