summaryrefslogtreecommitdiffstats
path: root/accessible/base/Logging.h
blob: 2a6a93faa9282b438b9a583f375dd1630b2a1969 (plain)
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
/* -*- 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/. */

#ifndef mozilla_a11y_logs_h__
#define mozilla_a11y_logs_h__

#include "nscore.h"
#include "nsStringFwd.h"
#include "mozilla/Attributes.h"

class nsINode;
class nsIRequest;
class nsISupports;
class nsIWebProgress;

namespace mozilla {

namespace dom {
class Document;
class Selection;
}  // namespace dom

namespace a11y {

class AccEvent;
class LocalAccessible;
class DocAccessible;
class OuterDocAccessible;

namespace logging {

enum EModules {
  eDocLoad = 1 << 0,
  eDocCreate = 1 << 1,
  eDocDestroy = 1 << 2,
  eDocLifeCycle = eDocLoad | eDocCreate | eDocDestroy,

  eEvents = 1 << 3,
  ePlatforms = 1 << 4,
  eText = 1 << 5,
  eTree = 1 << 6,
  eTreeSize = 1 << 7,

  eDOMEvents = 1 << 8,
  eFocus = 1 << 9,
  eSelection = 1 << 10,
  eNotifications = eDOMEvents | eSelection | eFocus,

  // extras
  eStack = 1 << 11,
  eVerbose = 1 << 12,
  eCache = 1 << 13,
};

/**
 * Return true if any of the given modules is logged.
 */
bool IsEnabled(uint32_t aModules);

/**
 * Return true if all of the given modules are logged.
 */
bool IsEnabledAll(uint32_t aModules);

/**
 * Return true if the given module is logged.
 */
bool IsEnabled(const nsAString& aModules);

/**
 * Log the document loading progress.
 */
void DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
             nsIRequest* aRequest, uint32_t aStateFlags);
void DocLoad(const char* aMsg, dom::Document* aDocumentNode);
void DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget);

/**
 * Log that document load event was fired.
 */
void DocLoadEventFired(AccEvent* aEvent);

/**
 * Log that document laod event was handled.
 */
void DocLoadEventHandled(AccEvent* aEvent);

/**
 * Log the document was created.
 */
void DocCreate(const char* aMsg, dom::Document* aDocumentNode,
               DocAccessible* aDocument = nullptr);

/**
 * Log the document was destroyed.
 */
void DocDestroy(const char* aMsg, dom::Document* aDocumentNode,
                DocAccessible* aDocument = nullptr);

/**
 * Log the outer document was destroyed.
 */
void OuterDocDestroy(OuterDocAccessible* OuterDoc);

/**
 * Log the focus notification target.
 */
void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
                             LocalAccessible* aTarget);
void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
                             nsINode* aTargetNode);
void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
                             nsISupports* aTargetThing);

/**
 * Log a cause of active item descendant change (submessage).
 */
void ActiveItemChangeCausedBy(const char* aMsg, LocalAccessible* aTarget);

/**
 * Log the active widget (submessage).
 */
void ActiveWidget(LocalAccessible* aWidget);

/**
 * Log the focus event was dispatched (submessage).
 */
void FocusDispatched(LocalAccessible* aTarget);

/**
 * Log the selection change.
 */
void SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
               int16_t aReason);

/**
 * Log the given accessible elements info.
 */
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, const char* aMsg1,
              LocalAccessible* aAcc, const char* aMsg2, nsINode* aNode);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, LocalAccessible* aParent);

/**
 * Log the accessible/DOM tree.
 */
typedef const char* (*GetTreePrefix)(void* aData, LocalAccessible*);
void Tree(const char* aTitle, const char* aMsgText, LocalAccessible* aRoot,
          GetTreePrefix aPrefixFunc = nullptr,
          void* aGetTreePrefixData = nullptr);
void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);

/**
 * Log the tree size in bytes.
 */
void TreeSize(const char* aTitle, const char* aMsgText, LocalAccessible* aRoot);

/**
 * Log the message ('title: text' format) on new line. Print the start and end
 * boundaries of the message body designated by '{' and '}' (2 spaces indent for
 * body).
 */
void MsgBegin(const char* aTitle, const char* aMsgText, ...)
    MOZ_FORMAT_PRINTF(2, 3);
void MsgEnd();

/**
 * Print start and end boundaries of the message body designated by '{' and '}'
 * (2 spaces indent for body).
 */
void SubMsgBegin();
void SubMsgEnd();

/**
 * Log the entry into message body (4 spaces indent).
 */
void MsgEntry(const char* aEntryText, ...) MOZ_FORMAT_PRINTF(1, 2);

/**
 * Log the text, two spaces offset is used.
 */
void Text(const char* aText);

/**
 * Log the accessible object address as message entry (4 spaces indent).
 */
void Address(const char* aDescr, LocalAccessible* aAcc);

/**
 * Log the DOM node info as message entry.
 */
void Node(const char* aDescr, nsINode* aNode);

/**
 * Log the document accessible info as message entry.
 */
void Document(DocAccessible* aDocument);

/**
 * Log the accessible and its DOM node as a message entry.
 */
void AccessibleInfo(const char* aDescr, LocalAccessible* aAccessible);
void AccessibleNNode(const char* aDescr, LocalAccessible* aAccessible);
void AccessibleNNode(const char* aDescr, nsINode* aNode);

/**
 * Log the DOM event.
 */
void DOMEvent(const char* aDescr, nsINode* aOrigTarget,
              const nsAString& aEventType);

/**
 * Log the call stack, two spaces offset is used.
 */
void Stack();

/**
 * Enable logging of the specified modules, all other modules aren't logged.
 */
void Enable(const nsCString& aModules);

/**
 * Enable logging of modules specified by A11YLOG environment variable,
 * all other modules aren't logged.
 */
void CheckEnv();

}  // namespace logging

}  // namespace a11y
}  // namespace mozilla

#endif