[orca/gnome-3-22] Take possible margins/padding into account when looking for descendant at point



commit aa707d2f60ee9b7407353eba6145b6f7059608ea
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Sep 3 16:37:53 2016 -0400

    Take possible margins/padding into account when looking for descendant at point

 src/orca/script_utilities.py                       |   18 +++++++++++++-----
 .../scripts/toolkits/Gecko/script_utilities.py     |    4 ++--
 2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 384df4d..f9233fd 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -3408,13 +3408,22 @@ class Utilities:
 
         return table.nRows, table.nColumns
 
-    def containsPoint(self, obj, x, y, coordType):
+    def containsPoint(self, obj, x, y, coordType, margin=2):
         try:
             component = obj.queryComponent()
         except:
             return False
 
-        return component.contains(x, y, coordType)
+        if component.contains(x, y, coordType):
+            return True
+
+        x1, y1 = x + margin, y + margin
+        if component.contains(x1, y1, coordType):
+            msg = "INFO: %s contains (%i,%i); not (%i,%i)" % (obj, x1, y1, x, y)
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return True
+
+        return False
 
     def _boundsIncludeChildren(self, obj):
         if not obj:
@@ -3474,9 +3483,8 @@ class Utilities:
                     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)
-                    return cell
-
-                return None
+                    if cell:
+                        return cell
 
         for child in root:
             obj = self.descendantAtPoint(child, x, y, coordType)
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py 
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 07823ff..4c8ac91 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -51,8 +51,8 @@ class Utilities(web.Utilities):
 
         return super()._treatAsLeafNode(obj)
 
-    def containsPoint(self, obj, x, y, coordType):
-        if not super().containsPoint(obj, x, y, coordType):
+    def containsPoint(self, obj, x, y, coordType, margin=2):
+        if not super().containsPoint(obj, x, y, coordType, margin):
             return False
 
         roles = [pyatspi.ROLE_MENU, pyatspi.ROLE_TOOL_TIP]


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