Source code

Revision control

Other Tools

1
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
2
* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "ProxyAccessibleWrap.h"
7
#include "nsPersistentProperties.h"
8
9
using namespace mozilla::a11y;
10
11
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
12
: AccessibleWrap(nullptr, nullptr) {
13
mType = eProxyType;
14
mBits.proxy = aProxy;
15
16
if (aProxy->mHasValue) {
17
mStateFlags |= eHasNumericValue;
18
}
19
20
if (aProxy->mIsSelection) {
21
mGenericTypes |= eSelect;
22
}
23
24
if (aProxy->mIsHyperText) {
25
mGenericTypes |= eHyperText;
26
}
27
28
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
29
Proxy()->Document()->GetWrapper());
30
if (doc) {
31
mID = AcquireID();
32
doc->AddID(mID, this);
33
}
34
}
35
36
void ProxyAccessibleWrap::Shutdown() {
37
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
38
Proxy()->Document()->GetWrapper());
39
if (mID && doc) {
40
doc->RemoveID(mID);
41
ReleaseID(mID);
42
mID = 0;
43
}
44
45
mBits.proxy = nullptr;
46
mStateFlags |= eIsDefunct;
47
}
48
49
// Accessible
50
51
already_AddRefed<nsIPersistentProperties> ProxyAccessibleWrap::Attributes() {
52
AutoTArray<Attribute, 10> attrs;
53
Proxy()->Attributes(&attrs);
54
return AttributeArrayToProperties(attrs);
55
}
56
57
uint32_t ProxyAccessibleWrap::ChildCount() const {
58
return Proxy()->ChildrenCount();
59
}
60
61
Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const {
62
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
63
return child ? WrapperFor(child) : nullptr;
64
}
65
66
ENameValueFlag ProxyAccessibleWrap::Name(nsString& aName) const {
67
Proxy()->Name(aName);
68
return eNameOK;
69
}
70
71
void ProxyAccessibleWrap::Value(nsString& aValue) const {
72
Proxy()->Value(aValue);
73
}
74
75
uint64_t ProxyAccessibleWrap::State() { return Proxy()->State(); }
76
77
nsIntRect ProxyAccessibleWrap::Bounds() const { return Proxy()->Bounds(); }
78
79
void ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const {
80
Proxy()->ScrollTo(aHow);
81
}
82
83
uint8_t ProxyAccessibleWrap::ActionCount() const {
84
return Proxy()->ActionCount();
85
}
86
87
bool ProxyAccessibleWrap::DoAction(uint8_t aIndex) const {
88
return Proxy()->DoAction(aIndex);
89
}
90
91
// Other
92
93
void ProxyAccessibleWrap::SetTextContents(const nsAString& aText) {
94
Proxy()->ReplaceText(PromiseFlatString(aText));
95
}
96
97
void ProxyAccessibleWrap::GetTextContents(nsAString& aText) {
98
nsAutoString text;
99
Proxy()->TextSubstring(0, -1, text);
100
aText.Assign(text);
101
}
102
103
bool ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
104
int32_t* aEndOffset) {
105
nsAutoString unused;
106
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
107
}
108
109
role ProxyAccessibleWrap::WrapperRole() { return Proxy()->Role(); }
110
111
AccessibleWrap* ProxyAccessibleWrap::WrapperParent() {
112
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
113
}
114
115
bool ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
116
double* aMaxVal, double* aStep) {
117
if (HasNumericValue()) {
118
ProxyAccessible* proxy = Proxy();
119
*aCurVal = proxy->CurValue();
120
*aMinVal = proxy->MinValue();
121
*aMaxVal = proxy->MaxValue();
122
*aStep = proxy->Step();
123
return true;
124
}
125
126
return false;
127
}
128
129
void ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
130
Proxy()->DOMNodeID(aDOMNodeID);
131
}