Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/xpcom/xpcAccessible.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "Accessible-inl.h"
8
#include "mozilla/a11y/DocAccessibleParent.h"
9
#include "nsAccUtils.h"
10
#include "nsIAccessibleRelation.h"
11
#include "nsIAccessibleRole.h"
12
#include "nsAccessibleRelation.h"
13
#include "Relation.h"
14
#include "Role.h"
15
#include "RootAccessible.h"
16
#include "xpcAccessibleDocument.h"
17
18
#include "nsIMutableArray.h"
19
#include "nsPersistentProperties.h"
20
21
using namespace mozilla::a11y;
22
23
NS_IMETHODIMP
24
xpcAccessible::GetParent(nsIAccessible** aParent)
25
0
{
26
0
  NS_ENSURE_ARG_POINTER(aParent);
27
0
  *aParent = nullptr;
28
0
  if (IntlGeneric().IsNull())
29
0
    return NS_ERROR_FAILURE;
30
0
31
0
  AccessibleOrProxy parent = IntlGeneric().Parent();
32
0
  NS_IF_ADDREF(*aParent = ToXPC(parent));
33
0
  return NS_OK;
34
0
}
35
36
NS_IMETHODIMP
37
xpcAccessible::GetNextSibling(nsIAccessible** aNextSibling)
38
0
{
39
0
  NS_ENSURE_ARG_POINTER(aNextSibling);
40
0
  *aNextSibling = nullptr;
41
0
  if (IntlGeneric().IsNull())
42
0
    return NS_ERROR_FAILURE;
43
0
44
0
  if (IntlGeneric().IsAccessible()) {
45
0
    nsresult rv = NS_OK;
46
0
    NS_IF_ADDREF(*aNextSibling = ToXPC(Intl()->GetSiblingAtOffset(1, &rv)));
47
0
    return rv;
48
0
  }
49
0
50
0
  ProxyAccessible* proxy = IntlGeneric().AsProxy();
51
0
  NS_ENSURE_STATE(proxy);
52
0
53
0
  NS_IF_ADDREF(*aNextSibling = ToXPC(proxy->NextSibling()));
54
0
  return *aNextSibling ? NS_OK : NS_ERROR_FAILURE;
55
0
}
56
57
NS_IMETHODIMP
58
xpcAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
59
0
{
60
0
  NS_ENSURE_ARG_POINTER(aPreviousSibling);
61
0
  *aPreviousSibling = nullptr;
62
0
  if (IntlGeneric().IsNull())
63
0
    return NS_ERROR_FAILURE;
64
0
65
0
  if (IntlGeneric().IsAccessible()) {
66
0
    nsresult rv = NS_OK;
67
0
    NS_IF_ADDREF(*aPreviousSibling = ToXPC(Intl()->GetSiblingAtOffset(-1, &rv)));
68
0
    return rv;
69
0
  }
70
0
71
0
  ProxyAccessible* proxy = IntlGeneric().AsProxy();
72
0
  NS_ENSURE_STATE(proxy);
73
0
74
0
  NS_IF_ADDREF(*aPreviousSibling = ToXPC(proxy->PrevSibling()));
75
0
  return *aPreviousSibling ? NS_OK : NS_ERROR_FAILURE;
76
0
}
77
78
NS_IMETHODIMP
79
xpcAccessible::GetFirstChild(nsIAccessible** aFirstChild)
80
0
{
81
0
  NS_ENSURE_ARG_POINTER(aFirstChild);
82
0
  *aFirstChild = nullptr;
83
0
84
0
  if (IntlGeneric().IsNull())
85
0
    return NS_ERROR_FAILURE;
86
0
87
0
  NS_IF_ADDREF(*aFirstChild = ToXPC(IntlGeneric().FirstChild()));
88
0
  return NS_OK;
89
0
}
90
91
NS_IMETHODIMP
92
xpcAccessible::GetLastChild(nsIAccessible** aLastChild)
93
0
{
94
0
  NS_ENSURE_ARG_POINTER(aLastChild);
95
0
  *aLastChild = nullptr;
96
0
97
0
  if (IntlGeneric().IsNull())
98
0
    return NS_ERROR_FAILURE;
99
0
100
0
  NS_IF_ADDREF(*aLastChild = ToXPC(IntlGeneric().LastChild()));
101
0
  return NS_OK;
102
0
}
103
104
NS_IMETHODIMP
105
xpcAccessible::GetChildCount(int32_t* aChildCount)
106
0
{
107
0
  NS_ENSURE_ARG_POINTER(aChildCount);
108
0
109
0
  if (IntlGeneric().IsNull())
110
0
    return NS_ERROR_FAILURE;
111
0
112
0
  *aChildCount = IntlGeneric().ChildCount();
113
0
  return NS_OK;
114
0
}
115
116
NS_IMETHODIMP
117
xpcAccessible::GetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
118
0
{
119
0
  NS_ENSURE_ARG_POINTER(aChild);
120
0
  *aChild = nullptr;
121
0
122
0
  if (IntlGeneric().IsNull())
123
0
    return NS_ERROR_FAILURE;
124
0
125
0
  // If child index is negative, then return last child.
126
0
  // XXX: do we really need this?
127
0
  if (aChildIndex < 0)
128
0
    aChildIndex = IntlGeneric().ChildCount() - 1;
129
0
130
0
  AccessibleOrProxy child = IntlGeneric().ChildAt(aChildIndex);
131
0
  if (child.IsNull())
132
0
    return NS_ERROR_INVALID_ARG;
133
0
134
0
  NS_ADDREF(*aChild = ToXPC(child));
135
0
  return NS_OK;
136
0
}
137
138
NS_IMETHODIMP
139
xpcAccessible::GetChildren(nsIArray** aChildren)
140
0
{
141
0
  NS_ENSURE_ARG_POINTER(aChildren);
142
0
  *aChildren = nullptr;
143
0
144
0
  if (IntlGeneric().IsNull())
145
0
    return NS_ERROR_FAILURE;
146
0
147
0
  nsresult rv = NS_OK;
148
0
  nsCOMPtr<nsIMutableArray> children =
149
0
    do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
150
0
  NS_ENSURE_SUCCESS(rv, rv);
151
0
152
0
  uint32_t childCount = IntlGeneric().ChildCount();
153
0
  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
154
0
    AccessibleOrProxy child = IntlGeneric().ChildAt(childIdx);
155
0
    children->AppendElement(static_cast<nsIAccessible*>(ToXPC(child)));
156
0
  }
