Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/generic/DocAccessible-inl.h
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
#ifndef mozilla_a11y_DocAccessible_inl_h_
8
#define mozilla_a11y_DocAccessible_inl_h_
9
10
#include "DocAccessible.h"
11
#include "nsAccessibilityService.h"
12
#include "nsAccessiblePivot.h"
13
#include "NotificationController.h"
14
#include "States.h"
15
#include "nsIScrollableFrame.h"
16
#include "nsIDocumentInlines.h"
17
18
#ifdef A11Y_LOG
19
#include "Logging.h"
20
#endif
21
22
namespace mozilla {
23
namespace a11y {
24
25
inline Accessible*
26
DocAccessible::AccessibleOrTrueContainer(nsINode* aNode, int aIgnoreARIAHidden) const
27
0
{
28
0
  // HTML comboboxes have no-content list accessible as an intermediate
29
0
  // containing all options.
30
0
  Accessible* container = GetAccessibleOrContainer(aNode, aIgnoreARIAHidden);
31
0
  if (container && container->IsHTMLCombobox()) {
32
0
    return container->FirstChild();
33
0
  }
34
0
  return container;
35
0
}
36
37
inline nsIAccessiblePivot*
38
DocAccessible::VirtualCursor()
39
0
{
40
0
  if (!mVirtualCursor) {
41
0
    mVirtualCursor = new nsAccessiblePivot(this);
42
0
    mVirtualCursor->AddObserver(this);
43
0
  }
44
0
  return mVirtualCursor;
45
0
}
46
47
inline void
48
DocAccessible::FireDelayedEvent(AccEvent* aEvent)
49
0
{
50
0
#ifdef A11Y_LOG
51
0
  if (logging::IsEnabled(logging::eDocLoad))
52
0
    logging::DocLoadEventFired(aEvent);
53
0
#endif
54
0
55
0
  mNotificationController->QueueEvent(aEvent);
56
0
}
57
58
inline void
59
DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget)
60
0
{
61
0
  RefPtr<AccEvent> event = new AccEvent(aEventType, aTarget);
62
0
  FireDelayedEvent(event);
63
0
}
64
65
inline void
66
DocAccessible::BindChildDocument(DocAccessible* aDocument)
67
0
{
68
0
  mNotificationController->ScheduleChildDocBinding(aDocument);
69
0
}
70
71
template<class Class, class Arg>
72
inline void
73
DocAccessible::HandleNotification(Class* aInstance,
74
                                  typename TNotification<Class, Arg>::Callback aMethod,
75
                                  Arg* aArg)
76
0
{
77
0
  if (mNotificationController) {
78
0
    mNotificationController->HandleNotification<Class, Arg>(aInstance,
79
0
                                                            aMethod, aArg);
80
0
  }
81
0
}
Unexecuted instantiation: void mozilla::a11y::DocAccessible::HandleNotification<mozilla::a11y::FocusManager, nsINode>(mozilla::a11y::FocusManager*, mozilla::a11y::TNotification<mozilla::a11y::FocusManager, nsINode>::Callback, nsINode*)
Unexecuted instantiation: void mozilla::a11y::DocAccessible::HandleNotification<mozilla::a11y::SelectionManager, mozilla::a11y::SelData>(mozilla::a11y::SelectionManager*, mozilla::a11y::TNotification<mozilla::a11y::SelectionManager, mozilla::a11y::SelData>::Callback, mozilla::a11y::SelData*)
Unexecuted instantiation: void mozilla::a11y::DocAccessible::HandleNotification<mozilla::a11y::RootAccessible, mozilla::dom::Event>(mozilla::a11y::RootAccessible*, mozilla::a11y::TNotification<mozilla::a11y::RootAccessible, mozilla::dom::Event>::Callback, mozilla::dom::Event*)
82
83
inline void
84
DocAccessible::UpdateText(nsIContent* aTextNode)
85
0
{
86
0
  NS_ASSERTION(mNotificationController, "The document was shut down!");
87
0
88
0
  // Ignore the notification if initial tree construction hasn't been done yet.
89
0
  if (mNotificationController && HasLoadState(eTreeConstructed))
90
0
    mNotificationController->ScheduleTextUpdate(aTextNode);
91
0
}
92
93
inline void
94
DocAccessible::AddScrollListener()
95
0
{
96
0
  // Delay scroll initializing until the document has a root frame.
97
0
  if (!mPresShell->GetRootFrame())
98
0
    return;
99
0
100
0
  mDocFlags |= eScrollInitialized;
101
0
  nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
102
0
  if (sf) {
103
0
    sf->AddScrollPositionListener(this);
104
0
105
0
#ifdef A11Y_LOG
106
0
    if (logging::IsEnabled(logging::eDocCreate))
107
0
      logging::Text("add scroll listener");
108
0
#endif
109
0
  }
110
0
}
111
112
inline void
113
DocAccessible::RemoveScrollListener()
114
0
{
115
0
  nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
116
0
  if (sf)
117
0
    sf->RemoveScrollPositionListener(this);
118
0
}
119
120
inline void
121
DocAccessible::NotifyOfLoad(uint32_t aLoadEventType)
122
0
{
123
0
  mLoadState |= eDOMLoaded;
124
0
  mLoadEventType = aLoadEventType;
125
0
126
0
  // If the document is loaded completely then network activity was presumingly
127
0
  // caused by file loading. Fire busy state change event.
128
0
  if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) {
129
0
    RefPtr<AccEvent> stateEvent =
130
0
      new AccStateChangeEvent(this, states::BUSY, false);
131
0
    FireDelayedEvent(stateEvent);
132
0
  }
133
0
}
134
135
inline void
136
DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible)
137
0
{
138
0
  if (aAccessible->IsCombobox() || aAccessible->Role() == roles::ENTRY)
139
0
    FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE, aAccessible);
140
0
}
141
142
inline Accessible*
143
DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const
144
0
{
145
0
  Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
146
0
  return acc ? acc : GetContainerAccessible(aNode);
147
0
}
148
149
inline void
150
DocAccessible::CreateSubtree(Accessible* aChild)
151
0
{
152
0
  // If a focused node has been shown then it could mean its frame was recreated
153
0
  // while the node stays focused and we need to fire focus event on
154
0
  // the accessible we just created. If the queue contains a focus event for
155
0
  // this node already then it will be suppressed by this one.
156
0
  Accessible* focusedAcc = nullptr;
157
0
  CacheChildrenInSubtree(aChild, &focusedAcc);
158
0
159
0
#ifdef A11Y_LOG
160
0
  if (logging::IsEnabled(logging::eVerbose)) {
161
0
    logging::Tree("TREE", "Created subtree", aChild);
162
0
  }
163
0
#endif
164
0
165
0
  // Fire events for ARIA elements.
166
0
  if (aChild->HasARIARole()) {
167
0
    roles::Role role = aChild->ARIARole();
168
0
    if (role == roles::MENUPOPUP) {
169
0
      FireDelayedEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START, aChild);
170
0
    }
171
0
    else if (role == roles::ALERT) {
172
0
      FireDelayedEvent(nsIAccessibleEvent::EVENT_ALERT, aChild);
173
0
    }
174
0
  }
175
0
176
0
  // XXX: do we really want to send focus to focused DOM node not taking into
177
0
  // account active item?
178
0
  if (focusedAcc) {
179
0
    FocusMgr()->DispatchFocusEvent(this, focusedAcc);
180
0
    SelectionMgr()->
181
0
      SetControlSelectionListener(focusedAcc->GetNode()->AsElement());
182
0
  }
183
0
}
184
185
} // namespace a11y
186
} // namespace mozilla
187
188
#endif