Skip to content

Ensure documents always scroll to exact browse mode position#12803

Merged
michaelDCurran merged 5 commits into
masterfrom
i9611
Sep 9, 2021
Merged

Ensure documents always scroll to exact browse mode position#12803
michaelDCurran merged 5 commits into
masterfrom
i9611

Conversation

@michaelDCurran

@michaelDCurran michaelDCurran commented Sep 3, 2021

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #9611

Summary of the issue:

When reading / navigating with browse mode in Microsoft Word via UI Automation, the document does not always scroll so that the current browse mode position is visible on screen, nor does the focus mode caret position stay in sync with the browse mode caret, especially when moving across pages in browse mode.
Browse mode currently only knows how to scroll to objects in the document, not specific text range positions. Thus, it is only able to scroll to lists, tables and graphics, and not any arbitrary text.
Also, setting the caret in Microsoft Word to a range that is on a page that is currently off screen seems to fail and or set the caret to a random point on the current page.

Description of how this pull request fixes the issue:

  • Add a scrollIntoView method on textInfos.TextInfo which should croll the document containing that range such that the range is visible on screen. The base implementation has no implementation and does nothing.
  • Implement ScrollIntoView for IAccessible2 textInfos, UIA textInfos, Microsoft Word object model textInfos, and virtualBuffer textInfos. The VirtualBuffer textInfo implementation comes straight from the old BrowseMode logic which is to call ScrollIntoView on the deepest object at the position in the document.
  • Change BrowseModeDocument's _set_selection to call ScrollIntoView on the given textInfo, rather than the deepest object at the position of that textInfo. This is much more accurate and will ensure that any arbitrary textRange is scrolled to. It is specifically this change, plus the implementation of ScrollIntoView for UIA TextInfo that solves the Microsoft Word with Browse mode via UI Automation scrolling issue.

Testing strategy:

Try build: https://ci.appveyor.com/api/buildjobs/bsjf2a8c6t9879wf/artifacts/output%2Fnvda_snapshot_try-i9611-23673%2C38a7b5ac.exe
@Qchristensen has confirmed this pr fixes #9611 and that it does not cause regressions in any other browse mode implementation (Firefox, Chrome etc).

Known issues with pull request:

None known.

Change log entries:

Bug fixes:

Code Review Checklist:

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual testing.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers

@lukaszgo1 lukaszgo1 left a comment

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 are some unrelated changes in this PR. Can it be rebased on master?

Comment thread source/NVDAObjects/window/winword.py Outdated
self.obj.WinwordWindowObject.ScrollIntoView(self._rangeObj, True)
except COMError:
log.exception("Can't scroll")
pass

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.

This line is unnecessary.

… possible.

Specifically:
* TextInfos.TextInfo:  Added ScrollIntoView method (no default implementation)
* Implemented ScrollIntoView for UIA, IAccessible2, MS Word (object model), base VirtualBuffer class.
  * treeInterceptorHandler.RootProxyTextInfo: expose ScrollIntoView method which forwards to the innerTextInfo's implementation.
  * BrowseModeDocument._set_selection: Call ScrollIntoView on the given textInfo, rather than its deepest object. this is more accurate.

 # Please enter the commit message for your changes. Lines starting
…ther than error as this could happen a lot in Outline view apparently.
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 3fbcb02018

@michaelDCurran michaelDCurran marked this pull request as ready for review September 9, 2021 05:53
@michaelDCurran michaelDCurran requested a review from a team as a code owner September 9, 2021 05:53
Comment on lines +400 to +404
if not obj:
return
if obj == self.obj.rootNVDAObject:
# However never scroll to the document itself
return

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should these cases be logged? if not obj used to be

…og a debug warning if there is an invalid NVDAObject at start.
@michaelDCurran

michaelDCurran commented Sep 9, 2021 via email

Copy link
Copy Markdown
Member Author

@LeonarddeR

LeonarddeR commented Sep 9, 2021

Copy link
Copy Markdown
Collaborator

Ah, a pity I missed this. There seems to be some overlap with #9919 which I abandoned. Some thoughts:

  1. This pr does not implement scrolling for MSHTML. MSHTML does support scrolling at the text range level, though.
  2. I implemented an allignToTop parameter in Improve scrolling experience in browse mode #9919 since most API's support specifying this. It was used in browse mode because otherwise, some implementations (I don't remember which) tent to scroll all the time, even when not necessary.
  3. IAccessible2 ScrollSubstringTo sometimes fails when the object is entirely out of view.

@michaelDCurran I assume you didn't know about #9919. May be it could be helpful to have a look at it and see what can be incorporated?

@michaelDCurran

michaelDCurran commented Sep 9, 2021 via email

Copy link
Copy Markdown
Member Author

@michaelDCurran

Copy link
Copy Markdown
Member Author

@LeonarddeR Although #9919 is much more complete, I believe this pr is enough of a subset for what is required for MS Word with UIA to scroll, without breaking anything else.
True that MSHTML is not implemented, but currently nothing would call it anyway. Any browse mode implementation we currently have for MSHTML is a virtualBuffer.
I'd be happy to take a look at what can be taken from #9919 at a later date. But for now I'd only be interested in real-world regressions caused by this PR.
I think the only one that might exist is scrolling in Amazon Kindle for PC -- this is the only browse mode implementation that uses IAccessible2 directly, and it is possible scrollToSubstring may have the limitation you noted in #9919. Though that would need to be tested.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Focus movement changing between focus and browse mode with UIA in Word 365

6 participants