blob: 6a9430da25cf677f6372850915a679acece89dba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
* 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 "RootAccessibleWrap.h"
#include "Accessible-inl.h"
#include "AccessibleOrProxy.h"
#include "DocAccessibleParent.h"
#include "DocAccessible-inl.h"
#include "ProxyAccessibleWrap.h"
#include "SessionAccessibility.h"
#include "mozilla/PresShell.h"
using namespace mozilla;
using namespace mozilla::a11y;
RootAccessibleWrap::RootAccessibleWrap(dom::Document* aDoc,
PresShell* aPresShell)
: RootAccessible(aDoc, aPresShell) {}
RootAccessibleWrap::~RootAccessibleWrap() {}
AccessibleWrap* RootAccessibleWrap::GetContentAccessible() {
if (ProxyAccessible* proxy = GetPrimaryRemoteTopLevelContentDoc()) {
return WrapperFor(proxy);
}
// Find first document that is not defunct or hidden.
// This is exclusively for Fennec which has a deck of browser elements.
// Otherwise, standard GeckoView will only have one browser element.
for (size_t i = 0; i < ChildDocumentCount(); i++) {
DocAccessible* childDoc = GetChildDocumentAt(i);
if (childDoc && !childDoc->IsDefunct() && !childDoc->IsHidden()) {
return childDoc;
}
}
return nullptr;
}
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(int32_t aID) {
AccessibleWrap* contentAcc = GetContentAccessible();
if (!contentAcc) {
return nullptr;
}
if (aID == AccessibleWrap::kNoID) {
return contentAcc;
}
if (contentAcc->IsProxy()) {
return FindAccessibleById(static_cast<DocProxyAccessibleWrap*>(contentAcc),
aID);
}
return FindAccessibleById(
static_cast<DocAccessibleWrap*>(contentAcc->AsDoc()), aID);
}
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(
DocProxyAccessibleWrap* aDoc, int32_t aID) {
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
uint32_t index = 0;
while (!acc) {
auto child =
static_cast<DocProxyAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
if (!child) {
break;
}
// A child document's id is not in its parent document's hash table.
if (child->VirtualViewID() == aID) {
acc = child;
} else {
acc = FindAccessibleById(child, aID);
}
}
return acc;
}
AccessibleWrap* RootAccessibleWrap::FindAccessibleById(DocAccessibleWrap* aDoc,
int32_t aID) {
AccessibleWrap* acc = aDoc->GetAccessibleByID(aID);
uint32_t index = 0;
while (!acc) {
auto child =
static_cast<DocAccessibleWrap*>(aDoc->GetChildDocumentAt(index++));
if (!child) {
break;
}
acc = FindAccessibleById(child, aID);
}
return acc;
}
|