Repository navigation
Expose Text Attributes to UI Automation #10336
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
84bca57
Expose Text Attributes to UI Automation
carlos-zamora 136a548
fix/add tests; remove invalid attributes
carlos-zamora a7bbf9d
address PR feedback
carlos-zamora 2be632b
remove 'limit' from new iterator
carlos-zamora 84fdf5a
bugfix: italic was not detected properly
carlos-zamora 3fa8c95
fix 1 char wide case; better degenerate range handling; don't return …
carlos-zamora 7c88010
Merge branch 'main' into dev/cazamor/a11y-7000/text-attributes
carlos-zamora 74a645f
fix failing tests and audit mode
carlos-zamora 2e7895c
fix typo
carlos-zamora 96a5551
apply Dustin's suggestions
carlos-zamora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Expose Text Attributes to UI Automation
- Loading branch information
commit 84bca57d2dbd28d1a3b9b98182c50616f11e3136
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| #include "XamlUiaTextRange.h" | ||
| #include "../types/TermControlUiaTextRange.hpp" | ||
| #include <UIAutomationClient.h> | ||
| #include <UIAutomationCoreApi.h> | ||
|
|
||
| // the same as COR_E_NOTSUPPORTED | ||
| // we don't want to import the CLR headers to get it | ||
|
|
@@ -89,12 +90,56 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
|
|
||
| winrt::Windows::Foundation::IInspectable XamlUiaTextRange::GetAttributeValue(int32_t textAttributeId) const | ||
| { | ||
| // Copied functionality from Types::UiaTextRange.cpp | ||
| if (textAttributeId == UIA_IsReadOnlyAttributeId) | ||
| // Call the function off of the underlying UiaTextRange. | ||
| VARIANT result; | ||
| THROW_IF_FAILED(_uiaProvider->GetAttributeValue(textAttributeId, &result)); | ||
|
|
||
| // Convert the resulting VARIANT into a format that is consumable by XAML. | ||
| switch (result.vt) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised that nobody has made a C++ visitor specialization for a variant |
||
| { | ||
| case VT_BSTR: | ||
| { | ||
| return box_value(result.bstrVal); | ||
| } | ||
| case VT_I4: | ||
| { | ||
| return box_value(result.iVal); | ||
| } | ||
| case VT_R8: | ||
| { | ||
| return box_value(result.dblVal); | ||
| } | ||
| case VT_BOOL: | ||
| { | ||
| return box_value(result.boolVal); | ||
| } | ||
| case VT_UNKNOWN: | ||
| { | ||
| return winrt::box_value(false); | ||
| // This one is particularly special. | ||
| // We might return a special value like UiaGetReservedMixedAttributeValue | ||
| // or UiaGetReservedNotSupportedValue. | ||
| // Some text attributes may return a real value, however, none of those | ||
| // are supported at this time. | ||
| // So we need to figure out what was actually intended to be returned. | ||
|
|
||
| IUnknown* notSupportedVal; | ||
| UiaGetReservedNotSupportedValue(¬SupportedVal); | ||
|
carlos-zamora marked this conversation as resolved.
Outdated
|
||
| if (result.punkVal == notSupportedVal) | ||
| { | ||
| // See below for why we need to throw this special value. | ||
| winrt::throw_hresult(XAML_E_NOT_SUPPORTED); | ||
| } | ||
|
carlos-zamora marked this conversation as resolved.
Outdated
|
||
|
|
||
| IUnknown* mixedAttributeVal; | ||
| UiaGetReservedMixedAttributeValue(&mixedAttributeVal); | ||
| if (result.punkVal == mixedAttributeVal) | ||
| { | ||
| return Windows::UI::Xaml::DependencyProperty::UnsetValue(); | ||
| } | ||
|
|
||
| __fallthrough; | ||
|
carlos-zamora marked this conversation as resolved.
Outdated
|
||
| } | ||
| else | ||
| default: | ||
| { | ||
| // We _need_ to return XAML_E_NOT_SUPPORTED here. | ||
| // Returning nullptr is an improper implementation of it being unsupported. | ||
|
|
@@ -103,6 +148,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
| // Magically, this doesn't affect other forms of navigation... | ||
| winrt::throw_hresult(XAML_E_NOT_SUPPORTED); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void XamlUiaTextRange::GetBoundingRectangles(com_array<double>& returnValue) const | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between a limit and an until? Why can they be different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment to be more clear. Also renamed...
limit-->boundsuntil-->limitTheoretically, you could have...
bounds = bufferSize&limit = (3,3): iterate fromatthroughlimit(explores (4,3) --> (5,3) --> (6,3))bounds = (5,5)&limit = (3,3): iterate fromatthroughlimitacrossbounds(explores (4,3) --> (5,3) --> (0,4))