Skip to content

Commit

Permalink
Contenteditable table headers (#15977)
Browse files Browse the repository at this point in the history
Fixes #14113 

Summary of the issue:
When navigating tables in contenteditable HTML elements in focus mode, table row and column headers are not reported.

Description of user facing changes
Table row and column headers are now reported when navigating tables in contenteditable HTML elements in focus mode.

Description of development approach
Added appropriate fields to the `TextInfos.ControlField` returned by `CompoundTextInfo._getControlFieldForObject`. Also added special case handling for Chromium, which erroneously reports heder cells as being their own headers.
  • Loading branch information
SaschaCowley authored Feb 7, 2024
1 parent c8d9c37 commit 65ddfb6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 17 additions & 2 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2006-2023 NV Access Limited, Babbage B.V., Cyrille Bougot
# Copyright (C) 2006-2024 NV Access Limited, Babbage B.V., Cyrille Bougot
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

Expand Down Expand Up @@ -1348,8 +1348,23 @@ def _tableHeaderTextHelper(self, axis):
# Each header must be fetched from the headers array once and only once,
# as it gets released when it gets garbage collected.
for i in range(nHeaders):
header = headers[i]
try:
text = headers[i].QueryInterface(IA2.IAccessible2).accName(0)
headerIA2Ptr = header.QueryInterface(IA2.IAccessible2)
except COMError:
log.debugWarning("could not get IAccessible2 pointer for table header", exc_info=True)
continue
# Chromium exposes cells as their own headers, so exclude cells with the same `Iaccessible2::uniqueID`.
if self.IA2UniqueID is not None: # No point checking if we don't have this cell's UID
try:
headerUniqueID = headerIA2Ptr.uniqueID
except COMError:
log.debugWarning("could not get IAccessible2::uniqueID to use as headerUniqueID", exc_info=True)
headerUniqueID = None
if self.IA2UniqueID == headerUniqueID:
continue
try:
text = headerIA2Ptr.accName(0)
except COMError:
continue
if not text:
Expand Down
5 changes: 4 additions & 1 deletion source/compoundDocuments.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# A part of NonVisual Desktop Access (NVDA)
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.
# Copyright (C) 2010-2022 NV Access Limited, Bram Duvigneau
# Copyright (C) 2010-2024 NV Access Limited, Bram Duvigneau

from typing import (
Optional,
Dict,
Expand Down Expand Up @@ -172,6 +173,8 @@ def _getControlFieldForObject(self, obj: NVDAObject, ignoreEditableText=True):
field["table-id"] = 1 # FIXME
field["table-rownumber"] = obj.rowNumber
field["table-columnnumber"] = obj.columnNumber
field["table-rowheadertext"] = obj.rowHeaderText
field["table-columnheadertext"] = obj.columnHeaderText
# Row/column span is not supported by all implementations (e.g. LibreOffice)
try:
field['table-rowsspanned']=obj.rowSpan
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ What's New in NVDA
= 2024.2 =

== New Features ==
- Reporting row and column headers is now supported in contenteditable HTML elements. (#14113)
- In Windows 11, NVDA will announce alerts from voice typing and suggested actions including the top suggestion when copying data such as phone numbers to the clipboard (Windows 11 2022 Update and later). (#16009, @josephsl)
- Added support for the BrailleEdgeS2 braille device. (#16033)
-
Expand Down

0 comments on commit 65ddfb6

Please sign in to comment.