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 UIA ScrollIntoView at EndExclusive #7868

Merged
2 commits merged into from
Oct 9, 2020
Merged

Fix UIA ScrollIntoView at EndExclusive #7868

2 commits merged into from
Oct 9, 2020

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Oct 9, 2020

ScrollIntoView is responsible for scrolling the viewport to include
the UTR's start endpoint. The crash was caused by start being at the
exclusive end, and attempting to scroll to it. This is now fixed by
clamping the result to the bottom of the buffer.

Most of the work here is to allow a test for this. ScrollIntoView
relied on a virtual ChangeViewport function. By making that
non-virtual, the DummyElementProvider in the tests can now be a
ScreenInfoUiaProviderBase. This opens up the possibility of more
UiaTextRange tests in the future too.

Closes #7839

@carlos-zamora carlos-zamora requested a review from DHowett October 9, 2020 00:04
@ghost ghost added Area-Accessibility Issues related to accessibility Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Conhost For issues in the Console codebase Severity-Crash Crashes are real bad news. labels Oct 9, 2020
@DHowett
Copy link
Member

DHowett commented Oct 9, 2020

The change that I am going to bring to Windows:

diff --git a/src/types/UiaTextRangeBase.cpp b/src/types/UiaTextRangeBase.cpp
index e26415999..99589eeb0 100644
--- a/src/types/UiaTextRangeBase.cpp
+++ b/src/types/UiaTextRangeBase.cpp
@@ -796,9 +796,13 @@ try
         // check if we can align to the bottom
         if (static_cast<unsigned int>(endScreenInfoRow) >= viewportHeight)
         {
+            // GH#7839: endScreenInfoRow may be ExclusiveEnd
+            //          ExclusiveEnd is past the bottomRow
+            //          so we need to clamp to the bottom row to stay in bounds
+
             // we can align to bottom
-            newViewport.Bottom = endScreenInfoRow;
-            newViewport.Top = endScreenInfoRow - viewportHeight + 1;
+            newViewport.Bottom = std::min(endScreenInfoRow, bottomRow);
+            newViewport.Top = base::ClampedNumeric<short>(newViewport.Bottom) - viewportHeight + 1;
         }
         else
         {

@miniksa
Copy link
Member

miniksa commented Oct 9, 2020

ScrollIntoView is responsible for scrolling the viewport to include
the UTR's start endpoint. The crash was caused by start being at the
exclusive end, and attempting to scroll to it. This is now fixed by
clamping the result to

You accidentally a word in the description.

@carlos-zamora
Copy link
Member Author

@msftbot merge this in 5 minutes

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 9, 2020
@ghost
Copy link

ghost commented Oct 9, 2020

Hello @carlos-zamora!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Fri, 09 Oct 2020 20:26:43 GMT, which is in 5 minutes

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost merged commit 7a1932c into master Oct 9, 2020
@ghost ghost deleted the dev/cazamor/a11y/7839 branch October 9, 2020 20:27
skyline75489 pushed a commit to skyline75489/terminal that referenced this pull request Oct 10, 2020
`ScrollIntoView` is responsible for scrolling the viewport to include
the UTR's start endpoint. The crash was caused by `start` being at the
exclusive end, and attempting to scroll to it. This is now fixed by
clamping the result to the bottom of the buffer.

Most of the work here is to allow a test for this. `ScrollIntoView`
relied on a virtual `ChangeViewport` function. By making that
non-virtual, the `DummyElementProvider` in the tests can now be a
`ScreenInfoUiaProviderBase`. This opens up the possibility of more
UiaTextRange tests in the future too.

Closes microsoft#7839
@codeofdusk
Copy link
Contributor

@DHowett Guessing this PR is also supposed to have a merged into Windows comment?

@DHowett
Copy link
Member

DHowett commented Oct 14, 2020

You'd be guessing wrong! 😄

@DHowett
Copy link
Member

DHowett commented Oct 14, 2020

I'll let folks on this PR know what build it's available in, when it's available in a public build.

DHowett pushed a commit that referenced this pull request Oct 19, 2020
`ScrollIntoView` is responsible for scrolling the viewport to include
the UTR's start endpoint. The crash was caused by `start` being at the
exclusive end, and attempting to scroll to it. This is now fixed by
clamping the result to the bottom of the buffer.

Most of the work here is to allow a test for this. `ScrollIntoView`
relied on a virtual `ChangeViewport` function. By making that
non-virtual, the `DummyElementProvider` in the tests can now be a
`ScreenInfoUiaProviderBase`. This opens up the possibility of more
UiaTextRange tests in the future too.

Closes #7839

(cherry picked from commit 7a1932c)
@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal v1.4.3141.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Accessibility Issues related to accessibility AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Conhost For issues in the Console codebase Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

narrator scan mode [ctrl+end] crashes conhost
4 participants