[orca] Improve braille presentation of new Firefox location input



commit 51d71ce45eb7612e6425f90ecb8343f904676f45
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jul 31 16:59:57 2019 -0400

    Improve braille presentation of new Firefox location input

 src/orca/script_utilities.py                       |  3 ++
 .../scripts/toolkits/Gecko/script_utilities.py     | 32 ++++++++++++++++++++++
 src/orca/scripts/web/braille_generator.py          |  2 ++
 3 files changed, 37 insertions(+)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 6d0a0d8ec..f05cf9c95 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4029,6 +4029,9 @@ class Utilities:
 
         return obj.getRole() not in roles
 
+    def treatAsEntry(self, obj):
+        return False
+
     def _treatAsLeafNode(self, obj):
         if not obj or self.isDead(obj):
             return False
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py 
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 7bc286105..07f34da23 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -180,3 +180,35 @@ class Utilities(web.Utilities):
         # We apparently having missing events from Gecko requiring
         # we update the cache. This is not performant. :(
         return super().canBeActiveWindow(window, True)
+
+    def treatAsEntry(self, obj):
+        if not obj or self.inDocumentContent(obj):
+            return super().treatAsEntry(obj)
+
+        # Firefox seems to have turned its accessible location widget into a
+        # childless editable combobox.
+
+        try:
+            role = obj.getRole()
+            state = obj.getState()
+            childCount = obj.childCount
+        except:
+            msg = "GECKO: Exception getting role, state, and child count for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if role != pyatspi.ROLE_COMBO_BOX:
+            return False
+
+        if not state.contains(pyatspi.STATE_FOCUSED):
+            return False
+
+        if childCount:
+            return False
+
+        if not "EditableText" in pyatspi.listInterfaces(obj):
+            return False
+
+        msg = "GECKO: Treating %s as entry" % obj
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return True
diff --git a/src/orca/scripts/web/braille_generator.py b/src/orca/scripts/web/braille_generator.py
index 7da7df54d..78e2aadef 100644
--- a/src/orca/scripts/web/braille_generator.py
+++ b/src/orca/scripts/web/braille_generator.py
@@ -198,6 +198,8 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
             oldRole = self._overrideRole(pyatspi.ROLE_STATIC, args)
         elif self._script.utilities.treatAsDiv(obj, offset=args.get('startOffset')):
             oldRole = self._overrideRole(pyatspi.ROLE_SECTION, args)
+        elif self._script.utilities.treatAsEntry(obj):
+            oldRole = self._overrideRole(pyatspi.ROLE_ENTRY, args)
 
         if obj.getRole() == pyatspi.ROLE_MENU_ITEM:
             comboBox = self._script.utilities.ancestorWithRole(


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