[orca] Treat headings as paragraphs for the purpose of structural navigation



commit 7f9d23db2efe2981bc6bf848f5a4f90d4a9f40e7
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Aug 14 10:42:57 2019 -0400

    Treat headings as paragraphs for the purpose of structural navigation
    
    This change was made so that users don't miss out on topic/content
    changes while navigating by paragraphs. This solution has been chosen
    over trying to guess the associated heading because we cannot guarantee
    that a given heading/title is associated with a given paragraph. Giving
    the wrong context is arguably worse than giving no context at all.

 src/orca/structural_navigation.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index ace2d4735..24819b70d 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -2568,8 +2568,12 @@ class StructuralNavigation:
           the criteria (e.g. the level of a heading).
         """
 
-        role = [pyatspi.ROLE_PARAGRAPH]
-        return MatchCriteria(collection, roles=role, applyPredicate=True)
+        # Treat headings as paragraphs so that the user doesn't miss context when
+        # the topic of the paragraph changes. Besides, a heading is paragraphy.
+
+        role = [pyatspi.ROLE_PARAGRAPH, pyatspi.ROLE_HEADING]
+        roleMatch = collection.MATCH_ANY
+        return MatchCriteria(collection, roles=role, matchRoles=roleMatch, applyPredicate=True)
 
     def _paragraphPredicate(self, obj, arg=None):
         """The predicate to be used for verifying that the object
@@ -2581,8 +2585,15 @@ class StructuralNavigation:
           the criteria (e.g. the level of a heading).
         """
 
+        if not obj:
+            return False
+
+        role = obj.getRole()
+        if role == pyatspi.ROLE_HEADING:
+            return True
+
         isMatch = False
-        if obj and obj.getRole() == pyatspi.ROLE_PARAGRAPH:
+        if role == pyatspi.ROLE_PARAGRAPH:
             try:
                 text = obj.queryText()
                 # We're choosing 3 characters as the minimum because some


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