Bug 760354 - implement IsInDocument as accessible flag, r=tbsaunde, f=surkov

This commit is contained in:
Mark Capella 2012-06-12 10:30:59 -04:00
parent 763a41042d
commit e952b81a3e
4 changed files with 27 additions and 31 deletions

View File

@ -649,8 +649,7 @@ Accessible::NativeState()
{
PRUint64 state = 0;
DocAccessible* document = Document();
if (!document || !document->IsInDocument(this))
if (!IsInDocument())
state |= states::STALE;
if (mContent->IsElement()) {

View File

@ -689,6 +689,11 @@ public:
*/
bool IsDefunct() const { return mFlags & eIsDefunct; }
/**
* Return true if the accessible is no longer in the document.
*/
bool IsInDocument() const { return !(mFlags & eIsNotInDocument); }
protected:
//////////////////////////////////////////////////////////////////////////////
@ -737,7 +742,8 @@ protected:
* @note keep these flags in sync with ChildrenFlags
*/
enum StateFlags {
eIsDefunct = 1 << 2 // accessible is defunct
eIsDefunct = 1 << 2, // accessible is defunct
eIsNotInDocument = 1 << 3 // accessible is not in document
};
/**
@ -745,22 +751,22 @@ protected:
* @note keep these flags in sync with ChildrenFlags and StateFlags
*/
enum AccessibleTypes {
eApplicationAccessible = 1 << 3,
eAutoCompleteAccessible = 1 << 4,
eAutoCompletePopupAccessible = 1 << 5,
eComboboxAccessible = 1 << 6,
eDocAccessible = 1 << 7,
eHyperTextAccessible = 1 << 8,
eHTMLFileInputAccessible = 1 << 9,
eHTMLListItemAccessible = 1 << 10,
eImageAccessible = 1 << 11,
eImageMapAccessible = 1 << 12,
eListControlAccessible = 1 << 13,
eMenuButtonAccessible = 1 << 14,
eMenuPopupAccessible = 1 << 15,
eRootAccessible = 1 << 16,
eTextLeafAccessible = 1 << 17,
eXULTreeAccessible = 1 << 18
eApplicationAccessible = 1 << 4,
eAutoCompleteAccessible = 1 << 5,
eAutoCompletePopupAccessible = 1 << 6,
eComboboxAccessible = 1 << 7,
eDocAccessible = 1 << 8,
eHyperTextAccessible = 1 << 9,
eHTMLFileInputAccessible = 1 << 10,
eHTMLListItemAccessible = 1 << 11,
eImageAccessible = 1 << 12,
eImageMapAccessible = 1 << 13,
eListControlAccessible = 1 << 14,
eMenuButtonAccessible = 1 << 15,
eMenuPopupAccessible = 1 << 16,
eRootAccessible = 1 << 17,
eTextLeafAccessible = 1 << 18,
eXULTreeAccessible = 1 << 19
};
//////////////////////////////////////////////////////////////////////////////
@ -871,6 +877,7 @@ protected:
eChildrenUninitialized | eMixedChildren | eEmbeddedChildren;
PRUint32 mFlags;
friend class DocAccessible;
nsAutoPtr<EmbeddedObjCollector> mEmbeddedObjCollector;
PRInt32 mIndexOfEmbeddedChild;

View File

@ -2020,6 +2020,8 @@ DocAccessible::CacheChildrenInSubtree(Accessible* aRoot)
void
DocAccessible::UncacheChildrenInSubtree(Accessible* aRoot)
{
aRoot->mFlags |= eIsNotInDocument;
if (aRoot->IsElement())
RemoveDependentIDsFor(aRoot);

View File

@ -242,18 +242,6 @@ public:
bool HasAccessible(nsINode* aNode) const
{ return GetAccessible(aNode); }
/**
* Return true if the given accessible is in document.
*/
bool IsInDocument(Accessible* aAccessible) const
{
Accessible* acc = aAccessible;
while (acc && !acc->IsPrimaryForNode())
acc = acc->Parent();
return acc ? mNodeToAccessibleMap.Get(acc->GetNode()) : false;
}
/**
* Return the cached accessible by the given unique ID within this document.
*