1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_a11y_XULTreeGridAccessible_h__
8 #define mozilla_a11y_XULTreeGridAccessible_h__
10 #include "mozilla/a11y/TableAccessible.h"
11 #include "mozilla/a11y/TableCellAccessible.h"
12 #include "XULTreeAccessible.h"
17 class XULTreeGridCellAccessible
;
20 * Represents accessible for XUL tree in the case when it has multiple columns.
22 class XULTreeGridAccessible
: public XULTreeAccessible
, public TableAccessible
{
24 XULTreeGridAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
,
25 nsTreeBodyFrame
* aTreeFrame
)
26 : XULTreeAccessible(aContent
, aDoc
, aTreeFrame
) {
27 mGenericTypes
|= eTable
;
31 virtual uint32_t ColCount() const override
;
32 virtual uint32_t RowCount() override
;
33 virtual LocalAccessible
* CellAt(uint32_t aRowIndex
,
34 uint32_t aColumnIndex
) override
;
35 virtual void ColDescription(uint32_t aColIdx
,
36 nsString
& aDescription
) override
;
37 virtual bool IsColSelected(uint32_t aColIdx
) override
;
38 virtual bool IsRowSelected(uint32_t aRowIdx
) override
;
39 virtual bool IsCellSelected(uint32_t aRowIdx
, uint32_t aColIdx
) override
;
40 virtual uint32_t SelectedCellCount() override
;
41 virtual uint32_t SelectedColCount() override
;
42 virtual uint32_t SelectedRowCount() override
;
43 virtual void SelectedCells(nsTArray
<Accessible
*>* aCells
) override
;
44 virtual void SelectedCellIndices(nsTArray
<uint32_t>* aCells
) override
;
45 virtual void SelectedColIndices(nsTArray
<uint32_t>* aCols
) override
;
46 virtual void SelectedRowIndices(nsTArray
<uint32_t>* aRows
) override
;
47 virtual LocalAccessible
* AsAccessible() override
{ return this; }
49 virtual int32_t CellIndexAt(uint32_t aRowIdx
, uint32_t aColIdx
) override
{
50 return static_cast<int32_t>(ColCount() * aRowIdx
+ aColIdx
);
53 virtual int32_t ColIndexAt(uint32_t aCellIdx
) override
;
54 virtual int32_t RowIndexAt(uint32_t aCellIdx
) override
;
55 virtual void RowAndColIndicesAt(uint32_t aCellIdx
, int32_t* aRowIdx
,
56 int32_t* aColIdx
) override
;
59 virtual TableAccessible
* AsTable() override
{ return this; }
60 virtual a11y::role
NativeRole() const override
;
63 virtual ~XULTreeGridAccessible();
66 virtual already_AddRefed
<XULTreeItemAccessibleBase
> CreateTreeItemAccessible(
67 int32_t aRow
) const override
;
71 * Represents accessible for XUL tree item in the case when XUL tree has
74 class XULTreeGridRowAccessible final
: public XULTreeItemAccessibleBase
{
76 using LocalAccessible::LocalChildAt
;
78 XULTreeGridRowAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
,
79 LocalAccessible
* aParent
, dom::XULTreeElement
* aTree
,
80 nsITreeView
* aTreeView
, int32_t aRow
);
82 // nsISupports and cycle collection
83 NS_DECL_ISUPPORTS_INHERITED
84 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridRowAccessible
,
85 XULTreeItemAccessibleBase
)
88 virtual void Shutdown() override
;
89 virtual a11y::role
NativeRole() const override
;
90 virtual ENameValueFlag
Name(nsString
& aName
) const override
;
91 virtual LocalAccessible
* LocalChildAtPoint(
92 int32_t aX
, int32_t aY
, EWhichChildAtPoint aWhichChild
) override
;
94 virtual LocalAccessible
* LocalChildAt(uint32_t aIndex
) const override
;
95 virtual uint32_t ChildCount() const override
;
97 // XULTreeItemAccessibleBase
98 XULTreeGridCellAccessible
* GetCellAccessible(
99 nsTreeColumn
* aColumn
) const final
;
100 virtual void RowInvalidated(int32_t aStartColIdx
,
101 int32_t aEndColIdx
) override
;
104 virtual ~XULTreeGridRowAccessible();
106 // XULTreeItemAccessibleBase
107 mutable nsRefPtrHashtable
<nsPtrHashKey
<const void>, XULTreeGridCellAccessible
>
112 * Represents an accessible for XUL tree cell in the case when XUL tree has
116 class XULTreeGridCellAccessible
: public LeafAccessible
,
117 public TableCellAccessible
{
119 XULTreeGridCellAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
,
120 XULTreeGridRowAccessible
* aRowAcc
,
121 dom::XULTreeElement
* aTree
, nsITreeView
* aTreeView
,
122 int32_t aRow
, nsTreeColumn
* aColumn
);
125 NS_DECL_ISUPPORTS_INHERITED
126 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridCellAccessible
,
130 virtual void Shutdown() override
;
131 virtual TableCellAccessible
* AsTableCell() override
{ return this; }
132 virtual nsRect
BoundsInAppUnits() const override
;
133 virtual nsIntRect
BoundsInCSSPixels() const override
;
134 virtual ENameValueFlag
Name(nsString
& aName
) const override
;
135 virtual Accessible
* FocusedChild() override
;
136 virtual already_AddRefed
<AccAttributes
> NativeAttributes() override
;
137 virtual int32_t IndexInParent() const override
;
138 virtual Relation
RelationByType(RelationType aType
) const override
;
139 virtual a11y::role
NativeRole() const override
;
140 virtual uint64_t NativeState() const override
;
141 virtual uint64_t NativeInteractiveState() const override
;
144 virtual bool HasPrimaryAction() const override
;
145 virtual void ActionNameAt(uint8_t aIndex
, nsAString
& aName
) override
;
147 // TableCellAccessible
148 virtual TableAccessible
* Table() const override
;
149 virtual uint32_t ColIdx() const override
;
150 virtual uint32_t RowIdx() const override
;
151 virtual void ColHeaderCells(nsTArray
<Accessible
*>* aHeaderCells
) override
;
152 virtual void RowHeaderCells(nsTArray
<Accessible
*>* aCells
) override
{}
153 virtual bool Selected() override
;
156 * Fire name or state change event if the accessible text or value has been
158 * @return true if name has changed
160 bool CellInvalidated();
163 virtual ~XULTreeGridCellAccessible();
166 virtual LocalAccessible
* GetSiblingAtOffset(
167 int32_t aOffset
, nsresult
* aError
= nullptr) const override
;
169 virtual void DispatchClickEvent(nsIContent
* aContent
,
170 uint32_t aActionIndex
) const override
;
172 // XULTreeGridCellAccessible
175 * Return true if value of cell can be modified.
177 bool IsEditable() const;
179 enum { eAction_Click
= 0 };
181 RefPtr
<dom::XULTreeElement
> mTree
;
182 nsITreeView
* mTreeView
;
185 RefPtr
<nsTreeColumn
> mColumn
;
187 nsString mCachedTextEquiv
;
191 } // namespace mozilla