Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/NVDAObjects/IAccessible/ia2TextMozilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


def _getRawTextInfo(obj) -> Type[offsets.OffsetsTextInfo]:
if obj.TextInfo is NVDAObjectTextInfo:
return NVDAObjectTextInfo
return IA2TextTextInfo
if hasattr(obj, "IAccessibleTextObject"):
return IA2TextTextInfo
return NVDAObjectTextInfo


def _getEmbedded(obj, offset) -> typing.Optional[IAccessible]:
Expand Down
2 changes: 1 addition & 1 deletion source/NVDAObjects/IAccessible/ia2Web.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Ia2Web(IAccessible):
# The IAccessibleText implementation in web browsers exposes embedded object
# characters which need to be traversed to read the content. That isn't useful
# to users.
_shouldUseTextInfoForReading = False
TextInfo = NVDAObjects.NVDAObjectTextInfo

def isDescendantOf(self, obj: "NVDAObjects.NVDAObject") -> bool:
if obj.windowHandle != self.windowHandle:
Expand Down
6 changes: 0 additions & 6 deletions source/NVDAObjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,12 +1605,6 @@ def _get__hasNavigableText(self):
else:
return False

#: Whether the TextInfo should be used for the review cursor, the read current
#: line command, etc. This should be False where the TextInfo is only used
#: internally and doesn't provide text that is suitable for presentation to the
#: user; e.g. it includes raw embedded object characters.
_shouldUseTextInfoForReading: bool = True

