[PR #11501] [MERGED] Properly initialize XamlUiaTextRange with ProviderFromPeer #28614

Open
opened 2026-01-31 09:29:39 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11501
Author: @carlos-zamora
Created: 10/13/2021
Status: Merged
Merged: 10/14/2021
Merged by: @undefined

Base: mainHead: dev/cazamor/a11y/a-tale-of-two-auto-peers


📝 Commits (4)

  • 8b8951b Properly initialize XamlUiaTextRange with ProviderFromPeer
  • b7fa5c7 address DHowett feedback
  • 49e9f41 revert OnCreateAutoPeer change
  • 89a1479 update comment

📊 Changes

6 files changed (+33 additions, -44 deletions)

View changed files

📝 src/cascadia/TerminalControl/InteractivityAutomationPeer.cpp (+25 -15)
📝 src/cascadia/TerminalControl/InteractivityAutomationPeer.h (+4 -0)
📝 src/cascadia/TerminalControl/InteractivityAutomationPeer.idl (+1 -1)
📝 src/cascadia/TerminalControl/TermControlAutomationPeer.cpp (+1 -26)
📝 src/cascadia/TerminalControl/TermControlAutomationPeer.h (+0 -2)
📝 src/cascadia/TerminalControl/XamlUiaTextRange.cpp (+2 -0)

📄 Description

Summary of the Pull Request

As a part of the Interactivity split, TermControlAutomationPeer had to be split into TermControlAutomationPeer (TCAP) and InteractivityAutomationPeer (IAP). Just about all of the functions in InterativityAutomationPeer operate by calling the non-XAML UIA Provider then wrapping the resulting UIATextRange into a XAML format (a XamlUiaTextRange [XUTR]). As a part of that XUTR constructor, we need a reference to the parent provider.

We generally get that via ProviderFromPeer(), but IAP's ProviderFromPeer() returned null (presumably because IAP isn't in the UI tree, whereas TCAP is directly registered as the automation peer for the TermControl).

It looks like some screen readers didn't care (like NVDA, though there may be a chance we just didn't encounter an issue just yet), but Narrator definitely did.

The fix was to provide XUTR constructors the ProviderFromPeer from TCAP, not IAP. To accomplish this, IAP now holds a weak reference to TCAP, and provides the ProviderFromPeer when needed. We can't cache this result because there is no guarantee that it won't change.

Some miscellaneous changes include:

  • TermControl::OnCreateAutomationPeer now returns the existing auto peer instead of always creating a new one
  • TCAP::WrapArrayOfTextRangeProviders was removed as it was unused (normally, this would be directly affected by the main ProviderFromPeer change here)
  • XUTR::GetEnclosingElement is now hooked up to trace logging for debugging purposes

References

Introduced in #10051
Closes #11488

Validation Steps Performed

Narrator scan mode now works (verified with character, word, and line navigation)
NVDA movement still works (verified with word and line navigation)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/11501 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 10/13/2021 **Status:** ✅ Merged **Merged:** 10/14/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/cazamor/a11y/a-tale-of-two-auto-peers` --- ### 📝 Commits (4) - [`8b8951b`](https://github.com/microsoft/terminal/commit/8b8951bae8244f9cc6424836359c7707000f1ddd) Properly initialize XamlUiaTextRange with ProviderFromPeer - [`b7fa5c7`](https://github.com/microsoft/terminal/commit/b7fa5c7fd2e1575794616e985283d1348903cade) address DHowett feedback - [`49e9f41`](https://github.com/microsoft/terminal/commit/49e9f4101332a981e9fe51aa10d642157a849778) revert OnCreateAutoPeer change - [`89a1479`](https://github.com/microsoft/terminal/commit/89a14790b727bdfc9da6e71e5e02e8272c75cb5c) update comment ### 📊 Changes **6 files changed** (+33 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/InteractivityAutomationPeer.cpp` (+25 -15) 📝 `src/cascadia/TerminalControl/InteractivityAutomationPeer.h` (+4 -0) 📝 `src/cascadia/TerminalControl/InteractivityAutomationPeer.idl` (+1 -1) 📝 `src/cascadia/TerminalControl/TermControlAutomationPeer.cpp` (+1 -26) 📝 `src/cascadia/TerminalControl/TermControlAutomationPeer.h` (+0 -2) 📝 `src/cascadia/TerminalControl/XamlUiaTextRange.cpp` (+2 -0) </details> ### 📄 Description ## Summary of the Pull Request As a part of the Interactivity split, `TermControlAutomationPeer` had to be split into `TermControlAutomationPeer` (TCAP) and `InteractivityAutomationPeer` (IAP). Just about all of the functions in `InterativityAutomationPeer` operate by calling the non-XAML UIA Provider then wrapping the resulting `UIATextRange` into a XAML format (a `XamlUiaTextRange` [XUTR]). As a part of that XUTR constructor, we need a reference to the parent provider. We generally get that via `ProviderFromPeer()`, but IAP's `ProviderFromPeer()` returned null (presumably because IAP isn't in the UI tree, whereas TCAP is directly registered as the automation peer for the `TermControl`). It looks like some screen readers didn't care (like NVDA, though there may be a chance we just didn't encounter an issue just yet), but Narrator definitely did. The fix was to provide XUTR constructors the `ProviderFromPeer` from TCAP, _not_ IAP. To accomplish this, IAP now holds a weak reference to TCAP, and provides the `ProviderFromPeer` when needed. We can't cache this result because there is no guarantee that it won't change. Some miscellaneous changes include: - `TermControl::OnCreateAutomationPeer` now returns the existing auto peer instead of always creating a new one - `TCAP::WrapArrayOfTextRangeProviders` was removed as it was unused (normally, this would be directly affected by the main `ProviderFromPeer` change here) - `XUTR::GetEnclosingElement` is now hooked up to trace logging for debugging purposes ## References Introduced in #10051 Closes #11488 ## Validation Steps Performed ✅ Narrator scan mode now works (verified with character, word, and line navigation) ✅ NVDA movement still works (verified with word and line navigation) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:29:39 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28614