tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Logging.h (5948B)


      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_logs_h__
      8 #define mozilla_a11y_logs_h__
      9 
     10 #include "nscore.h"
     11 #include "nsStringFwd.h"
     12 #include "mozilla/Attributes.h"
     13 
     14 class nsINode;
     15 class nsIRequest;
     16 class nsISupports;
     17 class nsIWebProgress;
     18 
     19 namespace mozilla {
     20 
     21 namespace dom {
     22 class Document;
     23 class Selection;
     24 }  // namespace dom
     25 
     26 namespace a11y {
     27 
     28 class AccEvent;
     29 class LocalAccessible;
     30 class DocAccessible;
     31 class OuterDocAccessible;
     32 
     33 namespace logging {
     34 
     35 enum EModules {
     36  eDocLoad = 1 << 0,
     37  eDocCreate = 1 << 1,
     38  eDocDestroy = 1 << 2,
     39  eDocLifeCycle = eDocLoad | eDocCreate | eDocDestroy,
     40 
     41  eEvents = 1 << 3,
     42  ePlatforms = 1 << 4,
     43  eText = 1 << 5,
     44  eTree = 1 << 6,
     45  eTreeSize = 1 << 7,
     46 
     47  eDOMEvents = 1 << 8,
     48  eFocus = 1 << 9,
     49  eSelection = 1 << 10,
     50  eNotifications = eDOMEvents | eSelection | eFocus,
     51 
     52  // extras
     53  eStack = 1 << 11,
     54  eVerbose = 1 << 12,
     55  eCache = 1 << 13,
     56 };
     57 
     58 /**
     59 * Return true if any of the given modules is logged.
     60 */
     61 bool IsEnabled(uint32_t aModules);
     62 
     63 /**
     64 * Return true if all of the given modules are logged.
     65 */
     66 bool IsEnabledAll(uint32_t aModules);
     67 
     68 /**
     69 * Return true if the given module is logged.
     70 */
     71 bool IsEnabled(const nsAString& aModules);
     72 
     73 /**
     74 * Log the document loading progress.
     75 */
     76 void DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
     77             nsIRequest* aRequest, uint32_t aStateFlags);
     78 void DocLoad(const char* aMsg, dom::Document* aDocumentNode);
     79 void DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget);
     80 
     81 /**
     82 * Log that document load event was fired.
     83 */
     84 void DocLoadEventFired(AccEvent* aEvent);
     85 
     86 /**
     87 * Log that document laod event was handled.
     88 */
     89 void DocLoadEventHandled(AccEvent* aEvent);
     90 
     91 /**
     92 * Log the document was created.
     93 */
     94 void DocCreate(const char* aMsg, dom::Document* aDocumentNode,
     95               DocAccessible* aDocument = nullptr);
     96 
     97 /**
     98 * Log the document was destroyed.
     99 */
    100 void DocDestroy(const char* aMsg, dom::Document* aDocumentNode,
    101                DocAccessible* aDocument = nullptr);
    102 
    103 /**
    104 * Log the outer document was destroyed.
    105 */
    106 void OuterDocDestroy(OuterDocAccessible* OuterDoc);
    107 
    108 /**
    109 * Log the focus notification target.
    110 */
    111 void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
    112                             LocalAccessible* aTarget);
    113 void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
    114                             nsINode* aTargetNode);
    115 void FocusNotificationTarget(const char* aMsg, const char* aTargetDescr,
    116                             nsISupports* aTargetThing);
    117 
    118 /**
    119 * Log a cause of active item descendant change (submessage).
    120 */
    121 void ActiveItemChangeCausedBy(const char* aMsg, LocalAccessible* aTarget);
    122 
    123 /**
    124 * Log the active widget (submessage).
    125 */
    126 void ActiveWidget(LocalAccessible* aWidget);
    127 
    128 /**
    129 * Log the focus event was dispatched (submessage).
    130 */
    131 void FocusDispatched(LocalAccessible* aTarget);
    132 
    133 /**
    134 * Log the selection change.
    135 */
    136 void SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
    137               int16_t aReason);
    138 
    139 /**
    140 * Log the given accessible elements info.
    141 */
    142 void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
    143 void TreeInfo(const char* aMsg, uint32_t aExtraFlags, const char* aMsg1,
    144              LocalAccessible* aAcc, const char* aMsg2, nsINode* aNode);
    145 void TreeInfo(const char* aMsg, uint32_t aExtraFlags, LocalAccessible* aParent);
    146 
    147 /**
    148 * Log the accessible/DOM tree.
    149 */
    150 typedef const char* (*GetTreePrefix)(void* aData, LocalAccessible*);
    151 void Tree(const char* aTitle, const char* aMsgText, LocalAccessible* aRoot,
    152          GetTreePrefix aPrefixFunc = nullptr,
    153          void* aGetTreePrefixData = nullptr);
    154 void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);
    155 
    156 /**
    157 * Log the tree size in bytes.
    158 */
    159 void TreeSize(const char* aTitle, const char* aMsgText, LocalAccessible* aRoot);
    160 
    161 /**
    162 * Log the message ('title: text' format) on new line. Print the start and end
    163 * boundaries of the message body designated by '{' and '}' (2 spaces indent for
    164 * body).
    165 */
    166 void MsgBegin(const char* aTitle, const char* aMsgText, ...)
    167    MOZ_FORMAT_PRINTF(2, 3);
    168 void MsgEnd();
    169 
    170 /**
    171 * Print start and end boundaries of the message body designated by '{' and '}'
    172 * (2 spaces indent for body).
    173 */
    174 void SubMsgBegin();
    175 void SubMsgEnd();
    176 
    177 /**
    178 * Log the entry into message body (4 spaces indent).
    179 */
    180 void MsgEntry(const char* aEntryText, ...) MOZ_FORMAT_PRINTF(1, 2);
    181 
    182 /**
    183 * Log the text, two spaces offset is used.
    184 */
    185 void Text(const char* aText);
    186 
    187 /**
    188 * Log the accessible object address as message entry (4 spaces indent).
    189 */
    190 void Address(const char* aDescr, LocalAccessible* aAcc);
    191 
    192 /**
    193 * Log the DOM node info as message entry.
    194 */
    195 void Node(const char* aDescr, nsINode* aNode);
    196 
    197 /**
    198 * Log the document accessible info as message entry.
    199 */
    200 void Document(DocAccessible* aDocument);
    201 
    202 /**
    203 * Log the accessible and its DOM node as a message entry.
    204 */
    205 void AccessibleInfo(const char* aDescr, LocalAccessible* aAccessible);
    206 void AccessibleNNode(const char* aDescr, LocalAccessible* aAccessible);
    207 void AccessibleNNode(const char* aDescr, nsINode* aNode);
    208 
    209 /**
    210 * Log the DOM event.
    211 */
    212 void DOMEvent(const char* aDescr, nsINode* aOrigTarget,
    213              const nsAString& aEventType);
    214 
    215 /**
    216 * Log the call stack, two spaces offset is used.
    217 */
    218 void Stack();
    219 
    220 /**
    221 * Enable logging of the specified modules, all other modules aren't logged.
    222 */
    223 void Enable(const nsCString& aModules);
    224 
    225 /**
    226 * Enable logging of modules specified by A11YLOG environment variable,
    227 * all other modules aren't logged.
    228 */
    229 void CheckEnv();
    230 
    231 }  // namespace logging
    232 
    233 }  // namespace a11y
    234 }  // namespace mozilla
    235 
    236 #endif