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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/* -*- 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 "ProxyAccessibleWrap.h"
#include "Accessible-inl.h"
#include "nsPersistentProperties.h"
#include "mozilla/a11y/DocAccessiblePlatformExtParent.h"
using namespace mozilla::a11y;
ProxyAccessibleWrap::ProxyAccessibleWrap(ProxyAccessible* aProxy)
: AccessibleWrap(nullptr, nullptr) {
mType = eProxyType;
mBits.proxy = aProxy;
if (aProxy->mHasValue) {
mStateFlags |= eHasNumericValue;
}
if (aProxy->mIsSelection) {
mGenericTypes |= eSelect;
}
if (aProxy->mIsHyperText) {
mGenericTypes |= eHyperText;
}
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
Proxy()->Document()->GetWrapper());
if (doc) {
mID = AcquireID();
doc->AddID(mID, this);
}
}
void ProxyAccessibleWrap::Shutdown() {
auto doc = reinterpret_cast<DocProxyAccessibleWrap*>(
Proxy()->Document()->GetWrapper());
if (mID && doc) {
doc->RemoveID(mID);
ReleaseID(mID);
mID = 0;
}
mBits.proxy = nullptr;
mStateFlags |= eIsDefunct;
}
// Accessible
already_AddRefed<nsIPersistentProperties> ProxyAccessibleWrap::Attributes() {
AutoTArray<Attribute, 10> attrs;
Proxy()->Attributes(&attrs);
return AttributeArrayToProperties(attrs);
}
uint32_t ProxyAccessibleWrap::ChildCount() const {
return Proxy()->ChildrenCount();
}
Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const {
ProxyAccessible* child = Proxy()->ChildAt(aIndex);
return child ? WrapperFor(child) : nullptr;
}
ENameValueFlag ProxyAccessibleWrap::Name(nsString& aName) const {
Proxy()->Name(aName);
return eNameOK;
}
void ProxyAccessibleWrap::Value(nsString& aValue) const {
Proxy()->Value(aValue);
}
uint64_t ProxyAccessibleWrap::State() { return Proxy()->State(); }
nsIntRect ProxyAccessibleWrap::Bounds() const { return Proxy()->Bounds(); }
void ProxyAccessibleWrap::ScrollTo(uint32_t aHow) const {
Proxy()->ScrollTo(aHow);
}
uint8_t ProxyAccessibleWrap::ActionCount() const {
return Proxy()->ActionCount();
}
bool ProxyAccessibleWrap::DoAction(uint8_t aIndex) const {
return Proxy()->DoAction(aIndex);
}
// Other
void ProxyAccessibleWrap::SetTextContents(const nsAString& aText) {
Proxy()->ReplaceText(PromiseFlatString(aText));
}
void ProxyAccessibleWrap::GetTextContents(nsAString& aText) {
nsAutoString text;
Proxy()->TextSubstring(0, -1, text);
aText.Assign(text);
}
bool ProxyAccessibleWrap::GetSelectionBounds(int32_t* aStartOffset,
int32_t* aEndOffset) {
nsAutoString unused;
return Proxy()->SelectionBoundsAt(0, unused, aStartOffset, aEndOffset);
}
void ProxyAccessibleWrap::PivotTo(int32_t aGranularity, bool aForward,
bool aInclusive) {
Unused << Proxy()->Document()->GetPlatformExtension()->SendPivot(
Proxy()->ID(), aGranularity, aForward, aInclusive);
}
void ProxyAccessibleWrap::ExploreByTouch(float aX, float aY) {
Unused << Proxy()->Document()->GetPlatformExtension()->SendExploreByTouch(
Proxy()->ID(), aX, aY);
}
void ProxyAccessibleWrap::NavigateText(int32_t aGranularity,
int32_t aStartOffset, int32_t aEndOffset,
bool aForward, bool aSelect) {
Unused << Proxy()->Document()->GetPlatformExtension()->SendNavigateText(
Proxy()->ID(), aGranularity, aStartOffset, aEndOffset, aForward, aSelect);
}
void ProxyAccessibleWrap::SetSelection(int32_t aStart, int32_t aEnd) {
Unused << Proxy()->Document()->GetPlatformExtension()->SendSetSelection(
Proxy()->ID(), aStart, aEnd);
}
void ProxyAccessibleWrap::Cut() {
Unused << Proxy()->Document()->GetPlatformExtension()->SendCut(Proxy()->ID());
}
void ProxyAccessibleWrap::Copy() {
Unused << Proxy()->Document()->GetPlatformExtension()->SendCopy(
Proxy()->ID());
}
void ProxyAccessibleWrap::Paste() {
Unused << Proxy()->Document()->GetPlatformExtension()->SendPaste(
Proxy()->ID());
}
role ProxyAccessibleWrap::WrapperRole() { return Proxy()->Role(); }
AccessibleWrap* ProxyAccessibleWrap::WrapperParent() {
return Proxy()->Parent() ? WrapperFor(Proxy()->Parent()) : nullptr;
}
bool ProxyAccessibleWrap::WrapperRangeInfo(double* aCurVal, double* aMinVal,
double* aMaxVal, double* aStep) {
if (HasNumericValue()) {
ProxyAccessible* proxy = Proxy();
*aCurVal = proxy->CurValue();
*aMinVal = proxy->MinValue();
*aMaxVal = proxy->MaxValue();
*aStep = proxy->Step();
return true;
}
return false;
}
void ProxyAccessibleWrap::WrapperDOMNodeID(nsString& aDOMNodeID) {
Proxy()->DOMNodeID(aDOMNodeID);
}
|