bug 829382 - remove nsIWinAccessNode and stuff from ia2AccessibleTableCell r=surkov

This commit is contained in:
Trevor Saunders 2013-01-09 05:20:35 -05:00
parent a1b7fbfef4
commit d989fedbf6
10 changed files with 155 additions and 185 deletions

View File

@ -39,3 +39,9 @@ IMPL_IUNKNOWN_INHERITED1(ARIAGridCellAccessibleWrap,
HyperTextAccessibleWrap,
ia2AccessibleTableCell)
void
ARIAGridCellAccessibleWrap::Shutdown()
{
ia2AccessibleTableCell::mTableCell = nullptr;
ARIAGridCellAccessible::Shutdown();
}

View File

@ -44,13 +44,15 @@ class ARIAGridCellAccessibleWrap : public ARIAGridCellAccessible,
{
public:
ARIAGridCellAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
ARIAGridCellAccessible(aContent, aDoc) {}
ARIAGridCellAccessible(aContent, aDoc), ia2AccessibleTableCell(this) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
virtual void Shutdown() MOZ_OVERRIDE;
};
} // namespace a11y

View File

@ -38,6 +38,12 @@ IMPL_IUNKNOWN_INHERITED1(HTMLTableCellAccessibleWrap,
HyperTextAccessibleWrap,
ia2AccessibleTableCell)
void
HTMLTableCellAccessibleWrap::Shutdown()
{
ia2AccessibleTableCell::mTableCell = nullptr;
HTMLTableCellAccessible::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
// HTMLTableCellAccessibleWrap
@ -49,3 +55,10 @@ NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableHeaderCellAccessibleWrap,
IMPL_IUNKNOWN_INHERITED1(HTMLTableHeaderCellAccessibleWrap,
HyperTextAccessibleWrap,
ia2AccessibleTableCell)
void
HTMLTableHeaderCellAccessibleWrap::Shutdown()
{
ia2AccessibleTableCell::mTableCell = nullptr;
HTMLTableHeaderCellAccessible::Shutdown();
}

View File

@ -46,13 +46,15 @@ class HTMLTableCellAccessibleWrap : public HTMLTableCellAccessible,
{
public:
HTMLTableCellAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
HTMLTableCellAccessible(aContent, aDoc) {}
HTMLTableCellAccessible(aContent, aDoc), ia2AccessibleTableCell(this) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
virtual void Shutdown() MOZ_OVERRIDE;
};
@ -66,13 +68,16 @@ class HTMLTableHeaderCellAccessibleWrap : public HTMLTableHeaderCellAccessible,
public:
HTMLTableHeaderCellAccessibleWrap(nsIContent* aContent,
DocAccessible* aDoc) :
HTMLTableHeaderCellAccessible(aContent, aDoc) {}
HTMLTableHeaderCellAccessible(aContent, aDoc), ia2AccessibleTableCell(this)
{}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
virtual void Shutdown() MOZ_OVERRIDE;
};
} // namespace a11y

View File

@ -30,15 +30,16 @@ XULListboxAccessibleWrap::Shutdown()
// XULListCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
XULListCellAccessibleWrap::
XULListCellAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
XULListCellAccessible(aContent, aDoc)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(XULListCellAccessibleWrap,
XULListCellAccessible)
IMPL_IUNKNOWN_INHERITED1(XULListCellAccessibleWrap,
HyperTextAccessibleWrap,
ia2AccessibleTableCell)
void
XULListCellAccessibleWrap::Shutdown()
{
ia2AccessibleTableCell::mTableCell = nullptr;
XULListCellAccessible::Shutdown();
}

View File

@ -42,13 +42,16 @@ class XULListCellAccessibleWrap : public XULListCellAccessible,
public ia2AccessibleTableCell
{
public:
XULListCellAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc);
XULListCellAccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
XULListCellAccessible(aContent, aDoc), ia2AccessibleTableCell(this) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
virtual void Shutdown() MOZ_OVERRIDE;
};
} // namespace a11y

