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 "Accessible-inl.h"
8
9
#include "nsPersistentProperties.h"
10
11
#include "mozilla/a11y/DocAccessiblePlatformExtParent.h"
12
13
using namespace mozilla::a11y;
14
15
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
16
: AccessibleWrap(nullptr, nullptr) {
17
mType = eProxyType;
18
mBits.proxy = aProxy;
19
20
if (aProxy->mHasValue) {
21
mStateFlags |= eHasNumericValue;
22
}
23
24
if (aProxy->mIsSelection) {
25
mGenericTypes |= eSelect;
26
}
27
28
if (aProxy->mIsHyperText) {
29
mGenericTypes |= eHyperText;
30
}
31
32
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
33
Proxy()->Document()->GetWrapper());
34
if (doc) {
35
mID = AcquireID();
36
doc->AddID(mID, this);
37
}
38
}
39
40
void ProxyAccessibleWrap::Shutdown() {
41
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
42
Proxy()->Document()->GetWrapper());
43
if (mID && doc) {
44
doc->RemoveID(mID);
45
ReleaseID(mID);
46
mID = 0;
47
}
48
49
mBits.proxy = nullptr;
50
mStateFlags |= eIsDefunct;
51
}
52
53
// Accessible
54
55
already_AddRefed<nsIPersistentProperties> ProxyAccessibleWrap::Attributes() {
56
AutoTArray<Attribute, 10> attrs;
57
Proxy()->Attributes(&attrs);
58
return AttributeArrayToProperties(attrs);
59
}
60
61
uint32_t ProxyAccessibleWrap::ChildCount() const {
62
return Proxy()->ChildrenCount();
63
}
64
65
Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const {
66
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
67
return child ? WrapperFor(child) : nullptr;
68
}
69
70
ENameValueFlag ProxyAccessibleWrap::Name(nsString& aName) const {
71
Proxy()->Name(aName);
72
return eNameOK;
73
}
74
75
void ProxyAccessibleWrap::Value(nsString& aValue) const {
76
Proxy()->Value(aValue);
77
}
78
79
uint64_t ProxyAccessibleWrap::State() { return Proxy()->State(); }
80
81
nsIntRect ProxyAccessibleWrap::Bounds() const { return Proxy()->Bounds(); }
82
83
void ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const {
84
Proxy()->ScrollTo(aHow);
85
}
86
87
uint8_t ProxyAccessibleWrap::ActionCount() const {
88
return Proxy()->ActionCount();
89
}
90
91
bool ProxyAccessibleWrap::DoAction(uint8_t aIndex) const {
92
return Proxy()->DoAction(aIndex);
93
}
94
95
// Other
96
97
void ProxyAccessibleWrap::SetTextContents(const nsAString& aText) {
98
Proxy()->ReplaceText(PromiseFlatString(aText));
99
}
100
101
void ProxyAccessibleWrap::GetTextContents(nsAString& aText) {
102
nsAutoString text;
103
Proxy()->TextSubstring(0, -1, text);
104
aText.Assign(text);
105
}
106
107
bool ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
108
int32_t* aEndOffset) {
109
nsAutoString unused;
110
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
111
}
112
113
void ProxyAccessibleWrap::Pivot(int32_t aGranularity, bool aForward,
114
bool aInclusive) {
115
Unused << Proxy()->Document()->GetPlatformExtension()->SendPivot(
116
Proxy()->ID(), aGranularity, aForward, aInclusive);
117
}
118
119
void ProxyAccessibleWrap::ExploreByTouch(float aX, float aY) {
120
Unused << Proxy()->Document()->GetPlatformExtension()->SendExploreByTouch(
121
Proxy()->ID(), aX, aY);
122
}
123
124
void ProxyAccessibleWrap::NavigateText(int32_t aGranularity,
125
int32_t aStartOffset, int32_t aEndOffset,
126
bool aForward, bool aSelect) {
127
Unused << Proxy()->Document()->GetPlatformExtension()->SendNavigateText(
128
Proxy()->ID(), aGranularity, aStartOffset, aEndOffset, aForward, aSelect);
129
}
130
131
void ProxyAccessibleWrap::SetSelection(int32_t aStart, int32_t aEnd) {
132
Unused << Proxy()->Document()->GetPlatformExtension()->SendSetSelection(
133
Proxy()->ID(), aStart, aEnd);
134
}
135
136
void ProxyAccessibleWrap::Cut() {
137
Unused << Proxy()->Document()->GetPlatformExtension()->SendCut(Proxy()->ID());
138
}
139
140
void ProxyAccessibleWrap::Copy() {
141
Unused << Proxy()->Document()->GetPlatformExtension()->SendCopy(
142
Proxy()->ID());
143
}
144
145
void ProxyAccessibleWrap::Paste() {
146
Unused << Proxy()->Document()->GetPlatformExtension()->SendPaste(
147
Proxy()->ID());
148
}
149
150
role ProxyAccessibleWrap::WrapperRole() { return Proxy()->Role(); }
151
152
AccessibleWrap* ProxyAccessibleWrap::WrapperParent() {
153
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
154
}
155
156
bool ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
157
double* aMaxVal, double* aStep) {
158
if (HasNumericValue()) {
159
ProxyAccessible* proxy = Proxy();
160
*aCurVal = proxy->CurValue();
161
*aMinVal = proxy->MinValue();
162
*aMaxVal = proxy->MaxValue();
163
*aStep = proxy->Step();
164
return true;
165
}
166
167
return false;
168
}
169
170
void ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
171
Proxy()->DOMNodeID(aDOMNodeID);
172
}