2007-06-05 08:41:07 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=2:tabstop=2:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2007-06-05 08:41:07 -07:00
|
|
|
|
2013-04-24 20:48:26 -07:00
|
|
|
#ifndef mozilla_a11y_aria_ARIAMap_h_
|
|
|
|
#define mozilla_a11y_aria_ARIAMap_h_
|
2007-06-05 08:41:07 -07:00
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
#include "ARIAStateMap.h"
|
2012-12-20 19:16:44 -08:00
|
|
|
#include "mozilla/a11y/AccTypes.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "mozilla/a11y/Role.h"
|
2007-09-24 18:19:03 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
#include "nsIAtom.h"
|
2012-08-10 13:10:18 -07:00
|
|
|
#include "nsIContent.h"
|
2012-06-10 16:44:50 -07:00
|
|
|
|
2012-04-16 02:24:23 -07:00
|
|
|
class nsINode;
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Value constants
|
|
|
|
|
|
|
|
/**
|
2014-10-21 17:49:28 -07:00
|
|
|
* Used to define if role requires to expose Value interface.
|
2009-06-24 19:12:38 -07:00
|
|
|
*/
|
2007-06-05 08:41:07 -07:00
|
|
|
enum EValueRule
|
|
|
|
{
|
2009-06-24 19:12:38 -07:00
|
|
|
/**
|
2014-10-21 17:49:28 -07:00
|
|
|
* Value interface isn't exposed.
|
2009-06-24 19:12:38 -07:00
|
|
|
*/
|
2007-06-05 08:41:07 -07:00
|
|
|
eNoValue,
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
/**
|
2014-10-21 17:49:28 -07:00
|
|
|
* Value interface is implemented, supports value, min and max from
|
2009-06-24 19:12:38 -07:00
|
|
|
* aria-valuenow, aria-valuemin and aria-valuemax.
|
|
|
|
*/
|
|
|
|
eHasValueMinMax
|
2007-06-05 08:41:07 -07:00
|
|
|
};
|
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Action constants
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to define if the role requires to expose action.
|
|
|
|
*/
|
2008-10-08 05:54:58 -07:00
|
|
|
enum EActionRule
|
|
|
|
{
|
|
|
|
eNoAction,
|
|
|
|
eActivateAction,
|
|
|
|
eClickAction,
|
2012-02-01 17:13:09 -08:00
|
|
|
ePressAction,
|
2008-10-08 05:54:58 -07:00
|
|
|
eCheckUncheckAction,
|
2009-04-19 23:06:19 -07:00
|
|
|
eExpandAction,
|
2008-10-08 05:54:58 -07:00
|
|
|
eJumpAction,
|
|
|
|
eOpenCloseAction,
|
|
|
|
eSelectAction,
|
2009-04-19 23:06:19 -07:00
|
|
|
eSortAction,
|
2008-10-08 05:54:58 -07:00
|
|
|
eSwitchAction
|
|
|
|
};
|
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Live region constants
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to define if role exposes default value of aria-live attribute.
|
|
|
|
*/
|
2009-02-18 22:56:19 -08:00
|
|
|
enum ELiveAttrRule
|
|
|
|
{
|
|
|
|
eNoLiveAttr,
|
|
|
|
eOffLiveAttr,
|
|
|
|
ePoliteLiveAttr
|
|
|
|
};
|
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Role constants
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ARIA role overrides role from native markup.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
const bool kUseMapRole = true;
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ARIA role doesn't override the role from native markup.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
const bool kUseNativeRole = false;
|
2009-06-11 11:18:24 -07:00
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ARIA attribute characteristic masks
|
2009-02-15 00:15:31 -08:00
|
|
|
|
|
|
|
/**
|
2009-03-10 13:44:43 -07:00
|
|
|
* This mask indicates the attribute should not be exposed as an object
|
2012-10-19 00:15:23 -07:00
|
|
|
* attribute via the catch-all logic in Accessible::Attributes().
|
2009-03-10 13:44:43 -07:00
|
|
|
* This means it either isn't mean't to be exposed as an object attribute, or
|
|
|
|
* that it should, but is already handled in other code.
|
2009-02-15 00:15:31 -08:00
|
|
|
*/
|
2012-11-10 02:26:58 -08:00
|
|
|
const uint8_t ATTR_BYPASSOBJ = 0x1 << 0;
|
2013-02-10 16:54:14 -08:00
|
|
|
const uint8_t ATTR_BYPASSOBJ_IF_FALSE = 0x1 << 1;
|
2009-02-15 00:15:31 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This mask indicates the attribute is expected to have an NMTOKEN or bool value.
|
2012-10-19 00:15:23 -07:00
|
|
|
* (See for example usage in Accessible::Attributes())
|
2009-02-15 00:15:31 -08:00
|
|
|
*/
|
2013-02-10 16:54:14 -08:00
|
|
|
const uint8_t ATTR_VALTOKEN = 0x1 << 2;
|
2012-11-10 02:26:58 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate the attribute is global state or property (refer to
|
|
|
|
* http://www.w3.org/TR/wai-aria/states_and_properties#global_states).
|
|
|
|
*/
|
2013-02-10 16:54:14 -08:00
|
|
|
const uint8_t ATTR_GLOBAL = 0x1 << 3;
|
2009-02-15 00:15:31 -08:00
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// State map entry
|
2007-06-05 08:41:07 -07:00
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
/**
|
|
|
|
* Used in nsRoleMapEntry.state if no nsIAccessibleStates are automatic for
|
|
|
|
* a given role.
|
|
|
|
*/
|
2007-06-11 02:46:39 -07:00
|
|
|
#define kNoReqStates 0
|
2007-06-05 08:41:07 -07:00
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Role map entry
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For each ARIA role, this maps the nsIAccessible information.
|
|
|
|
*/
|
2007-06-05 08:41:07 -07:00
|
|
|
struct nsRoleMapEntry
|
|
|
|
{
|
2012-06-10 16:44:50 -07:00
|
|
|
/**
|
|
|
|
* Return true if matches to the given ARIA role.
|
|
|
|
*/
|
|
|
|
bool Is(nsIAtom* aARIARole) const
|
|
|
|
{ return *roleAtom == aARIARole; }
|
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
/**
|
|
|
|
* Return true if ARIA role has the given accessible type.
|
|
|
|
*/
|
|
|
|
bool IsOfType(mozilla::a11y::AccGenericType aType) const
|
|
|
|
{ return accTypes & aType; }
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
/**
|
|
|
|
* Return ARIA role.
|
|
|
|
*/
|
|
|
|
const nsDependentAtomString ARIARoleString() const
|
|
|
|
{ return nsDependentAtomString(*roleAtom); }
|
|
|
|
|
2007-06-05 08:41:07 -07:00
|
|
|
// ARIA role: string representation such as "button"
|
2012-06-10 16:44:50 -07:00
|
|
|
nsIAtom** roleAtom;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
// Role mapping rule: maps to enum Role
|
2012-01-11 19:07:35 -08:00
|
|
|
mozilla::a11y::role role;
|
2014-10-21 17:49:28 -07:00
|
|
|
|
2009-06-11 11:18:24 -07:00
|
|
|
// Role rule: whether to use mapped role or native semantics
|
2011-09-28 23:19:26 -07:00
|
|
|
bool roleRule;
|
2014-10-21 17:49:28 -07:00
|
|
|
|
|
|
|
// Value mapping rule: how to compute accessible value
|
2007-06-05 08:41:07 -07:00
|
|
|
EValueRule valueRule;
|
2008-10-08 05:54:58 -07:00
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
// Action mapping rule, how to expose accessible action
|
2008-10-08 05:54:58 -07:00
|
|
|
EActionRule actionRule;
|
|
|
|
|
2009-02-18 22:56:19 -08:00
|
|
|
// 'live' and 'container-live' object attributes mapping rule: how to expose
|
|
|
|
// these object attributes if ARIA 'live' attribute is missed.
|
|
|
|
ELiveAttrRule liveAttRule;
|
|
|
|
|
2012-11-10 18:16:17 -08:00
|
|
|
// Accessible types this role belongs to.
|
|
|
|
uint32_t accTypes;
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
// Automatic state mapping rule: always include in states
|
|
|
|
uint64_t state; // or kNoReqStates if no default state for this role
|
2012-04-05 09:23:30 -07:00
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
// ARIA properties supported for this role (in other words, the aria-foo
|
|
|
|
// attribute to accessible states mapping rules).
|
2007-06-05 08:41:07 -07:00
|
|
|
// Currently you cannot have unlimited mappings, because
|
|
|
|
// a variable sized array would not allow the use of
|
|
|
|
// C++'s struct initialization feature.
|
2012-04-05 09:23:30 -07:00
|
|
|
mozilla::a11y::aria::EStateRule attributeMap1;
|
|
|
|
mozilla::a11y::aria::EStateRule attributeMap2;
|
|
|
|
mozilla::a11y::aria::EStateRule attributeMap3;
|
2014-08-11 05:13:44 -07:00
|
|
|
mozilla::a11y::aria::EStateRule attributeMap4;
|
2007-06-05 08:41:07 -07:00
|
|
|
};
|
|
|
|
|
2009-06-24 19:12:38 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ARIA map
|
|
|
|
|
2007-06-05 08:41:07 -07:00
|
|
|
/**
|
2013-04-24 20:48:26 -07:00
|
|
|
* These provide the mappings for WAI-ARIA roles, states and properties using
|
|
|
|
* the structs defined in this file and ARIAStateMap files.
|
2007-06-05 08:41:07 -07:00
|
|
|
*/
|
2012-04-16 02:24:23 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
namespace aria {
|
|
|
|
|
2013-04-24 20:48:26 -07:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2012-04-16 02:24:23 -07:00
|
|
|
/**
|
|
|
|
* 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
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return a pointer to the role map entry for the ARIA role, or nullptr
|
2012-04-16 02:24:23 -07:00
|
|
|
* if none
|
|
|
|
*/
|
|
|
|
nsRoleMapEntry* GetRoleMap(nsINode* aNode);
|
|
|
|
|
2012-07-10 18:00:30 -07:00
|
|
|
/**
|
|
|
|
* Return accessible state from ARIA universal states applied to the given
|
|
|
|
* element.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t UniversalStatesFor(mozilla::dom::Element* aElement);
|
2012-07-10 18:00:30 -07:00
|
|
|
|
2013-04-24 20:48:26 -07:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2012-08-10 13:10:18 -07:00
|
|
|
/**
|
|
|
|
* Represents a simple enumerator for iterating through ARIA attributes
|
|
|
|
* exposed as object attributes on a given accessible.
|
|
|
|
*/
|
|
|
|
class AttrIterator
|
|
|
|
{
|
|
|
|
public:
|
2014-09-02 09:19:58 -07:00
|
|
|
explicit AttrIterator(nsIContent* aContent) :
|
2012-08-10 13:10:18 -07:00
|
|
|
mContent(aContent), mAttrIdx(0)
|
|
|
|
{
|
|
|
|
mAttrCount = mContent->GetAttrCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Next(nsAString& aAttrName, nsAString& aAttrValue);
|
|
|
|
|
|
|
|
private:
|
|
|
|
AttrIterator() MOZ_DELETE;
|
|
|
|
AttrIterator(const AttrIterator&) MOZ_DELETE;
|
|
|
|
AttrIterator& operator= (const AttrIterator&) MOZ_DELETE;
|
|
|
|
|
|
|
|
nsIContent* mContent;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mAttrIdx;
|
|
|
|
uint32_t mAttrCount;
|
2012-08-10 13:10:18 -07:00
|
|
|
};
|
|
|
|
|
2012-04-16 02:24:23 -07:00
|
|
|
} // namespace aria
|
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-06-05 08:41:07 -07:00
|
|
|
#endif
|