157
0
158
0
  children.forget(aChildren);
159
0
  return NS_OK;
160
0
}
161
162
NS_IMETHODIMP
163
xpcAccessible::GetIndexInParent(int32_t* aIndexInParent)
164
0
{
165
0
  NS_ENSURE_ARG_POINTER(aIndexInParent);
166
0
  *aIndexInParent = -1;
167
0
  if (IntlGeneric().IsNull())
168
0
    return NS_ERROR_FAILURE;
169
0
170
0
  if (IntlGeneric().IsAccessible()) {
171
0
    *aIndexInParent = Intl()->IndexInParent();
172
0
  } else if (IntlGeneric().IsProxy()) {
173
0
    *aIndexInParent = IntlGeneric().AsProxy()->IndexInParent();
174
0
  }
175
0
176
0
  return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
177
0
}
178
179
NS_IMETHODIMP
180
xpcAccessible::GetDOMNode(nsINode** aDOMNode)
181
0
{
182
0
  NS_ENSURE_ARG_POINTER(aDOMNode);
183
0
  *aDOMNode = nullptr;
184
0
185
0
  if (!Intl())
186
0
    return NS_ERROR_FAILURE;
187
0
188
0
  nsCOMPtr<nsINode> node = Intl()->GetNode();
189
0
  node.forget(aDOMNode);
190
0
191
0
  return NS_OK;
192
0
}
193
194
NS_IMETHODIMP
195
xpcAccessible::GetId(nsAString& aID)
196
0
{
197
0
  ProxyAccessible* proxy = IntlGeneric().AsProxy();
198
0
  if (!proxy) {
199
0
    return NS_ERROR_FAILURE;
200
0
  }
201
0
202
0
  nsString id;
203
0
  proxy->DOMNodeID(id);
204
0
  aID.Assign(id);
205
0
206
0
  return NS_OK;
207
0
}
208
209
NS_IMETHODIMP
210
xpcAccessible::GetDocument(nsIAccessibleDocument** aDocument)
211
0
{
212
0
  NS_ENSURE_ARG_POINTER(aDocument);
213
0
  *aDocument = nullptr;
214
0
215
0
  if (!Intl())
216
0
    return NS_ERROR_FAILURE;
217
0
218
0
  NS_IF_ADDREF(*aDocument = ToXPCDocument(Intl()->Document()));
219
0
  return NS_OK;
220
0
}
221
222
NS_IMETHODIMP
223
xpcAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
224
0
{
225
0
  NS_ENSURE_ARG_POINTER(aRootDocument);
226
0
  *aRootDocument = nullptr;
227
0
228
0
  if (!Intl())
229
0
    return NS_ERROR_FAILURE;
230
0
231
0
  NS_IF_ADDREF(*aRootDocument = ToXPCDocument(Intl()->RootAccessible()));
232
0
  return NS_OK;
233
0
}
234
235
NS_IMETHODIMP
236
xpcAccessible::GetRole(uint32_t* aRole)
237
0
{
238
0
  NS_ENSURE_ARG_POINTER(aRole);
239
0
  *aRole = nsIAccessibleRole::ROLE_NOTHING;
240
0
241
0
  if (IntlGeneric().IsNull())
242
0
    return NS_ERROR_FAILURE;
243
0
244
0
  *aRole = IntlGeneric().Role();
245
0
  return NS_OK;
246
0
}
247
248
NS_IMETHODIMP
249
xpcAccessible::GetState(uint32_t* aState, uint32_t* aExtraState)
250
0
{
251
0
  NS_ENSURE_ARG_POINTER(aState);
252
0
253
0
  if (IntlGeneric().IsNull())
254
0
    nsAccUtils::To32States(states::DEFUNCT, aState, aExtraState);
255
0
  else if (Intl())
256
0
    nsAccUtils::To32States(Intl()->State(), aState, aExtraState);
257
0
  else
258
0
    nsAccUtils::To32States(IntlGeneric().AsProxy()->State(), aState,
259
0
                           aExtraState);
260
0
261
0
  return NS_OK;
262
0
}
263
264
NS_IMETHODIMP
265
xpcAccessible::GetName(nsAString& aName)
266
0
{
267
0
  aName.Truncate();
268
0
269
0
  if (IntlGeneric().IsNull())
270
0
    return NS_ERROR_FAILURE;
271
0
272
0
  nsAutoString name;
273
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
274
0
    proxy->Name(name);
275
0
  } else {
276
0
    Intl()->Name(name);
277
0
  }
