accessible/src/xpcom/xpcAccessibleTableCell.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "xpcAccessibleTableCell.h"
michael@0 8
michael@0 9 #include "Accessible.h"
michael@0 10 #include "TableAccessible.h"
michael@0 11 #include "TableCellAccessible.h"
michael@0 12
michael@0 13 #include "nsIAccessibleTable.h"
michael@0 14
michael@0 15 #include "nsComponentManagerUtils.h"
michael@0 16 #include "nsIMutableArray.h"
michael@0 17
michael@0 18 using namespace mozilla;
michael@0 19 using namespace mozilla::a11y;
michael@0 20
michael@0 21 nsresult
michael@0 22 xpcAccessibleTableCell::GetTable(nsIAccessibleTable** aTable)
michael@0 23 {
michael@0 24 NS_ENSURE_ARG_POINTER(aTable);
michael@0 25 *aTable = nullptr;
michael@0 26
michael@0 27 if (!mTableCell)
michael@0 28 return NS_ERROR_FAILURE;
michael@0 29
michael@0 30 TableAccessible* table = mTableCell->Table();
michael@0 31 if (!table)
michael@0 32 return NS_ERROR_FAILURE;
michael@0 33
michael@0 34 nsCOMPtr<nsIAccessibleTable> xpcTable =
michael@0 35 do_QueryInterface(static_cast<nsIAccessible*>(table->AsAccessible()));
michael@0 36 xpcTable.forget(aTable);
michael@0 37
michael@0 38 return NS_OK;
michael@0 39 }
michael@0 40
michael@0 41 nsresult
michael@0 42 xpcAccessibleTableCell::GetColumnIndex(int32_t* aColIdx)
michael@0 43 {
michael@0 44 NS_ENSURE_ARG_POINTER(aColIdx);
michael@0 45 *aColIdx = -1;
michael@0 46
michael@0 47 if (!mTableCell)
michael@0 48 return NS_ERROR_FAILURE;
michael@0 49
michael@0 50 *aColIdx = mTableCell->ColIdx();
michael@0 51 return NS_OK;
michael@0 52 }
michael@0 53
michael@0 54 nsresult
michael@0 55 xpcAccessibleTableCell::GetRowIndex(int32_t* aRowIdx)
michael@0 56 {
michael@0 57 NS_ENSURE_ARG_POINTER(aRowIdx);
michael@0 58 *aRowIdx = -1;
michael@0 59
michael@0 60 if (!mTableCell)
michael@0 61 return NS_ERROR_FAILURE;
michael@0 62
michael@0 63 *aRowIdx = mTableCell->RowIdx();
michael@0 64
michael@0 65 return NS_OK;
michael@0 66 }
michael@0 67
michael@0 68 nsresult
michael@0 69 xpcAccessibleTableCell::GetColumnExtent(int32_t* aExtent)
michael@0 70 {
michael@0 71 NS_ENSURE_ARG_POINTER(aExtent);
michael@0 72 *aExtent = -1;
michael@0 73
michael@0 74 if (!mTableCell)
michael@0 75 return NS_ERROR_FAILURE;
michael@0 76
michael@0 77 *aExtent = mTableCell->ColExtent();
michael@0 78
michael@0 79 return NS_OK;
michael@0 80 }
michael@0 81
michael@0 82 nsresult
michael@0 83 xpcAccessibleTableCell::GetRowExtent(int32_t* aExtent)
michael@0 84 {
michael@0 85 NS_ENSURE_ARG_POINTER(aExtent);
michael@0 86 *aExtent = -1;
michael@0 87
michael@0 88 if (!mTableCell)
michael@0 89 return NS_ERROR_FAILURE;
michael@0 90
michael@0 91 *aExtent = mTableCell->RowExtent();
michael@0 92
michael@0 93 return NS_OK;
michael@0 94 }
michael@0 95
michael@0 96 nsresult
michael@0 97 xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells)
michael@0 98 {
michael@0 99 NS_ENSURE_ARG_POINTER(aHeaderCells);
michael@0 100 *aHeaderCells = nullptr;
michael@0 101
michael@0 102 if (!mTableCell)
michael@0 103 return NS_ERROR_FAILURE;
michael@0 104
michael@0 105 nsAutoTArray<Accessible*, 10> headerCells;
michael@0 106 mTableCell->ColHeaderCells(&headerCells);
michael@0 107
michael@0 108 nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
michael@0 109 NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
michael@0 110
michael@0 111 for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
michael@0 112 cells->
michael@0 113 AppendElement(static_cast<nsIAccessible*>(headerCells.ElementAt(idx)),
michael@0 114 false);
michael@0 115 }
michael@0 116
michael@0 117 NS_ADDREF(*aHeaderCells = cells);
michael@0 118 return NS_OK;
michael@0 119 }
michael@0 120
michael@0 121 nsresult
michael@0 122 xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells)
michael@0 123 {
michael@0 124 NS_ENSURE_ARG_POINTER(aHeaderCells);
michael@0 125 *aHeaderCells = nullptr;
michael@0 126
michael@0 127 if (!mTableCell)
michael@0 128 return NS_ERROR_FAILURE;
michael@0 129
michael@0 130 nsAutoTArray<Accessible*, 10> headerCells;
michael@0 131 mTableCell->RowHeaderCells(&headerCells);
michael@0 132
michael@0 133 nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
michael@0 134 NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
michael@0 135
michael@0 136 for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
michael@0 137 cells->
michael@0 138 AppendElement(static_cast<nsIAccessible*>(headerCells.ElementAt(idx)),
michael@0 139 false);
michael@0 140 }
michael@0 141
michael@0 142 NS_ADDREF(*aHeaderCells = cells);
michael@0 143 return NS_OK;
michael@0 144 }
michael@0 145
michael@0 146 nsresult
michael@0 147 xpcAccessibleTableCell::IsSelected(bool* aSelected)
michael@0 148 {
michael@0 149 NS_ENSURE_ARG_POINTER(aSelected);
michael@0 150 *aSelected = false;
michael@0 151
michael@0 152 if (!mTableCell)
michael@0 153 return NS_ERROR_FAILURE;
michael@0 154
michael@0 155 *aSelected = mTableCell->Selected();
michael@0 156
michael@0 157 return NS_OK;
michael@0 158 }

mercurial