Bug 767755: Re-implement IsPrimaryForNode() using an Accessible::mFlags bit. r=surkov

This commit is contained in:
Eric Wong 2012-09-03 23:06:10 -07:00
parent 5052fa9f73
commit 8c2c0633e0
15 changed files with 42 additions and 84 deletions

View File

@ -155,12 +155,6 @@ nsAccessNode::GetDocumentNode() const
return mContent ? mContent->OwnerDoc() : nullptr;
}
bool
nsAccessNode::IsPrimaryForNode() const
{
return true;
}
void
nsAccessNode::Language(nsAString& aLanguage)
{

View File

@ -96,15 +96,6 @@ public:
*/
void* UniqueID() { return static_cast<void*>(this); }
/**
* Return true if the accessible is primary accessible for the given DOM node.
*
* Accessible hierarchy may be complex for single DOM node, in this case
* these accessibles share the same DOM node. The primary accessible "owns"
* that DOM node in terms it gets stored in the accessible to node map.
*/
virtual bool IsPrimaryForNode() const;//hello
/**
* Interface methods on nsIAccessible shared with ISimpleDOM.
*/

View File

@ -689,6 +689,15 @@ public:
*/
bool IsInDocument() const { return !(mFlags & eIsNotInDocument); }
/**
* Return true if the accessible is primary accessible for the given DOM node.
*
* Accessible hierarchy may be complex for single DOM node, in this case
* these accessibles share the same DOM node. The primary accessible "owns"
* that DOM node in terms it gets stored in the accessible to node map.
*/
bool IsPrimaryForNode() const { return !(mFlags & eSharedNode); }
protected:
//////////////////////////////////////////////////////////////////////////////
@ -738,7 +747,8 @@ protected:
*/
enum StateFlags {
eIsDefunct = 1 << 2, // accessible is defunct
eIsNotInDocument = 1 << 3 // accessible is not in document
eIsNotInDocument = 1 << 3, // accessible is not in document
eSharedNode = 1 << 4 // accessible shares DOM node from another accessible
};
/**
@ -746,23 +756,23 @@ protected:
* @note keep these flags in sync with ChildrenFlags and StateFlags
*/
enum AccessibleTypes {
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,
eXULDeckAccessible = 1 << 19,
eXULTreeAccessible = 1 << 20
eApplicationAccessible = 1 << 5,
eAutoCompleteAccessible = 1 << 6,
eAutoCompletePopupAccessible = 1 << 7,
eComboboxAccessible = 1 << 8,
eDocAccessible = 1 << 9,
eHyperTextAccessible = 1 << 10,
eHTMLFileInputAccessible = 1 << 11,
eHTMLListItemAccessible = 1 << 12,
eImageAccessible = 1 << 13,
eImageMapAccessible = 1 << 14,
eListControlAccessible = 1 << 15,
eMenuButtonAccessible = 1 << 16,
eMenuPopupAccessible = 1 << 17,
eRootAccessible = 1 << 18,
eTextLeafAccessible = 1 << 19,
eXULDeckAccessible = 1 << 20,
eXULTreeAccessible = 1 << 21
};
//////////////////////////////////////////////////////////////////////////////

View File

@ -26,7 +26,7 @@ using namespace mozilla::a11y;
ApplicationAccessible::ApplicationAccessible() :
AccessibleWrap(nullptr, nullptr)
{
mFlags |= eApplicationAccessible;
mFlags |= (eApplicationAccessible | eSharedNode);
}
////////////////////////////////////////////////////////////////////////////////
@ -280,11 +280,6 @@ ApplicationAccessible::Shutdown()
mAppInfo = nullptr;
}
bool
ApplicationAccessible::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Accessible public methods

View File

@ -63,7 +63,6 @@ public:
// nsAccessNode
virtual void Init();
virtual void Shutdown();
virtual bool IsPrimaryForNode() const;
// Accessible
virtual GroupPos GroupPosition();

View File

