[orca] Refine logic related to inclusion/exclusion of description



commit aa09296e0cd4122ac0ca8ef77940596d7ba35bdd
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Aug 26 18:32:30 2022 +0200

    Refine logic related to inclusion/exclusion of description
    
    Orca attempts to avoid presentation of descriptions which are the
    same as the name/label. The logic was that if we had a description
    and it wasn't the same text as either the name or the label, present
    it; otherwise don't. That makes sense in the case where both the name
    and label are to be presented. It also makes sense for web content,
    where any "label" is exposed as the accessible name. However, for
    widgets outside of web content for which we present the label (if
    found) and the name (if there is no label), we can incorrectly filter
    out a description due to being equal to the (not presented) name.
    
    This commit refines the logic as follows:
    * If we're presenting both label and name, the description must be
      different from both.
    * If we're presenting label or name and we have a label, the description
      must be different from the label (but can be the same as the name).
    * If we're presenting label or name and only have a name, the description
      must be different from the name.
    
    Fixes issue #218.

 src/orca/generator.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index e6fce5016..ad18b3a99 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -482,9 +482,24 @@ class Generator:
 
         result = []
         if description:
+            try:
+                tokens = self._script.formatting[self._mode][role][args.get('formatType')].split()
+                isLabelAndName = 'labelAndName' in tokens
+                isLabelOrName = 'labelOrName' in tokens
+            except:
+                isLabelAndName = False
+                isLabelOrName = False
+
             label = self._script.utilities.displayedLabel(obj) or ""
             desc = description.lower()
-            if not (desc in name.lower() or desc in label.lower()):
+            canUse = True
+            if isLabelAndName:
+                canUse = not desc in name.lower() and not desc in label.lower()
+            elif isLabelOrName and label:
+                canUse = not desc in label.lower()
+            elif isLabelOrName and name:
+                canUse = not desc in name.lower()
+            if canUse:
                 result.append(obj.description)
 
         if not result:


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