2007-11-11 17:05:37 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
#ifndef _Accessible_H_
|
|
|
|
#define _Accessible_H_
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "mozilla/a11y/Role.h"
|
2011-07-27 05:43:01 -07:00
|
|
|
#include "mozilla/a11y/States.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "nsAccessNodeWrap.h"
|
2007-05-19 19:41:33 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAccessible.h"
|
|
|
|
#include "nsIAccessibleHyperLink.h"
|
|
|
|
#include "nsIAccessibleSelectable.h"
|
|
|
|
#include "nsIAccessibleValue.h"
|
2007-05-19 19:41:33 -07:00
|
|
|
#include "nsIAccessibleStates.h"
|
2012-08-01 11:31:10 -07:00
|
|
|
#include "nsIContent.h"
|
2007-05-19 19:41:33 -07:00
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsStringGlue.h"
|
2009-01-18 12:14:14 -08:00
|
|
|
#include "nsTArray.h"
|
2010-06-21 06:08:27 -07:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2011-01-30 20:04:32 -08:00
|
|
|
class AccEvent;
|
2010-07-02 20:11:35 -07:00
|
|
|
class AccGroupInfo;
|
2011-07-19 01:30:24 -07:00
|
|
|
class KeyBinding;
|
2012-05-28 18:18:45 -07:00
|
|
|
class Accessible;
|
2012-05-31 01:04:41 -07:00
|
|
|
class HyperTextAccessible;
|
2012-04-13 07:17:03 -07:00
|
|
|
struct nsRoleMapEntry;
|
2012-04-30 20:08:31 -07:00
|
|
|
|
2012-03-27 17:53:58 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
2012-05-07 22:16:40 -07:00
|
|
|
|
2012-08-28 06:13:59 -07:00
|
|
|
class EmbeddedObjCollector;
|
2012-06-04 05:32:34 -07:00
|
|
|
class HTMLImageMapAccessible;
|
2012-05-07 22:16:40 -07:00
|
|
|
class HTMLLIAccessible;
|
2012-06-02 04:30:34 -07:00
|
|
|
class ImageAccessible;
|
2012-06-10 15:18:31 -07:00
|
|
|
class Relation;
|
2012-03-27 17:53:58 -07:00
|
|
|
class TableAccessible;
|
2012-08-08 23:24:31 -07:00
|
|
|
class TableCellAccessible;
|
2012-05-23 11:05:57 -07:00
|
|
|
class TextLeafAccessible;
|
2012-06-08 03:28:27 -07:00
|
|
|
class XULTreeAccessible;
|
2012-04-30 20:08:31 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Name type flags.
|
|
|
|
*/
|
|
|
|
enum ENameValueFlag {
|
|
|
|
/**
|
|
|
|
* Name either
|
|
|
|
* a) present (not empty): !name.IsEmpty()
|
|
|
|
* b) no name (was missed): name.IsVoid()
|
|
|
|
* c) was left empty by the author on demand: name.IsEmpty() && !name.IsVoid()
|
|
|
|
*/
|
|
|
|
eNameOK,
|
|
|
|
eNameFromTooltip // Tooltip was used as a name
|
|
|
|
};
|
|
|
|
|
2012-05-29 17:51:00 -07:00
|
|
|
/**
|
|
|
|
* Group position (level, position in set and set size).
|
|
|
|
*/
|
|
|
|
struct GroupPos
|
|
|
|
{
|
|
|
|
GroupPos() : level(0), posInSet(0), setSize(0) { }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t level;
|
|
|
|
int32_t posInSet;
|
|
|
|
int32_t setSize;
|
2012-05-29 17:51:00 -07:00
|
|
|
};
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
2012-05-23 11:05:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
struct nsRect;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIView;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
typedef nsRefPtrHashtable<nsPtrHashKey<const void>, Accessible>
|
|
|
|
AccessibleHashtable;
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
#define NS_ACCESSIBLE_IMPL_IID \
|
2010-01-18 20:23:44 -08:00
|
|
|
{ /* 133c8bf4-4913-4355-bd50-426bd1d6e1ad */ \
|
|
|
|
0x133c8bf4, \
|
|
|
|
0x4913, \
|
|
|
|
0x4355, \
|
|
|
|
{ 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad } \
|
2008-10-10 05:26:55 -07:00
|
|
|
}
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
class Accessible : public nsAccessNodeWrap,
|
|
|
|
public nsIAccessible,
|
2012-05-28 18:18:45 -07:00
|
|
|
public nsIAccessibleHyperLink,
|
|
|
|
public nsIAccessibleSelectable,
|
|
|
|
public nsIAccessibleValue
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible(nsIContent* aContent, DocAccessible* aDoc);
|
|
|
|
virtual ~Accessible();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Accessible, nsAccessNode)
|
2008-08-06 05:19:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIACCESSIBLE
|
|
|
|
NS_DECL_NSIACCESSIBLEHYPERLINK
|
|
|
|
NS_DECL_NSIACCESSIBLESELECTABLE
|
|
|
|
NS_DECL_NSIACCESSIBLEVALUE
|
2010-04-26 23:52:03 -07:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-31 20:58:07 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessNode
|
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
virtual void Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Public methods
|
|
|
|
|
2012-07-10 05:32:30 -07:00
|
|
|
/**
|
|
|
|
* Initialize the accessible.
|
|
|
|
*/
|
2012-07-27 06:53:02 -07:00
|
|
|
virtual void Init();
|
2012-07-10 05:32:30 -07:00
|
|
|
|
2011-04-23 06:14:05 -07:00
|
|
|
/**
|
2012-04-09 02:48:41 -07:00
|
|
|
* Get the description of this accessible.
|
2011-04-23 06:14:05 -07:00
|
|
|
*/
|
|
|
|
virtual void Description(nsString& aDescription);
|
|
|
|
|
2012-04-09 02:48:41 -07:00
|
|
|
/**
|
|
|
|
* Get the value of this accessible.
|
|
|
|
*/
|
|
|
|
virtual void Value(nsString& aValue);
|
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
/**
|
|
|
|
* Get the name of this accessible.
|
|
|
|
*/
|
|
|
|
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
|
|
|
|
|
2012-02-07 05:18:33 -08:00
|
|
|
/**
|
|
|
|
* Return DOM node associated with this accessible.
|
|
|
|
*/
|
|
|
|
inline already_AddRefed<nsIDOMNode> DOMNode() const
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIDOMNode *DOMNode = nullptr;
|
2012-02-07 05:18:33 -08:00
|
|
|
if (GetNode())
|
|
|
|
CallQueryInterface(GetNode(), &DOMNode);
|
|
|
|
return DOMNode;
|
|
|
|
}
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
/**
|
|
|
|
* Returns the accessible name specified by ARIA.
|
|
|
|
*/
|
|
|
|
nsresult GetARIAName(nsAString& aName);
|
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
/**
|
|
|
|
* Maps ARIA state attributes to state of accessible. Note the given state
|
|
|
|
* argument should hold states for accessible before you pass it into this
|
|
|
|
* method.
|
|
|
|
*
|
|
|
|
* @param [in/out] where to fill the states into.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void ApplyARIAState(uint64_t* aState) const;
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
/**
|
|
|
|
* Returns the accessible name provided by native markup. It doesn't take
|
2008-12-16 08:13:49 -08:00
|
|
|
* into account ARIA markup used to specify the name.
|
|
|
|
*
|
|
|
|
* @param aName [out] the accessible name
|
|
|
|
*
|
|
|
|
* @return NS_OK_EMPTY_NAME points empty name was specified by native markup
|
|
|
|
* explicitly (see nsIAccessible::name attribute for
|
|
|
|
* details)
|
2008-10-10 05:26:55 -07:00
|
|
|
*/
|
|
|
|
virtual nsresult GetNameInternal(nsAString& aName);
|
|
|
|
|
2010-09-05 20:33:29 -07:00
|
|
|
/**
|
2012-01-11 19:07:35 -08:00
|
|
|
* Return enumerated accessible role (see constants in Role.h).
|
2010-09-05 20:33:29 -07:00
|
|
|
*/
|
2012-04-13 07:17:03 -07:00
|
|
|
mozilla::a11y::role Role();
|
2010-12-01 00:53:17 -08:00
|
|
|
|
2012-01-20 07:22:31 -08:00
|
|
|
/**
|
|
|
|
* Return true if ARIA role is specified on the element.
|
|
|
|
*/
|
2012-04-13 07:17:03 -07:00
|
|
|
bool HasARIARole() const
|
|
|
|
{ return mRoleMapEntry; }
|
2012-01-20 07:22:31 -08:00
|
|
|
|
2010-12-01 00:53:17 -08:00
|
|
|
/**
|
|
|
|
* Return accessible role specified by ARIA (see constants in
|
2012-01-11 19:07:35 -08:00
|
|
|
* roles).
|
2010-12-01 00:53:17 -08:00
|
|
|
*/
|
2012-04-13 07:17:03 -07:00
|
|
|
mozilla::a11y::role ARIARole();
|
2010-09-05 20:33:29 -07:00
|
|
|
|
2009-03-07 07:38:58 -08:00
|
|
|
/**
|
|
|
|
* Returns enumerated accessible role from native markup (see constants in
|
2012-01-11 19:07:35 -08:00
|
|
|
* Role.h). Doesn't take into account ARIA roles.
|
2009-03-07 07:38:58 -08:00
|
|
|
*/
|
2012-01-11 19:07:35 -08:00
|
|
|
virtual mozilla::a11y::role NativeRole();
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2007-04-02 08:56:24 -07:00
|
|
|
/**
|
2011-04-09 16:38:06 -07:00
|
|
|
* Return all states of accessible (including ARIA states).
|
2007-04-02 08:56:24 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t State();
|
2011-04-09 16:38:06 -07:00
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
/**
|
|
|
|
* Return interactive states present on the accessible
|
|
|
|
* (@see NativeInteractiveState).
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t InteractiveState() const
|
2012-06-03 22:41:06 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = NativeInteractiveState();
|
2012-06-03 22:41:06 -07:00
|
|
|
ApplyARIAState(&state);
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2012-05-17 02:37:37 -07:00
|
|
|
/**
|
|
|
|
* Return link states present on the accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t LinkState() const
|
2012-05-17 02:37:37 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = NativeLinkState();
|
2012-05-17 02:37:37 -07:00
|
|
|
ApplyARIAState(&state);
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
/**
|
|
|
|
* Return the states of accessible, not taking into account ARIA states.
|
|
|
|
* Use State() to get complete set of states.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t NativeState();
|
2007-04-02 08:56:24 -07:00
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
/**
|
|
|
|
* Return native interactice state (unavailable, focusable or selectable).
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t NativeInteractiveState() const;
|
2012-06-03 22:41:06 -07:00
|
|
|
|
2012-05-17 02:37:37 -07:00
|
|
|
/**
|
|
|
|
* Return native link states present on the accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t NativeLinkState() const;
|
2012-05-17 02:37:37 -07:00
|
|
|
|
2012-03-07 19:28:38 -08:00
|
|
|
/**
|
|
|
|
* Return bit set of invisible and offscreen states.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t VisibilityState();
|
2012-03-07 19:28:38 -08:00
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
/**
|
|
|
|
* Return true if native unavailable state present.
|
|
|
|
*/
|
|
|
|
virtual bool NativelyUnavailable() const;
|
|
|
|
|
2007-04-07 02:07:24 -07:00
|
|
|
/**
|
|
|
|
* Returns attributes for accessible without explicitly setted ARIA
|
|
|
|
* attributes.
|
|
|
|
*/
|
|
|
|
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
|
|
|
|
|
2012-05-29 17:51:00 -07:00
|
|
|
/**
|
|
|
|
* Return group position (level, position in set and set size).
|
|
|
|
*/
|
|
|
|
virtual mozilla::a11y::GroupPos GroupPosition();
|
|
|
|
|
2011-03-28 21:44:20 -07:00
|
|
|
/**
|
2011-06-13 15:20:54 -07:00
|
|
|
* Used by ChildAtPoint() method to get direct or deepest child at point.
|
2011-03-28 21:44:20 -07:00
|
|
|
*/
|
|
|
|
enum EWhichChildAtPoint {
|
|
|
|
eDirectChild,
|
|
|
|
eDeepestChild
|
|
|
|
};
|
|
|
|
|
2009-05-11 03:57:28 -07:00
|
|
|
/**
|
|
|
|
* Return direct or deepest child at the given point.
|
|
|
|
*
|
2011-03-28 21:44:20 -07:00
|
|
|
* @param aX [in] x coordinate relative screen
|
|
|
|
* @param aY [in] y coordinate relative screen
|
|
|
|
* @param aWhichChild [in] flag points if deepest or direct child
|
|
|
|
* should be returned
|
2009-05-11 03:57:28 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
|
2012-05-28 18:18:45 -07:00
|
|
|
EWhichChildAtPoint aWhichChild);
|
2009-05-11 03:57:28 -07:00
|
|
|
|
2011-07-15 15:58:49 -07:00
|
|
|
/**
|
|
|
|
* Return the focused child if any.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* FocusedChild();
|
2011-07-15 15:58:49 -07:00
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
/**
|
|
|
|
* Return calculated group level based on accessible hierarchy.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetLevelInternal();
|
2010-01-06 02:36:50 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate position in group and group size ('posinset' and 'setsize') based
|
|
|
|
* on accessible hierarchy.
|
|
|
|
*
|
|
|
|
* @param aPosInSet [out] accessible position in the group
|
|
|
|
* @param aSetSize [out] the group size
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void GetPositionAndSizeInternal(int32_t *aPosInSet,
|
|
|
|
int32_t *aSetSize);
|
2010-01-06 02:36:50 -08:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
/**
|
|
|
|
* Get the relation of the given type.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual mozilla::a11y::Relation RelationByType(uint32_t aType);
|
2011-08-09 18:44:00 -07:00
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// Initializing methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the ARIA role map entry for a new accessible.
|
|
|
|
* For a newly created accessible, specify which role map entry should be used.
|
|
|
|
*
|
2012-06-08 03:28:27 -07:00
|
|
|
* @param aRoleMapEntry The ARIA nsRoleMapEntry* for the accessible, or
|
2012-07-30 07:20:58 -07:00
|
|
|
* nullptr if none.
|
2009-12-10 11:12:19 -08:00
|
|
|
*/
|
2012-04-16 02:24:23 -07:00
|
|
|
virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2011-01-26 19:38:50 -08:00
|
|
|
/**
|
|
|
|
* Update the children cache.
|
|
|
|
*/
|
|
|
|
inline bool UpdateChildren()
|
|
|
|
{
|
|
|
|
InvalidateChildren();
|
|
|
|
return EnsureChildren();
|
|
|
|
}
|
|
|
|
|
2010-04-07 23:43:08 -07:00
|
|
|
/**
|
|
|
|
* Cache children if necessary. Return true if the accessible is defunct.
|
|
|
|
*/
|
2011-01-27 20:38:02 -08:00
|
|
|
bool EnsureChildren();
|
2010-04-07 23:43:08 -07:00
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
/**
|
2009-12-10 11:12:19 -08:00
|
|
|
* Set the child count to -1 (unknown) and null out cached child pointers.
|
|
|
|
* Should be called when accessible tree is changed because document has
|
2010-07-01 18:22:41 -07:00
|
|
|
* transformed. Note, if accessible cares about its parent relation chain
|
|
|
|
* itself should override this method to do nothing.
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2009-12-10 11:12:19 -08:00
|
|
|
virtual void InvalidateChildren();
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
/**
|
2010-07-01 18:22:41 -07:00
|
|
|
* Append/insert/remove a child. Return true if operation was successful.
|
2010-06-08 09:39:58 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual bool AppendChild(Accessible* aChild);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild);
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual bool RemoveChild(Accessible* aChild);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Accessible tree traverse methods
|
2009-06-18 00:37:38 -07:00
|
|
|
|
|
|
|
/**
|
2009-12-10 11:12:19 -08:00
|
|
|
* Return parent accessible.
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* Parent() const { return mParent; }
|
2009-06-18 00:37:38 -07:00
|
|
|
|
|
|
|
/**
|
2009-12-10 11:12:19 -08:00
|
|
|
* Return child accessible at the given index.
|
2009-11-19 06:44:59 -08:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual Accessible* GetChildAt(uint32_t aIndex);
|
2009-11-19 06:44:59 -08:00
|
|
|
|
|
|
|
/**
|
2009-12-10 11:12:19 -08:00
|
|
|
* Return child accessible count.
|
2009-11-19 06:44:59 -08:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t ChildCount() const;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index of the given child accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetIndexOf(Accessible* aChild);
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index in parent accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t IndexInParent() const;
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2010-05-21 04:27:00 -07:00
|
|
|
/**
|
|
|
|
* Return true if accessible has children;
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasChildren() { return !!GetChildAt(0); }
|
2010-05-21 04:27:00 -07:00
|
|
|
|
2011-06-06 19:23:13 -07:00
|
|
|
/**
|
2011-07-23 01:38:33 -07:00
|
|
|
* Return first/last/next/previous sibling of the accessible.
|
2011-06-06 19:23:13 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
inline Accessible* NextSibling() const
|
2011-06-06 19:23:13 -07:00
|
|
|
{ return GetSiblingAtOffset(1); }
|
2012-05-28 18:18:45 -07:00
|
|
|
inline Accessible* PrevSibling() const
|
2011-06-06 19:23:13 -07:00
|
|
|
{ return GetSiblingAtOffset(-1); }
|
2012-05-28 18:18:45 -07:00
|
|
|
inline Accessible* FirstChild()
|
2012-05-25 03:53:45 -07:00
|
|
|
{ return GetChildAt(0); }
|
2012-05-28 18:18:45 -07:00
|
|
|
inline Accessible* LastChild()
|
2011-07-23 01:38:33 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = ChildCount();
|
2012-07-30 07:20:58 -07:00
|
|
|
return childCount != 0 ? GetChildAt(childCount - 1) : nullptr;
|
2011-07-23 01:38:33 -07:00
|
|
|
}
|
|
|
|
|
2011-06-06 19:23:13 -07:00
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
/**
|
|
|
|
* Return embedded accessible children count.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t EmbeddedChildCount();
|
2010-08-15 04:28:49 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return embedded accessible child at the given index.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
Accessible* GetEmbeddedChildAt(uint32_t aIndex);
|
2010-08-15 04:28:49 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index of the given embedded accessible child.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetIndexOfEmbeddedChild(Accessible* aChild);
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2011-06-06 19:24:01 -07:00
|
|
|
/**
|
|
|
|
* Return number of content children/content child at index. The content
|
|
|
|
* child is created from markup in contrast to it's never constructed by its
|
|
|
|
* parent accessible (like treeitem accessibles for XUL trees).
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t ContentChildCount() const { return mChildren.Length(); }
|
|
|
|
Accessible* ContentChildAt(uint32_t aIndex) const
|
2011-06-06 19:24:01 -07:00
|
|
|
{ return mChildren.ElementAt(aIndex); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if children were initialized.
|
|
|
|
*/
|
2011-01-27 21:15:04 -08:00
|
|
|
inline bool AreChildrenCached() const
|
|
|
|
{ return !IsChildrenFlag(eChildrenUninitialized); }
|
2011-06-06 19:24:01 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the accessible is attached to tree.
|
|
|
|
*/
|
2011-01-27 20:38:02 -08:00
|
|
|
bool IsBoundToParent() const { return !!mParent; }
|
2009-06-18 00:37:38 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// Miscellaneous methods
|
2009-06-18 00:37:38 -07:00
|
|
|
|
|
|
|
/**
|
2010-01-18 20:23:44 -08:00
|
|
|
* Handle accessible event, i.e. process it, notifies observers and fires
|
|
|
|
* platform specific event.
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2010-08-24 19:08:28 -07:00
|
|
|
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
|
2009-06-18 00:37:38 -07:00
|
|
|
|
|
|
|
/**
|
2012-02-07 23:31:25 -08:00
|
|
|
* Return true if this accessible allows accessible children from anonymous subtree.
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2012-02-07 23:31:25 -08:00
|
|
|
virtual bool CanHaveAnonChildren();
|
2009-06-18 00:37:38 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns text of accessible if accessible has text role otherwise empty
|
|
|
|
* string.
|
|
|
|
*
|
2011-01-31 19:00:24 -08:00
|
|
|
* @param aText [in] returned text of the accessible
|
|
|
|
* @param aStartOffset [in, optional] start offset inside of the accessible,
|
|
|
|
* if missed entire text is appended
|
|
|
|
* @param aLength [in, optional] required length of text, if missed
|
|
|
|
* then text form start offset till the end is appended
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
|
|
|
|
uint32_t aLength = PR_UINT32_MAX);
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2010-02-09 05:29:22 -08:00
|
|
|
/**
|
2010-03-08 23:25:24 -08:00
|
|
|
* Assert if child not in parent's cache if the cache was initialized at this
|
|
|
|
* point.
|
2010-02-09 05:29:22 -08:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
void TestChildCache(Accessible* aCachedChild) const;
|
2010-02-09 05:29:22 -08:00
|
|
|
|
2012-05-07 17:00:36 -07:00
|
|
|
/**
|
|
|
|
* Return boundaries rect relative the bounding frame.
|
|
|
|
*/
|
|
|
|
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
|
|
|
|
2011-01-27 21:15:13 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2011-09-27 18:46:11 -07:00
|
|
|
// Downcasting and types
|
2011-01-27 21:15:13 -08:00
|
|
|
|
2011-11-24 03:31:34 -08:00
|
|
|
inline bool IsAbbreviation() const
|
|
|
|
{
|
|
|
|
return mContent->IsHTML() &&
|
|
|
|
(mContent->Tag() == nsGkAtoms::abbr || mContent->Tag() == nsGkAtoms::acronym);
|
|
|
|
}
|
|
|
|
|
2011-02-22 05:54:46 -08:00
|
|
|
inline bool IsApplication() const { return mFlags & eApplicationAccessible; }
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
bool IsAutoComplete() const { return mFlags & eAutoCompleteAccessible; }
|
|
|
|
|
|
|
|
inline bool IsAutoCompletePopup() const { return mFlags & eAutoCompletePopupAccessible; }
|
|
|
|
|
|
|
|
inline bool IsCombobox() const { return mFlags & eComboboxAccessible; }
|
|
|
|
|
2011-05-19 22:17:47 -07:00
|
|
|
inline bool IsDoc() const { return mFlags & eDocAccessible; }
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* AsDoc();
|
2011-05-19 22:17:47 -07:00
|
|
|
|
2011-01-27 21:15:13 -08:00
|
|
|
inline bool IsHyperText() const { return mFlags & eHyperTextAccessible; }
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible* AsHyperText();
|
2011-01-27 21:15:13 -08:00
|
|
|
|
2011-11-30 04:36:20 -08:00
|
|
|
inline bool IsHTMLFileInput() const { return mFlags & eHTMLFileInputAccessible; }
|
|
|
|
|
2011-03-28 06:59:54 -07:00
|
|
|
inline bool IsHTMLListItem() const { return mFlags & eHTMLListItemAccessible; }
|
2012-05-07 22:16:40 -07:00
|
|
|
mozilla::a11y::HTMLLIAccessible* AsHTMLListItem();
|
2012-03-15 13:16:02 -07:00
|
|
|
|
2012-05-22 09:40:56 -07:00
|
|
|
inline bool IsImage() const { return mFlags & eImageAccessible; }
|
2012-06-02 04:30:34 -07:00
|
|
|
mozilla::a11y::ImageAccessible* AsImage();
|
2011-03-28 06:59:54 -07:00
|
|
|
|
2012-03-15 13:16:02 -07:00
|
|
|
bool IsImageMapAccessible() const { return mFlags & eImageMapAccessible; }
|
2012-06-04 05:32:34 -07:00
|
|
|
mozilla::a11y::HTMLImageMapAccessible* AsImageMap();
|
2012-03-15 13:16:02 -07:00
|
|
|
|
2012-04-03 02:54:01 -07:00
|
|
|
inline bool IsXULTree() const { return mFlags & eXULTreeAccessible; }
|
2012-06-08 03:28:27 -07:00
|
|
|
mozilla::a11y::XULTreeAccessible* AsXULTree();
|
2012-04-03 02:54:01 -07:00
|
|
|
|
2012-06-28 16:04:50 -07:00
|
|
|
inline bool IsXULDeck() const { return mFlags & eXULDeckAccessible; }
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
inline bool IsListControl() const { return mFlags & eListControlAccessible; }
|
|
|
|
|
|
|
|
inline bool IsMenuButton() const { return mFlags & eMenuButtonAccessible; }
|
|
|
|
|
|
|
|
inline bool IsMenuPopup() const { return mFlags & eMenuPopupAccessible; }
|
|
|
|
|
2011-03-01 21:16:28 -08:00
|
|
|
inline bool IsRoot() const { return mFlags & eRootAccessible; }
|
2012-05-03 23:09:22 -07:00
|
|
|
mozilla::a11y::RootAccessible* AsRoot();
|
2011-03-01 21:16:28 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
virtual mozilla::a11y::TableAccessible* AsTable() { return nullptr; }
|
2012-03-27 17:53:58 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
virtual mozilla::a11y::TableCellAccessible* AsTableCell() { return nullptr; }
|
|
|
|
|
2011-01-30 20:04:32 -08:00
|
|
|
inline bool IsTextLeaf() const { return mFlags & eTextLeafAccessible; }
|
2012-05-23 11:05:57 -07:00
|
|
|
mozilla::a11y::TextLeafAccessible* AsTextLeaf();
|
2011-01-30 20:04:32 -08:00
|
|
|
|
2011-07-19 01:30:24 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ActionAccessible
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
/**
|
|
|
|
* Return the number of actions that can be performed on this accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint8_t ActionCount();
|
2011-06-05 12:35:43 -07:00
|
|
|
|
2011-07-19 01:30:24 -07:00
|
|
|
/**
|
|
|
|
* Return access key, such as Alt+D.
|
|
|
|
*/
|
|
|
|
virtual KeyBinding AccessKey() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return global keyboard shortcut for default action, such as Ctrl+O for
|
|
|
|
* Open file menuitem.
|
|
|
|
*/
|
|
|
|
virtual KeyBinding KeyboardShortcut() const;
|
|
|
|
|
2010-08-31 20:26:13 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HyperLinkAccessible
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the accessible is hyper link accessible.
|
|
|
|
*/
|
2011-06-23 21:29:43 -07:00
|
|
|
virtual bool IsLink();
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the start offset of the link within the parent accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t StartOffset();
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the end offset of the link within the parent accessible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t EndOffset();
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the link is valid (e. g. points to a valid URL).
|
|
|
|
*/
|
2011-06-21 22:43:25 -07:00
|
|
|
inline bool IsLinkValid()
|
|
|
|
{
|
2011-06-23 21:29:43 -07:00
|
|
|
NS_PRECONDITION(IsLink(), "IsLinkValid is called on not hyper link!");
|
2011-06-21 22:43:25 -07:00
|
|
|
|
|
|
|
// XXX In order to implement this we would need to follow every link
|
|
|
|
// Perhaps we can get information about invalid links from the cache
|
|
|
|
// In the mean time authors can use role="link" aria-invalid="true"
|
|
|
|
// to force it for links they internally know to be invalid
|
2011-07-27 05:43:01 -07:00
|
|
|
return (0 == (State() & mozilla::a11y::states::INVALID));
|
2011-06-21 22:43:25 -07:00
|
|
|
}
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the link currently has the focus.
|
|
|
|
*/
|
2011-09-27 18:46:11 -07:00
|
|
|
bool IsLinkSelected();
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the number of anchors within the link.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t AnchorCount();
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an anchor accessible at the given index.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual Accessible* AnchorAt(uint32_t aAnchorIndex);
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an anchor URI at the given index.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
|
2010-08-31 20:26:13 -07:00
|
|
|
|
2010-09-01 17:46:59 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SelectAccessible
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the accessible is a select control containing selectable
|
|
|
|
* items.
|
|
|
|
*/
|
|
|
|
virtual bool IsSelect();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an array of selected items.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<nsIArray> SelectedItems();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the number of selected items.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t SelectedItemCount();
|
2010-09-01 17:46:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return selected item at the given index.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual Accessible* GetSelectedItem(uint32_t aIndex);
|
2010-09-01 17:46:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if item at the given index is selected.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsItemSelected(uint32_t aIndex);
|
2010-09-01 17:46:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add item at the given index the selection. Return true if success.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool AddItemToSelection(uint32_t aIndex);
|
2010-09-01 17:46:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove item at the given index from the selection. Return if success.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool RemoveItemFromSelection(uint32_t aIndex);
|
2010-09-01 17:46:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Select all items. Return true if success.
|
|
|
|
*/
|
|
|
|
virtual bool SelectAll();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unselect all items. Return true if success.
|
|
|
|
*/
|
|
|
|
virtual bool UnselectAll();
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Widgets
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if accessible is a widget, i.e. control or accessible that
|
|
|
|
* manages its items. Note, being a widget the accessible may be a part of
|
|
|
|
* composite widget.
|
|
|
|
*/
|
|
|
|
virtual bool IsWidget() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the widget is active, i.e. has a focus within it.
|
|
|
|
*/
|
|
|
|
virtual bool IsActiveWidget() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the widget has items and items are operable by user and
|
|
|
|
* can be activated.
|
|
|
|
*/
|
|
|
|
virtual bool AreItemsOperable() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the current item of the widget, i.e. an item that has or will have
|
|
|
|
* keyboard focus when widget gets active.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* CurrentItem();
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2011-12-08 04:20:15 -08:00
|
|
|
/**
|
|
|
|
* Set the current item of the widget.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual void SetCurrentItem(Accessible* aItem);
|
2011-12-08 04:20:15 -08:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
/**
|
|
|
|
* Return container widget this accessible belongs to.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
virtual Accessible* ContainerWidget() const;
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-01-26 22:14:09 -08:00
|
|
|
/**
|
|
|
|
* Return the localized string for the given key.
|
|
|
|
*/
|
2012-05-10 06:43:04 -07:00
|
|
|
static void TranslateString(const nsString& aKey, nsAString& aStringOut);
|
2012-01-26 22:14:09 -08:00
|
|
|
|
2012-03-28 08:59:01 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible is defunct.
|
|
|
|
*/
|
|
|
|
bool IsDefunct() const { return mFlags & eIsDefunct; }
|
|
|
|
|
2012-06-12 07:30:59 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible is no longer in the document.
|
|
|
|
*/
|
|
|
|
bool IsInDocument() const { return !(mFlags & eIsNotInDocument); }
|
|
|
|
|
2012-09-03 23:06:10 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible is primary accessible for the given DOM node.
|
|
|
|
*
|
|
|
|
* Accessible hierarchy may be complex for single DOM node, in this case
|
|
|
|
* these accessibles share the same DOM node. The primary accessible "owns"
|
|
|
|
* that DOM node in terms it gets stored in the accessible to node map.
|
|
|
|
*/
|
|
|
|
bool IsPrimaryForNode() const { return !(mFlags & eSharedNode); }
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
protected:
|
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// Initializing, cache and tree traverse methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cache accessible children.
|
|
|
|
*/
|
|
|
|
virtual void CacheChildren();
|
|
|
|
|
2010-07-01 18:22:41 -07:00
|
|
|
/**
|
|
|
|
* Set accessible parent and index in parent.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void BindToParent(Accessible* aParent, uint32_t aIndexInParent);
|
2012-03-23 05:21:31 -07:00
|
|
|
virtual void UnbindFromParent();
|
2010-07-01 18:22:41 -07:00
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
/**
|
|
|
|
* Return sibling accessible at the given offset.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual Accessible* GetSiblingAtOffset(int32_t aOffset,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsresult *aError = nullptr) const;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2011-01-27 21:15:04 -08:00
|
|
|
/**
|
|
|
|
* Flags used to describe the state and type of children.
|
|
|
|
*/
|
|
|
|
enum ChildrenFlags {
|
|
|
|
eChildrenUninitialized = 0, // children aren't initialized
|
|
|
|
eMixedChildren = 1 << 0, // text leaf children are presented
|
|
|
|
eEmbeddedChildren = 1 << 1 // all children are embedded objects
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the children flag is set.
|
|
|
|
*/
|
|
|
|
inline bool IsChildrenFlag(ChildrenFlags aFlag) const
|
2011-05-31 14:01:32 -07:00
|
|
|
{ return static_cast<ChildrenFlags> (mFlags & kChildrenFlagsMask) == aFlag; }
|
2011-01-27 21:15:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set children flag.
|
|
|
|
*/
|
|
|
|
inline void SetChildrenFlag(ChildrenFlags aFlag)
|
|
|
|
{ mFlags = (mFlags & ~kChildrenFlagsMask) | aFlag; }
|
|
|
|
|
2011-01-27 21:15:13 -08:00
|
|
|
/**
|
2012-03-28 08:59:01 -07:00
|
|
|
* Flags used to describe the state of this accessible.
|
2011-01-27 21:15:13 -08:00
|
|
|
* @note keep these flags in sync with ChildrenFlags
|
|
|
|
*/
|
2012-03-28 08:59:01 -07:00
|
|
|
enum StateFlags {
|
2012-06-12 07:30:59 -07:00
|
|
|
eIsDefunct = 1 << 2, // accessible is defunct
|
2012-09-03 23:06:10 -07:00
|
|
|
eIsNotInDocument = 1 << 3, // accessible is not in document
|
|
|
|
eSharedNode = 1 << 4 // accessible shares DOM node from another accessible
|
2012-03-28 08:59:01 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flags describing the type of this accessible.
|
|
|
|
* @note keep these flags in sync with ChildrenFlags and StateFlags
|
|
|
|
*/
|
2011-01-27 21:15:13 -08:00
|
|
|
enum AccessibleTypes {
|
2012-09-03 23:06:10 -07:00
|
|
|
eApplicationAccessible = 1 << 5,
|
|
|
|
eAutoCompleteAccessible = 1 << 6,
|
|
|
|
eAutoCompletePopupAccessible = 1 << 7,
|
|
|
|
eComboboxAccessible = 1 << 8,
|
|
|
|
eDocAccessible = 1 << 9,
|
|
|
|
eHyperTextAccessible = 1 << 10,
|
|
|
|
eHTMLFileInputAccessible = 1 << 11,
|
|
|
|
eHTMLListItemAccessible = 1 << 12,
|
|
|
|
eImageAccessible = 1 << 13,
|
|
|
|
eImageMapAccessible = 1 << 14,
|
|
|
|
eListControlAccessible = 1 << 15,
|
|
|
|
eMenuButtonAccessible = 1 << 16,
|
|
|
|
eMenuPopupAccessible = 1 << 17,
|
|
|
|
eRootAccessible = 1 << 18,
|
|
|
|
eTextLeafAccessible = 1 << 19,
|
|
|
|
eXULDeckAccessible = 1 << 20,
|
|
|
|
eXULTreeAccessible = 1 << 21
|
2011-01-27 21:15:13 -08:00
|
|
|
};
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Miscellaneous helpers
|
2007-11-11 17:05:37 -08:00
|
|
|
|
2010-12-01 00:53:17 -08:00
|
|
|
/**
|
|
|
|
* Return ARIA role (helper method).
|
|
|
|
*/
|
2012-03-29 17:04:06 -07:00
|
|
|
mozilla::a11y::role ARIATransformRole(mozilla::a11y::role aRole);
|
2010-12-01 00:53:17 -08:00
|
|
|
|
2008-12-02 23:18:41 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// Name helpers
|
2008-12-02 23:18:41 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the name of HTML node.
|
|
|
|
*/
|
|
|
|
nsresult GetHTMLName(nsAString& aName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the name for XUL node.
|
|
|
|
*/
|
|
|
|
nsresult GetXULName(nsAString& aName);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// helper method to verify frames
|
|
|
|
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
|
|
|
|
|
|
|
|
/**
|
2009-11-01 17:02:09 -08:00
|
|
|
* Return an accessible for the given DOM node, or if that node isn't
|
|
|
|
* accessible, return the accessible for the next DOM node which has one
|
|
|
|
* (based on forward depth first search).
|
|
|
|
*
|
|
|
|
* @param aStartNode [in] the DOM node to start from
|
|
|
|
* @return the resulting accessible
|
2010-05-25 01:05:52 -07:00
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* GetFirstAvailableAccessible(nsINode* aStartNode) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Action helpers
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepares click action that will be invoked in timeout.
|
|
|
|
*
|
|
|
|
* @note DoCommand() prepares an action in timeout because when action
|
|
|
|
* command opens a modal dialog/window, it won't return until the
|
|
|
|
* dialog/window is closed. If executing action command directly in
|
|
|
|
* nsIAccessible::DoAction() method, it will block AT tools (e.g. GOK) that
|
|
|
|
* invoke action of mozilla accessibles direclty (see bug 277888 for details).
|
|
|
|
*
|
|
|
|
* @param aContent [in, optional] element to click
|
|
|
|
* @param aActionIndex [in, optional] index of accessible action
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void DoCommand(nsIContent *aContent = nullptr, uint32_t aActionIndex = 0);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch click event.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void DispatchClickEvent(nsIContent *aContent, uint32_t aActionIndex);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_DECL_RUNNABLEMETHOD_ARG2(Accessible, DispatchClickEvent,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsCOMPtr<nsIContent>, uint32_t)
|
2010-01-25 07:08:08 -08:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-18 14:40:04 -07:00
|
|
|
/**
|
2007-12-11 18:10:26 -08:00
|
|
|
* Get the container node for an atomic region, defined by aria-atomic="true"
|
2007-09-18 14:40:04 -07:00
|
|
|
* @return the container node
|
|
|
|
*/
|
2011-08-09 18:44:00 -07:00
|
|
|
nsIContent* GetAtomicRegion() const;
|
2007-09-18 14:40:04 -07:00
|
|
|
|
2007-08-03 22:27:27 -07:00
|
|
|
/**
|
2007-09-24 18:19:03 -07:00
|
|
|
* Get numeric value of the given ARIA attribute.
|
2007-08-03 22:27:27 -07:00
|
|
|
*
|
2007-09-24 18:19:03 -07:00
|
|
|
* @param aAriaProperty - the ARIA property we're using
|
2007-08-03 22:27:27 -07:00
|
|
|
* @param aValue - value of the attribute
|
|
|
|
*
|
|
|
|
* @return - NS_OK_NO_ARIA_VALUE if there is no setted ARIA attribute
|
|
|
|
*/
|
2007-12-11 18:10:26 -08:00
|
|
|
nsresult GetAttrValue(nsIAtom *aAriaProperty, double *aValue);
|
2007-08-03 22:27:27 -07:00
|
|
|
|
2008-10-08 05:54:58 -07:00
|
|
|
/**
|
|
|
|
* Return the action rule based on ARIA enum constants EActionRule
|
2011-06-05 12:35:43 -07:00
|
|
|
* (see nsARIAMap.h). Used by ActionCount() and GetActionName().
|
2008-10-08 05:54:58 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetActionRule();
|
2008-10-08 05:54:58 -07:00
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
/**
|
|
|
|
* Return group info.
|
|
|
|
*/
|
|
|
|
AccGroupInfo* GetGroupInfo();
|
|
|
|
|
2008-06-15 23:16:18 -07:00
|
|
|
/**
|
|
|
|
* Fires platform accessible event. It's notification method only. It does
|
2010-01-18 20:23:44 -08:00
|
|
|
* change nothing on Gecko side. Don't use it until you're sure what you do
|
|
|
|
* (see example in XUL tree accessible), use nsEventShell::FireEvent()
|
|
|
|
* instead. MUST be overridden in wrap classes.
|
2008-06-15 23:16:18 -07:00
|
|
|
*
|
|
|
|
* @param aEvent the accessible event to fire.
|
|
|
|
*/
|
2010-08-24 19:08:28 -07:00
|
|
|
virtual nsresult FirePlatformEvent(AccEvent* aEvent) = 0;
|
2008-06-15 23:16:18 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Data Members
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> mParent;
|
|
|
|
nsTArray<nsRefPtr<Accessible> > mChildren;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mIndexInParent;
|
2008-08-06 05:19:56 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static const uint32_t kChildrenFlagsMask =
|
2011-01-27 21:15:04 -08:00
|
|
|
eChildrenUninitialized | eMixedChildren | eEmbeddedChildren;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mFlags;
|
2012-06-12 07:30:59 -07:00
|
|
|
friend class DocAccessible;
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2012-08-28 06:13:59 -07:00
|
|
|
nsAutoPtr<mozilla::a11y::EmbeddedObjCollector> mEmbeddedObjCollector;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mIndexOfEmbeddedChild;
|
2012-08-28 06:13:59 -07:00
|
|
|
friend class mozilla::a11y::EmbeddedObjCollector;
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
nsAutoPtr<AccGroupInfo> mGroupInfo;
|
|
|
|
friend class AccGroupInfo;
|
2012-06-04 05:32:34 -07:00
|
|
|
|
2012-04-16 02:24:23 -07:00
|
|
|
/**
|
|
|
|
* Non-null indicates author-supplied role; possibly state & value as well
|
|
|
|
*/
|
|
|
|
nsRoleMapEntry* mRoleMapEntry;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(Accessible,
|
2010-04-26 23:52:03 -07:00
|
|
|
NS_ACCESSIBLE_IMPL_IID)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-19 01:30:24 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represent key binding associated with accessible (such as access key and
|
|
|
|
* global keyboard shortcuts).
|
|
|
|
*/
|
|
|
|
class KeyBinding
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Modifier mask values.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static const uint32_t kShift = 1;
|
|
|
|
static const uint32_t kControl = 2;
|
|
|
|
static const uint32_t kAlt = 4;
|
|
|
|
static const uint32_t kMeta = 8;
|
|
|
|
static const uint32_t kOS = 16;
|
2011-07-19 01:30:24 -07:00
|
|
|
|
|
|
|
KeyBinding() : mKey(0), mModifierMask(0) {}
|
2012-08-22 08:56:38 -07:00
|
|
|
KeyBinding(uint32_t aKey, uint32_t aModifierMask) :
|
2011-07-19 01:30:24 -07:00
|
|
|
mKey(aKey), mModifierMask(aModifierMask) {};
|
|
|
|
|
|
|
|
inline bool IsEmpty() const { return !mKey; }
|
2012-08-22 08:56:38 -07:00
|
|
|
inline uint32_t Key() const { return mKey; }
|
|
|
|
inline uint32_t ModifierMask() const { return mModifierMask; }
|
2011-07-19 01:30:24 -07:00
|
|
|
|
|
|
|
enum Format {
|
|
|
|
ePlatformFormat,
|
|
|
|
eAtkFormat
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return formatted string for this key binding depending on the given format.
|
|
|
|
*/
|
|
|
|
inline void ToString(nsAString& aValue,
|
|
|
|
Format aFormat = ePlatformFormat) const
|
|
|
|
{
|
|
|
|
aValue.Truncate();
|
|
|
|
AppendToString(aValue, aFormat);
|
|
|
|
}
|
|
|
|
inline void AppendToString(nsAString& aValue,
|
|
|
|
Format aFormat = ePlatformFormat) const
|
|
|
|
{
|
|
|
|
if (mKey) {
|
|
|
|
if (aFormat == ePlatformFormat)
|
|
|
|
ToPlatformFormat(aValue);
|
|
|
|
else
|
|
|
|
ToAtkFormat(aValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void ToPlatformFormat(nsAString& aValue) const;
|
|
|
|
void ToAtkFormat(nsAString& aValue) const;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mKey;
|
|
|
|
uint32_t mModifierMask;
|
2011-07-19 01:30:24 -07:00
|
|
|
};
|
|
|
|
|
2010-07-16 07:15:03 -07:00
|
|
|
#endif
|