From f1de05abda29949ea183f8e471a309bb511e70bc Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Sun, 18 Nov 2012 00:27:03 +0900 Subject: [PATCH] Bug 804461 - accessible tree walker should take a context accessible as argument, r=tbsaunde --- accessible/src/base/nsAccTreeWalker.cpp | 10 +++++----- accessible/src/base/nsAccTreeWalker.h | 5 +++-- accessible/src/generic/Accessible.cpp | 2 +- accessible/src/generic/DocAccessible.cpp | 6 ++---- accessible/src/html/HTMLTableAccessible.cpp | 2 +- accessible/src/xul/XULColorPickerAccessible.cpp | 2 +- accessible/src/xul/XULFormControlAccessible.cpp | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/accessible/src/base/nsAccTreeWalker.cpp b/accessible/src/base/nsAccTreeWalker.cpp index 2a2383db040..eeff3d7be23 100644 --- a/accessible/src/base/nsAccTreeWalker.cpp +++ b/accessible/src/base/nsAccTreeWalker.cpp @@ -31,17 +31,17 @@ struct WalkState //////////////////////////////////////////////////////////////////////////////// nsAccTreeWalker:: - nsAccTreeWalker(DocAccessible* aDoc, nsIContent* aContent, - bool aWalkAnonContent, bool aWalkCache) : - mDoc(aDoc), mWalkCache(aWalkCache), mState(nullptr) + nsAccTreeWalker(DocAccessible* aDoc, Accessible* aContext, + nsIContent* aContent, bool aWalkCache) : + mDoc(aDoc), mContext(aContext), mWalkCache(aWalkCache), mState(nullptr) { NS_ASSERTION(aContent, "No node for the accessible tree walker!"); if (aContent) mState = new WalkState(aContent); - mChildFilter = aWalkAnonContent ? nsIContent::eAllChildren : - nsIContent::eAllButXBL; + mChildFilter = mContext->CanHaveAnonChildren() ? + nsIContent::eAllChildren : nsIContent::eAllButXBL; mChildFilter |= nsIContent::eSkipPlaceholderContent; diff --git a/accessible/src/base/nsAccTreeWalker.h b/accessible/src/base/nsAccTreeWalker.h index 6992291fecd..a3d0ecf8765 100644 --- a/accessible/src/base/nsAccTreeWalker.h +++ b/accessible/src/base/nsAccTreeWalker.h @@ -19,8 +19,8 @@ struct WalkState; class nsAccTreeWalker { public: - nsAccTreeWalker(DocAccessible* aDoc, nsIContent* aNode, - bool aWalkAnonymousContent, bool aWalkCache = false); + nsAccTreeWalker(DocAccessible* aDoc, Accessible* aContext, nsIContent* aNode, + bool aWalkCache = false); virtual ~nsAccTreeWalker(); /** @@ -60,6 +60,7 @@ private: void PopState(); DocAccessible* mDoc; + Accessible* mContext; int32_t mChildFilter; bool mWalkCache; WalkState* mState; diff --git a/accessible/src/generic/Accessible.cpp b/accessible/src/generic/Accessible.cpp index e1531c64c6b..b8c156e2e29 100644 --- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -2949,7 +2949,7 @@ Accessible::CacheChildren() DocAccessible* doc = Document(); NS_ENSURE_TRUE_VOID(doc); - nsAccTreeWalker walker(doc, mContent, CanHaveAnonChildren()); + nsAccTreeWalker walker(doc, this, mContent); Accessible* child = nullptr; while ((child = walker.NextChild()) && AppendChild(child)); diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 0674328ed5f..0cbef154204 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -1511,8 +1511,7 @@ DocAccessible::CacheChildren() { // Search for accessible children starting from the document element since // some web pages tend to insert elements under it rather than document body. - nsAccTreeWalker walker(this, mDocument->GetRootElement(), - CanHaveAnonChildren()); + nsAccTreeWalker walker(this, this, mDocument->GetRootElement()); Accessible* child = nullptr; while ((child = walker.NextChild()) && AppendChild(child)); @@ -1857,8 +1856,7 @@ DocAccessible::UpdateTree(Accessible* aContainer, nsIContent* aChildNode, updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent); } else { - nsAccTreeWalker walker(this, aChildNode, - aContainer->CanHaveAnonChildren(), true); + nsAccTreeWalker walker(this, aContainer, aChildNode, true); while ((child = walker.NextChild())) updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent); diff --git a/accessible/src/html/HTMLTableAccessible.cpp b/accessible/src/html/HTMLTableAccessible.cpp index 571989aed8e..259095ed195 100644 --- a/accessible/src/html/HTMLTableAccessible.cpp +++ b/accessible/src/html/HTMLTableAccessible.cpp @@ -358,7 +358,7 @@ HTMLTableAccessible::CacheChildren() // caption only, because nsAccessibilityService ensures we don't create // accessibles for the other captions, since only the first is actually // visible. - nsAccTreeWalker walker(mDoc, mContent, CanHaveAnonChildren()); + nsAccTreeWalker walker(mDoc, this, mContent); Accessible* child = nullptr; while ((child = walker.NextChild())) { diff --git a/accessible/src/xul/XULColorPickerAccessible.cpp b/accessible/src/xul/XULColorPickerAccessible.cpp index 6b1c36e8939..06edc18e77a 100644 --- a/accessible/src/xul/XULColorPickerAccessible.cpp +++ b/accessible/src/xul/XULColorPickerAccessible.cpp @@ -141,7 +141,7 @@ XULColorPickerAccessible::CacheChildren() { NS_ENSURE_TRUE_VOID(mDoc); - nsAccTreeWalker walker(mDoc, mContent, true); + nsAccTreeWalker walker(mDoc, this, mContent); Accessible* child = nullptr; while ((child = walker.NextChild())) { diff --git a/accessible/src/xul/XULFormControlAccessible.cpp b/accessible/src/xul/XULFormControlAccessible.cpp index 1b466a4633d..6b8c4d2993a 100644 --- a/accessible/src/xul/XULFormControlAccessible.cpp +++ b/accessible/src/xul/XULFormControlAccessible.cpp @@ -188,7 +188,7 @@ XULButtonAccessible::CacheChildren() Accessible* menupopup = nullptr; Accessible* button = nullptr; - nsAccTreeWalker walker(mDoc, mContent, true); + nsAccTreeWalker walker(mDoc, this, mContent); Accessible* child = nullptr; while ((child = walker.NextChild())) { @@ -827,7 +827,7 @@ XULTextFieldAccessible::CacheChildren() if (!inputContent) return; - nsAccTreeWalker walker(mDoc, inputContent, false); + nsAccTreeWalker walker(mDoc, this, inputContent); Accessible* child = nullptr; while ((child = walker.NextChild()) && AppendChild(child));