CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / accessible / src / html / nsHTMLTextAccessible.h
blobed7988a218da71c080a4ec46440cfea9766417d6
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 /**
48 * Used for text nodes within HTML document.
50 class nsHTMLTextAccessible : public nsTextAccessibleWrap
52 public:
53 nsHTMLTextAccessible(nsIContent *aContent, nsIWeakReference *aShell);
55 // nsISupports
56 NS_DECL_ISUPPORTS_INHERITED
58 // nsIAccessible
59 NS_IMETHOD GetName(nsAString& aName);
61 // nsAccessible
62 virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
63 virtual PRUint32 NativeRole();
64 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
67 /**
68 * Used for HTML hr element.
70 class nsHTMLHRAccessible : public nsLeafAccessible
72 public:
73 nsHTMLHRAccessible(nsIContent *aContent, nsIWeakReference *aShell);
75 // nsAccessible
76 virtual PRUint32 NativeRole();
79 /**
80 * Used for HTML br element.
82 class nsHTMLBRAccessible : public nsLeafAccessible
84 public:
85 nsHTMLBRAccessible(nsIContent *aContent, nsIWeakReference *aShell);
87 // nsAccessible
88 virtual nsresult GetNameInternal(nsAString& aName);
89 virtual PRUint32 NativeRole();
90 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
93 /**
94 * Used for HTML label element.
96 class nsHTMLLabelAccessible : public nsHyperTextAccessibleWrap
98 public:
99 nsHTMLLabelAccessible(nsIContent *aContent, nsIWeakReference *aShell);
101 NS_DECL_ISUPPORTS_INHERITED
103 // nsAccessible
104 virtual nsresult GetNameInternal(nsAString& aName);
105 virtual PRUint32 NativeRole();
109 * Used for HTML output element.
111 class nsHTMLOutputAccessible : public nsHyperTextAccessibleWrap
113 public:
114 nsHTMLOutputAccessible(nsIContent* aContent, nsIWeakReference* aShell);
116 NS_DECL_ISUPPORTS_INHERITED
118 // nsIAccessible
119 NS_IMETHOD GetRelationByType(PRUint32 aRelationType,
120 nsIAccessibleRelation** aRelation);
122 // nsAccessible
123 virtual PRUint32 NativeRole();
124 virtual nsresult GetAttributesInternal(nsIPersistentProperties* aAttributes);
128 * Used for bullet of HTML list item element (for example, HTML li).
130 class nsHTMLListBulletAccessible : public nsLeafAccessible
132 public:
133 nsHTMLListBulletAccessible(nsIContent* aContent, nsIWeakReference* aShell);
135 // nsIAccessible
136 NS_IMETHOD GetName(nsAString& aName);
138 // nsAccessNode
139 virtual void Shutdown();
140 virtual bool IsPrimaryForNode() const;
142 // nsAccessible
143 virtual PRUint32 NativeRole();
144 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
145 virtual void AppendTextTo(nsAString& aText, PRUint32 aStartOffset = 0,
146 PRUint32 aLength = PR_UINT32_MAX);
148 protected:
149 // XXX: Ideally we'd get the bullet text directly from the bullet frame via
150 // nsBulletFrame::GetListItemText(), but we'd need an interface for getting
151 // text from contentless anonymous frames. Perhaps something like
152 // nsIAnonymousFrame::GetText() ? However, in practice storing the bullet text
153 // here should not be a problem if we invalidate the right parts of
154 // the accessibility cache when mutation events occur.
155 nsString mBulletText;
159 * Used for HTML list (like HTML ul).
161 class nsHTMLListAccessible : public nsHyperTextAccessibleWrap
163 public:
164 nsHTMLListAccessible(nsIContent *aContent, nsIWeakReference *aShell);
166 // nsISupports
167 NS_DECL_ISUPPORTS_INHERITED
169 // nsAccessible
170 virtual PRUint32 NativeRole();
171 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
175 * Used for HTML list item (e.g. HTML li).
177 class nsHTMLLIAccessible : public nsHyperTextAccessibleWrap
179 public:
180 nsHTMLLIAccessible(nsIContent* aContent, nsIWeakReference* aShell);
182 // nsISupports
183 NS_DECL_ISUPPORTS_INHERITED
185 // nsIAccessible
186 NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
188 // nsAccessNode
189 virtual void Shutdown();
191 // nsAccessible
192 virtual PRUint32 NativeRole();
193 virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
195 protected:
196 // nsAccessible
197 virtual void CacheChildren();
199 private:
200 nsRefPtr<nsHTMLListBulletAccessible> mBulletAccessible;
203 #endif