278
0
279
0
  aName.Assign(name);
280
0
281
0
  return NS_OK;
282
0
}
283
284
NS_IMETHODIMP
285
xpcAccessible::GetDescription(nsAString& aDescription)
286
0
{
287
0
  if (IntlGeneric().IsNull())
288
0
    return NS_ERROR_FAILURE;
289
0
290
0
  nsAutoString desc;
291
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
292
0
    proxy->Description(desc);
293
0
  } else {
294
0
    Intl()->Description(desc);
295
0
  }
296
0
297
0
  aDescription.Assign(desc);
298
0
299
0
  return NS_OK;
300
0
}
301
302
NS_IMETHODIMP
303
xpcAccessible::GetLanguage(nsAString& aLanguage)
304
0
{
305
0
  if (IntlGeneric().IsNull())
306
0
    return NS_ERROR_FAILURE;
307
0
308
0
  nsAutoString lang;
309
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
310
0
    proxy->Language(lang);
311
0
  } else {
312
0
    Intl()->Language(lang);
313
0
  }
314
0
315
0
  aLanguage.Assign(lang);
316
0
  return NS_OK;
317
0
}
318
319
NS_IMETHODIMP
320
xpcAccessible::GetValue(nsAString& aValue)
321
0
{
322
0
  if (IntlGeneric().IsNull())
323
0
    return NS_ERROR_FAILURE;
324
0
325
0
  nsAutoString value;
326
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
327
0
    proxy->Value(value);
328
0
  } else {
329
0
    Intl()->Value(value);
330
0
  }
