accessible/src/html/HTMLTableAccessible.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/html/HTMLTableAccessible.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,238 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_a11y_HTMLTableAccessible_h__
    1.10 +#define mozilla_a11y_HTMLTableAccessible_h__
    1.11 +
    1.12 +#include "HyperTextAccessibleWrap.h"
    1.13 +#include "nsIAccessibleTable.h"
    1.14 +#include "TableAccessible.h"
    1.15 +#include "TableCellAccessible.h"
    1.16 +#include "xpcAccessibleTable.h"
    1.17 +#include "xpcAccessibleTableCell.h"
    1.18 +
    1.19 +class nsITableLayout;
    1.20 +class nsITableCellLayout;
    1.21 +
    1.22 +namespace mozilla {
    1.23 +namespace a11y {
    1.24 +
    1.25 +/**
    1.26 + * HTML table cell accessible (html:td).
    1.27 + */
    1.28 +class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
    1.29 +                                public nsIAccessibleTableCell,
    1.30 +                                public TableCellAccessible,
    1.31 +                                public xpcAccessibleTableCell
    1.32 +{
    1.33 +public:
    1.34 +  HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
    1.35 +
    1.36 +  // nsISupports
    1.37 +  NS_DECL_ISUPPORTS_INHERITED
    1.38 +
    1.39 +  // nsIAccessibleTableCell
    1.40 +  NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
    1.41 +
    1.42 +  // Accessible
    1.43 +  virtual TableCellAccessible* AsTableCell() { return this; }
    1.44 +  virtual void Shutdown();
    1.45 +  virtual a11y::role NativeRole();
    1.46 +  virtual uint64_t NativeState();
    1.47 +  virtual uint64_t NativeInteractiveState() const;
    1.48 +  virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
    1.49 +
    1.50 +  // TableCellAccessible
    1.51 +  virtual TableAccessible* Table() const MOZ_OVERRIDE;
    1.52 +  virtual uint32_t ColIdx() const MOZ_OVERRIDE;
    1.53 +  virtual uint32_t RowIdx() const MOZ_OVERRIDE;
    1.54 +  virtual uint32_t ColExtent() const MOZ_OVERRIDE;
    1.55 +  virtual uint32_t RowExtent() const MOZ_OVERRIDE;
    1.56 +  virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE;
    1.57 +  virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE;
    1.58 +  virtual bool Selected() MOZ_OVERRIDE;
    1.59 +
    1.60 +protected:
    1.61 +  /**
    1.62 +   * Return host table accessible.
    1.63 +   */
    1.64 +  already_AddRefed<nsIAccessibleTable> GetTableAccessible();
    1.65 +
    1.66 +  /**
    1.67 +   * Return nsITableCellLayout of the table cell frame.
    1.68 +   */
    1.69 +  nsITableCellLayout* GetCellLayout() const;
    1.70 +
    1.71 +  /**
    1.72 +   * Return row and column indices of the cell.
    1.73 +   */
    1.74 +  nsresult GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const;
    1.75 +};
    1.76 +
    1.77 +
    1.78 +/**
    1.79 + * HTML table row/column header accessible (html:th or html:td@scope).
    1.80 + */
    1.81 +class HTMLTableHeaderCellAccessible : public HTMLTableCellAccessible
    1.82 +{
    1.83 +public:
    1.84 +  HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
    1.85 +
    1.86 +  // Accessible
    1.87 +  virtual a11y::role NativeRole();
    1.88 +};
    1.89 +
    1.90 +
    1.91 +/**
    1.92 + * HTML table row accessible (html:tr).
    1.93 + */
    1.94 +class HTMLTableRowAccessible : public AccessibleWrap
    1.95 +{
    1.96 +public:
    1.97 +  HTMLTableRowAccessible(nsIContent* aContent, DocAccessible* aDoc) :
    1.98 +    AccessibleWrap(aContent, aDoc)
    1.99 +  {
   1.100 +    mType = eHTMLTableRowType;
   1.101 +    mGenericTypes |= eTableRow;
   1.102 +  }
   1.103 +  virtual ~HTMLTableRowAccessible() { }
   1.104 +
   1.105 +  NS_DECL_ISUPPORTS_INHERITED
   1.106 +
   1.107 +  // Accessible
   1.108 +  virtual a11y::role NativeRole();
   1.109 +};
   1.110 +
   1.111 +
   1.112 +/**
   1.113 + * HTML table accessible (html:table).
   1.114 + */
   1.115 +
   1.116 +// To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
   1.117 +// This allow release trunk builds to be used by testers to refine the
   1.118 +// data vs. layout heuristic
   1.119 +// #define SHOW_LAYOUT_HEURISTIC
   1.120 +
   1.121 +class HTMLTableAccessible : public AccessibleWrap,
   1.122 +                            public xpcAccessibleTable,
   1.123 +                            public nsIAccessibleTable,
   1.124 +                            public TableAccessible
   1.125 +{
   1.126 +public:
   1.127 +  HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.128 +    AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
   1.129 +  {
   1.130 +    mType = eHTMLTableType;
   1.131 +    mGenericTypes |= eTable;
   1.132 +  }
   1.133 +
   1.134 +  NS_DECL_ISUPPORTS_INHERITED
   1.135 +
   1.136 +  // nsIAccessible Table
   1.137 +  NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
   1.138 +
   1.139 +  // TableAccessible
   1.140 +  virtual Accessible* Caption();
   1.141 +  virtual void Summary(nsString& aSummary);
   1.142 +  virtual uint32_t ColCount();
   1.143 +  virtual uint32_t RowCount();
   1.144 +  virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
   1.145 +  virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx);
   1.146 +  virtual int32_t ColIndexAt(uint32_t aCellIdx);
   1.147 +  virtual int32_t RowIndexAt(uint32_t aCellIdx);
   1.148 +  virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
   1.149 +                                  int32_t* aColIdx);
   1.150 +  virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx);
   1.151 +  virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx);
   1.152 +  virtual bool IsColSelected(uint32_t aColIdx);
   1.153 +  virtual bool IsRowSelected(uint32_t aRowIdx);
   1.154 +  virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx);
   1.155 +  virtual uint32_t SelectedCellCount();
   1.156 +  virtual uint32_t SelectedColCount();
   1.157 +  virtual uint32_t SelectedRowCount();
   1.158 +  virtual void SelectedCells(nsTArray<Accessible*>* aCells);
   1.159 +  virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells);
   1.160 +  virtual void SelectedColIndices(nsTArray<uint32_t>* aCols);
   1.161 +  virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows);
   1.162 +  virtual void SelectCol(uint32_t aColIdx);
   1.163 +  virtual void SelectRow(uint32_t aRowIdx);
   1.164 +  virtual void UnselectCol(uint32_t aColIdx);
   1.165 +  virtual void UnselectRow(uint32_t aRowIdx);
   1.166 +  virtual bool IsProbablyLayoutTable();
   1.167 +  virtual Accessible* AsAccessible() { return this; }
   1.168 +
   1.169 +  // Accessible
   1.170 +  virtual void Shutdown();
   1.171 +  virtual TableAccessible* AsTable() { return this; }
   1.172 +  virtual void Description(nsString& aDescription);
   1.173 +  virtual a11y::role NativeRole();
   1.174 +  virtual uint64_t NativeState();
   1.175 +  virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
   1.176 +  virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
   1.177 +
   1.178 +protected:
   1.179 +  // Accessible
   1.180 +  virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
   1.181 +  virtual void CacheChildren();
   1.182 +
   1.183 +  // HTMLTableAccessible
   1.184 +
   1.185 +  /**
   1.186 +   * Add row or column to selection.
   1.187 +   *
   1.188 +   * @param aIndex   [in] index of row or column to be selected
   1.189 +   * @param aTarget  [in] indicates what should be selected, either row or column
   1.190 +   *                  (see nsISelectionPrivate)
   1.191 +   */
   1.192 +  nsresult AddRowOrColumnToSelection(int32_t aIndex, uint32_t aTarget);
   1.193 +
   1.194 +  /**
   1.195 +   * Removes rows or columns at the given index or outside it from selection.
   1.196 +   *
   1.197 +   * @param  aIndex    [in] row or column index
   1.198 +   * @param  aTarget   [in] indicates whether row or column should unselected
   1.199 +   * @param  aIsOuter  [in] indicates whether all rows or column excepting
   1.200 +   *                    the given one should be unselected or the given one
   1.201 +   *                    should be unselected only
   1.202 +   */
   1.203 +  nsresult RemoveRowsOrColumnsFromSelection(int32_t aIndex,
   1.204 +                                            uint32_t aTarget,
   1.205 +                                            bool aIsOuter);
   1.206 +
   1.207 +  /**
   1.208 +   * Return true if table has an element with the given tag name.
   1.209 +   *
   1.210 +   * @param  aTagName     [in] tag name of searched element
   1.211 +   * @param  aAllowEmpty  [in, optional] points if found element can be empty
   1.212 +   *                       or contain whitespace text only.
   1.213 +   */
   1.214 +  bool HasDescendant(const nsAString& aTagName, bool aAllowEmpty = true);
   1.215 +
   1.216 +#ifdef SHOW_LAYOUT_HEURISTIC
   1.217 +  nsString mLayoutHeuristic;
   1.218 +#endif
   1.219 +};
   1.220 +
   1.221 +/**
   1.222 + * HTML caption accessible (html:caption).
   1.223 + */
   1.224 +class HTMLCaptionAccessible : public HyperTextAccessibleWrap
   1.225 +{
   1.226 +public:
   1.227 +  HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   1.228 +    HyperTextAccessibleWrap(aContent, aDoc) { }
   1.229 +  virtual ~HTMLCaptionAccessible() { }
   1.230 +
   1.231 +  // nsIAccessible
   1.232 +
   1.233 +  // Accessible
   1.234 +  virtual a11y::role NativeRole();
   1.235 +  virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
   1.236 +};
   1.237 +
   1.238 +} // namespace a11y
   1.239 +} // namespace mozilla
   1.240 +
   1.241 +#endif

mercurial