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-12-17 21:22:26 -08:00
|
|
|
#include "mozilla/a11y/AccTypes.h"
|
2013-10-19 11:19:50 -07:00
|
|
|
#include "mozilla/a11y/RelationType.h"
|
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"
|
2007-05-19 19:41:33 -07:00
|
|
|
|
2013-03-21 17:05:20 -07:00
|
|
|
#include "nsIContent.h"
|
2013-09-23 10:25:00 -07:00
|
|
|
#include "nsString.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
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
struct nsRoleMapEntry;
|
2012-04-30 20:08:31 -07:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
struct nsRect;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIAtom;
|
2014-09-16 10:30:23 -07:00
|
|
|
struct nsIntRect;
|
2014-10-21 17:49:28 -07:00
|
|
|
class nsIPersistentProperties;
|
2013-01-03 05:23:11 -08:00
|
|
|
class nsView;
|
2012-11-17 18:01:44 -08:00
|
|
|
|
2012-03-27 17:53:58 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
2012-05-07 22:16:40 -07:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
class Accessible;
|
|
|
|
class AccEvent;
|
|
|
|
class AccGroupInfo;
|
2014-10-21 17:49:28 -07:00
|
|
|
class ApplicationAccessible;
|
2013-10-28 20:30:55 -07:00
|
|
|
class DocAccessible;
|
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-11-17 18:01:44 -08:00
|
|
|
class HyperTextAccessible;
|
2012-06-02 04:30:34 -07:00
|
|
|
class ImageAccessible;
|
2012-11-17 18:01:44 -08:00
|
|
|
class KeyBinding;
|
2015-01-19 13:34:14 -08:00
|
|
|
class ProxyAccessible;
|
2012-06-10 15:18:31 -07:00
|
|
|
class Relation;
|
2013-10-28 20:30:55 -07:00
|
|
|
class RootAccessible;
|
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;
|
2013-02-28 20:06:16 -08:00
|
|
|
class XULLabelAccessible;
|
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()
|
|
|
|
*/
|
|
|
|
eNameOK,
|
2012-10-13 21:18:39 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Name was left empty by the author on purpose:
|
|
|
|
* name.IsEmpty() && !name.IsVoid().
|
|
|
|
*/
|
|
|
|
eNoNameOnPurpose,
|
|
|
|
|
2012-10-16 23:38:16 -07:00
|
|
|
/**
|
|
|
|
* Name was computed from the subtree.
|
|
|
|
*/
|
|
|
|
eNameFromSubtree,
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
/**
|
|
|
|
* Tooltip was used as a name.
|
|
|
|
*/
|
|
|
|
eNameFromTooltip
|
2012-04-30 20:08:31 -07:00
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-05-16 16:16:34 -07:00
|
|
|
/**
|
|
|
|
* An index type. Assert if out of range value was attempted to be used.
|
|
|
|
*/
|
|
|
|
class index_t
|
|
|
|
{
|
|
|
|
public:
|
2014-08-05 14:57:52 -07:00
|
|
|
MOZ_IMPLICIT index_t(int32_t aVal) : mVal(aVal) {}
|
2014-05-16 16:16:34 -07:00
|
|
|
|
|
|
|
operator uint32_t() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mVal >= 0, "Attempt to use wrong index!");
|
|
|
|
return mVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsValid() const { return mVal >= 0; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
int32_t mVal;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
class Accessible : public nsISupports
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible(nsIContent* aContent, DocAccessible* aDoc);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-28 20:30:55 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2014-10-21 17:49:28 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(Accessible)
|
2008-08-06 05:19:56 -07:00
|
|
|
|
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
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2013-10-28 20:30:55 -07:00
|
|
|
// Public methods
|
2008-10-31 20:58:07 -07:00
|
|
|
|
2013-10-28 20:30:55 -07:00
|
|
|
/**
|
|
|
|
* Return the document accessible for this accessible.
|
|
|
|
*/
|
|
|
|
DocAccessible* Document() const { return mDoc; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-28 20:30:55 -07:00
|
|
|
/**
|
|
|
|
* Return the root document accessible for this accessible.
|
|
|
|
*/
|
|
|
|
a11y::RootAccessible* RootAccessible() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return frame for this accessible.
|
|
|
|
*/
|
|
|
|
virtual nsIFrame* GetFrame() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return DOM node associated with the accessible.
|
|
|
|
*/
|
|
|
|
virtual nsINode* GetNode() const;
|
|
|
|
inline already_AddRefed<nsIDOMNode> DOMNode() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMNode> DOMNode = do_QueryInterface(GetNode());
|
|
|
|
return DOMNode.forget();
|
|
|
|
}
|
|
|
|
nsIContent* GetContent() const { return mContent; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return node type information of DOM node associated with the accessible.
|
|
|
|
*/
|
|
|
|
bool IsContent() const
|
|
|
|
{ return GetNode() && GetNode()->IsNodeOfType(nsINode::eCONTENT); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the unique identifier of the accessible.
|
|
|
|
*/
|
|
|
|
void* UniqueID() { return static_cast<void*>(this); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return language associated with the accessible.
|
|
|
|
*/
|
|
|
|
void Language(nsAString& aLocale);
|
2008-10-10 05:26:55 -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);
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
/**
|
|
|
|
* Get help string for the accessible.
|
|
|
|
*/
|
|
|
|
void Help(nsString& aHelp) const { aHelp.Truncate(); }
|
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
/**
|
|
|
|
* Get the name of this accessible.
|
2012-10-13 21:18:39 -07:00
|
|
|
*
|
|
|
|
* Note: aName.IsVoid() when name was left empty by the author on purpose.
|
|
|
|
* aName.IsEmpty() when the author missed name, AT can try to repair a name.
|
2012-04-30 20:08:31 -07:00
|
|
|
*/
|
2012-11-17 18:01:44 -08:00
|
|
|
virtual ENameValueFlag Name(nsString& aName);
|
2012-04-30 20:08:31 -07:00
|
|
|
|
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
|
|
|
|
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-11-29 23:33:01 -08:00
|
|
|
bool HasARIARole() const { return mRoleMapEntry; }
|
2013-11-13 05:58:12 -08:00
|
|
|
bool IsARIARole(nsIAtom* aARIARole) const;
|
2014-08-15 13:49:02 -07:00
|
|
|
bool HasStrongARIARole() const;
|
2012-11-29 23:33:01 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrun ARIA role map if any.
|
|
|
|
*/
|
|
|
|
nsRoleMapEntry* ARIARoleMap() 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
|
|
|
|
2015-02-28 14:25:06 -08:00
|
|
|
/**
|
|
|
|
* Return a landmark role if applied.
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* LandmarkRole() const;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-20 10:24:30 -08:00
|
|
|
/**
|
|
|
|
* Return if accessible is unavailable.
|
|
|
|
*/
|
|
|
|
bool Unavailable() const
|
|
|
|
{
|
|
|
|
uint64_t state = NativelyUnavailable() ? states::UNAVAILABLE : 0;
|
|
|
|
ApplyARIAState(&state);
|
|
|
|
return state & states::UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
2012-10-19 00:15:23 -07:00
|
|
|
* Return object attributes for the accessible.
|
2007-04-07 02:07:24 -07:00
|
|
|
*/
|
2012-10-19 00:15:23 -07:00
|
|
|
virtual already_AddRefed<nsIPersistentProperties> Attributes();
|
2007-04-07 02:07:24 -07:00
|
|
|
|
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.
|
|
|
|
*/
|
2013-10-19 11:19:50 -07:00
|
|
|
virtual Relation RelationByType(RelationType 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
|
|
|
|
|
2013-10-28 20:30:55 -07:00
|
|
|
/**
|
|
|
|
* Shutdown this accessible object.
|
|
|
|
*/
|
|
|
|
virtual void Shutdown();
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
/**
|
|
|
|
* Set the ARIA role map entry for a new accessible.
|
|
|
|
*/
|
2012-12-20 19:16:44 -08:00
|
|
|
void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
|
|
|
|
{ mRoleMapEntry = aRoleMapEntry; }
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2011-01-26 19:38:50 -08:00
|
|
|
/**
|
2014-12-30 12:43:49 -08:00
|
|
|
* Cache children if necessary.
|
2011-01-26 19:38:50 -08:00
|
|
|
*/
|
2014-12-30 12:43:49 -08:00
|
|
|
void 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
|
|
|
*/
|
2013-03-13 21:53:28 -07:00
|
|
|
bool AppendChild(Accessible* aChild)
|
|
|
|
{ return InsertChildAt(mChildren.Length(), 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
|
|
|
*/
|
2014-01-24 19:08:17 -08:00
|
|
|
virtual Accessible* GetChildAt(uint32_t aIndex) const;
|
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.
|
|
|
|
*/
|
2014-01-25 06:07:37 -08:00
|
|
|
int32_t GetIndexOf(const Accessible* aChild) const
|
|
|
|
{ return (aChild->mParent != this) ? -1 : aChild->IndexInParent(); }
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-09-06 12:27:07 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible is an acceptable child.
|
|
|
|
*/
|
|
|
|
virtual bool IsAcceptableChild(Accessible* aPossibleChild) const { return true; }
|
|
|
|
|
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,
|
2012-09-27 23:57:33 -07:00
|
|
|
uint32_t aLength = 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
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
/**
|
|
|
|
* Return boundaries in screen coordinates.
|
|
|
|
*/
|
|
|
|
virtual nsIntRect Bounds() const;
|
|
|
|
|
2012-05-07 17:00:36 -07:00
|
|
|
/**
|
|
|
|
* Return boundaries rect relative the bounding frame.
|
|
|
|
*/
|
2014-09-16 10:30:23 -07:00
|
|
|
virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the accessible within its container if applicable.
|
|
|
|
*/
|
|
|
|
virtual void SetSelected(bool aSelect);
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
/**
|
|
|
|
* Extend selection to this accessible.
|
|
|
|
*/
|
|
|
|
void ExtendSelection() { };
|
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
/**
|
|
|
|
* Select the accessible within its container.
|
|
|
|
*/
|
|
|
|
void TakeSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Focus the accessible.
|
|
|
|
*/
|
|
|
|
virtual void TakeFocus();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scroll the accessible into view.
|
|
|
|
*/
|
|
|
|
void ScrollTo(uint32_t aHow) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scroll the accessible to the given point.
|
|
|
|
*/
|
|
|
|
void ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
|
2012-05-07 17:00:36 -07:00
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
/**
|
|
|
|
* Get a pointer to accessibility interface for this node, which is specific
|
|
|
|
* to the OS/accessibility toolkit we're running on.
|
|
|
|
*/
|
|
|
|
virtual void GetNativeInterface(void** aNativeAccessible);
|
|
|
|
|
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
|
|
|
|
{
|
2015-03-03 03:08:59 -08:00
|
|
|
return mContent->IsHTMLElement() &&
|
2011-11-24 03:31:34 -08:00
|
|
|
(mContent->Tag() == nsGkAtoms::abbr || mContent->Tag() == nsGkAtoms::acronym);
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsApplication() const { return mType == eApplicationType; }
|
2014-10-21 17:49:28 -07:00
|
|
|
ApplicationAccessible* AsApplication();
|
2011-02-22 05:54:46 -08:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsAutoComplete() const { return HasGenericType(eAutoComplete); }
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsAutoCompletePopup() const
|
2012-12-20 19:16:44 -08:00
|
|
|
{ return HasGenericType(eAutoCompletePopup); }
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2014-04-04 01:01:19 -07:00
|
|
|
bool IsButton() const { return HasGenericType(eButton); }
|
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsCombobox() const { return HasGenericType(eCombobox); }
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsDoc() const { return HasGenericType(eDocument); }
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* AsDoc();
|
2011-05-19 22:17:47 -07:00
|
|
|
|
2015-02-13 17:09:51 -08:00
|
|
|
bool IsGenericHyperText() const { return mType == eHyperTextType; }
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsHyperText() const { return HasGenericType(eHyperText); }
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible* AsHyperText();
|
2011-01-27 21:15:13 -08:00
|
|
|
|
2013-09-11 09:56:01 -07:00
|
|
|
bool IsHTMLBr() const { return mType == eHTMLBRType; }
|
2014-12-30 12:43:49 -08:00
|
|
|
bool IsHTMLCombobox() const { return mType == eHTMLComboboxType; }
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsHTMLFileInput() const { return mType == eHTMLFileInputType; }
|
2011-11-30 04:36:20 -08:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsHTMLListItem() const { return mType == eHTMLLiType; }
|
|
|
|
HTMLLIAccessible* AsHTMLListItem();
|
2012-03-15 13:16:02 -07:00
|
|
|
|
2012-11-10 01:41:40 -08:00
|
|
|
bool IsHTMLOptGroup() const { return mType == eHTMLOptGroupType; }
|
|
|
|
|
2013-02-15 21:42:00 -08:00
|
|
|
bool IsHTMLTable() const { return mType == eHTMLTableType; }
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsHTMLTableRow() const { return mType == eHTMLTableRowType; }
|
2011-03-28 06:59:54 -07:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsImage() const { return mType == eImageType; }
|
|
|
|
ImageAccessible* AsImage();
|
2012-03-15 13:16:02 -07:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsImageMap() const { return mType == eImageMapType; }
|
|
|
|
HTMLImageMapAccessible* AsImageMap();
|
2012-04-03 02:54:01 -07:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsList() const { return HasGenericType(eList); }
|
2012-06-28 16:04:50 -07:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsListControl() const { return HasGenericType(eListControl); }
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsMenuButton() const { return HasGenericType(eMenuButton); }
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsMenuPopup() const { return mType == eMenuPopupType; }
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2015-01-19 13:34:14 -08:00
|
|
|
bool IsProxy() const { return mType == eProxyType; }
|
2015-01-21 15:31:27 -08:00
|
|
|
ProxyAccessible* Proxy() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsProxy());
|
|
|
|
return mBits.proxy;
|
|
|
|
}
|
2015-01-19 13:34:14 -08:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsProgress() const { return mType == eProgressType; }
|
2012-10-15 20:05:20 -07:00
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsRoot() const { return mType == eRootType; }
|
|
|
|
a11y::RootAccessible* AsRoot();
|
2011-03-01 21:16:28 -08:00
|
|
|
|
2015-02-28 14:25:06 -08:00
|
|
|
bool IsSearchbox() const;
|
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsSelect() const { return HasGenericType(eSelect); }
|
2012-03-27 17:53:58 -07:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsTable() const { return HasGenericType(eTable); }
|
2012-12-17 21:22:26 -08:00
|
|
|
virtual TableAccessible* AsTable() { return nullptr; }
|
2012-08-08 23:24:31 -07:00
|
|
|
|
2013-07-18 08:09:45 -07:00
|
|
|
bool IsTableCell() const { return HasGenericType(eTableCell); }
|
2012-12-17 21:22:26 -08:00
|
|
|
virtual TableCellAccessible* AsTableCell() { return nullptr; }
|
2013-02-14 02:57:35 -08:00
|
|
|
const TableCellAccessible* AsTableCell() const
|
|
|
|
{ return const_cast<Accessible*>(this)->AsTableCell(); }
|
2012-12-17 21:22:26 -08:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
bool IsTableRow() const { return HasGenericType(eTableRow); }
|
2012-12-17 21:22:26 -08:00
|
|
|
|
2013-04-05 01:15:26 -07:00
|
|
|
bool IsTextField() const { return mType == eHTMLTextFieldType; }
|
|
|
|
|
2012-12-17 21:22:26 -08:00
|
|
|
bool IsTextLeaf() const { return mType == eTextLeafType; }
|
|
|
|
TextLeafAccessible* AsTextLeaf();
|
|
|
|
|
2013-02-28 20:06:16 -08:00
|
|
|
bool IsXULLabel() const { return mType == eXULLabelType; }
|
|
|
|
XULLabelAccessible* AsXULLabel();
|
|
|
|
|
2014-03-31 07:30:46 -07:00
|
|
|
bool IsXULListItem() const { return mType == eXULListItemType; }
|
|
|
|
|
2012-12-28 00:15:02 -08:00
|
|
|
bool IsXULTabpanels() const { return mType == eXULTabpanelsType; }
|
2012-12-17 21:22:26 -08:00
|
|
|
|
|
|
|
bool IsXULTree() const { return mType == eXULTreeType; }
|
|
|
|
XULTreeAccessible* AsXULTree();
|
2011-01-30 20:04:32 -08:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
/**
|
|
|
|
* Return true if the accessible belongs to the given accessible type.
|
|
|
|
*/
|
|
|
|
bool HasGenericType(AccGenericType aType) const;
|
|
|
|
|
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
|
|
|
|
2014-09-16 10:30:23 -07:00
|
|
|
/**
|
|
|
|
* Return action name at given index.
|
|
|
|
*/
|
|
|
|
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default to localized action name.
|
|
|
|
*/
|
|
|
|
void ActionDescriptionAt(uint8_t aIndex, nsAString& aDescription)
|
|
|
|
{
|
|
|
|
nsAutoString name;
|
|
|
|
ActionNameAt(aIndex, name);
|
|
|
|
TranslateString(name, aDescription);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoke the accessible action.
|
|
|
|
*/
|
|
|
|
virtual bool DoAction(uint8_t aIndex);
|
|
|
|
|
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
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2014-09-16 10:30:23 -07:00
|
|
|
// HyperLinkAccessible (any embedded object in text can implement HyperLink,
|
|
|
|
// which helps determine where it is located within containing text).
|
2010-08-31 20:26:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 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 an array of selected items.
|
|
|
|
*/
|
2014-10-21 17:49:28 -07:00
|
|
|
virtual void SelectedItems(nsTArray<Accessible*>* aItems);
|
2010-09-01 17:46:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2013-11-19 13:01:15 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Value (numeric value interface)
|
|
|
|
|
|
|
|
virtual double MaxValue() const;
|
|
|
|
virtual double MinValue() const;
|
|
|
|
virtual double CurValue() const;
|
|
|
|
virtual double Step() const;
|
|
|
|
virtual bool SetCurValue(double aValue);
|
|
|
|
|
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.
|
|
|
|
*/
|
2012-12-10 19:31:42 -08:00
|
|
|
bool IsDefunct() const { return mStateFlags & eIsDefunct; }
|
2012-03-28 08:59:01 -07:00
|
|
|
|
2012-06-12 07:30:59 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible is no longer in the document.
|
|
|
|
*/
|
2012-12-10 19:31:42 -08:00
|
|
|
bool IsInDocument() const { return !(mStateFlags & eIsNotInDocument); }
|
2012-06-12 07:30:59 -07:00
|
|
|
|
2012-09-03 23:06:10 -07:00
|
|
|
/**
|
2012-10-12 23:34:21 -07:00
|
|
|
* Return true if the accessible should be contained by document node map.
|
|
|
|
*/
|
|
|
|
bool IsNodeMapEntry() const
|
2012-12-10 19:31:42 -08:00
|
|
|
{ return HasOwnContent() && !(mStateFlags & eNotNodeMapEntry); }
|
2012-10-12 23:34:21 -07:00
|
|
|
|
2014-03-28 07:01:06 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible's group info needs to be updated.
|
|
|
|
*/
|
|
|
|
inline bool HasDirtyGroupInfo() const { return mStateFlags & eGroupInfoDirty; }
|
|
|
|
|
2012-10-12 23:34:21 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible has associated DOM content.
|
|
|
|
*/
|
2012-12-10 19:31:42 -08:00
|
|
|
bool HasOwnContent() const
|
|
|
|
{ return mContent && !(mStateFlags & eSharedNode); }
|
2012-09-03 23:06:10 -07:00
|
|
|
|
2012-10-04 07:34:56 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible has a numeric value.
|
|
|
|
*/
|
|
|
|
bool HasNumericValue() const;
|
|
|
|
|
2013-08-02 09:42:36 -07:00
|
|
|
/**
|
|
|
|
* Return true if the accessible state change is processed by handling proper
|
|
|
|
* DOM UI event, if otherwise then false. For example, HTMLCheckboxAccessible
|
|
|
|
* process nsIDocumentObserver::ContentStateChanged instead
|
|
|
|
* 'CheckboxStateChange' event.
|
|
|
|
*/
|
|
|
|
bool NeedsDOMUIEvent() const
|
|
|
|
{ return !(mStateFlags & eIgnoreDOMUIEvent); }
|
|
|
|
|
2014-12-30 12:43:49 -08:00
|
|
|
/**
|
|
|
|
* Get/set survivingInUpdate bit on child indicating that parent recollects
|
|
|
|
* its children.
|
|
|
|
*/
|
|
|
|
bool IsSurvivingInUpdate() const { return mStateFlags & eSurvivingInUpdate; }
|
|
|
|
void SetSurvivingInUpdate(bool aIsSurviving)
|
|
|
|
{
|
|
|
|
if (aIsSurviving)
|
|
|
|
mStateFlags |= eSurvivingInUpdate;
|
|
|
|
else
|
|
|
|
mStateFlags &= ~eSurvivingInUpdate;
|
|
|
|
}
|
|
|
|
|
2014-03-31 07:30:46 -07:00
|
|
|
/**
|
|
|
|
* Return true if this accessible has a parent whose name depends on this
|
|
|
|
* accessible.
|
|
|
|
*/
|
|
|
|
bool HasNameDependentParent() const
|
|
|
|
{ return mContextFlags & eHasNameDependentParent; }
|
|
|
|
|
2015-02-04 15:33:33 -08:00
|
|
|
/**
|
|
|
|
* Return true if aria-hidden="true" is applied to the accessible or inherited
|
|
|
|
* from the parent.
|
|
|
|
*/
|
|
|
|
bool IsARIAHidden() const { return mContextFlags & eARIAHidden; }
|
|
|
|
void SetARIAHidden(bool aIsDefined);
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
protected:
|
|
|
|
|
2014-06-23 12:56:09 -07:00
|
|
|
virtual ~Accessible();
|
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
/**
|
|
|
|
* Return the accessible name provided by native markup. It doesn't take
|
|
|
|
* into account ARIA markup used to specify the name.
|
|
|
|
*/
|
|
|
|
virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return object attributes provided by native markup. It doesn't take into
|
|
|
|
* account ARIA.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes();
|
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// Initializing, cache and tree traverse methods
|
|
|
|
|
2013-10-28 20:30:55 -07:00
|
|
|
/**
|
|
|
|
* Destroy the object.
|
|
|
|
*/
|
|
|
|
void LastRelease();
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
/**
|
|
|
|
* 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
|
2012-12-17 21:22:26 -08:00
|
|
|
eEmbeddedChildren = 1 << 1, // all children are embedded objects
|
|
|
|
|
|
|
|
eLastChildrenFlag = eEmbeddedChildren
|
2011-01-27 21:15:04 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the children flag is set.
|
|
|
|
*/
|
2012-12-10 19:31:42 -08:00
|
|
|
bool IsChildrenFlag(ChildrenFlags aFlag) const
|
|
|
|
{ return static_cast<ChildrenFlags>(mChildrenFlags) == aFlag; }
|
2011-01-27 21:15:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set children flag.
|
|
|
|
*/
|
2012-12-10 19:31:42 -08:00
|
|
|
void SetChildrenFlag(ChildrenFlags aFlag) { mChildrenFlags = aFlag; }
|
2011-01-27 21:15:04 -08:00
|
|
|
|
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-12-10 19:31:42 -08:00
|
|
|
eIsDefunct = 1 << 0, // accessible is defunct
|
|
|
|
eIsNotInDocument = 1 << 1, // accessible is not in document
|
|
|
|
eSharedNode = 1 << 2, // accessible shares DOM node from another accessible
|
|
|
|
eNotNodeMapEntry = 1 << 3, // accessible shouldn't be in document node map
|
2012-12-17 21:22:26 -08:00
|
|
|
eHasNumericValue = 1 << 4, // accessible has a numeric value
|
2014-03-28 07:01:06 -07:00
|
|
|
eGroupInfoDirty = 1 << 5, // accessible needs to update group info
|
2014-09-02 11:54:04 -07:00
|
|
|
eSubtreeMutating = 1 << 6, // subtree is being mutated
|
|
|
|
eIgnoreDOMUIEvent = 1 << 7, // don't process DOM UI events for a11y events
|
2014-12-30 12:43:49 -08:00
|
|
|
eSurvivingInUpdate = 1 << 8, // parent drops children to recollect them
|
2012-03-28 08:59:01 -07:00
|
|
|
|
2014-12-30 12:43:49 -08:00
|
|
|
eLastStateFlag = eSurvivingInUpdate
|
2011-01-27 21:15:13 -08:00
|
|
|
};
|
|
|
|
|
2014-03-31 07:30:46 -07:00
|
|
|
/**
|
|
|
|
* Flags used for contextual information about the accessible.
|
|
|
|
*/
|
|
|
|
enum ContextFlags {
|
|
|
|
eHasNameDependentParent = 1 << 0, // Parent's name depends on this accessible.
|
2015-02-04 15:33:33 -08:00
|
|
|
eARIAHidden = 1 << 1,
|
2014-03-31 07:30:46 -07:00
|
|
|
|
2015-02-04 15:33:33 -08:00
|
|
|
eLastContextFlag = eARIAHidden
|
2014-03-31 07:30:46 -07:00
|
|
|
};
|
|
|
|
|
2012-11-10 18:16:17 -08:00
|
|
|
protected:
|
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
2012-10-13 21:18:39 -07:00
|
|
|
* Returns the accessible name specified by ARIA.
|
2008-12-02 23:18:41 -08:00
|
|
|
*/
|
2012-10-16 23:38:16 -07:00
|
|
|
void ARIAName(nsString& aName);
|
2008-12-02 23:18:41 -08:00
|
|
|
|
|
|
|
/**
|
2013-12-07 13:37:04 -08:00
|
|
|
* Return the name for XUL element.
|
2008-12-02 23:18:41 -08:00
|
|
|
*/
|
2013-12-07 13:37:04 -08:00
|
|
|
static void XULElmName(DocAccessible* aDocument,
|
|
|
|
nsIContent* aElm, nsString& aName);
|
2008-12-02 23:18:41 -08:00
|
|
|
|
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-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
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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
|
|
|
/**
|
2013-11-19 13:01:15 -08:00
|
|
|
* Return numeric value of the given ARIA attribute, NaN if not applicable.
|
2007-08-03 22:27:27 -07:00
|
|
|
*
|
2013-11-19 13:01:15 -08:00
|
|
|
* @param aARIAProperty [in] the ARIA property we're using
|
|
|
|
* @return a numeric value
|
2007-08-03 22:27:27 -07:00
|
|
|
*/
|
2013-11-19 13:01:15 -08:00
|
|
|
double AttrNumericValue(nsIAtom* aARIAAttr) const;
|
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
|
2014-09-16 10:30:23 -07:00
|
|
|
* (see ARIAMap.h). Used by ActionCount() and ActionNameAt().
|
2008-10-08 05:54:58 -07:00
|
|
|
*/
|
2014-09-16 10:30:23 -07:00
|
|
|
uint32_t GetActionRule() const;
|
2008-10-08 05:54:58 -07:00
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
/**
|
|
|
|
* Return group info.
|
|
|
|
*/
|
|
|
|
AccGroupInfo* GetGroupInfo();
|
|
|
|
|
2014-03-28 07:01:06 -07:00
|
|
|
/**
|
|
|
|
* Set dirty state of the accessible's group info.
|
|
|
|
*/
|
|
|
|
inline void SetDirtyGroupInfo(bool aIsDirty)
|
|
|
|
{
|
|
|
|
if (aIsDirty)
|
|
|
|
mStateFlags |= eGroupInfoDirty;
|
|
|
|
else
|
|
|
|
mStateFlags &= ~eGroupInfoDirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag all children group info as needing to be updated.
|
|
|
|
*/
|
|
|
|
void InvalidateChildrenGroupInfo();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Data Members
|
2013-10-28 20:30:55 -07:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
DocAccessible* mDoc;
|
|
|
|
|
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-12-17 21:22:26 -08:00
|
|
|
static const uint8_t kChildrenFlagsBits = 2;
|
2014-12-30 12:43:49 -08:00
|
|
|
static const uint8_t kStateFlagsBits = 9;
|
2015-02-04 15:33:33 -08:00
|
|
|
static const uint8_t kContextFlagsBits = 2;
|
2013-02-28 20:06:16 -08:00
|
|
|
static const uint8_t kTypeBits = 6;
|
2015-02-28 14:25:06 -08:00
|
|
|
static const uint8_t kGenericTypesBits = 14;
|
2012-12-17 21:22:26 -08:00
|
|
|
|
2012-12-10 19:31:42 -08:00
|
|
|
/**
|
2014-03-31 07:30:46 -07:00
|
|
|
* Keep in sync with ChildrenFlags, StateFlags, ContextFlags, and AccTypes.
|
2012-12-10 19:31:42 -08:00
|
|
|
*/
|
2012-12-17 21:22:26 -08:00
|
|
|
uint32_t mChildrenFlags : kChildrenFlagsBits;
|
|
|
|
uint32_t mStateFlags : kStateFlagsBits;
|
2014-03-31 07:30:46 -07:00
|
|
|
uint32_t mContextFlags : kContextFlagsBits;
|
2012-12-17 21:22:26 -08:00
|
|
|
uint32_t mType : kTypeBits;
|
|
|
|
uint32_t mGenericTypes : kGenericTypesBits;
|
|
|
|
|
|
|
|
void StaticAsserts() const;
|
2014-09-02 11:54:04 -07:00
|
|
|
void AssertInMutatingSubtree() const;
|
2011-01-27 21:15:04 -08:00
|
|
|
|
2012-06-12 07:30:59 -07:00
|
|
|
friend class DocAccessible;
|
2014-09-16 10:30:23 -07:00
|
|
|
friend class xpcAccessible;
|
2014-09-02 11:54:04 -07:00
|
|
|
friend class AutoTreeMutation;
|
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-11-17 18:01:44 -08:00
|
|
|
friend class EmbeddedObjCollector;
|
2010-08-15 04:28:49 -07:00
|
|
|
|
2015-01-19 13:34:14 -08:00
|
|
|
union
|
|
|
|
{
|
|
|
|
AccGroupInfo* groupInfo;
|
|
|
|
ProxyAccessible* proxy;
|
|
|
|
} mBits;
|
2010-07-02 20:11:35 -07:00
|
|
|
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;
|
2013-10-28 20:30:55 -07:00
|
|
|
|
|
|
|
private:
|
2015-01-06 15:35:02 -08:00
|
|
|
Accessible() = delete;
|
|
|
|
Accessible(const Accessible&) = delete;
|
|
|
|
Accessible& operator =(const Accessible&) = delete;
|
2013-10-28 20:30:55 -07:00
|
|
|
|
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
|
|
|
|
2014-05-21 21:06:05 -07:00
|
|
|
static uint32_t AccelModifier();
|
|
|
|
|
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) :
|
2012-12-09 09:23:19 -08:00
|
|
|
mKey(aKey), mModifierMask(aModifierMask) {}
|
2011-07-19 01:30:24 -07:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-09-02 11:54:04 -07:00
|
|
|
/**
|
|
|
|
* This class makes sure required tasks are done before and after tree
|
|
|
|
* mutations. Currently this only includes group info invalidation. You must
|
|
|
|
* have an object of this class on the stack when calling methods that mutate
|
|
|
|
* the accessible tree.
|
|
|
|
*/
|
|
|
|
class AutoTreeMutation
|
|
|
|
{
|
|
|
|
public:
|
2014-10-10 14:28:35 -07:00
|
|
|
explicit AutoTreeMutation(Accessible* aRoot, bool aInvalidationRequired = true) :
|
2014-09-02 11:54:04 -07:00
|
|
|
mInvalidationRequired(aInvalidationRequired), mRoot(aRoot)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(mRoot->mStateFlags & Accessible::eSubtreeMutating));
|
|
|
|
mRoot->mStateFlags |= Accessible::eSubtreeMutating;
|
|
|
|
}
|
|
|
|
~AutoTreeMutation()
|
|
|
|
{
|
|
|
|
if (mInvalidationRequired)
|
|
|
|
mRoot->InvalidateChildrenGroupInfo();
|
|
|
|
|
|
|
|
MOZ_ASSERT(mRoot->mStateFlags & Accessible::eSubtreeMutating);
|
|
|
|
mRoot->mStateFlags &= ~Accessible::eSubtreeMutating;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mInvalidationRequired;
|
|
|
|
private:
|
|
|
|
Accessible* mRoot;
|
|
|
|
};
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-07-16 07:15:03 -07:00
|
|
|
#endif
|