tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TableAccessible.h (4360B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef TABLE_ACCESSIBLE_H
      8 #define TABLE_ACCESSIBLE_H
      9 
     10 #include "nsString.h"
     11 #include "nsTArray.h"
     12 
     13 namespace mozilla {
     14 namespace a11y {
     15 
     16 class Accessible;
     17 
     18 /**
     19 * Accessible table interface.
     20 */
     21 class TableAccessible {
     22 public:
     23  /**
     24   * Return the caption accessible if any for this table.
     25   */
     26  virtual Accessible* Caption() const { return nullptr; }
     27 
     28  /**
     29   * Get the summary for this table.
     30   */
     31  virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
     32 
     33  /**
     34   * Return the number of columns in the table.
     35   */
     36  virtual uint32_t ColCount() const { return 0; }
     37 
     38  /**
     39   * Return the number of rows in the table.
     40   */
     41  virtual uint32_t RowCount() { return 0; }
     42 
     43  /**
     44   * Return the accessible for the cell at the given row and column indices.
     45   */
     46  virtual Accessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) {
     47    return nullptr;
     48  }
     49 
     50  /**
     51   * Return the index of the cell at the given row and column.
     52   */
     53  virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) { return -1; }
     54 
     55  /**
     56   * Return the column index of the cell with the given index.
     57   * This returns -1 if the column count is 0 or an invalid index is being
     58   * passed in.
     59   */
     60  virtual int32_t ColIndexAt(uint32_t aCellIdx) { return -1; }
     61 
     62  /**
     63   * Return the row index of the cell with the given index.
     64   * This returns -1 if the column count is 0 or an invalid index is being
     65   * passed in.
     66   */
     67  virtual int32_t RowIndexAt(uint32_t aCellIdx) { return -1; }
     68 
     69  /**
     70   * Get the row and column indices for the cell at the given index.
     71   * This returns -1 for both output parameters if the column count is 0 or an
     72   * invalid index is being passed in.
     73   */
     74  virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
     75                                  int32_t* aColIdx) {
     76    *aRowIdx = -1;
     77    *aColIdx = -1;
     78  }
     79 
     80  /**
     81   * Return the number of columns occupied by the cell at the given row and
     82   * column indices.
     83   */
     84  virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
     85 
     86  /**
     87   * Return the number of rows occupied by the cell at the given row and column
     88   * indices.
     89   */
     90  virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
     91 
     92  /**
     93   * Get the description of the given column.
     94   */
     95  virtual void ColDescription(uint32_t aColIdx, nsString& aDescription) {
     96    aDescription.Truncate();
     97  }
     98 
     99  /**
    100   * Get the description for the given row.
    101   */
    102  virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription) {
    103    aDescription.Truncate();
    104  }
    105 
    106  /**
    107   * Return true if the given column is selected.
    108   */
    109  virtual bool IsColSelected(uint32_t aColIdx) { return false; }
    110 
    111  /**
    112   * Return true if the given row is selected.
    113   */
    114  virtual bool IsRowSelected(uint32_t aRowIdx) { return false; }
    115 
    116  /**
    117   * Return true if the given cell is selected.
    118   */
    119  virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
    120    return false;
    121  }
    122 
    123  /**
    124   * Return the number of selected cells.
    125   */
    126  virtual uint32_t SelectedCellCount() { return 0; }
    127 
    128  /**
    129   * Return the number of selected columns.
    130   */
    131  virtual uint32_t SelectedColCount() { return 0; }
    132 
    133  /**
    134   * Return the number of selected rows.
    135   */
    136  virtual uint32_t SelectedRowCount() { return 0; }
    137 
    138  /**
    139   * Get the set of selected cells.
    140   */
    141  virtual void SelectedCells(nsTArray<Accessible*>* aCells) {}
    142 
    143  /**
    144   * Get the set of selected cell indices.
    145   */
    146  virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) {}
    147 
    148  /**
    149   * Get the set of selected column indices.
    150   */
    151  virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) {}
    152 
    153  /**
    154   * Get the set of selected row indices.
    155   */
    156  virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) {}
    157 
    158  /**
    159   * Return true if the table is probably for layout.
    160   */
    161  virtual bool IsProbablyLayoutTable() { return false; }
    162 
    163  /**
    164   * Convert the table to an Accessible*.
    165   */
    166  virtual Accessible* AsAccessible() = 0;
    167 };
    168 
    169 }  // namespace a11y
    170 }  // namespace mozilla
    171 
    172 #endif