diff --git a/Tests/LibWeb/Text/expected/DOM/Elements-from-point-2.txt b/Tests/LibWeb/Text/expected/DOM/Elements-from-point-2.txt new file mode 100644 index 0000000000..6054def21f --- /dev/null +++ b/Tests/LibWeb/Text/expected/DOM/Elements-from-point-2.txt @@ -0,0 +1,4 @@ +hello
+
+
+ diff --git a/Tests/LibWeb/Text/expected/DOM/Elements-from-point-3.txt b/Tests/LibWeb/Text/expected/DOM/Elements-from-point-3.txt new file mode 100644 index 0000000000..c894e27d07 --- /dev/null +++ b/Tests/LibWeb/Text/expected/DOM/Elements-from-point-3.txt @@ -0,0 +1 @@ + Some text Elements at point 30, 20: p < div < body < html diff --git a/Tests/LibWeb/Text/expected/DOM/Elements-from-point.txt b/Tests/LibWeb/Text/expected/DOM/Elements-from-point.txt index 1fcbfb47c4..c0566d3411 100644 --- a/Tests/LibWeb/Text/expected/DOM/Elements-from-point.txt +++ b/Tests/LibWeb/Text/expected/DOM/Elements-from-point.txt @@ -3,11 +3,9 @@ Coordinates outside the viewport return empty array: true == Elements at (500, 10) ==
-== FIXME: Elements at (550, 60) == +== Elements at (550, 60) ==
-
-
 
-
+
 
diff --git a/Tests/LibWeb/Text/input/DOM/Elements-from-point-2.html b/Tests/LibWeb/Text/input/DOM/Elements-from-point-2.html
new file mode 100644
index 0000000000..761bdb3f5d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/DOM/Elements-from-point-2.html
@@ -0,0 +1,37 @@
+
+
+
+
+
hello
+ + diff --git a/Tests/LibWeb/Text/input/DOM/Elements-from-point-3.html b/Tests/LibWeb/Text/input/DOM/Elements-from-point-3.html new file mode 100644 index 0000000000..8f4d2a80a0 --- /dev/null +++ b/Tests/LibWeb/Text/input/DOM/Elements-from-point-3.html @@ -0,0 +1,18 @@ +
+

Some text

+
+

Elements at point 30, 20:

+
+ + diff --git a/Tests/LibWeb/Text/input/DOM/Elements-from-point.html b/Tests/LibWeb/Text/input/DOM/Elements-from-point.html index 5a9b70960a..d5c6cac2bc 100644 --- a/Tests/LibWeb/Text/input/DOM/Elements-from-point.html +++ b/Tests/LibWeb/Text/input/DOM/Elements-from-point.html @@ -32,15 +32,9 @@ for (let elem of document.elementsFromPoint(500, 10)) { printElement(elem); } - println("== FIXME: Elements at (550, 60) ==") + println("== Elements at (550, 60) ==") for (let elem of document.elementsFromPoint(550, 60)) { printElement(elem); } - // FIXME: 550, 60 is supposed to print the following, but the algorithm is wrong. - //
- //
- //
-        // 
-        // 
     });
 
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 3470eba8f5..035c5c923c 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -3829,16 +3829,12 @@ Vector> 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.
-    // FIXME: Paintable box tree order is not the same as paint order. We need a helper to traverse the paint tree in
-    //        paint order with a custom callback.
     if (auto const* paintable_box = this->paintable_box(); paintable_box) {
-        paintable_box->for_each_in_inclusive_subtree_of_type([&](auto& paintable_box) {
-            if (auto result = paintable_box.hit_test(position, Painting::HitTestType::Exact); result.has_value()) {
-                if (auto* dom_node = result->dom_node(); dom_node && dom_node->is_element())
-                    sequence.append(*static_cast(dom_node));
-                return Painting::TraversalDecision::Continue;
-            }
-            return Painting::TraversalDecision::SkipChildrenAndContinue;
+        (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())
+                sequence.append(*static_cast(dom_node));
+            return Painting::TraversalDecision::Continue;
         });
     }