Bug 614552 - fire reorder event on XUL tree when treeview is changed, r=marcoz, davidb, a=blocking
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 25 Nov 2010 23:56:37 +0800
changeset 58222 6038dc8945d8
parent 58221 eb8d110a117a
child 58223 c5becae1d0ad
push id17208
push usersurkov.alexander@gmail.com
push dateThu, 25 Nov 2010 15:58:46 +0000
treeherdermozilla-central@c5becae1d0ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz, davidb, blocking
bugs614552
milestone2.0b8pre
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 614552 - fire reorder event on XUL tree when treeview is changed, r=marcoz, davidb, a=blocking
accessible/src/xul/nsXULTreeAccessible.cpp
accessible/tests/mochitest/actions/test_tree.xul
accessible/tests/mochitest/actions/test_treegrid.xul
accessible/tests/mochitest/attributes/test_obj_group_tree.xul
accessible/tests/mochitest/events/test_tree.xul
accessible/tests/mochitest/relations/test_tree.xul
accessible/tests/mochitest/selectable/test_tree.xul
accessible/tests/mochitest/states/test_tree.xul
accessible/tests/mochitest/table/test_headers_tree.xul
accessible/tests/mochitest/table/test_indexes_tree.xul
accessible/tests/mochitest/table/test_sels_tree.xul
accessible/tests/mochitest/table/test_struct_tree.xul
accessible/tests/mochitest/tree/test_tree.xul
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -591,36 +591,28 @@ nsXULTreeAccessible::TreeViewInvalidated
 }
 
 void
 nsXULTreeAccessible::TreeViewChanged()
 {
   if (IsDefunct())
     return;
 
-  // Fire only notification destroy/create events on accessible tree to lie to
-  // AT because it should be expensive to fire destroy events for each tree item
-  // in cache.
-  nsRefPtr<AccEvent> eventDestroy =
-    new AccEvent(nsIAccessibleEvent::EVENT_HIDE, this);
-  if (!eventDestroy)
-    return;
-
-  FirePlatformEvent(eventDestroy);
+  // Fire reorder event on tree accessible on accessible tree (do not fire
+  // show/hide events on tree items because it can be expensive to fire them for
+  // each tree item.
+  nsRefPtr<AccEvent> reorderEvent =
+    new AccEvent(nsIAccessibleEvent::EVENT_REORDER, this, eAutoDetect,
+                 AccEvent::eCoalesceFromSameSubtree);
+  if (reorderEvent)
+    GetDocAccessible()->FireDelayedAccessibleEvent(reorderEvent);
 
+  // Clear cache.
   ClearCache(mAccessibleCache);
-
   mTree->GetView(getter_AddRefs(mTreeView));
-
-  nsRefPtr<AccEvent> eventCreate =
-    new AccEvent(nsIAccessibleEvent::EVENT_SHOW, this);
-  if (!eventCreate)
-    return;
-
-  FirePlatformEvent(eventCreate);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeAccessible: protected implementation
 
 already_AddRefed<nsAccessible>
 nsXULTreeAccessible::CreateTreeItemAccessible(PRInt32 aRow)
 {
--- a/accessible/tests/mochitest/actions/test_tree.xul
+++ b/accessible/tests/mochitest/actions/test_tree.xul
@@ -46,17 +46,16 @@
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     // gA11yEventDumpID = "debug";
 
     function doTestActions()
     {
       var treeNode = getNode("tree");
-      treeNode.removeEventListener("TreeViewChanged", doTestActions, false);
 
       var treeBodyNode = treeNode.boxObject.treeBody;
 
       var tree = getAccessible(treeNode);
       var expandedTreeItem = tree.getChildAt(2);
       var collapsedTreeItem = tree.getChildAt(5);
 
       var actions = [
@@ -95,17 +94,17 @@
       ];
 
       testActions(actions); // Will call SimpleTest.finish();
     }
 
     function doTest()
     {
       var treeNode = getNode("tree");
-      treeNode.addEventListener("TreeViewChanged", doTestActions, false);
+      waitForEvent(EVENT_REORDER, treeNode, doTestActions);
       treeNode.view = new nsTreeTreeView();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
 
--- a/accessible/tests/mochitest/actions/test_treegrid.xul
+++ b/accessible/tests/mochitest/actions/test_treegrid.xul
@@ -63,17 +63,16 @@
     }
 
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     function doTestActions()
     {
       var treeNode = getNode("tabletree");
-      treeNode.removeEventListener("TreeViewChanged", doTestActions, false);
 
       var treeBodyNode = treeNode.boxObject.treeBody;
       treeNode.focus();
 
       var tree = getAccessible(treeNode);
 
       var expandedTreeItem = tree.getChildAt(2);
       var collapsedTreeItem = tree.getChildAt(5);
@@ -145,17 +144,17 @@
       testActions(actions); // Will call SimpleTest.finish();
     }
 
     // gA11yEventDumpID = "debug";
 
     function doTest()
     {
       var treeNode = getNode("tabletree");
-      treeNode.addEventListener("TreeViewChanged", doTestActions, false);
+      waitForEvent(EVENT_REORDER, treeNode, doTestActions);
       treeNode.view = new nsTreeTreeView();
     }
 
     function test1()
     {
       var boxObj = getNode("tabletree").treeBoxObject;
       boxObj.view.setCellValue(0, boxObj.columns.firstColumn, "false");
     }
--- a/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
+++ b/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
@@ -13,26 +13,27 @@
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../attributes.js" />
+  <script type="application/javascript"
+          src="../events.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     function doTestAttrs()
     {
       var treeNode = getNode("tree");
-      treeNode.removeEventListener("TreeViewChanged", doTestAttrs, false);
 
       var tree = getAccessible(treeNode);
       var treeitem1 = tree.firstChild.nextSibling;
       testGroupAttrs(treeitem1, 1, 4, 1);
 
       var treeitem2 = treeitem1.nextSibling;
       testGroupAttrs(treeitem2, 2, 4, 1);
 
@@ -49,17 +50,17 @@
       testGroupAttrs(treeitem6, 4, 4, 1);
 
       SimpleTest.finish();
     }
 
     function doTest()
     {
       var treeNode = getNode("tree");
-      treeNode.addEventListener("TreeViewChanged", doTestAttrs, false);
+      waitForEvent(EVENT_REORDER, treeNode, doTestAttrs);
       treeNode.view = new nsTreeTreeView();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
 
--- a/accessible/tests/mochitest/events/test_tree.xul
+++ b/accessible/tests/mochitest/events/test_tree.xul
@@ -33,20 +33,16 @@
     /**
      * Check TreeViewChanged event and run through accessible tree to ensure
      * it's created.
      */
     function treeViewChangedChecker(aMsg)
     {
       this.type = "TreeViewChanged";
       this.target = gTree;
-      this.check = function check(aEvent)
-      {
-        ensureAccessibleTree(gTree);
-      }
       this.getID = function getID()
       {
         return "TreeViewChanged";
       }
     }
 
     /**
      * Check TreeRowCountChanged event.
@@ -128,19 +124,27 @@
      */
     function setTreeView()
     {
       this.invoke = function setTreeView_invoke()
       {
         gTreeBox.view = gView;
       }
 
-      this.getID = function setTreeView_getID() { return "TreeViewChanged"; }
+      this.finalCheck = function setTreeView_finalCheck(aEvent)
+      {
+        ensureAccessibleTree(gTree);
+      }
 
-      this.eventSeq = [ new treeViewChangedChecker() ];
+      this.getID = function setTreeView_getID() { return "set tree view"; }
+
+      this.eventSeq = [
+        new treeViewChangedChecker(),
+        new invokerChecker(EVENT_REORDER, gTree)
+      ];
     };
 
     /**
      * Insert row at 0 index and checks TreeRowCountChanged and TreeInvalidated
      * event.
      */
     function insertRow()
     {
--- a/accessible/tests/mochitest/relations/test_tree.xul
+++ b/accessible/tests/mochitest/relations/test_tree.xul
@@ -12,27 +12,28 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
+          src="../events.js" />
+  <script type="application/javascript"
           src="../relations.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     function doTestRelations()
     {
       var treeNode = getNode("tree");
-      treeNode.removeEventListener("TreeViewChanged", doTestRelations, false);
 
       var tree = getAccessible(treeNode);
       var treeitem1 = tree.firstChild.nextSibling;
       testRelation(treeitem1, RELATION_NODE_CHILD_OF, [tree]);
 
       var treeitem2 = treeitem1.nextSibling;
       testRelation(treeitem2, RELATION_NODE_CHILD_OF, [tree]);
 
@@ -49,17 +50,17 @@
       testRelation(treeitem6, RELATION_NODE_CHILD_OF, [tree]);
 
       SimpleTest.finish();
     }
 
     function doTest()
     {
       var treeNode = getNode("tree");
-      treeNode.addEventListener("TreeViewChanged", doTestRelations, false);
+      waitForEvent(EVENT_REORDER, treeNode, doTestRelations);
       treeNode.view = new nsTreeTreeView();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
 
--- a/accessible/tests/mochitest/selectable/test_tree.xul
+++ b/accessible/tests/mochitest/selectable/test_tree.xul
@@ -14,21 +14,21 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
+          src="../events.js" />
+  <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
           src="../states.js" />
-  <script type="application/javascript"
-          src="../events.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     // gA11yEventDumpID = "debug";
 
@@ -78,17 +78,17 @@
         "tree processor for " + prettyName(aTreeID);
       }
     }
 
     var gQueue = null;
 
     function doTest()
     {
-      gQueue = new eventQueue("TreeViewChanged");
+      gQueue = new eventQueue(EVENT_REORDER);
       gQueue.push(new statesChecker("tree", new nsTreeTreeView()));
       gQueue.push(new statesChecker("treesingle", new nsTreeTreeView()));
       gQueue.push(new statesChecker("treecell", new nsTreeTreeView()));
       gQueue.push(new statesChecker("treetext", new nsTreeTreeView()));
       gQueue.push(new statesChecker("tabletree", new nsTreeTreeView()));
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
--- a/accessible/tests/mochitest/states/test_tree.xul
+++ b/accessible/tests/mochitest/states/test_tree.xul
@@ -79,17 +79,17 @@
         "tree processor for " + prettyName(aTreeID);
       }
     }
 
     var gQueue = null;
 
     function doTest()
     {
-      gQueue = new eventQueue("TreeViewChanged");
+      gQueue = new eventQueue(EVENT_REORDER);
       gQueue.push(new statesChecker("tree", new nsTreeTreeView()));
       gQueue.push(new statesChecker("treesingle", new nsTreeTreeView()));
       gQueue.push(new statesChecker("tabletree", new nsTreeTreeView()));
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
--- a/accessible/tests/mochitest/table/test_headers_tree.xul
+++ b/accessible/tests/mochitest/table/test_headers_tree.xul
@@ -12,16 +12,18 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
+          src="../events.js" />
+  <script type="application/javascript"
           src="../table.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     var gTree = null;
@@ -32,24 +34,22 @@
 
     function doTest()
     {
       // Initialize the tree
       gTree = document.getElementById("tree");
       gTreeBox = gTree.treeBoxObject;
       gView = new nsTableTreeView(3);
 
-      gTree.addEventListener("TreeViewChanged", continueTest, false);
+      waitForEvent(EVENT_REORDER, gTree, continueTest);
       gTreeBox.view = gView;
     }
 
     function continueTest()
     {
-      gTree.removeEventListener("TreeViewChanged", continueTest, false);
-
       var treeAcc = getAccessible(gTree, [nsIAccessibleTable]);
 
       var headerInfoMap = [
         {
           cell: treeAcc.getCellAt(0, 0),
           rowHeaderCells: [],
           columnHeaderCells: [ "col" ]
         },
--- a/accessible/tests/mochitest/table/test_indexes_tree.xul
+++ b/accessible/tests/mochitest/table/test_indexes_tree.xul
@@ -12,16 +12,18 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
+          src="../events.js" />
+  <script type="application/javascript"
           src="../table.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     var gTree = null;
@@ -32,24 +34,22 @@
 
     function doTest()
     {
       // Initialize the tree
       gTree = document.getElementById("tree");
       gTreeBox = gTree.treeBoxObject;
       gView = new nsTableTreeView(3);
 
-      gTree.addEventListener("TreeViewChanged", continueTest, false);
+      waitForEvent(EVENT_REORDER, gTree, continueTest);
       gTreeBox.view = gView;
     }
 
     function continueTest()
     {
-      gTree.removeEventListener("TreeViewChanged", continueTest, false);
-
       var idxes = [
         [0, 1],
         [2, 3],
         [4, 5]
       ];
       testTableIndexes(gTree, idxes);
 
       SimpleTest.finish();
--- a/accessible/tests/mochitest/table/test_sels_tree.xul
+++ b/accessible/tests/mochitest/table/test_sels_tree.xul
@@ -12,16 +12,18 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
+          src="../events.js" />
+  <script type="application/javascript"
           src="../states.js" />
   <script type="application/javascript"
           src="../table.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
@@ -34,24 +36,22 @@
 
     function doTest()
     {
       // Initialize the tree
       gTree = document.getElementById("tree");
       gTreeBox = gTree.treeBoxObject;
       gView = new nsTableTreeView(3);
 
-      gTree.addEventListener("TreeViewChanged", continueTest, false);
+      waitForEvent(EVENT_REORDER, gTree, continueTest);
       gTreeBox.view = gView;
     }
 
     function continueTest()
     {
-      gTree.removeEventListener("TreeViewChanged", continueTest, false);
-
       var cellsArray =
       [
         [false, false],
         [false, false],
         [false, false]
       ];
 
       testTableSelection(gTree, cellsArray);
--- a/accessible/tests/mochitest/table/test_struct_tree.xul
+++ b/accessible/tests/mochitest/table/test_struct_tree.xul
@@ -12,16 +12,18 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
+          src="../events.js" />
+  <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
           src="../table.js" />
 
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
@@ -34,24 +36,22 @@
 
     function doTest()
     {
       // Initialize the tree
       gTree = document.getElementById("table");
       gTreeBox = gTree.treeBoxObject;
       gView = new nsTableTreeView(3);
 
-      gTree.addEventListener("TreeViewChanged", continueTest, false);
+      waitForEvent(EVENT_REORDER, gTree, continueTest);
       gTreeBox.view = gView;
     }
 
     function continueTest()
     {
-      gTree.removeEventListener("TreeViewChanged", continueTest, false);
-
       var cellsArray = [
         [kDataCell, kDataCell],
         [kDataCell, kDataCell],
         [kDataCell, kDataCell]
       ];
 
       testTableStruct(gTree, cellsArray, kTreeColumnHeader);
 
--- a/accessible/tests/mochitest/tree/test_tree.xul
+++ b/accessible/tests/mochitest/tree/test_tree.xul
@@ -112,17 +112,17 @@
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     // gA11yEventDumpID = "debug";
     var gQueue = null;
 
     function doTest()
     {
-      var gQueue = new eventQueue("TreeViewChanged");
+      var gQueue = new eventQueue(EVENT_REORDER);
 
       gQueue.push(new treeChecker("list", new nsTableTreeView(3), ROLE_LIST));
       gQueue.push(new treeChecker("tree", new nsTreeTreeView(), ROLE_OUTLINE));
       gQueue.push(new treeChecker("table", new nsTableTreeView(3), ROLE_TABLE));
       gQueue.push(new treeChecker("treetable", new nsTreeTreeView(), ROLE_TREE_TABLE));
 
       gQueue.invoke(); // Will call SimpleTest.finish()
     }