Bug 538633 - nsAccessible tree navigation methods should deal with nsAccessible pointers, r=marcoz, davidb, sr=neil

This commit is contained in:
Alexander Surkov 2010-01-11 22:14:06 +08:00
Родитель bdbbc255c0
Коммит 6a850efa80
34 изменённых файлов: 241 добавлений и 268 удалений

Просмотреть файл

@ -665,7 +665,7 @@ nsApplicationAccessibleWrap::AddRootAccessible(nsIAccessible *aRootAccWrap)
AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
atk_object_set_parent(atkAccessible, mAtkObject);
PRUint32 count = mChildren.Count();
PRUint32 count = mChildren.Length();
// Emit children_changed::add in a timeout
// to make sure aRootAccWrap is fully initialized.

Просмотреть файл

@ -335,6 +335,15 @@ public:
return object;
}
template<class DestinationType, class SourceType> static inline
already_AddRefed<DestinationType> QueryObject(nsRefPtr<SourceType>& aObject)
{
DestinationType* object = nsnull;
if (aObject)
CallQueryInterface(aObject.get(), &object);
return object;
}
/**
* Query nsAccessNode from the given nsIAccessible.

Просмотреть файл

@ -148,13 +148,19 @@ nsAccessibleDOMStringList::Contains(const nsAString& aString, PRBool *aResult)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsAccessible)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsAccessible, nsAccessNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mChildren)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mParent");
cb.NoteXPCOMChild(static_cast<nsIAccessible*>(tmp->mParent.get()));
PRUint32 i, length = tmp->mChildren.Length();
for (i = 0; i < length; ++i) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildren[i]");
cb.NoteXPCOMChild(static_cast<nsIAccessible*>(tmp->mChildren[i].get()));
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsAccessible, nsAccessNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mChildren)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mChildren)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(nsAccessible, nsAccessNode)
@ -209,8 +215,9 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperLink))) {
nsCOMPtr<nsIAccessible> parent(GetParent());
nsCOMPtr<nsIAccessibleHyperText> hyperTextParent(do_QueryInterface(parent));
nsCOMPtr<nsIAccessibleHyperText> hyperTextParent =
nsAccUtils::QueryObject<nsIAccessibleHyperText>(GetParent());
if (hyperTextParent) {
*aInstancePtr = static_cast<nsIAccessibleHyperLink*>(this);
NS_ADDREF_THIS();
@ -483,8 +490,7 @@ nsAccessible::Shutdown()
// sure none of its children point to this parent
InvalidateChildren();
if (mParent) {
nsRefPtr<nsAccessible> parent(nsAccUtils::QueryAccessible(mParent));
parent->InvalidateChildren();
mParent->InvalidateChildren();
mParent = nsnull;
}
@ -569,7 +575,7 @@ nsAccessible::GetChildAt(PRInt32 aChildIndex, nsIAccessible **aChild)
if (aChildIndex < 0)
aChildIndex = childCount - 1;
nsIAccessible* child = GetChildAt(aChildIndex);
nsAccessible* child = GetChildAt(aChildIndex);
if (!child)
return NS_ERROR_INVALID_ARG;
@ -2343,9 +2349,7 @@ nsAccessible::GetRelationByType(PRUint32 aRelationType,
if (view) {
nsIScrollableFrame *scrollFrame = do_QueryFrame(frame);
if (scrollFrame || view->GetWidget() || !frame->GetParent()) {
nsCOMPtr<nsIAccessible> accTarget;
GetParent(getter_AddRefs(accTarget));
return nsRelUtils::AddTarget(aRelationType, aRelation, accTarget);
return nsRelUtils::AddTarget(aRelationType, aRelation, GetParent());
}
}
}
@ -2692,9 +2696,7 @@ NS_IMETHODIMP nsAccessible::AddChildToSelection(PRInt32 aIndex)
NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> child;
GetChildAt(aIndex, getter_AddRefs(child));
nsAccessible* child = GetChildAt(aIndex);
PRUint32 state = nsAccUtils::State(child);
if (!(state & nsIAccessibleStates::STATE_SELECTABLE)) {
return NS_OK;
@ -2711,9 +2713,7 @@ NS_IMETHODIMP nsAccessible::RemoveChildFromSelection(PRInt32 aIndex)
NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> child;
GetChildAt(aIndex, getter_AddRefs(child));
nsAccessible* child = GetChildAt(aIndex);
PRUint32 state = nsAccUtils::State(child);
if (!(state & nsIAccessibleStates::STATE_SELECTED)) {
return NS_OK;
@ -2731,9 +2731,7 @@ NS_IMETHODIMP nsAccessible::IsChildSelected(PRInt32 aIndex, PRBool *aIsSelected)
*aIsSelected = PR_FALSE;
NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> child;
GetChildAt(aIndex, getter_AddRefs(child));
nsAccessible* child = GetChildAt(aIndex);
PRUint32 state = nsAccUtils::State(child);
if (state & nsIAccessibleStates::STATE_SELECTED) {
*aIsSelected = PR_TRUE;
@ -2860,7 +2858,7 @@ nsAccessible::GetSelected(PRBool *aSelected)
nsresult nsAccessible::GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset)
{
*aStartOffset = *aEndOffset = 0;
nsCOMPtr<nsIAccessible> parent(GetParent());
nsAccessible* parent = GetParent();
if (!parent) {
return NS_ERROR_FAILURE;
}
@ -2940,7 +2938,7 @@ nsAccessible::GetNameInternal(nsAString& aName)
}
void
nsAccessible::SetParent(nsIAccessible *aParent)
nsAccessible::SetParent(nsAccessible *aParent)
{
NS_PRECONDITION(aParent, "This method isn't used to set null parent!");
@ -2950,9 +2948,8 @@ nsAccessible::SetParent(nsIAccessible *aParent)
// The old parent's children now need to be invalidated, since
// it no longer owns the child, the new parent does
NS_ASSERTION(PR_FALSE, "Adopting child!");
nsRefPtr<nsAccessible> oldParent = nsAccUtils::QueryAccessible(mParent);
if (oldParent)
oldParent->InvalidateChildren();
if (mParent)
mParent->InvalidateChildren();
}
mParent = aParent;
@ -2961,10 +2958,9 @@ nsAccessible::SetParent(nsIAccessible *aParent)
void
nsAccessible::InvalidateChildren()
{
PRInt32 childCount = mChildren.Count();
PRInt32 childCount = mChildren.Length();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsRefPtr<nsAccessible> child =
nsAccUtils::QueryObject<nsAccessible>(mChildren.ObjectAt(childIdx));
nsAccessible* child = mChildren.ElementAt(childIdx);
child->mParent = nsnull;
}
@ -2972,7 +2968,7 @@ nsAccessible::InvalidateChildren()
mAreChildrenInitialized = PR_FALSE;
}
nsIAccessible*
nsAccessible*
nsAccessible::GetParent()
{
if (IsDefunct())
@ -2991,8 +2987,9 @@ nsAccessible::GetParent()
docAccessible->GetAccessibleInParentChain(mDOMNode, PR_TRUE,
getter_AddRefs(parent));
#ifdef DEBUG
nsRefPtr<nsAccessible> parentAcc = nsAccUtils::QueryAccessible(parent);
#ifdef DEBUG
NS_ASSERTION(!parentAcc->IsDefunct(), "Defunct parent!");
parentAcc->EnsureChildren();
@ -3000,22 +2997,21 @@ nsAccessible::GetParent()
NS_WARNING("Bad accessible tree!");
#endif
return parent;
return parentAcc;
}
nsIAccessible*
nsAccessible*
nsAccessible::GetChildAt(PRUint32 aIndex)
{
if (EnsureChildren())
return nsnull;
nsIAccessible *child = mChildren.SafeObjectAt(aIndex);
nsAccessible *child = mChildren.SafeElementAt(aIndex, nsnull);
if (!child)
return nsnull;
#ifdef DEBUG
nsRefPtr<nsAccessible> childAcc = nsAccUtils::QueryAccessible(child);
nsCOMPtr<nsIAccessible> realParent = childAcc->mParent;
nsAccessible* realParent = child->mParent;
NS_ASSERTION(!realParent || realParent == this,
"Two accessibles have the same first child accessible!");
#endif
@ -3026,7 +3022,7 @@ nsAccessible::GetChildAt(PRUint32 aIndex)
PRInt32
nsAccessible::GetChildCount()
{
return EnsureChildren() ? -1 : mChildren.Count();
return EnsureChildren() ? -1 : mChildren.Length();
}
PRInt32
@ -3038,33 +3034,26 @@ nsAccessible::GetIndexOf(nsIAccessible *aChild)
PRInt32
nsAccessible::GetIndexInParent()
{
nsIAccessible *parent = GetParent();
if (!parent)
return -1;
nsRefPtr<nsAccessible> parentAcc =
nsAccUtils::QueryObject<nsAccessible>(parent);
return parentAcc->GetIndexOf(this);
nsAccessible *parent = GetParent();
return parent ? parent->GetIndexOf(this) : -1;
}
already_AddRefed<nsIAccessible>
nsAccessible*
nsAccessible::GetCachedParent()
{
if (IsDefunct())
return nsnull;
nsCOMPtr<nsIAccessible> cachedParent = mParent;
return cachedParent.forget();
return mParent;
}
already_AddRefed<nsIAccessible>
nsAccessible*
nsAccessible::GetCachedFirstChild()
{
if (IsDefunct())
return nsnull;
nsCOMPtr<nsIAccessible> cachedFirstChild = GetChildAt(0);
return cachedFirstChild.forget();
return mChildren.SafeElementAt(0, nsnull);
}
@ -3085,10 +3074,11 @@ nsAccessible::CacheChildren()
walker.GetFirstChild();
while (walker.mState.accessible) {
mChildren.AppendObject(walker.mState.accessible);
nsRefPtr<nsAccessible> acc =
nsAccUtils::QueryObject<nsAccessible>(walker.mState.accessible);
mChildren.AppendElement(acc);
acc->SetParent(this);
walker.GetNextSibling();
@ -3096,14 +3086,14 @@ nsAccessible::CacheChildren()
}
void
nsAccessible::TestChildCache(nsIAccessible *aCachedChild)
nsAccessible::TestChildCache(nsAccessible *aCachedChild)
{
#ifdef DEBUG_A11Y
// All cached accessible nodes should be in the parent
// It will assert if not all the children were created
// when they were first cached, and no invalidation
// ever corrected parent accessible's child cache.
PRUint32 childCount = mChildren.Count();
PRUint32 childCount = mChildren.Length();
if (childCount == 0) {
NS_ASSERTION(mAreChildrenInitialized,
"Children are stored but not initailzied!");
@ -3111,7 +3101,7 @@ nsAccessible::TestChildCache(nsIAccessible *aCachedChild)
}
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsIAccessible *child = GetChildAt(childIdx);
nsAccessible *child = GetChildAt(childIdx);
if (child == aCachedChild)
break;
}
@ -3148,7 +3138,7 @@ nsAccessible::GetSiblingAtOffset(PRInt32 aOffset, nsresult* aError)
return nsnull;
}
nsIAccessible *parent = GetParent();
nsAccessible *parent = GetParent();
if (!parent) {
if (aError)
*aError = NS_ERROR_UNEXPECTED;
@ -3156,10 +3146,7 @@ nsAccessible::GetSiblingAtOffset(PRInt32 aOffset, nsresult* aError)
return nsnull;
}
nsRefPtr<nsAccessible> parentAcc =
nsAccUtils::QueryObject<nsAccessible>(parent);
PRInt32 indexInParent = parentAcc->GetIndexOf(this);
PRInt32 indexInParent = parent->GetIndexOf(this);
if (indexInParent == -1) {
if (aError)
*aError = NS_ERROR_UNEXPECTED;
@ -3168,14 +3155,14 @@ nsAccessible::GetSiblingAtOffset(PRInt32 aOffset, nsresult* aError)
}
if (aError) {
PRInt32 childCount = parentAcc->GetChildCount();
PRInt32 childCount = parent->GetChildCount();
if (indexInParent + aOffset >= childCount) {
*aError = NS_OK; // fail peacefully
return nsnull;
}
}
nsIAccessible *child = parentAcc->GetChildAt(indexInParent + aOffset);
nsAccessible *child = parent->GetChildAt(indexInParent + aOffset);
if (aError && !child)
*aError = NS_ERROR_UNEXPECTED;
@ -3338,28 +3325,24 @@ nsAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize)
role != nsIAccessibleRole::ROLE_GRID_CELL)
return;
PRInt32 positionInGroup = 0;
PRInt32 setSize = 0;
PRUint32 baseRole = role;
if (role == nsIAccessibleRole::ROLE_CHECK_MENU_ITEM ||
role == nsIAccessibleRole::ROLE_RADIO_MENU_ITEM)
baseRole = nsIAccessibleRole::ROLE_MENUITEM;
nsCOMPtr<nsIAccessible> parent = GetParent();
nsAccessible* parent = GetParent();
NS_ENSURE_TRUE(parent,);
// Compute 'posinset' and 'setsize' attributes.
PRInt32 positionInGroup = 0;
PRInt32 setSize = 0;
nsCOMPtr<nsIAccessible> sibling, nextSibling;
parent->GetFirstChild(getter_AddRefs(sibling));
NS_ENSURE_TRUE(sibling,);
PRBool foundCurrent = PR_FALSE;
PRUint32 siblingRole, siblingBaseRole;
while (sibling) {
siblingRole = nsAccUtils::Role(sibling);
PRInt32 siblingCount = parent->GetChildCount();
for (PRInt32 siblingIdx = 0; siblingIdx < siblingCount; siblingIdx++) {
nsAccessible* sibling = parent->GetChildAt(siblingIdx);
siblingBaseRole = siblingRole;
PRUint32 siblingRole = siblingRole = nsAccUtils::Role(sibling);
PRUint32 siblingBaseRole = siblingRole;
if (siblingRole == nsIAccessibleRole::ROLE_CHECK_MENU_ITEM ||
siblingRole == nsIAccessibleRole::ROLE_RADIO_MENU_ITEM)
siblingBaseRole = nsIAccessibleRole::ROLE_MENUITEM;
@ -3384,9 +3367,6 @@ nsAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet, PRInt32 *aSetSize)
positionInGroup = 0;
setSize = 0;
}
sibling->GetNextSibling(getter_AddRefs(nextSibling));
sibling = nextSibling;
}
*aPosInSet = positionInGroup;
@ -3397,14 +3377,13 @@ PRInt32
nsAccessible::GetLevelInternal()
{
PRUint32 role = nsAccUtils::Role(this);
nsCOMPtr<nsIAccessible> parent = GetParent();
nsAccessible* parent = GetParent();
if (role == nsIAccessibleRole::ROLE_OUTLINEITEM) {
// Always expose 'level' attribute for 'outlineitem' accessible. The number
// of nested 'grouping' accessibles containing 'outlineitem' accessible is
// its level.
PRInt32 level = 1;
nsCOMPtr<nsIAccessible> nextParent;
while (parent) {
PRUint32 parentRole = nsAccUtils::Role(parent);
@ -3413,8 +3392,7 @@ nsAccessible::GetLevelInternal()
if (parentRole == nsIAccessibleRole::ROLE_GROUPING)
++ level;
parent->GetParent(getter_AddRefs(nextParent));
parent.swap(nextParent);
parent = parent->GetParent();
}
return level;
@ -3428,7 +3406,6 @@ nsAccessible::GetLevelInternal()
// Calculate 'level' attribute based on number of parent listitems.
PRInt32 level = 0;
nsCOMPtr<nsIAccessible> nextParent;
while (parent) {
PRUint32 parentRole = nsAccUtils::Role(parent);
@ -3438,26 +3415,23 @@ nsAccessible::GetLevelInternal()
else if (parentRole != nsIAccessibleRole::ROLE_LIST)
break;
parent->GetParent(getter_AddRefs(nextParent));
parent.swap(nextParent);
parent = parent->GetParent();
}
if (level == 0) {
// If this listitem is on top of nested lists then expose 'level'
// attribute.
nsCOMPtr<nsIAccessible> parent(GetParent()), sibling, nextSibling;
parent->GetFirstChild(getter_AddRefs(sibling));
nsAccessible* parent(GetParent());
PRInt32 siblingCount = parent->GetChildCount();
for (PRInt32 siblingIdx = 0; siblingIdx < siblingCount; siblingIdx++) {
nsAccessible* sibling = parent->GetChildAt(siblingIdx);
while (sibling) {
nsCOMPtr<nsIAccessible> siblingChild;
sibling->GetLastChild(getter_AddRefs(siblingChild));
if (nsAccUtils::Role(siblingChild) == nsIAccessibleRole::ROLE_LIST) {
level = 1;
break;
}
sibling->GetNextSibling(getter_AddRefs(nextSibling));
sibling.swap(nextSibling);
}
} else {
++ level; // level is 1-index based

Просмотреть файл

@ -103,11 +103,11 @@ private:
#define NS_ACCESSIBLE_IMPL_CID \
{ /* 81a84b69-de5a-412f-85ff-deb005c5a68d */ \
0x81a84b69, \
0xde5a, \
0x412f, \
{ 0x85, 0xff, 0xde, 0xb0, 0x05, 0xc5, 0xa6, 0x8d } \
{ /* c734df37-7e12-49ec-8983-eea88a186bb8 */ \
0xc734df37, \
0x7e12, \
0x49ec, \
{ 0x89, 0x83, 0xee, 0xa8, 0x8a, 0x18, 0x6b, 0xb8 } \
}
class nsAccessible : public nsAccessNodeWrap,
@ -228,7 +228,7 @@ public:
/**
* Set accessible parent.
*/
void SetParent(nsIAccessible *aParent);
void SetParent(nsAccessible *aParent);
/**
* Set the child count to -1 (unknown) and null out cached child pointers.
@ -243,12 +243,12 @@ public:
/**
* Return parent accessible.
*/
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
/**
* Return child accessible at the given index.
*/
virtual nsIAccessible* GetChildAt(PRUint32 aIndex);
virtual nsAccessible* GetChildAt(PRUint32 aIndex);
/**
* Return child accessible count.
@ -268,12 +268,12 @@ public:
/**
* Return parent accessible only if cached.
*/
already_AddRefed<nsIAccessible> GetCachedParent();
nsAccessible* GetCachedParent();
/**
* Return first child accessible only if cached.
*/
already_AddRefed<nsIAccessible> GetCachedFirstChild();
nsAccessible* GetCachedFirstChild();
//////////////////////////////////////////////////////////////////////////////
// Miscellaneous methods
@ -312,7 +312,7 @@ protected:
/**
* Assert if child not in parent's cache.
*/
void TestChildCache(nsIAccessible *aCachedChild);
void TestChildCache(nsAccessible *aCachedChild);
/**
* Cache children if necessary. Return true if the accessible is defunct.
@ -454,8 +454,8 @@ protected:
virtual nsresult FirePlatformEvent(nsIAccessibleEvent *aEvent) = 0;
// Data Members
nsCOMPtr<nsIAccessible> mParent;
nsCOMArray<nsIAccessible> mChildren;
nsRefPtr<nsAccessible> mParent;
nsTArray<nsRefPtr<nsAccessible> > mChildren;
PRBool mAreChildrenInitialized;
nsRoleMapEntry *mRoleMapEntry; // Non-null indicates author-supplied role; possibly state & value as well

Просмотреть файл

@ -160,7 +160,7 @@ nsApplicationAccessible::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
nsIAccessible*
nsAccessible*
nsApplicationAccessible::GetParent()
{
return nsnull;
@ -207,10 +207,12 @@ nsApplicationAccessible::AddRootAccessible(nsIAccessible *aRootAccessible)
{
NS_ENSURE_ARG_POINTER(aRootAccessible);
if (!mChildren.AppendObject(aRootAccessible))
nsRefPtr<nsAccessible> rootAcc =
nsAccUtils::QueryObject<nsAccessible>(aRootAccessible);
if (!mChildren.AppendElement(rootAcc))
return NS_ERROR_FAILURE;
nsRefPtr<nsAccessible> rootAcc = nsAccUtils::QueryAccessible(aRootAccessible);
rootAcc->SetParent(this);
return NS_OK;
@ -224,5 +226,5 @@ nsApplicationAccessible::RemoveRootAccessible(nsIAccessible *aRootAccessible)
// It's not needed to void root accessible parent because this method is
// called on root accessible shutdown and its parent will be cleared
// properly.
return mChildren.RemoveObject(aRootAccessible) ? NS_OK : NS_ERROR_FAILURE;
return mChildren.RemoveElement(aRootAccessible) ? NS_OK : NS_ERROR_FAILURE;
}

Просмотреть файл

@ -79,7 +79,7 @@ public:
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
virtual void InvalidateChildren();

Просмотреть файл

@ -346,9 +346,8 @@ nsDocAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState)
nsresult rv = nsAccessible::GetARIAState(aState, aExtraState);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsAccessible> parent = nsAccUtils::QueryAccessible(mParent);
if (parent) // Allow iframe/frame etc. to have final state override via ARIA
return parent->GetARIAState(aState, aExtraState);
if (mParent) // Allow iframe/frame etc. to have final state override via ARIA
return mParent->GetARIAState(aState, aExtraState);
return rv;
}
@ -554,13 +553,13 @@ NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNod
// It will assert if not all the children were created
// when they were first cached, and no invalidation
// ever corrected parent accessible's child cache.
nsCOMPtr<nsIAccessible> accessible = do_QueryInterface(*aAccessNode);
nsRefPtr<nsAccessible> acc = nsAccUtils::QueryAccessible(accessible);
nsRefPtr<nsAccessible> acc =
nsAccUtils::QueryObject<nsAccessible>(*aAccessNode);
if (acc) {
nsCOMPtr<nsIAccessible> parent = acc->GetCachedParent();
nsRefPtr<nsAccessible> parentAcc(nsAccUtils::QueryAccessible(parent));
if (parentAcc)
parentAcc->TestChildCache(accessible);
nsAccessible* parent(acc->GetCachedParent());
if (parent)
parent->TestChildCache(acc);
}
#endif
return NS_OK;
@ -880,7 +879,7 @@ nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
if (isFinished) {
// Need to wait until scrollable view is available
AddScrollListener();
nsRefPtr<nsAccessible> acc(nsAccUtils::QueryAccessible(GetParent()));
nsRefPtr<nsAccessible> acc(GetParent());
if (acc) {
// Make the parent forget about the old document as a child
acc->InvalidateChildren();
@ -1421,7 +1420,7 @@ nsDocAccessible::ParentChainChanged(nsIContent *aContent)
////////////////////////////////////////////////////////////////////////////////
// nsAccessible
nsIAccessible*
nsAccessible*
nsDocAccessible::GetParent()
{
if (IsDefunct())
@ -1444,7 +1443,9 @@ nsDocAccessible::GetParent()
// hierarchy. GetAccessibleFor() is bad because it doesn't support our
// concept of multiple presshells per doc.
// It should be changed to use GetAccessibleInWeakShell()
accService->GetAccessibleFor(ownerNode, getter_AddRefs(mParent));
nsCOMPtr<nsIAccessible> parent;
accService->GetAccessibleFor(ownerNode, getter_AddRefs(parent));
mParent = nsAccUtils::QueryObject<nsAccessible>(parent);
}
}
@ -1931,8 +1932,7 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
// We only need to shutdown the accessibles here if one of them has been
// created.
nsCOMPtr<nsIAccessible> childAccessible = acc->GetCachedFirstChild();
if (childAccessible) {
if (acc->GetCachedFirstChild()) {
nsCOMPtr<nsIArray> children;
// use GetChildren() to fetch children at one time, instead of using
// GetNextSibling(), because after we shutdown the first child,

Просмотреть файл

@ -112,7 +112,7 @@ public:
virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);
virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
// nsIAccessibleText
NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor);

Просмотреть файл

@ -127,7 +127,7 @@ nsOuterDocAccessible::CacheChildren()
return;
// Success getting inner document as first child -- now we cache it.
mChildren.AppendObject(innerAccessible);
mChildren.AppendElement(innerAcc);
innerAcc->SetParent(this);
}

Просмотреть файл

@ -1062,7 +1062,7 @@ nsRootAccessible::GetRelationByType(PRUint32 aRelationType,
////////////////////////////////////////////////////////////////////////////////
// nsAccessible
nsIAccessible*
nsAccessible*
nsRootAccessible::GetParent()
{
// Parent has been setted in nsApplicationAccesible::AddRootAccessible()

Просмотреть файл

@ -87,7 +87,7 @@ public:
// nsAccessible
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
// nsDocAccessible
virtual void FireDocLoadEvents(PRUint32 aEventType);

Просмотреть файл

@ -673,19 +673,20 @@ nsHTMLLegendAccessible::GetRelationByType(PRUint32 aRelationType,
if (aRelationType == nsIAccessibleRelation::RELATION_LABEL_FOR) {
// Look for groupbox parent
nsCOMPtr<nsIAccessible> groupboxAccessible = GetParent();
if (nsAccUtils::Role(groupboxAccessible) == nsIAccessibleRole::ROLE_GROUPING) {
nsAccessible* groupbox = GetParent();
if (nsAccUtils::Role(groupbox) == nsIAccessibleRole::ROLE_GROUPING) {
// XXX: if group box exposes more than one relation of the given type
// then we fail.
nsCOMPtr<nsIAccessible> testLabelAccessible =
nsRelUtils::GetRelatedAccessible(groupboxAccessible,
nsRelUtils::GetRelatedAccessible(groupbox,
nsIAccessibleRelation::RELATION_LABELLED_BY);
if (testLabelAccessible == this) {
// We're the first child of the parent groupbox, see
// nsHTMLGroupboxAccessible::GetRelationByType().
return nsRelUtils::
AddTarget(aRelationType, aRelation, groupboxAccessible);
AddTarget(aRelationType, aRelation, groupbox);
}
}
}

Просмотреть файл

@ -173,8 +173,8 @@ nsHTMLImageAccessible::CacheChildren()
if (!areaAccessible)
return;
mChildren.AppendObject(areaAccessible);
areaAcc = nsAccUtils::QueryObject<nsAccessible>(areaAccessible);
mChildren.AppendElement(areaAcc);
areaAcc->SetParent(this);
}
}

Просмотреть файл

@ -403,10 +403,10 @@ nsHTMLSelectListAccessible::CacheOptSiblings(nsIContent *aParentContent)
GetAccService()->GetAccessibleInWeakShell(childNode, mWeakShell,
getter_AddRefs(accessible));
if (accessible) {
mChildren.AppendObject(accessible);
nsRefPtr<nsAccessible> acc =
nsAccUtils::QueryObject<nsAccessible>(accessible);
mChildren.AppendElement(acc);
acc->SetParent(this);
}
@ -445,7 +445,10 @@ nsHyperTextAccessibleWrap(aDOMNode, aShell)
}
}
}
SetParent(parentAccessible);
nsRefPtr<nsAccessible> parentAcc =
nsAccUtils::QueryObject<nsAccessible>(parentAccessible);
SetParent(parentAcc);
}
////////////////////////////////////////////////////////////////////////////////
@ -585,12 +588,12 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState,
// visibility implementation unless they get reimplemented in layout
*aState &= ~nsIAccessibleStates::STATE_OFFSCREEN;
// <select> is not collapsed: compare bounds to calculate STATE_OFFSCREEN
nsCOMPtr<nsIAccessible> listAccessible = GetParent();
if (listAccessible) {
nsAccessible* listAcc = GetParent();
if (listAcc) {
PRInt32 optionX, optionY, optionWidth, optionHeight;
PRInt32 listX, listY, listWidth, listHeight;
GetBounds(&optionX, &optionY, &optionWidth, &optionHeight);
listAccessible->GetBounds(&listX, &listY, &listWidth, &listHeight);
listAcc->GetBounds(&listX, &listY, &listWidth, &listHeight);
if (optionY < listY || optionY + optionHeight > listY + listHeight) {
*aState |= nsIAccessibleStates::STATE_OFFSCREEN;
}
@ -672,10 +675,10 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
return NS_ERROR_FAILURE;
// Clear old selection
nsCOMPtr<nsIDOMNode> oldHTMLOptionNode, selectNode;
nsCOMPtr<nsIAccessible> parent(GetParent());
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(parent));
NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode");
accessNode->GetDOMNode(getter_AddRefs(selectNode));
nsAccessible* parent = GetParent();
NS_ASSERTION(parent, "No parent!");
parent->GetDOMNode(getter_AddRefs(selectNode));
GetFocusedOptionNode(selectNode, getter_AddRefs(oldHTMLOptionNode));
nsCOMPtr<nsIDOMHTMLOptionElement> oldHTMLOption(do_QueryInterface(oldHTMLOptionNode));
if (oldHTMLOption)
@ -953,7 +956,7 @@ nsHTMLComboboxAccessible::CacheChildren()
mListAccessible->Init();
}
mChildren.AppendObject(mListAccessible);
mChildren.AppendElement(mListAccessible);
mListAccessible->SetParent(this);
}
@ -1170,11 +1173,11 @@ void nsHTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBo
{
*aBoundingFrame = nsnull;
nsCOMPtr<nsIAccessible> comboAccessible = GetParent();
if (!comboAccessible)
nsAccessible* comboAcc = GetParent();
if (!comboAcc)
return;
if (0 == (nsAccUtils::State(comboAccessible) & nsIAccessibleStates::STATE_COLLAPSED)) {
if (0 == (nsAccUtils::State(comboAcc) & nsIAccessibleStates::STATE_COLLAPSED)) {
nsHTMLSelectListAccessible::GetBoundsRect(aBounds, aBoundingFrame);
return;
}
@ -1198,7 +1201,7 @@ void nsHTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBo
}
// nsHTMLComboboxListAccessible. nsAccessible public mehtod
nsIAccessible*
nsAccessible*
nsHTMLComboboxListAccessible::GetParent()
{
return mParent;

Просмотреть файл

@ -271,7 +271,7 @@ public:
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
};
#endif

Просмотреть файл

@ -461,20 +461,20 @@ nsHTMLTableAccessible::CacheChildren()
nsAccessible::CacheChildren();
// Move caption accessible so that it's the first child.
PRInt32 length = mChildren.Count();
PRInt32 length = mChildren.Length();
for (PRInt32 idx = 0; idx < length; idx++) {
// Check for the first caption, because nsAccessibilityService ensures we
// don't create accessibles for the other captions, since only the first is
// actually visible.
nsIAccessible* child = mChildren.ObjectAt(idx);
nsAccessible* child = mChildren.ElementAt(idx);
if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_CAPTION) {
if (idx == 0)
break;
nsCOMPtr<nsIAccessible> tmp = mChildren.ObjectAt(0);
mChildren.ReplaceObjectAt(child, 0);
mChildren.ReplaceObjectAt(tmp, idx);
nsRefPtr<nsAccessible> tmp = mChildren[0];
mChildren[0] = child;
mChildren[idx] = tmp;
break;
}
}

Просмотреть файл

@ -270,7 +270,7 @@ void
nsHTMLLIAccessible::CacheChildren()
{
if (mBulletAccessible) {
mChildren.AppendObject(mBulletAccessible);
mChildren.AppendElement(mBulletAccessible);
mBulletAccessible->SetParent(this);
}
@ -343,7 +343,7 @@ nsHTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset
return NS_OK;
}
nsIAccessible*
nsAccessible*
nsHTMLListBulletAccessible::GetParent()
{
return mParent;

Просмотреть файл

@ -116,7 +116,7 @@ public:
virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
PRUint32 aLength);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
protected:
// XXX: Ideally we'd get the bullet text directly from the bullet frame via

Просмотреть файл

@ -232,10 +232,10 @@ nsHyperTextAccessible::CacheChildren()
walker.GetFirstChild();
while (walker.mState.accessible) {
mChildren.AppendObject(walker.mState.accessible);
nsRefPtr<nsAccessible> acc =
nsAccUtils::QueryObject<nsAccessible>(walker.mState.accessible);
mChildren.AppendElement(acc);
acc->SetParent(this);
walker.GetNextSibling();
@ -859,7 +859,7 @@ nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
hyperTextOffset = 0;
}
else if (aAmount == eSelectBeginLine) {
nsIAccessible *firstChild = mChildren.SafeObjectAt(0);
nsAccessible *firstChild = mChildren.SafeElementAt(0, nsnull);
// For line selection with needsStart, set start of line exactly to line break
if (pos.mContentOffset == 0 && firstChild &&
nsAccUtils::Role(firstChild) == nsIAccessibleRole::ROLE_STATICTEXT &&

Просмотреть файл

@ -105,15 +105,13 @@ class nsAccessibleWrap : public nsAccessible
//
// to maintain a scripting environment where the XPCOM accessible hierarchy look the same
// on all platforms, we still let the C++ objects be created though.
nsCOMPtr<nsIAccessible> curParent = GetParent();
while (curParent) {
if (nsAccUtils::MustPrune(curParent))
nsAccessible* parent(GetParent());
while (parent) {
if (nsAccUtils::MustPrune(parent))
return PR_TRUE;
nsCOMPtr<nsIAccessible> newParent;
curParent->GetParent(getter_AddRefs(newParent));
curParent.swap(newParent);
parent = parent->GetParent();
}
// no parent was flat
return PR_FALSE;

Просмотреть файл

@ -300,8 +300,7 @@ nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aC
already_AddRefed<nsIAccessible>
nsAccessibleWrap::GetUnignoredParent()
{
nsCOMPtr<nsIAccessible> parent(GetParent());
nsAccessibleWrap *parentWrap = static_cast<nsAccessibleWrap*>(parent.get());
nsAccessibleWrap *parentWrap = static_cast<nsAccessibleWrap*>(GetParent());
if (!parentWrap)
return nsnull;

Просмотреть файл

@ -237,12 +237,14 @@ __try {
}
}
nsCOMPtr<nsIAccessible> xpParentAccessible(GetParent());
NS_ASSERTION(xpParentAccessible, "No parent accessible where we're not direct child of window");
if (!xpParentAccessible) {
nsAccessible* xpParentAcc = GetParent();
NS_ASSERTION(xpParentAcc,
"No parent accessible where we're not direct child of window");
if (!xpParentAcc)
return E_UNEXPECTED;
}
*ppdispParent = NativeAccessible(xpParentAccessible);
*ppdispParent = NativeAccessible(xpParentAcc);
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
return S_OK;
@ -278,11 +280,10 @@ __try {
return S_OK;
}
nsCOMPtr<nsIAccessible> childAccessible;
if (!nsAccUtils::MustPrune(this)) {
GetChildAt(varChild.lVal - 1, getter_AddRefs(childAccessible));
if (childAccessible) {
*ppdispChild = NativeAccessible(childAccessible);
nsAccessible* child = GetChildAt(varChild.lVal - 1);
if (child) {
*ppdispChild = NativeAccessible(child);
}
}
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@ -483,8 +484,7 @@ __try {
// a ROLE_OUTLINEITEM for consistency and compatibility.
// We need this because ARIA has a role of "row" for both grid and treegrid
if (xpRole == nsIAccessibleRole::ROLE_ROW) {
nsCOMPtr<nsIAccessible> parent = GetParent();
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE)
if (nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_TREE_TABLE)
msaaRole = ROLE_SYSTEM_OUTLINEITEM;
}
@ -1102,7 +1102,7 @@ __try {
for (; numElementsFetched < aNumElementsRequested;
numElementsFetched++, mEnumVARIANTPosition++) {
nsIAccessible* accessible = GetChildAt(mEnumVARIANTPosition);
nsAccessible* accessible = GetChildAt(mEnumVARIANTPosition);
if (!accessible)
break;
@ -1286,8 +1286,7 @@ __try {
// Special case, if there is a ROLE_ROW inside of a ROLE_TREE_TABLE, then call
// the IA2 role a ROLE_OUTLINEITEM.
if (xpRole == nsIAccessibleRole::ROLE_ROW) {
nsCOMPtr<nsIAccessible> parent = GetParent();
if (nsAccUtils::Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE)
if (nsAccUtils::Role(GetParent()) == nsIAccessibleRole::ROLE_TREE_TABLE)
*aRole = ROLE_SYSTEM_OUTLINEITEM;
}

Просмотреть файл

@ -100,11 +100,8 @@ void
nsHTMLWin32ObjectOwnerAccessible::CacheChildren()
{
if (mNativeAccessible) {
mChildren.AppendObject(mNativeAccessible);
nsRefPtr<nsAccessible> nativeAcc =
nsAccUtils::QueryObject<nsAccessible>(mNativeAccessible);
nativeAcc->SetParent(this);
mChildren.AppendElement(mNativeAccessible);
mNativeAccessible->SetParent(this);
}
}

Просмотреть файл

@ -69,7 +69,7 @@ protected:
virtual void CacheChildren();
void* mHwnd;
nsCOMPtr<nsIAccessible> mNativeAccessible;
nsRefPtr<nsAccessible> mNativeAccessible;
};
/**

Просмотреть файл

@ -136,8 +136,8 @@ nsXFormsAccessible::CacheSelectChildren(nsIDOMNode *aContainerNode)
if (!accessible)
continue;
mChildren.AppendObject(accessible);
acc = nsAccUtils::QueryObject<nsAccessible>(accessible);
mChildren.AppendElement(acc);
acc->SetParent(this);
}
}

Просмотреть файл

@ -175,10 +175,10 @@ nsXULColorPickerAccessible::CacheChildren()
// Get an accessbile for menupopup or panel elements.
if (role == nsIAccessibleRole::ROLE_ALERT) {
mChildren.AppendObject(walker.mState.accessible);
nsRefPtr<nsAccessible> menupopupAcc =
nsAccUtils::QueryObject<nsAccessible>(walker.mState.accessible);
mChildren.AppendElement(menupopupAcc);
menupopupAcc->SetParent(this);
return;

Просмотреть файл

@ -229,17 +229,17 @@ nsXULButtonAccessible::CacheChildren()
if (!menupopupAccessible)
return;
mChildren.AppendObject(menupopupAccessible);
nsRefPtr<nsAccessible> menupopupAcc =
nsAccUtils::QueryObject<nsAccessible>(menupopupAccessible);
mChildren.AppendElement(menupopupAcc);
menupopupAcc->SetParent(this);
if (buttonAccessible) {
mChildren.AppendObject(buttonAccessible);
nsRefPtr<nsAccessible> buttonAcc =
nsAccUtils::QueryObject<nsAccessible>(buttonAccessible);
mChildren.AppendElement(buttonAcc);
buttonAcc->SetParent(this);
}
}
@ -776,26 +776,26 @@ void
nsXULToolbarButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize)
{
nsCOMPtr<nsIAccessible> parent(GetParent());
PRInt32 setSize = 0;
PRInt32 posInSet = 0;
if (parent) {
nsCOMPtr<nsIAccessible> sibling;
nsCOMPtr<nsIAccessible> tempSibling;
parent->GetFirstChild(getter_AddRefs(sibling));
while (sibling) {
if (IsSeparator(sibling)) { // end of a group of buttons
if (posInSet)
break; // we've found our group, so we're done
setSize = 0; // not our group, so start a new group
} else {
setSize++; // another button in the group
if (sibling == this)
posInSet = setSize; // we've found our button
}
sibling->GetNextSibling(getter_AddRefs(tempSibling));
sibling.swap(tempSibling);
nsAccessible* parent(GetParent());
NS_ENSURE_TRUE(parent,);
PRInt32 childCount = parent->GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible* child = parent->GetChildAt(childIdx);
if (IsSeparator(child)) { // end of a group of buttons
if (posInSet)
break; // we've found our group, so we're done
setSize = 0; // not our group, so start a new group
} else {
setSize++; // another button in the group
if (child == this)
posInSet = setSize; // we've found our button
}
}
@ -804,11 +804,10 @@ nsXULToolbarButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
}
PRBool
nsXULToolbarButtonAccessible::IsSeparator(nsIAccessible *aAccessible)
nsXULToolbarButtonAccessible::IsSeparator(nsAccessible *aAccessible)
{
nsCOMPtr<nsIDOMNode> domNode;
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aAccessible));
accessNode->GetDOMNode(getter_AddRefs(domNode));
aAccessible->GetDOMNode(getter_AddRefs(domNode));
nsCOMPtr<nsIContent> contentDomNode(do_QueryInterface(domNode));
if (!contentDomNode)

Просмотреть файл

@ -191,7 +191,8 @@ public:
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
PRInt32 *aSetSize);
static PRBool IsSeparator(nsIAccessible *aAccessible);
// nsXULToolbarButtonAccessible
static PRBool IsSeparator(nsAccessible *aAccessible);
};
class nsXULToolbarAccessible : public nsAccessibleWrap

Просмотреть файл

@ -85,13 +85,11 @@ nsresult nsXULSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint8 aMet
if (!mSelectControl) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIAccessible> childAcc;
GetChildAt(aIndex, getter_AddRefs(childAcc));
nsCOMPtr<nsIAccessNode> accNode = do_QueryInterface(childAcc);
NS_ENSURE_TRUE(accNode, NS_ERROR_FAILURE);
nsAccessible* child = GetChildAt(aIndex);
NS_ENSURE_TRUE(child, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMNode> childNode;
accNode->GetDOMNode(getter_AddRefs(childNode));
child->GetDOMNode(getter_AddRefs(childNode));
nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(childNode));
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
@ -338,18 +336,17 @@ nsXULMenuitemAccessible::GetStateInternal(PRUint32 *aState,
// Is collapsed?
PRBool isCollapsed = PR_FALSE;
nsCOMPtr<nsIAccessible> parentAccessible(GetParent());
if (nsAccUtils::State(parentAccessible) & nsIAccessibleStates::STATE_INVISIBLE)
nsAccessible* parentAcc = GetParent();
if (nsAccUtils::State(parentAcc) & nsIAccessibleStates::STATE_INVISIBLE)
isCollapsed = PR_TRUE;
if (isSelected) {
*aState |= nsIAccessibleStates::STATE_SELECTED;
// Selected and collapsed?
if (isCollapsed) {
// Set selected option offscreen/invisible according to combobox state
nsCOMPtr<nsIAccessible> grandParentAcc;
parentAccessible->GetParent(getter_AddRefs(grandParentAcc));
nsAccessible* grandParentAcc = parentAcc->GetParent();
NS_ENSURE_TRUE(grandParentAcc, NS_ERROR_FAILURE);
NS_ASSERTION(nsAccUtils::Role(grandParentAcc) == nsIAccessibleRole::ROLE_COMBOBOX,
"grandparent of combobox listitem is not combobox");
@ -423,9 +420,9 @@ nsXULMenuitemAccessible::GetKeyboardShortcut(nsAString& aAccessKey)
if (accesskey.IsEmpty())
return NS_OK;
nsCOMPtr<nsIAccessible> parentAccessible(GetParent());
if (parentAccessible) {
if (nsAccUtils::RoleInternal(parentAccessible) ==
nsAccessible* parentAcc = GetParent();
if (parentAcc) {
if (nsAccUtils::RoleInternal(parentAcc) ==
nsIAccessibleRole::ROLE_MENUBAR) {
// If top level menu item, add Alt+ or whatever modifier text to string
// No need to cache pref service, this happens rarely

Просмотреть файл

@ -159,43 +159,35 @@ nsXULTabAccessible::GetRelationByType(PRUint32 aRelationType,
// assume tab and tabpanels are related 1 to 1. We follow algorithm from
// the setter 'selectedIndex' of tabbox.xml#tabs binding.
nsCOMPtr<nsIAccessible> tabsAcc = GetParent();
nsAccessible* tabsAcc = GetParent();
NS_ENSURE_TRUE(nsAccUtils::Role(tabsAcc) == nsIAccessibleRole::ROLE_PAGETABLIST,
NS_ERROR_FAILURE);
PRInt32 tabIndex = -1;
nsCOMPtr<nsIAccessible> childAcc;
tabsAcc->GetFirstChild(getter_AddRefs(childAcc));
while (childAcc) {
PRInt32 childCount = tabsAcc->GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible* childAcc = tabsAcc->GetChildAt(childIdx);
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PAGETAB)
tabIndex++;
if (childAcc == this)
break;
nsCOMPtr<nsIAccessible> acc;
childAcc->GetNextSibling(getter_AddRefs(acc));
childAcc.swap(acc);
}
nsCOMPtr<nsIAccessible> tabBoxAcc;
tabsAcc->GetParent(getter_AddRefs(tabBoxAcc));
nsAccessible* tabBoxAcc = tabsAcc->GetParent();
NS_ENSURE_TRUE(nsAccUtils::Role(tabBoxAcc) == nsIAccessibleRole::ROLE_PANE,
NS_ERROR_FAILURE);
tabBoxAcc->GetFirstChild(getter_AddRefs(childAcc));
while (childAcc) {
childCount = tabBoxAcc->GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible* childAcc = tabBoxAcc->GetChildAt(childIdx);
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_PROPERTYPAGE) {
if (tabIndex == 0)
return nsRelUtils::AddTarget(aRelationType, aRelation, childAcc);
tabIndex--;
}
nsCOMPtr<nsIAccessible> acc;
childAcc->GetNextSibling(getter_AddRefs(acc));
childAcc.swap(acc);
}
return NS_OK;

Просмотреть файл

@ -461,7 +461,7 @@ nsXULTreeAccessible::SelectAllSelection(PRBool *aIsMultiSelectable)
////////////////////////////////////////////////////////////////////////////////
// nsXULTreeAccessible: nsAccessible implementation
nsIAccessible*
nsAccessible*
nsXULTreeAccessible::GetChildAt(PRUint32 aIndex)
{
PRInt32 childCount = nsAccessible::GetChildCount();
@ -473,7 +473,10 @@ nsXULTreeAccessible::GetChildAt(PRUint32 aIndex)
nsCOMPtr<nsIAccessible> child;
GetTreeItemAccessible(aIndex - childCount, getter_AddRefs(child));
return child;
nsRefPtr<nsAccessible> childAcc =
nsAccUtils::QueryObject<nsAccessible>(child);
return childAcc;
}
PRInt32
@ -717,7 +720,7 @@ nsXULTreeAccessible::CreateTreeItemAccessible(PRInt32 aRow,
nsXULTreeItemAccessibleBase::
nsXULTreeItemAccessibleBase(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsIAccessible *aParent, nsITreeBoxObject *aTree,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow) :
mTree(aTree), mTreeView(aTreeView), mRow(aRow),
nsAccessibleWrap(aDOMNode, aShell)
@ -1082,7 +1085,7 @@ nsXULTreeItemAccessibleBase::GetStateInternal(PRUint32 *aState,
return NS_OK;
}
nsIAccessible*
nsAccessible*
nsXULTreeItemAccessibleBase::GetParent()
{
return IsDefunct() ? nsnull : mParent.get();
@ -1184,9 +1187,9 @@ nsXULTreeItemAccessibleBase::IsExpandable()
////////////////////////////////////////////////////////////////////////////////
nsXULTreeItemAccessible::
nsXULTreeItemAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsIAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow) :
nsXULTreeItemAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow) :
nsXULTreeItemAccessibleBase(aDOMNode, aShell, aParent, aTree, aTreeView, aRow)
{
mColumn = nsCoreUtils::GetFirstSensibleColumn(mTree);

Просмотреть файл

@ -89,7 +89,7 @@ public:
PRBool aDeepestChild,
nsIAccessible **aChild);
virtual nsIAccessible* GetChildAt(PRUint32 aIndex);
virtual nsAccessible* GetChildAt(PRUint32 aIndex);
virtual PRInt32 GetChildCount();
virtual PRInt32 GetIndexOf(nsIAccessible *aChild);
@ -166,7 +166,7 @@ class nsXULTreeItemAccessibleBase : public nsAccessibleWrap
{
public:
nsXULTreeItemAccessibleBase(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsIAccessible *aParent, nsITreeBoxObject *aTree,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow);
// nsISupports
@ -201,7 +201,7 @@ public:
// nsAccessible
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
// nsXULTreeItemAccessibleBase
NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID)
@ -255,7 +255,7 @@ class nsXULTreeItemAccessible : public nsXULTreeItemAccessibleBase
{
public:
nsXULTreeItemAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsIAccessible *aParent, nsITreeBoxObject *aTree,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow);
NS_IMETHOD GetName(nsAString& aName);

Просмотреть файл

@ -604,7 +604,7 @@ nsXULTreeGridAccessible::CreateTreeItemAccessible(PRInt32 aRow,
nsXULTreeGridRowAccessible::
nsXULTreeGridRowAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsIAccessible *aTreeAcc, nsITreeBoxObject* aTree,
nsAccessible *aTreeAcc, nsITreeBoxObject* aTree,
nsITreeView *aTreeView, PRInt32 aRow) :
nsXULTreeItemAccessibleBase(aDOMNode, aShell, aTreeAcc, aTree, aTreeView, aRow)
{
@ -689,7 +689,7 @@ nsXULTreeGridRowAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
return NS_OK;
}
nsIAccessible*
nsAccessible*
nsXULTreeGridRowAccessible::GetChildAt(PRUint32 aIndex)
{
if (IsDefunct())
@ -702,7 +702,9 @@ nsXULTreeGridRowAccessible::GetChildAt(PRUint32 aIndex)
nsCOMPtr<nsIAccessible> cell;
GetCellAccessible(column, getter_AddRefs(cell));
return cell;
nsRefPtr<nsAccessible> cellAcc = nsAccUtils::QueryObject<nsAccessible>(cell);
return cellAcc;
}
PRInt32
@ -994,10 +996,7 @@ nsXULTreeGridCellAccessible::GetTable(nsIAccessibleTable **aTable)
if (IsDefunct())
return NS_OK;
nsCOMPtr<nsIAccessible> accessible;
mParent->GetParent(getter_AddRefs(accessible));
CallQueryInterface(accessible, aTable);
CallQueryInterface(mParent->GetParent(), aTable);
return NS_OK;
}
@ -1222,7 +1221,7 @@ nsXULTreeGridCellAccessible::GetStateInternal(PRUint32 *aStates,
return NS_OK;
}
nsIAccessible*
nsAccessible*
nsXULTreeGridCellAccessible::GetParent()
{
return IsDefunct() ? nsnull : mParent.get();

Просмотреть файл

@ -78,7 +78,7 @@ class nsXULTreeGridRowAccessible : public nsXULTreeItemAccessibleBase
{
public:
nsXULTreeGridRowAccessible(nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
nsIAccessible *aParent, nsITreeBoxObject *aTree,
nsAccessible *aParent, nsITreeBoxObject *aTree,
nsITreeView *aTreeView, PRInt32 aRow);
// nsISupports and cycle collection
@ -95,7 +95,7 @@ public:
PRBool aDeepestChild,
nsIAccessible **aChild);
virtual nsIAccessible* GetChildAt(PRUint32 aIndex);
virtual nsAccessible* GetChildAt(PRUint32 aIndex);
virtual PRInt32 GetChildCount();
virtual PRInt32 GetIndexOf(nsIAccessible *aChild);
@ -164,7 +164,7 @@ public:
virtual nsresult GetRoleInternal(PRUint32 *aRole);
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
virtual nsIAccessible* GetParent();
virtual nsAccessible* GetParent();
// nsXULTreeGridCellAccessible
NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID)