Bug 691248 - XUL tree items shouldn't pick up relations from XUL tree, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 03 Oct 2011 23:26:11 +0900
changeset 77996 b963098e5361846337f0c44ced6a1f4564a3ab7f
parent 77995 11d110b351c536091fbd594599b23d5dedd5202e
child 77997 265d39da5c3da955ad5a804b791651cc6b612dd5
push id21260
push usermbrubeck@mozilla.com
push dateMon, 03 Oct 2011 23:22:50 +0000
treeherdermozilla-central@25b8388347af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs691248
milestone10.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 691248 - XUL tree items shouldn't pick up relations from XUL tree, r=tbsaunde
accessible/src/xul/nsXULTreeAccessible.cpp
accessible/src/xul/nsXULTreeGridAccessible.cpp
accessible/src/xul/nsXULTreeGridAccessible.h
accessible/tests/mochitest/relations/test_tree.xul
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -812,32 +812,27 @@ nsXULTreeItemAccessibleBase::TakeFocus()
   // focus event will be fired here
   return nsAccessible::TakeFocus();
 }
 
 Relation
 nsXULTreeItemAccessibleBase::RelationByType(PRUint32 aType)
 {
   if (aType != nsIAccessibleRelation::RELATION_NODE_CHILD_OF)
-    return nsAccessible::RelationByType(aType);
+    return Relation();
 
-  Relation rel;
     PRInt32 parentIndex;
   if (!NS_SUCCEEDED(mTreeView->GetParentIndex(mRow, &parentIndex)))
-    return rel;
+    return Relation();
 
-  if (parentIndex == -1) {
-    rel.AppendTarget(mParent);
-    return rel;
-  }
+  if (parentIndex == -1)
+    return Relation(mParent);
 
   nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(mParent);
-
-  rel.AppendTarget(treeAcc->GetTreeItemAccessible(parentIndex));
-  return rel;
+  return Relation(treeAcc->GetTreeItemAccessible(parentIndex));
 }
 
 PRUint8
 nsXULTreeItemAccessibleBase::ActionCount()
 {
   // "activate" action is available for all treeitems, "expand/collapse" action
   // is avaible for treeitem which is container.
   return IsExpandable() ? 2 : 1;
--- a/accessible/src/xul/nsXULTreeGridAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp
@@ -38,16 +38,17 @@
 
 #include "nsXULTreeGridAccessibleWrap.h"
 
 #include "nsAccCache.h"
 #include "nsAccessibilityService.h"
 #include "nsAccUtils.h"
 #include "nsDocAccessible.h"
 #include "nsEventShell.h"
+#include "Relation.h"
 #include "States.h"
 
 #include "nsITreeSelection.h"
 #include "nsComponentManagerUtils.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1232,16 +1233,22 @@ nsXULTreeGridCellAccessible::NativeState
 }
 
 PRInt32
 nsXULTreeGridCellAccessible::IndexInParent() const
 {
   return GetColumnIndex();
 }
 
+Relation
+nsXULTreeGridCellAccessible::RelationByType(PRUint32 aType)
+{
+  return Relation();
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeGridCellAccessible: public implementation
 
 PRInt32
 nsXULTreeGridCellAccessible::GetColumnIndex() const
 {
   PRInt32 index = 0;
   nsCOMPtr<nsITreeColumn> column = mColumn;
--- a/accessible/src/xul/nsXULTreeGridAccessible.h
+++ b/accessible/src/xul/nsXULTreeGridAccessible.h
@@ -158,16 +158,17 @@ public:
   virtual bool IsDefunct() const;
   virtual bool Init();
   virtual bool IsPrimaryForNode() const;
 
   // nsAccessible
   virtual nsAccessible* FocusedChild();
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
   virtual PRInt32 IndexInParent() const;
+  virtual Relation RelationByType(PRUint32 aType);
   virtual PRUint32 NativeRole();
   virtual PRUint64 NativeState();
 
   // ActionAccessible
   virtual PRUint8 ActionCount();
 
   // nsXULTreeGridCellAccessible
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
--- a/accessible/tests/mochitest/relations/test_tree.xul
+++ b/accessible/tests/mochitest/relations/test_tree.xul
@@ -42,16 +42,20 @@
       testRelation(treeitem4, RELATION_NODE_CHILD_OF, [treeitem2]);
 
       var treeitem5 = treeitem4.nextSibling;
       testRelation(treeitem5, RELATION_NODE_CHILD_OF, [tree]);
 
       var treeitem6 = treeitem5.nextSibling;
       testRelation(treeitem6, RELATION_NODE_CHILD_OF, [tree]);
 
+      // treeitems and treecells shouldn't pick up relations from tree
+      testRelation(treeitem1, RELATION_LABELLED_BY, null);
+      testRelation(treeitem1.firstChild, RELATION_LABELLED_BY, null);
+
       SimpleTest.finish();
     }
 
     function doTest()
     {
       var treeNode = getNode("tree");
       waitForEvent(EVENT_REORDER, treeNode, doTestRelations);
       treeNode.view = new nsTreeTreeView();
@@ -63,28 +67,35 @@
   </script>
 
   <hbox flex="1" style="overflow: auto;">
     <body xmlns="http://www.w3.org/1999/xhtml">
       <a target="_blank"
          href="https://bugzilla.mozilla.org/show_bug.cgi?id=503727"
          title="Reorganize implementation of XUL tree accessibility">
         Mozilla Bug 503727
-      </a><br/>
+      </a>
+      <a target="_blank"
+         href="https://bugzilla.mozilla.org/show_bug.cgi?id=691248"
+         title="XUL tree items shouldn't pick up relations from XUL tree">
+        Mozilla Bug 691248
+      </a>
       <p id="display"></p>
       <div id="content" style="display: none">
       </div>
       <pre id="test">
       </pre>
     </body>
 
     <vbox flex="1">
+      <label control="tree" value="It's a tree"/>
       <tree id="tree" flex="1">
         <treecols>
           <treecol id="col" flex="1" primary="true" label="column"/>
+          <treecol id="col2" flex="1" label="column2"/>
         </treecols>
         <treechildren/>
       </tree>
 
       <vbox id="debug"/>
     </vbox>
   </hbox>