зеркало из https://github.com/mozilla/pjs.git
Bug 340827. Support nsIAccessibleTable cross platform. Patch by Ming Gao. r=aaronlev
This commit is contained in:
Родитель
e20e054c9a
Коммит
2ec38575a5
|
@ -68,7 +68,6 @@ CPPSRCS = \
|
|||
nsDocAccessibleWrap.cpp \
|
||||
nsRootAccessibleWrap.cpp \
|
||||
nsAppRootAccessible.cpp \
|
||||
nsHTMLTableAccessibleWrap.cpp \
|
||||
nsMaiInterfaceComponent.cpp \
|
||||
nsMaiInterfaceAction.cpp \
|
||||
nsMaiInterfaceText.cpp \
|
||||
|
|
|
@ -98,10 +98,6 @@
|
|||
#include "nsHTMLWin32ObjectAccessible.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
#include "nsHTMLTableAccessibleWrap.h"
|
||||
#endif
|
||||
|
||||
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull;
|
||||
|
||||
/**
|
||||
|
@ -499,9 +495,11 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsISupports *aFrame,
|
|||
tag == nsAccessibilityAtoms::h5 ||
|
||||
tag == nsAccessibilityAtoms::h6 ||
|
||||
tag == nsAccessibilityAtoms::q ||
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
tag == nsAccessibilityAtoms::tbody ||
|
||||
tag == nsAccessibilityAtoms::tfoot ||
|
||||
tag == nsAccessibilityAtoms::thead ||
|
||||
#endif
|
||||
content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::tabindex) ||
|
||||
// The role from a <body> or doc element is already exposed in nsDocAccessible
|
||||
(tag != nsAccessibilityAtoms::body && content->GetParent() &&
|
||||
|
@ -790,7 +788,7 @@ nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccess
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTableAccessibleWrap(node, weakShell);
|
||||
*_retval = new nsHTMLTableAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -835,7 +833,7 @@ nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports *aFrame, nsIAc
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = new nsHTMLTableCellAccessibleWrap(node, weakShell);
|
||||
*_retval = new nsHTMLTableCellAccessible(node, weakShell);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -40,6 +40,18 @@
|
|||
#include "nsAccessibilityAtoms.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLTableCaptionElem.h"
|
||||
#include "nsIDOMHTMLTableCellElement.h"
|
||||
#include "nsIDOMHTMLTableElement.h"
|
||||
#include "nsIDOMHTMLTableRowElement.h"
|
||||
#include "nsIDOMHTMLTableSectionElem.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsITableLayout.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableCellAccessible, nsHyperTextAccessible)
|
||||
|
||||
|
@ -62,10 +74,10 @@ NS_IMETHODIMP nsHTMLTableCellAccessible::GetState(PRUint32 *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableAccessible, nsHyperTextAccessible)
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableAccessible, nsAccessibleWrap)
|
||||
|
||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||
nsHyperTextAccessible(aDomNode, aShell)
|
||||
nsAccessibleWrap(aDomNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -119,3 +131,528 @@ NS_IMETHODIMP nsHTMLTableAccessible::GetName(nsAString& aName)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
|
||||
{
|
||||
*aCaption = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption;
|
||||
rv = table->GetCaption(getter_AddRefs(caption));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> captionNode(do_QueryInterface(caption));
|
||||
NS_ENSURE_TRUE(captionNode, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService>
|
||||
accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
accService->GetCachedAccessible(captionNode, mWeakShell, aCaption);
|
||||
if (*aCaption)
|
||||
return NS_OK;
|
||||
|
||||
return accService->CreateHyperTextAccessible(captionNode, aCaption);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::SetCaption(nsIAccessible *aCaption)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aCaption));
|
||||
NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode");
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
rv = accessNode->GetDOMNode(getter_AddRefs(domNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> newDOMNode;
|
||||
rv = domNode->CloneNode(PR_TRUE, getter_AddRefs(newDOMNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement>
|
||||
captionElement(do_QueryInterface(newDOMNode));
|
||||
NS_ENSURE_TRUE(captionElement, NS_ERROR_FAILURE);
|
||||
|
||||
return table->SetCaption(captionElement);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetSummary(nsAString &aSummary)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
return table->GetSummary(aSummary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::SetSummary(const nsAString &aSummary)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
return table->SetSummary(aSummary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetColumns(PRInt32 *aColumns)
|
||||
{
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 rows;
|
||||
return tableLayout->GetTableSize(rows, *aColumns);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section;
|
||||
rv = table->GetTHead(getter_AddRefs(section));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService>
|
||||
accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accHead;
|
||||
nsCOMPtr<nsIDOMNode> sectionNode(do_QueryInterface(section));
|
||||
if (sectionNode) {
|
||||
rv = accService->GetCachedAccessible(sectionNode, mWeakShell,
|
||||
getter_AddRefs(accHead));
|
||||
}
|
||||
|
||||
if (!accHead) {
|
||||
rv = accService->CreateHTMLTableHeadAccessible(section,
|
||||
getter_AddRefs(accHead));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessibleTable> accTableHead(do_QueryInterface(accHead));
|
||||
NS_ENSURE_TRUE(accTableHead, NS_ERROR_FAILURE);
|
||||
|
||||
*aColumnHeader = accTableHead;
|
||||
NS_IF_ADDREF(*aColumnHeader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetRows(PRInt32 *aRows)
|
||||
{
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 columns;
|
||||
return tableLayout->GetTableSize(*aRows, columns);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetRowHeader(nsIAccessibleTable **aRowHeader)
|
||||
{
|
||||
// Can not implement because there is no row header in html table
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetSelectedColumns(PRUint32 *aNumColumns,
|
||||
PRInt32 **aColumns)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columnCount;
|
||||
rv = GetColumns(&columnCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool *states = new PRBool[columnCount];
|
||||
NS_ENSURE_TRUE(states, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aNumColumns = 0;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < columnCount; index++) {
|
||||
rv = IsColumnSelected(index, &states[index]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (states[index]) {
|
||||
(*aNumColumns)++;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 *outArray = (PRInt32 *)nsMemory::Alloc((*aNumColumns) * sizeof(PRInt32));
|
||||
if (!outArray) {
|
||||
delete []states;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRInt32 curr = 0;
|
||||
for (index = 0; index < columnCount; index++) {
|
||||
if (states[index]) {
|
||||
outArray[curr++] = index;
|
||||
}
|
||||
}
|
||||
|
||||
delete []states;
|
||||
*aColumns = outArray;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetSelectedRows(PRUint32 *aNumRows, PRInt32 **aRows)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 rowCount;
|
||||
rv = GetRows(&rowCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool *states = new PRBool[rowCount];
|
||||
NS_ENSURE_TRUE(states, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aNumRows = 0;
|
||||
PRInt32 index;
|
||||
for (index = 0; index < rowCount; index++) {
|
||||
rv = IsRowSelected(index, &states[index]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (states[index]) {
|
||||
(*aNumRows)++;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 *outArray = (PRInt32 *)nsMemory::Alloc((*aNumRows) * sizeof(PRInt32));
|
||||
if (!outArray) {
|
||||
delete []states;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRInt32 curr = 0;
|
||||
for (index = 0; index < rowCount; index++) {
|
||||
if (states[index]) {
|
||||
outArray[curr++] = index;
|
||||
}
|
||||
}
|
||||
|
||||
delete []states;
|
||||
*aRows = outArray;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::CellRefAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
nsIAccessible **aTableCellAccessible)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> cellElement;
|
||||
rv = GetCellAt(aRow, aColumn, *getter_AddRefs(cellElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAccessibilityService>
|
||||
accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
return accService->GetAccessibleInWeakShell(cellElement, mWeakShell,
|
||||
aTableCellAccessible);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetIndexAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = aRow * columns + aColumn;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetColumnAtIndex(PRInt32 aIndex, PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = aIndex % columns;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetRowAtIndex(PRInt32 aIndex, PRInt32 *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = aIndex / columns;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
rv = GetCellAt(aRow, aColumn, *getter_AddRefs(domElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCellElement> cell(do_QueryInterface(domElement));
|
||||
NS_ENSURE_TRUE(cell, NS_ERROR_FAILURE);
|
||||
|
||||
return cell->GetColSpan(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetRowExtentAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
rv = GetCellAt(aRow, aColumn, *getter_AddRefs(domElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableCellElement> cell(do_QueryInterface(domElement));
|
||||
NS_ENSURE_TRUE(cell, NS_ERROR_FAILURE);
|
||||
|
||||
return cell->GetRowSpan(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetColumnDescription(PRInt32 aColumn, nsAString &_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetRowDescription(PRInt32 aRow, nsAString &_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::IsColumnSelected(PRInt32 aColumn, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 rows;
|
||||
rv = GetRows(&rows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRInt32 index = 0; index < rows; index++) {
|
||||
rv = IsCellSelected(index, aColumn, _retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!*_retval) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::IsRowSelected(PRInt32 aRow, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 columns;
|
||||
rv = GetColumns(&columns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRInt32 index = 0; index < columns; index++) {
|
||||
rv = IsCellSelected(aRow, index, _retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!*_retval) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::IsCellSelected(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
PRInt32 startRowIndex = 0, startColIndex = 0,
|
||||
rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
|
||||
return tableLayout->GetCellDataAt(aRow, aColumn,
|
||||
*getter_AddRefs(domElement),
|
||||
startRowIndex, startColIndex, rowSpan,
|
||||
colSpan, actualRowSpan, actualColSpan,
|
||||
*_retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTableAccessible::GetTableNode(nsIDOMNode **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
||||
if (table) {
|
||||
*_retval = table;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> section(do_QueryInterface(mDOMNode));
|
||||
if (section) {
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = section->GetParentNode(getter_AddRefs(parent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*_retval = parent;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTableAccessible::GetTableLayout(nsITableLayout **aLayoutObject)
|
||||
{
|
||||
*aLayoutObject = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tableNode;
|
||||
rv = GetTableNode(getter_AddRefs(tableNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(tableNode));
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
nsIPresShell *presShell = content->GetDocument()->GetShellAt(0);
|
||||
|
||||
nsCOMPtr<nsISupports> layoutObject;
|
||||
rv = presShell->GetLayoutObjectFor(content, getter_AddRefs(layoutObject));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(layoutObject, aLayoutObject);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTableAccessible::GetCellAt(PRInt32 aRowIndex,
|
||||
PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell)
|
||||
{
|
||||
PRInt32 startRowIndex = 0, startColIndex = 0,
|
||||
rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
PRBool isSelected;
|
||||
|
||||
nsITableLayout *tableLayout;
|
||||
nsresult rv = GetTableLayout(&tableLayout);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return tableLayout->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
||||
startRowIndex, startColIndex,
|
||||
rowSpan, colSpan,
|
||||
actualRowSpan, actualColSpan,
|
||||
isSelected);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsHTMLTableHeadAccessible Accessible
|
||||
// --------------------------------------------------------
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTableHeadAccessible, nsHTMLTableAccessible)
|
||||
|
||||
nsHTMLTableHeadAccessible::nsHTMLTableHeadAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell):
|
||||
nsHTMLTableAccessible(aDomNode, aShell)
|
||||
{
|
||||
Init(); // Make sure this generated accessible of the table is cached
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetRole(PRUint32 *aResult)
|
||||
{
|
||||
*aResult = ROLE_COLUMNHEADER;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetCaption(nsIAccessible **aCaption)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::SetCaption(nsIAccessible *aCaption)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetSummary(nsAString &aSummary)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::SetSummary(const nsAString &aSummary)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableHeadAccessible::GetRows(PRInt32 *aRows)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLTableSectionElement> head(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(head, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
rv = head->GetRows(getter_AddRefs(rows));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return rows->GetLength((PRUint32 *)aRows);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define _nsHTMLTableAccessible_H_
|
||||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsIAccessibleTable.h"
|
||||
|
||||
class nsHTMLTableCellAccessible : public nsHyperTextAccessible
|
||||
{
|
||||
|
@ -51,15 +52,45 @@ public:
|
|||
NS_IMETHOD GetState(PRUint32 *aResult);
|
||||
};
|
||||
|
||||
class nsHTMLTableAccessible : public nsHyperTextAccessible
|
||||
class nsITableLayout;
|
||||
|
||||
class nsHTMLTableAccessible : public nsAccessibleWrap
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLETABLE
|
||||
|
||||
nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetRole(PRUint32 *aResult);
|
||||
NS_IMETHOD GetState(PRUint32 *aResult);
|
||||
NS_IMETHOD GetName(nsAString& aResult);
|
||||
|
||||
protected:
|
||||
nsresult GetTableNode(nsIDOMNode **_retval);
|
||||
nsresult GetTableLayout(nsITableLayout **aLayoutObject);
|
||||
nsresult GetCellAt(PRInt32 aRowIndex,
|
||||
PRInt32 aColIndex,
|
||||
nsIDOMElement* &aCell);
|
||||
};
|
||||
|
||||
|
||||
class nsHTMLTableHeadAccessible : public nsHTMLTableAccessible
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLTableHeadAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell);
|
||||
|
||||
/* nsIAccessible */
|
||||
NS_IMETHOD GetRole(PRUint32 *aResult);
|
||||
|
||||
/* nsIAccessibleTable */
|
||||
NS_IMETHOD GetCaption(nsIAccessible **aCaption);
|
||||
NS_IMETHOD SetCaption(nsIAccessible *aCaption);
|
||||
NS_IMETHOD GetSummary(nsAString &aSummary);
|
||||
NS_IMETHOD SetSummary(const nsAString &aSummary);
|
||||
NS_IMETHOD GetColumnHeader(nsIAccessibleTable **aColumnHeader);
|
||||
NS_IMETHOD GetRows(PRInt32 *aRows);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,8 +53,4 @@ class nsAccessibleWrap : public nsAccessible
|
|||
virtual ~nsAccessibleWrap();
|
||||
};
|
||||
|
||||
// Define unsupported wrap classes here
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -197,8 +197,6 @@ protected:
|
|||
|
||||
// Define unsupported wrap classes here
|
||||
typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,8 +53,4 @@ class nsAccessibleWrap : public nsAccessible
|
|||
virtual ~nsAccessibleWrap();
|
||||
};
|
||||
|
||||
// Define unsupported wrap classes here
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче