Skip to content

Ignore hidden text in richEdit controls accessed with ITextDocument#13618

Merged
feerrenrut merged 6 commits into
masterfrom
ignoreRichEditHiddenText
May 6, 2022
Merged

Ignore hidden text in richEdit controls accessed with ITextDocument#13618
feerrenrut merged 6 commits into
masterfrom
ignoreRichEditHiddenText

Conversation

@michaelDCurran

@michaelDCurran michaelDCurran commented Apr 20, 2022

Copy link
Copy Markdown
Member

Link to issue number:

None.

Summary of the issue:

Currently if NVDA accesses a RichEdit control with the ITextDocument objectinterface, it does not ignore hidden text. I.e. hidden text is both read, and can be navigated through with the review cursor.
An example of this is the hidden text included at the start of hyperlinks in RichEdit controls. Usually looking something like:

HYPERLINK "<URL>"

So therefore for a link for NV access the user would here:

link HYPERLINK "https://www.nvaccess.org" NV access out of link

Where as they should really just hear:

link NV Access out of link

Description of how this pull request fixes the issue:

  1. Remove the need for the user to turn on the Fetch Formatting after the cursor option in NVDA's document formatting settings, in order to fetch all formatting in a range of text. In Windows XP this was extremely slow. It seems these days it is much faster now. We specifically need this to correctly split on the boundaries of hidden text, and also to report the start and end of links within a line.
  2. If a particular format run is marked as hidden, then do not produce a formatField or text for that run. In other words, skip over the hidden text within the text range.
  3. when moving by a particular unit (character, word etc), skip over any hidden text. I.e. after the move, if the range is marked as hidden, keep moving by the given unit until outside the hidden text. this ensures the review cursor does not land on / report any hidden text.

Testing strategy:

  1. Open a new document in Microsoft word
  2. Type the words: NV Access
  3. Select these words and press control+k to insert a hyperlink. Give a URL of https://www.nvaccess.org/.
  4. Copy the link to the clipboard.
  5. Open Wordpad
  6. Paste the copied link into a new document.
  7. Read the line containing the link with NVDA. Verify that it announces "link NV Access out of link"
  8. Move through the line by character with the review cursor. Ensure that NVDA only reports the letters NV Access and not any of the initial hidden text (I.e. HYPERLINK).

Known issues with pull request:

There may be a performance hit in ignoring the fetch formatting after the cursor option on some systems.
If users report such a performance hit, then some alternatives are:

  • Move all this code in-process, similar to Microsoft Word's old object model support. Though this would be a lot of work for very little gain.
  • Only ignore the fetch formatting after the cursor option if the richEdit control is in NVDA's process (I.e. part of NVDA's own UI). In this case there would be no cross-process performance cost, and this also answers the original motivation of fixing this bug which was to make links more presentable in richEdit controls in NVDA's UI.

Change log entries:

Bug fixes

- Hidden text is no longer announced in Wordpad and other ``richEdit`` controls. (#13618)

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English

…, no matter whether the fetch formatting after cursor setting in NVDA is on or not. This used to be very slow in Windows XP, but these days seems to be less problematic.. Plus, it is needed to correctly identify the existance of links. If users report a major reduction in performance in Wordpad / other Richedit controls with many formatting changes, we may instead:

* Move all this code in-process like Microsoft Word. Though this would be a great deal of work for little gain.
* Only ignore this setting if the richEdit control is hosted in the NVDA process itself (part of NVDA's UI). As 1. being in the same process there will be no cross-process performance hit, and 2. We technically only cared about links in RichEdit currently for NvDA's own UI.
… text. RichEdit places a string of hidden text at the beginning of inserted hyperlinks.
@michaelDCurran michaelDCurran requested a review from a team as a code owner April 20, 2022 06:00
formatConfig=config.conf["documentFormatting"]
textRange=self._rangeObj.duplicate
textRange.collapse(True)
if not formatConfig["detectFormatAfterCursor"]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this exposed in the GUI? Can it be removed if no longer observed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From another conversation with @michaelDCurran, if this is the only usage, we can remove it from the settings dialog.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another usage at: source/textInfos/offsets.py:570
Snippet:

	def getTextWithFields(self, formatConfig: Optional[Dict] = None) -> textInfos.TextInfo.TextWithFieldsT:
		if not formatConfig:
			formatConfig=config.conf["documentFormatting"]
		if self.detectFormattingAfterCursorMaybeSlow and not formatConfig['detectFormatAfterCursor']:
			field,(boundStart,boundEnd)=self._getFormatFieldAndOffsets(self._startOffset,formatConfig,calculateOffsets=False)
			text=self.text
			return [textInfos.FieldCommand('formatChange',field),text]
		commandList=[]
		offset=self._startOffset
		while offset<self._endOffset:

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Apr 27, 2022
@michaelDCurran

Copy link
Copy Markdown
Member Author

Based on this finding, I would keep this setting available. It looks like at very least Java Access Bridge, old winConsoles, displayModel, and RichEdit without ITextDocument could all be affected. In other words, pretty much anything that inherits from textInfos.offsets.OffsetsTextInfo but not IAccessible2, as it sets self.detectFormattingAfterCursorMaybeSlow to False. I have no idea whether performance is still an issue with any of them, but at very least, definitely would require further investigation.

@AppVeyorBot

This comment was marked as outdated.

@AppVeyorBot

This comment was marked as outdated.

@AppVeyorBot

This comment was marked as outdated.

@feerrenrut feerrenrut merged commit c591309 into master May 6, 2022
@feerrenrut feerrenrut deleted the ignoreRichEditHiddenText branch May 6, 2022 06:55
@nvaccessAuto nvaccessAuto added this to the 2022.2 milestone May 6, 2022
@codeofdusk

codeofdusk commented May 9, 2022

Copy link
Copy Markdown
Contributor

After this PR:

  1. Open Outlook.
  2. press Ctrl+n.
  3. Enter an email address (in the to: field), then press enter.
  4. Press right arrow.

Observed: NVDA says "out of link, blank".
Expected: NVDA says "blank" (there is no indication that the email address is a link).

@feerrenrut

Copy link
Copy Markdown
Contributor

@codeofdusk Is the email address exposed as a link? It probably is, please report to Microsoft. By the way, adding a comment to a closed PR is very likely to get ignored. Please open a new issue so it can be triaged.

seanbudd added a commit that referenced this pull request Jun 30, 2022
seanbudd added a commit that referenced this pull request Jul 1, 2022
…cument (PR #13618)" (#13858)

This reverts commit c591309.

Link to issue number:
Fixes #13826, reverts #13618

Summary of the issue:
#13618 causes a regression - #13826.
The PR needs to be reverted for 2022.2, and a new attempt at #13618 can be taken for 2022.3.

Description of user facing changes
#13618 is reverted: Hidden text will now be announced again in Wordpad and other richEdit controls.

Description of development approach
Note: another translation freeze may need to be announced.
The only translation changes is remove a line from changes.t2t.
@Brian1Gaff

Brian1Gaff commented Oct 11, 2022 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. reverted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants