accessible/src/html/HTMLTableAccessible.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef mozilla_a11y_HTMLTableAccessible_h__
michael@0 7 #define mozilla_a11y_HTMLTableAccessible_h__
michael@0 8
michael@0 9 #include "HyperTextAccessibleWrap.h"
michael@0 10 #include "nsIAccessibleTable.h"
michael@0 11 #include "TableAccessible.h"
michael@0 12 #include "TableCellAccessible.h"
michael@0 13 #include "xpcAccessibleTable.h"
michael@0 14 #include "xpcAccessibleTableCell.h"
michael@0 15
michael@0 16 class nsITableLayout;
michael@0 17 class nsITableCellLayout;
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20 namespace a11y {
michael@0 21
michael@0 22 /**
michael@0 23 * HTML table cell accessible (html:td).
michael@0 24 */
michael@0 25 class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
michael@0 26 public nsIAccessibleTableCell,
michael@0 27 public TableCellAccessible,
michael@0 28 public xpcAccessibleTableCell
michael@0 29 {
michael@0 30 public:
michael@0 31 HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
michael@0 32
michael@0 33 // nsISupports
michael@0 34 NS_DECL_ISUPPORTS_INHERITED
michael@0 35
michael@0 36 // nsIAccessibleTableCell
michael@0 37 NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
michael@0 38
michael@0 39 // Accessible
michael@0 40 virtual TableCellAccessible* AsTableCell() { return this; }
michael@0 41 virtual void Shutdown();
michael@0 42 virtual a11y::role NativeRole();
michael@0 43 virtual uint64_t NativeState();
michael@0 44 virtual uint64_t NativeInteractiveState() const;
michael@0 45 virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
michael@0 46
michael@0 47 // TableCellAccessible
michael@0 48 virtual TableAccessible* Table() const MOZ_OVERRIDE;
michael@0 49 virtual uint32_t ColIdx() const MOZ_OVERRIDE;
michael@0 50 virtual uint32_t RowIdx() const MOZ_OVERRIDE;
michael@0 51 virtual uint32_t ColExtent() const MOZ_OVERRIDE;
michael@0 52 virtual uint32_t RowExtent() const MOZ_OVERRIDE;
michael@0 53 virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE;
michael@0 54 virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE;
michael@0 55 virtual bool Selected() MOZ_OVERRIDE;
michael@0 56
michael@0 57 protected:
michael@0 58 /**
michael@0 59 * Return host table accessible.
michael@0 60 */
michael@0 61 already_AddRefed<nsIAccessibleTable> GetTableAccessible();
michael@0 62
michael@0 63 /**
michael@0 64 * Return nsITableCellLayout of the table cell frame.
michael@0 65 */
michael@0 66 nsITableCellLayout* GetCellLayout() const;
michael@0 67
michael@0 68 /**
michael@0 69 * Return row and column indices of the cell.
michael@0 70 */
michael@0 71 nsresult GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const;
michael@0 72 };
michael@0 73
michael@0 74
michael@0 75 /**
michael@0 76 * HTML table row/column header accessible (html:th or html:td@scope).
michael@0 77 */
michael@0 78 class HTMLTableHeaderCellAccessible : public HTMLTableCellAccessible
michael@0 79 {
michael@0 80 public:
michael@0 81 HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
michael@0 82
michael@0 83 // Accessible
michael@0 84 virtual a11y::role NativeRole();
michael@0 85 };
michael@0 86
michael@0 87
michael@0 88 /**
michael@0 89 * HTML table row accessible (html:tr).
michael@0 90 */
michael@0 91 class HTMLTableRowAccessible : public AccessibleWrap
michael@0 92 {
michael@0 93 public:
michael@0 94 HTMLTableRowAccessible(nsIContent* aContent, DocAccessible* aDoc) :
michael@0 95 AccessibleWrap(aContent, aDoc)
michael@0 96 {
michael@0 97 mType = eHTMLTableRowType;
michael@0 98 mGenericTypes |= eTableRow;
michael@0 99 }
michael@0 100 virtual ~HTMLTableRowAccessible() { }
michael@0 101
michael@0 102 NS_DECL_ISUPPORTS_INHERITED
michael@0 103
michael@0 104 // Accessible
michael@0 105 virtual a11y::role NativeRole();
michael@0 106 };
michael@0 107
michael@0 108
michael@0 109 /**
michael@0 110 * HTML table accessible (html:table).
michael@0 111 */
michael@0 112
michael@0 113 // To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
michael@0 114 // This allow release trunk builds to be used by testers to refine the
michael@0 115 // data vs. layout heuristic
michael@0 116 // #define SHOW_LAYOUT_HEURISTIC
michael@0 117
michael@0 118 class HTMLTableAccessible : public AccessibleWrap,
michael@0 119 public xpcAccessibleTable,
michael@0 120 public nsIAccessibleTable,
michael@0 121 public TableAccessible
michael@0 122 {
michael@0 123 public:
michael@0 124 HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
michael@0 125 AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
michael@0 126 {
michael@0 127 mType = eHTMLTableType;
michael@0 128 mGenericTypes |= eTable;
michael@0 129 }
michael@0 130
michael@0 131 NS_DECL_ISUPPORTS_INHERITED
michael@0 132
michael@0 133 // nsIAccessible Table
michael@0 134 NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
michael@0 135
michael@0 136 // TableAccessible
michael@0 137 virtual Accessible* Caption();
michael@0 138 virtual void Summary(nsString& aSummary);
michael@0 139 virtual uint32_t ColCount();
michael@0 140 virtual uint32_t RowCount();
michael@0 141 virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
michael@0 142 virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx);
michael@0 143 virtual int32_t ColIndexAt(uint32_t aCellIdx);
michael@0 144 virtual int32_t RowIndexAt(uint32_t aCellIdx);
michael@0 145 virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
michael@0 146 int32_t* aColIdx);
michael@0 147 virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx);
michael@0 148 virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx);
michael@0 149 virtual bool IsColSelected(uint32_t aColIdx);
michael@0 150 virtual bool IsRowSelected(uint32_t aRowIdx);
michael@0 151 virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx);
michael@0 152 virtual uint32_t SelectedCellCount();
michael@0 153 virtual uint32_t SelectedColCount();
michael@0 154 virtual uint32_t SelectedRowCount();
michael@0 155 virtual void SelectedCells(nsTArray<Accessible*>* aCells);
michael@0 156 virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells);
michael@0 157 virtual void SelectedColIndices(nsTArray<uint32_t>* aCols);
michael@0 158 virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows);
michael@0 159 virtual void SelectCol(uint32_t aColIdx);
michael@0 160 virtual void SelectRow(uint32_t aRowIdx);
michael@0 161 virtual void UnselectCol(uint32_t aColIdx);
michael@0 162 virtual void UnselectRow(uint32_t aRowIdx);
michael@0 163 virtual bool IsProbablyLayoutTable();
michael@0 164 virtual Accessible* AsAccessible() { return this; }
michael@0 165
michael@0 166 // Accessible
michael@0 167 virtual void Shutdown();
michael@0 168 virtual TableAccessible* AsTable() { return this; }
michael@0 169 virtual void Description(nsString& aDescription);
michael@0 170 virtual a11y::role NativeRole();
michael@0 171 virtual uint64_t NativeState();
michael@0 172 virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
michael@0 173 virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
michael@0 174
michael@0 175 protected:
michael@0 176 // Accessible
michael@0 177 virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
michael@0 178 virtual void CacheChildren();
michael@0 179
michael@0 180 // HTMLTableAccessible
michael@0 181
michael@0 182 /**
michael@0 183 * Add row or column to selection.
michael@0 184 *
michael@0 185 * @param aIndex [in] index of row or column to be selected
michael@0 186 * @param aTarget [in] indicates what should be selected, either row or column
michael@0 187 * (see nsISelectionPrivate)
michael@0 188 */
michael@0 189 nsresult AddRowOrColumnToSelection(int32_t aIndex, uint32_t aTarget);
michael@0 190
michael@0 191 /**
michael@0 192 * Removes rows or columns at the given index or outside it from selection.
michael@0 193 *
michael@0 194 * @param aIndex [in] row or column index
michael@0 195 * @param aTarget [in] indicates whether row or column should unselected
michael@0 196 * @param aIsOuter [in] indicates whether all rows or column excepting
michael@0 197 * the given one should be unselected or the given one
michael@0 198 * should be unselected only
michael@0 199 */
michael@0 200 nsresult RemoveRowsOrColumnsFromSelection(int32_t aIndex,
michael@0 201 uint32_t aTarget,
michael@0 202 bool aIsOuter);
michael@0 203
michael@0 204 /**
michael@0 205 * Return true if table has an element with the given tag name.
michael@0 206 *
michael@0 207 * @param aTagName [in] tag name of searched element
michael@0 208 * @param aAllowEmpty [in, optional] points if found element can be empty
michael@0 209 * or contain whitespace text only.
michael@0 210 */
michael@0 211 bool HasDescendant(const nsAString& aTagName, bool aAllowEmpty = true);
michael@0 212
michael@0 213 #ifdef SHOW_LAYOUT_HEURISTIC
michael@0 214 nsString mLayoutHeuristic;
michael@0 215 #endif
michael@0 216 };
michael@0 217
michael@0 218 /**
michael@0 219 * HTML caption accessible (html:caption).
michael@0 220 */
michael@0 221 class HTMLCaptionAccessible : public HyperTextAccessibleWrap
michael@0 222 {
michael@0 223 public:
michael@0 224 HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
michael@0 225 HyperTextAccessibleWrap(aContent, aDoc) { }
michael@0 226 virtual ~HTMLCaptionAccessible() { }
michael@0 227
michael@0 228 // nsIAccessible
michael@0 229
michael@0 230 // Accessible
michael@0 231 virtual a11y::role NativeRole();
michael@0 232 virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
michael@0 233 };
michael@0 234
michael@0 235 } // namespace a11y
michael@0 236 } // namespace mozilla
michael@0 237
michael@0 238 #endif

mercurial