331
0
332
0
  aValue.Assign(value);
333
0
334
0
  return NS_OK;
335
0
}
336
337
NS_IMETHODIMP
338
xpcAccessible::GetHelp(nsAString& aHelp)
339
0
{
340
0
  if (IntlGeneric().IsNull())
341
0
    return NS_ERROR_FAILURE;
342
0
343
0
  nsAutoString help;
344
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
345
#if defined(XP_WIN)
346
    return NS_ERROR_NOT_IMPLEMENTED;
347
#else
348
    proxy->Help(help);
349
0
#endif
350
0
  } else {
351
0
    Intl()->Help(help);
352
0
  }
353
0
354
0
  aHelp.Assign(help);
355
0
356
0
  return NS_OK;
357
0
}
358
359
NS_IMETHODIMP
360
xpcAccessible::GetAccessKey(nsAString& aAccessKey)
361
0
{
362
0
  aAccessKey.Truncate();
363
0
364
0
  if (IntlGeneric().IsNull())
365
0
    return NS_ERROR_FAILURE;
366
0
367
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
368
#if defined(XP_WIN)
369
    return NS_ERROR_NOT_IMPLEMENTED;
370
#else
371
    proxy->AccessKey().ToString(aAccessKey);
372
0
#endif
373
0
  } else {
374
0
    Intl()->AccessKey().ToString(aAccessKey);
375
0
  }
376
0
377
0
  return NS_OK;
378
0
}
379
380
NS_IMETHODIMP
381
xpcAccessible::GetKeyboardShortcut(nsAString& aKeyBinding)
382
0
{
383
0
  aKeyBinding.Truncate();
384
0
  if (IntlGeneric().IsNull())
385
0
    return NS_ERROR_FAILURE;
386
0
387
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
388
#if defined(XP_WIN)
389
    return NS_ERROR_NOT_IMPLEMENTED;
390
#else
391
    proxy->KeyboardShortcut().ToString(aKeyBinding);
392
0
#endif
393
0
  } else {
394
0
    Intl()->KeyboardShortcut().ToString(aKeyBinding);
395
0
  }
396
0
  return NS_OK;
397
0
}
398
399
NS_IMETHODIMP
400
xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
401
0
{
402
0
  NS_ENSURE_ARG_POINTER(aAttributes);
403
0
  *aAttributes = nullptr;
404
0
405
0
  if (IntlGeneric().IsNull()) {
406
0
    return NS_ERROR_FAILURE;
407
0
  }
408
0
409
0
  if (Accessible* acc = Intl()) {
410
0
    nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
411
0
    attributes.swap(*aAttributes);
412
0
    return NS_OK;
413
0
  }
414
0
415
0
  ProxyAccessible* proxy = IntlGeneric().AsProxy();
416
0
  AutoTArray<Attribute, 10> attrs;
417
0
  proxy->Attributes(&attrs);
418
0
419
0
  RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
420
0
  uint32_t attrCount = attrs.Length();
421
0
  nsAutoString unused;
422
0
  for (uint32_t i = 0; i < attrCount; i++) {
423
0
    props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused);
424
0
  }