@ -152,6 +152,9 @@ HTMLAreaAccessible::
HTMLAreaAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HTMLLinkAccessible(aContent, aDoc)
{
// Make HTML area DOM element not accessible. HTML image map accessible
// manages its tree itself.
mFlags |= eSharedNode;
}
////////////////////////////////////////////////////////////////////////////////
@ -183,17 +186,6 @@ HTMLAreaAccessible::Description(nsString& aDescription)
area->GetShape(aDescription);
}
////////////////////////////////////////////////////////////////////////////////
// HTMLAreaAccessible: nsAccessNode public
bool
HTMLAreaAccessible::IsPrimaryForNode() const
{
// Make HTML area DOM element not accessible. HTML image map accessible
// manages its tree itself.
return false;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLAreaAccessible: Accessible public

View File

@ -53,9 +53,6 @@ public:
HTMLAreaAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsAccessNode
virtual bool IsPrimaryForNode() const;
// Accessible
virtual void Description(nsString& aDescription);
virtual nsresult GetNameInternal(nsAString& aName);

View File

@ -141,6 +141,12 @@ HTMLLIAccessible::CacheChildren()
////////////////////////////////////////////////////////////////////////////////
// HTMLListBulletAccessible
////////////////////////////////////////////////////////////////////////////////
HTMLListBulletAccessible::
HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc)
{
mFlags |= eSharedNode;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLListBulletAccessible: nsAccessNode
@ -152,12 +158,6 @@ HTMLListBulletAccessible::GetFrame() const
return blockFrame ? blockFrame->GetBullet() : nullptr;
}
bool
HTMLListBulletAccessible::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLListBulletAccessible: Accessible

View File

@ -75,13 +75,11 @@ private:
class HTMLListBulletAccessible : public LeafAccessible
{
public:
HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc) { }
HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc);
virtual ~HTMLListBulletAccessible() { }
// nsAccessNode
virtual nsIFrame* GetFrame() const;
virtual bool IsPrimaryForNode() const;
// Accessible
virtual ENameValueFlag Name(nsString& aName);

View File

@ -635,6 +635,7 @@ HTMLComboboxListAccessible::
DocAccessible* aDoc) :
HTMLSelectListAccessible(aContent, aDoc)
{
mFlags |= eSharedNode;
}
////////////////////////////////////////////////////////////////////////////////
@ -655,12 +656,6 @@ HTMLComboboxListAccessible::GetFrame() const
return nullptr;
}
bool
HTMLComboboxListAccessible::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLComboboxAccessible: Accessible

View File

@ -222,7 +222,6 @@ public:
// nsAccessNode
virtual nsIFrame* GetFrame() const;
virtual bool IsPrimaryForNode() const;
// Accessible
virtual a11y::role NativeRole();

View File

@ -703,6 +703,7 @@ XULTreeItemAccessibleBase::
mTree(aTree), mTreeView(aTreeView), mRow(aRow)
{
mParent = aParent;
mFlags |= eSharedNode;
}
////////////////////////////////////////////////////////////////////////////////
@ -896,12 +897,6 @@ XULTreeItemAccessibleBase::Shutdown()
AccessibleWrap::Shutdown();
}
bool
XULTreeItemAccessibleBase::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeItemAccessibleBase: Accessible public methods

View File

@ -154,7 +154,6 @@ public:
// nsAccessNode
virtual void Shutdown();
virtual bool IsPrimaryForNode() const;
// Accessible
virtual GroupPos GroupPosition();

View File

@ -469,6 +469,7 @@ XULTreeGridCellAccessible::
mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
{
mParent = aRowAcc;
mFlags |= eSharedNode;
}
////////////////////////////////////////////////////////////////////////////////
@ -794,12 +795,6 @@ XULTreeGridCellAccessible::Init()
mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
}
bool
XULTreeGridCellAccessible::IsPrimaryForNode() const
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridCellAccessible: Accessible public implementation

View File

@ -151,7 +151,6 @@ public:
// nsAccessNode
virtual void Init();
virtual bool IsPrimaryForNode() const;
// Accessible
virtual void Shutdown();