Skip to content

Fix empty automation bounds for custom root providers - #21730

Merged
MrJul merged 3 commits into
masterfrom
fix/automation-peer-presentation-source
Jul 8, 2026
Merged

MrJul merged 3 commits into
masterfrom
fix/automation-peer-presentation-source

Conversation

@jmacato

@jmacato jmacato commented Jul 8, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

Adds AutomationPeer.ToScreen(Rect) so each peer converts its own bounding rectangle to screen coordinates, and uses it from the Win32 UIA backend.

What is the current behavior?

AutomationNode.GetBoundingRectangle only produces bounds when the visual root peer is a ControlAutomationPeer with a live Control owner:

if (Peer.GetVisualRoot() is ControlAutomationPeer root &&
    root.Owner.GetPresentationSource() is not null)
    ...

Any custom IRootProvider that is not a ControlAutomationPeer (embedded/hosted trees) fails that check and every element reports an empty rectangle. The conversion also goes through root.Owner (the FocusRoot), while GetBoundingRectangle returns rects relative to the visual root, so the two disagree whenever FocusRoot is offset from the root.

What is the updated/expected behavior with this PR?

Bounds are correct for any root provider. The peer converts its own rectangle in the coordinate space it was measured in, so there is no root-peer type requirement and no FocusRoot offset.

Checklist

Breaking changes

None. ToScreen is additive and [PrivateApi].

…ctangle to screen coordinates, fixing empty UIA bounds for root providers that are not ControlAutomationPeers.
@MrJul MrJul added the bug label Jul 8, 2026

@MrJul MrJul left a comment

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.

LGTM!

@MrJul
MrJul enabled auto-merge July 8, 2026 09:48
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0067306-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul
MrJul added this pull request to the merge queue Jul 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 8, 2026
@MrJul
MrJul merged commit a6dbeb7 into master Jul 8, 2026
11 checks passed
@MrJul
MrJul deleted the fix/automation-peer-presentation-source branch July 8, 2026 11:20
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