Skip to content

Commit 3258762

Browse files
authored
Update AutomationProvider.md
1 parent b47a381 commit 3258762

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

specs/AutomationProvider.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
# Background
22
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.
33

4-
In this document we describe the updated API. We'd appreciate your feedback.
4+
In this document we describe the updated API so visual-hosted WebViews are correctly managed by accessibility. We'd appreciate your feedback.
55

66

77
# Description
88
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.
99

1010
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.
1111

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.
12+
When accessibility is traversing parent elements, the app needs to implement IRawElementProviderHwndOverride. The HWND parameter from GetOverrideProviderForHwnd can be passed to `GetProviderForHwnd` to get the automation provider for the corresponding WebView.
1313

1414
# Examples
1515
```cpp
1616
HRESULT WebView2AutomationPeer::GetRawElementProviderSimple(IRawElementProviderSimple** value)
1717
{
1818
wil::com_ptr<IUnknown> provider;
19-
CHECK_FAILURE(m_controller->get_UIAProvider(&provider));
19+
CHECK_FAILURE(m_controller->get_AutomationProvider(&provider));
2020
return provider->QueryInterface(IID_PPV_ARGS(value));
2121
}
2222

23-
bool WebView2AutomationPeer::IsCorrectPeerForHwnd(HWND hwnd)
23+
// Find the WebView2AutomationPeer for the HWND from
24+
// IRawElementProviderHwndOverride::GetOverrideProviderForHwnd
25+
bool WebView2AutomationPeer::IsAutomationPeerForWindow(HWND window)
2426
{
2527
wil::com_ptr<IUnknown> provider;
26-
CHECK_FAILURE(m_controller->get_UIAProvider(&provider));
28+
CHECK_FAILURE(m_controller->get_AutomationProvider(&provider));
2729

28-
wil::com_ptr<IUnknown> providerForHwnd;
29-
CHECK_FAILURE(m_environment->GetProviderForHwnd(hwnd, &providerForHwnd));
30+
wil::com_ptr<IUnknown> providerForWindow;
31+
CHECK_FAILURE(m_environment->GetAutomationProviderForWindow(window, &providerForWindow));
3032

31-
return (provider == providerForHwnd);
33+
return (provider == providerForWindow);
3234
}
3335
```
3436
@@ -39,16 +41,17 @@ See [API Details](#api_details) section below for API reference.
3941
## Win32 C++
4042
``` c#
4143
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,
44+
/// Returns the UI Automation Provider for the WebView that matches the provided window.
45+
/// Host apps are expected to implement IRawElementProviderHwndOverride. When GetOverrideProviderForHwnd
46+
/// is called, the app can pass the HWND to GetAutomationProviderForWindow to find the matching WebView
47+
/// automation provider.
48+
HRESULT GetAutomationProviderForWindow([in] HWND window,
4649
[out, retval] IUnknown** provider);
4750
}
4851
4952
interface ICoreWebView2CompositionController2 : ICoreWebView2CompositionController {
5053
/// Returns the UI Automation Provider for the WebView.
51-
[propget] HRESULT UIAProvider([out, retval] IUnknown** provider);
54+
[propget] HRESULT AutomationProvider([out, retval] IUnknown** provider);
5255
}
5356
```
5457
## .Net and WinRT

0 commit comments

Comments
 (0)