Logging.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_a11y_logs_h__
  6. #define mozilla_a11y_logs_h__
  7. #include "nscore.h"
  8. #include "nsStringFwd.h"
  9. class nsIDocument;
  10. class nsINode;
  11. class nsIRequest;
  12. class nsISelection;
  13. class nsISupports;
  14. class nsIWebProgress;
  15. namespace mozilla {
  16. namespace a11y {
  17. class AccEvent;
  18. class Accessible;
  19. class DocAccessible;
  20. class OuterDocAccessible;
  21. namespace logging {
  22. enum EModules {
  23. eDocLoad = 1 << 0,
  24. eDocCreate = 1 << 1,
  25. eDocDestroy = 1 << 2,
  26. eDocLifeCycle = eDocLoad | eDocCreate | eDocDestroy,
  27. eEvents = 1 << 3,
  28. eEventTree = 1 << 4,
  29. ePlatforms = 1 << 5,
  30. eText = 1 << 6,
  31. eTree = 1 << 7,
  32. eDOMEvents = 1 << 8,
  33. eFocus = 1 << 9,
  34. eSelection = 1 << 10,
  35. eNotifications = eDOMEvents | eSelection | eFocus,
  36. // extras
  37. eStack = 1 << 11,
  38. eVerbose = 1 << 12
  39. };
  40. /**
  41. * Return true if any of the given modules is logged.
  42. */
  43. bool IsEnabled(uint32_t aModules);
  44. /**
  45. * Return true if all of the given modules are logged.
  46. */
  47. bool IsEnabledAll(uint32_t aModules);
  48. /**
  49. * Return true if the given module is logged.
  50. */
  51. bool IsEnabled(const nsAString& aModules);
  52. /**
  53. * Log the document loading progress.
  54. */
  55. void DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
  56. nsIRequest* aRequest, uint32_t aStateFlags);
  57. void DocLoad(const char* aMsg, nsIDocument* aDocumentNode);
  58. void DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget);
  59. /**
  60. * Log that document load event was fired.
  61. */
  62. void DocLoadEventFired(AccEvent* aEvent);
  63. /**
  64. * Log that document laod event was handled.
  65. */
  66. void DocLoadEventHandled(AccEvent* aEvent);
  67. /**
  68. * Log the document was created.
  69. */
  70. void DocCreate(const char* aMsg, nsIDocument* aDocumentNode,
  71. DocAccessible* aDocument = nullptr);
  72. /**
  73. * Log the document was destroyed.
  74. */
  75. void DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
  76. DocAccessible* aDocument = nullptr);
  77. /**
  78. * Log the outer document was destroyed.
  79. */
  80. void OuterDocDestroy(OuterDocAccessible* OuterDoc);
  81. /**
  82. * Log the focus notification target.
  83. */
  84. void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
  85. Accessible* aTarget);
  86. void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
  87. nsINode* aTargetNode);
  88. void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
  89. nsISupports* aTargetThing);
  90. /**
  91. * Log a cause of active item descendant change (submessage).
  92. */
  93. void ActiveItemChangeCausedBy(const char* aMsg, Accessible* aTarget);
  94. /**
  95. * Log the active widget (submessage).
  96. */
  97. void ActiveWidget(Accessible* aWidget);
  98. /**
  99. * Log the focus event was dispatched (submessage).
  100. */
  101. void FocusDispatched(Accessible* aTarget);
  102. /**
  103. * Log the selection change.
  104. */
  105. void SelChange(nsISelection* aSelection, DocAccessible* aDocument,
  106. int16_t aReason);
  107. /**
  108. * Log the given accessible elements info.
  109. */
  110. void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
  111. void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
  112. const char* aMsg1, Accessible* aAcc,
  113. const char* aMsg2, nsINode* aNode);
  114. void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
  115. /**
  116. * Log the accessible/DOM tree.
  117. */
  118. typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
  119. void Tree(const char* aTitle, const char* aMsgText, Accessible* aRoot,
  120. GetTreePrefix aPrefixFunc = nullptr, void* aGetTreePrefixData = nullptr);
  121. void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);
  122. /**
  123. * Log the message ('title: text' format) on new line. Print the start and end
  124. * boundaries of the message body designated by '{' and '}' (2 spaces indent for
  125. * body).
  126. */
  127. void MsgBegin(const char* aTitle, const char* aMsgText, ...);
  128. void MsgEnd();
  129. /**
  130. * Print start and end boundaries of the message body designated by '{' and '}'
  131. * (2 spaces indent for body).
  132. */
  133. void SubMsgBegin();
  134. void SubMsgEnd();
  135. /**
  136. * Log the entry into message body (4 spaces indent).
  137. */
  138. void MsgEntry(const char* aEntryText, ...);
  139. /**
  140. * Log the text, two spaces offset is used.
  141. */
  142. void Text(const char* aText);
  143. /**
  144. * Log the accessible object address as message entry (4 spaces indent).
  145. */
  146. void Address(const char* aDescr, Accessible* aAcc);
  147. /**
  148. * Log the DOM node info as message entry.
  149. */
  150. void Node(const char* aDescr, nsINode* aNode);
  151. /**
  152. * Log the document accessible info as message entry.
  153. */
  154. void Document(DocAccessible* aDocument);
  155. /**
  156. * Log the accessible and its DOM node as a message entry.
  157. */
  158. void AccessibleInfo(const char* aDescr, Accessible* aAccessible);
  159. void AccessibleNNode(const char* aDescr, Accessible* aAccessible);
  160. void AccessibleNNode(const char* aDescr, nsINode* aNode);
  161. /**
  162. * Log the DOM event.
  163. */
  164. void DOMEvent(const char* aDescr, nsINode* aOrigTarget,
  165. const nsAString& aEventType);
  166. /**
  167. * Log the call stack, two spaces offset is used.
  168. */
  169. void Stack();
  170. /**
  171. * Enable logging of the specified modules, all other modules aren't logged.
  172. */
  173. void Enable(const nsAFlatCString& aModules);
  174. /**
  175. * Enable logging of modules specified by A11YLOG environment variable,
  176. * all other modules aren't logged.
  177. */
  178. void CheckEnv();
  179. } // namespace logging
  180. } // namespace a11y
  181. } // namespace mozilla
  182. #endif