Bug 1845134 - Part 4: Update existing ui-icons to use the latest source from acorn...
[gecko.git] / accessible / windows / uia / UiaRoot.cpp
blob0e8c86ce6a32b0ed228d55ade25b9fa107dde297
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "UiaRoot.h"
9 #include "MsaaRootAccessible.h"
10 #include "RootAccessible.h"
12 using namespace mozilla;
13 using namespace mozilla::a11y;
15 // UiaRoot
17 Accessible* UiaRoot::Acc() {
18 auto* mr = static_cast<MsaaRootAccessible*>(this);
19 return static_cast<MsaaAccessible*>(mr)->Acc();
22 // IRawElementProviderFragmentRoot
24 STDMETHODIMP
25 UiaRoot::ElementProviderFromPoint(
26 double aX, double aY,
27 __RPC__deref_out_opt IRawElementProviderFragment** aRetVal) {
28 if (!aRetVal) {
29 return E_INVALIDARG;
31 *aRetVal = nullptr;
32 Accessible* acc = Acc();
33 if (!acc) {
34 return CO_E_OBJNOTCONNECTED;
36 if (Accessible* target = acc->ChildAtPoint(
37 aX, aY, Accessible::EWhichChildAtPoint::DeepestChild)) {
38 RefPtr<IRawElementProviderFragment> fragment =
39 MsaaAccessible::GetFrom(target);
40 fragment.forget(aRetVal);
42 return S_OK;
45 STDMETHODIMP
46 UiaRoot::GetFocus(__RPC__deref_out_opt IRawElementProviderFragment** aRetVal) {
47 if (!aRetVal) {
48 return E_INVALIDARG;
50 *aRetVal = nullptr;
51 Accessible* acc = Acc();
52 if (!acc) {
53 return CO_E_OBJNOTCONNECTED;
55 if (Accessible* focus = acc->FocusedChild()) {
56 RefPtr<IRawElementProviderFragment> fragment =
57 MsaaAccessible::GetFrom(focus);
58 fragment.forget(aRetVal);
60 return S_OK;