Skip to content

Commit ee6178b

Browse files
authored
Merge c319a50 into 96d59ec
2 parents 96d59ec + c319a50 commit ee6178b

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

source/NVDAObjects/IAccessible/chromium.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def _normalizeControlField(self, attrs):
6565
if attrs['role'] == controlTypes.Role.TOGGLEBUTTON and controlTypes.State.CHECKABLE in attrs['states']:
6666
# In Chromium, the checkable state is exposed erroneously on toggle buttons.
6767
attrs['states'].discard(controlTypes.State.CHECKABLE)
68+
69+
if (
70+
attrs['role'] == controlTypes.Role.GROUPING
71+
and attrs.get('IAccessible2::attribute_tag', "").lower() == "figure"):
72+
# Chromium doesn't expose the `<figure>` element as a figure.
73+
attrs['role'] = controlTypes.Role.FIGURE
6874
return attrs
6975

7076

@@ -154,6 +160,12 @@ def _get_states(self):
154160
return states
155161

156162

163+
class Figure(ia2Web.Ia2Web):
164+
def _get_role(self):
165+
return controlTypes.Role.FIGURE
166+
# return super()._get_role()
167+
168+
157169
def findExtraOverlayClasses(obj, clsList):
158170
"""Determine the most appropriate class(es) for Chromium objects.
159171
This works similarly to L{NVDAObjects.NVDAObject.findOverlayClasses} except that it never calls any other findOverlayClasses method.
@@ -164,5 +176,7 @@ def findExtraOverlayClasses(obj, clsList):
164176
clsList.append(ToggleButton)
165177
elif obj.role == controlTypes.Role.LIST and obj.IA2Attributes.get('tag') in ('ul', 'dl', 'ol'):
166178
clsList.append(PresentationalList)
179+
elif obj.role == controlTypes.Role.GROUPING and obj.IA2Attributes.get("tag", "").casefold() == "figure":
180+
clsList.append(Figure)
167181
ia2Web.findExtraOverlayClasses(obj, clsList,
168182
documentClass=Document)

source/virtualBuffers/gecko_ia2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,9 @@ def _searchableAttribsForNodeType(self,nodeType):
552552
elif nodeType == "figure":
553553
attrs = [
554554
{"Iaccessible::role": [oleacc.ROLE_SYSTEM_GROUPING]},
555-
{"IAccessible2::attribute_xml-roles": [VBufStorage_findMatch_word("figure")]}
555+
{"IAccessible2::attribute_xml-roles": [VBufStorage_findMatch_word("figure")]},
556+
# Needed so that navigation by figure works for HTML figures in Chromium
557+
{"IAccessible2::attribute_tag": self._searchableTagValues(["figure"])}
556558
]
557559
else:
558560
return None

0 commit comments

Comments
 (0)