mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 864646 - get rid nsARIAMap struct, r=tbsaunde
--HG-- rename : accessible/src/base/nsARIAMap.cpp => accessible/src/base/ARIAMap.cpp rename : accessible/src/base/nsARIAMap.h => accessible/src/base/ARIAMap.h
This commit is contained in:
parent
f760939bec
commit
78558d84e7
@ -5,7 +5,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 "nsARIAMap.h"
|
||||
#include "ARIAMap.h"
|
||||
|
||||
#include "Accessible.h"
|
||||
#include "nsAccUtils.h"
|
||||
@ -634,7 +634,7 @@ static nsRoleMapEntry sLandmarkRoleMap = {
|
||||
kNoReqStates
|
||||
};
|
||||
|
||||
nsRoleMapEntry nsARIAMap::gEmptyRoleMap = {
|
||||
nsRoleMapEntry aria::gEmptyRoleMap = {
|
||||
&nsGkAtoms::_empty,
|
||||
roles::NOTHING,
|
||||
kUseMapRole,
|
||||
@ -662,11 +662,17 @@ static const EStateRule sWAIUnivStateMap[] = {
|
||||
|
||||
|
||||
/**
|
||||
* ARIA attribute map for attribute characteristics
|
||||
*
|
||||
* @note ARIA attributes that don't have any flags are not included here
|
||||
* ARIA attribute map for attribute characteristics.
|
||||
* @note ARIA attributes that don't have any flags are not included here.
|
||||
*/
|
||||
nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
|
||||
|
||||
struct AttrCharacteristics
|
||||
{
|
||||
nsIAtom** attributeName;
|
||||
const uint8_t characteristics;
|
||||
};
|
||||
|
||||
static const AttrCharacteristics gWAIUnivAttrMap[] = {
|
||||
{&nsGkAtoms::aria_activedescendant, ATTR_BYPASSOBJ },
|
||||
{&nsGkAtoms::aria_atomic, ATTR_VALTOKEN | ATTR_GLOBAL },
|
||||
{&nsGkAtoms::aria_busy, ATTR_VALTOKEN | ATTR_GLOBAL },
|
||||
@ -703,9 +709,6 @@ nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
|
||||
{&nsGkAtoms::aria_valuetext, ATTR_BYPASSOBJ }
|
||||
};
|
||||
|
||||
uint32_t
|
||||
nsARIAMap::gWAIUnivAttrMapLength = NS_ARRAY_LENGTH(nsARIAMap::gWAIUnivAttrMap);
|
||||
|
||||
nsRoleMapEntry*
|
||||
aria::GetRoleMap(nsINode* aNode)
|
||||
{
|
||||
@ -753,6 +756,16 @@ aria::UniversalStatesFor(mozilla::dom::Element* aElement)
|
||||
return state;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
aria::AttrCharacteristicsFor(nsIAtom* aAtom)
|
||||
{
|
||||
for (uint32_t i = 0; i < ArrayLength(gWAIUnivAttrMap); i++)
|
||||
if (*gWAIUnivAttrMap[i].attributeName == aAtom)
|
||||
return gWAIUnivAttrMap[i].characteristics;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// AttrIterator class
|
||||
|
||||
@ -768,7 +781,7 @@ AttrIterator::Next(nsAString& aAttrName, nsAString& aAttrValue)
|
||||
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
|
||||
continue; // Not ARIA
|
||||
|
||||
uint8_t attrFlags = nsAccUtils::GetAttributeCharacteristics(attrAtom);
|
||||
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
|
||||
if (attrFlags & ATTR_BYPASSOBJ)
|
||||
continue; // No need to handle exposing as obj attribute here
|
||||
|
@ -5,8 +5,8 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef _nsARIAMap_H_
|
||||
#define _nsARIAMap_H_
|
||||
#ifndef mozilla_a11y_aria_ARIAMap_h_
|
||||
#define mozilla_a11y_aria_ARIAMap_h_
|
||||
|
||||
#include "ARIAStateMap.h"
|
||||
#include "mozilla/a11y/AccTypes.h"
|
||||
@ -112,16 +112,6 @@ const uint8_t ATTR_VALTOKEN = 0x1 << 2;
|
||||
*/
|
||||
const uint8_t ATTR_GLOBAL = 0x1 << 3;
|
||||
|
||||
/**
|
||||
* Small footprint storage of persistent aria attribute characteristics.
|
||||
*/
|
||||
struct nsAttributeCharacteristics
|
||||
{
|
||||
nsIAtom** attributeName;
|
||||
const uint8_t characteristics;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// State map entry
|
||||
|
||||
@ -131,12 +121,6 @@ struct nsAttributeCharacteristics
|
||||
*/
|
||||
#define kNoReqStates 0
|
||||
|
||||
enum EDefaultStateRule
|
||||
{
|
||||
//eNoDefaultState,
|
||||
eUseFirstState
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Role map entry
|
||||
|
||||
@ -203,30 +187,20 @@ struct nsRoleMapEntry
|
||||
// ARIA map
|
||||
|
||||
/**
|
||||
* These are currently initialized (hardcoded) in nsARIAMap.cpp,
|
||||
* and provide the mappings for WAI-ARIA roles and properties using the
|
||||
* structs defined in this file.
|
||||
* These provide the mappings for WAI-ARIA roles, states and properties using
|
||||
* the structs defined in this file and ARIAStateMap files.
|
||||
*/
|
||||
struct nsARIAMap
|
||||
{
|
||||
/**
|
||||
* Empty role map entry. Used by accessibility service to create an accessible
|
||||
* if the accessible can't use role of used accessible class. For example,
|
||||
* it is used for table cells that aren't contained by table.
|
||||
*/
|
||||
static nsRoleMapEntry gEmptyRoleMap;
|
||||
|
||||
/**
|
||||
* Map of attribute to attribute characteristics.
|
||||
*/
|
||||
static nsAttributeCharacteristics gWAIUnivAttrMap[];
|
||||
static uint32_t gWAIUnivAttrMapLength;
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
namespace aria {
|
||||
|
||||
/**
|
||||
* Empty role map entry. Used by accessibility service to create an accessible
|
||||
* if the accessible can't use role of used accessible class. For example,
|
||||
* it is used for table cells that aren't contained by table.
|
||||
*/
|
||||
extern nsRoleMapEntry gEmptyRoleMap;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -243,6 +217,15 @@ nsRoleMapEntry* GetRoleMap(nsINode* aNode);
|
||||
*/
|
||||
uint64_t UniversalStatesFor(mozilla::dom::Element* aElement);
|
||||
|
||||
/**
|
||||
* Get the ARIA attribute characteristics for a given ARIA attribute.
|
||||
*
|
||||
* @param aAtom ARIA attribute
|
||||
* @return A bitflag representing the attribute characteristics
|
||||
* (see above for possible bit masks, prefixed "ATTR_")
|
||||
*/
|
||||
uint8_t AttrCharacteristicsFor(nsIAtom* aAtom);
|
||||
|
||||
/**
|
||||
* Represents a simple enumerator for iterating through ARIA attributes
|
||||
* exposed as object attributes on a given accessible.
|
@ -4,9 +4,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 "ARIAStateMap.h"
|
||||
|
||||
#include "nsARIAMap.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "States.h"
|
||||
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
#include "ApplicationAccessible.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "DocAccessible-inl.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "RootAccessibleWrap.h"
|
||||
#include "States.h"
|
||||
|
||||
|
@ -19,13 +19,13 @@ CPPSRCS = \
|
||||
AccGroupInfo.cpp \
|
||||
AccIterator.cpp \
|
||||
Filters.cpp \
|
||||
ARIAMap.cpp \
|
||||
ARIAStateMap.cpp \
|
||||
DocManager.cpp \
|
||||
EventQueue.cpp \
|
||||
FocusManager.cpp \
|
||||
NotificationController.cpp \
|
||||
nsAccessNode.cpp \
|
||||
nsARIAMap.cpp \
|
||||
nsCoreUtils.cpp \
|
||||
nsAccUtils.cpp \
|
||||
nsAccessibilityService.cpp \
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include "nsAccUtils.h"
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "nsCoreUtils.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "HyperTextAccessible.h"
|
||||
@ -369,16 +369,6 @@ nsAccUtils::GetScreenCoordsForParent(Accessible* aAccessible)
|
||||
ToNearestPixels(parentFrame->PresContext()->AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
uint8_t
|
||||
nsAccUtils::GetAttributeCharacteristics(nsIAtom* aAtom)
|
||||
{
|
||||
for (uint32_t i = 0; i < nsARIAMap::gWAIUnivAttrMapLength; i++)
|
||||
if (*nsARIAMap::gWAIUnivAttrMap[i].attributeName == aAtom)
|
||||
return nsARIAMap::gWAIUnivAttrMap[i].characteristics;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue)
|
||||
{
|
||||
|
@ -191,15 +191,6 @@ public:
|
||||
*/
|
||||
static nsIntPoint GetScreenCoordsForParent(Accessible* aAccessible);
|
||||
|
||||
/**
|
||||
* Get the ARIA attribute characteristics for a given ARIA attribute.
|
||||
*
|
||||
* @param aAtom ARIA attribute
|
||||
* @return A bitflag representing the attribute characteristics
|
||||
* (see nsARIAMap.h for possible bit masks, prefixed "ARIA_")
|
||||
*/
|
||||
static uint8_t GetAttributeCharacteristics(nsIAtom* aAtom);
|
||||
|
||||
/**
|
||||
* Get the 'live' or 'container-live' object attribute value from the given
|
||||
* ELiveAttrRule constant.
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Accessible-inl.h"
|
||||
#include "ApplicationAccessibleWrap.h"
|
||||
#include "ARIAGridAccessibleWrap.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "DocAccessible-inl.h"
|
||||
#include "FocusManager.h"
|
||||
#include "HTMLCanvasAccessible.h"
|
||||
@ -21,7 +22,6 @@
|
||||
#include "HyperTextAccessibleWrap.h"
|
||||
#include "nsAccessiblePivot.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "nsEventShell.h"
|
||||
#include "nsIAccessibleProvider.h"
|
||||
#include "OuterDocAccessible.h"
|
||||
@ -107,7 +107,7 @@ MustBeAccessible(nsIContent* aContent, DocAccessible* aDocument)
|
||||
continue; // not ARIA
|
||||
|
||||
// A global state or a property and in case of token defined.
|
||||
uint8_t attrFlags = nsAccUtils::GetAttributeCharacteristics(attrAtom);
|
||||
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
|
||||
if ((attrFlags & ATTR_GLOBAL) && (!(attrFlags & ATTR_VALTOKEN) ||
|
||||
nsAccUtils::HasDefinedARIAToken(aContent, attrAtom))) {
|
||||
return true;
|
||||
@ -943,11 +943,11 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
if (frame->AccessibleType() == eHTMLTableRowType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (contextRoleMap && !(contextRoleMap->IsOfType(eTable)))
|
||||
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
|
||||
} else if (frame->AccessibleType() == eHTMLTableCellType &&
|
||||
aContext->ARIARoleMap() == &nsARIAMap::gEmptyRoleMap) {
|
||||
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
|
||||
aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
|
||||
} else if (content->Tag() == nsGkAtoms::dt ||
|
||||
content->Tag() == nsGkAtoms::li ||
|
||||
@ -955,7 +955,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
frame->AccessibleType() == eHTMLLiType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (contextRoleMap && !(contextRoleMap->IsOfType(eList)))
|
||||
roleMapEntry = &nsARIAMap::gEmptyRoleMap;
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define mozilla_a11y_Accessible_inl_h_
|
||||
|
||||
#include "Accessible.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "ARIAMap.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
@ -1508,9 +1508,9 @@ Accessible::State()
|
||||
const uint32_t kExpandCollapseStates = states::COLLAPSED | states::EXPANDED;
|
||||
if ((state & kExpandCollapseStates) == kExpandCollapseStates) {
|
||||
// Cannot be both expanded and collapsed -- this happens in ARIA expanded
|
||||
// combobox because of limitation of nsARIAMap.
|
||||
// combobox because of limitation of ARIAMap.
|
||||
// XXX: Perhaps we will be able to make this less hacky if we support
|
||||
// extended states in nsARIAMap, e.g. derive COLLAPSED from
|
||||
// extended states in ARIAMap, e.g. derive COLLAPSED from
|
||||
// EXPANDABLE && !EXPANDED.
|
||||
state &= ~states::COLLAPSED;
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Return the action rule based on ARIA enum constants EActionRule
|
||||
* (see nsARIAMap.h). Used by ActionCount() and GetActionName().
|
||||
* (see ARIAMap.h). Used by ActionCount() and GetActionName().
|
||||
*/
|
||||
uint32_t GetActionRule();
|
||||
|
||||
|
@ -1061,7 +1061,7 @@ DocAccessible::ARIAAttributeChanged(Accessible* aAccessible, nsIAtom* aAttribute
|
||||
|
||||
// For aria attributes like drag and drop changes we fire a generic attribute
|
||||
// change event; at least until native API comes up with a more meaningful event.
|
||||
uint8_t attrFlags = nsAccUtils::GetAttributeCharacteristics(aAttribute);
|
||||
uint8_t attrFlags = aria::AttrCharacteristicsFor(aAttribute);
|
||||
if (!(attrFlags & ATTR_BYPASSOBJ))
|
||||
FireDelayedEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
|
||||
aAccessible);
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "Accessible-inl.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "nsEventShell.h"
|
||||
#include "nsTextEquivUtils.h"
|
||||
#include "Relation.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
#include "HTMLImageMapAccessible.h"
|
||||
|
||||
#include "ARIAMap.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsARIAMap.h"
|
||||
#include "DocAccessible-inl.h"
|
||||
#include "Role.h"
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "uiaRawElmProvider.h"
|
||||
|
||||
#include "AccessibleWrap.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
#include "nsARIAMap.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
Loading…
Reference in New Issue
Block a user