2012-08-09 10:24:31 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#include "xpcAccessibleTableCell.h"
|
|
|
|
|
|
|
|
#include "Accessible.h"
|
2014-10-22 04:49:28 +04:00
|
|
|
#include "nsIAccessibleTable.h"
|
2012-08-09 10:24:31 +04:00
|
|
|
#include "TableAccessible.h"
|
|
|
|
#include "TableCellAccessible.h"
|
2014-10-22 04:49:28 +04:00
|
|
|
#include "xpcAccessibleDocument.h"
|
2012-08-09 10:24:31 +04:00
|
|
|
|
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsIMutableArray.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleTableCell,
|
|
|
|
xpcAccessibleHyperText,
|
|
|
|
nsIAccessibleTableCell)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleTableCell
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetTable(nsIAccessibleTable** aTable)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTable);
|
|
|
|
*aTable = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
TableAccessible* table = Intl()->Table();
|
2012-08-09 10:24:31 +04:00
|
|
|
if (!table)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> xpcTable =
|
2014-10-22 04:49:28 +04:00
|
|
|
do_QueryInterface(static_cast<nsIAccessible*>(ToXPC(table->AsAccessible())));
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcTable.forget(aTable);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetColumnIndex(int32_t* aColIdx)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aColIdx);
|
|
|
|
*aColIdx = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aColIdx = Intl()->ColIdx();
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetRowIndex(int32_t* aRowIdx)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRowIdx);
|
|
|
|
*aRowIdx = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aRowIdx = Intl()->RowIdx();
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetColumnExtent(int32_t* aExtent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtent);
|
|
|
|
*aExtent = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aExtent = Intl()->ColExtent();
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetRowExtent(int32_t* aExtent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtent);
|
|
|
|
*aExtent = -1;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aExtent = Intl()->RowExtent();
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsAutoTArray<Accessible*, 10> headerCells;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->ColHeaderCells(&headerCells);
|
2012-08-09 10:24:31 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
|
2014-10-22 04:49:28 +04:00
|
|
|
cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])),
|
|
|
|
false);
|
2012-08-09 10:24:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aHeaderCells = cells);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nullptr;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsAutoTArray<Accessible*, 10> headerCells;
|
2014-10-22 04:49:28 +04:00
|
|
|
Intl()->RowHeaderCells(&headerCells);
|
2012-08-09 10:24:31 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
|
2014-10-22 04:49:28 +04:00
|
|
|
cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])),
|
|
|
|
false);
|
2012-08-09 10:24:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aHeaderCells = cells);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-09 10:24:31 +04:00
|
|
|
xpcAccessibleTableCell::IsSelected(bool* aSelected)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSelected);
|
|
|
|
*aSelected = false;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!Intl())
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
*aSelected = Intl()->Selected();
|
2012-08-09 10:24:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|