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 * Author: Aaron Leventhal (aaronl@netscape.com)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef _nsHTMLTableAccessible_H_
40 #define _nsHTMLTableAccessible_H_
42 #include "nsBaseWidgetAccessible.h"
43 #include "nsIAccessibleTable.h"
45 class nsHTMLTableCellAccessible
: public nsHyperTextAccessibleWrap
48 nsHTMLTableCellAccessible(nsIDOMNode
* aDomNode
, nsIWeakReference
* aShell
);
50 NS_DECL_ISUPPORTS_INHERITED
53 NS_IMETHOD
GetRole(PRUint32
*aRole
);
56 virtual nsresult
GetAttributesInternal(nsIPersistentProperties
*aAttributes
);
61 // To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
62 // This allow release trunk builds to be used by testers to refine the
63 // data vs. layout heuristic
64 // #define SHOW_LAYOUT_HEURISTIC
66 class nsHTMLTableAccessible
: public nsAccessibleWrap
,
67 public nsIAccessibleTable
70 nsHTMLTableAccessible(nsIDOMNode
* aDomNode
, nsIWeakReference
* aShell
);
72 NS_DECL_ISUPPORTS_INHERITED
73 NS_DECL_NSIACCESSIBLETABLE
76 NS_IMETHOD
GetRole(PRUint32
*aResult
);
77 NS_IMETHOD
GetDescription(nsAString
& aDescription
);
78 NS_IMETHOD
GetAccessibleRelated(PRUint32 aRelationType
, nsIAccessible
**aRelated
);
81 virtual nsresult
GetNameInternal(nsAString
& aName
);
82 virtual nsresult
GetStateInternal(PRUint32
*aState
, PRUint32
*aExtraState
);
83 virtual nsresult
GetAttributesInternal(nsIPersistentProperties
*aAttributes
);
85 // nsHTMLTableAccessible
88 * Returns true if the column index is in the valid column range.
90 * @param aColumn The index to check for validity.
92 PRBool
IsValidColumn(PRInt32 aColumn
);
95 * Returns true if the given index is in the valid row range.
97 * @param aRow The index to check for validity.
99 PRBool
IsValidRow(PRInt32 aRow
);
104 * Selects or unselects row or column.
106 * @param aIndex - index of row or column to be selected
107 * @param aTarget - indicates what should be selected, either row or column
108 * (see nsISelectionPrivate)
109 * @param aDoSelect - indicates whether row or column should selected or
112 nsresult
SelectRowOrColumn(PRInt32 aIndex
, PRUint32 aTarget
, PRBool aDoSelect
);
115 * Selects or unselects the cell.
117 * @param aSelection - the selection of document
118 * @param aDocument - the document that contains the cell
119 * @param aCellElement - the cell of table
120 * @param aDoSelect - indicates whether cell should be selected or unselected
122 nsresult
SelectCell(nsISelection
*aSelection
, nsIDocument
*aDocument
,
123 nsIDOMElement
*aCellElement
, PRBool aDoSelect
);
125 virtual void CacheChildren();
126 nsresult
GetTableNode(nsIDOMNode
**_retval
);
127 nsresult
GetTableLayout(nsITableLayout
**aLayoutObject
);
128 nsresult
GetCellAt(PRInt32 aRowIndex
,
130 nsIDOMElement
* &aCell
);
131 PRBool
HasDescendant(char *aTagName
, PRBool aAllowEmpty
= PR_TRUE
);
132 #ifdef SHOW_LAYOUT_HEURISTIC
133 nsAutoString mLayoutHeuristic
;
137 class nsHTMLTableHeadAccessible
: public nsHTMLTableAccessible
140 NS_DECL_ISUPPORTS_INHERITED
142 nsHTMLTableHeadAccessible(nsIDOMNode
*aDomNode
, nsIWeakReference
*aShell
);
145 NS_IMETHOD
GetRole(PRUint32
*aResult
);
147 /* nsIAccessibleTable */
148 NS_IMETHOD
GetCaption(nsIAccessible
**aCaption
);
149 NS_IMETHOD
GetSummary(nsAString
&aSummary
);
150 NS_IMETHOD
GetColumnHeader(nsIAccessibleTable
**aColumnHeader
);
151 NS_IMETHOD
GetRows(PRInt32
*aRows
);
154 class nsHTMLCaptionAccessible
: public nsHyperTextAccessibleWrap
157 nsHTMLCaptionAccessible(nsIDOMNode
*aDomNode
, nsIWeakReference
*aShell
) :
158 nsHyperTextAccessibleWrap(aDomNode
, aShell
) { }
161 NS_IMETHOD
GetRole(PRUint32
*aRole
)
162 { *aRole
= nsIAccessibleRole::ROLE_CAPTION
; return NS_OK
; }
163 NS_IMETHOD
GetAccessibleRelated(PRUint32 aRelationType
, nsIAccessible
**aRelated
);