Bug 739568 - nsXULTreeGridRowAccesible should cache its kids as nsXULTreeGridCellAccessibles not generic accessibles, r=tbsaunde
authorDiwas Joshi <dj.dij123@gmail.com>
Wed, 05 Nov 2014 21:16:37 +0530
changeset 214766 992784f79f96fcc63b04f716a5772dd270fc80c6
parent 214765 b4493970ffdced0b04fe9fcf4b7c886fd718277f
child 214767 2024df0523026feae3cd468811168575643e0952
push id27795
push usercbook@mozilla.com
push dateMon, 10 Nov 2014 13:26:15 +0000
treeherdermozilla-central@1a09297482e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs739568
milestone36.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 739568 - nsXULTreeGridRowAccesible should cache its kids as nsXULTreeGridCellAccessibles not generic accessibles, r=tbsaunde
accessible/base/nsAccCache.h
accessible/xul/XULTreeAccessible.cpp
accessible/xul/XULTreeAccessible.h
accessible/xul/XULTreeGridAccessible.cpp
accessible/xul/XULTreeGridAccessible.h
--- a/accessible/base/nsAccCache.h
+++ b/accessible/base/nsAccCache.h
@@ -25,15 +25,16 @@ ClearCacheEntry(const void* aKey, nsRefP
 
   return PL_DHASH_REMOVE;
 }
 
 /**
  * Clear the cache and shutdown the accessibles.
  */
 
+template <class T>
 static void
-ClearCache(mozilla::a11y::AccessibleHashtable& aCache)
+ClearCache(nsRefPtrHashtable<nsPtrHashKey<const void>, T>& aCache)
 {
-  aCache.Enumerate(ClearCacheEntry<mozilla::a11y::Accessible>, nullptr);
+  aCache.Enumerate(ClearCacheEntry<T>, nullptr);
 }
 
 #endif
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -11,16 +11,17 @@
 #include "nsAccCache.h"
 #include "nsAccUtils.h"
 #include "nsCoreUtils.h"
 #include "nsEventShell.h"
 #include "DocAccessible.h"
 #include "Relation.h"
 #include "Role.h"
 #include "States.h"
+#include "XULTreeGridAccessible.h"
 
 #include "nsComponentManagerUtils.h"
 #include "nsIAccessibleRelation.h"
 #include "nsIAutoCompleteInput.h"
 #include "nsIAutoCompletePopup.h"
 #include "nsIBoxObject.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDOMXULMenuListElement.h"
--- a/accessible/xul/XULTreeAccessible.h
+++ b/accessible/xul/XULTreeAccessible.h
@@ -11,16 +11,18 @@
 #include "nsITreeColumns.h"
 #include "XULListboxAccessible.h"
 
 class nsTreeBodyFrame;
 
 namespace mozilla {
 namespace a11y {
 
+class XULTreeGridCellAccessible;
+
 /*
  * A class the represents the XUL Tree widget.
  */
 const uint32_t kMaxTreeColumns = 100;
 const uint32_t kDefaultTreeCacheLength = 128;
 
 /**
  * Accessible class for XUL tree element.
@@ -169,17 +171,17 @@ public:
    * Return row index associated with the accessible.
    */
   int32_t GetRowIndex() const { return mRow; }
 
   /**
    * Return cell accessible for the given column. If XUL tree accessible is not
    * accessible table then return null.
    */
-  virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const
+  virtual XULTreeGridCellAccessible* GetCellAccessible(nsITreeColumn* aColumn) const
     { return nullptr; }
 
   /**
    * Proccess row invalidation. Used to fires name change events.
    */
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) = 0;
 
 protected:
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -356,27 +356,27 @@ uint32_t
 XULTreeGridRowAccessible::ChildCount() const
 {
   return nsCoreUtils::GetSensibleColumnCount(mTree);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible: XULTreeItemAccessibleBase implementation
 
-Accessible*
+XULTreeGridCellAccessible*
 XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const
 {
   NS_PRECONDITION(aColumn, "No tree column!");
 
   void* key = static_cast<void*>(aColumn);
-  Accessible* cachedCell = mAccessibleCache.GetWeak(key);
+  XULTreeGridCellAccessible* cachedCell = mAccessibleCache.GetWeak(key);
   if (cachedCell)
     return cachedCell;
 
-  nsRefPtr<Accessible> cell =
+  nsRefPtr<XULTreeGridCellAccessible> cell =
     new XULTreeGridCellAccessibleWrap(mContent, mDoc,
                                       const_cast<XULTreeGridRowAccessible*>(this),
                                       mTree, mTreeView, mRow, aColumn);
   mAccessibleCache.Put(key, cell);
   Document()->BindToDocument(cell, nullptr);
   return cell;
 }
 
@@ -389,22 +389,19 @@ XULTreeGridRowAccessible::RowInvalidated
   if (!treeColumns)
     return;
 
   bool nameChanged = false;
   for (int32_t colIdx = aStartColIdx; colIdx <= aEndColIdx; ++colIdx) {
     nsCOMPtr<nsITreeColumn> column;
     treeColumns->GetColumnAt(colIdx, getter_AddRefs(column));
     if (column && !nsCoreUtils::IsColumnHidden(column)) {
-      Accessible* cellAccessible = GetCellAccessible(column);
-      if (cellAccessible) {
-        nsRefPtr<XULTreeGridCellAccessible> cellAcc = do_QueryObject(cellAccessible);
-
-        nameChanged |= cellAcc->CellInvalidated();
-      }
+      XULTreeGridCellAccessible* cell = GetCellAccessible(column);
+      if (cell)
+        nameChanged |= cell->CellInvalidated();
     }
   }
 
   if (nameChanged)
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
 
 }
 
@@ -447,20 +444,18 @@ XULTreeGridCellAccessible::~XULTreeGridC
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: nsISupports implementation
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(XULTreeGridCellAccessible, LeafAccessible,
                                    mTree, mColumn)
 
-NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XULTreeGridCellAccessible)
-  NS_INTERFACE_TABLE_INHERITED(XULTreeGridCellAccessible,
-                               XULTreeGridCellAccessible)
-NS_INTERFACE_TABLE_TAIL_INHERITING(LeafAccessible)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XULTreeGridCellAccessible)
+NS_INTERFACE_MAP_END_INHERITING(LeafAccessible)
 NS_IMPL_ADDREF_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
 NS_IMPL_RELEASE_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: Accessible
 
 Accessible*
 XULTreeGridCellAccessible::FocusedChild()
