Bug 1886371 part 1: Hook up our native UIA tree. r=nlapre,win-reviewers,rkraesig

1. Respond to WM_GETOBJECT with our IRawElementProviderSimple implementation for the root Accessible of the HWND.
2. Don't allow QueryInterface to UIA interfaces if the UIA pref is disabled. This stops WM_GETOBJECT from returning our UIA implementation in this case.
3. Specify the appropriate provider options.

Differential Revision: https://phabricator.services.mozilla.com/D205179
This commit is contained in:
James Teh 2024-03-25 03:28:03 +00:00
Родитель 6589218a3d
Коммит 0ea4812cf2
4 изменённых файлов: 25 добавлений и 6 удалений

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/a11y/AccessibleWrap.h"
#include "mozilla/a11y/Compatibility.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "mozilla/StaticPrefs_accessibility.h"
#include "MsaaAccessible.h"
#include "MsaaDocAccessible.h"
#include "MsaaRootAccessible.h"
@ -522,9 +523,11 @@ MsaaAccessible::QueryInterface(REFIID iid, void** ppv) {
if (SUCCEEDED(hr)) {
return hr;
}
hr = uiaRawElmProvider::QueryInterface(iid, ppv);
if (SUCCEEDED(hr)) {
return hr;
if (StaticPrefs::accessibility_uia_enable()) {
hr = uiaRawElmProvider::QueryInterface(iid, ppv);
if (SUCCEEDED(hr)) {
return hr;
}
}
}
if (*ppv) {

Просмотреть файл

@ -113,8 +113,9 @@ uiaRawElmProvider::get_ProviderOptions(
__RPC__out enum ProviderOptions* aOptions) {
if (!aOptions) return E_INVALIDARG;
// This method is not used with IAccessibleEx implementations.
*aOptions = ProviderOptions_ServerSideProvider;
*aOptions = ProviderOptions_ServerSideProvider |
ProviderOptions_UseComThreading |
ProviderOptions_HasNativeIAccessible;
return S_OK;
}

Просмотреть файл

@ -59,7 +59,7 @@ def Libxul(name, output_category=None):
]
if CONFIG["ACCESSIBILITY"]:
DELAYLOAD_DLLS += ["oleacc.dll"]
DELAYLOAD_DLLS += ["oleacc.dll", "UIAutomationCore.dll"]
if CONFIG["MOZ_WEBRTC"]:
DELAYLOAD_DLLS += ["msdmo.dll"]
@ -381,6 +381,7 @@ if CONFIG["OS_ARCH"] == "WINNT":
if CONFIG["ACCESSIBILITY"]:
OS_LIBS += [
"oleacc",
"uiautomationcore",
]
# Prevent winapi-rs from statically linking

Просмотреть файл

@ -182,6 +182,7 @@
# endif
# include "mozilla/a11y/Compatibility.h"
# include "oleidl.h"
# include <uiautomation.h>
# include <winuser.h>
# include "nsAccessibilityService.h"
# include "mozilla/a11y/DocAccessible.h"
@ -5886,6 +5887,19 @@ bool nsWindow::ProcessMessageInternal(UINT msg, WPARAM& wParam, LPARAM& lParam,
a11y::LazyInstantiator::EnableBlindAggregation(mWnd);
result = true;
}
} else if (objId == UiaRootObjectId) {
if (a11y::LocalAccessible* acc = GetAccessible()) {
RefPtr<IAccessible> ia;
acc->GetNativeInterface(getter_AddRefs(ia));
MOZ_ASSERT(ia);
RefPtr<IRawElementProviderSimple> uia;
ia->QueryInterface(IID_IRawElementProviderSimple,
getter_AddRefs(uia));
if (uia) {
*aRetValue = UiaReturnRawElementProvider(mWnd, wParam, lParam, uia);
result = true;
}
}
}
} break;
#endif