[orca] Chromium: Ask the document for the descendant at point before tree diving



commit df742aaa5c949477d7a8265e56004f2f319191f1
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Feb 4 23:24:00 2020 -0500

    Chromium: Ask the document for the descendant at point before tree diving
    
    In some instances, Chromium will return the deepest descendant at point
    for the document. And in other cases it at least gets us closer to the
    right object. This is preferable to doing a non-performant tree dive.

 .../scripts/toolkits/Chromium/script_utilities.py  | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index f2706c6a5..3cc5685a1 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -474,7 +474,34 @@ class Utilities(web.Utilities):
 
         return super().findAllDescendants(root, includeIf, excludeIf)
 
+    def _accessibleAtPoint(self, root, x, y, coordType=None):
+        if self.isHidden(root):
+            return None
+
+        try:
+            component = root.queryComponent()
+        except:
+            msg = "CHROMIUM: Exception querying component of %s" % root
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return None
+
+        result = component.getAccessibleAtPoint(x, y, coordType)
+        msg = "CHROMIUM: %s is descendant of %s at (%i, %i)" % (result, root, x, y)
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return result
+
     def descendantAtPoint(self, root, x, y, coordType=None):
+        if coordType is None:
+            coordType = pyatspi.DESKTOP_COORDS
+
+        result = None
+        if self.isDocument(root):
+            result = self._accessibleAtPoint(root, x, y, coordType)
+            if self.isTextBlockElement(result) and not self.isStaticTextLeaf(result):
+                child = self._accessibleAtPoint(result, x, y, coordType)
+                result = child or result
+
+        root = result or root
         result = super().descendantAtPoint(root, x, y, coordType)
         if self.isListItemMarker(result) or self.isStaticTextLeaf(result):
             return result.parent


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