1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_a11y_HTMLTableAccessible_h__
7 #define mozilla_a11y_HTMLTableAccessible_h__
9 #include "HyperTextAccessible.h"
11 class nsITableCellLayout
;
12 class nsTableCellFrame
;
13 class nsTableWrapperFrame
;
19 class HTMLTableAccessible
;
22 * HTML table cell accessible (html:td).
24 class HTMLTableCellAccessible
: public HyperTextAccessible
{
26 HTMLTableCellAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
);
29 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableCellAccessible
,
33 virtual a11y::role
NativeRole() const override
;
34 virtual uint64_t NativeState() const override
;
35 virtual uint64_t NativeInteractiveState() const override
;
36 virtual already_AddRefed
<AccAttributes
> NativeAttributes() override
;
39 virtual void DOMAttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
41 const nsAttrValue
* aOldValue
,
42 uint64_t aOldState
) override
;
43 // HTMLTableCellAccessible
45 HTMLTableAccessible
* Table() const;
46 uint32_t ColExtent() const;
47 uint32_t RowExtent() const;
49 static HTMLTableCellAccessible
* GetFrom(LocalAccessible
* aAcc
) {
50 if (aAcc
->IsHTMLTableCell()) {
51 return static_cast<HTMLTableCellAccessible
*>(aAcc
);
57 virtual ~HTMLTableCellAccessible() {}
61 * HTML table row/column header accessible (html:th or html:td@scope).
63 class HTMLTableHeaderCellAccessible
: public HTMLTableCellAccessible
{
65 HTMLTableHeaderCellAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
);
68 virtual a11y::role
NativeRole() const override
;
72 * HTML table row accessible (html:tr).
74 class HTMLTableRowAccessible
: public HyperTextAccessible
{
76 HTMLTableRowAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
77 : HyperTextAccessible(aContent
, aDoc
) {
78 mType
= eHTMLTableRowType
;
79 mGenericTypes
|= eTableRow
;
82 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableRowAccessible
,
86 virtual ~HTMLTableRowAccessible() {}
89 virtual ENameValueFlag
NativeName(nsString
& aName
) const override
;
93 * HTML table accessible (html:table).
96 // To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
97 // This allow release trunk builds to be used by testers to refine the
98 // data vs. layout heuristic
99 // #define SHOW_LAYOUT_HEURISTIC
101 class HTMLTableAccessible
: public HyperTextAccessible
{
103 HTMLTableAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
104 : HyperTextAccessible(aContent
, aDoc
) {
105 mType
= eHTMLTableType
;
106 mGenericTypes
|= eTable
;
109 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableAccessible
, HyperTextAccessible
)
111 // HTMLTableAccessible
112 LocalAccessible
* Caption() const;
113 uint32_t ColCount() const;
115 bool IsProbablyLayoutTable();
117 static HTMLTableAccessible
* GetFrom(LocalAccessible
* aAcc
) {
118 if (aAcc
->IsHTMLTable()) {
119 return static_cast<HTMLTableAccessible
*>(aAcc
);
125 virtual void Description(nsString
& aDescription
) const override
;
126 virtual uint64_t NativeState() const override
;
127 virtual already_AddRefed
<AccAttributes
> NativeAttributes() override
;
128 virtual Relation
RelationByType(RelationType aRelationType
) const override
;
130 virtual bool InsertChildAt(uint32_t aIndex
, LocalAccessible
* aChild
) override
;
133 virtual ~HTMLTableAccessible() {}
136 virtual ENameValueFlag
NativeName(nsString
& aName
) const override
;
138 virtual void DOMAttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
140 const nsAttrValue
* aOldValue
,
141 uint64_t aOldState
) override
;
143 // HTMLTableAccessible
145 #ifdef SHOW_LAYOUT_HEURISTIC
146 nsString mLayoutHeuristic
;
151 * Get table wrapper frame, or return null if there is no inner table.
153 nsTableWrapperFrame
* GetTableWrapperFrame() const;
157 * HTML caption accessible (html:caption).
159 class HTMLCaptionAccessible
: public HyperTextAccessible
{
161 HTMLCaptionAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
162 : HyperTextAccessible(aContent
, aDoc
) {
163 mType
= eHTMLCaptionType
;
167 virtual a11y::role
NativeRole() const override
;
168 virtual Relation
RelationByType(RelationType aRelationType
) const override
;
171 virtual ~HTMLCaptionAccessible() {}
175 } // namespace mozilla