Bug 1278294 - add DOM tree logging, part=7, r=yzen
authorAlexander Surkov <surkov.alexander@gmail.com>
Tue, 21 Jun 2016 07:41:06 -0400
changeset 302171 46178702a3cae1d9f18228c4d7a0af99a0b0ebcc
parent 302170 24999edead4ee8f1fa54c2820a436ba4b266b38b
child 302172 01bfa6d7d56176ac9adda98040b7a66b38dfebef
push id78630
push usersurkov.alexander@gmail.com
push dateTue, 21 Jun 2016 11:41:20 +0000
treeherdermozilla-inbound@46178702a3ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs1278294
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1278294 - add DOM tree logging, part=7, r=yzen
accessible/base/Logging.cpp
accessible/base/Logging.h
--- a/accessible/base/Logging.cpp
+++ b/accessible/base/Logging.cpp
@@ -710,16 +710,47 @@ logging::Tree(const char* aTitle, const 
     }
   }
   while (root && !root->IsDoc());
 
   logging::MsgEnd();
 }
 
 void
+logging::DOMTree(const char* aTitle, const char* aMsgText,
+                 DocAccessible* aDocument)
+{
+  logging::MsgBegin(aTitle, aMsgText);
+  nsAutoString level;
+  nsINode* root = aDocument->DocumentNode();
+  do {
+    printf("%s", NS_ConvertUTF16toUTF8(level).get());
+    logging::Node("", root);
+    if (root->GetFirstChild()) {
+      level.Append(NS_LITERAL_STRING("  "));
+      root = root->GetFirstChild();
+      continue;
+    }
+    if (root->GetNextSibling()) {
+      root = root->GetNextSibling();
+      continue;
+    }
+    while ((root = root->GetParentNode())) {
+      level.Cut(0, 2);
+      if (root->GetNextSibling()) {
+        root = root->GetNextSibling();
+        break;
+      }
+    }
+  }
+  while (root);
+  logging::MsgEnd();
+}
+
+void
 logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
 {
   printf("\nA11Y %s: ", aTitle);
 
   va_list argptr;
   va_start(argptr, aMsgText);
   vprintf(aMsgText, argptr);
   va_end(argptr);
--- a/accessible/base/Logging.h
+++ b/accessible/base/Logging.h
@@ -135,21 +135,22 @@ void SelChange(nsISelection* aSelection,
  */
 void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
 void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
               const char* aMsg1, Accessible* aAcc,
               const char* aMsg2, nsINode* aNode);
 void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
 
 /**
- * Log the accessible tree.
+ * Log the accessible/DOM tree.
  */
 typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
 void Tree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc,
           GetTreePrefix aPrefixFunc = nullptr, void* aGetTreePrefixData = nullptr);
+void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);
 
 /**
  * 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, ...);
 void MsgEnd();