[orca/gnome-3-36] Fall back on xml-roles object attribute when identifying comments



commit f226dc566da1f94d64f343590743447f799f6f33
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Feb 25 20:41:42 2020 +0100

    Fall back on xml-roles object attribute when identifying comments

 src/orca/generator.py                    | 4 ++++
 src/orca/script_utilities.py             | 3 +++
 src/orca/scripts/web/script_utilities.py | 9 +++++++++
 3 files changed, 16 insertions(+)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 1d47bec47..3d64e0c0f 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -1229,6 +1229,8 @@ class Generator:
             return pyatspi.ROLE_STATIC
         if self._script.utilities.isBlockquote(obj):
             return pyatspi.ROLE_BLOCK_QUOTE
+        if self._script.utilities.isComment(obj):
+            return pyatspi.ROLE_COMMENT
         if self._script.utilities.isContentDeletion(obj):
             return 'ROLE_CONTENT_DELETION'
         if self._script.utilities.isContentInsertion(obj):
@@ -1382,6 +1384,8 @@ class Generator:
                 return object_properties.ROLE_LANDMARK_SEARCH
             if self._script.utilities.isLandmarkForm(obj):
                 role = pyatspi.ROLE_FORM
+        elif self._script.utilities.isComment(obj):
+            role = pyatspi.ROLE_COMMENT
 
         if not isinstance(role, (pyatspi.Role, Atspi.Role)):
             try:
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index d6f27ae64..26582cc5b 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -768,6 +768,9 @@ class Utilities:
 
         return False
 
+    def isComment(self, obj):
+        return False
+
     def isContentDeletion(self, obj):
         return False
 
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 306cb08d2..854f8ef2e 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2095,6 +2095,15 @@ class Utilities(script_utilities.Utilities):
 
         return self._getTag(obj) == 'blockquote'
 
+    def isComment(self, obj):
+        if not (obj and self.inDocumentContent(obj)):
+            return super().isComment(obj)
+
+        if obj.getRole() == pyatspi.ROLE_COMMENT:
+            return True
+
+        return 'comment' in self._getXMLRoles(obj)
+
     def isContentDeletion(self, obj):
         if not (obj and self.inDocumentContent(obj)):
             return super().isContentDeletion(obj)


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