Bug 818407, part1 - don't mix up with accessible types of ARIA role, r=tbsaunde

This commit is contained in:
Alexander Surkov 2012-12-20 20:48:03 +09:00
parent 12983421f5
commit 290e6e5ec4
12 changed files with 38 additions and 19 deletions

View File

@ -6,6 +6,7 @@
#include "InterfaceInitFuncs.h" #include "InterfaceInitFuncs.h"
#include "Accessible-inl.h"
#include "HyperTextAccessible.h" #include "HyperTextAccessible.h"
#include "nsMai.h" #include "nsMai.h"

View File

@ -6,6 +6,7 @@
#include "InterfaceInitFuncs.h" #include "InterfaceInitFuncs.h"
#include "Accessible-inl.h"
#include "HyperTextAccessible.h" #include "HyperTextAccessible.h"
#include "nsMai.h" #include "nsMai.h"
#include "nsMaiHyperlink.h" #include "nsMaiHyperlink.h"

View File

@ -6,6 +6,7 @@
#include "InterfaceInitFuncs.h" #include "InterfaceInitFuncs.h"
#include "Accessible-inl.h"
#include "HyperTextAccessible.h" #include "HyperTextAccessible.h"
#include "nsMai.h" #include "nsMai.h"

View File

@ -5,7 +5,7 @@
#include "AccIterator.h" #include "AccIterator.h"
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "Accessible.h" #include "Accessible-inl.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "nsBindingManager.h" #include "nsBindingManager.h"

View File

@ -9,6 +9,7 @@
#define _nsARIAMap_H_ #define _nsARIAMap_H_
#include "ARIAStateMap.h" #include "ARIAStateMap.h"
#include "mozilla/a11y/AccTypes.h"
#include "mozilla/a11y/Role.h" #include "mozilla/a11y/Role.h"
#include "nsIAtom.h" #include "nsIAtom.h"
@ -149,6 +150,12 @@ struct nsRoleMapEntry
bool Is(nsIAtom* aARIARole) const bool Is(nsIAtom* aARIARole) const
{ return *roleAtom == aARIARole; } { return *roleAtom == aARIARole; }
/**
* Return true if ARIA role has the given accessible type.
*/
bool IsOfType(mozilla::a11y::AccGenericType aType) const
{ return accTypes & aType; }
/** /**
* Return ARIA role. * Return ARIA role.
*/ */

View File

@ -31,12 +31,11 @@ Accessible::ARIARole()
return ARIATransformRole(mRoleMapEntry->role); return ARIATransformRole(mRoleMapEntry->role);
} }
inline void inline bool
Accessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry) Accessible::HasGenericType(AccGenericType aType) const
{ {
mRoleMapEntry = aRoleMapEntry; return (mGenericTypes & aType) ||
if (mRoleMapEntry) (mRoleMapEntry && mRoleMapEntry->IsOfType(aType));
mGenericTypes |= mRoleMapEntry->accTypes;
} }
inline bool inline bool

View File