425
0
426
0
  props.forget(aAttributes);
427
0
  return NS_OK;
428
0
}
429
430
NS_IMETHODIMP
431
xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
432
                         int32_t* aWidth, int32_t* aHeight)
433
0
{
434
0
  NS_ENSURE_ARG_POINTER(aX);
435
0
  *aX = 0;
436
0
  NS_ENSURE_ARG_POINTER(aY);
437
0
  *aY = 0;
438
0
  NS_ENSURE_ARG_POINTER(aWidth);
439
0
  *aWidth = 0;
440
0
  NS_ENSURE_ARG_POINTER(aHeight);
441
0
  *aHeight = 0;
442
0
443
0
  if (IntlGeneric().IsNull())
444
0
    return NS_ERROR_FAILURE;
445
0
446
0
  nsIntRect rect;
447
0
  if (Accessible* acc = IntlGeneric().AsAccessible()) {
448
0
    rect = acc->Bounds();
449
0
  } else {
450
0
    rect = IntlGeneric().AsProxy()->Bounds();
451
0
  }
452
0
453
0
  rect.GetRect(aX, aY, aWidth, aHeight);
454
0
  return NS_OK;
455
0
}
456
457
NS_IMETHODIMP
458
xpcAccessible::GetBoundsInCSSPixels(int32_t* aX, int32_t* aY,
459
                                  int32_t* aWidth, int32_t* aHeight)
460
0
{
461
0
  NS_ENSURE_ARG_POINTER(aX);
462
0
  *aX = 0;
463
0
  NS_ENSURE_ARG_POINTER(aY);
464
0
  *aY = 0;
465
0
  NS_ENSURE_ARG_POINTER(aWidth);
466
0
  *aWidth = 0;
467
0
  NS_ENSURE_ARG_POINTER(aHeight);
468
0
  *aHeight = 0;
469
0
470
0
  if (IntlGeneric().IsNull()) {
471
0
    return NS_ERROR_FAILURE;
472
0
  }
473
0
474
0
  nsIntRect rect;
475
0
  if (Accessible* acc = IntlGeneric().AsAccessible()) {
476
0
    rect = acc->BoundsInCSSPixels();
477
0
  } else {
478
0
    rect = IntlGeneric().AsProxy()->BoundsInCSSPixels();
479
0
  }
480
0
481
0
  rect.GetRect(aX, aY, aWidth, aHeight);
482
0
  return NS_OK;
483
0
}
484
485
NS_IMETHODIMP
486
xpcAccessible::GroupPosition(int32_t* aGroupLevel,
487
                             int32_t* aSimilarItemsInGroup,
488
                             int32_t* aPositionInGroup)
489
0
{
490
0
  NS_ENSURE_ARG_POINTER(aGroupLevel);
491
0
  *aGroupLevel = 0;
492
0
493
0
  NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
494
0
  *aSimilarItemsInGroup = 0;
495
0
496
0
  NS_ENSURE_ARG_POINTER(aPositionInGroup);
497
0
  *aPositionInGroup = 0;
498
0
499
0
  if (!Intl())
500
0
    return NS_ERROR_FAILURE;
501
0
502
0
  GroupPos groupPos = Intl()->GroupPosition();
503
0
504
0
  *aGroupLevel = groupPos.level;
505
0
  *aSimilarItemsInGroup = groupPos.setSize;
506
0
  *aPositionInGroup = groupPos.posInSet;
507
0
508
0
  return NS_OK;
509
0
}
510
511
NS_IMETHODIMP
512
xpcAccessible::GetRelationByType(uint32_t aType,
513
                                 nsIAccessibleRelation** aRelation)
