2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-07 05:47:49 -07:00
|
|
|
#ifndef mozilla_a11y_HTMLTableAccessible_h__
|
|
|
|
#define mozilla_a11y_HTMLTableAccessible_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-31 01:04:41 -07:00
|
|
|
#include "HyperTextAccessibleWrap.h"
|
2012-03-27 17:53:58 -07:00
|
|
|
#include "TableAccessible.h"
|
2012-07-24 08:58:25 -07:00
|
|
|
#include "TableCellAccessible.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
class nsITableLayout;
|
2009-09-10 18:07:56 -07:00
|
|
|
class nsITableCellLayout;
|
2009-05-13 22:31:09 -07:00
|
|
|
|
2012-06-07 05:47:49 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
/**
|
|
|
|
* HTML table cell accessible (html:td).
|
|
|
|
*/
|
2012-06-07 05:47:49 -07:00
|
|
|
class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
|
2014-10-21 17:49:28 -07:00
|
|
|
public TableCellAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-07 05:47:49 -07:00
|
|
|
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
2008-04-14 20:38:31 -07:00
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
// nsISupports
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual TableCellAccessible* AsTableCell() override { return this; }
|
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
|
|
|
virtual uint64_t NativeInteractiveState() const override;
|
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
|
2009-05-13 22:31:09 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
// TableCellAccessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual TableAccessible* Table() const override;
|
|
|
|
virtual uint32_t ColIdx() const override;
|
|
|
|
virtual uint32_t RowIdx() const override;
|
|
|
|
virtual uint32_t ColExtent() const override;
|
|
|
|
virtual uint32_t RowExtent() const override;
|
|
|
|
virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) override;
|
|
|
|
virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) override;
|
|
|
|
virtual bool Selected() override;
|
2012-08-08 23:24:31 -07:00
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~HTMLTableCellAccessible() {}
|
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
/**
|
2009-09-10 18:07:56 -07:00
|
|
|
* Return nsITableCellLayout of the table cell frame.
|
2009-05-13 22:31:09 -07:00
|
|
|
*/
|
2012-08-08 23:24:31 -07:00
|
|
|
nsITableCellLayout* GetCellLayout() const;
|
2009-05-13 22:31:09 -07:00
|
|
|
|
|
|
|
/**
|
2009-09-10 18:07:56 -07:00
|
|
|
* Return row and column indices of the cell.
|
2009-05-13 22:31:09 -07:00
|
|
|
*/
|
2012-08-08 23:24:31 -07:00
|
|
|
nsresult GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* HTML table row/column header accessible (html:th or html:td@scope).
|
|
|
|
*/
|
2012-06-07 05:47:49 -07:00
|
|
|
class HTMLTableHeaderCellAccessible : public HTMLTableCellAccessible
|
2009-05-13 22:31:09 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-07 05:47:49 -07:00
|
|
|
HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
2009-05-13 22:31:09 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
2009-05-13 22:31:09 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-29 23:33:01 -08:00
|
|
|
/**
|
|
|
|
* HTML table row accessible (html:tr).
|
|
|
|
*/
|
|
|
|
class HTMLTableRowAccessible : public AccessibleWrap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HTMLTableRowAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
|
|
|
AccessibleWrap(aContent, aDoc)
|
2012-12-17 21:22:26 -08:00
|
|
|
{
|
|
|
|
mType = eHTMLTableRowType;
|
|
|
|
mGenericTypes |= eTableRow;
|
|
|
|
}
|
2012-11-29 23:33:01 -08:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
2014-07-08 14:23:18 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~HTMLTableRowAccessible() { }
|
2012-11-29 23:33:01 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-13 22:31:09 -07:00
|
|
|
/**
|
2009-09-10 18:07:56 -07:00
|
|
|
* HTML table accessible (html:table).
|
2009-05-13 22:31:09 -07:00
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-09 10:41:45 -08:00
|
|
|
// To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
|
|
|
|
// This allow release trunk builds to be used by testers to refine the
|
|
|
|
// data vs. layout heuristic
|
|
|
|
// #define SHOW_LAYOUT_HEURISTIC
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-07 05:47:49 -07:00
|
|
|
class HTMLTableAccessible : public AccessibleWrap,
|
|
|
|
public TableAccessible
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-02-15 21:42:00 -08:00
|
|
|
HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2014-10-21 17:49:28 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2013-02-15 21:42:00 -08:00
|
|
|
{
|
|
|
|
mType = eHTMLTableType;
|
|
|
|
mGenericTypes |= eTable;
|
|
|
|
}
|
2008-10-10 05:26:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2012-03-27 17:53:58 -07:00
|
|
|
// TableAccessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual Accessible* Caption() const override;
|
|
|
|
virtual void Summary(nsString& aSummary) override;
|
|
|
|
virtual uint32_t ColCount() override;
|
|
|
|
virtual uint32_t RowCount() override;
|
|
|
|
virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex) override;
|
|
|
|
virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) override;
|
|
|
|
virtual int32_t ColIndexAt(uint32_t aCellIdx) override;
|
|
|
|
virtual int32_t RowIndexAt(uint32_t aCellIdx) override;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
|
2015-03-21 09:28:04 -07:00
|
|
|
int32_t* aColIdx) override;
|
|
|
|
virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) override;
|
|
|
|
virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) override;
|
|
|
|
virtual bool IsColSelected(uint32_t aColIdx) override;
|
|
|
|
virtual bool IsRowSelected(uint32_t aRowIdx) override;
|
|
|
|
virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) override;
|
|
|
|
virtual uint32_t SelectedCellCount() override;
|
|
|
|
virtual uint32_t SelectedColCount() override;
|
|
|
|
virtual uint32_t SelectedRowCount() override;
|
|
|
|
virtual void SelectedCells(nsTArray<Accessible*>* aCells) override;
|
|
|
|
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
|
|
|
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
|
|
|
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
|
|
|
virtual void SelectCol(uint32_t aColIdx) override;
|
|
|
|
virtual void SelectRow(uint32_t aRowIdx) override;
|
|
|
|
virtual void UnselectCol(uint32_t aColIdx) override;
|
|
|
|
virtual void UnselectRow(uint32_t aRowIdx) override;
|
|
|
|
virtual bool IsProbablyLayoutTable() override;
|
|
|
|
virtual Accessible* AsAccessible() override { return this; }
|
2012-03-27 17:53:58 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual TableAccessible* AsTable() override { return this; }
|
|
|
|
virtual void Description(nsString& aDescription) override;
|
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
|
|
|
|
virtual Relation RelationByType(RelationType aRelationType) override;
|
2008-10-10 05:26:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~HTMLTableAccessible() {}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual ENameValueFlag NativeName(nsString& aName) override;
|
|
|
|
virtual void CacheChildren() override;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-06-07 05:47:49 -07:00
|
|
|
// HTMLTableAccessible
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2007-05-11 05:21:43 -07:00
|
|
|
/**
|
2009-09-09 20:06:54 -07:00
|
|
|
* Add row or column to selection.
|
2007-05-11 05:21:43 -07:00
|
|
|
*
|
2009-09-09 20:06:54 -07:00
|
|
|
* @param aIndex [in] index of row or column to be selected
|
|
|
|
* @param aTarget [in] indicates what should be selected, either row or column
|
2007-05-11 05:21:43 -07:00
|
|
|
* (see nsISelectionPrivate)
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult AddRowOrColumnToSelection(int32_t aIndex, uint32_t aTarget);
|
2007-05-11 05:21:43 -07:00
|
|
|
|
|
|
|
/**
|
2009-09-09 20:06:54 -07:00
|
|
|
* Removes rows or columns at the given index or outside it from selection.
|
2007-05-11 05:21:43 -07:00
|
|
|
*
|
2009-09-09 20:06:54 -07:00
|
|
|
* @param aIndex [in] row or column index
|
|
|
|
* @param aTarget [in] indicates whether row or column should unselected
|
|
|
|
* @param aIsOuter [in] indicates whether all rows or column excepting
|
|
|
|
* the given one should be unselected or the given one
|
|
|
|
* should be unselected only
|
2007-05-11 05:21:43 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult RemoveRowsOrColumnsFromSelection(int32_t aIndex,
|
|
|
|
uint32_t aTarget,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsOuter);
|
2007-05-11 05:21:43 -07:00
|
|
|
|
2009-07-07 19:39:04 -07:00
|
|
|
/**
|
|
|
|
* Return true if table has an element with the given tag name.
|
|
|
|
*
|
|
|
|
* @param aTagName [in] tag name of searched element
|
|
|
|
* @param aAllowEmpty [in, optional] points if found element can be empty
|
|
|
|
* or contain whitespace text only.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasDescendant(const nsAString& aTagName, bool aAllowEmpty = true);
|
2009-07-07 19:39:04 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef SHOW_LAYOUT_HEURISTIC
|
2009-08-12 02:49:55 -07:00
|
|
|
nsString mLayoutHeuristic;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
/**
|
|
|
|
* HTML caption accessible (html:caption).
|
|
|
|
*/
|
2012-06-07 05:47:49 -07:00
|
|
|
class HTMLCaptionAccessible : public HyperTextAccessibleWrap
|
2007-07-05 08:39:29 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-07 05:47:49 -07:00
|
|
|
HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc) { }
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual Relation RelationByType(RelationType aRelationType) override;
|
2014-10-21 17:49:28 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~HTMLCaptionAccessible() { }
|
2007-07-05 08:39:29 -07:00
|
|
|
};
|
|
|
|
|
2012-06-07 05:47:49 -07:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|