Bug 708144 - Make sure to update the Mac accessible tree. r=tbsaunde landing on a CLOSED TREE

This commit is contained in:
Hub Figuière 2011-12-22 14:31:06 -08:00
parent 0e444575b8
commit 9892e422ac
5 changed files with 78 additions and 27 deletions

View File

@ -187,7 +187,7 @@ nsOuterDocAccessible::AppendChild(nsAccessible *aAccessible)
if (mChildren.Length())
mChildren[0]->Shutdown();
if (!nsAccessible::AppendChild(aAccessible))
if (!nsAccessibleWrap::AppendChild(aAccessible))
return false;
NS_LOG_ACCDOCCREATE("append document to outerdoc",
@ -210,7 +210,7 @@ nsOuterDocAccessible::RemoveChild(nsAccessible *aAccessible)
child->GetDocumentNode(), child)
NS_LOG_ACCDOCDESTROY_ACCADDRESS("outerdoc", this)
bool wasRemoved = nsAccessible::RemoveChild(child);
bool wasRemoved = nsAccessibleWrap::RemoveChild(child);
NS_ASSERTION(!mChildren.Length(),
"This child document of outerdoc accessible wasn't removed!");

View File

@ -130,6 +130,11 @@
// invalidates and removes all our children from our cached array.
- (void)invalidateChildren;
/**
* Append a child if they are already cached.
*/
- (void)appendChild:(nsAccessible*)aAccessible;
// invalidates the cached parent, used by invalidateChildren.
- (void)invalidateParent;

View File

@ -615,6 +615,17 @@ GetNativeFromGeckoAccessible(nsIAccessible *anAccessible)
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (void)appendChild:(nsAccessible*)aAccessible
{
// if mChildren is nil, then we don't even need to bother
if (!mChildren)
return;
mozAccessible *curNative = GetNativeFromGeckoAccessible(aAccessible);
if (curNative)
[mChildren addObject:GetObjectOrRepresentedView(curNative)];
}
- (void)invalidateParent
{
mParent = nil;

View File

@ -61,33 +61,45 @@
class nsAccessibleWrap : public nsAccessible
{
public: // construction, destruction
nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
public: // construction, destruction
nsAccessibleWrap(nsIContent* aContent, nsIWeakReference* aShell);
virtual ~nsAccessibleWrap();
// get the native obj-c object (mozAccessible)
NS_IMETHOD GetNativeInterface (void **aOutAccessible);
/**
* Get the native Obj-C object (mozAccessible).
*/
NS_IMETHOD GetNativeInterface (void** aOutAccessible);
// the objective-c |Class| type that this accessible's native object
// should be instantied with. used on runtime to determine the
// right type for this accessible's associated native object.
/**
* The objective-c |Class| type that this accessible's native object
* should be instantied with. used on runtime to determine the
* right type for this accessible's associated native object.
*/
virtual Class GetNativeType ();
virtual void Shutdown ();
virtual void InvalidateChildren();
virtual bool AppendChild(nsAccessible* aAccessible);
virtual bool RemoveChild(nsAccessible* aAccessible);
virtual nsresult HandleAccEvent(AccEvent* aEvent);
// ignored means that the accessible might still have children, but is not displayed
// to the user. it also has no native accessible object represented for it.
/**
* Ignored means that the accessible might still have children, but is not
* displayed to the user. it also has no native accessible object represented
* for it.
*/
bool IsIgnored();
bool HasPopup () {
return (NativeState() & mozilla::a11y::states::HASPOPUP);
}
inline bool HasPopup ()
{ return (NativeState() & mozilla::a11y::states::HASPOPUP); }
// return this accessible's all children, adhering to "flat" accessibles by not returning their children.
void GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aChildrenArray);
/**
* Returns this accessible's all children, adhering to "flat" accessibles by
* not returning their children.
*/
void GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> >& aChildrenArray);
virtual already_AddRefed<nsIAccessible> GetUnignoredParent();
protected:
@ -112,7 +124,8 @@ private:
/**
* Our native object. Private because its creation is done lazily.
* Don't access it directly. Ever. Unless you are GetNativeObject() or Shutdown()
* Don't access it directly. Ever. Unless you are GetNativeObject() or
* Shutdown()
*/
#if defined(__OBJC__)
// if we are in Objective-C, we use the actual Obj-C class.

View File

@ -208,6 +208,28 @@ nsAccessibleWrap::InvalidateChildren()
NS_OBJC_END_TRY_ABORT_BLOCK;
}
bool
nsAccessibleWrap::AppendChild(nsAccessible *aAccessible)
{
bool appended = nsAccessible::AppendChild(aAccessible);
if (appended && mNativeObject)
[mNativeObject appendChild:aAccessible];
return appended;
}
bool
nsAccessibleWrap::RemoveChild(nsAccessible *aAccessible)
{
bool removed = nsAccessible::RemoveChild(aAccessible);
if (removed && mNativeObject)
[mNativeObject invalidateChildren];
return removed;
}
// if we for some reason have no native accessible, we should be skipped over (and traversed)
// when fetching all unignored children, etc. when counting unignored children, we will not be counted.
bool