View File

@ -29,21 +29,16 @@ XULTreeGridAccessibleWrap::Shutdown()
// XULTreeGridCellAccessibleWrap
////////////////////////////////////////////////////////////////////////////////
XULTreeGridCellAccessibleWrap::
XULTreeGridCellAccessibleWrap(nsIContent* aContent,
DocAccessible* aDoc,
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree,
nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn) :
XULTreeGridCellAccessible(aContent, aDoc, aRowAcc, aTree, aTreeView,
aRow, aColumn)
{
}
NS_IMPL_ISUPPORTS_INHERITED0(XULTreeGridCellAccessibleWrap,
XULTreeGridCellAccessible)
IMPL_IUNKNOWN_INHERITED1(XULTreeGridCellAccessibleWrap,
AccessibleWrap,
ia2AccessibleTableCell)
void
XULTreeGridCellAccessibleWrap::Shutdown()
{
ia2AccessibleTableCell::mTableCell = nullptr;
XULTreeGridCellAccessible::Shutdown();
}

View File

@ -47,13 +47,17 @@ public:
XULTreeGridRowAccessible* aRowAcc,
nsITreeBoxObject* aTree,
nsITreeView* aTreeView,
int32_t aRow, nsITreeColumn* aColumn);
int32_t aRow, nsITreeColumn* aColumn) :
XULTreeGridCellAccessible(aContent, aDoc, aRowAcc, aTree, aTreeView, aRow,
aColumn), ia2AccessibleTableCell(this) {}
// IUnknown
DECL_IUNKNOWN_INHERITED
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
virtual void Shutdown() MOZ_OVERRIDE;
};
} // namespace a11y

View File

