michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_A11Y_ARIAGridAccessible_h_ michael@0: #define MOZILLA_A11Y_ARIAGridAccessible_h_ michael@0: michael@0: #include "nsIAccessibleTable.h" michael@0: michael@0: #include "HyperTextAccessibleWrap.h" michael@0: #include "TableAccessible.h" michael@0: #include "TableCellAccessible.h" michael@0: #include "xpcAccessibleTable.h" michael@0: #include "xpcAccessibleTableCell.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: /** michael@0: * Accessible for ARIA grid and treegrid. michael@0: */ michael@0: class ARIAGridAccessible : public AccessibleWrap, michael@0: public xpcAccessibleTable, michael@0: public nsIAccessibleTable, michael@0: public TableAccessible michael@0: { michael@0: public: michael@0: ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIAccessibleTable michael@0: NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::) michael@0: michael@0: // Accessible michael@0: virtual TableAccessible* AsTable() { return this; } michael@0: virtual void Shutdown(); michael@0: michael@0: // TableAccessible michael@0: virtual uint32_t ColCount(); michael@0: virtual uint32_t RowCount(); michael@0: virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex); michael@0: virtual bool IsColSelected(uint32_t aColIdx); michael@0: virtual bool IsRowSelected(uint32_t aRowIdx); michael@0: virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx); michael@0: virtual uint32_t SelectedCellCount(); michael@0: virtual uint32_t SelectedColCount(); michael@0: virtual uint32_t SelectedRowCount(); michael@0: virtual void SelectedCells(nsTArray* aCells); michael@0: virtual void SelectedCellIndices(nsTArray* aCells); michael@0: virtual void SelectedColIndices(nsTArray* aCols); michael@0: virtual void SelectedRowIndices(nsTArray* aRows); michael@0: virtual void SelectCol(uint32_t aColIdx); michael@0: virtual void SelectRow(uint32_t aRowIdx); michael@0: virtual void UnselectCol(uint32_t aColIdx); michael@0: virtual void UnselectRow(uint32_t aRowIdx); michael@0: virtual Accessible* AsAccessible() { return this; } michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * Return true if the given row index is valid. michael@0: */ michael@0: bool IsValidRow(int32_t aRow); michael@0: michael@0: /** michael@0: * Retrn true if the given column index is valid. michael@0: */ michael@0: bool IsValidColumn(int32_t aColumn); michael@0: michael@0: /** michael@0: * Return row accessible at the given row index. michael@0: */ michael@0: Accessible* GetRowAt(int32_t aRow); michael@0: michael@0: /** michael@0: * Return cell accessible at the given column index in the row. michael@0: */ michael@0: Accessible* GetCellInRowAt(Accessible* aRow, int32_t aColumn); michael@0: michael@0: /** michael@0: * Set aria-selected attribute value on DOM node of the given accessible. michael@0: * michael@0: * @param aAccessible [in] accessible michael@0: * @param aIsSelected [in] new value of aria-selected attribute michael@0: * @param aNotify [in, optional] specifies if DOM should be notified michael@0: * about attribute change (used internally). michael@0: */ michael@0: nsresult SetARIASelected(Accessible* aAccessible, bool aIsSelected, michael@0: bool aNotify = true); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * Accessible for ARIA gridcell and rowheader/columnheader. michael@0: */ michael@0: class ARIAGridCellAccessible : public HyperTextAccessibleWrap, michael@0: public nsIAccessibleTableCell, michael@0: public TableCellAccessible, michael@0: public xpcAccessibleTableCell michael@0: { michael@0: public: michael@0: ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIAccessibleTableCell michael@0: NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::) michael@0: michael@0: // Accessible michael@0: virtual TableCellAccessible* AsTableCell() { return this; } michael@0: virtual void Shutdown(); michael@0: virtual void ApplyARIAState(uint64_t* aState) const; michael@0: virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * Return a containing row. michael@0: */ michael@0: Accessible* Row() const michael@0: { michael@0: Accessible* row = Parent(); michael@0: return row && row->Role() == roles::ROW ? row : nullptr; michael@0: } michael@0: michael@0: /** michael@0: * Return a table for the given row. michael@0: */ michael@0: Accessible* TableFor(Accessible* aRow) const; michael@0: michael@0: /** michael@0: * Return index of the given row. michael@0: */ michael@0: int32_t RowIndexFor(Accessible* aRow) const; michael@0: michael@0: // TableCellAccessible michael@0: virtual TableAccessible* Table() const MOZ_OVERRIDE; michael@0: virtual uint32_t ColIdx() const MOZ_OVERRIDE; michael@0: virtual uint32_t RowIdx() const MOZ_OVERRIDE; michael@0: virtual bool Selected() MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif