Skip to content

Commit

Permalink
merge mozilla-inbound to mozilla-central a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
BavarianTomcat committed Jul 22, 2016
2 parents 53b9562 + 8c4c732 commit 336105a
Show file tree
Hide file tree
Showing 329 changed files with 5,870 additions and 2,609 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ devtools/client/shared/developer-toolbar.js
devtools/client/shared/components/test/**
devtools/client/shared/redux/middleware/test/**
devtools/client/shared/test/**
!devtools/client/shared/test/test-actor-registry.js
devtools/client/shared/widgets/*.jsm
devtools/client/sourceeditor/**
devtools/client/webaudioeditor/**
Expand Down
2 changes: 1 addition & 1 deletion CLOBBER
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.

Bug 911216 - clobber needed
Bug 1287946 - clobber due to generated SDK headers changing (bug 1182840)
44 changes: 40 additions & 4 deletions accessible/base/ARIAMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,18 @@ struct RoleComparator

const nsRoleMapEntry*
aria::GetRoleMap(dom::Element* aEl)
{
return GetRoleMapFromIndex(GetRoleMapIndex(aEl));
}

uint8_t
aria::GetRoleMapIndex(dom::Element* aEl)
{
nsAutoString roles;
if (!aEl || !aEl->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roles) ||
roles.IsEmpty()) {
// We treat role="" as if the role attribute is absent (per aria spec:8.1.1)
return nullptr;
return NO_ROLE_MAP_ENTRY_INDEX;
}

nsWhitespaceTokenizer tokenizer(roles);
Expand All @@ -878,13 +884,43 @@ aria::GetRoleMap(dom::Element* aEl)
size_t idx;
if (BinarySearchIf(sWAIRoleMaps, 0, ArrayLength(sWAIRoleMaps),
RoleComparator(role), &idx)) {
return sWAIRoleMaps + idx;
return idx;
}
}

// Always use some entry if there is a non-empty role string
// Always use some entry index if there is a non-empty role string
// To ensure an accessible object is created
return &sLandmarkRoleMap;
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
}


const nsRoleMapEntry*
aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex)
{
switch (aRoleMapIndex) {
case NO_ROLE_MAP_ENTRY_INDEX:
return nullptr;
case EMPTY_ROLE_MAP_ENTRY_INDEX:
return &gEmptyRoleMap;
case LANDMARK_ROLE_MAP_ENTRY_INDEX:
return &sLandmarkRoleMap;
default:
return sWAIRoleMaps + aRoleMapIndex;
}
}

uint8_t
aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry)
{
if (aRoleMapEntry == nullptr) {
return NO_ROLE_MAP_ENTRY_INDEX;
} else if (aRoleMapEntry == &gEmptyRoleMap) {
return EMPTY_ROLE_MAP_ENTRY_INDEX;
} else if (aRoleMapEntry == &sLandmarkRoleMap) {
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
} else {
return aRoleMapEntry - sWAIRoleMaps;
}
}

uint64_t
Expand Down
43 changes: 42 additions & 1 deletion accessible/base/ARIAMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,57 @@ namespace aria {
*/
extern nsRoleMapEntry gEmptyRoleMap;

/**
* Constants for the role map entry index to indicate that the role map entry
* isn't in sWAIRoleMaps, but rather is a special entry: nullptr,
* gEmptyRoleMap, and sLandmarkRoleMap
*/
const uint8_t NO_ROLE_MAP_ENTRY_INDEX = UINT8_MAX - 2;
const uint8_t EMPTY_ROLE_MAP_ENTRY_INDEX = UINT8_MAX - 1;
const uint8_t LANDMARK_ROLE_MAP_ENTRY_INDEX = UINT8_MAX;

/**
* Get the role map entry for a given DOM node. This will use the first
* ARIA role if the role attribute provides a space delimited list of roles.
*
* @param aNode [in] the DOM node to get the role map entry for
* @param aEl [in] the DOM node to get the role map entry for
* @return a pointer to the role map entry for the ARIA role, or nullptr
* if none
*/
const nsRoleMapEntry* GetRoleMap(dom::Element* aEl);

/**
* Get the role map entry pointer's index for a given DOM node. This will use
* the first ARIA role if the role attribute provides a space delimited list of
* roles.
*
* @param aEl [in] the DOM node to get the role map entry for
* @return the index of the pointer to the role map entry for the ARIA
* role, or NO_ROLE_MAP_ENTRY_INDEX if none
*/
uint8_t GetRoleMapIndex(dom::Element* aEl);

/**
* Get the role map entry pointer for a given role map entry index.
*
* @param aRoleMapIndex [in] the role map index to get the role map entry
* pointer for
* @return a pointer to the role map entry for the ARIA role,
* or nullptr, if none
*/
const nsRoleMapEntry* GetRoleMapFromIndex(uint8_t aRoleMapIndex);

/**
* Get the role map entry index for a given role map entry pointer. If the role
* map entry is within sWAIRoleMaps, return the index within that array,
* otherwise return one of the special index constants listed above.
*
* @param aRoleMap [in] the role map entry pointer to get the index for
* @return the index of the pointer to the role map entry, or
* NO_ROLE_MAP_ENTRY_INDEX if none
*/
uint8_t GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMap);

/**
* Return accessible state from ARIA universal states applied to the given
* element.
Expand Down
43 changes: 34 additions & 9 deletions accessible/generic/Accessible-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,60 @@ namespace a11y {
inline mozilla::a11y::role
Accessible::Role()
{
if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole)
return ARIATransformRole(NativeRole());

return ARIATransformRole(mRoleMapEntry->role);
return ARIATransformRole(roleMapEntry->role);
}

inline bool
Accessible::HasARIARole() const
{
return mRoleMapEntryIndex != aria::NO_ROLE_MAP_ENTRY_INDEX;
}

inline bool
Accessible::IsARIARole(nsIAtom* aARIARole) const
{
return mRoleMapEntry && mRoleMapEntry->Is(aARIARole);
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return roleMapEntry && roleMapEntry->Is(aARIARole);
}

inline bool
Accessible::HasStrongARIARole() const
{
return mRoleMapEntry && mRoleMapEntry->roleRule == kUseMapRole;
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()
{
if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole)
return mozilla::a11y::roles::NOTHING;

return ARIATransformRole(mRoleMapEntry->role);
return ARIATransformRole(roleMapEntry->role);
}

inline void
Accessible::SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry)
{
mRoleMapEntryIndex = aria::GetIndexFromRoleMap(aRoleMapEntry);
}

inline bool
Accessible::IsSearchbox() const
{
return (mRoleMapEntry && mRoleMapEntry->Is(nsGkAtoms::searchbox)) ||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return (roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) ||
(mContent->IsHTMLElement(nsGkAtoms::input) &&
mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::textInputType, eCaseMatters));
Expand All @@ -60,8 +83,9 @@ Accessible::IsSearchbox() const
inline bool
Accessible::HasGenericType(AccGenericType aType) const
{
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return (mGenericTypes & aType) ||
(mRoleMapEntry && mRoleMapEntry->IsOfType(aType));
(roleMapEntry && roleMapEntry->IsOfType(aType));
}

inline bool
Expand All @@ -70,7 +94,8 @@ Accessible::HasNumericValue() const
if (mStateFlags & eHasNumericValue)
return true;

return mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue;
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
return roleMapEntry && roleMapEntry->valueRule != eNoValue;
}

inline void
Expand Down
Loading

0 comments on commit 336105a

Please sign in to comment.