bug 1285272 - Change Accessible's role map entry variable from a raw pointer to an index. r=yzen
MozReview-Commit-ID: 2diXMOohyk
--- a/accessible/generic/Accessible-inl.h
+++ b/accessible/generic/Accessible-inl.h
@@ -24,39 +24,57 @@ Accessible::Role()
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole)
return ARIATransformRole(NativeRole());
return ARIATransformRole(roleMapEntry->role);
}
inline bool
+Accessible::HasARIARole() const
+{
+ return mRoleMapEntryIndex != aria::NO_ROLE_MAP_ENTRY_INDEX;
+}
+
+inline bool
Accessible::IsARIARole(nsIAtom* aARIARole) const
{
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return roleMapEntry && roleMapEntry->Is(aARIARole);
}
inline bool
Accessible::HasStrongARIARole() const
{
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return roleMapEntry && roleMapEntry->roleRule == kUseMapRole;
}
+inline const nsRoleMapEntry*
+Accessible::ARIARoleMap() const
+{
+ return aria::GetRoleMapFromIndex(mRoleMapEntryIndex);
+}
+
inline mozilla::a11y::role
Accessible::ARIARole()
{
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole)
return mozilla::a11y::roles::NOTHING;
return ARIATransformRole(roleMapEntry->role);
}
+inline void
+Accessible::SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry)
+{
+ mRoleMapEntryIndex = aria::GetIndexFromRoleMap(aRoleMapEntry);
+}
+
inline bool
Accessible::IsSearchbox() const
{
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return (roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) ||
(mContent->IsHTMLElement(nsGkAtoms::input) &&
mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::textInputType, eCaseMatters));
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -103,18 +103,18 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(Accessible)
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(Accessible, LastRelease())
Accessible::Accessible(nsIContent* aContent, DocAccessible* aDoc) :
mContent(aContent), mDoc(aDoc),
mParent(nullptr), mIndexInParent(-1),
- mStateFlags(0), mContextFlags(0), mType(0), mGenericTypes(0),
- mRoleMapEntry(nullptr)
+ mRoleMapEntryIndex(aria::NO_ROLE_MAP_ENTRY_INDEX),
+ mStateFlags(0), mContextFlags(0), mType(0), mGenericTypes(0)
{
mBits.groupInfo = nullptr;
mInt.mIndexOfEmbeddedChild = -1;
}
Accessible::~Accessible()
{
NS_ASSERTION(!mDoc, "LastRelease was never called!?!");
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -225,24 +225,24 @@ public:
/**
* Return enumerated accessible role (see constants in Role.h).
*/
mozilla::a11y::role Role();
/**
* Return true if ARIA role is specified on the element.
*/
- bool HasARIARole() const { return mRoleMapEntry; }
+ bool HasARIARole() const;
bool IsARIARole(nsIAtom* aARIARole) const;
bool HasStrongARIARole() const;
/**
* Retrun ARIA role map if any.
*/
- const nsRoleMapEntry* ARIARoleMap() const { return mRoleMapEntry; }
+ const nsRoleMapEntry* ARIARoleMap() const;
/**
* Return accessible role specified by ARIA (see constants in
* roles).
*/
mozilla::a11y::role ARIARole();
/**
@@ -378,18 +378,17 @@ public:
/**
* Shutdown this accessible object.
*/
virtual void Shutdown();
/**
* Set the ARIA role map entry for a new accessible.
*/
- void SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry)
- { mRoleMapEntry = aRoleMapEntry; }
+ void SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry);
/**
* Append/insert/remove a child. Return true if operation was successful.
*/
bool AppendChild(Accessible* aChild)
{ return InsertChildAt(mChildren.Length(), aChild); }
virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild);
@@ -1115,16 +1114,22 @@ protected:
int32_t mIndexInParent;
static const uint8_t kStateFlagsBits = 13;
static const uint8_t kContextFlagsBits = 3;
static const uint8_t kTypeBits = 6;
static const uint8_t kGenericTypesBits = 16;
/**
+ * Non-NO_ROLE_MAP_ENTRY_INDEX indicates author-supplied role;
+ * possibly state & value as well
+ */
+ uint8_t mRoleMapEntryIndex;
+
+ /**
* Keep in sync with StateFlags, ContextFlags, and AccTypes.
*/
uint32_t mStateFlags : kStateFlagsBits;
uint32_t mContextFlags : kContextFlagsBits;
uint32_t mType : kTypeBits;
uint32_t mGenericTypes : kGenericTypesBits;
void StaticAsserts() const;
@@ -1149,21 +1154,16 @@ protected:
union
{
AccGroupInfo* groupInfo;
ProxyAccessible* proxy;
} mBits;
friend class AccGroupInfo;
- /**
- * Non-null indicates author-supplied role; possibly state & value as well
- */
- const nsRoleMapEntry* mRoleMapEntry;
-
private:
Accessible() = delete;
Accessible(const Accessible&) = delete;
Accessible& operator =(const Accessible&) = delete;
};
NS_DEFINE_STATIC_IID_ACCESSOR(Accessible,