2007-11-11 17:05:37 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2007-03-22 10:30:00 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* John Gaunt (jgaunt@netscape.com)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef _nsAccessible_H_
|
|
|
|
#define _nsAccessible_H_
|
|
|
|
|
|
|
|
#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 "nsIAccessibleRole.h"
|
|
|
|
#include "nsIAccessibleStates.h"
|
|
|
|
|
2010-12-01 00:53:17 -08:00
|
|
|
#include "nsARIAMap.h"
|
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
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
class AccGroupInfo;
|
2010-08-15 04:28:49 -07:00
|
|
|
class EmbeddedObjCollector;
|
2010-04-26 23:52:03 -07:00
|
|
|
class nsAccessible;
|
2010-08-24 19:08:28 -07:00
|
|
|
class AccEvent;
|
2010-04-26 23:52:03 -07:00
|
|
|
struct nsRoleMapEntry;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct nsRect;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIView;
|
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsAccessible>
|
|
|
|
nsAccessibleHashtable;
|
|
|
|
|
2008-12-16 08:13:49 -08:00
|
|
|
// see nsAccessible::GetAttrValue
|
2007-08-03 22:27:27 -07:00
|
|
|
#define NS_OK_NO_ARIA_VALUE \
|
|
|
|
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x21)
|
|
|
|
|
2008-12-16 08:13:49 -08:00
|
|
|
// see nsAccessible::GetNameInternal
|
|
|
|
#define NS_OK_EMPTY_NAME \
|
|
|
|
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x23)
|
|
|
|
|
2009-02-27 02:54:39 -08:00
|
|
|
// see nsAccessible::GetNameInternal
|
|
|
|
#define NS_OK_NAME_FROM_TOOLTIP \
|
|
|
|
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x25)
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsAccessible : public nsAccessNodeWrap,
|
|
|
|
public nsIAccessible,
|
|
|
|
public nsIAccessibleHyperLink,
|
|
|
|
public nsIAccessibleSelectable,
|
|
|
|
public nsIAccessibleValue
|
|
|
|
{
|
|
|
|
public:
|
2010-06-11 01:23:18 -07:00
|
|
|
nsAccessible(nsIContent *aContent, nsIWeakReference *aShell);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsAccessible();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2008-08-06 05:19:56 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsAccessible, nsAccessNode)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2009-06-24 19:12:38 -07:00
|
|
|
* @param [in/out] where to fill the extra states into
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2009-06-24 19:12:38 -07:00
|
|
|
virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);
|
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
|
|
|
/**
|
|
|
|
* Return enumerated accessible role (see constants in nsIAccessibleRole).
|
|
|
|
*/
|
2010-12-01 00:53:17 -08:00
|
|
|
inline PRUint32 Role()
|
|
|
|
{
|
|
|
|
if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
|
|
|
|
return NativeRole();
|
|
|
|
|
|
|
|
return ARIARoleInternal();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return accessible role specified by ARIA (see constants in
|
|
|
|
* nsIAccessibleRole).
|
|
|
|
*/
|
|
|
|
inline PRUint32 ARIARole()
|
|
|
|
{
|
|
|
|
if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
|
|
|
|
return nsIAccessibleRole::ROLE_NOTHING;
|
|
|
|
|
|
|
|
return ARIARoleInternal();
|
|
|
|
}
|
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
|
|
|
|
* nsIAccessibleRole). Doesn't take into account ARIA roles.
|
|
|
|
*/
|
2010-09-04 19:14:01 -07:00
|
|
|
virtual PRUint32 NativeRole();
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2007-04-02 08:56:24 -07:00
|
|
|
/**
|
|
|
|
* Return the state of accessible that doesn't take into account ARIA states.
|
2008-11-03 19:37:46 -08:00
|
|
|
* Use nsIAccessible::state to get all states for accessible. If
|
2007-04-02 08:56:24 -07:00
|
|
|
* second argument is omitted then second bit field of accessible state won't
|
|
|
|
* be calculated.
|
|
|
|
*/
|
2008-11-03 19:37:46 -08:00
|
|
|
virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
|
2007-04-02 08:56:24 -07:00
|
|
|
|
2007-04-07 02:07:24 -07:00
|
|
|
/**
|
|
|
|
* Returns attributes for accessible without explicitly setted ARIA
|
|
|
|
* attributes.
|
|
|
|
*/
|
|
|
|
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
|
|
|
|
|
2009-05-11 03:57:28 -07:00
|
|
|
/**
|
|
|
|
* Return direct or deepest child at the given point.
|
|
|
|
*
|
|
|
|
* @param aX [in] x coordinate relative screen
|
|
|
|
* @param aY [in] y coordinate relative screen
|
|
|
|
* @param aDeepestChild [in] flag points if deep child should be returned
|
|
|
|
* @param aChild [out] found child
|
|
|
|
*/
|
|
|
|
virtual nsresult GetChildAtPoint(PRInt32 aX, PRInt32 aY,
|
|
|
|
PRBool aDeepestChild,
|
|
|
|
nsIAccessible **aChild);
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
/**
|
|
|
|
* Return calculated group level based on accessible hierarchy.
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetLevelInternal();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
|
|
|
|
PRInt32 *aSetSize);
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @param aRoleMapEntry The ARIA nsRoleMapEntry* for the accessible, or
|
|
|
|
* nsnull if none.
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
PRBool EnsureChildren();
|
|
|
|
|
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
|
|
|
*/
|
2010-07-01 18:22:41 -07:00
|
|
|
virtual PRBool AppendChild(nsAccessible* aChild);
|
|
|
|
virtual PRBool InsertChildAt(PRUint32 aIndex, nsAccessible* aChild);
|
|
|
|
virtual PRBool RemoveChild(nsAccessible* 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
|
|
|
*/
|
2011-01-17 20:14:47 -08:00
|
|
|
virtual nsAccessible* GetParent();
|
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
|
|
|
*/
|
2010-01-11 06:14:06 -08:00
|
|
|
virtual nsAccessible* GetChildAt(PRUint32 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
|
|
|
*/
|
2009-12-10 11:12:19 -08:00
|
|
|
virtual PRInt32 GetChildCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index of the given child accessible.
|
|
|
|
*/
|
2010-07-01 18:22:41 -07:00
|
|
|
virtual PRInt32 GetIndexOf(nsAccessible* aChild);
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index in parent accessible.
|
|
|
|
*/
|
2010-07-01 18:22:41 -07:00
|
|
|
virtual PRInt32 GetIndexInParent();
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2010-05-21 04:27:00 -07:00
|
|
|
/**
|
|
|
|
* Return true if accessible has children;
|
|
|
|
*/
|
|
|
|
PRBool HasChildren() { return !!GetChildAt(0); }
|
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
/**
|
|
|
|
* Return embedded accessible children count.
|
|
|
|
*/
|
|
|
|
PRInt32 GetEmbeddedChildCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return embedded accessible child at the given index.
|
|
|
|
*/
|
|
|
|
nsAccessible* GetEmbeddedChildAt(PRUint32 aIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return index of the given embedded accessible child.
|
|
|
|
*/
|
|
|
|
PRInt32 GetIndexOfEmbeddedChild(nsAccessible* aChild);
|
|
|
|
|
2009-06-18 00:37:38 -07:00
|
|
|
/**
|
2010-06-30 19:18:08 -07:00
|
|
|
* Return cached accessible of parent-child relatives.
|
2009-06-18 00:37:38 -07:00
|
|
|
*/
|
2010-06-30 19:18:08 -07:00
|
|
|
nsAccessible* GetCachedParent() const { return mParent; }
|
2010-07-01 18:49:42 -07:00
|
|
|
nsAccessible* GetCachedNextSibling() const
|
|
|
|
{
|
|
|
|
return mParent ?
|
2010-07-02 03:55:43 -07:00
|
|
|
mParent->mChildren.SafeElementAt(mIndexInParent + 1, nsnull).get() : nsnull;
|
2010-07-01 18:49:42 -07:00
|
|
|
}
|
|
|
|
nsAccessible* GetCachedPrevSibling() const
|
|
|
|
{
|
|
|
|
return mParent ?
|
2010-07-02 03:55:43 -07:00
|
|
|
mParent->mChildren.SafeElementAt(mIndexInParent - 1, nsnull).get() : nsnull;
|
2010-07-01 18:49:42 -07:00
|
|
|
}
|
2010-07-01 18:22:41 -07:00
|
|
|
PRUint32 GetCachedChildCount() const { return mChildren.Length(); }
|
2010-10-20 21:16:10 -07:00
|
|
|
nsAccessible* GetCachedChildAt(PRUint32 aIndex) const { return mChildren.ElementAt(aIndex); }
|
2010-08-15 04:28:49 -07:00
|
|
|
PRBool AreChildrenCached() const { return mChildrenFlags != eChildrenUninitialized; }
|
2010-10-20 21:16:10 -07: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
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if there are accessible children in anonymous content
|
|
|
|
*/
|
|
|
|
virtual PRBool GetAllowsAnonChildAccessibles();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns text of accessible if accessible has text role otherwise empty
|
|
|
|
* string.
|
|
|
|
*
|
|
|
|
* @param aText returned text of the accessible
|
|
|
|
* @param aStartOffset start offset inside of the accesible
|
|
|
|
* @param aLength required lenght of text
|
|
|
|
*/
|
|
|
|
virtual nsresult AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
|
|
|
|
PRUint32 aLength);
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
void TestChildCache(nsAccessible *aCachedChild);
|
|
|
|
|
2010-08-31 20:26:13 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HyperLinkAccessible
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the accessible is hyper link accessible.
|
|
|
|
*/
|
|
|
|
virtual bool IsHyperLink();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the start offset of the link within the parent accessible.
|
|
|
|
*/
|
|
|
|
virtual PRUint32 StartOffset();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the end offset of the link within the parent accessible.
|
|
|
|
*/
|
|
|
|
virtual PRUint32 EndOffset();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the link is valid (e. g. points to a valid URL).
|
|
|
|
*/
|
|
|
|
virtual bool IsValid();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the link currently has the focus.
|
|
|
|
*/
|
|
|
|
virtual bool IsSelected();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the number of anchors within the link.
|
|
|
|
*/
|
|
|
|
virtual PRUint32 AnchorCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an anchor accessible at the given index.
|
|
|
|
*/
|
|
|
|
virtual nsAccessible* GetAnchor(PRUint32 aAnchorIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an anchor URI at the given index.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<nsIURI> GetAnchorURI(PRUint32 aAnchorIndex);
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
virtual PRUint32 SelectedItemCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return selected item at the given index.
|
|
|
|
*/
|
|
|
|
virtual nsAccessible* GetSelectedItem(PRUint32 aIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if item at the given index is selected.
|
|
|
|
*/
|
|
|
|
virtual bool IsItemSelected(PRUint32 aIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add item at the given index the selection. Return true if success.
|
|
|
|
*/
|
|
|
|
virtual bool AddItemToSelection(PRUint32 aIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove item at the given index from the selection. Return if success.
|
|
|
|
*/
|
|
|
|
virtual bool RemoveItemFromSelection(PRUint32 aIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select all items. Return true if success.
|
|
|
|
*/
|
|
|
|
virtual bool SelectAll();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unselect all items. Return true if success.
|
|
|
|
*/
|
|
|
|
virtual bool UnselectAll();
|
|
|
|
|
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.
|
|
|
|
*/
|
2010-11-12 11:01:04 -08:00
|
|
|
virtual void BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent);
|
2010-07-16 07:15:03 -07:00
|
|
|
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.
|
|
|
|
*/
|
2010-03-10 02:26:11 -08:00
|
|
|
virtual nsAccessible* GetSiblingAtOffset(PRInt32 aOffset,
|
|
|
|
nsresult *aError = nsnull);
|
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).
|
|
|
|
*/
|
|
|
|
PRUint32 ARIARoleInternal();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsIFrame* GetBoundsFrame();
|
|
|
|
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
|
|
|
PRBool IsVisible(PRBool *aIsOffscreen);
|
|
|
|
|
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);
|
|
|
|
static nsresult GetTranslatedString(const nsAString& aKey, 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
|
|
|
*/
|
2010-06-11 01:23:18 -07:00
|
|
|
nsAccessible *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
|
|
|
|
*/
|
2010-01-25 07:09:25 -08:00
|
|
|
void DoCommand(nsIContent *aContent = nsnull, PRUint32 aActionIndex = 0);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch click event.
|
|
|
|
*/
|
|
|
|
virtual void DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex);
|
|
|
|
|
2010-01-25 07:08:08 -08:00
|
|
|
NS_DECL_RUNNABLEMETHOD_ARG2(nsAccessible, DispatchClickEvent,
|
|
|
|
nsCOMPtr<nsIContent>, PRUint32)
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Check the visibility across both parent content and chrome
|
|
|
|
PRBool CheckVisibilityInParentChain(nsIDocument* aDocument, nsIView* aView);
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
nsIDOMNode* GetAtomicRegion();
|
|
|
|
|
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
|
|
|
|
* (see nsARIAMap.h). Used by GetNumActions() and GetActionName().
|
|
|
|
*
|
|
|
|
* @param aStates [in] states of the accessible
|
|
|
|
*/
|
|
|
|
PRUint32 GetActionRule(PRUint32 aStates);
|
|
|
|
|
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
|
2010-01-11 06:14:06 -08:00
|
|
|
nsRefPtr<nsAccessible> mParent;
|
|
|
|
nsTArray<nsRefPtr<nsAccessible> > mChildren;
|
2010-07-01 18:22:41 -07:00
|
|
|
PRInt32 mIndexInParent;
|
2008-08-06 05:19:56 -07:00
|
|
|
|
2010-08-15 04:28:49 -07:00
|
|
|
enum ChildrenFlags {
|
|
|
|
eChildrenUninitialized = 0x00,
|
|
|
|
eMixedChildren = 0x01,
|
|
|
|
eEmbeddedChildren = 0x02
|
|
|
|
};
|
|
|
|
ChildrenFlags mChildrenFlags;
|
|
|
|
|
|
|
|
nsAutoPtr<EmbeddedObjCollector> mEmbeddedObjCollector;
|
|
|
|
PRInt32 mIndexOfEmbeddedChild;
|
|
|
|
friend class EmbeddedObjCollector;
|
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
nsAutoPtr<AccGroupInfo> mGroupInfo;
|
|
|
|
friend class AccGroupInfo;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRoleMapEntry *mRoleMapEntry; // Non-null indicates author-supplied role; possibly state & value as well
|
|
|
|
};
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsAccessible,
|
2010-04-26 23:52:03 -07:00
|
|
|
NS_ACCESSIBLE_IMPL_IID)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-16 07:15:03 -07:00
|
|
|
#endif
|