514
0
{
515
0
  NS_ENSURE_ARG_POINTER(aRelation);
516
0
  *aRelation = nullptr;
517
0
518
0
  NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
519
0
520
0
  if (IntlGeneric().IsNull())
521
0
    return NS_ERROR_FAILURE;
522
0
523
0
  if (IntlGeneric().IsAccessible()) {
524
0
    Relation rel = Intl()->RelationByType(static_cast<RelationType>(aType));
525
0
    NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
526
0
    return NS_OK;
527
0
  }
528
0
529
0
  ProxyAccessible* proxy = IntlGeneric().AsProxy();
530
0
  nsTArray<ProxyAccessible*> targets =
531
0
    proxy->RelationByType(static_cast<RelationType>(aType));
532
0
  NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &targets));
533
0
534
0
  return NS_OK;
535
0
}
536
537
NS_IMETHODIMP
538
xpcAccessible::GetRelations(nsIArray** aRelations)
539
0
{
540
0
  NS_ENSURE_ARG_POINTER(aRelations);
541
0
  *aRelations = nullptr;
542
0
543
0
  if (IntlGeneric().IsNull())
544
0
    return NS_ERROR_FAILURE;
545
0
546
0
  nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
547
0
  NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
548
0
549
0
  static const uint32_t relationTypes[] = {
550
0
    nsIAccessibleRelation::RELATION_LABELLED_BY,
551
0
    nsIAccessibleRelation::RELATION_LABEL_FOR,
552
0
    nsIAccessibleRelation::RELATION_DESCRIBED_BY,
553
0
    nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
554
0
    nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
555
0
    nsIAccessibleRelation::RELATION_NODE_PARENT_OF,
556
0
    nsIAccessibleRelation::RELATION_CONTROLLED_BY,
557
0
    nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
558
0
    nsIAccessibleRelation::RELATION_FLOWS_TO,
559
0
    nsIAccessibleRelation::RELATION_FLOWS_FROM,
560
0
    nsIAccessibleRelation::RELATION_MEMBER_OF,
561
0
    nsIAccessibleRelation::RELATION_SUBWINDOW_OF,
562
0
    nsIAccessibleRelation::RELATION_EMBEDS,
563
0
    nsIAccessibleRelation::RELATION_EMBEDDED_BY,
564
0
    nsIAccessibleRelation::RELATION_POPUP_FOR,
565
0
    nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF,
566
0
    nsIAccessibleRelation::RELATION_DEFAULT_BUTTON,
567
0
    nsIAccessibleRelation::RELATION_CONTAINING_DOCUMENT,
568
0
    nsIAccessibleRelation::RELATION_CONTAINING_TAB_PANE,
569
0
    nsIAccessibleRelation::RELATION_CONTAINING_APPLICATION
570
0
  };
571
0
572
0
  for (uint32_t idx = 0; idx < ArrayLength(relationTypes); idx++) {
573
0
    nsCOMPtr<nsIAccessibleRelation> relation;
574
0
    nsresult rv = GetRelationByType(relationTypes[idx], getter_AddRefs(relation));
575
0
576
0
    if (NS_SUCCEEDED(rv) && relation) {
577
0
      uint32_t targets = 0;
578
0
      relation->GetTargetsCount(&targets);
579
0
      if (targets)
580
0
        relations->AppendElement(relation);
581
0
    }
582
0
  }
583
0
584
0
  NS_ADDREF(*aRelations = relations);
585
0
  return NS_OK;
586
0
}
587
588
NS_IMETHODIMP
589
xpcAccessible::GetFocusedChild(nsIAccessible** aChild)
590
0
{
591
0
  NS_ENSURE_ARG_POINTER(aChild);
592
0
  *aChild = nullptr;
593
0
594
0
  if (IntlGeneric().IsNull())
595
0
    return NS_ERROR_FAILURE;
596
0
597
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
598
#if defined(XP_WIN)
599
    return NS_ERROR_NOT_IMPLEMENTED;
600
#else
601
0
    NS_IF_ADDREF(*aChild = ToXPC(proxy->FocusedChild()));
602
0
#endif
603
0
  } else {
604
0
    NS_IF_ADDREF(*aChild = ToXPC(Intl()->FocusedChild()));
605
0
  }
