Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix routing to account for rawToContentPos #16497

Merged
merged 3 commits into from
May 8, 2024

Conversation

LeonarddeR
Copy link
Collaborator

Link to issue number:

Fixup of #16477

Summary of the issue:

When writing #16477, I hadn't realized that TextInfoRegion compensated for characters that aren't part of the text info. This mapping is stored in the _rawToContentPos attribute. This compensation is necessary for character movement based routing, but not for code point offset based routing. The following would happen without this pr.

  1. In Word, write a list item, e.g. 1. Hello
  2. Route to the fourth cell (offset 3)
  3. The third raw position (h) would correspond with content position zero (1)
  4. With moveToCodepointOffset, moving to offset 0 means moving to 1 not to h. Basically, the cursor would end up at the first cell, not at the fourth.

Description of user facing changes

Routing works again in Word list items.

Description of development approach

  1. When using moveToCodepointOffset, move to the raw position, not to the actual content position. moveToCodepointOffset expects raw positions, not content positions.
  2. Don't use moveToCodepointOffset when the content position is 0, since we can simply collapse the textInfo at the start of the reading unit and return that. Note that moveToCodepointOffset would fail for everything up to offset 3 anyway, since it wouldn't be able to move.

Testing strategy:

Tested the steps to reproduce as mentioned above.

Known issues with pull request:

None known

Code Review Checklist:

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

@LeonarddeR LeonarddeR marked this pull request as ready for review May 7, 2024 08:53
@LeonarddeR LeonarddeR requested a review from a team as a code owner May 7, 2024 08:53
@LeonarddeR LeonarddeR requested a review from michaelDCurran May 7, 2024 08:53
@@ -1345,18 +1345,27 @@ def update(self):
self._brailleInputIndStart = None

def getTextInfoForBraillePos(self, braillePos):
Copy link
Member

Choose a reason for hiding this comment

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

could you add type information here given the rewrite of this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@seanbudd seanbudd added this to the 2024.3 milestone May 8, 2024
@seanbudd seanbudd merged commit 892f1e2 into nvaccess:master May 8, 2024
1 check passed
XLTechie pushed a commit to XLTechie/xlnvda that referenced this pull request May 10, 2024
Fixup of nvaccess#16477

Summary of the issue:
When writing nvaccess#16477, I hadn't realized that TextInfoRegion compensated for characters that aren't part of the text info. This mapping is stored in the _rawToContentPos attribute. This compensation is necessary for character movement based routing, but not for code point offset based routing. The following would happen without this pr.

In Word, write a list item, e.g. 1. Hello
Route to the fourth cell (offset 3)
The third raw position (h) would correspond with content position zero (1)
With moveToCodepointOffset, moving to offset 0 means moving to 1 not to h. Basically, the cursor would end up at the first cell, not at the fourth.
Description of user facing changes
Routing works again in Word list items.

Description of development approach
When using moveToCodepointOffset, move to the raw position, not to the actual content position. moveToCodepointOffset expects raw positions, not content positions.
Don't use moveToCodepointOffset when the content position is 0, since we can simply collapse the textInfo at the start of the reading unit and return that. Note that moveToCodepointOffset would fail for everything up to offset 3 anyway, since it wouldn't be able to move.
@burmancomp
Copy link
Contributor

I have noticed this behavior change:

When selecting text with shift+down arrow in wordpad atleast in windows 10, review position moves to next line after last selected line (to first unselected line).

This does not happen in notepad or in word 2019.

Could this change have been introduced with this pr?

@LeonarddeR
Copy link
Collaborator Author

No. I think it's more likely a cause of the behavioral changes you introduced with the several prs of redundant handleUpdate calls.

@burmancomp
Copy link
Contributor

They were reverted. It seems to be #16455.

@burmancomp
Copy link
Contributor

Unfortunately in browse mode routing buttons seem to work inaccurately at least with firefox in windows 10:

  • go to https://www.nvaccess.org
  • move to end of page (control+end)
  • press up arrow to move to "careers"
  • press various routing buttons.

@LeonarddeR
Copy link
Collaborator Author

Ugh, good catch. It looks like fixing problem 1 introduced problem 2. I think it might be better to revert at least this pr, may be also #16477, I'm not sure. What do you think @seanbudd

@LeonarddeR
Copy link
Collaborator Author

I'm going the revert route for now

LeonarddeR added a commit to LeonarddeR/nvda that referenced this pull request May 13, 2024
seanbudd pushed a commit that referenced this pull request May 14, 2024
Reverts #16477 , #16497

Issues fixed
None

Issues reopened
Reopens #10960

Reason for revert
Feature turns out to be unstable.

Can this PR be reimplemented? If so, what is required for the next attempt
Use a feature flag
Ensure issues reported in Fix routing to account for rawToContentPos #16497 (comment) and Fix routing to account for rawToContentPos #16497 (comment) are covered by the fix
seanbudd pushed a commit that referenced this pull request Jul 30, 2024
Fixes #10960
Replaces #16477, #16497

Summary of the issue:
There are cases where moving one character on a textInfo instance actually moves more than one unicode point offset. This is described by @mltony in the doc string for textInfos.TextInfo.moveToCodepointOffset.
This causes of by one errors when cursor routing, since we're asking the textInfo to move by 1 characters, that might be presented by two or even more characters within the liblouis mapping.

Description of user facing changes
Cursor routing should be more reliable.

Description of development approach
@mltony's creation of moveToCodepointOffset allows us to move x code points from the start of the reading unit. As we're using 32 bit encoding for liblouis, every character as presented by liblouis is equal to one code point. Therefore we can safely assume that this method to move is much more reliable than the previous method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants