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
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.
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
52 nsHTMLTextAccessible(nsIDOMNode
* aDomNode
, nsIWeakReference
* aShell
);
55 NS_IMETHOD
GetName(nsAString
& aName
);
56 NS_IMETHOD
GetRole(PRUint32
*aRole
);
59 virtual nsresult
GetAttributesInternal(nsIPersistentProperties
*aAttributes
);
60 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
63 class nsHTMLHRAccessible
: public nsLeafAccessible
66 nsHTMLHRAccessible(nsIDOMNode
* aDomNode
, nsIWeakReference
* aShell
);
67 NS_IMETHOD
GetRole(PRUint32
*aRole
);
70 class nsHTMLBRAccessible
: public nsLeafAccessible
73 nsHTMLBRAccessible(nsIDOMNode
* aDomNode
, nsIWeakReference
* aShell
);
76 NS_IMETHOD
GetRole(PRUint32
*aRole
);
79 virtual nsresult
GetNameInternal(nsAString
& aName
);
80 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
83 class nsHTMLLabelAccessible
: public nsTextAccessible
86 nsHTMLLabelAccessible(nsIDOMNode
* aDomNode
, nsIWeakReference
* aShell
);
88 NS_DECL_ISUPPORTS_INHERITED
91 NS_IMETHOD
GetRole(PRUint32
*_retval
);
92 NS_IMETHOD
GetFirstChild(nsIAccessible
**aFirstChild
);
93 NS_IMETHOD
GetLastChild(nsIAccessible
**aLastChild
);
94 NS_IMETHOD
GetChildCount(PRInt32
*aAccChildCount
);
97 virtual nsresult
GetNameInternal(nsAString
& aName
);
98 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
101 class nsHTMLListBulletAccessible
: public nsLeafAccessible
104 nsHTMLListBulletAccessible(nsIDOMNode
*aDOMNode
, nsIWeakReference
* aShell
,
105 const nsAString
& aBulletText
);
108 NS_IMETHOD
GetUniqueID(void **aUniqueID
);
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
);
121 virtual nsresult
Shutdown();
124 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
127 NS_IMETHOD
AppendTextTo(nsAString
& aText
, PRUint32 aStartOffset
, PRUint32 aLength
);
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
143 nsHTMLListAccessible(nsIDOMNode
*aDOMNode
, nsIWeakReference
* aShell
):
144 nsHyperTextAccessibleWrap(aDOMNode
, aShell
) { }
147 NS_IMETHOD
GetRole(PRUint32
*aRole
) { *aRole
= nsIAccessibleRole::ROLE_LIST
; return NS_OK
; }
150 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
153 class nsHTMLLIAccessible
: public nsLinkableAccessible
156 nsHTMLLIAccessible(nsIDOMNode
*aDOMNode
, nsIWeakReference
* aShell
,
157 const nsAString
& aBulletText
);
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
);
164 virtual nsresult
Shutdown();
167 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
170 void CacheChildren(); // Include bullet accessible
172 nsRefPtr
<nsHTMLListBulletAccessible
> mBulletAccessible
;