606
0
607
0
  return NS_OK;
608
0
}
609
610
NS_IMETHODIMP
611
xpcAccessible::GetChildAtPoint(int32_t aX, int32_t aY,
612
                               nsIAccessible** aAccessible)
613
0
{
614
0
  NS_ENSURE_ARG_POINTER(aAccessible);
615
0
  *aAccessible = nullptr;
616
0
617
0
  if (IntlGeneric().IsNull())
618
0
    return NS_ERROR_FAILURE;
619
0
620
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
621
#if defined(XP_WIN)
622
    return NS_ERROR_NOT_IMPLEMENTED;
623
#else
624
0
    NS_IF_ADDREF(*aAccessible =
625
0
                 ToXPC(proxy->ChildAtPoint(aX, aY, Accessible::eDirectChild)));
626
0
#endif
627
0
  } else {
628
0
    NS_IF_ADDREF(*aAccessible =
629
0
                 ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDirectChild)));
630
0
  }
631
0
632
0
  return NS_OK;
633
0
}
634
635
NS_IMETHODIMP
636
xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
637
                                      nsIAccessible** aAccessible)
638
0
{
639
0
  NS_ENSURE_ARG_POINTER(aAccessible);
640
0
  *aAccessible = nullptr;
641
0
642
0
  if (IntlGeneric().IsNull())
643
0
    return NS_ERROR_FAILURE;
644
0
645
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
646
#if defined(XP_WIN)
647
    return NS_ERROR_NOT_IMPLEMENTED;
648
#else
649
0
    NS_IF_ADDREF(*aAccessible =
650
0
                 ToXPC(proxy->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
651
0
#endif
652
0
  } else {
653
0
    NS_IF_ADDREF(*aAccessible =
654
0
                 ToXPC(Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
655
0
  }
656
0
657
0
  return NS_OK;
658
0
}
659
660
NS_IMETHODIMP
661
xpcAccessible::SetSelected(bool aSelect)
662
0
{
663
0
  if (IntlGeneric().IsNull())
664
0
    return NS_ERROR_FAILURE;
665
0
666
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
667
#if defined(XP_WIN)
668
    return NS_ERROR_NOT_IMPLEMENTED;
669
#else
670
    proxy->SetSelected(aSelect);
671
0
#endif
672
0
  } else {
673
0
    Intl()->SetSelected(aSelect);
674
0
  }
675
0
676
0
  return NS_OK;
677
0
}
678
679
NS_IMETHODIMP
680
xpcAccessible::TakeSelection()
681
0
{
682
0
  if (IntlGeneric().IsNull())
683
0
    return NS_ERROR_FAILURE;
684
0
685
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
686
#if defined(XP_WIN)
687
    return NS_ERROR_NOT_IMPLEMENTED;
688
#else
689
    proxy->TakeSelection();
690
0
#endif
691
0
  } else {
692
0
    Intl()->TakeSelection();
693
0
  }
694
0
695
0
  return NS_OK;
696
0
}
697
698
NS_IMETHODIMP
699
xpcAccessible::TakeFocus()
700
0
{
701
0
  if (IntlGeneric().IsNull())
702
0
    return NS_ERROR_FAILURE;
703
0
704
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
705
#if defined(XP_WIN)
706
    return NS_ERROR_NOT_IMPLEMENTED;
707
#else
708
    proxy->TakeFocus();
709
0
#endif
710
0
  } else {
711
0
    Intl()->TakeFocus();
712
0
  }
713
0
714
0
  return NS_OK;
715
0
}
716
717
NS_IMETHODIMP
718
xpcAccessible::GetActionCount(uint8_t* aActionCount)
719
0
{
720
0
  NS_ENSURE_ARG_POINTER(aActionCount);
721
0
  *aActionCount = 0;
722
0
  if (IntlGeneric().IsNull())
723
0
    return NS_ERROR_FAILURE;
724
0
725
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
726
#if defined(XP_WIN)
727
    return NS_ERROR_NOT_IMPLEMENTED;
728
#else
729
    *aActionCount = proxy->ActionCount();
730
0
#endif
731
0
  } else {
732
0
    *aActionCount = Intl()->ActionCount();
733
0
  }
