Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / accessible / src / html / nsHTMLTextAccessible.h
blobdffc8ed093ce772704a2def5b34ca3422140af39
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Aaron Leventhal (aaronl@netscape.com)
24 * Kyle Yuan (kyle.yuan@sun.com)
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef _nsHTMLTextAccessible_H_
41 #define _nsHTMLTextAccessible_H_
43 #include "nsTextAccessibleWrap.h"
44 #include "nsAutoPtr.h"
45 #include "nsBaseWidgetAccessible.h"
47 class nsIWeakReference;
49 class nsHTMLTextAccessible : public nsTextAccessibleWrap
51 public:
52 nsHTMLTextAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
54 // nsIAccessible
55 NS_IMETHOD GetName(nsAString& aName);
56 NS_IMETHOD GetRole(PRUint32 *aRole);
58 // nsAccessible
59 virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
60 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
63 class nsHTMLHRAccessible : public nsLeafAccessible
65 public:
66 nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
67 NS_IMETHOD GetRole(PRUint32 *aRole);
70 class nsHTMLBRAccessible : public nsLeafAccessible
72 public:
73 nsHTMLBRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
75 // nsIAccessible
76 NS_IMETHOD GetRole(PRUint32 *aRole);
78 // nsAccessible
79 virtual nsresult GetNameInternal(nsAString& aName);
80 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
83 class nsHTMLLabelAccessible : public nsTextAccessible
85 public:
86 nsHTMLLabelAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
88 NS_DECL_ISUPPORTS_INHERITED
90 // nsIAccessible
91 NS_IMETHOD GetRole(PRUint32 *_retval);
92 NS_IMETHOD GetFirstChild(nsIAccessible **aFirstChild);
93 NS_IMETHOD GetLastChild(nsIAccessible **aLastChild);
94 NS_IMETHOD GetChildCount(PRInt32 *aAccChildCount);
96 // nsAccessible
97 virtual nsresult GetNameInternal(nsAString& aName);
98 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
101 class nsHTMLListBulletAccessible : public nsLeafAccessible
103 public:
104 nsHTMLListBulletAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
105 const nsAString& aBulletText);
107 // nsIAccessNode
108 NS_IMETHOD GetUniqueID(void **aUniqueID);
110 // nsIAccessible
111 NS_IMETHOD GetRole(PRUint32 *aRole);
112 NS_IMETHOD GetName(nsAString& aName);
114 // Don't cache via unique ID -- bullet accessible shares the same dom node as
115 // this LI accessible. Also, don't cache via mParent/SetParent(), prevent
116 // circular reference since li holds onto us.
117 NS_IMETHOD SetParent(nsIAccessible *aParentAccessible);
118 NS_IMETHOD GetParent(nsIAccessible **aParentAccessible);
120 // nsAccessNode
121 virtual nsresult Shutdown();
123 // nsAccessible
124 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
126 // nsPIAccessible
127 NS_IMETHOD AppendTextTo(nsAString& aText, PRUint32 aStartOffset, PRUint32 aLength);
129 protected:
130 // XXX: Ideally we'd get the bullet text directly from the bullet frame via
131 // nsBulletFrame::GetListItemText(), but we'd need an interface for getting
132 // text from contentless anonymous frames. Perhaps something like
133 // nsIAnonymousFrame::GetText() ? However, in practice storing the bullet text
134 // here should not be a problem if we invalidate the right parts of
135 // the accessibility cache when mutation events occur.
136 nsIAccessible *mWeakParent;
137 nsString mBulletText;
140 class nsHTMLListAccessible : public nsHyperTextAccessibleWrap
142 public:
143 nsHTMLListAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
144 nsHyperTextAccessibleWrap(aDOMNode, aShell) { }
146 // nsIAccessible
147 NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = nsIAccessibleRole::ROLE_LIST; return NS_OK; }
149 // nsAccessible
150 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
153 class nsHTMLLIAccessible : public nsLinkableAccessible
155 public:
156 nsHTMLLIAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell,
157 const nsAString& aBulletText);
159 // nsIAccessible
160 NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = nsIAccessibleRole::ROLE_LISTITEM; return NS_OK; }
161 NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
163 // nsAccessNode
164 virtual nsresult Shutdown();
166 // nsAccessible
167 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
169 protected:
170 void CacheChildren(); // Include bullet accessible
172 nsRefPtr<nsHTMLListBulletAccessible> mBulletAccessible;
175 #endif