Bug 740725 - Add down-casting to nsXULTreeAccessible, r=tbsaunde, f=surkov

This commit is contained in:
Mark Capella 2012-04-03 18:54:01 +09:00
parent c9eb168ef6
commit a647b4f38c
5 changed files with 30 additions and 18 deletions

View File

@ -605,7 +605,7 @@ nsAccessibilityService::TreeViewChanged(nsIPresShell* aPresShell,
if (document) {
nsAccessible* accessible = document->GetAccessible(aContent);
if (accessible) {
nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(accessible);
nsXULTreeAccessible* treeAcc = accessible->AsXULTree();
if (treeAcc)
treeAcc->TreeViewChanged(aView);
}

View File

@ -72,6 +72,7 @@ class TableAccessible;
}
}
class nsTextAccessible;
class nsXULTreeAccessible;
struct nsRect;
class nsIContent;
@ -467,6 +468,9 @@ public:
bool IsImageMapAccessible() const { return mFlags & eImageMapAccessible; }
nsHTMLImageMapAccessible* AsImageMap();
inline bool IsXULTree() const { return mFlags & eXULTreeAccessible; }
nsXULTreeAccessible* AsXULTree();
inline bool IsListControl() const { return mFlags & eListControlAccessible; }
inline bool IsMenuButton() const { return mFlags & eMenuButtonAccessible; }
@ -718,7 +722,8 @@ protected:
eMenuButtonAccessible = 1 << 14,
eMenuPopupAccessible = 1 << 15,
eRootAccessible = 1 << 16,
eTextLeafAccessible = 1 << 17
eTextLeafAccessible = 1 << 17,
eXULTreeAccessible = 1 << 18
};
//////////////////////////////////////////////////////////////////////////////

View File

@ -386,21 +386,16 @@ nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
nsINode* targetNode = accessible->GetNode();
#ifdef MOZ_XUL
nsRefPtr<nsXULTreeAccessible> treeAcc;
if (targetNode->IsElement() &&
targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree,
kNameSpaceID_XUL)) {
treeAcc = do_QueryObject(accessible);
if (treeAcc) {
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
return;
}
nsXULTreeAccessible* treeAcc = accessible->AsXULTree();
if (treeAcc) {
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
return;
}
if (eventType.EqualsLiteral("TreeInvalidated")) {
HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
return;
}
if (eventType.EqualsLiteral("TreeInvalidated")) {
HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
return;
}
}
#endif

View File

@ -68,6 +68,8 @@ nsXULTreeAccessible::
nsXULTreeAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
nsAccessibleWrap(aContent, aDoc)
{
mFlags |= eXULTreeAccessible;
mTree = nsCoreUtils::GetTreeBoxObject(aContent);
if (mTree)
mTree->GetView(getter_AddRefs(mTreeView));
@ -863,7 +865,7 @@ nsXULTreeItemAccessibleBase::RelationByType(PRUint32 aType)
if (parentIndex == -1)
return Relation(mParent);
nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(mParent);
nsXULTreeAccessible* treeAcc = mParent->AsXULTree();
return Relation(treeAcc->GetTreeItemAccessible(parentIndex));
}
@ -1283,7 +1285,7 @@ nsXULTreeColumnsAccessible::GetSiblingAtOffset(PRInt32 aOffset,
PRInt32 rowCount = 0;
treeView->GetRowCount(&rowCount);
if (rowCount > 0 && aOffset <= rowCount) {
nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(Parent());
nsXULTreeAccessible* treeAcc = Parent()->AsXULTree();
if (treeAcc)
return treeAcc->GetTreeItemAccessible(aOffset - 1);

View File

@ -320,4 +320,14 @@ protected:
nsresult *aError = nsnull) const;
};
////////////////////////////////////////////////////////////////////////////////
// nsAccessible downcasting method
inline nsXULTreeAccessible*
nsAccessible::AsXULTree()
{
return IsXULTree() ?
static_cast<nsXULTreeAccessible*>(this) : nsnull;
}
#endif