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

Allow embedded root automation peers. #12330

Merged
merged 20 commits into from
Aug 10, 2023

Conversation

grokys
Copy link
Member

@grokys grokys commented Jul 25, 2023

What does the pull request do?

Adds a way to allow an embedded 3rd party UI framework to integrate itself in Avalonia's Automation tree, using the Avalonia AutomationPeer API.

The Avalonia container element for the embedded 3rd party UI framework should expose an automation peer which implements IEmbeddedRootProvider. When a ControlAutomationPeer finds a peer which implements this interface, then it will delegate hit testing to that peer. The 3rd party UI framework can then return its own AutomationPeer-derived object for the located element.

Ideally IRootProvider and IEmbeddedRootProvider would have shared a common interface, but that was not possible without breaking our stable API so they're completely different interfaces for 11.x. This could be fixed for 12.0.

Also needed to fix quite a few instances where we were casting a peer to a provider type directly instead of going via AutomationPeer.GetProvider<T>.

@avaloniaui-team
Copy link
Contributor

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

@avaloniaui-team
Copy link
Contributor

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

We should use `GetProvider<T>` instead of a plain cast as a peer may decide to dynamically support a provider, or delegate its implementation.
@avaloniaui-team
Copy link
Contributor

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

The previous commit missed some providers, and we also need to call `GetProvider<T>` when calling members on the provider.
@avaloniaui-team
Copy link
Contributor

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

Found a few more places that were doing casts instead of calling `GetProvider<T>()`.
@avaloniaui-team
Copy link
Contributor

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

Arrgh! Forgot to save the file.
@avaloniaui-team
Copy link
Contributor

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

grokys added 3 commits July 27, 2023 00:19
This reverts commit 0e7b8f6. The code is in the wrong place.
For some reason, on win32 embedded `IRawElementProviderFragmentRoot`s just don't show up, so we need an interface to distinguish between "actual" root peers and "embedded" root peers. Ideally `IRootProvider` and `IEmbeddedRootProvider` would share a common interface but that would be a breaking change.
@avaloniaui-team
Copy link
Contributor

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

@avaloniaui-team
Copy link
Contributor

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

This is needed for example when a UI framework hosts a peer in the automation tree of a main window whose control is actually hosted in a popup. It allows the bounding rectangle to be calculated correctly in that case.

s
@grokys grokys force-pushed the feature/embedded-automation-roots branch from 32d1e89 to c1645ca Compare July 27, 2023 17:40
@avaloniaui-team
Copy link
Contributor

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

Seems it was broken before and always would have returned null.
@avaloniaui-team
Copy link
Contributor

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

@avaloniaui-team
Copy link
Contributor

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

grokys added 2 commits July 28, 2023 11:19
Needs to check for `IRootProvider`. Fixes integration tests on Windows.
@avaloniaui-team
Copy link
Contributor

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

@grokys grokys changed the title WIP: Allow embedded root automation peers. Allow embedded root automation peers. Aug 8, 2023
@grokys grokys marked this pull request as ready for review August 8, 2023 13:38
@avaloniaui-team
Copy link
Contributor

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

@danwalmsley danwalmsley merged commit 1896e8a into master Aug 10, 2023
@danwalmsley danwalmsley deleted the feature/embedded-automation-roots branch August 10, 2023 10:31
@grokys grokys added backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Sep 29, 2023
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.

4 participants