diff --git a/accessible/src/atk/nsApplicationAccessibleWrap.cpp b/accessible/src/atk/nsApplicationAccessibleWrap.cpp index 0aede6766cc..e9ebff65a1e 100644 --- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp +++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp @@ -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. diff --git a/accessible/src/base/nsAccUtils.h b/accessible/src/base/nsAccUtils.h index 80101056b5e..70a42e7eef9 100644 --- a/accessible/src/base/nsAccUtils.h +++ b/accessible/src/base/nsAccUtils.h @@ -335,6 +335,15 @@ public: return object; } + template static inline + already_AddRefed QueryObject(nsRefPtr& aObject) + { + DestinationType* object = nsnull; + if (aObject) + CallQueryInterface(aObject.get(), &object); + + return object; + } /** * Query nsAccessNode from the given nsIAccessible. diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 33ad4b9d4ea..44d23810786 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -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(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(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 parent(GetParent()); - nsCOMPtr hyperTextParent(do_QueryInterface(parent)); + nsCOMPtr hyperTextParent = + nsAccUtils::QueryObject(GetParent()); + if (hyperTextParent) { *aInstancePtr = static_cast(this); NS_ADDREF_THIS(); @@ -483,8 +490,7 @@ nsAccessible::Shutdown() // sure none of its children point to this parent InvalidateChildren(); if (mParent) { - nsRefPtr 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 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 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 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 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 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 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 child = - nsAccUtils::QueryObject(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 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 childAcc = nsAccUtils::QueryAccessible(child); - nsCOMPtr 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 parentAcc = - nsAccUtils::QueryObject(parent); - return parentAcc->GetIndexOf(this); + nsAccessible *parent = GetParent(); + return parent ? parent->GetIndexOf(this) : -1; } -already_AddRefed +nsAccessible* nsAccessible::GetCachedParent() { if (IsDefunct()) return nsnull; - nsCOMPtr cachedParent = mParent; - return cachedParent.forget(); + return mParent; } -already_AddRefed +nsAccessible* nsAccessible::GetCachedFirstChild() { if (IsDefunct()) return nsnull; - nsCOMPtr 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 acc = nsAccUtils::QueryObject(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 parentAcc = - nsAccUtils::QueryObject(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 parent = GetParent(); + nsAccessible* parent = GetParent(); NS_ENSURE_TRUE(parent,); - // Compute 'posinset' and 'setsize' attributes. - PRInt32 positionInGroup = 0; - PRInt32 setSize = 0; - - nsCOMPtr 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 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 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 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 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 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 diff --git a/accessible/src/base/nsAccessible.h b/accessible/src/base/nsAccessible.h index 20739ae1419..04947378a9b 100644 --- a/accessible/src/base/nsAccessible.h +++ b/accessible/src/base/nsAccessible.h @@ -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 GetCachedParent(); + nsAccessible* GetCachedParent(); /** * Return first child accessible only if cached. */ - already_AddRefed 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 mParent; - nsCOMArray mChildren; + nsRefPtr mParent; + nsTArray > mChildren; PRBool mAreChildrenInitialized; nsRoleMapEntry *mRoleMapEntry; // Non-null indicates author-supplied role; possibly state & value as well diff --git a/accessible/src/base/nsApplicationAccessible.cpp b/accessible/src/base/nsApplicationAccessible.cpp index e2ec604f5ff..1ef674eed22 100644 --- a/accessible/src/base/nsApplicationAccessible.cpp +++ b/accessible/src/base/nsApplicationAccessible.cpp @@ -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 rootAcc = + nsAccUtils::QueryObject(aRootAccessible); + + if (!mChildren.AppendElement(rootAcc)) return NS_ERROR_FAILURE; - nsRefPtr 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; } diff --git a/accessible/src/base/nsApplicationAccessible.h b/accessible/src/base/nsApplicationAccessible.h index 6668df5708b..54beb46189a 100644 --- a/accessible/src/base/nsApplicationAccessible.h +++ b/accessible/src/base/nsApplicationAccessible.h @@ -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(); diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 504027262e5..77858f63c6c 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -346,9 +346,8 @@ nsDocAccessible::GetARIAState(PRUint32 *aState, PRUint32 *aExtraState) nsresult rv = nsAccessible::GetARIAState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr 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 accessible = do_QueryInterface(*aAccessNode); - nsRefPtr acc = nsAccUtils::QueryAccessible(accessible); + nsRefPtr acc = + nsAccUtils::QueryObject(*aAccessNode); + if (acc) { - nsCOMPtr parent = acc->GetCachedParent(); - nsRefPtr 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 acc(nsAccUtils::QueryAccessible(GetParent())); + nsRefPtr 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 parent; + accService->GetAccessibleFor(ownerNode, getter_AddRefs(parent)); + mParent = nsAccUtils::QueryObject(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 childAccessible = acc->GetCachedFirstChild(); - if (childAccessible) { + if (acc->GetCachedFirstChild()) { nsCOMPtr children; // use GetChildren() to fetch children at one time, instead of using // GetNextSibling(), because after we shutdown the first child, diff --git a/accessible/src/base/nsDocAccessible.h b/accessible/src/base/nsDocAccessible.h index d351be665a1..fd5e0c36a71 100644 --- a/accessible/src/base/nsDocAccessible.h +++ b/accessible/src/base/nsDocAccessible.h @@ -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); diff --git a/accessible/src/base/nsOuterDocAccessible.cpp b/accessible/src/base/nsOuterDocAccessible.cpp index df962beffa7..db17b978200 100644 --- a/accessible/src/base/nsOuterDocAccessible.cpp +++ b/accessible/src/base/nsOuterDocAccessible.cpp @@ -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); } diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index b18280eafd9..9a0efebf204 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -1062,7 +1062,7 @@ nsRootAccessible::GetRelationByType(PRUint32 aRelationType, //////////////////////////////////////////////////////////////////////////////// // nsAccessible -nsIAccessible* +nsAccessible* nsRootAccessible::GetParent() { // Parent has been setted in nsApplicationAccesible::AddRootAccessible() diff --git a/accessible/src/base/nsRootAccessible.h b/accessible/src/base/nsRootAccessible.h index 8e39079a1c5..89d0414b440 100644 --- a/accessible/src/base/nsRootAccessible.h +++ b/accessible/src/base/nsRootAccessible.h @@ -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); diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp index e723fd5626c..d1a9ec91914 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -673,19 +673,20 @@ nsHTMLLegendAccessible::GetRelationByType(PRUint32 aRelationType, if (aRelationType == nsIAccessibleRelation::RELATION_LABEL_FOR) { // Look for groupbox parent - nsCOMPtr 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 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); } } } diff --git a/accessible/src/html/nsHTMLImageAccessible.cpp b/accessible/src/html/nsHTMLImageAccessible.cpp index 29d235fc956..cb21a2a1abb 100644 --- a/accessible/src/html/nsHTMLImageAccessible.cpp +++ b/accessible/src/html/nsHTMLImageAccessible.cpp @@ -173,8 +173,8 @@ nsHTMLImageAccessible::CacheChildren() if (!areaAccessible) return; - mChildren.AppendObject(areaAccessible); areaAcc = nsAccUtils::QueryObject(areaAccessible); + mChildren.AppendElement(areaAcc); areaAcc->SetParent(this); } } diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index 16ce9e16e2d..96512dcbc4d 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -403,10 +403,10 @@ nsHTMLSelectListAccessible::CacheOptSiblings(nsIContent *aParentContent) GetAccService()->GetAccessibleInWeakShell(childNode, mWeakShell, getter_AddRefs(accessible)); if (accessible) { - mChildren.AppendObject(accessible); - nsRefPtr acc = nsAccUtils::QueryObject(accessible); + + mChildren.AppendElement(acc); acc->SetParent(this); } @@ -445,7 +445,10 @@ nsHyperTextAccessibleWrap(aDOMNode, aShell) } } } - SetParent(parentAccessible); + + nsRefPtr parentAcc = + nsAccUtils::QueryObject(parentAccessible); + SetParent(parentAcc); } //////////////////////////////////////////////////////////////////////////////// @@ -585,12 +588,12 @@ nsHTMLSelectOptionAccessible::GetStateInternal(PRUint32 *aState, // visibility implementation unless they get reimplemented in layout *aState &= ~nsIAccessibleStates::STATE_OFFSCREEN; //