[orca] Chromium: Fall back on hierarchy when status bar doesn't id the find dialog



commit aecbd14cd5a5081127ac2bff313e49b3800fb0e2
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Aug 1 13:37:03 2019 -0400

    Chromium: Fall back on hierarchy when status bar doesn't id the find dialog

 .../scripts/toolkits/Chromium/script_utilities.py  | 27 +++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index c6772dc9d..b81eac102 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -387,8 +387,33 @@ class Utilities(web.Utilities):
         if result:
             msg = "CHROMIUM: %s believed to be find-in-page dialog (%s)" % (obj, result)
             debug.println(debug.LEVEL_INFO, msg, True)
+            return True
+
+        # When there are no results due to the absence of a search term, the status
+        # bar lacks a name. When there are no results due to lack of match, the name
+        # of the status bar is "No results" (presumably localized). Therefore fall
+        # back on the widgets. TODO: This would be far easier if Chromium gave us an
+        # object attribute we could look for....
+
+        isEntry = lambda x: x.getRole() == pyatspi.ROLE_ENTRY
+        if len(self.findAllDescendants(obj, isEntry)) != 1:
+            msg = "CHROMIUM: %s not believed to be find-in-page dialog (entry count)" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
 
-        return bool(result)
+        isButton = lambda x: x.getRole() == pyatspi.ROLE_PUSH_BUTTON
+        if len(self.findAllDescendants(obj, isButton)) != 3:
+            msg = "CHROMIUM: %s not believed to be find-in-page dialog (button count)" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+
+        isSeparator = lambda x: x.getRole() == pyatspi.ROLE_SEPARATOR
+        if len(self.findAllDescendants(obj, isSeparator)) != 1:
+            msg = "CHROMIUM: %s not believed to be find-in-page dialog (separator count)" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+
+        msg = "CHROMIUM: %s believed to be find-in-page dialog (accessibility tree)" % obj
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return True
 
     def inFindToolbar(self, obj=None):
         if not obj:


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