@ -304,7 +304,8 @@ public:
/** /**
* Set the ARIA role map entry for a new accessible. * Set the ARIA role map entry for a new accessible.
*/ */
void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry); void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
{ mRoleMapEntry = aRoleMapEntry; }
/** /**
* Update the children cache. * Update the children cache.
@ -468,17 +469,17 @@ public:
bool IsApplication() const { return mType == eApplicationType; } bool IsApplication() const { return mType == eApplicationType; }
bool IsAutoComplete() const { return mGenericTypes & eAutoComplete; } bool IsAutoComplete() const { return HasGenericType(eAutoComplete); }
bool IsAutoCompletePopup() const bool IsAutoCompletePopup() const
{ return mGenericTypes & eAutoCompletePopup; } { return HasGenericType(eAutoCompletePopup); }
bool IsCombobox() const { return mGenericTypes & eCombobox; } bool IsCombobox() const { return HasGenericType(eCombobox); }
bool IsDoc() const { return mGenericTypes & eDocument; } bool IsDoc() const { return HasGenericType(eDocument); }
DocAccessible* AsDoc(); DocAccessible* AsDoc();
bool IsHyperText() const { return mGenericTypes & eHyperText; } bool IsHyperText() const { return HasGenericType(eHyperText); }
HyperTextAccessible* AsHyperText(); HyperTextAccessible* AsHyperText();
bool IsHTMLFileInput() const { return mType == eHTMLFileInputType; } bool IsHTMLFileInput() const { return mType == eHTMLFileInputType; }
@ -494,11 +495,11 @@ public:
bool IsImageMap() const { return mType == eImageMapType; } bool IsImageMap() const { return mType == eImageMapType; }
HTMLImageMapAccessible* AsImageMap(); HTMLImageMapAccessible* AsImageMap();
bool IsList() const { return mGenericTypes & eList; } bool IsList() const { return HasGenericType(eList); }
bool IsListControl() const { return mGenericTypes & eListControl; } bool IsListControl() const { return HasGenericType(eListControl); }
bool IsMenuButton() const { return mGenericTypes & eMenuButton; } bool IsMenuButton() const { return HasGenericType(eMenuButton); }
bool IsMenuPopup() const { return mType == eMenuPopupType; } bool IsMenuPopup() const { return mType == eMenuPopupType; }
@ -507,14 +508,14 @@ public:
bool IsRoot() const { return mType == eRootType; } bool IsRoot() const { return mType == eRootType; }
a11y::RootAccessible* AsRoot(); a11y::RootAccessible* AsRoot();
bool IsSelect() const { return mGenericTypes & eSelect; } bool IsSelect() const { return HasGenericType(eSelect); }
bool IsTable() const { return mGenericTypes & eTable; } bool IsTable() const { return HasGenericType(eTable); }
virtual TableAccessible* AsTable() { return nullptr; } virtual TableAccessible* AsTable() { return nullptr; }
virtual TableCellAccessible* AsTableCell() { return nullptr; } virtual TableCellAccessible* AsTableCell() { return nullptr; }
bool IsTableRow() const { return mGenericTypes & eTableRow; } bool IsTableRow() const { return HasGenericType(eTableRow); }
bool IsTextLeaf() const { return mType == eTextLeafType; } bool IsTextLeaf() const { return mType == eTextLeafType; }
TextLeafAccessible* AsTextLeaf(); TextLeafAccessible* AsTextLeaf();
@ -524,6 +525,11 @@ public:
bool IsXULTree() const { return mType == eXULTreeType; } bool IsXULTree() const { return mType == eXULTreeType; }
XULTreeAccessible* AsXULTree(); XULTreeAccessible* AsXULTree();
/**
* Return true if the accessible belongs to the given accessible type.
*/
bool HasGenericType(AccGenericType aType) const;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// ActionAccessible // ActionAccessible

View File

@ -5,6 +5,7 @@
#include "OuterDocAccessible.h" #include "OuterDocAccessible.h"
#include "Accessible-inl.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"
#include "DocAccessible.h" #include "DocAccessible.h"
#include "Role.h" #include "Role.h"

View File

@ -7,6 +7,7 @@
#import "mozHTMLAccessible.h" #import "mozHTMLAccessible.h"
#import "Accessible-inl.h"
#import "HyperTextAccessible.h" #import "HyperTextAccessible.h"
#import "nsCocoaUtils.h" #import "nsCocoaUtils.h"

View File

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Accessible-inl.h"
#include "AccessibleWrap.h" #include "AccessibleWrap.h"
#include "TextLeafAccessible.h" #include "TextLeafAccessible.h"

View File

@ -5,6 +5,7 @@
#include "XULAlertAccessible.h" #include "XULAlertAccessible.h"
#include "Accessible-inl.h"
#include "Role.h" #include "Role.h"
#include "States.h" #include "States.h"

View File

@ -6,6 +6,7 @@
#include "XULTreeAccessible.h" #include "XULTreeAccessible.h"
#include "Accessible-inl.h"
#include "DocAccessible-inl.h" #include "DocAccessible-inl.h"
#include "nsAccCache.h" #include "nsAccCache.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"