From 1ec3b1c6dfaa5eb364145170e4951172a47e4e11 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Fri, 4 Jul 2025 12:56:37 +0200 Subject: [PATCH] LibWeb: Simplify Document::elements_from_point() We should not need to check if the result of a hit test is actually visible for hit testing, because if it wasn't, it should not have been returned from PaintableBox::hit_test() in the first place. --- Libraries/LibWeb/DOM/Document.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 58def85fc79..237a21063f5 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -5660,11 +5660,10 @@ GC::RootVector> Document::elements_from_point(double x, double // 3. For each box in the viewport, in paint order, starting with the topmost box, that would be a target for // hit testing at coordinates x,y even if nothing would be overlapping it, when applying the transforms that // apply to the descendants of the viewport, append the associated element to sequence. - if (auto const* paintable_box = this->paintable_box(); paintable_box) { + if (auto const* paintable_box = this->paintable_box()) { (void)paintable_box->hit_test(position, Painting::HitTestType::Exact, [&](Painting::HitTestResult result) { - auto* dom_node = result.dom_node(); - if (dom_node && dom_node->is_element() && result.paintable->visible_for_hit_testing()) - sequence.append(*static_cast(dom_node)); + if (auto* element = as_if(result.dom_node())) + sequence.append(*element); return TraversalDecision::Continue; }); }