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
|
|
|
|
2009-02-18 23:06:14 -08:00
|
|
|
#include "nsARIAMap.h"
|
|
|
|
#include "nsRelUtils.h"
|
|
|
|
#include "nsTextEquivUtils.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAccessible.h"
|
|
|
|
#include "nsPIAccessible.h"
|
|
|
|
#include "nsIAccessibleHyperLink.h"
|
|
|
|
#include "nsIAccessibleSelectable.h"
|
|
|
|
#include "nsIAccessibleValue.h"
|
2007-05-19 19:41:33 -07:00
|
|
|
#include "nsIAccessibleRole.h"
|
|
|
|
#include "nsIAccessibleStates.h"
|
2007-06-01 20:01:38 -07:00
|
|
|
#include "nsIAccessibleEvent.h"
|
2007-05-19 19:41:33 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsString.h"
|
2009-01-18 12:14:14 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMDOMStringList.h"
|
|
|
|
|
|
|
|
struct nsRect;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsIDOMNode;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIView;
|
|
|
|
|
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)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Saves a data member -- if child count equals this value we haven't
|
|
|
|
// cached children or child count yet
|
|
|
|
enum { eChildCountUninitialized = -1 };
|
|
|
|
|
|
|
|
class nsAccessibleDOMStringList : public nsIDOMDOMStringList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsAccessibleDOMStringList();
|
|
|
|
virtual ~nsAccessibleDOMStringList();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMDOMSTRINGLIST
|
|
|
|
|
|
|
|
PRBool Add(const nsAString& aName) {
|
2009-01-18 12:14:14 -08:00
|
|
|
return mNames.AppendElement(aName) != nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2009-01-18 12:14:14 -08:00
|
|
|
nsTArray<nsString> mNames;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
#define NS_ACCESSIBLE_IMPL_CID \
|
|
|
|
{ /* 4E36C7A8-9203-4ef9-B619-271DDF6BB839 */ \
|
|
|
|
0x4e36c7a8, \
|
|
|
|
0x9203, \
|
|
|
|
0x4ef9, \
|
|
|
|
{ 0xb6, 0x19, 0x27, 0x1d, 0xdf, 0x6b, 0xb8, 0x39 } \
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsAccessible : public nsAccessNodeWrap,
|
|
|
|
public nsIAccessible,
|
|
|
|
public nsPIAccessible,
|
|
|
|
public nsIAccessibleHyperLink,
|
|
|
|
public nsIAccessibleSelectable,
|
|
|
|
public nsIAccessibleValue
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
|
|
|
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_NSPIACCESSIBLE
|
|
|
|
NS_DECL_NSIACCESSIBLEHYPERLINK
|
|
|
|
NS_DECL_NSIACCESSIBLESELECTABLE
|
|
|
|
NS_DECL_NSIACCESSIBLEVALUE
|
2008-10-10 05:26:55 -07:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_CID)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-31 20:58:07 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessNode
|
|
|
|
|
|
|
|
virtual nsresult 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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
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);
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helper methods
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
already_AddRefed<nsIAccessible> GetParent() {
|
|
|
|
nsIAccessible *parent = nsnull;
|
|
|
|
GetParent(&parent);
|
|
|
|
return parent;
|
|
|
|
}
|
2007-11-11 17:05:37 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
PRBool MappedAttrState(nsIContent *aContent, PRUint32 *aStateInOut, nsStateMapEntry *aStateMapEntry);
|
|
|
|
virtual nsIFrame* GetBoundsFrame();
|
|
|
|
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
|
|
|
PRBool IsVisible(PRBool *aIsOffscreen);
|
|
|
|
|
2008-12-02 23:18:41 -08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name helpers.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2008-07-16 08:24:36 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Walk into subtree and calculate the string which is used as the accessible
|
|
|
|
* name or description.
|
|
|
|
*
|
|
|
|
* @param aContent [in] traversed content
|
|
|
|
* @param aFlatString [in, out] result string
|
|
|
|
* @param aIsRootHidden [in] specifies whether root content (we started to
|
|
|
|
* traverse from) is hidden, in this case the result
|
|
|
|
* string is calculated from hidden children
|
|
|
|
* (this is used when hidden root content is explicitly
|
|
|
|
* specified as label or description by author)
|
|
|
|
*/
|
|
|
|
nsresult AppendFlatStringFromSubtreeRecurse(nsIContent *aContent,
|
|
|
|
nsAString *aFlatString,
|
|
|
|
PRBool aIsRootHidden);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Helpers for dealing with children
|
|
|
|
virtual void CacheChildren();
|
|
|
|
|
|
|
|
// nsCOMPtr<>& is useful here, because getter_AddRefs() nulls the comptr's value, and NextChild
|
|
|
|
// depends on the passed-in comptr being null or already set to a child (finding the next sibling).
|
|
|
|
nsIAccessible *NextChild(nsCOMPtr<nsIAccessible>& aAccessible);
|
|
|
|
|
|
|
|
already_AddRefed<nsIAccessible> GetNextWithState(nsIAccessible *aStart, PRUint32 matchState);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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, the DOM node to start from
|
|
|
|
* @param aRequireLeaf, only accept leaf accessible nodes
|
|
|
|
* @return the resulting accessible
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIAccessible> GetFirstAvailableAccessible(nsIDOMNode *aStartNode, PRBool aRequireLeaf = PR_FALSE);
|
|
|
|
|
|
|
|
// Hyperlink helpers
|
|
|
|
virtual nsresult GetLinkOffset(PRInt32* aStartOffset, PRInt32* aEndOffset);
|
|
|
|
|
|
|
|
// For accessibles that have actions
|
|
|
|
static void DoCommandCallback(nsITimer *aTimer, void *aClosure);
|
|
|
|
nsresult DoCommand(nsIContent *aContent = nsnull);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2009-01-04 23:41:30 -08:00
|
|
|
/**
|
|
|
|
* Compute group attributes ('posinset', 'setsize' and 'level') based
|
|
|
|
* on accessible hierarchy. Used by GetAttributes() method if group attributes
|
|
|
|
* weren't provided by ARIA or by internal accessible implementation.
|
|
|
|
*
|
|
|
|
* @param aRole [in] role of this accessible
|
|
|
|
* @param aAttributes [in, out] object attributes
|
|
|
|
*/
|
|
|
|
nsresult ComputeGroupAttributes(PRUint32 aRole,
|
|
|
|
nsIPersistentProperties *aAttributes);
|
|
|
|
|
2008-06-15 23:16:18 -07:00
|
|
|
/**
|
|
|
|
* Fires platform accessible event. It's notification method only. It does
|
|
|
|
* change nothing on Gecko side. Mostly you should use
|
|
|
|
* nsIAccessible::FireAccessibleEvent excepting special cases like we have
|
|
|
|
* in xul:tree accessible to lie to AT. Must be overridden in wrap classes.
|
|
|
|
*
|
|
|
|
* @param aEvent the accessible event to fire.
|
|
|
|
*/
|
|
|
|
virtual nsresult FirePlatformEvent(nsIAccessibleEvent *aEvent) = 0;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Data Members
|
|
|
|
nsCOMPtr<nsIAccessible> mParent;
|
2008-08-06 05:19:56 -07:00
|
|
|
nsCOMPtr<nsIAccessible> mFirstChild;
|
|
|
|
nsCOMPtr<nsIAccessible> mNextSibling;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRoleMapEntry *mRoleMapEntry; // Non-null indicates author-supplied role; possibly state & value as well
|
|
|
|
PRInt32 mAccChildCount;
|
|
|
|
};
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsAccessible,
|
|
|
|
NS_ACCESSIBLE_IMPL_CID)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|