Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/ipc/DocAccessibleChildBase.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
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/a11y/DocAccessibleChildBase.h"
8
#include "mozilla/a11y/ProxyAccessible.h"
9
10
#include "Accessible-inl.h"
11
12
namespace mozilla {
13
namespace a11y {
14
15
/* static */ uint32_t
16
DocAccessibleChildBase::InterfacesFor(Accessible* aAcc)
17
0
{
18
0
  uint32_t interfaces = 0;
19
0
  if (aAcc->IsHyperText() && aAcc->AsHyperText()->IsTextRole())
20
0
    interfaces |= Interfaces::HYPERTEXT;
21
0
22
0
  if (aAcc->IsLink())
23
0
    interfaces |= Interfaces::HYPERLINK;
24
0
25
0
  if (aAcc->HasNumericValue())
26
0
    interfaces |= Interfaces::VALUE;
27
0
28
0
  if (aAcc->IsImage())
29
0
    interfaces |= Interfaces::IMAGE;
30
0
31
0
  if (aAcc->IsTable()) {
32
0
    interfaces |= Interfaces::TABLE;
33
0
  }
34
0
35
0
  if (aAcc->IsTableCell())
36
0
    interfaces |= Interfaces::TABLECELL;
37
0
38
0
  if (aAcc->IsDoc())
39
0
    interfaces |= Interfaces::DOCUMENT;
40
0
41
0
  if (aAcc->IsSelect()) {
42
0
    interfaces |= Interfaces::SELECTION;
43
0
  }
44
0
45
0
  if (aAcc->ActionCount()) {
46
0
    interfaces |= Interfaces::ACTION;
47
0
  }
48
0
49
0
  return interfaces;
50
0
}
51
52
/* static */ void
53
DocAccessibleChildBase::SerializeTree(Accessible* aRoot,
54
                                      nsTArray<AccessibleData>& aTree)
55
0
{
56
0
  uint64_t id = reinterpret_cast<uint64_t>(aRoot->UniqueID());
57
#if defined(XP_WIN)
58
  int32_t msaaId = AccessibleWrap::GetChildIDFor(aRoot);
59
#endif
60
  a11y::role role = aRoot->Role();
61
0
  uint32_t childCount = aRoot->ChildCount();
62
0
  uint32_t interfaces = InterfacesFor(aRoot);
63
0
64
0
  // OuterDocAccessibles are special because we don't want to serialize the
65
0
  // child doc here, we'll call PDocAccessibleConstructor in
66
0
  // NotificationController.
67
0
  MOZ_ASSERT(!aRoot->IsDoc(), "documents shouldn't be serialized");
68
0
  if (aRoot->IsOuterDoc()) {
69
0
    childCount = 0;
70
0
  }
71
0
72
#if defined(XP_WIN)
73
  aTree.AppendElement(AccessibleData(id, msaaId, role, childCount, interfaces));
74
#else
75
  aTree.AppendElement(AccessibleData(id, role, childCount, interfaces));
76
0
#endif
77
0
78
0
  for (uint32_t i = 0; i < childCount; i++) {
79
0
    SerializeTree(aRoot->GetChildAt(i), aTree);
80
0
  }
81
0
}
82
83
void
84
DocAccessibleChildBase::InsertIntoIpcTree(Accessible* aParent,
85
                                          Accessible* aChild,
86
                                          uint32_t aIdxInParent)
87
0
{
88
0
  uint64_t parentID = aParent->IsDoc() ?
89
0
    0 : reinterpret_cast<uint64_t>(aParent->UniqueID());
90
0
  nsTArray<AccessibleData> shownTree;
91
0
  ShowEventData data(parentID, aIdxInParent, shownTree, true);
92
0
  SerializeTree(aChild, data.NewTree());
93
0
  MaybeSendShowEvent(data, false);
94
0
}
95
96
void
97
DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent)
98
0
{
99
0
  Accessible* parent = aShowEvent->Parent();
100
0
  uint64_t parentID = parent->IsDoc() ? 0 : reinterpret_cast<uint64_t>(parent->UniqueID());
101
0
  uint32_t idxInParent = aShowEvent->GetAccessible()->IndexInParent();
102
0
  nsTArray<AccessibleData> shownTree;
103
0
  ShowEventData data(parentID, idxInParent, shownTree, false);
104
0
  SerializeTree(aShowEvent->GetAccessible(), data.NewTree());
105
0
  MaybeSendShowEvent(data, aShowEvent->IsFromUserInput());
106
0
}
107
108
} // namespace a11y
109
} // namespace mozilla
110