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