--- a/accessible/xul/XULTreeGridAccessible.h
+++ b/accessible/xul/XULTreeGridAccessible.h
@@ -10,16 +10,18 @@
 #include "TableAccessible.h"
 #include "TableCellAccessible.h"
 #include "xpcAccessibleTable.h"
 #include "xpcAccessibleTableCell.h"
 
 namespace mozilla {
 namespace a11y {
 
+class XULTreeGridCellAccessible;
+
 /**
  * Represents accessible for XUL tree in the case when it has multiple columns.
  */
 class XULTreeGridAccessible : public XULTreeAccessible,
                               public TableAccessible
 {
 public:
   XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc,
@@ -83,43 +85,37 @@ public:
   virtual ENameValueFlag Name(nsString& aName);
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
 
   virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
   virtual uint32_t ChildCount() const MOZ_OVERRIDE;
 
   // XULTreeItemAccessibleBase
-  virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const MOZ_OVERRIDE;
+  virtual XULTreeGridCellAccessible* GetCellAccessible(nsITreeColumn* aColumn)
+    const MOZ_OVERRIDE MOZ_FINAL;
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx);
 
 protected:
   virtual ~XULTreeGridRowAccessible();
 
   // Accessible
   virtual void CacheChildren();
 
   // XULTreeItemAccessibleBase
-  mutable AccessibleHashtable mAccessibleCache;
+  mutable nsRefPtrHashtable<nsPtrHashKey<const void>, XULTreeGridCellAccessible>
+    mAccessibleCache;
 };
 
 
 /**
  * Represents an accessible for XUL tree cell in the case when XUL tree has
  * multiple columns.
  */
 
-#define XULTREEGRIDCELLACCESSIBLE_IMPL_CID            \
-{  /* 84588ad4-549c-4196-a932-4c5ca5de5dff */         \
-  0x84588ad4,                                         \
-  0x549c,                                             \
-  0x4196,                                             \
-  { 0xa9, 0x32, 0x4c, 0x5c, 0xa5, 0xde, 0x5d, 0xff }  \
-}
-
 class XULTreeGridCellAccessible : public LeafAccessible,
                                   public TableCellAccessible
 {
 public:
 
   XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
                             XULTreeGridRowAccessible* aRowAcc,
                             nsITreeBoxObject* aTree, nsITreeView* aTreeView,
@@ -150,19 +146,16 @@ public:
   // TableCellAccessible
   virtual TableAccessible* Table() const MOZ_OVERRIDE;
   virtual uint32_t ColIdx() const MOZ_OVERRIDE;
   virtual uint32_t RowIdx() const MOZ_OVERRIDE;
   virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) MOZ_OVERRIDE;
   virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE { }
   virtual bool Selected() MOZ_OVERRIDE;
 
-  // XULTreeGridCellAccessible
-  NS_DECLARE_STATIC_IID_ACCESSOR(XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
-
   /**
    * Fire name or state change event if the accessible text or value has been
    * changed.
    * @return true if name has changed
    */
   bool CellInvalidated();
 
 protected:
@@ -186,15 +179,12 @@ protected:
   nsITreeView* mTreeView;
 
   int32_t mRow;
   nsCOMPtr<nsITreeColumn> mColumn;
 
   nsString mCachedTextEquiv;
 };
 
-NS_DEFINE_STATIC_IID_ACCESSOR(XULTreeGridCellAccessible,
-                              XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
-
 } // namespace a11y
 } // namespace mozilla
 
 #endif