Skip to content

Commit 564489b

Browse files
authored
Create AutomationProvider.md
1 parent f2abacd commit 564489b

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

specs/AutomationProvider.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Background
2+
WebView has two hosting modes, windowed (which uses the ICoreWebView2Controller) and visual (which uses the ICoreWebView2CompositionController). Accessibility for the windowed WebView is able to walk the HWND tree to know where to place the WebView in the accessibility tree. For visual hosting, accessibility is not able to know where within the accessibility tree to place the WebView. This results in a WebView being a sibling to the rest of the app content.
3+
4+
In this document we describe the updated API. We'd appreciate your feedback.
5+
6+
7+
# Description
8+
To give apps using the ICoreWebView2CompositionController more control over how the WebView is positioned in the accessibility tree, we are adding new APIs to let the app retrieve the automation provider for the WebView. This let's the app return the automation provider as part of its accessibility tree.
9+
10+
While traversing child elements, when the app reaches the WebView, it can use the `UIAProvider` property to get the automation provider for the WebView and return it.
11+
12+
When accessibility is traversing parent elements, the app can use `GetProviderForHwnd` to get the automation provider that matches the WebView based on the HWND.
13+
14+
# Examples
15+
```cpp
16+
HRESULT WebView2AutomationPeer::GetRawElementProviderSimple(IRawElementProviderSimple** value)
17+
{
18+
wil::com_ptr<IUnknown> provider;
19+
CHECK_FAILURE(m_controller->get_UIAProvider(&provider));
20+
return provider->QueryInterface(IID_PPV_ARGS(value));
21+
}
22+
23+
bool WebView2AutomationPeer::IsCorrectPeerForHwnd(HWND hwnd)
24+
{
25+
wil::com_ptr<IUnknown> provider;
26+
CHECK_FAILURE(m_controller->get_UIAProvider(&provider));
27+
28+
wil::com_ptr<IUnknown> providerForHwnd;
29+
CHECK_FAILURE(m_environment->GetProviderForHwnd(hwnd, &providerForHwnd));
30+
31+
return (provider == providerForHwnd);
32+
}
33+
```
34+
35+
# API Notes
36+
See [API Details](#api_details) section below for API reference.
37+
38+
# API Details
39+
## Win32 C++
40+
``` c#
41+
interface ICoreWebView2Environment4 : ICoreWebView2Environment3 {
42+
/// Returns the UI Automation Provider for the
43+
/// ICoreWebView2CompositionController that corresponds with the given HWND.
44+
HRESULT GetProviderForHwnd([in] HWND hwnd,
45+
[out, retval] IUnknown** provider);
46+
}
47+
48+
interface ICoreWebView2CompositionController2 : ICoreWebView2CompositionController {
49+
/// Returns the UI Automation Provider for the WebView.
50+
[propget] HRESULT UIAProvider([out, retval] IUnknown** provider);
51+
}
52+
```
53+
## .Net and WinRT
54+
API is not natively supported in .Net and WinRT. The Win32 COM API is exposed using an interop interface.

0 commit comments

Comments
 (0)