summaryrefslogtreecommitdiffstats
path: root/accessible/base/AccessibleOrProxy.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /accessible/base/AccessibleOrProxy.cpp
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/base/AccessibleOrProxy.cpp')
-rw-r--r--accessible/base/AccessibleOrProxy.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/accessible/base/AccessibleOrProxy.cpp b/accessible/base/AccessibleOrProxy.cpp
new file mode 100644
index 0000000000..3826e6968c
--- /dev/null
+++ b/accessible/base/AccessibleOrProxy.cpp
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "AccessibleOrProxy.h"
+#include "mozilla/a11y/DocAccessibleParent.h"
+#include "mozilla/a11y/OuterDocAccessible.h"
+
+namespace mozilla {
+namespace a11y {
+
+int32_t AccessibleOrProxy::IndexInParent() const {
+ if (IsAccessible()) {
+ return AsAccessible()->IndexInParent();
+ }
+
+ ProxyAccessible* proxy = AsProxy();
+ if (!proxy) {
+ return -1;
+ }
+
+ if (proxy->Parent()) {
+ return proxy->IndexInParent();
+ }
+
+ if (proxy->OuterDocOfRemoteBrowser()) {
+ return 0;
+ }
+
+ MOZ_ASSERT_UNREACHABLE("Proxy should have parent or outer doc.");
+ return -1;
+}
+
+AccessibleOrProxy AccessibleOrProxy::Parent() const {
+ if (IsAccessible()) {
+ return AsAccessible()->Parent();
+ }
+
+ ProxyAccessible* proxy = AsProxy();
+ if (!proxy) {
+ return nullptr;
+ }
+
+ if (ProxyAccessible* parent = proxy->Parent()) {
+ return parent;
+ }
+
+ // Otherwise this should be the proxy for the tab's top level document.
+ return proxy->OuterDocOfRemoteBrowser();
+}
+
+AccessibleOrProxy AccessibleOrProxy::ChildAtPoint(
+ int32_t aX, int32_t aY, Accessible::EWhichChildAtPoint aWhichChild) {
+ if (IsProxy()) {
+ return AsProxy()->ChildAtPoint(aX, aY, aWhichChild);
+ }
+ ProxyAccessible* childDoc = RemoteChildDoc();
+ if (childDoc) {
+ // This is an OuterDocAccessible.
+ nsIntRect docRect = AsAccessible()->Bounds();
+ if (!docRect.Contains(aX, aY)) {
+ return nullptr;
+ }
+ if (aWhichChild == Accessible::eDirectChild) {
+ return childDoc;
+ }
+ return childDoc->ChildAtPoint(aX, aY, aWhichChild);
+ }
+ AccessibleOrProxy target = AsAccessible()->ChildAtPoint(aX, aY, aWhichChild);
+ if (target.IsNull() || aWhichChild == Accessible::eDirectChild) {
+ return target;
+ }
+ childDoc = target.RemoteChildDoc();
+ if (childDoc) {
+ // Accessible::ChildAtPoint stopped at an OuterDocAccessible, since it
+ // can't traverse into ProxyAccessibles. Continue the search from childDoc.
+ return childDoc->ChildAtPoint(aX, aY, aWhichChild);
+ }
+ return target;
+}
+
+ProxyAccessible* AccessibleOrProxy::RemoteChildDoc() const {
+ MOZ_ASSERT(!IsNull());
+ if (IsProxy()) {
+ return nullptr;
+ }
+ OuterDocAccessible* outerDoc = AsAccessible()->AsOuterDoc();
+ if (!outerDoc) {
+ return nullptr;
+ }
+ return outerDoc->RemoteChildDoc();
+}
+
+} // namespace a11y
+} // namespace mozilla