[orca] Don't double-present name of widgets which descend from label element



commit 7d025ebfa61694fa969c78d1f24761fa0c1bddfa
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jun 14 15:04:57 2017 -0400

    Don't double-present name of widgets which descend from label element

 src/orca/scripts/web/script_utilities.py |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index e05a86c..becc6ed 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -58,6 +58,7 @@ class Utilities(script_utilities.Utilities):
         self._isTextBlockElement = {}
         self._isContentEditableWithEmbeddedObjects = {}
         self._isGridDescendant = {}
+        self._isLabelDescendant = {}
         self._isMenuDescendant = {}
         self._isToolBarDescendant = {}
         self._isLayoutOnly = {}
@@ -118,6 +119,7 @@ class Utilities(script_utilities.Utilities):
         self._isTextBlockElement = {}
         self._isContentEditableWithEmbeddedObjects = {}
         self._isGridDescendant = {}
+        self._isLabelDescendant = {}
         self._isMenuDescendant = {}
         self._isToolBarDescendant = {}
         self._isLayoutOnly = {}
@@ -2088,6 +2090,19 @@ class Utilities(script_utilities.Utilities):
         self._isGridDescendant[hash(obj)] = rv
         return rv
 
+    def isLabelDescendant(self, obj):
+        if not obj:
+            return False
+
+        rv = self._isLabelDescendant.get(hash(obj))
+        if rv is not None:
+            return rv
+
+        isLabel = lambda x: x and x.getRole() == pyatspi.ROLE_LABEL
+        rv = pyatspi.findAncestor(obj, isLabel) is not None
+        self._isLabelDescendant[hash(obj)] = rv
+        return rv
+
     def isMenuDescendant(self, obj):
         if not obj:
             return False
@@ -2276,6 +2291,20 @@ class Utilities(script_utilities.Utilities):
             if hash(acc) in targets:
                 return True
 
+        if not self.isTextBlockElement(obj):
+            return False
+
+        if not self.isLabelDescendant(obj):
+            return False
+
+        for acc, start, end, string in contents:
+            if not self.isLabelDescendant(acc) or self.isTextBlockElement(acc):
+                continue
+
+            ancestor = self.commonAncestor(acc, obj)
+            if ancestor and ancestor.getRole() == pyatspi.ROLE_LABEL:
+                return True
+
         return False
 
     def isAnchor(self, obj):


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