diff --git a/accessible/src/base/AccIterator.cpp b/accessible/src/base/AccIterator.cpp index 97daed43145e..f549c1491668 100644 --- a/accessible/src/base/AccIterator.cpp +++ b/accessible/src/base/AccIterator.cpp @@ -5,7 +5,7 @@ #include "AccIterator.h" #include "nsAccessibilityService.h" -#include "Accessible.h" +#include "Accessible-inl.h" #include "mozilla/dom/Element.h" #include "nsBindingManager.h" diff --git a/accessible/src/base/nsARIAMap.h b/accessible/src/base/nsARIAMap.h index 8f9e7048bcc0..7c9710eddbe2 100644 --- a/accessible/src/base/nsARIAMap.h +++ b/accessible/src/base/nsARIAMap.h @@ -9,6 +9,7 @@ #define _nsARIAMap_H_ #include "ARIAStateMap.h" +#include "mozilla/a11y/AccTypes.h" #include "mozilla/a11y/Role.h" #include "nsIAtom.h" @@ -149,6 +150,12 @@ struct nsRoleMapEntry bool Is(nsIAtom* aARIARole) const { 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. */ diff --git a/accessible/src/generic/Accessible-inl.h b/accessible/src/generic/Accessible-inl.h index 0d463feb6d1b..3ee8a84902e9 100644 --- a/accessible/src/generic/Accessible-inl.h +++ b/accessible/src/generic/Accessible-inl.h @@ -31,12 +31,11 @@ Accessible::ARIARole() return ARIATransformRole(mRoleMapEntry->role); } -inline void -Accessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry) +inline bool +Accessible::HasGenericType(AccGenericType aType) const { - mRoleMapEntry = aRoleMapEntry; - if (mRoleMapEntry) - mGenericTypes |= mRoleMapEntry->accTypes; + return (mGenericTypes & aType) || + (mRoleMapEntry && mRoleMapEntry->IsOfType(aType)); } inline bool diff --git a/accessible/src/generic/Accessible.h b/accessible/src/generic/Accessible.h index 3e94e64a1b5a..9eb2e62ab4f8 100644 --- a/accessible/src/generic/Accessible.h +++ b/accessible/src/generic/Accessible.h @@ -304,7 +304,8 @@ public: /** * Set the ARIA role map entry for a new accessible. */ - void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry); + void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry) + { mRoleMapEntry = aRoleMapEntry; } /** * Update the children cache. @@ -468,17 +469,17 @@ public: bool IsApplication() const { return mType == eApplicationType; } - bool IsAutoComplete() const { return mGenericTypes & eAutoComplete; } + bool IsAutoComplete() const { return HasGenericType(eAutoComplete); } 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(); - bool IsHyperText() const { return mGenericTypes & eHyperText; } + bool IsHyperText() const { return HasGenericType(eHyperText); } HyperTextAccessible* AsHyperText(); bool IsHTMLFileInput() const { return mType == eHTMLFileInputType; } @@ -494,11 +495,11 @@ public: bool IsImageMap() const { return mType == eImageMapType; } 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; } @@ -507,14 +508,14 @@ public: bool IsRoot() const { return mType == eRootType; } 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 TableCellAccessible* AsTableCell() { return nullptr; } - bool IsTableRow() const { return mGenericTypes & eTableRow; } + bool IsTableRow() const { return HasGenericType(eTableRow); } bool IsTextLeaf() const { return mType == eTextLeafType; } TextLeafAccessible* AsTextLeaf(); @@ -524,6 +525,11 @@ public: bool IsXULTree() const { return mType == eXULTreeType; } XULTreeAccessible* AsXULTree(); + /** + * Return true if the accessible belongs to the given accessible type. + */ + bool HasGenericType(AccGenericType aType) const; + ////////////////////////////////////////////////////////////////////////////// // ActionAccessible diff --git a/accessible/src/generic/OuterDocAccessible.cpp b/accessible/src/generic/OuterDocAccessible.cpp index d10496f0ec49..6ad340ffce50 100644 --- a/accessible/src/generic/OuterDocAccessible.cpp +++ b/accessible/src/generic/OuterDocAccessible.cpp @@ -5,6 +5,7 @@ #include "OuterDocAccessible.h" +#include "Accessible-inl.h" #include "nsAccUtils.h" #include "DocAccessible.h" #include "Role.h" diff --git a/accessible/src/mac/mozHTMLAccessible.mm b/accessible/src/mac/mozHTMLAccessible.mm index f9b88fbcf36f..c17231f45c5a 100644 --- a/accessible/src/mac/mozHTMLAccessible.mm +++ b/accessible/src/mac/mozHTMLAccessible.mm @@ -7,6 +7,7 @@ #import "mozHTMLAccessible.h" +#import "Accessible-inl.h" #import "HyperTextAccessible.h" #import "nsCocoaUtils.h" diff --git a/accessible/src/mac/mozTextAccessible.mm b/accessible/src/mac/mozTextAccessible.mm index 86da8028543d..f88c3490878a 100644 --- a/accessible/src/mac/mozTextAccessible.mm +++ b/accessible/src/mac/mozTextAccessible.mm @@ -3,7 +3,7 @@ * 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/. */ - +#include "Accessible-inl.h" #include "AccessibleWrap.h" #include "TextLeafAccessible.h" diff --git a/accessible/src/xul/XULAlertAccessible.cpp b/accessible/src/xul/XULAlertAccessible.cpp index 010c5c3e7127..bc555b3a11cb 100644 --- a/accessible/src/xul/XULAlertAccessible.cpp +++ b/accessible/src/xul/XULAlertAccessible.cpp @@ -5,6 +5,7 @@ #include "XULAlertAccessible.h" +#include "Accessible-inl.h" #include "Role.h" #include "States.h" diff --git a/accessible/src/xul/XULTreeAccessible.cpp b/accessible/src/xul/XULTreeAccessible.cpp index 10ab9b2597f9..61535a7acbd0 100644 --- a/accessible/src/xul/XULTreeAccessible.cpp +++ b/accessible/src/xul/XULTreeAccessible.cpp @@ -6,6 +6,7 @@ #include "XULTreeAccessible.h" +#include "Accessible-inl.h" #include "DocAccessible-inl.h" #include "nsAccCache.h" #include "nsAccUtils.h"