2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
#include "XULListboxAccessible.h"
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
#include "Accessible-inl.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsAccUtils.h"
|
2012-05-27 02:01:40 -07:00
|
|
|
#include "DocAccessible.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsIAutoCompleteInput.h"
|
|
|
|
#include "nsIAutoCompletePopup.h"
|
|
|
|
#include "nsIDOMXULMenuListElement.h"
|
2008-03-05 20:14:10 -08:00
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
2011-08-11 06:29:50 -07:00
|
|
|
#include "nsIDOMNodeList.h"
|
2011-09-27 18:46:11 -07:00
|
|
|
#include "nsIDOMXULPopupElement.h"
|
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2007-09-18 20:31:14 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULColumAccessible
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-09-18 20:31:14 -07:00
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumAccessible::
|
|
|
|
XULColumAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumAccessible::NativeRole()
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::LIST;
|
2007-09-18 20:31:14 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumAccessible::NativeState()
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
2011-04-11 23:18:42 -07:00
|
|
|
return states::READONLY;
|
2007-09-18 20:31:14 -07:00
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2007-09-18 20:31:14 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULColumnItemAccessible
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-09-18 20:31:14 -07:00
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumnItemAccessible::
|
|
|
|
XULColumnItemAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-06-04 05:32:29 -07:00
|
|
|
LeafAccessible(aContent, aDoc)
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumnItemAccessible::NativeRole()
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::COLUMNHEADER;
|
2007-09-18 20:31:14 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumnItemAccessible::NativeState()
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
2011-04-11 23:18:42 -07:00
|
|
|
return states::READONLY;
|
2007-09-18 20:31:14 -07:00
|
|
|
}
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumnItemAccessible::ActionCount()
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-09-18 20:31:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumnItemAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
aName.AssignLiteral("click");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULColumnItemAccessible::DoAction(PRUint8 aIndex)
|
2007-09-18 20:31:14 -07:00
|
|
|
{
|
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2010-01-25 07:09:25 -08:00
|
|
|
DoCommand();
|
|
|
|
return NS_OK;
|
2007-09-18 20:31:14 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-18 20:31:14 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListboxAccessible
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::
|
|
|
|
XULListboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-03-27 17:53:58 -07:00
|
|
|
XULSelectControlAccessible(aContent, aDoc), xpcAccessibleTable(this)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-27 18:46:11 -07:00
|
|
|
nsIContent* parentContent = mContent->GetParent();
|
|
|
|
if (parentContent) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
do_QueryInterface(parentContent);
|
|
|
|
if (autoCompletePopupElm)
|
|
|
|
mFlags |= eAutoCompletePopupAccessible;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(XULListboxAccessible, XULSelectControlAccessible)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(XULListboxAccessible, XULSelectControlAccessible)
|
2008-02-19 01:07:35 -08:00
|
|
|
|
|
|
|
nsresult
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2000-12-31 16:12:15 -08:00
|
|
|
nsresult rv = XULSelectControlAccessible::QueryInterface(aIID, aInstancePtr);
|
2008-02-19 01:07:35 -08:00
|
|
|
if (*aInstancePtr)
|
|
|
|
return rv;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAccessibleTable)) && IsMulticolumn()) {
|
2008-02-19 01:07:35 -08:00
|
|
|
*aInstancePtr = static_cast<nsIAccessibleTable*>(this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-03-27 17:53:58 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//nsAccessNode
|
|
|
|
|
|
|
|
void
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::Shutdown()
|
2012-03-27 17:53:58 -07:00
|
|
|
{
|
|
|
|
mTable = nsnull;
|
|
|
|
XULSelectControlAccessible::Shutdown();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::IsMulticolumn()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
PRInt32 numColumns = 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
nsresult rv = GetColumnCount(&numColumns);
|
2008-02-19 01:07:35 -08:00
|
|
|
if (NS_FAILED(rv))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2008-02-19 01:07:35 -08:00
|
|
|
return numColumns > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListboxAccessible. nsIAccessible
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-06-09 01:21:07 -07:00
|
|
|
// As a XULListboxAccessible we can have the following states:
|
2011-04-09 16:38:06 -07:00
|
|
|
// FOCUSED, READONLY, FOCUSABLE
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Get focus status from base class
|
2012-05-28 18:18:45 -07:00
|
|
|
PRUint64 states = Accessible::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
// see if we are multiple select if so set ourselves as such
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::seltype,
|
|
|
|
nsGkAtoms::multiple, eCaseMatters)) {
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::MULTISELECTABLE | states::EXTSELECTABLE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return states;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Our value is the label of our ( first ) selected child.
|
|
|
|
*/
|
2012-04-09 02:48:41 -07:00
|
|
|
void
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::Value(nsString& aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-04-09 02:48:41 -07:00
|
|
|
aValue.Truncate();
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (select) {
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
|
|
|
|
select->GetSelectedItem(getter_AddRefs(selectedItem));
|
|
|
|
if (selectedItem)
|
2012-04-09 02:48:41 -07:00
|
|
|
selectedItem->GetLabel(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
// A richlistbox is used with the new autocomplete URL bar, and has a parent
|
|
|
|
// popup <panel>.
|
|
|
|
nsCOMPtr<nsIDOMXULPopupElement> xulPopup =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
2010-09-04 19:14:01 -07:00
|
|
|
if (xulPopup)
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::COMBOBOX_LIST;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
return IsMulticolumn() ? roles::TABLE : roles::LISTBOX;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-02-19 01:07:35 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListboxAccessible. nsIAccessibleTable
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-19 14:32:11 -07:00
|
|
|
PRUint32
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::ColCount()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
nsIContent* headContent = nsnull;
|
2011-12-06 23:20:17 -08:00
|
|
|
for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
2011-06-03 14:35:17 -07:00
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcols,
|
2008-02-19 01:07:35 -08:00
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
headContent = childContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!headContent)
|
2012-04-19 14:32:11 -07:00
|
|
|
return 0;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
|
|
|
PRUint32 columnCount = 0;
|
2011-12-06 23:20:17 -08:00
|
|
|
for (nsIContent* childContent = headContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
2011-06-03 14:35:17 -07:00
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcol,
|
2008-02-19 01:07:35 -08:00
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
columnCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:32:11 -07:00
|
|
|
return columnCount;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-04-19 14:32:11 -07:00
|
|
|
PRUint32
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::RowCount()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> element(do_QueryInterface(mContent));
|
2008-02-19 01:07:35 -08:00
|
|
|
|
|
|
|
PRUint32 itemCount = 0;
|
2012-04-19 14:32:11 -07:00
|
|
|
if(element)
|
|
|
|
element->GetItemCount(&itemCount);
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2012-04-19 14:32:11 -07:00
|
|
|
return itemCount;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex)
|
2012-05-22 09:41:01 -07:00
|
|
|
{
|
2008-02-19 01:07:35 -08:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2012-05-22 09:41:01 -07:00
|
|
|
NS_ENSURE_TRUE(control, nsnull);
|
2008-02-19 01:07:35 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
2012-05-22 09:41:01 -07:00
|
|
|
control->GetItemAtIndex(aRowIndex, getter_AddRefs(item));
|
|
|
|
if (!item)
|
|
|
|
return nsnull;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(item));
|
2012-05-22 09:41:01 -07:00
|
|
|
if (!itemContent)
|
|
|
|
return nsnull;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* row = mDoc->GetAccessible(itemContent);
|
2012-05-22 09:41:01 -07:00
|
|
|
NS_ENSURE_TRUE(row, nsnull);
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2012-05-22 09:41:01 -07:00
|
|
|
return row->GetChildAt(aColumnIndex);
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetColumnIndexAt(PRInt32 aIndex, PRInt32* aColumn)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumn);
|
|
|
|
*aColumn = -1;
|
|
|
|
|
|
|
|
PRInt32 columnCount = 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
nsresult rv = GetColumnCount(&columnCount);
|
2008-02-19 01:07:35 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aColumn = aIndex % columnCount;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetRowIndexAt(PRInt32 aIndex, PRInt32* aRow)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRow);
|
|
|
|
*aRow = -1;
|
|
|
|
|
|
|
|
PRInt32 columnCount = 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
nsresult rv = GetColumnCount(&columnCount);
|
2008-02-19 01:07:35 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aRow = aIndex / columnCount;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-02 20:16:52 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
|
|
|
|
PRInt32* aRowIndex,
|
|
|
|
PRInt32* aColumnIndex)
|
2010-07-02 20:16:52 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool
|
|
|
|
XULListboxAccessible::IsColSelected(PRUint32 aColIdx)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 selectedrowCount = 0;
|
|
|
|
nsresult rv = control->GetSelectedCount(&selectedrowCount);
|
2012-06-15 01:03:51 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
return selectedrowCount == RowCount();
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool
|
|
|
|
XULListboxAccessible::IsRowSelected(PRUint32 aRowIdx)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULSelectControlElement.");
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
2012-06-15 01:03:51 -07:00
|
|
|
nsresult rv = control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool isSelected = false;
|
|
|
|
item->GetSelected(&isSelected);
|
|
|
|
return isSelected;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-06-15 01:03:51 -07:00
|
|
|
bool
|
|
|
|
XULListboxAccessible::IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2012-06-15 01:03:51 -07:00
|
|
|
return IsRowSelected(aRowIdx);
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
PRUint32
|
|
|
|
XULListboxAccessible::SelectedCellCount()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
2012-06-20 11:05:31 -07:00
|
|
|
return 0;
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
PRUint32 selectedItemsCount = 0;
|
|
|
|
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
|
2012-06-20 11:05:31 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
return selectedItemsCount * ColCount();
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
PRUint32
|
|
|
|
XULListboxAccessible::SelectedColCount()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
PRInt32 selectedRowCount = 0;
|
|
|
|
nsresult rv = control->GetSelectedCount(&selectedRowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
return selectedRowCount > 0 && selectedRowCount == RowCount() ? ColCount() : 0;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
PRUint32
|
|
|
|
XULListboxAccessible::SelectedRowCount()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
PRInt32 selectedRowCount = 0;
|
|
|
|
nsresult rv = control->GetSelectedCount(&selectedRowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2008-03-05 20:14:10 -08:00
|
|
|
|
2012-06-20 11:05:31 -07:00
|
|
|
return selectedRowCount >= 0 ? selectedRowCount : 0;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetSelectedCells(nsIArray** aCells)
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCells);
|
|
|
|
*aCells = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMutableArray> selCells =
|
|
|
|
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRUint32 selectedItemsCount = 0;
|
|
|
|
rv = selectedItems->GetLength(&selectedItemsCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
NS_ENSURE_TRUE(mDoc, NS_ERROR_FAILURE);
|
2009-09-10 18:07:56 -07:00
|
|
|
PRUint32 index = 0;
|
|
|
|
for (; index < selectedItemsCount; index++) {
|
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
|
|
|
selectedItems->Item(index, getter_AddRefs(itemNode));
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(itemNode));
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* item = mDoc->GetAccessible(itemContent);
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
if (item) {
|
2012-05-25 03:53:45 -07:00
|
|
|
PRUint32 cellCount = item->ChildCount();
|
|
|
|
for (PRUint32 cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* cell = mChildren[cellIdx];
|
2012-01-11 19:07:35 -08:00
|
|
|
if (cell->Role() == roles::CELL)
|
2011-10-17 07:59:28 -07:00
|
|
|
selCells->AppendElement(static_cast<nsIAccessible*>(cell), false);
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ADDREF(*aCells = selCells);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetSelectedCellIndices(PRUint32* aNumCells,
|
|
|
|
PRInt32** aCells)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumCells);
|
2008-03-05 20:14:10 -08:00
|
|
|
*aNumCells = 0;
|
2008-02-19 01:07:35 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aCells);
|
2008-03-05 20:14:10 -08:00
|
|
|
*aCells = nsnull;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRUint32 selectedItemsCount = 0;
|
|
|
|
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRInt32 columnCount = 0;
|
|
|
|
rv = GetColumnCount(&columnCount);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRUint32 cellsCount = selectedItemsCount * columnCount;
|
2008-03-05 20:14:10 -08:00
|
|
|
|
|
|
|
PRInt32 *cellsIdxArray =
|
|
|
|
static_cast<PRInt32*>(nsMemory::Alloc((cellsCount) * sizeof(PRInt32)));
|
|
|
|
NS_ENSURE_TRUE(cellsIdxArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
PRUint32 index = 0, cellsIdx = 0;
|
|
|
|
for (; index < selectedItemsCount; index++) {
|
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
|
|
|
selectedItems->Item(index, getter_AddRefs(itemNode));
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
|
|
|
do_QueryInterface(itemNode);
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
PRInt32 itemIdx = -1;
|
|
|
|
control->GetIndexOfItem(item, &itemIdx);
|
|
|
|
if (itemIdx != -1) {
|
|
|
|
PRInt32 colIdx = 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
for (; colIdx < columnCount; colIdx++)
|
|
|
|
cellsIdxArray[cellsIdx++] = itemIdx * columnCount + colIdx;
|
2008-03-05 20:14:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aNumCells = cellsCount;
|
|
|
|
*aCells = cellsIdxArray;
|
|
|
|
|
|
|
|
return NS_OK;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetSelectedColumnIndices(PRUint32* aNumColumns,
|
|
|
|
PRInt32** aColumns)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumColumns);
|
2008-03-05 20:14:10 -08:00
|
|
|
*aNumColumns = 0;
|
2008-02-19 01:07:35 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aColumns);
|
2008-03-05 20:14:10 -08:00
|
|
|
*aColumns = nsnull;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
PRUint32 columnCount = 0;
|
|
|
|
nsresult rv = GetSelectedColumnCount(&columnCount);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (!columnCount)
|
2008-03-05 20:14:10 -08:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRInt32 *colsIdxArray =
|
2009-09-10 18:07:56 -07:00
|
|
|
static_cast<PRInt32*>(nsMemory::Alloc((columnCount) * sizeof(PRInt32)));
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ENSURE_TRUE(colsIdxArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
PRUint32 colIdx = 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
for (; colIdx < columnCount; colIdx++)
|
2008-03-05 20:14:10 -08:00
|
|
|
colsIdxArray[colIdx] = colIdx;
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
*aNumColumns = columnCount;
|
2008-03-05 20:14:10 -08:00
|
|
|
*aColumns = colsIdxArray;
|
|
|
|
|
|
|
|
return NS_OK;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::GetSelectedRowIndices(PRUint32* aNumRows,
|
|
|
|
PRInt32** aRows)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumRows);
|
2008-03-05 20:14:10 -08:00
|
|
|
*aNumRows = 0;
|
2008-02-19 01:07:35 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aRows);
|
2008-03-05 20:14:10 -08:00
|
|
|
*aRows = nsnull;
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
|
|
|
return NS_OK;
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
PRUint32 selectedItemsCount = 0;
|
|
|
|
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!selectedItemsCount)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRInt32 *rowsIdxArray =
|
|
|
|
static_cast<PRInt32*>(nsMemory::Alloc((selectedItemsCount) * sizeof(PRInt32)));
|
|
|
|
NS_ENSURE_TRUE(rowsIdxArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
PRUint32 index = 0;
|
|
|
|
for (; index < selectedItemsCount; index++) {
|
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
|
|
|
selectedItems->Item(index, getter_AddRefs(itemNode));
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
|
|
|
do_QueryInterface(itemNode);
|
2012-05-29 17:51:08 -07:00
|
|
|
|
2008-03-05 20:14:10 -08:00
|
|
|
if (item) {
|
|
|
|
PRInt32 itemIdx = -1;
|
|
|
|
control->GetIndexOfItem(item, &itemIdx);
|
|
|
|
if (itemIdx != -1)
|
|
|
|
rowsIdxArray[index] = itemIdx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aNumRows = selectedItemsCount;
|
|
|
|
*aRows = rowsIdxArray;
|
|
|
|
|
|
|
|
return NS_OK;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-06-10 22:25:07 -07:00
|
|
|
void
|
|
|
|
XULListboxAccessible::SelectRow(PRUint32 aRowIdx)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
2012-06-10 22:25:07 -07:00
|
|
|
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
|
|
|
control->SelectItem(item);
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-04-26 04:19:59 -07:00
|
|
|
void
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::UnselectRow(PRUint32 aRowIdx)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
2008-03-05 20:14:10 -08:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-05 20:14:10 -08:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-06-10 22:25:07 -07:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
|
|
|
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
|
|
|
control->RemoveItemFromSelection(item);
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListboxAccessible: Widgets
|
2011-09-27 18:46:11 -07:00
|
|
|
|
|
|
|
bool
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::IsWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::IsActiveWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
if (IsAutoCompletePopup()) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
|
|
|
|
|
|
|
if (autoCompletePopupElm) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isOpen = false;
|
2011-09-27 18:46:11 -07:00
|
|
|
autoCompletePopupElm->GetPopupOpen(&isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::AreItemsOperable() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
if (IsAutoCompletePopup()) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
|
|
|
|
|
|
|
if (autoCompletePopupElm) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isOpen = false;
|
2011-09-27 18:46:11 -07:00
|
|
|
autoCompletePopupElm->GetPopupOpen(&isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListboxAccessible::ContainerWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
if (IsAutoCompletePopup()) {
|
|
|
|
// This works for XUL autocompletes. It doesn't work for HTML forms
|
|
|
|
// autocomplete because of potential crossprocess calls (when autocomplete
|
|
|
|
// lives in content process while popup lives in chrome process). If that's
|
|
|
|
// a problem then rethink Widgets interface.
|
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> menuListElm =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
|
|
|
if (menuListElm) {
|
|
|
|
nsCOMPtr<nsIDOMNode> inputElm;
|
|
|
|
menuListElm->GetInputField(getter_AddRefs(inputElm));
|
|
|
|
if (inputElm) {
|
|
|
|
nsCOMPtr<nsINode> inputNode = do_QueryInterface(inputElm);
|
|
|
|
if (inputNode) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* input =
|
2012-02-15 11:22:17 -08:00
|
|
|
mDoc->GetAccessible(inputNode);
|
2011-09-27 18:46:11 -07:00
|
|
|
return input ? input->ContainerWidget() : nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2008-02-19 01:07:35 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListitemAccessible
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::
|
|
|
|
XULListitemAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
|
|
|
XULMenuitemAccessible(aContent, aDoc)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
mIsCheckbox = mContent->AttrValueIs(kNameSpaceID_None,
|
2011-06-03 14:35:17 -07:00
|
|
|
nsGkAtoms::type,
|
|
|
|
nsGkAtoms::checkbox,
|
2010-06-11 01:23:18 -07:00
|
|
|
eCaseMatters);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(XULListitemAccessible, Accessible)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::GetListAccessible()
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
if (IsDefunct())
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2008-02-22 03:07:54 -08:00
|
|
|
if (!listItem)
|
|
|
|
return nsnull;
|
|
|
|
|
2008-02-19 01:07:35 -08:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> list;
|
|
|
|
listItem->GetControl(getter_AddRefs(list));
|
2008-06-11 01:36:57 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIContent> listContent(do_QueryInterface(list));
|
|
|
|
if (!listContent)
|
2008-02-19 01:07:35 -08:00
|
|
|
return nsnull;
|
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
return mDoc->GetAccessible(listContent);
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2011-04-23 06:14:05 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListitemAccessible Accessible
|
2011-04-23 06:14:05 -07:00
|
|
|
|
|
|
|
void
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::Description(nsString& aDesc)
|
2011-04-23 06:14:05 -07:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap::Description(aDesc);
|
2011-04-23 06:14:05 -07:00
|
|
|
}
|
|
|
|
|
2008-02-19 01:07:35 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListitemAccessible. nsIAccessible
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* If there is a Listcell as a child ( not anonymous ) use it, otherwise
|
|
|
|
* default to getting the name from GetXULName
|
|
|
|
*/
|
2008-10-10 05:26:55 -07:00
|
|
|
nsresult
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::GetNameInternal(nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-12-06 23:20:17 -08:00
|
|
|
nsIContent* childContent = mContent->GetFirstChild();
|
|
|
|
if (childContent) {
|
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcell,
|
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
childContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
|
2010-06-11 01:23:18 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2008-08-24 09:45:56 -07:00
|
|
|
return GetXULName(aName);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* list = GetListAccessible();
|
2010-09-04 19:14:01 -07:00
|
|
|
if (!list) {
|
|
|
|
NS_ERROR("No list accessible for listitem accessible!");
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::NOTHING;
|
2008-02-19 01:07:35 -08:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (list->Role() == roles::TABLE)
|
|
|
|
return roles::ROW;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mIsCheckbox)
|
2012-03-23 18:09:10 -07:00
|
|
|
return roles::CHECK_RICH_OPTION;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (mParent && mParent->Role() == roles::COMBOBOX_LIST)
|
|
|
|
return roles::COMBOBOX_OPTION;
|
2010-09-04 19:14:01 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::RICH_OPTION;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-11 23:18:42 -07:00
|
|
|
if (mIsCheckbox)
|
2012-06-09 01:21:07 -07:00
|
|
|
return XULMenuitemAccessible::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
PRUint64 states = NativeInteractiveState();
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (listItem) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isSelected;
|
2007-03-22 10:30:00 -07:00
|
|
|
listItem->GetSelected(&isSelected);
|
|
|
|
if (isSelected)
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::SELECTED;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
if (FocusMgr()->IsFocused(this))
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::FOCUSED;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return states;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
PRUint64
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::NativeInteractiveState() const
|
2012-06-03 22:41:06 -07:00
|
|
|
{
|
2012-06-06 07:35:41 -07:00
|
|
|
return NativelyUnavailable() || (mParent && mParent->NativelyUnavailable()) ?
|
2012-06-03 22:41:06 -07:00
|
|
|
states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
|
|
|
|
}
|
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
XULListitemAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aIndex == eAction_Click && mIsCheckbox) {
|
|
|
|
// check or uncheck
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 states = NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
if (states & states::CHECKED)
|
2007-03-22 10:30:00 -07:00
|
|
|
aName.AssignLiteral("uncheck");
|
|
|
|
else
|
|
|
|
aName.AssignLiteral("check");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::CanHaveAnonChildren()
|
2007-04-30 23:03:08 -07:00
|
|
|
{
|
|
|
|
// That indicates we should walk anonymous children for listitems
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-04-30 23:03:08 -07:00
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListitemAccessible: Widgets
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListitemAccessible::ContainerWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
return Parent();
|
|
|
|
}
|
|
|
|
|
2008-02-19 05:47:19 -08:00
|
|
|
|
2008-02-19 01:07:35 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListCellAccessible
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::
|
|
|
|
XULListCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2008-02-19 01:07:35 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
2008-02-19 01:07:35 -08:00
|
|
|
|
2012-06-09 01:21:07 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(XULListCellAccessible,
|
2012-05-31 01:04:41 -07:00
|
|
|
HyperTextAccessible,
|
2009-09-10 18:07:56 -07:00
|
|
|
nsIAccessibleTableCell)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListCellAccessible: nsIAccessibleTableCell implementation
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetTable(nsIAccessibleTable** aTable)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aTable);
|
|
|
|
*aTable = nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* thisRow = Parent();
|
2012-01-11 19:07:35 -08:00
|
|
|
if (!thisRow || thisRow->Role() != roles::ROW)
|
2009-09-10 18:07:56 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* table = thisRow->Parent();
|
2012-01-11 19:07:35 -08:00
|
|
|
if (!table || table->Role() != roles::TABLE)
|
2009-09-10 18:07:56 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
CallQueryInterface(table, aTable);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetColumnIndex(PRInt32* aColumnIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
|
|
|
*aColumnIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* row = Parent();
|
2010-09-06 19:41:53 -07:00
|
|
|
if (!row)
|
|
|
|
return NS_OK;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2010-09-06 19:41:53 -07:00
|
|
|
*aColumnIndex = 0;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2011-06-13 02:08:40 -07:00
|
|
|
PRInt32 indexInRow = IndexInParent();
|
2010-09-06 19:41:53 -07:00
|
|
|
for (PRInt32 idx = 0; idx < indexInRow; idx++) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* cell = row->GetChildAt(idx);
|
2012-01-11 19:07:35 -08:00
|
|
|
roles::Role role = cell->Role();
|
|
|
|
if (role == roles::CELL || role == roles::GRID_CELL ||
|
|
|
|
role == roles::ROWHEADER || role == roles::COLUMNHEADER)
|
2009-09-10 18:07:56 -07:00
|
|
|
(*aColumnIndex)++;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetRowIndex(PRInt32* aRowIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aRowIndex);
|
|
|
|
*aRowIndex = -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* row = Parent();
|
2010-09-06 19:41:53 -07:00
|
|
|
if (!row)
|
|
|
|
return NS_OK;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* table = row->Parent();
|
2010-09-06 19:41:53 -07:00
|
|
|
if (!table)
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-06 19:41:53 -07:00
|
|
|
*aRowIndex = 0;
|
|
|
|
|
2011-06-13 02:08:40 -07:00
|
|
|
PRInt32 indexInTable = row->IndexInParent();
|
2010-09-06 19:41:53 -07:00
|
|
|
for (PRInt32 idx = 0; idx < indexInTable; idx++) {
|
|
|
|
row = table->GetChildAt(idx);
|
2012-01-11 19:07:35 -08:00
|
|
|
if (row->Role() == roles::ROW)
|
2010-09-06 19:41:53 -07:00
|
|
|
(*aRowIndex)++;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetColumnExtent(PRInt32* aExtentCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aExtentCount = 1;
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetRowExtent(PRInt32* aExtentCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aExtentCount = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetColumnHeaderCells(nsIArray** aHeaderCells)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> table;
|
|
|
|
GetTable(getter_AddRefs(table));
|
2009-11-17 13:14:45 -08:00
|
|
|
NS_ENSURE_STATE(table); // we expect to be in a listbox (table)
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
// Get column header cell from XUL listhead.
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* list = nsnull;
|
2010-05-18 07:03:56 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
nsRefPtr<Accessible> tableAcc(do_QueryObject(table));
|
2012-05-25 03:53:45 -07:00
|
|
|
PRUint32 tableChildCount = tableAcc->ChildCount();
|
|
|
|
for (PRUint32 childIdx = 0; childIdx < tableChildCount; childIdx++) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* child = tableAcc->GetChildAt(childIdx);
|
2012-01-11 19:07:35 -08:00
|
|
|
if (child->Role() == roles::LIST) {
|
2010-05-18 07:03:56 -07:00
|
|
|
list = child;
|
2009-09-10 18:07:56 -07:00
|
|
|
break;
|
2010-05-18 07:03:56 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-06-18 00:37:38 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (list) {
|
|
|
|
PRInt32 colIdx = -1;
|
|
|
|
GetColumnIndex(&colIdx);
|
|
|
|
|
2010-05-18 07:03:56 -07:00
|
|
|
nsIAccessible *headerCell = list->GetChildAt(colIdx);
|
2009-09-10 18:07:56 -07:00
|
|
|
if (headerCell) {
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMutableArray> headerCells =
|
|
|
|
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
headerCells->AppendElement(headerCell, false);
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ADDREF(*aHeaderCells = headerCells);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No column header cell from XUL markup, try to get it from ARIA markup.
|
|
|
|
return nsAccUtils::GetHeaderCellsFor(table, this,
|
|
|
|
nsAccUtils::eColumnHeaderCells,
|
|
|
|
aHeaderCells);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetRowHeaderCells(nsIArray** aHeaderCells)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> table;
|
|
|
|
GetTable(getter_AddRefs(table));
|
2009-11-17 13:14:45 -08:00
|
|
|
NS_ENSURE_STATE(table); // we expect to be in a listbox (table)
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
// Calculate row header cells from ARIA markup.
|
|
|
|
return nsAccUtils::GetHeaderCellsFor(table, this,
|
|
|
|
nsAccUtils::eRowHeaderCells,
|
|
|
|
aHeaderCells);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_IMETHODIMP
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::IsSelected(bool* aIsSelected)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-10 18:07:56 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aIsSelected);
|
2011-10-17 07:59:28 -07:00
|
|
|
*aIsSelected = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> table;
|
|
|
|
GetTable(getter_AddRefs(table));
|
2009-11-17 13:14:45 -08:00
|
|
|
NS_ENSURE_STATE(table); // we expect to be in a listbox (table)
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
PRInt32 rowIdx = -1;
|
|
|
|
GetRowIndex(&rowIdx);
|
|
|
|
|
|
|
|
return table->IsRowSelected(rowIdx, aIsSelected);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 01:21:07 -07:00
|
|
|
// XULListCellAccessible. Accessible implementation
|
2009-09-10 18:07:56 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::CELL;
|
2009-09-10 18:07:56 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 18:07:56 -07:00
|
|
|
nsresult
|
2012-06-09 01:21:07 -07:00
|
|
|
XULListCellAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
|
2009-09-10 18:07:56 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
|
|
|
|
|
|
|
if (IsDefunct())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
// "table-cell-index" attribute
|
|
|
|
nsCOMPtr<nsIAccessibleTable> table;
|
|
|
|
GetTable(getter_AddRefs(table));
|
2009-11-17 13:14:45 -08:00
|
|
|
NS_ENSURE_STATE(table); // we expect to be in a listbox (table)
|
2009-09-10 18:07:56 -07:00
|
|
|
|
|
|
|
PRInt32 rowIdx = -1;
|
|
|
|
GetRowIndex(&rowIdx);
|
|
|
|
PRInt32 colIdx = -1;
|
|
|
|
GetColumnIndex(&colIdx);
|
|
|
|
|
|
|
|
PRInt32 cellIdx = -1;
|
|
|
|
table->GetCellIndexAt(rowIdx, colIdx, &cellIdx);
|
|
|
|
|
|
|
|
nsAutoString stringIdx;
|
|
|
|
stringIdx.AppendInt(cellIdx);
|
2011-06-03 14:35:17 -07:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::tableCellIndex,
|
2009-09-10 18:07:56 -07:00
|
|
|
stringIdx);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|