[orca] Update getChildAtOffset() to use hypertext.getLink()



commit cdc01adb6a1c373c2dd1d81ea1b2d984631295b7
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Apr 23 02:21:20 2019 -0400

    Update getChildAtOffset() to use hypertext.getLink()
    
    This is the correct way to do things and seems to (now) work for Gecko.
    In addition, using hypertext.getLink() is needed for Chromium because
    it exposes more children than are hyperlink objects. If this introduces
    a regression, we can restore the original behavior, but just for Gecko.

 src/orca/scripts/web/script_utilities.py | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 78b04dbec..e5633907d 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -3464,15 +3464,25 @@ class Utilities(script_utilities.Utilities):
         return hypertext.getLinkIndex(offset)
 
     def getChildAtOffset(self, obj, offset):
-        index = self.getChildIndex(obj, offset)
-        if index == -1:
-            return None
-
         try:
-            child = obj[index]
+            hypertext = obj.queryHypertext()
+        except NotImplementedError:
+            msg = "WEB: %s does not implement the hypertext interface" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return None
         except:
+            msg = "WEB: Exception querying hypertext interface for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
             return None
 
+        index = hypertext.getLinkIndex(offset)
+        if index == -1:
+            return None
+
+        hyperlink = hypertext.getLink(index)
+        child = hyperlink.getObject(0)
+        msg = "WEB: Hyperlink object at index %i for %s is %s" % (index, obj, child)
+        debug.println(debug.LEVEL_INFO, msg, True)
         return child
 
     def getError(self, obj):
@@ -3550,8 +3560,6 @@ class Utilities(script_utilities.Utilities):
 
     def _canHaveCaretContext(self, obj):
         if not obj:
-            msg = "WEB: Null object cannot have caret context"
-            debug.println(debug.LEVEL_INFO, msg, True)
             return False
         if self.isDead(obj):
             msg = "WEB: Dead object cannot have caret context %s" % obj


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