Bug 739568 - nsXULTreeGridRowAccesible should cache its kids as nsXULTreeGridCellAccessibles not generic accessibles, r=tbsaunde

This commit is contained in:
Diwas Joshi 2014-11-05 21:16:37 +05:30
parent 2248a2dc58
commit 3edf35cc67
5 changed files with 21 additions and 32 deletions

View File

@ -30,10 +30,11 @@ ClearCacheEntry(const void* aKey, nsRefPtr<T>& aAccessible, void* aUserArg)
* 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

View File

@ -16,6 +16,7 @@
#include "Relation.h"
#include "Role.h"
#include "States.h"
#include "XULTreeGridAccessible.h"
#include "nsComponentManagerUtils.h"
#include "nsIAccessibleRelation.h"

View File

@ -16,6 +16,8 @@ class nsTreeBodyFrame;
namespace mozilla {
namespace a11y {
class XULTreeGridCellAccessible;
/*
* A class the represents the XUL Tree widget.
*/
@ -174,7 +176,7 @@ public:
* 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; }
/**

View File

@ -361,17 +361,17 @@ XULTreeGridRowAccessible::ChildCount() const
////////////////////////////////////////////////////////////////////////////////
// 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);
@ -394,12 +394,9 @@ XULTreeGridRowAccessible::RowInvalidated(int32_t aStartColIdx,
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();
}
}
@ -452,10 +449,8 @@ XULTreeGridCellAccessible::~XULTreeGridCellAccessible()
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)

View File

@ -15,6 +15,8 @@
namespace mozilla {
namespace a11y {
class XULTreeGridCellAccessible;
/**
* Represents accessible for XUL tree in the case when it has multiple columns.
*/
@ -88,7 +90,8 @@ public:
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:
@ -98,7 +101,8 @@ protected:
virtual void CacheChildren();
// XULTreeItemAccessibleBase
mutable AccessibleHashtable mAccessibleCache;
mutable nsRefPtrHashtable<nsPtrHashKey<const void>, XULTreeGridCellAccessible>
mAccessibleCache;
};
@ -107,14 +111,6 @@ protected:
* 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
{
@ -155,9 +151,6 @@ public:
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.
@ -191,9 +184,6 @@ protected:
nsString mCachedTextEquiv;
};
NS_DEFINE_STATIC_IID_ACCESSOR(XULTreeGridCellAccessible,
XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
} // namespace a11y
} // namespace mozilla