Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
ui::AXPlatformRelationWin Class Reference

#include <ax_platform_relation_win.h>

Inheritance diagram for ui::AXPlatformRelationWin:

Public Member Functions

 AXPlatformRelationWin ()
 
virtual ~AXPlatformRelationWin ()
 
void Initialize (const base::string16 &type)
 
void Invalidate ()
 
void AddTarget (AXPlatformNodeWin *target)
 
IFACEMETHODIMP get_relationType (BSTR *relation_type) override
 
IFACEMETHODIMP get_nTargets (LONG *n_targets) override
 
IFACEMETHODIMP get_target (LONG target_index, IUnknown **target) override
 
IFACEMETHODIMP get_targets (LONG max_targets, IUnknown **targets, LONG *n_targets) override
 
IFACEMETHODIMP get_localizedRelationType (BSTR *relation_type) override
 

Static Public Member Functions

static int EnumerateRelationships (AXPlatformNodeBase *node, int desired_index, const base::string16 &desired_ia2_relation, base::string16 *out_ia2_relation, std::set< AXPlatformNode * > *out_targets)
 

Detailed Description

Definition at line 32 of file ax_platform_relation_win.h.

Constructor & Destructor Documentation

◆ AXPlatformRelationWin()

ui::AXPlatformRelationWin::AXPlatformRelationWin ( )

Definition at line 34 of file ax_platform_relation_win.cc.

34 {
36}
void CreateATLModuleIfNeeded()
Definition: atl_module.h:22

◆ ~AXPlatformRelationWin()

ui::AXPlatformRelationWin::~AXPlatformRelationWin ( )
virtual

Definition at line 38 of file ax_platform_relation_win.cc.

38{}

Member Function Documentation

◆ AddTarget()

void ui::AXPlatformRelationWin::AddTarget ( AXPlatformNodeWin *  target)

Definition at line 256 of file ax_platform_relation_win.cc.

256 {
257 targets_.push_back(target);
258}
uint32_t * target

◆ EnumerateRelationships()

int ui::AXPlatformRelationWin::EnumerateRelationships ( AXPlatformNodeBase node,
int  desired_index,
const base::string16 &  desired_ia2_relation,
base::string16 *  out_ia2_relation,
std::set< AXPlatformNode * > *  out_targets 
)
static

Definition at line 108 of file ax_platform_relation_win.cc.

113 {
114 const AXNodeData& node_data = node->GetData();
115 AXPlatformNodeDelegate* delegate = node->GetDelegate();
116
117 // The first time this is called, populate vectors with all of the
118 // int attributes and intlist attributes that have reverse relations
119 // we care about on Windows. Computing these by calling
120 // GetIA2ReverseRelationFrom{Int|IntList}Attr on every possible attribute
121 // simplifies the work needed to support an additional relation
122 // attribute in the future.
123 static std::vector<ax::mojom::IntAttribute>
124 int_attributes_with_reverse_relations;
125 static std::vector<ax::mojom::IntListAttribute>
126 intlist_attributes_with_reverse_relations;
127 static bool first_time = true;
128 if (first_time) {
129 for (int32_t attr_index =
130 static_cast<int32_t>(ax::mojom::IntAttribute::kNone);
131 attr_index <= static_cast<int32_t>(ax::mojom::IntAttribute::kMaxValue);
132 ++attr_index) {
133 auto attr = static_cast<ax::mojom::IntAttribute>(attr_index);
134 if (!GetIA2ReverseRelationFromIntAttr(attr).empty())
135 int_attributes_with_reverse_relations.push_back(attr);
136 }
137 for (int32_t attr_index =
138 static_cast<int32_t>(ax::mojom::IntListAttribute::kNone);
139 attr_index <=
140 static_cast<int32_t>(ax::mojom::IntListAttribute::kMaxValue);
141 ++attr_index) {
142 auto attr = static_cast<ax::mojom::IntListAttribute>(attr_index);
143 if (!GetIA2ReverseRelationFromIntListAttr(attr).empty())
144 intlist_attributes_with_reverse_relations.push_back(attr);
145 }
146 first_time = false;
147 }
148
149 // Enumerate all of the relations and reverse relations that
150 // are exposed via IAccessible2 on Windows. We do this with a series
151 // of loops. Every time we encounter one, we check if the caller
152 // requested that particular relation by index, and return it.
153 // Otherwise we build up and return the total number of relations found.
154 int total_count = 0;
155
156 // Iterate over all int attributes on this node to check the ones
157 // that correspond to IAccessible2 relations.
158 for (size_t i = 0; i < node_data.int_attributes.size(); ++i) {
159 ax::mojom::IntAttribute int_attribute = node_data.int_attributes[i].first;
160 base::string16 relation = GetIA2RelationFromIntAttr(int_attribute);
161 if (!relation.empty() &&
162 (desired_ia2_relation.empty() || desired_ia2_relation == relation)) {
163 // Skip reflexive relations
164 if (node_data.int_attributes[i].second == node_data.id)
165 continue;
166 if (desired_index == total_count) {
167 *out_ia2_relation = relation;
168 out_targets->insert(
169 delegate->GetFromNodeID(node_data.int_attributes[i].second));
170 return 1;
171 }
172 total_count++;
173 }
174 }
175
176 // Iterate over all of the int attributes that have reverse relations
177 // in IAccessible2, and query AXTree to see if the reverse relation exists.
178 for (ax::mojom::IntAttribute int_attribute :
179 int_attributes_with_reverse_relations) {
180 base::string16 relation = GetIA2ReverseRelationFromIntAttr(int_attribute);
181 std::set<AXPlatformNode*> targets =
182 delegate->GetReverseRelations(int_attribute);
183 // Erase reflexive relations.
184 targets.erase(node);
185 if (targets.size()) {
186 if (!relation.empty() &&
187 (desired_ia2_relation.empty() || desired_ia2_relation == relation)) {
188 if (desired_index == total_count) {
189 *out_ia2_relation = relation;
190 *out_targets = targets;
191 return 1;
192 }
193 total_count++;
194 }
195 }
196 }
197
198 // Iterate over all intlist attributes on this node to check the ones
199 // that correspond to IAccessible2 relations.
200 for (size_t i = 0; i < node_data.intlist_attributes.size(); ++i) {
201 ax::mojom::IntListAttribute intlist_attribute =
202 node_data.intlist_attributes[i].first;
203 base::string16 relation = GetIA2RelationFromIntListAttr(intlist_attribute);
204 if (!relation.empty() &&
205 (desired_ia2_relation.empty() || desired_ia2_relation == relation)) {
206 if (desired_index == total_count) {
207 *out_ia2_relation = relation;
208 for (int32_t target_id : node_data.intlist_attributes[i].second) {
209 // Skip reflexive relations
210 if (target_id == node_data.id)
211 continue;
212 out_targets->insert(delegate->GetFromNodeID(target_id));
213 }
214 if (out_targets->size() == 0)
215 continue;
216 return 1;
217 }
218 total_count++;
219 }
220 }
221
222 // Iterate over all of the intlist attributes that have reverse relations
223 // in IAccessible2, and query AXTree to see if the reverse relation exists.
224 for (ax::mojom::IntListAttribute intlist_attribute :
225 intlist_attributes_with_reverse_relations) {
226 base::string16 relation =
227 GetIA2ReverseRelationFromIntListAttr(intlist_attribute);
228 std::set<AXPlatformNode*> targets =
229 delegate->GetReverseRelations(intlist_attribute);
230 // Erase reflexive relations.
231 targets.erase(node);
232 if (targets.size()) {
233 if (!relation.empty() &&
234 (desired_ia2_relation.empty() || desired_ia2_relation == relation)) {
235 if (desired_index == total_count) {
236 *out_ia2_relation = relation;
237 *out_targets = targets;
238 return 1;
239 }
240 total_count++;
241 }
242 }
243 }
244
245 return total_count;
246}
IntListAttribute
Definition: ax_enums.h:799
base::string16 GetIA2ReverseRelationFromIntAttr(ax::mojom::IntAttribute attribute)
base::string16 GetIA2RelationFromIntAttr(ax::mojom::IntAttribute attribute)
base::string16 GetIA2RelationFromIntListAttr(ax::mojom::IntListAttribute attribute)
base::string16 GetIA2ReverseRelationFromIntListAttr(ax::mojom::IntListAttribute attribute)

