2009-08-19 23:45:19 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
#include "XULTreeGridAccessibleWrap.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"
|
2012-05-27 02:01:40 -07:00
|
|
|
#include "DocAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsEventShell.h"
|
2011-10-03 07:26:11 -07:00
|
|
|
#include "Relation.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
2011-04-09 16:38:06 -07:00
|
|
|
#include "States.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2012-08-01 11:31:10 -07:00
|
|
|
#include "nsIMutableArray.h"
|
2009-08-19 23:45:19 -07:00
|
|
|
#include "nsITreeSelection.h"
|
2011-08-11 06:29:50 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridAccessible
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridAccessible::
|
|
|
|
XULTreeGridAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
|
|
|
XULTreeAccessible(aContent, aDoc), xpcAccessibleTable(this)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridAccessible: nsISupports implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(XULTreeGridAccessible,
|
|
|
|
XULTreeAccessible,
|
2009-08-19 23:45:19 -07:00
|
|
|
nsIAccessibleTable)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridAccessible: nsIAccessibleTable implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridAccessible::ColCount()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-04-19 14:32:11 -07:00
|
|
|
return nsCoreUtils::GetSensibleColumnCount(mTree);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridAccessible::RowCount()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
2012-04-19 14:32:11 -07:00
|
|
|
return 0;
|
2012-03-28 08:59:01 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowCount = 0;
|
2012-04-19 14:32:11 -07:00
|
|
|
mTreeView->GetRowCount(&rowCount);
|
|
|
|
return rowCount >= 0 ? rowCount : 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-06-20 11:05:31 -07:00
|
|
|
XULTreeGridAccessible::SelectedCellCount()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-06-20 11:05:31 -07:00
|
|
|
return SelectedRowCount() * ColCount();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-06-20 11:05:31 -07:00
|
|
|
XULTreeGridAccessible::SelectedColCount()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
// If all the row has been selected, then all the columns are selected,
|
|
|
|
// because we can't select a column alone.
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t selectedRowCount = 0;
|
2012-06-20 11:05:31 -07:00
|
|
|
nsresult rv = GetSelectionCount(&selectedRowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
return selectedRowCount > 0 && selectedRowCount == RowCount() ? ColCount() : 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-06-20 11:05:31 -07:00
|
|
|
XULTreeGridAccessible::SelectedRowCount()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t selectedRowCount = 0;
|
2012-06-20 11:05:31 -07:00
|
|
|
nsresult rv = GetSelectionCount(&selectedRowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
return selectedRowCount >= 0 ? selectedRowCount : 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
|
2012-06-29 01:14:22 -07:00
|
|
|
void
|
|
|
|
XULTreeGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t colCount = ColCount(), rowCount = RowCount();
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
2012-06-29 01:14:22 -07:00
|
|
|
if (IsRowSelected(rowIdx)) {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t colIdx = 0; colIdx < colCount; colIdx++) {
|
2012-06-29 01:14:22 -07:00
|
|
|
Accessible* cell = CellAt(rowIdx, colIdx);
|
|
|
|
aCells->AppendElement(cell);
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-23 15:34:44 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::SelectedCellIndices(nsTArray<uint32_t>* aCells)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t colCount = ColCount(), rowCount = RowCount();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++)
|
2012-06-23 15:34:44 -07:00
|
|
|
if (IsRowSelected(rowIdx))
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t colIdx = 0; colIdx < colCount; colIdx++)
|
2012-06-23 15:34:44 -07:00
|
|
|
aCells->AppendElement(rowIdx * colCount + colIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-23 15:34:44 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::SelectedColIndices(nsTArray<uint32_t>* aCols)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-06-23 15:34:44 -07:00
|
|
|
if (RowCount() != SelectedRowCount())
|
|
|
|
return;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t colCount = ColCount();
|
2012-06-23 15:34:44 -07:00
|
|
|
aCols->SetCapacity(colCount);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t colIdx = 0; colIdx < colCount; colIdx++)
|
2012-06-23 15:34:44 -07:00
|
|
|
aCols->AppendElement(colIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-23 15:34:44 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::SelectedRowIndices(nsTArray<uint32_t>* aRows)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t rowCount = RowCount();
|
|
|
|
for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++)
|
2012-06-23 15:34:44 -07:00
|
|
|
if (IsRowSelected(rowIdx))
|
|
|
|
aRows->AppendElement(rowIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::CellAt(uint32_t aRowIndex, uint32_t aColumnIndex)
|
2012-05-22 09:41:01 -07:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* row = GetTreeItemAccessible(aRowIndex);
|
2012-05-22 09:41:01 -07:00
|
|
|
if (!row)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> column =
|
2012-05-22 09:41:01 -07:00
|
|
|
nsCoreUtils::GetSensibleColumnAt(mTree, aColumnIndex);
|
2009-08-19 23:45:19 -07:00
|
|
|
if (!column)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
nsRefPtr<XULTreeItemAccessibleBase> rowAcc = do_QueryObject(row);
|
2012-05-22 09:41:01 -07:00
|
|
|
if (!rowAcc)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-05-22 09:41:01 -07:00
|
|
|
return rowAcc->GetCellAccessible(column);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-15 01:04:03 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::ColDescription(uint32_t aColIdx, nsString& aDescription)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
aDescription.Truncate();
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
nsCOMPtr<nsIAccessible> treeColumns;
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible::GetFirstChild(getter_AddRefs(treeColumns));
|
2009-09-10 18:07:56 -07:00
|
|
|
if (treeColumns) {
|
|
|
|
nsCOMPtr<nsIAccessible> treeColumnItem;
|
2012-06-15 01:04:03 -07:00
|
|
|
treeColumns->GetChildAt(aColIdx, getter_AddRefs(treeColumnItem));
|
2009-09-10 18:07:56 -07:00
|
|
|
if (treeColumnItem)
|
2012-06-15 01:04:03 -07:00
|
|
|
treeColumnItem->GetName(aDescription);
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::IsColSelected(uint32_t aColIdx)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
// If all the row has been selected, then all the columns are selected.
|
|
|
|
// Because we can't select a column alone.
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t selectedrowCount = 0;
|
2012-06-15 01:03:51 -07:00
|
|
|
nsresult rv = GetSelectionCount(&selectedrowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
return selectedrowCount == RowCount();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::IsRowSelected(uint32_t aRowIdx)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
2012-06-15 01:03:51 -07:00
|
|
|
return false;
|
2012-03-28 08:59:01 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
nsresult rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
2012-06-15 01:03:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool isSelected = false;
|
|
|
|
selection->IsSelected(aRowIdx, &isSelected);
|
|
|
|
return isSelected;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-06-15 01:03:51 -07:00
|
|
|
return IsRowSelected(aRowIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 22:25:07 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::SelectRow(uint32_t aRowIdx)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
2012-06-10 22:25:07 -07:00
|
|
|
return;
|
2012-03-28 08:59:01 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
mTreeView->GetSelection(getter_AddRefs(selection));
|
2012-06-10 22:25:07 -07:00
|
|
|
NS_ASSERTION(selection, "GetSelection() Shouldn't fail!");
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-10 22:25:07 -07:00
|
|
|
selection->Select(aRowIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-04-26 04:19:59 -07:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::UnselectRow(uint32_t aRowIdx)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
2012-04-26 04:19:59 -07:00
|
|
|
return;
|
2012-03-28 08:59:01 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
mTreeView->GetSelection(getter_AddRefs(selection));
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2012-04-26 04:19:59 -07:00
|
|
|
if (selection)
|
|
|
|
selection->ClearRange(aRowIdx, aRowIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-03-27 17:53:58 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridAccessible: nsAccessNode implementation
|
2012-03-27 17:32:49 -07:00
|
|
|
|
2012-03-27 17:53:58 -07:00
|
|
|
void
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridAccessible::Shutdown()
|
2012-03-27 17:53:58 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mTable = nullptr;
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeAccessible::Shutdown();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridAccessible: Accessible implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridAccessible::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!");
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::NOTHING;
|
2010-09-04 19:14:01 -07:00
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> primaryColumn;
|
|
|
|
treeColumns->GetPrimaryColumn(getter_AddRefs(primaryColumn));
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
return primaryColumn ? roles::TREE_TABLE : roles::TABLE;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridAccessible: XULTreeAccessible implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
already_AddRefed<Accessible>
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridAccessible::CreateTreeItemAccessible(int32_t aRow)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> accessible =
|
2012-06-08 03:28:27 -07:00
|
|
|
new XULTreeGridRowAccessible(mContent, mDoc, this, mTree, mTreeView, aRow);
|
2010-03-10 02:26:11 -08:00
|
|
|
|
|
|
|
return accessible.forget();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridRowAccessible
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::
|
|
|
|
XULTreeGridRowAccessible(nsIContent* aContent, DocAccessible* aDoc,
|
|
|
|
Accessible* aTreeAcc, nsITreeBoxObject* aTree,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsITreeView* aTreeView, int32_t aRow) :
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeItemAccessibleBase(aContent, aDoc, 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
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridRowAccessible: nsISupports and cycle collection implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(XULTreeGridRowAccessible)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULTreeGridRowAccessible,
|
|
|
|
XULTreeItemAccessibleBase)
|
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
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XULTreeGridRowAccessible,
|
|
|
|
XULTreeItemAccessibleBase)
|
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
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XULTreeGridRowAccessible)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(XULTreeItemAccessibleBase)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(XULTreeGridRowAccessible,
|
|
|
|
XULTreeItemAccessibleBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(XULTreeGridRowAccessible,
|
|
|
|
XULTreeItemAccessibleBase)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridRowAccessible: nsAccessNode implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
void
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::Shutdown()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2010-03-10 02:26:11 -08:00
|
|
|
ClearCache(mAccessibleCache);
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeItemAccessibleBase::Shutdown();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridRowAccessible: Accessible implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::NativeRole()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::ROW;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
ENameValueFlag
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::Name(nsString& aName)
|
2011-06-09 02:09:05 -07:00
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
|
2011-06-30 00:35:11 -07:00
|
|
|
// XXX: the row name sholdn't be a concatenation of cell names (bug 664384).
|
|
|
|
nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
|
|
|
|
while (column) {
|
|
|
|
if (!aName.IsEmpty())
|
|
|
|
aName.AppendLiteral(" ");
|
|
|
|
|
|
|
|
nsAutoString cellName;
|
|
|
|
GetCellName(column, cellName);
|
|
|
|
aName.Append(cellName);
|
|
|
|
|
|
|
|
column = nsCoreUtils::GetNextSensibleColumn(column);
|
2011-06-09 02:09:05 -07:00
|
|
|
}
|
2011-06-30 00:35:11 -07:00
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
return eNameOK;
|
2011-06-09 02:09:05 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridRowAccessible::ChildAtPoint(int32_t aX, int32_t aY,
|
2012-06-08 03:28:27 -07:00
|
|
|
EWhichChildAtPoint aWhichChild)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
nsIFrame *frame = GetFrame();
|
|
|
|
if (!frame)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsPresContext *presContext = frame->PresContext();
|
2012-04-04 20:11:39 -07:00
|
|
|
nsIPresShell* presShell = presContext->PresShell();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsIFrame *rootFrame = presShell->GetRootFrame();
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(rootFrame, nullptr);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-03-26 05:19:07 -07:00
|
|
|
nsIntRect rootRect = rootFrame->GetScreenRect();
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t clientX = presContext->DevPixelsToIntCSSPixels(aX) - rootRect.x;
|
|
|
|
int32_t clientY = presContext->DevPixelsToIntCSSPixels(aY) - rootRect.y;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t row = -1;
|
2009-08-19 23:45:19 -07:00
|
|
|
nsCOMPtr<nsITreeColumn> column;
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString childEltUnused;
|
2009-08-19 23:45:19 -07:00
|
|
|
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)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex)
|
2009-12-10 11:12:19 -08:00
|
|
|
{
|
|
|
|
if (IsDefunct())
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeColumn> column =
|
|
|
|
nsCoreUtils::GetSensibleColumnAt(mTree, aIndex);
|
|
|
|
if (!column)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2010-03-10 02:26:11 -08:00
|
|
|
return GetCellAccessible(column);
|
2009-12-10 11:12:19 -08:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::ChildCount() const
|
2009-12-10 11:12:19 -08:00
|
|
|
{
|
|
|
|
return nsCoreUtils::GetSensibleColumnCount(mTree);
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridRowAccessible: XULTreeItemAccessibleBase implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aColumn, "No tree column!");
|
|
|
|
|
|
|
|
void* key = static_cast<void*>(aColumn);
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* cachedCell = mAccessibleCache.GetWeak(key);
|
2010-11-12 11:00:55 -08:00
|
|
|
if (cachedCell)
|
|
|
|
return cachedCell;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> cell =
|
2012-06-08 03:28:27 -07:00
|
|
|
new XULTreeGridCellAccessibleWrap(mContent, mDoc, this, mTree,
|
|
|
|
mTreeView, mRow, aColumn);
|
2010-11-12 11:00:55 -08:00
|
|
|
if (cell) {
|
2012-05-18 10:30:49 -07:00
|
|
|
mAccessibleCache.Put(key, cell);
|
2012-07-30 07:20:58 -07:00
|
|
|
if (Document()->BindToDocument(cell, nullptr))
|
2012-05-18 10:30:49 -07:00
|
|
|
return cell;
|
2010-11-12 11:00:55 -08:00
|
|
|
|
2012-05-18 10:30:49 -07:00
|
|
|
mAccessibleCache.Remove(key);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridRowAccessible::RowInvalidated(int32_t aStartColIdx,
|
|
|
|
int32_t aEndColIdx)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsITreeColumns> treeColumns;
|
|
|
|
mTree->GetColumns(getter_AddRefs(treeColumns));
|
|
|
|
if (!treeColumns)
|
|
|
|
return;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t colIdx = aStartColIdx; colIdx <= aEndColIdx; ++colIdx) {
|
2009-08-19 23:45:19 -07:00
|
|
|
nsCOMPtr<nsITreeColumn> column;
|
|
|
|
treeColumns->GetColumnAt(colIdx, getter_AddRefs(column));
|
|
|
|
if (column && !nsCoreUtils::IsColumnHidden(column)) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* cellAccessible = GetCellAccessible(column);
|
2009-08-19 23:45:19 -07:00
|
|
|
if (cellAccessible) {
|
2012-06-08 03:28:27 -07:00
|
|
|
nsRefPtr<XULTreeGridCellAccessible> cellAcc = do_QueryObject(cellAccessible);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
cellAcc->CellInvalidated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridRowAccessible: Accessible protected implementation
|
2009-12-10 11:12:19 -08:00
|
|
|
|
|
|
|
void
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridRowAccessible::CacheChildren()
|
2009-12-10 11:12:19 -08:00
|
|
|
{
|
|
|
|
}
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::
|
|
|
|
XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
|
|
|
|
XULTreeGridRowAccessible* aRowAcc,
|
|
|
|
nsITreeBoxObject* aTree, nsITreeView* aTreeView,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aRow, nsITreeColumn* aColumn) :
|
2012-07-24 08:58:25 -07:00
|
|
|
LeafAccessible(aContent, aDoc), xpcAccessibleTableCell(this), mTree(aTree),
|
2009-08-19 23:45:19 -07:00
|
|
|
mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
|
|
|
|
{
|
|
|
|
mParent = aRowAcc;
|
2012-09-03 23:06:10 -07:00
|
|
|
mFlags |= eSharedNode;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: nsISupports implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(XULTreeGridCellAccessible)
|
2011-06-09 02:44:31 -07:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULTreeGridCellAccessible,
|
2012-06-04 05:32:29 -07:00
|
|
|
LeafAccessible)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTree)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mColumn)
|
2011-06-09 02:44:31 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XULTreeGridCellAccessible,
|
2012-06-04 05:32:29 -07:00
|
|
|
LeafAccessible)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTree)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mColumn)
|
2011-06-09 02:44:31 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XULTreeGridCellAccessible)
|
|
|
|
NS_INTERFACE_TABLE_INHERITED2(XULTreeGridCellAccessible,
|
2011-06-09 02:44:31 -07:00
|
|
|
nsIAccessibleTableCell,
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible)
|
2012-06-04 05:32:29 -07:00
|
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(LeafAccessible)
|
2012-06-08 03:28:27 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(XULTreeGridCellAccessible, LeafAccessible)
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: nsIAccessible implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
void
|
|
|
|
XULTreeGridCellAccessible::Shutdown()
|
2012-07-24 08:58:25 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mTableCell = nullptr;
|
2012-07-24 08:58:25 -07:00
|
|
|
LeafAccessible::Shutdown();
|
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::FocusedChild()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
ENameValueFlag
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::Name(nsString& aName)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
if (!mTreeView)
|
|
|
|
return eNameOK;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2012-04-30 20:08:31 -07:00
|
|
|
return eNameOK;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridCellAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aWidth, int32_t* aHeight)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t x = 0, y = 0, width = 0, height = 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
nsresult rv = mTree->GetCoordsForCellItem(mRow, mColumn,
|
|
|
|
NS_LITERAL_CSTRING("cell"),
|
|
|
|
&x, &y, &width, &height);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t tcX = 0, tcY = 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
boxObj->GetScreenX(&tcX);
|
|
|
|
boxObj->GetScreenY(&tcY);
|
|
|
|
x += tcX;
|
|
|
|
y += tcY;
|
|
|
|
|
2012-04-10 20:42:42 -07:00
|
|
|
nsPresContext* presContext = mDoc->PresContext();
|
2009-08-19 23:45:19 -07:00
|
|
|
*aX = presContext->CSSPixelsToDevPixels(x);
|
|
|
|
*aY = presContext->CSSPixelsToDevPixels(y);
|
|
|
|
*aWidth = presContext->CSSPixelsToDevPixels(width);
|
|
|
|
*aHeight = presContext->CSSPixelsToDevPixels(height);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::ActionCount()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isCycler = false;
|
2009-08-19 23:45:19 -07:00
|
|
|
mColumn->GetCycler(&isCycler);
|
2011-06-05 12:35:43 -07:00
|
|
|
if (isCycler)
|
|
|
|
return 1;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t type;
|
2009-08-19 23:45:19 -07:00
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
return 0;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridCellAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
|
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-03-28 08:59:01 -07:00
|
|
|
if (IsDefunct() || !mTreeView)
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isCycler = false;
|
2009-08-19 23:45:19 -07:00
|
|
|
mColumn->GetCycler(&isCycler);
|
|
|
|
if (isCycler) {
|
|
|
|
aName.AssignLiteral("cycle");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t type;
|
2009-08-19 23:45:19 -07:00
|
|
|
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");
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridCellAccessible::DoAction(uint8_t aIndex)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isCycler = false;
|
2009-08-19 23:45:19 -07:00
|
|
|
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
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t type;
|
2009-08-19 23:45:19 -07:00
|
|
|
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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: nsIAccessibleTableCell implementation
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
TableAccessible*
|
|
|
|
XULTreeGridCellAccessible::Table() const
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* grandParent = mParent->Parent();
|
2011-07-23 01:38:33 -07:00
|
|
|
if (grandParent)
|
2012-08-08 23:24:31 -07:00
|
|
|
return grandParent->AsTable();
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
return nullptr;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
uint32_t
|
|
|
|
XULTreeGridCellAccessible::ColIdx() const
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
2012-08-08 23:24:31 -07:00
|
|
|
uint32_t colIdx = 0;
|
|
|
|
nsCOMPtr<nsITreeColumn> column = mColumn;
|
|
|
|
while ((column = nsCoreUtils::GetPreviousSensibleColumn(column)))
|
|
|
|
colIdx++;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
return colIdx;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
uint32_t
|
|
|
|
XULTreeGridCellAccessible::RowIdx() const
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
2012-08-08 23:24:31 -07:00
|
|
|
return mRow;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
void
|
|
|
|
XULTreeGridCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aHeaderCells)
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> columnElm;
|
|
|
|
mColumn->GetElement(getter_AddRefs(columnElm));
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIContent> columnContent(do_QueryInterface(columnElm));
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* headerCell = mDoc->GetAccessible(columnContent);
|
2009-09-10 18:07:56 -07:00
|
|
|
if (headerCell)
|
2012-08-08 23:24:31 -07:00
|
|
|
aHeaderCells->AppendElement(headerCell);
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
bool
|
|
|
|
XULTreeGridCellAccessible::Selected()
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
nsresult rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
2012-08-08 23:24:31 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-08-08 23:24:31 -07:00
|
|
|
bool selected = false;
|
|
|
|
selection->IsSelected(mRow, &selected);
|
|
|
|
return selected;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
|
2012-11-19 19:54:41 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// XULTreeGridCellAccessible: nsAccessNode implementation
|
|
|
|
|
|
|
|
void
|
|
|
|
XULTreeGridCellAccessible::Init()
|
|
|
|
{
|
|
|
|
LeafAccessible::Init();
|
|
|
|
|
|
|
|
NS_ASSERTION(mTreeView, "mTreeView is null");
|
|
|
|
|
|
|
|
int16_t type;
|
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX)
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, mCachedTextEquiv);
|
|
|
|
else
|
|
|
|
mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: Accessible public implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
already_AddRefed<nsIPersistentProperties>
|
|
|
|
XULTreeGridCellAccessible::NativeAttributes()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-10-19 00:15:23 -07:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
// "table-cell-index" attribute
|
2012-08-08 23:24:31 -07:00
|
|
|
TableAccessible* table = Table();
|
|
|
|
if (!table)
|
2012-10-19 00:15:23 -07:00
|
|
|
return attributes.forget();
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
nsAutoString stringIdx;
|
2012-08-08 23:24:31 -07:00
|
|
|
stringIdx.AppendInt(table->CellIndexAt(mRow, ColIdx()));
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
// "cycles" attribute
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isCycler = false;
|
2009-08-19 23:45:19 -07:00
|
|
|
nsresult rv = mColumn->GetCycler(&isCycler);
|
|
|
|
if (NS_SUCCEEDED(rv) && isCycler)
|
2012-10-19 00:15:23 -07:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles,
|
2009-08-19 23:45:19 -07:00
|
|
|
NS_LITERAL_STRING("true"));
|
|
|
|
|
2012-10-19 00:15:23 -07:00
|
|
|
return attributes.forget();
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::NativeRole()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::GRID_CELL;
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::NativeState()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
|
|
|
return states::DEFUNCT;
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
// selectable/selected state
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t states = states::SELECTABLE; // keep in sync with NativeInteractiveState
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsITreeSelection> selection;
|
|
|
|
mTreeView->GetSelection(getter_AddRefs(selection));
|
|
|
|
if (selection) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isSelected = false;
|
2009-08-19 23:45:19 -07:00
|
|
|
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
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t type;
|
2009-08-19 23:45:19 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::NativeInteractiveState() const
|
2012-06-03 22:41:06 -07:00
|
|
|
{
|
|
|
|
return states::SELECTABLE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::IndexInParent() const
|
2011-01-30 20:04:39 -08:00
|
|
|
{
|
2012-08-08 23:24:31 -07:00
|
|
|
return ColIdx();
|
2011-01-30 20:04:39 -08:00
|
|
|
}
|
|
|
|
|
2011-10-03 07:26:11 -07:00
|
|
|
Relation
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridCellAccessible::RelationByType(uint32_t aType)
|
2011-10-03 07:26:11 -07:00
|
|
|
{
|
|
|
|
return Relation();
|
|
|
|
}
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: public implementation
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
void
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::CellInvalidated()
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
|
|
|
return;
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
nsAutoString textEquiv;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t type;
|
2009-08-19 23:45:19 -07:00
|
|
|
mColumn->GetType(&type);
|
|
|
|
if (type == nsITreeColumn::TYPE_CHECKBOX) {
|
|
|
|
mTreeView->GetCellValue(mRow, mColumn, textEquiv);
|
|
|
|
if (mCachedTextEquiv != textEquiv) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: Accessible protected implementation
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTreeGridCellAccessible::GetSiblingAtOffset(int32_t aOffset,
|
2012-06-08 03:28:27 -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) {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t index = aOffset; index < 0 && columnAtOffset; index++) {
|
2009-12-10 11:12:19 -08:00
|
|
|
column = nsCoreUtils::GetPreviousSensibleColumn(columnAtOffset);
|
|
|
|
column.swap(columnAtOffset);
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t index = aOffset; index > 0 && columnAtOffset; index--) {
|
2009-12-10 11:12:19 -08:00
|
|
|
column = nsCoreUtils::GetNextSensibleColumn(columnAtOffset);
|
|
|
|
column.swap(columnAtOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!columnAtOffset)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2012-06-08 03:28:27 -07:00
|
|
|
nsRefPtr<XULTreeItemAccessibleBase> rowAcc = do_QueryObject(Parent());
|
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
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::DispatchClickEvent(nsIContent* aContent,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aActionIndex)
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
|
|
|
if (IsDefunct())
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCoreUtils::DispatchClickEvent(mTree, mRow, mColumn);
|
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-08 03:28:27 -07:00
|
|
|
// XULTreeGridCellAccessible: protected implementation
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-06-08 03:28:27 -07:00
|
|
|
XULTreeGridCellAccessible::IsEditable() const
|
2009-08-19 23:45:19 -07:00
|
|
|
{
|
2012-03-28 08:59:01 -07:00
|
|
|
if (!mTreeView)
|
|
|
|
return false;
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
// XXX: logic corresponds to tree.xml, it's preferable to have interface
|
|
|
|
// method to check it.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEditable = false;
|
2009-08-19 23:45:19 -07:00
|
|
|
nsresult rv = mTreeView->IsEditable(mRow, mColumn, &isEditable);
|
|
|
|
if (NS_FAILED(rv) || !isEditable)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> columnElm;
|
|
|
|
mColumn->GetElement(getter_AddRefs(columnElm));
|
|
|
|
if (!columnElm)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> columnContent(do_QueryInterface(columnElm));
|
|
|
|
if (!columnContent->AttrValueIs(kNameSpaceID_None,
|
2011-06-03 14:35:17 -07:00
|
|
|
nsGkAtoms::editable,
|
|
|
|
nsGkAtoms::_true,
|
2009-08-19 23:45:19 -07:00
|
|
|
eCaseMatters))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-19 23:45:19 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
return mContent->AttrValueIs(kNameSpaceID_None,
|
2011-06-03 14:35:17 -07:00
|
|
|
nsGkAtoms::editable,
|
|
|
|
nsGkAtoms::_true, eCaseMatters);
|
2009-08-19 23:45:19 -07:00
|
|
|
}
|