From 9a3cd09269dfe9a61ebea71df0e9a0fa47ffb08e Mon Sep 17 00:00:00 2001 From: Jignesh Kakadiya Date: Fri, 23 Mar 2012 14:26:52 +0900 Subject: [PATCH] Bug 726005 - IDRefsIterator::Next() should use nsDocAccessible::GetAccessible(), r=tbsaunde, f=surkov --- accessible/src/base/AccIterator.cpp | 8 +++++--- accessible/src/base/AccIterator.h | 4 +++- accessible/src/base/nsAccessible.cpp | 14 +++++++------- accessible/src/base/nsDocAccessible.cpp | 4 ++-- accessible/src/base/nsTextEquivUtils.cpp | 2 +- accessible/src/html/nsHTMLTableAccessible.cpp | 2 +- accessible/src/html/nsHTMLTextAccessible.cpp | 2 +- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/accessible/src/base/AccIterator.cpp b/accessible/src/base/AccIterator.cpp index 58c4de6af7b1..e8b305a4e51b 100644 --- a/accessible/src/base/AccIterator.cpp +++ b/accessible/src/base/AccIterator.cpp @@ -277,8 +277,10 @@ XULDescriptionIterator::Next() // IDRefsIterator //////////////////////////////////////////////////////////////////////////////// -IDRefsIterator::IDRefsIterator(nsIContent* aContent, nsIAtom* aIDRefsAttr) : - mCurrIdx(0), mContent(aContent) +IDRefsIterator:: + IDRefsIterator(nsDocAccessible* aDoc, nsIContent* aContent, + nsIAtom* aIDRefsAttr) : + mCurrIdx(0), mContent(aContent), mDoc(aDoc) { if (mContent->IsInDoc()) mContent->GetAttr(kNameSpaceID_None, aIDRefsAttr, mIDs); @@ -368,7 +370,7 @@ nsAccessible* IDRefsIterator::Next() { nsIContent* nextElm = NextElem(); - return nextElm ? GetAccService()->GetAccessible(nextElm, nsnull) : nsnull; + return nextElm ? mDoc->GetAccessible(nextElm) : nsnull; } nsAccessible* diff --git a/accessible/src/base/AccIterator.h b/accessible/src/base/AccIterator.h index 0be6880a4dd2..60acf78cafdd 100644 --- a/accessible/src/base/AccIterator.h +++ b/accessible/src/base/AccIterator.h @@ -264,7 +264,8 @@ private: class IDRefsIterator : public AccIterable { public: - IDRefsIterator(nsIContent* aContent, nsIAtom* aIDRefsAttr); + IDRefsIterator(nsDocAccessible* aDoc, nsIContent* aContent, + nsIAtom* aIDRefsAttr); virtual ~IDRefsIterator() { } /** @@ -292,6 +293,7 @@ private: nsString mIDs; nsIContent* mContent; + nsDocAccessible* mDoc; nsAString::index_type mCurrIdx; }; diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index d1f1a57dec8b..df02dd788023 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -2015,14 +2015,14 @@ nsAccessible::RelationByType(PRUint32 aType) Relation rel(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_labelledby)); if (mContent->Tag() == nsGkAtoms::label) - rel.AppendIter(new IDRefsIterator(mContent, mContent->IsHTML() ? + rel.AppendIter(new IDRefsIterator(mDoc, mContent, mContent->IsHTML() ? nsGkAtoms::_for : nsGkAtoms::control)); return rel; } case nsIAccessibleRelation::RELATION_LABELLED_BY: { - Relation rel(new IDRefsIterator(mContent, + Relation rel(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_labelledby)); if (mContent->IsHTML()) { rel.AppendIter(new HTMLLabelIterator(Document(), this)); @@ -2033,8 +2033,8 @@ nsAccessible::RelationByType(PRUint32 aType) return rel; } case nsIAccessibleRelation::RELATION_DESCRIBED_BY: { - Relation rel(new IDRefsIterator(mContent, - nsGkAtoms::aria_describedby)); + Relation rel(new IDRefsIterator(mDoc, mContent, + nsGkAtoms::aria_describedby)); if (mContent->IsXUL()) rel.AppendIter(new XULDescriptionIterator(Document(), mContent)); @@ -2049,7 +2049,7 @@ nsAccessible::RelationByType(PRUint32 aType) // tied to a control. if (mContent->Tag() == nsGkAtoms::description && mContent->IsXUL()) - rel.AppendIter(new IDRefsIterator(mContent, + rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::control)); return rel; @@ -2091,13 +2091,13 @@ nsAccessible::RelationByType(PRUint32 aType) return Relation(new RelatedAccIterator(Document(), mContent, nsGkAtoms::aria_controls)); case nsIAccessibleRelation::RELATION_CONTROLLER_FOR: { - Relation rel(new IDRefsIterator(mContent, + Relation rel(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_controls)); rel.AppendIter(new HTMLOutputIterator(Document(), mContent)); return rel; } case nsIAccessibleRelation::RELATION_FLOWS_TO: - return Relation(new IDRefsIterator(mContent, + return Relation(new IDRefsIterator(mDoc, mContent, nsGkAtoms::aria_flowto)); case nsIAccessibleRelation::RELATION_FLOWS_FROM: return Relation(new RelatedAccIterator(Document(), mContent, diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index ac70389f7ae7..9e3e5e81252b 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1617,7 +1617,7 @@ nsDocAccessible::AddDependentIDsFor(nsAccessible* aRelProvider, continue; } - IDRefsIterator iter(aRelProvider->GetContent(), relAttr); + IDRefsIterator iter(this, aRelProvider->GetContent(), relAttr); while (true) { const nsDependentSubstring id = iter.NextID(); if (id.IsEmpty()) @@ -1668,7 +1668,7 @@ nsDocAccessible::RemoveDependentIDsFor(nsAccessible* aRelProvider, if (aRelAttr && aRelAttr != *kRelationAttrs[idx]) continue; - IDRefsIterator iter(aRelProvider->GetContent(), relAttr); + IDRefsIterator iter(this, aRelProvider->GetContent(), relAttr); while (true) { const nsDependentSubstring id = iter.NextID(); if (id.IsEmpty()) diff --git a/accessible/src/base/nsTextEquivUtils.cpp b/accessible/src/base/nsTextEquivUtils.cpp index 881e51bb170b..44ed8e41d1aa 100644 --- a/accessible/src/base/nsTextEquivUtils.cpp +++ b/accessible/src/base/nsTextEquivUtils.cpp @@ -94,7 +94,7 @@ nsTextEquivUtils::GetTextEquivFromIDRefs(nsAccessible *aAccessible, return NS_OK; nsIContent* refContent = nsnull; - IDRefsIterator iter(content, aIDRefsAttr); + IDRefsIterator iter(aAccessible->Document(), content, aIDRefsAttr); while ((refContent = iter.NextElem())) { if (!aTextEquiv.IsEmpty()) aTextEquiv += ' '; diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp index e487a54f3761..a5547bb3d1cc 100644 --- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -334,7 +334,7 @@ nsHTMLTableCellAccessible::GetHeaderCells(PRInt32 aRowOrColumnHeaderCell, nsIArray **aHeaderCells) { // Get header cells from @header attribute. - IDRefsIterator iter(mContent, nsGkAtoms::headers); + IDRefsIterator iter(mDoc, mContent, nsGkAtoms::headers); nsIContent* headerCellElm = iter.NextElem(); if (headerCellElm) { nsresult rv = NS_OK; diff --git a/accessible/src/html/nsHTMLTextAccessible.cpp b/accessible/src/html/nsHTMLTextAccessible.cpp index 766462f3dda9..d997253e0fcb 100644 --- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -204,7 +204,7 @@ nsHTMLOutputAccessible::RelationByType(PRUint32 aType) { Relation rel = nsAccessibleWrap::RelationByType(aType); if (aType == nsIAccessibleRelation::RELATION_CONTROLLED_BY) - rel.AppendIter(new IDRefsIterator(mContent, nsGkAtoms::_for)); + rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for)); return rel; }