Allow browse mode's native selection mode in Chromium-based browsers that can support it.#17838
Conversation
…ased browsers where supported (Chromium 134 and newer). Also try clearing the selection and handle extra errors when first enabling to ensure native selection mode is fully supported.
|
Thanks @michaelDCurran . This is amazing! I've reviewed this PR and tested it in Thorium EPUB reader, and when this is merged we can use a new feature to select text and create bookmarks with the selected text as the bookmark label, and maybe also annotations. |
| self.clearAppSelection() | ||
| self.updateAppSelection() | ||
| except NotImplementedError: | ||
| except (NotImplementedError, COMError): |
There was a problem hiding this comment.
| except (NotImplementedError, COMError): | |
| except (NotImplementedError, COMError): |
What about adding an explanatiry ui.message here? An exception can happen if we try to select all pressing control+aand the document contain elements inside and outside a frame, like in Thorium Reader.
Traceback (most recent call last):
File "scriptHandler.py", line 300, in executeScript
script(gesture)
File "cursorManager.py", line 474, in script_selectLine_forward
self._selectionMovementScriptHelper(unit=textInfos.UNIT_LINE, direction=1)
File "cursorManager.py", line 458, in _selectionMovementScriptHelper
self.selection = newInfo
^^^^^^^^^^^^^^
File "browseMode.py", line 1750, in _set_selection
super(BrowseModeDocumentTreeInterceptor, self)._set_selection(info)
File "cursorManager.py", line 132, in _set_selection
info.updateSelection()
File "textInfos\offsets.py", line 747, in updateSelection
return self._setSelectionOffsets(self._startOffset, self._endOffset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "virtualBuffers\gecko_ia2.py", line 55, in _setSelectionOffsets
self.obj.updateAppSelection()
File "virtualBuffers\gecko_ia2.py", line 723, in updateAppSelection
self._getEndSelection(ia2Sel, selFields)
File "virtualBuffers\gecko_ia2.py", line 691, in _getEndSelection
raise NotImplementedError("No ia2TextEndOffset in any field")
NotImplementedError: No ia2TextEndOffset in any field
| self.updateAppSelection() | ||
| except NotImplementedError: | ||
| except (NotImplementedError, COMError): | ||
| log.debugWarning("updateAppSelection failed", exc_info=True) |
There was a problem hiding this comment.
| log.debugWarning("updateAppSelection failed", exc_info=True) | |
| # Translators: Message presented when update native selection fails in Browse Mode. | |
| ui.message(_("Update native selection has failed, try to adjust the selection range")) | |
| log.debugWarning("updateAppSelection failed", exc_info=True) |
|
hello everyone. I have a long time qustion. can this feature only be enabled using nvda shift f10? or can it also be enabled with an option in settings? thanks |
|
This PR specifically just focuses on extending the current support from Firefox to now also Chromium. |
|
When this is merged, I can open an issue, if needed requesting better handling of reporting selection failures. |
nvdaes
left a comment
There was a problem hiding this comment.
Given the scope of this PR, for me it's OK.
|
I'm using Beta1 of NVDA 2025.1, and occasionally I get "Native selection mode unsupported in this document" when attempting to enable, however closing and reopening the browser magically allows me to enable native selection again: |
Link to issue number:
Fixes #17591
Summary of the issue:
In #15830, NVDA browse mode gained a new native Selection Mode (toggled on with
NVDA+shift+f10) which caused the browser's underlying native selection (DOM selection) to mirror the browse mode virtual selection. Although this worked well in Firefox, it had to be forcefully disabled for Chromium-based browsers as there were major bugs in Chromiums implementation of IAccessibleTextSelectionContainer.As of Chromium 134 stable, all known bugs have been addressed, thus NVDA should allow native selection mode in Chromium-based browsers where possible.
Description of user facing changes
NVDA browse mode's native selection mode (
NVDA+shift+f10) can now be enabled in any browser based on Chromium 134 or newer.Description of development approach
Testing strategy:
Known issues with pull request:
None known.
Code Review Checklist:
@coderabbitai summary