[orca] Make a general script utility for accessibleAtPoint()



commit 499e70b713cfab3d694be90dfd4c2dbc94542f82
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue May 19 20:02:48 2020 -0400

    Make a general script utility for accessibleAtPoint()

 src/orca/script_utilities.py                       | 40 ++++++++++++----------
 .../scripts/toolkits/Chromium/script_utilities.py  | 23 ++++---------
 2 files changed, 28 insertions(+), 35 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 53190ba64..125612b6e 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4369,6 +4369,22 @@ class Utilities:
 
         return role in roles
 
+    def accessibleAtPoint(self, root, x, y, coordType=None):
+        if self.isHidden(root):
+            return None
+
+        try:
+            component = root.queryComponent()
+        except:
+            msg = "INFO: Exception querying component of %s" % root
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return None
+
+        result = component.getAccessibleAtPoint(x, y, coordType)
+        msg = "INFO: %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 not root:
             return None
@@ -4386,24 +4402,12 @@ class Utilities:
             return None
 
         if "Table" in pyatspi.listInterfaces(root):
-            try:
-                component = root.queryComponent()
-            except:
-                msg = "ERROR: Exception querying component of %s" % root
-                debug.println(debug.LEVEL_INFO, msg, True)
-                child = None
-            else:
-                child = component.getAccessibleAtPoint(x, y, coordType)
-                msg = "INFO: %s is at (%s, %s) in %s" % (child, x, y, root)
-                debug.println(debug.LEVEL_INFO, msg, True)
-
-                if child and child != root:
-                    cell = self.descendantAtPoint(child, x, y, coordType)
-                    msg = "INFO: %s is at (%s, %s) in %s" % (cell, x, y, child)
-                    debug.println(debug.LEVEL_INFO, msg, True)
-                    if cell:
-                        return cell
-                    return child
+            child = self.accessibleAtPoint(root, x, y, coordType)
+            if child and child != root:
+                cell = self.descendantAtPoint(child, x, y, coordType)
+                if cell:
+                    return cell
+                return child
 
         candidates_showing = []
         candidates = []
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index fe37b3f63..50140f655 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -507,28 +507,17 @@ 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)
+    def accessibleAtPoint(self, root, x, y, coordType=None):
+        result = super().accessibleAtPoint(root, x, y, coordType)
 
         # Chromium cannot do a hit test of web content synchronously. So what it
         # does is return a guess, then fire off an async hit test. The next time
         # one calls it, Chromium returns the previous async hit test result if
         # the point is still within its bounds. Therefore, we need to call
-        # getAccessibleAtPoint() twice to be safe.
-        result = component.getAccessibleAtPoint(x, y, coordType)
-
-        msg = "CHROMIUM: %s is descendant of %s at (%i, %i)" % (result, root, x, y)
+        # accessibleAtPoint() twice to be safe.
+        msg = "CHROMIUM: Getting accessibleAtPoint again due to async hit test result."
         debug.println(debug.LEVEL_INFO, msg, True)
+        result = super().accessibleAtPoint(root, x, y, coordType)
         return result
 
     def descendantAtPoint(self, root, x, y, coordType=None):
@@ -537,7 +526,7 @@ class Utilities(web.Utilities):
 
         result = None
         if self.isDocument(root):
-            result = self._accessibleAtPoint(root, x, y, coordType)
+            result = self.accessibleAtPoint(root, x, y, coordType)
 
         root = result or root
         result = super().descendantAtPoint(root, x, y, coordType)


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