no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / accessible / xul / XULTreeGridAccessible.h
blobcfb314d30ec0fde4cb0258ffa5a13cccd6e77b15
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"
14 namespace mozilla {
15 namespace a11y {
17 class XULTreeGridCellAccessible;
19 /**
20 * Represents accessible for XUL tree in the case when it has multiple columns.
22 class XULTreeGridAccessible : public XULTreeAccessible, public TableAccessible {
23 public:
24 XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc,
25 nsTreeBodyFrame* aTreeFrame)
26 : XULTreeAccessible(aContent, aDoc, aTreeFrame) {
27 mGenericTypes |= eTable;
30 // TableAccessible
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;
58 // LocalAccessible
59 virtual TableAccessible* AsTable() override { return this; }
60 virtual a11y::role NativeRole() const override;
62 protected:
63 virtual ~XULTreeGridAccessible();
65 // XULTreeAccessible
66 virtual already_AddRefed<XULTreeItemAccessibleBase> CreateTreeItemAccessible(
67 int32_t aRow) const override;
70 /**
71 * Represents accessible for XUL tree item in the case when XUL tree has
72 * multiple columns.
74 class XULTreeGridRowAccessible final : public XULTreeItemAccessibleBase {
75 public:
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)
87 // LocalAccessible
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;
103 protected:
104 virtual ~XULTreeGridRowAccessible();
106 // XULTreeItemAccessibleBase
107 mutable nsRefPtrHashtable<nsPtrHashKey<const void>, XULTreeGridCellAccessible>
108 mAccessibleCache;
112 * Represents an accessible for XUL tree cell in the case when XUL tree has
113 * multiple columns.
116 class XULTreeGridCellAccessible : public LeafAccessible,
117 public TableCellAccessible {
118 public:
119 XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
120 XULTreeGridRowAccessible* aRowAcc,
121 dom::XULTreeElement* aTree, nsITreeView* aTreeView,
122 int32_t aRow, nsTreeColumn* aColumn);
124 // nsISupports
125 NS_DECL_ISUPPORTS_INHERITED
126 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridCellAccessible,
127 LeafAccessible)
129 // LocalAccessible
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;
143 // ActionAccessible
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
157 * changed.
158 * @return true if name has changed
160 bool CellInvalidated();
162 protected:
163 virtual ~XULTreeGridCellAccessible();
165 // LocalAccessible
166 virtual LocalAccessible* GetSiblingAtOffset(
167 int32_t aOffset, nsresult* aError = nullptr) const override;
168 MOZ_CAN_RUN_SCRIPT
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;
184 int32_t mRow;
185 RefPtr<nsTreeColumn> mColumn;
187 nsString mCachedTextEquiv;
190 } // namespace a11y
191 } // namespace mozilla
193 #endif