[orca] Mouse Review: Do full tree dive to locate all document candidates at point



commit 31c118d7d6f2e3b1f3d11de0fc192a7e71d0188a
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Nov 20 17:28:55 2019 -0500

    Mouse Review: Do full tree dive to locate all document candidates at point
    
    Some web authoring makes it extremely unlikely that we'll get the correct
    object under the mouse pointer. Therefore do a full tree dive. There should
    only be object under the mouse pointer with presentable info.

 src/orca/scripts/web/script_utilities.py | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index ff05000ee..b68c18a63 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -4578,22 +4578,15 @@ class Utilities(script_utilities.Utilities):
         if coordType is None:
             coordType = pyatspi.DESKTOP_COORDS
 
-        if not (root and self.inDocumentContent(root)):
+        if not self.inDocumentContent(root):
             return super().descendantAtPoint(root, x, y, coordType)
 
-        if self.containsPoint(root, x, y, coordType):
-            return super().descendantAtPoint(root, x, y, coordType)
+        isMatch = lambda o: self.containsPoint(o, x, y, coordType)
+        candidates = self.findAllDescendants(root, isMatch)
 
-        # Authoring can cause user agents to expose containers with a bounding
-        # box that doesn't contain the child container at the specified point.
-        obj = root
-        for child in root:
-            if self.containsPoint(child, x, y, coordType):
-                obj = child
-                break
-        else:
-            child = root.queryComponent().getAccessibleAtPoint(x, y, coordType)
-            if child and self.containsPoint(child, x, y, coordType):
-                return child
+        isPresentable = lambda x: x and (x.name or self.hasPresentableText(x))
+        candidates = list(filter(isPresentable, candidates))
+        if len(candidates) == 1:
+            return candidates[0]
 
-        return super().descendantAtPoint(obj, x, y, coordType)
+        return super().descendantAtPoint(root, x, y, coordType)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]