2009-08-19 23:45:19 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
2011-03-01 21:16:20 -08:00
|
|
|
* Mozilla Foundation.
|
2009-08-19 23:45:19 -07:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
#include "nsXULTreeGridAccessibleWrap.h"
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccCache.h"
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsAccUtils.h"
|
2010-11-12 11:00:55 -08:00
|
|
|
#include "nsDocAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsEventShell.h"
|
2011-04-09 16:38:06 -07:00
|
|
|
#include "States.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
#include "nsITreeSelection.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsXULTreeGridAccessible::
|
2010-06-11 01:23:18 -07:00
|
|
|
nsXULTreeGridAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsXULTreeAccessible(aContent, aShell)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridAccessible: nsISupports implementation
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeGridAccessible,
|
|
|
|
nsXULTreeAccessible,
|
|
|
|
nsIAccessibleTable)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridAccessible: nsIAccessibleTable implementation
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetCaption(nsIAccessible **aCaption)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCaption);
|
|
|
|
*aCaption = nsnull;
|
|
|
|
|
|
|
|
return IsDefunct() ? NS_ERROR_FAILURE : NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetSummary(nsAString &aSummary)
|
|
|
|
{
|
|
|
|
aSummary.Truncate();
|
|
|
|
return IsDefunct() ? NS_ERROR_FAILURE : NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-12-10 11:12:19 -08:00
|
|
|
nsXULTreeGridAccessible::GetColumnCount(PRInt32 *aColumnCount)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2009-12-10 11:12:19 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aColumnCount);
|
|
|
|
*aColumnCount = 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
*aColumnCount = nsCoreUtils::GetSensibleColumnCount(mTree);
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetRowCount(PRInt32 *arowCount)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(arowCount);
|
|
|
|
*arowCount = nsnull;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
return mTreeView->GetRowCount(arowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetSelectedCellCount(PRUint32* aCount)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCount);
|
|
|
|
*aCount = 0;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRUint32 selectedrowCount = 0;
|
|
|
|
nsresult rv = GetSelectedRowCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aCount = selectedrowCount * columnCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetSelectedColumnCount(PRUint32* aCount)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCount);
|
|
|
|
*aCount = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// If all the row has been selected, then all the columns are selected,
|
|
|
|
// because we can't select a column alone.
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 rowCount = 0;
|
|
|
|
nsresult rv = GetRowCount(&rowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
rv = GetSelectionCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (rowCount == selectedrowCount) {
|
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aCount = columnCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetSelectedRowCount(PRUint32* aCount)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCount);
|
|
|
|
*aCount = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
nsresult rv = GetSelectionCount(&selectedrowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aCount = selectedrowCount;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetSelectedCells(nsIArray **aCells)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCells);
|
|
|
|
*aCells = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMutableArray> selCells = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(selCells, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
nsresult rv = GetSelectionCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
rv = GetColumnCount(&columnCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRInt32 rowCount = 0;
|
|
|
|
rv = GetRowCount(&rowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRBool isSelected;
|
|
|
|
for (PRInt32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
|
|
|
selection->IsSelected(rowIdx, &isSelected);
|
|
|
|
if (isSelected) {
|
|
|
|
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++) {
|
|
|
|
nsCOMPtr<nsIAccessible> cell;
|
|
|
|
GetCellAt(rowIdx, colIdx, getter_AddRefs(cell));
|
|
|
|
selCells->AppendElement(cell, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aCells = selCells);
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetSelectedCellIndices(PRUint32 *aCellsCount,
|
|
|
|
PRInt32 **aCells)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCellsCount);
|
|
|
|
*aCellsCount = 0;
|
|
|
|
NS_ENSURE_ARG_POINTER(aCells);
|
|
|
|
*aCells = nsnull;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
nsresult rv = GetSelectionCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedCellCount = selectedrowCount * columnCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
PRInt32* outArray = static_cast<PRInt32*>(
|
2009-09-10 18:07:56 -07:00
|
|
|
nsMemory::Alloc(selectedCellCount * sizeof(PRInt32)));
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 rowCount = 0;
|
|
|
|
rv = GetRowCount(&rowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRBool isSelected;
|
2009-09-10 18:07:56 -07:00
|
|
|
for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowCount; rowIdx++) {
|
2009-08-19 23:45:19 -07:00
|
|
|
selection->IsSelected(rowIdx, &isSelected);
|
|
|
|
if (isSelected) {
|
2009-09-10 18:07:56 -07:00
|
|
|
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++)
|
|
|
|
outArray[arrayIdx++] = rowIdx * columnCount + colIdx;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aCellsCount = selectedCellCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
*aCells = outArray;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetSelectedColumnIndices(PRUint32 *acolumnCount,
|
|
|
|
PRInt32 **aColumns)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(acolumnCount);
|
|
|
|
*acolumnCount = 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aColumns);
|
|
|
|
*aColumns = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// If all the row has been selected, then all the columns are selected.
|
|
|
|
// Because we can't select a column alone.
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 rowCount = 0;
|
|
|
|
nsresult rv = GetRowCount(&rowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
rv = GetSelectionCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (rowCount != selectedrowCount)
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRInt32* outArray = static_cast<PRInt32*>(
|
2009-09-10 18:07:56 -07:00
|
|
|
nsMemory::Alloc(columnCount * sizeof(PRInt32)));
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++)
|
2009-08-19 23:45:19 -07:00
|
|
|
outArray[colIdx] = colIdx;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*acolumnCount = columnCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
*aColumns = outArray;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetSelectedRowIndices(PRUint32 *arowCount,
|
|
|
|
PRInt32 **aRows)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(arowCount);
|
|
|
|
*arowCount = 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aRows);
|
|
|
|
*aRows = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
nsresult rv = GetSelectionCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRInt32* outArray = static_cast<PRInt32*>(
|
2009-09-10 18:07:56 -07:00
|
|
|
nsMemory::Alloc(selectedrowCount * sizeof(PRInt32)));
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_TRUE(outArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 rowCount = 0;
|
|
|
|
rv = GetRowCount(&rowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRBool isSelected;
|
2009-09-10 18:07:56 -07:00
|
|
|
for (PRInt32 rowIdx = 0, arrayIdx = 0; rowIdx < rowCount; rowIdx++) {
|
2009-08-19 23:45:19 -07:00
|
|
|
selection->IsSelected(rowIdx, &isSelected);
|
|
|
|
if (isSelected)
|
|
|
|
outArray[arrayIdx++] = rowIdx;
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*arowCount = selectedrowCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
*aRows = outArray;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
|
2009-08-19 23:45:19 -07:00
|
|
|
nsIAccessible **aCell)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCell);
|
|
|
|
*aCell = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
nsAccessible *rowAccessible = GetTreeItemAccessible(aRowIndex);
|
2009-08-19 23:45:19 -07:00
|
|
|
if (!rowAccessible)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> column =
|
|
|
|
nsCoreUtils::GetSensibleColumnAt(mTree, aColumnIndex);
|
|
|
|
if (!column)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2010-05-11 02:48:10 -07:00
|
|
|
nsRefPtr<nsXULTreeItemAccessibleBase> rowAcc = do_QueryObject(rowAccessible);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
NS_IF_ADDREF(*aCell = rowAcc->GetCellAccessible(column));
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
|
|
|
|
PRInt32 *aCellIndex)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCellIndex);
|
|
|
|
*aCellIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
nsresult rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aCellIndex = aRowIndex * columnCount + aColumnIndex;
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetColumnIndexAt(PRInt32 aCellIndex,
|
2009-08-19 23:45:19 -07:00
|
|
|
PRInt32 *aColumnIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
|
|
|
*aColumnIndex = -1;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
nsresult rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aColumnIndex = aCellIndex % columnCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-09-10 18:07:56 -07:00
|
|
|
nsXULTreeGridAccessible::GetRowIndexAt(PRInt32 aCellIndex, PRInt32 *aRowIndex)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRowIndex);
|
|
|
|
*aRowIndex = -1;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount;
|
|
|
|
nsresult rv = GetColumnCount(&columnCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aRowIndex = aCellIndex / columnCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-02 20:16:52 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
|
|
|
|
PRInt32* aRowIndex,
|
|
|
|
PRInt32* aColumnIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRowIndex);
|
|
|
|
*aRowIndex = -1;
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
|
|
|
*aColumnIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
nsresult rv = GetColumnCount(&columnCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aColumnIndex = aCellIndex % columnCount;
|
|
|
|
*aRowIndex = aCellIndex / columnCount;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetColumnExtentAt(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColumnIndex,
|
|
|
|
PRInt32 *aExtentCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 1;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetRowExtentAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
|
|
|
|
PRInt32 *aExtentCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 1;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetColumnDescription(PRInt32 aColumnIndex,
|
|
|
|
nsAString& aDescription)
|
|
|
|
{
|
|
|
|
aDescription.Truncate();
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessible> treeColumns;
|
|
|
|
nsAccessible::GetFirstChild(getter_AddRefs(treeColumns));
|
|
|
|
if (treeColumns) {
|
|
|
|
nsCOMPtr<nsIAccessible> treeColumnItem;
|
|
|
|
treeColumns->GetChildAt(aColumnIndex, getter_AddRefs(treeColumnItem));
|
|
|
|
if (treeColumnItem)
|
|
|
|
return treeColumnItem->GetName(aDescription);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::GetRowDescription(PRInt32 aRowIndex,
|
|
|
|
nsAString& aDescription)
|
|
|
|
{
|
|
|
|
aDescription.Truncate();
|
2009-09-10 18:07:56 -07:00
|
|
|
return NS_OK;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::IsColumnSelected(PRInt32 aColumnIndex,
|
|
|
|
PRBool *aIsSelected)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsSelected);
|
|
|
|
*aIsSelected = PR_FALSE;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// If all the row has been selected, then all the columns are selected.
|
|
|
|
// Because we can't select a column alone.
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 rowCount = 0;
|
|
|
|
nsresult rv = GetRowCount(&rowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
rv = GetSelectionCount(&selectedrowCount);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aIsSelected = rowCount == selectedrowCount;
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::IsRowSelected(PRInt32 aRowIndex, PRBool *aIsSelected)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsSelected);
|
|
|
|
*aIsSelected = PR_FALSE;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
nsresult rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return selection->IsSelected(aRowIndex, aIsSelected);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::IsCellSelected(PRInt32 aRowIndex, PRInt32 aColumnIndex,
|
|
|
|
PRBool *aIsSelected)
|
|
|
|
{
|
|
|
|
return IsRowSelected(aRowIndex, aIsSelected);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::SelectRow(PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_STATE(selection);
|
|
|
|
|
|
|
|
return selection->Select(aRowIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::SelectColumn(PRInt32 aColumnIndex)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::UnselectRow(PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_STATE(selection);
|
|
|
|
|
|
|
|
return selection->ClearRange(aRowIndex, aRowIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::UnselectColumn(PRInt32 aColumnIndex)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridAccessible::IsProbablyForLayout(PRBool *aIsProbablyForLayout)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsProbablyForLayout);
|
|
|
|
*aIsProbablyForLayout = PR_FALSE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridAccessible: nsAccessible implementation
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsXULTreeGridAccessible::NativeRole()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsITreeColumns> treeColumns;
|
|
|
|
mTree->GetColumns(getter_AddRefs(treeColumns));
|
2010-09-04 19:14:01 -07:00
|
|
|
if (!treeColumns) {
|
|
|
|
NS_ERROR("No treecolumns object for tree!");
|
|
|
|
return nsIAccessibleRole::ROLE_NOTHING;
|
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> primaryColumn;
|
|
|
|
treeColumns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
return primaryColumn ?
|
2010-08-18 19:14:50 -07:00
|
|
|
static_cast<PRUint32>(nsIAccessibleRole::ROLE_TREE_TABLE) :
|
|
|
|
static_cast<PRUint32>(nsIAccessibleRole::ROLE_TABLE);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridAccessible: nsXULTreeAccessible implementation
|
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsXULTreeGridAccessible::CreateTreeItemAccessible(PRInt32 aRow)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2010-03-10 02:26:11 -08:00
|
|
|
nsRefPtr<nsAccessible> accessible =
|
2010-06-11 01:23:18 -07:00
|
|
|
new nsXULTreeGridRowAccessible(mContent, mWeakShell, this, mTree,
|
2010-03-10 02:26:11 -08:00
|
|
|
mTreeView, aRow);
|
|
|
|
|
|
|
|
return accessible.forget();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridRowAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsXULTreeGridRowAccessible::
|
2010-06-11 01:23:18 -07:00
|
|
|
nsXULTreeGridRowAccessible(nsIContent *aContent, nsIWeakReference *aShell,
|
2010-01-11 06:14:06 -08:00
|
|
|
nsAccessible *aTreeAcc, nsITreeBoxObject* aTree,
|
2009-08-19 23:45:19 -07:00
|
|
|
nsITreeView *aTreeView, PRInt32 aRow) :
|
2010-06-11 01:23:18 -07:00
|
|
|
nsXULTreeItemAccessibleBase(aContent, aShell, aTreeAcc, aTree, aTreeView, aRow)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2010-03-10 02:26:11 -08:00
|
|
|
mAccessibleCache.Init(kDefaultTreeCacheSize);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridRowAccessible: nsISupports and cycle collection implementation
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTreeGridRowAccessible)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULTreeGridRowAccessible,
|
2011-06-09 02:44:31 -07:00
|
|
|
nsXULTreeItemAccessibleBase)
|
2010-03-10 02:26:11 -08:00
|
|
|
CycleCollectorTraverseCache(tmp->mAccessibleCache, &cb);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULTreeGridRowAccessible,
|
2011-06-09 02:44:31 -07:00
|
|
|
nsXULTreeItemAccessibleBase)
|
2010-03-10 02:26:11 -08:00
|
|
|
ClearCache(tmp->mAccessibleCache);
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXULTreeGridRowAccessible)
|
|
|
|
NS_INTERFACE_MAP_STATIC_AMBIGUOUS(nsXULTreeGridRowAccessible)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsXULTreeItemAccessibleBase)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsXULTreeGridRowAccessible,
|
|
|
|
nsXULTreeItemAccessibleBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsXULTreeGridRowAccessible,
|
|
|
|
nsXULTreeItemAccessibleBase)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridRowAccessible: nsAccessNode implementation
|
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
void
|
2009-08-19 23:45:19 -07:00
|
|
|
nsXULTreeGridRowAccessible::Shutdown()
|
|
|
|
{
|
2010-03-10 02:26:11 -08:00
|
|
|
ClearCache(mAccessibleCache);
|
2010-06-11 21:04:35 -07:00
|
|
|
nsXULTreeItemAccessibleBase::Shutdown();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridRowAccessible: nsAccessible implementation
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsXULTreeGridRowAccessible::NativeRole()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_ROW;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2011-06-09 02:09:05 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridRowAccessible::GetName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumns> columns;
|
|
|
|
mTree->GetColumns(getter_AddRefs(columns));
|
|
|
|
if (columns) {
|
|
|
|
nsCOMPtr<nsITreeColumn> primaryColumn;
|
|
|
|
columns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
|
|
|
|
if (primaryColumn)
|
|
|
|
GetCellName(primaryColumn, aName);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-03-28 21:44:20 -07:00
|
|
|
nsAccessible*
|
2009-08-19 23:45:19 -07:00
|
|
|
nsXULTreeGridRowAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY,
|
2011-03-28 21:44:20 -07:00
|
|
|
EWhichChildAtPoint aWhichChild)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
nsIFrame *frame = GetFrame();
|
|
|
|
if (!frame)
|
2011-03-28 21:44:20 -07:00
|
|
|
return nsnull;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsPresContext *presContext = frame->PresContext();
|
|
|
|
nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
|
|
|
|
|
|
|
|
nsIFrame *rootFrame = presShell->GetRootFrame();
|
2011-03-28 21:44:20 -07:00
|
|
|
NS_ENSURE_TRUE(rootFrame, nsnull);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsIntRect rootRect = rootFrame->GetScreenRectExternal();
|
|
|
|
|
|
|
|
PRInt32 clientX = presContext->DevPixelsToIntCSSPixels(aX - rootRect.x);
|
|
|
|
PRInt32 clientY = presContext->DevPixelsToIntCSSPixels(aY - rootRect.y);
|
|
|
|
|
|
|
|
PRInt32 row = -1;
|
|
|
|
nsCOMPtr<nsITreeColumn> column;
|
|
|
|
nsCAutoString childEltUnused;
|
|
|
|
mTree->GetCellAt(clientX, clientY, &row, getter_AddRefs(column),
|
|
|
|
childEltUnused);
|
|
|
|
|
|
|
|
// Return if we failed to find tree cell in the row for the given point.
|
|
|
|
if (row != mRow || !column)
|
2011-03-28 21:44:20 -07:00
|
|
|
return nsnull;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2011-03-28 21:44:20 -07:00
|
|
|
return GetCellAccessible(column);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2010-01-11 06:14:06 -08:00
|
|
|
nsAccessible*
|
2009-12-10 11:12:19 -08:00
|
|
|
nsXULTreeGridRowAccessible::GetChildAt(PRUint32 aIndex)
|
|
|
|
{
|
|
|
|
if (IsDefunct())
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> column =
|
|
|
|
nsCoreUtils::GetSensibleColumnAt(mTree, aIndex);
|
|
|
|
if (!column)
|
|
|
|
return nsnull;
|
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
return GetCellAccessible(column);
|
2009-12-10 11:12:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsXULTreeGridRowAccessible::GetChildCount()
|
|
|
|
{
|
|
|
|
if (IsDefunct())
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return nsCoreUtils::GetSensibleColumnCount(mTree);
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridRowAccessible: nsXULTreeItemAccessibleBase implementation
|
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
nsAccessible*
|
|
|
|
nsXULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aColumn, "No tree column!");
|
|
|
|
|
|
|
|
void* key = static_cast<void*>(aColumn);
|
2010-11-12 11:00:55 -08:00
|
|
|
nsAccessible* cachedCell = mAccessibleCache.GetWeak(key);
|
|
|
|
if (cachedCell)
|
|
|
|
return cachedCell;
|
|
|
|
|
|
|
|
nsRefPtr<nsAccessible> cell =
|
|
|
|
new nsXULTreeGridCellAccessibleWrap(mContent, mWeakShell, this, mTree,
|
|
|
|
mTreeView, mRow, aColumn);
|
|
|
|
if (cell) {
|
|
|
|
if (mAccessibleCache.Put(key, cell)) {
|
|
|
|
if (GetDocAccessible()->BindToDocument(cell, nsnull))
|
|
|
|
return cell;
|
|
|
|
|
|
|
|
mAccessibleCache.Remove(key);
|
2010-03-10 02:26:11 -08:00
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2010-11-12 11:00:55 -08:00
|
|
|
return nsnull;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXULTreeGridRowAccessible::RowInvalidated(PRInt32 aStartColIdx,
|
|
|
|
PRInt32 aEndColIdx)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsITreeColumns> treeColumns;
|
|
|
|
mTree->GetColumns(getter_AddRefs(treeColumns));
|
|
|
|
if (!treeColumns)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (PRInt32 colIdx = aStartColIdx; colIdx <= aEndColIdx; ++colIdx) {
|
|
|
|
nsCOMPtr<nsITreeColumn> column;
|
|
|
|
treeColumns->GetColumnAt(colIdx, getter_AddRefs(column));
|
|
|
|
if (column && !nsCoreUtils::IsColumnHidden(column)) {
|
2010-03-10 02:26:11 -08:00
|
|
|
nsAccessible *cellAccessible = GetCellAccessible(column);
|
2009-08-19 23:45:19 -07:00
|
|
|
if (cellAccessible) {
|
2010-05-11 02:48:10 -07:00
|
|
|
nsRefPtr<nsXULTreeGridCellAccessible> cellAcc = do_QueryObject(cellAccessible);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
cellAcc->CellInvalidated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridRowAccessible: nsAccessible protected implementation
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXULTreeGridRowAccessible::CacheChildren()
|
|
|
|
{
|
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsXULTreeGridCellAccessible::
|
2010-06-11 01:23:18 -07:00
|
|
|
nsXULTreeGridCellAccessible(nsIContent *aContent, nsIWeakReference *aShell,
|
2009-08-19 23:45:19 -07:00
|
|
|
nsXULTreeGridRowAccessible *aRowAcc,
|
|
|
|
nsITreeBoxObject *aTree, nsITreeView *aTreeView,
|
|
|
|
PRInt32 aRow, nsITreeColumn* aColumn) :
|
2010-06-11 01:23:18 -07:00
|
|
|
nsLeafAccessible(aContent, aShell), mTree(aTree),
|
2009-08-19 23:45:19 -07:00
|
|
|
mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
|
|
|
|
{
|
|
|
|
mParent = aRowAcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible: nsISupports implementation
|
|
|
|
|
2011-06-09 02:44:31 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTreeGridCellAccessible)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULTreeGridCellAccessible,
|
|
|
|
nsLeafAccessible)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTree)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTreeView)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mColumn)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULTreeGridCellAccessible,
|
|
|
|
nsLeafAccessible)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTree)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTreeView)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mColumn)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXULTreeGridCellAccessible)
|
|
|
|
NS_INTERFACE_TABLE_INHERITED2(nsXULTreeGridCellAccessible,
|
|
|
|
nsIAccessibleTableCell,
|
|
|
|
nsXULTreeGridCellAccessible)
|
|
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(nsLeafAccessible)
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsXULTreeGridCellAccessible, nsLeafAccessible)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsXULTreeGridCellAccessible, nsLeafAccessible)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible: nsIAccessible implementation
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFocusedChild);
|
|
|
|
*aFocusedChild = nsnull;
|
|
|
|
|
|
|
|
return IsDefunct() ? NS_ERROR_FAILURE : NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
mTreeView->GetCellText(mRow, mColumn, aName);
|
|
|
|
|
|
|
|
// If there is still no name try the cell value:
|
|
|
|
// This is for graphical cells. We need tree/table view implementors to implement
|
|
|
|
// FooView::GetCellValue to return a meaningful string for cases where there is
|
|
|
|
// something shown in the cell (non-text) such as a star icon; in which case
|
|
|
|
// GetCellValue for that cell would return "starred" or "flagged" for example.
|
|
|
|
if (aName.IsEmpty())
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, aName);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY,
|
|
|
|
PRInt32 *aWidth, PRInt32 *aHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aX);
|
|
|
|
*aX = 0;
|
|
|
|
NS_ENSURE_ARG_POINTER(aY);
|
|
|
|
*aY = 0;
|
|
|
|
NS_ENSURE_ARG_POINTER(aWidth);
|
|
|
|
*aWidth = 0;
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeight);
|
|
|
|
*aHeight = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Get bounds for tree cell and add x and y of treechildren element to
|
|
|
|
// x and y of the cell.
|
|
|
|
nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
|
|
|
|
NS_ENSURE_STATE(boxObj);
|
|
|
|
|
|
|
|
PRInt32 x = 0, y = 0, width = 0, height = 0;
|
|
|
|
nsresult rv = mTree->GetCoordsForCellItem(mRow, mColumn,
|
|
|
|
NS_LITERAL_CSTRING("cell"),
|
|
|
|
&x, &y, &width, &height);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
PRInt32 tcX = 0, tcY = 0;
|
|
|
|
boxObj->GetScreenX(&tcX);
|
|
|
|
boxObj->GetScreenY(&tcY);
|
|
|
|
x += tcX;
|
|
|
|
y += tcY;
|
|
|
|
|
|
|
|
nsPresContext *presContext = GetPresContext();
|
|
|
|
*aX = presContext->CSSPixelsToDevPixels(x);
|
|
|
|
*aY = presContext->CSSPixelsToDevPixels(y);
|
|
|
|
*aWidth = presContext->CSSPixelsToDevPixels(width);
|
|
|
|
*aHeight = presContext->CSSPixelsToDevPixels(height);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetNumActions(PRUint8 *aActionsCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aActionsCount);
|
|
|
|
*aActionsCount = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PRBool isCycler = PR_FALSE;
|
|
|
|
mColumn->GetCycler(&isCycler);
|
|
|
|
if (isCycler) {
|
|
|
|
*aActionsCount = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt16 type;
|
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
|
|
|
|
*aActionsCount = 1;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
|
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PRBool isCycler = PR_FALSE;
|
|
|
|
mColumn->GetCycler(&isCycler);
|
|
|
|
if (isCycler) {
|
|
|
|
aName.AssignLiteral("cycle");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt16 type;
|
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
|
|
|
|
nsAutoString value;
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, value);
|
|
|
|
if (value.EqualsLiteral("true"))
|
|
|
|
aName.AssignLiteral("uncheck");
|
|
|
|
else
|
|
|
|
aName.AssignLiteral("check");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::DoAction(PRUint8 aIndex)
|
|
|
|
{
|
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PRBool isCycler = PR_FALSE;
|
|
|
|
mColumn->GetCycler(&isCycler);
|
2010-01-25 07:09:25 -08:00
|
|
|
if (isCycler) {
|
|
|
|
DoCommand();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
PRInt16 type;
|
|
|
|
mColumn->GetType(&type);
|
2010-01-25 07:09:25 -08:00
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
|
|
|
|
DoCommand();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible: nsIAccessibleTableCell implementation
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetTable(nsIAccessibleTable **aTable)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTable);
|
|
|
|
*aTable = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-01-11 06:14:06 -08:00
|
|
|
CallQueryInterface(mParent->GetParent(), aTable);
|
2009-09-10 18:07:56 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetColumnIndex(PRInt32 *aColumnIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
|
|
|
*aColumnIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aColumnIndex = GetColumnIndex();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetRowIndex(PRInt32 *aRowIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRowIndex);
|
|
|
|
*aRowIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aRowIndex = mRow;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetColumnExtent(PRInt32 *aExtentCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 1;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetRowExtent(PRInt32 *aExtentCount)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 1;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetColumnHeaderCells(nsIArray **aHeaderCells)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMutableArray> headerCells =
|
|
|
|
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> columnElm;
|
|
|
|
mColumn->GetElement(getter_AddRefs(columnElm));
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIContent> columnContent(do_QueryInterface(columnElm));
|
2010-05-25 01:05:52 -07:00
|
|
|
nsAccessible *headerCell =
|
2010-06-11 01:23:18 -07:00
|
|
|
GetAccService()->GetAccessibleInWeakShell(columnContent, mWeakShell);
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
if (headerCell)
|
2010-05-25 01:05:52 -07:00
|
|
|
headerCells->AppendElement(static_cast<nsIAccessible*>(headerCell),
|
2010-04-23 17:40:51 -07:00
|
|
|
PR_FALSE);
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
NS_ADDREF(*aHeaderCells = headerCells);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::GetRowHeaderCells(nsIArray **aHeaderCells)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMutableArray> headerCells =
|
|
|
|
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
NS_ADDREF(*aHeaderCells = headerCells);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTreeGridCellAccessible::IsSelected(PRBool *aIsSelected)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsSelected);
|
|
|
|
*aIsSelected = PR_FALSE;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
nsresult rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return selection->IsSelected(mRow, aIsSelected);
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible: nsAccessNode implementation
|
|
|
|
|
2011-05-28 02:26:45 -07:00
|
|
|
bool
|
|
|
|
nsXULTreeGridCellAccessible::IsDefunct() const
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
return nsLeafAccessible::IsDefunct() || !mParent || !mTree || !mTreeView ||
|
|
|
|
!mColumn;
|
|
|
|
}
|
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
PRBool
|
2009-08-19 23:45:19 -07:00
|
|
|
nsXULTreeGridCellAccessible::Init()
|
|
|
|
{
|
2010-06-11 21:04:35 -07:00
|
|
|
if (!nsLeafAccessible::Init())
|
|
|
|
return PR_FALSE;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
PRInt16 type;
|
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX)
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, mCachedTextEquiv);
|
|
|
|
else
|
|
|
|
mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
|
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
return PR_TRUE;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
bool
|
|
|
|
nsXULTreeGridCellAccessible::IsPrimaryForNode() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// nsXULTreeGridCellAccessible: nsAccessible public implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// "table-cell-index" attribute
|
|
|
|
nsCOMPtr<nsIAccessible> accessible;
|
|
|
|
mParent->GetParent(getter_AddRefs(accessible));
|
|
|
|
nsCOMPtr<nsIAccessibleTable> tableAccessible = do_QueryInterface(accessible);
|
|
|
|
|
2009-09-18 09:20:45 -07:00
|
|
|
// XXX - temp fix for crash bug 516047
|
|
|
|
if (!tableAccessible)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
PRInt32 colIdx = GetColumnIndex();
|
|
|
|
|
|
|
|
PRInt32 cellIdx = -1;
|
2009-09-10 18:07:56 -07:00
|
|
|
tableAccessible->GetCellIndexAt(mRow, colIdx, &cellIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsAutoString stringIdx;
|
|
|
|
stringIdx.AppendInt(cellIdx);
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::tableCellIndex,
|
|
|
|
stringIdx);
|
|
|
|
|
|
|
|
// "cycles" attribute
|
|
|
|
PRBool isCycler = PR_FALSE;
|
|
|
|
nsresult rv = mColumn->GetCycler(&isCycler);
|
|
|
|
if (NS_SUCCEEDED(rv) && isCycler)
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsAccessibilityAtoms::cycles,
|
|
|
|
NS_LITERAL_STRING("true"));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsXULTreeGridCellAccessible::NativeRole()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_GRID_CELL;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsXULTreeGridCellAccessible::NativeState()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
// selectable/selected state
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 states = states::SELECTABLE;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
if (selection) {
|
|
|
|
PRBool isSelected = PR_FALSE;
|
|
|
|
selection->IsSelected(mRow, &isSelected);
|
|
|
|
if (isSelected)
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::SELECTED;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// checked state
|
|
|
|
PRInt16 type;
|
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX) {
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::CHECKABLE;
|
2009-08-19 23:45:19 -07:00
|
|
|
nsAutoString checked;
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, checked);
|
|
|
|
if (checked.EqualsIgnoreCase("true"))
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::CHECKED;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return states;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2011-01-30 20:04:39 -08:00
|
|
|
PRInt32
|
2011-06-13 02:08:40 -07:00
|
|
|
nsXULTreeGridCellAccessible::IndexInParent() const
|
2011-01-30 20:04:39 -08:00
|
|
|
{
|
|
|
|
return GetColumnIndex();
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible: public implementation
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsXULTreeGridCellAccessible::GetColumnIndex() const
|
|
|
|
{
|
|
|
|
PRInt32 index = 0;
|
|
|
|
nsCOMPtr<nsITreeColumn> column = mColumn;
|
|
|
|
while (column = nsCoreUtils::GetPreviousSensibleColumn(column))
|
|
|
|
index++;
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXULTreeGridCellAccessible::CellInvalidated()
|
|
|
|
{
|
|
|
|
nsAutoString textEquiv;
|
|
|
|
|
|
|
|
PRInt16 type;
|
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX) {
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, textEquiv);
|
|
|
|
if (mCachedTextEquiv != textEquiv) {
|
|
|
|
PRBool isEnabled = textEquiv.EqualsLiteral("true");
|
2010-08-24 19:08:28 -07:00
|
|
|
nsRefPtr<AccEvent> accEvent =
|
2011-04-09 16:38:06 -07:00
|
|
|
new AccStateChangeEvent(this, states::CHECKED, isEnabled);
|
2010-01-18 08:17:01 -08:00
|
|
|
nsEventShell::FireEvent(accEvent);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
mCachedTextEquiv = textEquiv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mTreeView->GetCellText(mRow, mColumn, textEquiv);
|
|
|
|
if (mCachedTextEquiv != textEquiv) {
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
|
2009-08-19 23:45:19 -07:00
|
|
|
mCachedTextEquiv = textEquiv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-12-10 11:12:19 -08:00
|
|
|
// nsXULTreeGridCellAccessible: nsAccessible protected implementation
|
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
nsAccessible*
|
2009-12-10 11:12:19 -08:00
|
|
|
nsXULTreeGridCellAccessible::GetSiblingAtOffset(PRInt32 aOffset,
|
2011-06-06 19:23:13 -07:00
|
|
|
nsresult* aError) const
|
2009-12-10 11:12:19 -08:00
|
|
|
{
|
|
|
|
if (aError)
|
2011-06-06 19:23:13 -07:00
|
|
|
*aError = NS_OK; // fail peacefully
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> columnAtOffset(mColumn), column;
|
|
|
|
if (aOffset < 0) {
|
|
|
|
for (PRInt32 index = aOffset; index < 0 && columnAtOffset; index++) {
|
|
|
|
column = nsCoreUtils::GetPreviousSensibleColumn(columnAtOffset);
|
|
|
|
column.swap(columnAtOffset);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (PRInt32 index = aOffset; index > 0 && columnAtOffset; index--) {
|
|
|
|
column = nsCoreUtils::GetNextSensibleColumn(columnAtOffset);
|
|
|
|
column.swap(columnAtOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!columnAtOffset)
|
|
|
|
return nsnull;
|
|
|
|
|
2011-06-06 19:23:13 -07:00
|
|
|
nsRefPtr<nsXULTreeItemAccessibleBase> rowAcc = do_QueryObject(GetParent());
|
2010-03-10 02:26:11 -08:00
|
|
|
return rowAcc->GetCellAccessible(columnAtOffset);
|
2009-12-10 11:12:19 -08:00
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
nsXULTreeGridCellAccessible::DispatchClickEvent(nsIContent *aContent,
|
|
|
|
PRUint32 aActionIndex)
|
|
|
|
{
|
|
|
|
if (IsDefunct())
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCoreUtils::DispatchClickEvent(mTree, mRow, mColumn);
|
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTreeGridCellAccessible: protected implementation
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
PRBool
|
|
|
|
nsXULTreeGridCellAccessible::IsEditable() const
|
|
|
|
{
|
|
|
|
// XXX: logic corresponds to tree.xml, it's preferable to have interface
|
|
|
|
// method to check it.
|
|
|
|
PRBool isEditable = PR_FALSE;
|
|
|
|
nsresult rv = mTreeView->IsEditable(mRow, mColumn, &isEditable);
|
|
|
|
if (NS_FAILED(rv) || !isEditable)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> columnElm;
|
|
|
|
mColumn->GetElement(getter_AddRefs(columnElm));
|
|
|
|
if (!columnElm)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> columnContent(do_QueryInterface(columnElm));
|
|
|
|
if (!columnContent->AttrValueIs(kNameSpaceID_None,
|
|
|
|
nsAccessibilityAtoms::editable,
|
|
|
|
nsAccessibilityAtoms::_true,
|
|
|
|
eCaseMatters))
|
|
|
|
return PR_FALSE;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
return mContent->AttrValueIs(kNameSpaceID_None,
|
|
|
|
nsAccessibilityAtoms::editable,
|
|
|
|
nsAccessibilityAtoms::_true, eCaseMatters);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|