734
0
735
0
  return NS_OK;
736
0
}
737
738
NS_IMETHODIMP
739
xpcAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
740
0
{
741
0
  if (IntlGeneric().IsNull())
742
0
    return NS_ERROR_FAILURE;
743
0
744
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
745
#if defined(XP_WIN)
746
    return NS_ERROR_NOT_IMPLEMENTED;
747
#else
748
    nsString name;
749
0
    proxy->ActionNameAt(aIndex, name);
750
0
    aName.Assign(name);
751
0
#endif
752
0
  } else {
753
0
    if (aIndex >= Intl()->ActionCount())
754
0
      return NS_ERROR_INVALID_ARG;
755
0
756
0
    Intl()->ActionNameAt(aIndex, aName);
757
0
  }
758
0
759
0
  return NS_OK;
760
0
}
761
762
NS_IMETHODIMP
763
xpcAccessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
764
0
{
765
0
  if (IntlGeneric().IsNull())
766
0
    return NS_ERROR_FAILURE;
767
0
768
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
769
#if defined(XP_WIN)
770
    return NS_ERROR_NOT_IMPLEMENTED;
771
#else
772
    nsString description;
773
0
    proxy->ActionDescriptionAt(aIndex, description);
774
0
    aDescription.Assign(description);
775
0
#endif
776
0
  } else {
777
0
    if (aIndex >= Intl()->ActionCount())
778
0
      return NS_ERROR_INVALID_ARG;
779
0
780
0
    Intl()->ActionDescriptionAt(aIndex, aDescription);
781
0
  }
782
0
783
0
  return NS_OK;
784
0
}
785
786
NS_IMETHODIMP
787
xpcAccessible::DoAction(uint8_t aIndex)
788
0
{
789
0
  if (IntlGeneric().IsNull())
790
0
    return NS_ERROR_FAILURE;
791
0
792
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
793
#if defined(XP_WIN)
794
    return NS_ERROR_NOT_IMPLEMENTED;
795
#else
796
0
    return proxy->DoAction(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
797
0
#endif
798
0
  } else {
799
0
    return Intl()->DoAction(aIndex) ?
800
0
      NS_OK : NS_ERROR_INVALID_ARG;
801
0
  }
802
0
}
803
804
NS_IMETHODIMP
805
xpcAccessible::ScrollTo(uint32_t aHow)
806
0
{
807
0
  if (IntlGeneric().IsNull())
808
0
    return NS_ERROR_FAILURE;
809
0
810
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
811
#if defined(XP_WIN)
812
    return NS_ERROR_NOT_IMPLEMENTED;
813
#else
814
    proxy->ScrollTo(aHow);
815
0
#endif
816
0
  } else {
817
0
    Intl()->ScrollTo(aHow);
818
0
  }
819
0
820
0
  return NS_OK;
821
0
}
822
823
NS_IMETHODIMP
824
xpcAccessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY)
825
0
{
826
0
  if (IntlGeneric().IsNull())
827
0
    return NS_ERROR_FAILURE;
828
0
829
0
  if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
830
#if defined(XP_WIN)
831
    return NS_ERROR_NOT_IMPLEMENTED;
832
#else
833
    proxy->ScrollToPoint(aCoordinateType, aX, aY);
834
0
#endif
835
0
  } else {
836
0
    Intl()->ScrollToPoint(aCoordinateType, aX, aY);
837
0
  }
838
0
839
0
  return NS_OK;
840
0
}