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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "AccessibleOrProxy.h"
8 #include "mozilla/a11y/DocAccessibleParent.h"
9 #include "mozilla/a11y/OuterDocAccessible.h"
14 int32_t AccessibleOrProxy::IndexInParent() const {
16 return AsAccessible()->IndexInParent();
19 RemoteAccessible
* proxy
= AsProxy();
24 if (proxy
->RemoteParent()) {
25 return proxy
->IndexInParent();
28 if (proxy
->OuterDocOfRemoteBrowser()) {
32 MOZ_ASSERT_UNREACHABLE("Proxy should have parent or outer doc.");
36 AccessibleOrProxy
AccessibleOrProxy::Parent() const {
38 return AsAccessible()->LocalParent();
41 RemoteAccessible
* proxy
= AsProxy();
46 if (RemoteAccessible
* parent
= proxy
->RemoteParent()) {
50 // Otherwise this should be the proxy for the tab's top level document.
51 return proxy
->OuterDocOfRemoteBrowser();
54 AccessibleOrProxy
AccessibleOrProxy::ChildAtPoint(
55 int32_t aX
, int32_t aY
, Accessible::EWhichChildAtPoint aWhichChild
) {
56 // XXX: This implementation is silly now, but it will go away with AoP...
57 Accessible
* result
= IsProxy()
58 ? AsProxy()->ChildAtPoint(aX
, aY
, aWhichChild
)
59 : AsAccessible()->ChildAtPoint(aX
, aY
, aWhichChild
);
64 if (result
->IsLocal()) {
65 return result
->AsLocal();
68 if (result
->IsRemote()) {
69 return result
->AsRemote();
75 RemoteAccessible
* AccessibleOrProxy::RemoteChildDoc() const {
76 MOZ_ASSERT(!IsNull());
80 OuterDocAccessible
* outerDoc
= AsAccessible()->AsOuterDoc();
84 return outerDoc
->RemoteChildDoc();
88 } // namespace mozilla