Bug 963607 - add some consts, make cache members mutable, GetChildAt part, r=tbsaunde

This commit is contained in:
Alexander Surkov 2014-01-24 22:08:17 -05:00
parent 0b4e10c2b0
commit 638f429fd8
6 changed files with 29 additions and 23 deletions

View File

@ -2648,7 +2648,7 @@ Accessible::RemoveChild(Accessible* aChild)
}
Accessible*
Accessible::GetChildAt(uint32_t aIndex)
Accessible::GetChildAt(uint32_t aIndex) const
{
Accessible* child = mChildren.SafeElementAt(aIndex, nullptr);
if (!child)

View File

@ -389,7 +389,7 @@ public:
/**
* Return child accessible at the given index.
*/
virtual Accessible* GetChildAt(uint32_t aIndex);
virtual Accessible* GetChildAt(uint32_t aIndex) const;
/**
* Return child accessible count.

View File

@ -414,7 +414,7 @@ XULTreeAccessible::SelectAll()
// XULTreeAccessible: Accessible implementation
Accessible*
XULTreeAccessible::GetChildAt(uint32_t aIndex)
XULTreeAccessible::GetChildAt(uint32_t aIndex) const
{
uint32_t childCount = Accessible::ChildCount();
if (aIndex < childCount)
@ -522,7 +522,7 @@ XULTreeAccessible::ContainerWidget() const
// XULTreeAccessible: public implementation
Accessible*
XULTreeAccessible::GetTreeItemAccessible(int32_t aRow)
XULTreeAccessible::GetTreeItemAccessible(int32_t aRow) const
{
if (aRow < 0 || IsDefunct() || !mTreeView)
return nullptr;
@ -679,10 +679,11 @@ XULTreeAccessible::TreeViewChanged(nsITreeView* aView)
// XULTreeAccessible: protected implementation
already_AddRefed<Accessible>
XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow)
XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow) const
{
nsRefPtr<Accessible> accessible =
new XULTreeItemAccessible(mContent, mDoc, this, mTree, mTreeView, aRow);
new XULTreeItemAccessible(mContent, mDoc, const_cast<XULTreeAccessible*>(this),
mTree, mTreeView, aRow);
return accessible.forget();
}

View File

@ -46,8 +46,8 @@ public:
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild);
virtual Accessible* GetChildAt(uint32_t aIndex);
virtual uint32_t ChildCount() const;
virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
virtual uint32_t ChildCount() const MOZ_OVERRIDE;
virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
// SelectAccessible
@ -77,7 +77,7 @@ public:
*
* @param aRow [in] the given row index
*/
Accessible* GetTreeItemAccessible(int32_t aRow);
Accessible* GetTreeItemAccessible(int32_t aRow) const;
/**
* Invalidates the number of cached treeitem accessibles.
@ -110,11 +110,12 @@ protected:
/**
* Creates tree item accessible for the given row index.
*/
virtual already_AddRefed<Accessible> CreateTreeItemAccessible(int32_t aRow);
virtual already_AddRefed<Accessible>
CreateTreeItemAccessible(int32_t aRow) const;
nsCOMPtr<nsITreeBoxObject> mTree;
nsITreeView* mTreeView;
AccessibleHashtable mAccessibleCache;
mutable AccessibleHashtable mAccessibleCache;
};
/**
@ -180,7 +181,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)
virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const
{ return nullptr; }
/**

View File

@ -237,10 +237,12 @@ XULTreeGridAccessible::NativeRole()
// XULTreeGridAccessible: XULTreeAccessible implementation
already_AddRefed<Accessible>
XULTreeGridAccessible::CreateTreeItemAccessible(int32_t aRow)
XULTreeGridAccessible::CreateTreeItemAccessible(int32_t aRow) const
{
nsRefPtr<Accessible> accessible =
new XULTreeGridRowAccessible(mContent, mDoc, this, mTree, mTreeView, aRow);
new XULTreeGridRowAccessible(mContent, mDoc,
const_cast<XULTreeGridAccessible*>(this),
mTree, mTreeView, aRow);
return accessible.forget();
}
@ -345,7 +347,7 @@ XULTreeGridRowAccessible::ChildAtPoint(int32_t aX, int32_t aY,
}
Accessible*
XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex)
XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex) const
{
if (IsDefunct())
return nullptr;
@ -368,7 +370,7 @@ XULTreeGridRowAccessible::ChildCount() const
// XULTreeGridRowAccessible: XULTreeItemAccessibleBase implementation
Accessible*
XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn)
XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const
{
NS_PRECONDITION(aColumn, "No tree column!");
@ -378,8 +380,9 @@ XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn)
return cachedCell;
nsRefPtr<Accessible> cell =
new XULTreeGridCellAccessibleWrap(mContent, mDoc, this, mTree,
mTreeView, mRow, aColumn);
new XULTreeGridCellAccessibleWrap(mContent, mDoc,
const_cast<XULTreeGridRowAccessible*>(this),
mTree, mTreeView, mRow, aColumn);
mAccessibleCache.Put(key, cell);
Document()->BindToDocument(cell, nullptr);
return cell;

View File

@ -62,7 +62,8 @@ public:
protected:
// XULTreeAccessible
virtual already_AddRefed<Accessible> CreateTreeItemAccessible(int32_t aRow);
virtual already_AddRefed<Accessible>
CreateTreeItemAccessible(int32_t aRow) const MOZ_OVERRIDE;
};
@ -91,11 +92,11 @@ public:
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild);
virtual Accessible* GetChildAt(uint32_t aIndex);
virtual uint32_t ChildCount() const;
virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
virtual uint32_t ChildCount() const MOZ_OVERRIDE;
// XULTreeItemAccessibleBase
virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn);
virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const MOZ_OVERRIDE;
virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx);
protected:
@ -104,7 +105,7 @@ protected:
virtual void CacheChildren();
// XULTreeItemAccessibleBase
AccessibleHashtable mAccessibleCache;
mutable AccessibleHashtable mAccessibleCache;
};