def _get_hasIrrelevantLocation(self):
"""Returns whether the location of this object is irrelevant for mouse or magnification tracking or highlighting,
either because it is programatically hidden (State.INVISIBLE), off screen or the object has no location."""
Expand Down
42 changes: 17 additions & 25 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,15 @@ def script_toggleCurrentAppSleepMode(self, gesture):
def script_reportCurrentLine(self, gesture):
obj = api.getFocusObject()
treeInterceptor = obj.treeInterceptor
useTextInfo: bool = False
if (
isinstance(treeInterceptor, treeInterceptorHandler.DocumentTreeInterceptor)
and not treeInterceptor.passThrough
):
obj = treeInterceptor
useTextInfo = True
else:
useTextInfo = obj._shouldUseTextInfoForReading
if useTextInfo:
try:
info = obj.makeTextInfo(textInfos.POSITION_CARET)
except (NotImplementedError, RuntimeError):
info = obj.makeTextInfo(textInfos.POSITION_FIRST)
else:
info = NVDAObjectTextInfo(obj, textInfos.POSITION_FIRST)
try:
info = obj.makeTextInfo(textInfos.POSITION_CARET)
except (NotImplementedError, RuntimeError):
info = obj.makeTextInfo(textInfos.POSITION_FIRST)
info.expand(textInfos.UNIT_LINE)
scriptCount = getLastScriptRepeatCount()
if scriptCount == 0:
Expand Down Expand Up @@ -2792,35 +2785,34 @@ def _getNvdaObjWithAnnotationUnderCaret(self) -> Optional[NVDAObject]:
relation' in that range, and we don't yet have a way for the user to select which one to report.
For now, we minimise this risk by only reporting details at the current location.
"""
_isDebugLogCatEnabled = bool(config.conf["debugLog"]["annotations"])
try:
# Common cases use Caret Position: vbuf available or object supports text range
# Eg editable text, or regular web content
# Firefox and Chromium support this even in a button within a role=application.
caret: textInfos.TextInfo = api.getCaretPosition()
except RuntimeError:
log.debugWarning("Unable to get the caret position.", exc_info=True)
return None
caret.expand(textInfos.UNIT_CHARACTER)
objAtStart: NVDAObject = caret.NVDAObjectAtStart
_isDebugLogCatEnabled = bool(config.conf["debugLog"]["annotations"])
if _isDebugLogCatEnabled:
log.debug(f"Trying with nvdaObject : {objAtStart}")

if objAtStart.annotations:
else:
caret.expand(textInfos.UNIT_CHARACTER)
objAtStart: NVDAObject = caret.NVDAObjectAtStart
if _isDebugLogCatEnabled:
log.debug("NVDAObjectAtStart of caret has details")
return objAtStart
elif api.getFocusObject():
log.debug(f"Trying with nvdaObject : {objAtStart}")
if objAtStart.annotations:
if _isDebugLogCatEnabled:
log.debug("NVDAObjectAtStart of caret has details")
return objAtStart

focus: NVDAObject = api.getFocusObject()
if focus:
# If fetching from the caret position fails, try via the focus object
# This case is to support where there is no virtual buffer or text interface and a caret position can
# not be fetched.
# There may still be an object with focus that has details.
# There isn't a known test case for this, however there isn't a known downside to attempt this.
focus = api.getFocusObject()
if _isDebugLogCatEnabled:
log.debug(f"Trying focus object: {focus}")

if objAtStart.annotations:
if focus.annotations:
if _isDebugLogCatEnabled:
log.debug("focus object has details, able to proceed")
return focus
Expand Down
24 changes: 10 additions & 14 deletions source/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,18 @@ def getObjectPosition(obj: NVDAObject) -> tuple[textInfos.TextInfo, ScriptableOb
:param obj: the NVDAObject to review
:return: the TextInfo instance and the Scriptable object the TextInfo instance is referencing, or None on error.
"""
useTextInfo: bool = obj._shouldUseTextInfoForReading
if useTextInfo:
try:
pos = obj.makeTextInfo(textInfos.POSITION_CARET)
except (NotImplementedError, RuntimeError):
# No caret supported, try first position instead
try:
pos = obj.makeTextInfo(textInfos.POSITION_CARET)
pos = obj.makeTextInfo(textInfos.POSITION_FIRST)
except (NotImplementedError, RuntimeError):
# No caret supported, try first position instead
try:
pos = obj.makeTextInfo(textInfos.POSITION_FIRST)
except (NotImplementedError, RuntimeError):
log.debugWarning(
f"{obj.TextInfo} does not support POSITION_FIRST, falling back to NVDAObjectTextInfo",
)
# First position not supported either, return first position from a generic NVDAObjectTextInfo
useTextInfo = False
if not useTextInfo:
return NVDAObjectTextInfo(obj, textInfos.POSITION_FIRST), obj
log.debugWarning(
"%s does not support POSITION_FIRST, falling back to NVDAObjectTextInfo" % obj.TextInfo,
)
# First position not supported either, return first position from a generic NVDAObjectTextInfo
return NVDAObjectTextInfo(obj, textInfos.POSITION_FIRST), obj
return pos, pos.obj


Expand Down
3 changes: 2 additions & 1 deletion user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Changes

### Bug Fixes
* In focus mode in web browsers, it is now possible to review and spell the labels of controls when those labels are specifically provided for accessibility; e.g. via aria-label or aria-labelledby. (#15159, @jcsteh)
* In Mozilla Firefox, reporting annotation details now works correctly in focus mode on controls which are not editable text. (#20132, @jcsteh)

### Changes for Developers

Expand Down Expand Up @@ -93,7 +95,6 @@ The setting is disabled by default. (#20013, @LeonarddeR)
* Fixed NVDA freezing when navigating in JetBrains IDEs. (#16741, @christopherpross)
* Speech dictionary entries of type Whole word now correctly handle words containing Unicode combining marks (e.g. Hebrew niqqud, Arabic harakat). (#20013, @LeonarddeR)
* In particular, Whole word entries no longer incorrectly match inside larger words when those words contain combining marks.
* In focus mode in web browsers, it is now possible to review and spell the labels of controls when those labels are specifically provided for accessibility; e.g. via aria-label or aria-labelledby. (#15159, @jcsteh)

### Changes for Developers

Expand Down
Loading