@ -11,20 +11,15 @@
#include "AccessibleTable2_i.c"
#include "AccessibleTableCell_i.c"
#include "nsIAccessible.h"
#include "nsIAccessibleTable.h"
#include "nsIWinAccessNode.h"
#include "nsAccessNodeWrap.h"
#include "nsWinUtils.h"
#include "AccessibleWrap.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
#include "nsCOMPtr.h"
#include "nsString.h"
using namespace mozilla::a11y;
#define TABLECELL_INTERFACE_UNSUPPORTED_MSG \
"Subclass of ia2AccessibleTableCell doesn't implement nsIAccessibleTableCell"\
// IUnknown
STDMETHODIMP
@ -49,51 +44,34 @@ ia2AccessibleTableCell::get_table(IUnknown** aTable)
{
A11Y_TRYBLOCK_BEGIN
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
*aTable = NULL;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
TableAccessible* table = mTableCell->Table();
if (!table)
return E_FAIL;
nsCOMPtr<nsIAccessibleTable> geckoTable;
nsresult rv = tableCell->GetTable(getter_AddRefs(geckoTable));
if (NS_FAILED(rv))
return GetHRESULT(rv);
nsCOMPtr<nsIWinAccessNode> winAccessNode = do_QueryInterface(geckoTable);
if (!winAccessNode)
return E_FAIL;
void *instancePtr = NULL;
rv = winAccessNode->QueryNativeInterface(IID_IUnknown, &instancePtr);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aTable = static_cast<IUnknown*>(instancePtr);
AccessibleWrap* wrap = static_cast<AccessibleWrap*>(table->AsAccessible());
*aTable = static_cast<IAccessible*>(wrap);
(*aTable)->AddRef();
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
ia2AccessibleTableCell::get_columnExtent(long* aNColumnsSpanned)
ia2AccessibleTableCell::get_columnExtent(long* aSpan)
{
A11Y_TRYBLOCK_BEGIN
*aNColumnsSpanned = 0;
*aSpan = 0;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
*aSpan = mTableCell->ColExtent();
int32_t columnsSpanned = 0;
nsresult rv = tableCell->GetColumnExtent(&columnsSpanned);
if (NS_SUCCEEDED(rv)) {
*aNColumnsSpanned = columnsSpanned;
return S_OK;
}
return GetHRESULT(rv);
return S_OK;
A11Y_TRYBLOCK_END
}
@ -104,66 +82,59 @@ ia2AccessibleTableCell::get_columnHeaderCells(IUnknown*** aCellAccessibles,
{
A11Y_TRYBLOCK_BEGIN
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
*aCellAccessibles = NULL;
*aNColumnHeaderCells = 0;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIArray> headerCells;
nsresult rv = tableCell->GetColumnHeaderCells(getter_AddRefs(headerCells));
if (NS_FAILED(rv))
return GetHRESULT(rv);
nsAutoTArray<Accessible*, 10> cells;
mTableCell->ColHeaderCells(&cells);
return nsWinUtils::ConvertToIA2Array(headerCells, aCellAccessibles,
aNColumnHeaderCells);
*aNColumnHeaderCells = cells.Length();
*aCellAccessibles =
static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
cells.Length()));
if (!*aCellAccessibles)
return E_OUTOFMEMORY;
for (uint32_t i = 0; i < cells.Length(); i++) {
AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]);
(*aCellAccessibles)[i] = static_cast<IAccessible*>(cell);
(*aCellAccessibles)[i]->AddRef();
}
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
ia2AccessibleTableCell::get_columnIndex(long* aColumnIndex)
ia2AccessibleTableCell::get_columnIndex(long* aColIdx)
{
A11Y_TRYBLOCK_BEGIN
*aColumnIndex = -1;
*aColIdx = -1;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
int32_t colIdx = -1;
nsresult rv = tableCell->GetColumnIndex(&colIdx);
if (NS_SUCCEEDED(rv)) {
*aColumnIndex = colIdx;
return S_OK;
}
return GetHRESULT(rv);
*aColIdx = mTableCell->ColIdx();
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
ia2AccessibleTableCell::get_rowExtent(long* aNRowsSpanned)
ia2AccessibleTableCell::get_rowExtent(long* aSpan)
{
A11Y_TRYBLOCK_BEGIN
*aNRowsSpanned = 0;
*aSpan = 0;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
int32_t rowsSpanned = 0;
nsresult rv = tableCell->GetRowExtent(&rowsSpanned);
if (NS_SUCCEEDED(rv)) {
*aNRowsSpanned = rowsSpanned;
return S_OK;
}
return GetHRESULT(rv);
*aSpan = mTableCell->RowExtent();
return S_OK;
A11Y_TRYBLOCK_END
}
@ -174,95 +145,66 @@ ia2AccessibleTableCell::get_rowHeaderCells(IUnknown*** aCellAccessibles,
{
A11Y_TRYBLOCK_BEGIN
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
*aCellAccessibles = NULL;
*aNRowHeaderCells = 0;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIArray> headerCells;
nsresult rv = tableCell->GetRowHeaderCells(getter_AddRefs(headerCells));
if (NS_FAILED(rv))
return GetHRESULT(rv);
nsAutoTArray<Accessible*, 10> cells;
mTableCell->RowHeaderCells(&cells);
return nsWinUtils::ConvertToIA2Array(headerCells, aCellAccessibles,
aNRowHeaderCells);
*aNRowHeaderCells = cells.Length();
*aCellAccessibles =
static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
cells.Length()));
if (!*aCellAccessibles)
return E_OUTOFMEMORY;
for (uint32_t i = 0; i < cells.Length(); i++) {
AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]);
(*aCellAccessibles)[i] = static_cast<IAccessible*>(cell);
(*aCellAccessibles)[i]->AddRef();
}
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
ia2AccessibleTableCell::get_rowIndex(long* aRowIndex)
ia2AccessibleTableCell::get_rowIndex(long* aRowIdx)
{
A11Y_TRYBLOCK_BEGIN
*aRowIndex = -1;
*aRowIdx = -1;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
int32_t rowIdx = -1;
nsresult rv = tableCell->GetRowIndex(&rowIdx);
if (NS_SUCCEEDED(rv)) {
*aRowIndex = rowIdx;
return S_OK;
}
return GetHRESULT(rv);
*aRowIdx = mTableCell->RowIdx();
return S_OK;
A11Y_TRYBLOCK_END
}
STDMETHODIMP
ia2AccessibleTableCell::get_rowColumnExtents(long* aRow, long* aColumn,
ia2AccessibleTableCell::get_rowColumnExtents(long* aRowIdx, long* aColIdx,
long* aRowExtents,
long* aColumnExtents,
long* aColExtents,
boolean* aIsSelected)
{
A11Y_TRYBLOCK_BEGIN
*aRow = 0;
*aRow = 0;
*aRow = 0;
*aColumnExtents = 0;
*aRowIdx = *aColIdx = *aRowExtents = *aColExtents = 0;
*aIsSelected = false;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
*aRowIdx = mTableCell->RowIdx();
*aColIdx = mTableCell->ColIdx();
*aRowExtents = mTableCell->RowExtent();
*aColExtents = mTableCell->ColExtent();
*aIsSelected = mTableCell->Selected();
int32_t rowIdx = -1;
nsresult rv = tableCell->GetRowIndex(&rowIdx);
if (NS_FAILED(rv))
return GetHRESULT(rv);
int32_t columnIdx = -1;
rv = tableCell->GetColumnIndex(&columnIdx);
if (NS_FAILED(rv))
return GetHRESULT(rv);
int32_t spannedRows = 0;
rv = tableCell->GetRowExtent(&spannedRows);
if (NS_FAILED(rv))
return GetHRESULT(rv);
int32_t spannedColumns = 0;
rv = tableCell->GetColumnExtent(&spannedColumns);
if (NS_FAILED(rv))
return GetHRESULT(rv);
bool isSel = false;
rv = tableCell->IsSelected(&isSel);
if (NS_FAILED(rv))
return GetHRESULT(rv);
*aRow = rowIdx;
*aColumn = columnIdx;
*aRowExtents = spannedRows;
*aColumnExtents = spannedColumns;
*aIsSelected = isSel;
return S_OK;
A11Y_TRYBLOCK_END
@ -274,20 +216,11 @@ ia2AccessibleTableCell::get_isSelected(boolean* aIsSelected)
A11Y_TRYBLOCK_BEGIN
*aIsSelected = false;
if (!mTableCell)
return CO_E_OBJNOTCONNECTED;
nsCOMPtr<nsIAccessibleTableCell> tableCell(do_QueryObject(this));
NS_ASSERTION(tableCell, TABLECELL_INTERFACE_UNSUPPORTED_MSG);
if (!tableCell)
return E_FAIL;
bool isSel = false;
nsresult rv = tableCell->IsSelected(&isSel);
if (NS_SUCCEEDED(rv)) {
*aIsSelected = isSel;
return S_OK;
}
return GetHRESULT(rv);
*aIsSelected = mTableCell->Selected();
return S_OK;
A11Y_TRYBLOCK_END
}

View File

@ -8,10 +8,12 @@
#ifndef _ACCESSIBLE_TABLECELL_H
#define _ACCESSIBLE_TABLECELL_H
#include "nsISupports.h"
#include "AccessibleTableCell.h"
namespace mozilla {
namespace a11y {
class TableCellAccessible;
class ia2AccessibleTableCell : public IAccessibleTableCell
{
public:
@ -54,8 +56,14 @@ public:
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_isSelected(
/* [out, retval] */ boolean *isSelected);
// nsISupports
NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
protected:
ia2AccessibleTableCell(TableCellAccessible* aTableCell) :
mTableCell(aTableCell) {}
TableCellAccessible* mTableCell;
};
} // namespace a11y
} // namespace mozilla
#endif