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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "RemoteAccessible.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "DocAccessible.h"
#include "AccAttributes.h"
#include "mozilla/a11y/DocManager.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/Unused.h"
#include "mozilla/a11y/Platform.h"
#include "Relation.h"
#include "RelationType.h"
#include "mozilla/a11y/Role.h"
#include "mozilla/StaticPrefs_accessibility.h"
namespace mozilla {
namespace a11y {
uint64_t RemoteAccessible::State() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::State();
}
uint64_t state = 0;
Unused << mDoc->SendState(mID, &state);
return state;
}
uint64_t RemoteAccessible::NativeState() const {
uint64_t state = 0;
Unused << mDoc->SendNativeState(mID, &state);
return state;
}
ENameValueFlag RemoteAccessible::Name(nsString& aName) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::Name(aName);
}
uint32_t flag = 0;
Unused << mDoc->SendName(mID, &aName, &flag);
return static_cast<ENameValueFlag>(flag);
}
void RemoteAccessible::Value(nsString& aValue) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
RemoteAccessibleBase<RemoteAccessible>::Value(aValue);
return;
}
Unused << mDoc->SendValue(mID, &aValue);
}
void RemoteAccessible::Help(nsString& aHelp) const {
Unused << mDoc->SendHelp(mID, &aHelp);
}
void RemoteAccessible::Description(nsString& aDesc) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
RemoteAccessibleBase<RemoteAccessible>::Description(aDesc);
return;
}
Unused << mDoc->SendDescription(mID, &aDesc);
}
already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::Attributes();
}
RefPtr<AccAttributes> attrs;
Unused << mDoc->SendAttributes(mID, &attrs);
return attrs.forget();
}
Relation RemoteAccessible::RelationByType(RelationType aType) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::RelationByType(aType);
}
nsTArray<uint64_t> targetIDs;
Unused << mDoc->SendRelationByType(mID, static_cast<uint32_t>(aType),
&targetIDs);
return Relation(new RemoteAccIterator(std::move(targetIDs), Document()));
}
void RemoteAccessible::Relations(
nsTArray<RelationType>* aTypes,
nsTArray<nsTArray<RemoteAccessible*>>* aTargetSets) const {
nsTArray<RelationTargets> ipcRelations;
Unused << mDoc->SendRelations(mID, &ipcRelations);
size_t relationCount = ipcRelations.Length();
aTypes->SetCapacity(relationCount);
aTargetSets->SetCapacity(relationCount);
for (size_t i = 0; i < relationCount; i++) {
uint32_t type = ipcRelations[i].Type();
if (type > static_cast<uint32_t>(RelationType::LAST)) continue;
size_t targetCount = ipcRelations[i].Targets().Length();
nsTArray<RemoteAccessible*> targets(targetCount);
for (size_t j = 0; j < targetCount; j++) {
if (RemoteAccessible* proxy =
mDoc->GetAccessible(ipcRelations[i].Targets()[j])) {
targets.AppendElement(proxy);
}
}
if (targets.IsEmpty()) continue;
aTargetSets->AppendElement(std::move(targets));
aTypes->AppendElement(static_cast<RelationType>(type));
}
}
bool RemoteAccessible::IsSearchbox() const {
bool retVal = false;
Unused << mDoc->SendIsSearchbox(mID, &retVal);
return retVal;
}
nsAtom* RemoteAccessible::LandmarkRole() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::LandmarkRole();
}
nsString landmark;
Unused << mDoc->SendLandmarkRole(mID, &landmark);
return NS_GetStaticAtom(landmark);
}
GroupPos RemoteAccessible::GroupPosition() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::GroupPosition();
}
GroupPos groupPos;
Unused << mDoc->SendGroupPosition(mID, &groupPos.level, &groupPos.setSize,
&groupPos.posInSet);
return groupPos;
}
void RemoteAccessible::ScrollToPoint(uint32_t aScrollType, int32_t aX,
int32_t aY) {
Unused << mDoc->SendScrollToPoint(mID, aScrollType, aX, aY);
}
void RemoteAccessible::Announce(const nsString& aAnnouncement,
uint16_t aPriority) {
Unused << mDoc->SendAnnounce(mID, aAnnouncement, aPriority);
}
int32_t RemoteAccessible::CaretLineNumber() {
int32_t line = -1;
Unused << mDoc->SendCaretOffset(mID, &line);
return line;
}
int32_t RemoteAccessible::CaretOffset() const {
int32_t offset = 0;
Unused << mDoc->SendCaretOffset(mID, &offset);
return offset;
}
uint32_t RemoteAccessible::CharacterCount() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::CharacterCount();
}
int32_t count = 0;
Unused << mDoc->SendCharacterCount(mID, &count);
return count;
}
int32_t RemoteAccessible::SelectionCount() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::SelectionCount();
}
int32_t count = 0;
Unused << mDoc->SendSelectionCount(mID, &count);
return count;
}
void RemoteAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOffset,
nsAString& aText) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::TextSubstring(
aStartOffset, aEndOffset, aText);
}
bool valid;
nsString text;
Unused << mDoc->SendTextSubstring(mID, aStartOffset, aEndOffset, &text,
&valid);
aText = std::move(text);
}
void RemoteAccessible::TextAfterOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset,
int32_t* aEndOffset, nsAString& aText) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::TextAfterOffset(
aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
}
nsString text;
Unused << mDoc->SendGetTextAfterOffset(mID, aOffset, aBoundaryType, &text,
aStartOffset, aEndOffset);
aText = std::move(text);
}
void RemoteAccessible::TextAtOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::TextAtOffset(
aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
}
nsString text;
Unused << mDoc->SendGetTextAtOffset(mID, aOffset, aBoundaryType, &text,
aStartOffset, aEndOffset);
aText = std::move(text);
}
void RemoteAccessible::TextBeforeOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset,
int32_t* aEndOffset, nsAString& aText) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::TextBeforeOffset(
aOffset, aBoundaryType, aStartOffset, aEndOffset, aText);
}
nsString text;
Unused << mDoc->SendGetTextBeforeOffset(mID, aOffset, aBoundaryType, &text,
aStartOffset, aEndOffset);
aText = std::move(text);
}
char16_t RemoteAccessible::CharAt(int32_t aOffset) {
uint16_t retval = 0;
Unused << mDoc->SendCharAt(mID, aOffset, &retval);
return static_cast<char16_t>(retval);
}
already_AddRefed<AccAttributes> RemoteAccessible::TextAttributes(
bool aIncludeDefAttrs, int32_t aOffset, int32_t* aStartOffset,
int32_t* aEndOffset) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::TextAttributes(
aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
}
RefPtr<AccAttributes> attrs;
Unused << mDoc->SendTextAttributes(mID, aIncludeDefAttrs, aOffset, &attrs,
aStartOffset, aEndOffset);
return attrs.forget();
}
already_AddRefed<AccAttributes> RemoteAccessible::DefaultTextAttributes() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::DefaultTextAttributes();
}
RefPtr<AccAttributes> attrs;
Unused << mDoc->SendDefaultTextAttributes(mID, &attrs);
return attrs.forget();
}
LayoutDeviceIntRect RemoteAccessible::TextBounds(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aCoordType) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
MOZ_ASSERT(IsHyperText(), "is not hypertext?");
return RemoteAccessibleBase<RemoteAccessible>::TextBounds(
aStartOffset, aEndOffset, aCoordType);
}
LayoutDeviceIntRect rect;
Unused << mDoc->SendTextBounds(mID, aStartOffset, aEndOffset, aCoordType,
&rect);
return rect;
}
LayoutDeviceIntRect RemoteAccessible::CharBounds(int32_t aOffset,
uint32_t aCoordType) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
MOZ_ASSERT(IsHyperText(), "is not hypertext?");
return RemoteAccessibleBase<RemoteAccessible>::CharBounds(aOffset,
aCoordType);
}
LayoutDeviceIntRect rect;
Unused << mDoc->SendCharBounds(mID, aOffset, aCoordType, &rect);
return rect;
}
int32_t RemoteAccessible::OffsetAtPoint(int32_t aX, int32_t aY,
uint32_t aCoordType) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
MOZ_ASSERT(IsHyperText(), "is not hypertext?");
return RemoteAccessibleBase<RemoteAccessible>::OffsetAtPoint(aX, aY,
aCoordType);
}
int32_t retVal = -1;
Unused << mDoc->SendOffsetAtPoint(mID, aX, aY, aCoordType, &retVal);
return retVal;
}
bool RemoteAccessible::SelectionBoundsAt(int32_t aSelectionNum, nsString& aData,
int32_t* aStartOffset,
int32_t* aEndOffset) {
bool retVal = false;
Unused << mDoc->SendSelectionBoundsAt(mID, aSelectionNum, &retVal, &aData,
aStartOffset, aEndOffset);
return retVal;
}
bool RemoteAccessible::SetSelectionBoundsAt(int32_t aSelectionNum,
int32_t aStartOffset,
int32_t aEndOffset) {
bool retVal = false;
Unused << mDoc->SendSetSelectionBoundsAt(mID, aSelectionNum, aStartOffset,
aEndOffset, &retVal);
return retVal;
}
bool RemoteAccessible::AddToSelection(int32_t aStartOffset,
int32_t aEndOffset) {
bool retVal = false;
Unused << mDoc->SendAddToSelection(mID, aStartOffset, aEndOffset, &retVal);
return retVal;
}
bool RemoteAccessible::RemoveFromSelection(int32_t aSelectionNum) {
bool retVal = false;
Unused << mDoc->SendRemoveFromSelection(mID, aSelectionNum, &retVal);
return retVal;
}
void RemoteAccessible::ScrollSubstringTo(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aScrollType) {
Unused << mDoc->SendScrollSubstringTo(mID, aStartOffset, aEndOffset,
aScrollType);
}
void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aCoordinateType,
int32_t aX, int32_t aY) {
Unused << mDoc->SendScrollSubstringToPoint(mID, aStartOffset, aEndOffset,
aCoordinateType, aX, aY);
}
void RemoteAccessible::Text(nsString* aText) {
Unused << mDoc->SendText(mID, aText);
}
void RemoteAccessible::ReplaceText(const nsString& aText) {
Unused << mDoc->SendReplaceText(mID, aText);
}
bool RemoteAccessible::InsertText(const nsString& aText, int32_t aPosition) {
bool valid;
Unused << mDoc->SendInsertText(mID, aText, aPosition, &valid);
return valid;
}
bool RemoteAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) {
bool valid;
Unused << mDoc->SendCopyText(mID, aStartPos, aEndPos, &valid);
return valid;
}
bool RemoteAccessible::CutText(int32_t aStartPos, int32_t aEndPos) {
bool valid;
Unused << mDoc->SendCutText(mID, aStartPos, aEndPos, &valid);
return valid;
}
bool RemoteAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos) {
bool valid;
Unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos, &valid);
return valid;
}
bool RemoteAccessible::PasteText(int32_t aPosition) {
bool valid;
Unused << mDoc->SendPasteText(mID, aPosition, &valid);
return valid;
}
uint32_t RemoteAccessible::StartOffset() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::StartOffset();
}
uint32_t retVal = 0;
bool ok;
Unused << mDoc->SendStartOffset(mID, &retVal, &ok);
return retVal;
}
uint32_t RemoteAccessible::EndOffset() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::EndOffset();
}
bool ok;
uint32_t retVal = 0;
Unused << mDoc->SendEndOffset(mID, &retVal, &ok);
return retVal;
}
bool RemoteAccessible::IsLinkValid() {
bool retVal = false;
Unused << mDoc->SendIsLinkValid(mID, &retVal);
return retVal;
}
uint32_t RemoteAccessible::AnchorCount(bool* aOk) {
uint32_t retVal = 0;
Unused << mDoc->SendAnchorCount(mID, &retVal, aOk);
return retVal;
}
void RemoteAccessible::AnchorURIAt(uint32_t aIndex, nsCString& aURI,
bool* aOk) {
Unused << mDoc->SendAnchorURIAt(mID, aIndex, &aURI, aOk);
}
RemoteAccessible* RemoteAccessible::AnchorAt(uint32_t aIndex) {
uint64_t id = 0;
bool ok = false;
Unused << mDoc->SendAnchorAt(mID, aIndex, &id, &ok);
return ok ? mDoc->GetAccessible(id) : nullptr;
}
uint32_t RemoteAccessible::LinkCount() {
uint32_t retVal = 0;
Unused << mDoc->SendLinkCount(mID, &retVal);
return retVal;
}
RemoteAccessible* RemoteAccessible::LinkAt(const uint32_t& aIndex) {
uint64_t linkID = 0;
bool ok = false;
Unused << mDoc->SendLinkAt(mID, aIndex, &linkID, &ok);
return ok ? mDoc->GetAccessible(linkID) : nullptr;
}
int32_t RemoteAccessible::LinkIndexAtOffset(uint32_t aOffset) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::LinkIndexAtOffset(aOffset);
}
int32_t retVal = -1;
Unused << mDoc->SendLinkIndexAtOffset(mID, aOffset, &retVal);
return retVal;
}
RemoteAccessible* RemoteAccessible::TableOfACell() {
uint64_t tableID = 0;
bool ok = false;
Unused << mDoc->SendTableOfACell(mID, &tableID, &ok);
return ok ? mDoc->GetAccessible(tableID) : nullptr;
}
uint32_t RemoteAccessible::ColIdx() {
uint32_t index = 0;
Unused << mDoc->SendColIdx(mID, &index);
return index;
}
uint32_t RemoteAccessible::RowIdx() {
uint32_t index = 0;
Unused << mDoc->SendRowIdx(mID, &index);
return index;
}
void RemoteAccessible::GetColRowExtents(uint32_t* aColIdx, uint32_t* aRowIdx,
uint32_t* aColExtent,
uint32_t* aRowExtent) {
Unused << mDoc->SendGetColRowExtents(mID, aColIdx, aRowIdx, aColExtent,
aRowExtent);
}
void RemoteAccessible::GetPosition(uint32_t* aRowIdx, uint32_t* aColIdx) {
Unused << mDoc->SendGetPosition(mID, aRowIdx, aColIdx);
}
uint32_t RemoteAccessible::ColExtent() {
uint32_t extent = 0;
Unused << mDoc->SendColExtent(mID, &extent);
return extent;
}
uint32_t RemoteAccessible::RowExtent() {
uint32_t extent = 0;
Unused << mDoc->SendRowExtent(mID, &extent);
return extent;
}
void RemoteAccessible::ColHeaderCells(nsTArray<RemoteAccessible*>* aCells) {
nsTArray<uint64_t> targetIDs;
Unused << mDoc->SendColHeaderCells(mID, &targetIDs);
size_t targetCount = targetIDs.Length();
for (size_t i = 0; i < targetCount; i++) {
aCells->AppendElement(mDoc->GetAccessible(targetIDs[i]));
}
}
void RemoteAccessible::RowHeaderCells(nsTArray<RemoteAccessible*>* aCells) {
nsTArray<uint64_t> targetIDs;
Unused << mDoc->SendRowHeaderCells(mID, &targetIDs);
size_t targetCount = targetIDs.Length();
for (size_t i = 0; i < targetCount; i++) {
aCells->AppendElement(mDoc->GetAccessible(targetIDs[i]));
}
}
bool RemoteAccessible::IsCellSelected() {
bool selected = false;
Unused << mDoc->SendIsCellSelected(mID, &selected);
return selected;
}
RemoteAccessible* RemoteAccessible::TableCaption() {
uint64_t captionID = 0;
bool ok = false;
Unused << mDoc->SendTableCaption(mID, &captionID, &ok);
return ok ? mDoc->GetAccessible(captionID) : nullptr;
}
void RemoteAccessible::TableSummary(nsString& aSummary) {
Unused << mDoc->SendTableSummary(mID, &aSummary);
}
uint32_t RemoteAccessible::TableColumnCount() {
uint32_t count = 0;
Unused << mDoc->SendTableColumnCount(mID, &count);
return count;
}
uint32_t RemoteAccessible::TableRowCount() {
uint32_t count = 0;
Unused << mDoc->SendTableRowCount(mID, &count);
return count;
}
RemoteAccessible* RemoteAccessible::TableCellAt(uint32_t aRow, uint32_t aCol) {
uint64_t cellID = 0;
bool ok = false;
Unused << mDoc->SendTableCellAt(mID, aRow, aCol, &cellID, &ok);
return ok ? mDoc->GetAccessible(cellID) : nullptr;
}
int32_t RemoteAccessible::TableCellIndexAt(uint32_t aRow, uint32_t aCol) {
int32_t index = 0;
Unused << mDoc->SendTableCellIndexAt(mID, aRow, aCol, &index);
return index;
}
int32_t RemoteAccessible::TableColumnIndexAt(uint32_t aCellIndex) {
int32_t index = 0;
Unused << mDoc->SendTableColumnIndexAt(mID, aCellIndex, &index);
return index;
}
int32_t RemoteAccessible::TableRowIndexAt(uint32_t aCellIndex) {
int32_t index = 0;
Unused << mDoc->SendTableRowIndexAt(mID, aCellIndex, &index);
return index;
}
void RemoteAccessible::TableRowAndColumnIndicesAt(uint32_t aCellIndex,
int32_t* aRow,
int32_t* aCol) {
Unused << mDoc->SendTableRowAndColumnIndicesAt(mID, aCellIndex, aRow, aCol);
}
uint32_t RemoteAccessible::TableColumnExtentAt(uint32_t aRow, uint32_t aCol) {
uint32_t extent = 0;
Unused << mDoc->SendTableColumnExtentAt(mID, aRow, aCol, &extent);
return extent;
}
uint32_t RemoteAccessible::TableRowExtentAt(uint32_t aRow, uint32_t aCol) {
uint32_t extent = 0;
Unused << mDoc->SendTableRowExtentAt(mID, aRow, aCol, &extent);
return extent;
}
void RemoteAccessible::TableColumnDescription(uint32_t aCol,
nsString& aDescription) {
Unused << mDoc->SendTableColumnDescription(mID, aCol, &aDescription);
}
void RemoteAccessible::TableRowDescription(uint32_t aRow,
nsString& aDescription) {
Unused << mDoc->SendTableRowDescription(mID, aRow, &aDescription);
}
bool RemoteAccessible::TableColumnSelected(uint32_t aCol) {
bool selected = false;
Unused << mDoc->SendTableColumnSelected(mID, aCol, &selected);
return selected;
}
bool RemoteAccessible::TableRowSelected(uint32_t aRow) {
bool selected = false;
Unused << mDoc->SendTableRowSelected(mID, aRow, &selected);
return selected;
}
bool RemoteAccessible::TableCellSelected(uint32_t aRow, uint32_t aCol) {
bool selected = false;
Unused << mDoc->SendTableCellSelected(mID, aRow, aCol, &selected);
return selected;
}
uint32_t RemoteAccessible::TableSelectedCellCount() {
uint32_t count = 0;
Unused << mDoc->SendTableSelectedCellCount(mID, &count);
return count;
}
uint32_t RemoteAccessible::TableSelectedColumnCount() {
uint32_t count = 0;
Unused << mDoc->SendTableSelectedColumnCount(mID, &count);
return count;
}
uint32_t RemoteAccessible::TableSelectedRowCount() {
uint32_t count = 0;
Unused << mDoc->SendTableSelectedRowCount(mID, &count);
return count;
}
void RemoteAccessible::TableSelectedCells(
nsTArray<RemoteAccessible*>* aCellIDs) {
AutoTArray<uint64_t, 30> cellIDs;
Unused << mDoc->SendTableSelectedCells(mID, &cellIDs);
aCellIDs->SetCapacity(cellIDs.Length());
for (uint32_t i = 0; i < cellIDs.Length(); ++i) {
aCellIDs->AppendElement(mDoc->GetAccessible(cellIDs[i]));
}
}
void RemoteAccessible::TableSelectedCellIndices(
nsTArray<uint32_t>* aCellIndices) {
Unused << mDoc->SendTableSelectedCellIndices(mID, aCellIndices);
}
void RemoteAccessible::TableSelectedColumnIndices(
nsTArray<uint32_t>* aColumnIndices) {
Unused << mDoc->SendTableSelectedColumnIndices(mID, aColumnIndices);
}
void RemoteAccessible::TableSelectedRowIndices(
nsTArray<uint32_t>* aRowIndices) {
Unused << mDoc->SendTableSelectedRowIndices(mID, aRowIndices);
}
void RemoteAccessible::TableSelectColumn(uint32_t aCol) {
Unused << mDoc->SendTableSelectColumn(mID, aCol);
}
void RemoteAccessible::TableSelectRow(uint32_t aRow) {
Unused << mDoc->SendTableSelectRow(mID, aRow);
}
void RemoteAccessible::TableUnselectColumn(uint32_t aCol) {
Unused << mDoc->SendTableUnselectColumn(mID, aCol);
}
void RemoteAccessible::TableUnselectRow(uint32_t aRow) {
Unused << mDoc->SendTableUnselectRow(mID, aRow);
}
bool RemoteAccessible::TableIsProbablyForLayout() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::TableIsProbablyForLayout();
}
bool forLayout = false;
Unused << mDoc->SendTableIsProbablyForLayout(mID, &forLayout);
return forLayout;
}
RemoteAccessible* RemoteAccessible::AtkTableColumnHeader(int32_t aCol) {
uint64_t headerID = 0;
bool ok = false;
Unused << mDoc->SendAtkTableColumnHeader(mID, aCol, &headerID, &ok);
return ok ? mDoc->GetAccessible(headerID) : nullptr;
}
RemoteAccessible* RemoteAccessible::AtkTableRowHeader(int32_t aRow) {
uint64_t headerID = 0;
bool ok = false;
Unused << mDoc->SendAtkTableRowHeader(mID, aRow, &headerID, &ok);
return ok ? mDoc->GetAccessible(headerID) : nullptr;
}
void RemoteAccessible::SelectedItems(nsTArray<Accessible*>* aSelectedItems) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
RemoteAccessibleBase<RemoteAccessible>::SelectedItems(aSelectedItems);
return;
}
AutoTArray<uint64_t, 10> itemIDs;
Unused << mDoc->SendSelectedItems(mID, &itemIDs);
aSelectedItems->SetCapacity(itemIDs.Length());
for (size_t i = 0; i < itemIDs.Length(); ++i) {
aSelectedItems->AppendElement(mDoc->GetAccessible(itemIDs[i]));
}
}
uint32_t RemoteAccessible::SelectedItemCount() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::SelectedItemCount();
}
uint32_t count = 0;
Unused << mDoc->SendSelectedItemCount(mID, &count);
return count;
}
Accessible* RemoteAccessible::GetSelectedItem(uint32_t aIndex) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::GetSelectedItem(aIndex);
}
uint64_t selectedItemID = 0;
bool ok = false;
Unused << mDoc->SendGetSelectedItem(mID, aIndex, &selectedItemID, &ok);
return ok ? mDoc->GetAccessible(selectedItemID) : nullptr;
}
bool RemoteAccessible::IsItemSelected(uint32_t aIndex) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::IsItemSelected(aIndex);
}
bool selected = false;
Unused << mDoc->SendIsItemSelected(mID, aIndex, &selected);
return selected;
}
bool RemoteAccessible::AddItemToSelection(uint32_t aIndex) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::AddItemToSelection(aIndex);
}
bool success = false;
Unused << mDoc->SendAddItemToSelection(mID, aIndex, &success);
return success;
}
bool RemoteAccessible::RemoveItemFromSelection(uint32_t aIndex) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::RemoveItemFromSelection(
aIndex);
}
bool success = false;
Unused << mDoc->SendRemoveItemFromSelection(mID, aIndex, &success);
return success;
}
bool RemoteAccessible::SelectAll() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::SelectAll();
}
bool success = false;
Unused << mDoc->SendSelectAll(mID, &success);
return success;
}
bool RemoteAccessible::UnselectAll() {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::UnselectAll();
}
bool success = false;
Unused << mDoc->SendUnselectAll(mID, &success);
return success;
}
bool RemoteAccessible::DoAction(uint8_t aIndex) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::DoAction(aIndex);
}
bool success = false;
Unused << mDoc->SendDoAction(mID, aIndex, &success);
return success;
}
uint8_t RemoteAccessible::ActionCount() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::ActionCount();
}
uint8_t count = 0;
Unused << mDoc->SendActionCount(mID, &count);
return count;
}
void RemoteAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
RemoteAccessibleBase<RemoteAccessible>::ActionNameAt(aIndex, aName);
return;
}
nsAutoString name;
Unused << mDoc->SendActionNameAt(mID, aIndex, &name);
aName.Assign(name);
}
KeyBinding RemoteAccessible::AccessKey() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::AccessKey();
}
uint32_t key = 0;
uint32_t modifierMask = 0;
Unused << mDoc->SendAccessKey(mID, &key, &modifierMask);
return KeyBinding(key, modifierMask);
}
void RemoteAccessible::AtkKeyBinding(nsString& aBinding) {
Unused << mDoc->SendAtkKeyBinding(mID, &aBinding);
}
double RemoteAccessible::CurValue() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::CurValue();
}
double val = UnspecifiedNaN<double>();
Unused << mDoc->SendCurValue(mID, &val);
return val;
}
bool RemoteAccessible::SetCurValue(double aValue) {
bool success = false;
Unused << mDoc->SendSetCurValue(mID, aValue, &success);
return success;
}
double RemoteAccessible::MinValue() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::MinValue();
}
double val = UnspecifiedNaN<double>();
Unused << mDoc->SendMinValue(mID, &val);
return val;
}
double RemoteAccessible::MaxValue() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::MaxValue();
}
double val = UnspecifiedNaN<double>();
Unused << mDoc->SendMaxValue(mID, &val);
return val;
}
double RemoteAccessible::Step() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::Step();
}
double step = UnspecifiedNaN<double>();
Unused << mDoc->SendStep(mID, &step);
return step;
}
Accessible* RemoteAccessible::ChildAtPoint(
int32_t aX, int32_t aY, LocalAccessible::EWhichChildAtPoint aWhichChild) {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::ChildAtPoint(aX, aY,
aWhichChild);
}
RemoteAccessible* target = this;
do {
if (target->IsOuterDoc()) {
if (target->ChildCount() == 0) {
// Return the OuterDoc if the requested point is within its bounds.
LayoutDeviceIntRect rect = target->Bounds();
if (rect.Contains(aX, aY)) {
return target;
}
return nullptr;
}
DocAccessibleParent* childDoc = target->RemoteChildAt(0)->AsDoc();
MOZ_ASSERT(childDoc);
if (childDoc->IsTopLevelInContentProcess()) {
// This is an OOP iframe. Remote calls can only work within their
// process, so they stop at OOP iframes.
if (aWhichChild == Accessible::EWhichChildAtPoint::DirectChild) {
// Return the child document if it's within the bounds of the iframe.
LayoutDeviceIntRect docRect = target->Bounds();
if (docRect.Contains(aX, aY)) {
return childDoc;
}
return nullptr;
}
// We must continue the search from the child document.
target = childDoc;
}
}
PDocAccessibleParent* resultDoc = nullptr;
uint64_t resultID = 0;
Unused << target->mDoc->SendChildAtPoint(target->mID, aX, aY,
static_cast<uint32_t>(aWhichChild),
&resultDoc, &resultID);
// If resultDoc is null, this means there is no child at this point.
auto useDoc = static_cast<DocAccessibleParent*>(resultDoc);
target = resultDoc ? useDoc->GetAccessible(resultID) : nullptr;
} while (target && target->IsOuterDoc() &&
aWhichChild == Accessible::EWhichChildAtPoint::DeepestChild);
return target;
}
LayoutDeviceIntRect RemoteAccessible::Bounds() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::Bounds();
}
LayoutDeviceIntRect rect;
Unused << mDoc->SendExtents(mID, false, &(rect.x), &(rect.y), &(rect.width),
&(rect.height));
return rect;
}
nsIntRect RemoteAccessible::BoundsInCSSPixels() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::BoundsInCSSPixels();
}
nsIntRect rect;
Unused << mDoc->SendExtentsInCSSPixels(mID, &rect.x, &rect.y, &rect.width,
&rect.height);
return rect;
}
void RemoteAccessible::Language(nsString& aLocale) {
Unused << mDoc->SendLanguage(mID, &aLocale);
}
void RemoteAccessible::DocType(nsString& aType) {
Unused << mDoc->SendDocType(mID, &aType);
}
void RemoteAccessible::Title(nsString& aTitle) {
Unused << mDoc->SendTitle(mID, &aTitle);
}
void RemoteAccessible::MimeType(nsString aMime) {
Unused << mDoc->SendMimeType(mID, &aMime);
}
void RemoteAccessible::URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
nsString& aMimeType) {
Unused << mDoc->SendURLDocTypeMimeType(mID, &aURL, &aDocType, &aMimeType);
}
void RemoteAccessible::Extents(bool aNeedsScreenCoords, int32_t* aX,
int32_t* aY, int32_t* aWidth, int32_t* aHeight) {
Unused << mDoc->SendExtents(mID, aNeedsScreenCoords, aX, aY, aWidth, aHeight);
}
void RemoteAccessible::DOMNodeID(nsString& aID) const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::DOMNodeID(aID);
}
Unused << mDoc->SendDOMNodeID(mID, &aID);
}
} // namespace a11y
} // namespace mozilla
|