◆ get_localizedRelationType()

IFACEMETHODIMP ui::AXPlatformRelationWin::get_localizedRelationType ( BSTR *  relation_type)
override

Definition at line 315 of file ax_platform_relation_win.cc.

315 {
316 return E_NOTIMPL;
317}

◆ get_nTargets()

IFACEMETHODIMP ui::AXPlatformRelationWin::get_nTargets ( LONG n_targets)
override

Definition at line 269 of file ax_platform_relation_win.cc.

269 {
270 if (!n_targets)
271 return E_INVALIDARG;
272
273 *n_targets = static_cast<LONG>(targets_.size());
274 return S_OK;
275}
long LONG
Definition: windows_types.h:23

◆ get_relationType()

IFACEMETHODIMP ui::AXPlatformRelationWin::get_relationType ( BSTR *  relation_type)
override

Definition at line 260 of file ax_platform_relation_win.cc.

260 {
261 if (!relation_type)
262 return E_INVALIDARG;
263
264 *relation_type = SysAllocString(type_.c_str());
265 DCHECK(*relation_type);
266 return S_OK;
267}

◆ get_target()

IFACEMETHODIMP ui::AXPlatformRelationWin::get_target ( LONG  target_index,
IUnknown **  target 
)
override

Definition at line 277 of file ax_platform_relation_win.cc.

278 {
279 if (!target)
280 return E_INVALIDARG;
281
282 if (target_index < 0 || target_index >= static_cast<LONG>(targets_.size())) {
283 return E_INVALIDARG;
284 }
285
286 *target = static_cast<IAccessible*>(targets_[target_index].Get());
287 (*target)->AddRef();
288 return S_OK;
289}

◆ get_targets()

IFACEMETHODIMP ui::AXPlatformRelationWin::get_targets ( LONG  max_targets,
IUnknown **  targets,
LONG n_targets 
)
override

Definition at line 291 of file ax_platform_relation_win.cc.

293 {
294 if (!targets || !n_targets)
295 return E_INVALIDARG;
296
297 LONG count = static_cast<LONG>(targets_.size());
298 if (count > max_targets)
299 count = max_targets;
300
301 *n_targets = count;
302 if (count == 0)
303 return S_FALSE;
304
305 for (LONG i = 0; i < count; ++i) {
306 HRESULT result = get_target(i, &targets[i]);
307 if (result != S_OK)
308 return result;
309 }
310
311 return S_OK;
312}
int count
Definition: FontMgrTest.cpp:50
IFACEMETHODIMP get_target(LONG target_index, IUnknown **target) override
GAsyncResult * result

◆ Initialize()

void ui::AXPlatformRelationWin::Initialize ( const base::string16 &  type)

Definition at line 248 of file ax_platform_relation_win.cc.

248 {
249 type_ = type;
250}
GLenum type

◆ Invalidate()

void ui::AXPlatformRelationWin::Invalidate ( )

Definition at line 252 of file ax_platform_relation_win.cc.

252 {
253 targets_.clear();
254}

The documentation for this class was generated from the following files: