[orca] Chromium: Add means to identify find-in-page widgets



commit aaa13fbf9d93532d821335e1d530063b07e4bde6
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Jul 23 10:55:13 2019 -0400

    Chromium: Add means to identify find-in-page widgets

 .../scripts/toolkits/Chromium/script_utilities.py  | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
---
diff --git a/src/orca/scripts/toolkits/Chromium/script_utilities.py 
b/src/orca/scripts/toolkits/Chromium/script_utilities.py
index a753af831..bb15a1267 100644
--- a/src/orca/scripts/toolkits/Chromium/script_utilities.py
+++ b/src/orca/scripts/toolkits/Chromium/script_utilities.py
@@ -354,3 +354,36 @@ class Utilities(web.Utilities):
             return False
 
         return super().handleAsLiveRegion(event)
+
+    def getFindResultsCount(self, root):
+        if not root:
+            return ""
+
+        isMatch = lambda x: x and x.getRole() == pyatspi.ROLE_STATUS_BAR \
+                  and len(re.findall("\d+", x.name)) == 2
+        statusBars = self.findAllDescendants(root, isMatch)
+        if len(statusBars) == 1:
+            return statusBars[0].name
+
+        return ""
+
+    def inFindToolbar(self, obj=None):
+        if not obj:
+            obj = orca_state.locusOfFocus
+
+        if not obj or self.inDocumentContent(obj):
+            return False
+
+        if obj.getRole() not in [pyatspi.ROLE_ENTRY, pyatspi.ROLE_PUSH_BUTTON]:
+            return False
+
+        isDialog = lambda x: x and x.getRole() == pyatspi.ROLE_DIALOG
+        if not pyatspi.findAncestor(obj, isDialog):
+            return False
+
+        result = self.getFindResultsCount(obj.parent)
+        if result:
+            msg = "CHROMIUM: %s believed to be find-in-page widget (%s)" % (obj, result)
+            debug.println(debug.LEVEL_INFO, msg, True)
+
+        return bool(result)


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