Bug 775661 - Added dump tree Logger method, and states to string function. r=davidb
authorEitan Isaacson <eitan@monotonous.org>
Fri, 20 Jul 2012 09:46:54 -0700
changeset 99934 69a69e2a873ddeb6dfbda04cb5ce4a45ef6086c1
parent 99933 0ec90d4991ca25287d2c742bdd574840efcc9f51
child 99935 6a893f7cea3ad129933b6561ef558045650bd309
push id23157
push userryanvm@gmail.com
push dateSat, 21 Jul 2012 03:56:05 +0000
treeherdermozilla-central@045c11dd41a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs775661
milestone17.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 775661 - Added dump tree Logger method, and states to string function. r=davidb
accessible/src/jsat/Utils.jsm
--- a/accessible/src/jsat/Utils.jsm
+++ b/accessible/src/jsat/Utils.jsm
@@ -160,10 +160,37 @@ var Logger = {
       let event = aEvent.QueryInterface(Ci.nsIAccessibleStateChangeEvent);
       let stateStrings = (event.isExtraState()) ?
         gAccRetrieval.getStringStates(0, event.state) :
         gAccRetrieval.getStringStates(event.state, 0);
       str += ' (' + stateStrings.item(0) + ')';
     }
 
     return str;
-  }
+  },
+
+  statesToString: function statesToString(aAccessible) {
+    let [state, extState] = Utils.getStates(aAccessible);
+    let stringArray = [];
+    let stateStrings = gAccRetrieval.getStringStates(state, extState);
+    for (var i=0; i < stateStrings.length; i++)
+      stringArray.push(stateStrings.item(i));
+    return stringArray.join(' ');
+  },
+
+  dumpTree: function dumpTree(aLogLevel, aRootAccessible) {
+    if (aLogLevel < this.logLevel)
+      return;
+
+    this._dumpTreeInternal(aLogLevel, aRootAccessible, 0);
+  },
+
+  _dumpTreeInternal: function _dumpTreeInternal(aLogLevel, aAccessible, aIndent) {
+    let indentStr = '';
+    for (var i=0; i < aIndent; i++)
+      indentStr += ' ';
+    this.log(aLogLevel, indentStr,
+             this.accessibleToString(aAccessible),
+             '(' + this.statesToString(aAccessible) + ')');
+    for (var i=0; i < aAccessible.childCount; i++)
+      this._dumpTreeInternal(aLogLevel, aAccessible.getChildAt(i), aIndent + 1);
+    }
 };