[orca] Treat menu and toolbar descendants as focus mode widgets



commit 4acd3f4c9e1b19f7a8489dff2e0e6342bda9b751
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Aug 6 12:59:34 2016 -0400

    Treat menu and toolbar descendants as focus mode widgets

 src/orca/scripts/web/script_utilities.py |   34 +++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index ea7dce8..96ed553 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -54,6 +54,8 @@ class Utilities(script_utilities.Utilities):
         self._inTopLevelWebApp = {}
         self._isTextBlockElement = {}
         self._isGridDescendant = {}
+        self._isMenuDescendant = {}
+        self._isToolBarDescendant = {}
         self._isLayoutOnly = {}
         self._isMath = {}
         self._mathNestingLevel = {}
@@ -108,6 +110,8 @@ class Utilities(script_utilities.Utilities):
         self._inTopLevelWebApp = {}
         self._isTextBlockElement = {}
         self._isGridDescendant = {}
+        self._isMenuDescendant = {}
+        self._isToolBarDescendant = {}
         self._isLayoutOnly = {}
         self._isMath = {}
         self._mathNestingLevel = {}
@@ -1484,7 +1488,9 @@ class Utilities(script_utilities.Utilities):
            and not self.isTextBlockElement(obj):
             return True
 
-        if self.isGridDescendant(obj):
+        if self.isGridDescendant(obj) \
+           or self.isMenuDescendant(obj) \
+           or self.isToolBarDescendant(obj):
             return True
 
         return False
@@ -1941,6 +1947,32 @@ class Utilities(script_utilities.Utilities):
         self._isGridDescendant[hash(obj)] = rv
         return rv
 
+    def isMenuDescendant(self, obj):
+        if not obj:
+            return False
+
+        rv = self._isMenuDescendant.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        isMenu = lambda x: x and x.getRole() == pyatspi.ROLE_MENU
+        rv = pyatspi.findAncestor(obj, isMenu) is not None
+        self._isMenuDescendant[hash(obj)] = rv
+        return rv
+
+    def isToolBarDescendant(self, obj):
+        if not obj:
+            return False
+
+        rv = self._isToolBarDescendant.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        isMenu = lambda x: x and x.getRole() == pyatspi.ROLE_TOOL_BAR
+        rv = pyatspi.findAncestor(obj, isMenu) is not None
+        self._isToolBarDescendant[hash(obj)] = rv
+        return rv
+
     def isLayoutOnly(self, obj):
         if not obj:
             return False


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