Skip to content

Commit b47a381

Browse files
authored
Merge pull request #966 from MicrosoftEdge/automationprovider-draft
Create AutomationProvider.md
2 parents f2abacd + 6272db7 commit b47a381

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

specs/AutomationProvider.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 in cases where automation APIs are asking
43+
/// about an HWND that may belong to the WebView but the app doesn't have context
44+
/// to know which CoreWebView2Controller is being referenced.
45+
HRESULT GetProviderForHwnd([in] HWND hwnd,
46+
[out, retval] IUnknown** provider);
47+
}
48+
49+
interface ICoreWebView2CompositionController2 : ICoreWebView2CompositionController {
50+
/// Returns the UI Automation Provider for the WebView.
51+
[propget] HRESULT UIAProvider([out, retval] IUnknown** provider);
52+
}
53+
```
54+
## .Net and WinRT
55+
API is not natively supported in .Net and WinRT. The Win32 COM API is exposed using an interop interface.

0 commit comments

Comments
 (0)