2001-12-17 04:21:29 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
#include "XULListboxAccessible.h"
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "Accessible-inl.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsAccUtils.h"
|
2012-05-27 13:01:40 +04:00
|
|
|
#include "DocAccessible.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsIAutoCompleteInput.h"
|
|
|
|
#include "nsIAutoCompletePopup.h"
|
|
|
|
#include "nsIDOMXULMenuListElement.h"
|
2008-03-06 07:14:10 +03:00
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
2011-08-11 17:29:50 +04:00
|
|
|
#include "nsIDOMNodeList.h"
|
2011-09-28 05:46:11 +04:00
|
|
|
#include "nsIDOMXULPopupElement.h"
|
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2012-08-01 22:31:10 +04:00
|
|
|
#include "nsIMutableArray.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "nsIPersistentProperties2.h"
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2007-09-19 07:31:14 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULColumAccessible
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-09-19 07:31:14 +04:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumAccessible::
|
|
|
|
XULColumAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumAccessible::NativeRole()
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::LIST;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumAccessible::NativeState()
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
return states::READONLY;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2007-09-19 07:31:14 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULColumnItemAccessible
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-09-19 07:31:14 +04:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumnItemAccessible::
|
|
|
|
XULColumnItemAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-06-04 16:32:29 +04:00
|
|
|
LeafAccessible(aContent, aDoc)
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumnItemAccessible::NativeRole()
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::COLUMNHEADER;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumnItemAccessible::NativeState()
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
return states::READONLY;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULColumnItemAccessible::ActionCount()
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
2011-06-05 23:35:43 +04:00
|
|
|
return 1;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
|
|
|
XULColumnItemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
2014-09-16 21:30:23 +04:00
|
|
|
if (aIndex == eAction_Click)
|
|
|
|
aName.AssignLiteral("click");
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
XULColumnItemAccessible::DoAction(uint8_t aIndex)
|
2007-09-19 07:31:14 +04:00
|
|
|
{
|
|
|
|
if (aIndex != eAction_Click)
|
2014-09-16 21:30:23 +04:00
|
|
|
return false;
|
2007-09-19 07:31:14 +04:00
|
|
|
|
2010-01-25 18:09:25 +03:00
|
|
|
DoCommand();
|
2014-09-16 21:30:23 +04:00
|
|
|
return true;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2007-09-19 07:31:14 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListboxAccessible
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::
|
|
|
|
XULListboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2014-10-22 04:49:28 +04:00
|
|
|
XULSelectControlAccessible(aContent, aDoc)
|
2001-12-17 04:21:29 +03:00
|
|
|
{
|
2013-05-02 02:50:08 +04:00
|
|
|
nsIContent* parentContent = mContent->GetFlattenedTreeParent();
|
2011-09-28 05:46:11 +04:00
|
|
|
if (parentContent) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
do_QueryInterface(parentContent);
|
|
|
|
if (autoCompletePopupElm)
|
2012-12-18 09:22:26 +04:00
|
|
|
mGenericTypes |= eAutoCompletePopup;
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
2012-03-28 04:53:58 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (IsMulticolumn())
|
|
|
|
mGenericTypes |= eTable;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-10-22 04:49:28 +04:00
|
|
|
// XULListboxAccessible: Accessible
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::NativeState()
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2012-06-09 12:21:07 +04:00
|
|
|
// As a XULListboxAccessible we can have the following states:
|
2011-04-10 03:38:06 +04:00
|
|
|
// FOCUSED, READONLY, FOCUSABLE
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2002-02-18 10:35:10 +03:00
|
|
|
// Get focus status from base class
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t states = Accessible::NativeState();
|
2002-02-18 10:35:10 +03:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
// see if we are multiple select if so set ourselves as such
|
|
|
|
|
2011-06-04 01:35:17 +04:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::seltype,
|
|
|
|
nsGkAtoms::multiple, eCaseMatters)) {
|
2011-04-10 03:38:06 +04:00
|
|
|
states |= states::MULTISELECTABLE | states::EXTSELECTABLE;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return states;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2001-12-17 04:21:29 +03:00
|
|
|
/**
|
2004-06-02 08:06:28 +04:00
|
|
|
* Our value is the label of our ( first ) selected child.
|
2001-12-17 04:21:29 +03:00
|
|
|
*/
|
2012-04-09 13:48:41 +04:00
|
|
|
void
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::Value(nsString& aValue)
|
2001-12-17 04:21:29 +03:00
|
|
|
{
|
2012-04-09 13:48:41 +04:00
|
|
|
aValue.Truncate();
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent));
|
2001-12-17 04:21:29 +03:00
|
|
|
if (select) {
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
|
|
|
|
select->GetSelectedItem(getter_AddRefs(selectedItem));
|
2002-06-14 05:47:26 +04:00
|
|
|
if (selectedItem)
|
2012-04-09 13:48:41 +04:00
|
|
|
selectedItem->GetLabel(aValue);
|
2001-12-17 04:21:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::NativeRole()
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2010-06-11 12:23:18 +04: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-05 06:14:01 +04:00
|
|
|
if (xulPopup)
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::COMBOBOX_LIST;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
return IsMulticolumn() ? roles::TABLE : roles::LISTBOX;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-10-22 04:49:28 +04:00
|
|
|
// XULListboxAccessible: Table
|
2002-02-18 10:35:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::ColCount()
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIContent* headContent = nullptr;
|
2011-12-07 11:20:17 +04:00
|
|
|
for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
2011-06-04 01:35:17 +04:00
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcols,
|
2008-02-19 12:07:35 +03:00
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
headContent = childContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!headContent)
|
2012-04-20 01:32:11 +04:00
|
|
|
return 0;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t columnCount = 0;
|
2011-12-07 11:20:17 +04:00
|
|
|
for (nsIContent* childContent = headContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
2011-06-04 01:35:17 +04:00
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcol,
|
2008-02-19 12:07:35 +03:00
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
columnCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:32:11 +04:00
|
|
|
return columnCount;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::RowCount()
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> element(do_QueryInterface(mContent));
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t itemCount = 0;
|
2012-04-20 01:32:11 +04:00
|
|
|
if(element)
|
|
|
|
element->GetItemCount(&itemCount);
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-04-20 01:32:11 +04:00
|
|
|
return itemCount;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::CellAt(uint32_t aRowIndex, uint32_t aColumnIndex)
|
2014-04-26 06:42:19 +04:00
|
|
|
{
|
2008-02-19 12:07:35 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(control, nullptr);
|
2008-02-19 12:07:35 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
2012-05-22 20:41:01 +04:00
|
|
|
control->GetItemAtIndex(aRowIndex, getter_AddRefs(item));
|
|
|
|
if (!item)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(item));
|
2012-05-22 20:41:01 +04:00
|
|
|
if (!itemContent)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* row = mDoc->GetAccessible(itemContent);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(row, nullptr);
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-05-22 20:41:01 +04:00
|
|
|
return row->GetChildAt(aColumnIndex);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-15 12:03:51 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::IsColSelected(uint32_t aColIdx)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t selectedrowCount = 0;
|
2009-09-11 05:07:56 +04:00
|
|
|
nsresult rv = control->GetSelectedCount(&selectedrowCount);
|
2012-06-15 12:03:51 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2014-04-26 06:42:19 +04:00
|
|
|
return selectedrowCount == static_cast<int32_t>(RowCount());
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-15 12:03:51 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::IsRowSelected(uint32_t aRowIdx)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULSelectControlElement.");
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
2012-06-15 12:03:51 +04:00
|
|
|
nsresult rv = control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-06-15 12:03:51 +04:00
|
|
|
bool isSelected = false;
|
|
|
|
item->GetSelected(&isSelected);
|
|
|
|
return isSelected;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-15 12:03:51 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2012-06-15 12:03:51 +04:00
|
|
|
return IsRowSelected(aRowIdx);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-06-20 22:05:31 +04:00
|
|
|
XULListboxAccessible::SelectedCellCount()
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
2012-06-20 22:05:31 +04:00
|
|
|
return 0;
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t selectedItemsCount = 0;
|
2008-03-06 07:14:10 +03:00
|
|
|
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
|
2012-06-20 22:05:31 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-06-20 22:05:31 +04:00
|
|
|
return selectedItemsCount * ColCount();
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-06-20 22:05:31 +04:00
|
|
|
XULListboxAccessible::SelectedColCount()
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t selectedRowCount = 0;
|
2012-06-20 22:05:31 +04:00
|
|
|
nsresult rv = control->GetSelectedCount(&selectedRowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2014-04-26 06:42:19 +04:00
|
|
|
return selectedRowCount > 0 &&
|
|
|
|
selectedRowCount == static_cast<int32_t>(RowCount()) ? ColCount() : 0;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-06-20 22:05:31 +04:00
|
|
|
XULListboxAccessible::SelectedRowCount()
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t selectedRowCount = 0;
|
2012-06-20 22:05:31 +04:00
|
|
|
nsresult rv = control->GetSelectedCount(&selectedRowCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, 0);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-06-20 22:05:31 +04:00
|
|
|
return selectedRowCount >= 0 ? selectedRowCount : 0;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-29 12:14:22 +04:00
|
|
|
void
|
|
|
|
XULListboxAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
2009-09-11 05:07:56 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2009-09-11 05:07:56 +04:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
2012-06-29 12:14:22 +04:00
|
|
|
return;
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t selectedItemsCount = 0;
|
2013-03-13 00:08:29 +04:00
|
|
|
DebugOnly<nsresult> rv = selectedItems->GetLength(&selectedItemsCount);
|
2012-06-29 12:14:22 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t index = 0; index < selectedItemsCount; index++) {
|
2009-09-11 05:07:56 +04:00
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
|
|
|
selectedItems->Item(index, getter_AddRefs(itemNode));
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(itemNode));
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* item = mDoc->GetAccessible(itemContent);
|
2009-09-11 05:07:56 +04:00
|
|
|
|
|
|
|
if (item) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t cellCount = item->ChildCount();
|
|
|
|
for (uint32_t cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* cell = mChildren[cellIdx];
|
2012-01-12 07:07:35 +04:00
|
|
|
if (cell->Role() == roles::CELL)
|
2012-06-29 12:14:22 +04:00
|
|
|
aCells->AppendElement(cell);
|
2009-09-11 05:07:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-24 02:34:44 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::SelectedCellIndices(nsTArray<uint32_t>* aCells)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
2012-06-24 02:34:44 +04:00
|
|
|
return;
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t selectedItemsCount = 0;
|
2013-03-13 00:08:29 +04:00
|
|
|
DebugOnly<nsresult> rv = selectedItems->GetLength(&selectedItemsCount);
|
2012-06-24 02:34:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t colCount = ColCount();
|
2012-06-24 02:34:44 +04:00
|
|
|
aCells->SetCapacity(selectedItemsCount * colCount);
|
|
|
|
aCells->AppendElements(selectedItemsCount * colCount);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t selItemsIdx = 0, cellsIdx = 0;
|
2012-06-24 02:34:44 +04:00
|
|
|
selItemsIdx < selectedItemsCount; selItemsIdx++) {
|
2008-03-06 07:14:10 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
2012-06-24 02:34:44 +04:00
|
|
|
selectedItems->Item(selItemsIdx, getter_AddRefs(itemNode));
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
|
|
|
do_QueryInterface(itemNode);
|
|
|
|
|
|
|
|
if (item) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t itemIdx = -1;
|
2008-03-06 07:14:10 +03:00
|
|
|
control->GetIndexOfItem(item, &itemIdx);
|
2012-06-24 02:34:44 +04:00
|
|
|
if (itemIdx >= 0)
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t colIdx = 0; colIdx < colCount; colIdx++, cellsIdx++)
|
2012-06-24 02:34:44 +04:00
|
|
|
aCells->ElementAt(cellsIdx) = itemIdx * colCount + colIdx;
|
2008-03-06 07:14:10 +03:00
|
|
|
}
|
|
|
|
}
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-24 02:34:44 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::SelectedColIndices(nsTArray<uint32_t>* aCols)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t selColCount = SelectedColCount();
|
2012-06-24 02:34:44 +04:00
|
|
|
aCols->SetCapacity(selColCount);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t colIdx = 0; colIdx < selColCount; colIdx++)
|
2012-06-24 02:34:44 +04:00
|
|
|
aCols->AppendElement(colIdx);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-24 02:34:44 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::SelectedRowIndices(nsTArray<uint32_t>* aRows)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems)
|
2012-06-24 02:34:44 +04:00
|
|
|
return;
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t rowCount = 0;
|
2013-03-13 00:08:29 +04:00
|
|
|
DebugOnly<nsresult> rv = selectedItems->GetLength(&rowCount);
|
2012-06-24 02:34:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-06-24 02:34:44 +04:00
|
|
|
if (!rowCount)
|
|
|
|
return;
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-06-24 02:34:44 +04:00
|
|
|
aRows->SetCapacity(rowCount);
|
|
|
|
aRows->AppendElements(rowCount);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
2012-06-24 02:34:44 +04:00
|
|
|
selectedItems->Item(rowIdx, getter_AddRefs(itemNode));
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
|
|
|
do_QueryInterface(itemNode);
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2008-03-06 07:14:10 +03:00
|
|
|
if (item) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t itemIdx = -1;
|
2008-03-06 07:14:10 +03:00
|
|
|
control->GetIndexOfItem(item, &itemIdx);
|
2012-06-24 02:34:44 +04:00
|
|
|
if (itemIdx >= 0)
|
|
|
|
aRows->ElementAt(rowIdx) = itemIdx;
|
2008-03-06 07:14:10 +03:00
|
|
|
}
|
|
|
|
}
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-11 09:25:07 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::SelectRow(uint32_t aRowIdx)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
2012-06-11 09:25:07 +04:00
|
|
|
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
|
|
|
control->SelectItem(item);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-04-26 15:19:59 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
XULListboxAccessible::UnselectRow(uint32_t aRowIdx)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2012-06-11 09:25:07 +04:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
|
|
|
|
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
|
|
|
control->RemoveItemFromSelection(item);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListboxAccessible: Widgets
|
2011-09-28 05:46:11 +04:00
|
|
|
|
|
|
|
bool
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::IsWidget() const
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::IsActiveWidget() const
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
|
|
|
if (IsAutoCompletePopup()) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
|
|
|
|
|
|
|
if (autoCompletePopupElm) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOpen = false;
|
2011-09-28 05:46:11 +04:00
|
|
|
autoCompletePopupElm->GetPopupOpen(&isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::AreItemsOperable() const
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
|
|
|
if (IsAutoCompletePopup()) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
|
|
|
|
|
|
|
if (autoCompletePopupElm) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOpen = false;
|
2011-09-28 05:46:11 +04:00
|
|
|
autoCompletePopupElm->GetPopupOpen(&isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListboxAccessible::ContainerWidget() const
|
2011-09-28 05:46:11 +04: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) {
|
2014-04-26 06:42:19 +04:00
|
|
|
Accessible* input =
|
2012-02-15 23:22:17 +04:00
|
|
|
mDoc->GetAccessible(inputNode);
|
2012-07-30 18:20:58 +04:00
|
|
|
return input ? input->ContainerWidget() : nullptr;
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListitemAccessible
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListitemAccessible::
|
|
|
|
XULListitemAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
|
|
|
XULMenuitemAccessible(aContent, aDoc)
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2010-06-11 12:23:18 +04:00
|
|
|
mIsCheckbox = mContent->AttrValueIs(kNameSpaceID_None,
|
2011-06-04 01:35:17 +04:00
|
|
|
nsGkAtoms::type,
|
|
|
|
nsGkAtoms::checkbox,
|
2010-06-11 12:23:18 +04:00
|
|
|
eCaseMatters);
|
2014-03-31 18:30:46 +04:00
|
|
|
mType = eXULListItemType;
|
2016-02-22 20:32:03 +03:00
|
|
|
|
|
|
|
// Walk XBL anonymous children for list items. Overrides the flag value from
|
|
|
|
// base XULMenuitemAccessible class.
|
|
|
|
mStateFlags &= ~eNoXBLKids;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:18 +04:00
|
|
|
XULListitemAccessible::~XULListitemAccessible()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(XULListitemAccessible, Accessible)
|
2002-02-18 10:35:10 +03:00
|
|
|
|
2014-04-26 06:42:19 +04:00
|
|
|
Accessible*
|
2014-09-16 21:30:23 +04:00
|
|
|
XULListitemAccessible::GetListAccessible() const
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
|
|
|
if (IsDefunct())
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2014-04-26 06:42:19 +04:00
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2008-02-22 14:07:54 +03:00
|
|
|
if (!listItem)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-02-22 14:07:54 +03:00
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> list;
|
|
|
|
listItem->GetControl(getter_AddRefs(list));
|
2008-06-11 12:36:57 +04:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIContent> listContent(do_QueryInterface(list));
|
|
|
|
if (!listContent)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-02-08 02:38:54 +04:00
|
|
|
return mDoc->GetAccessible(listContent);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2011-04-23 17:14:05 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListitemAccessible Accessible
|
2011-04-23 17:14:05 +04:00
|
|
|
|
|
|
|
void
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListitemAccessible::Description(nsString& aDesc)
|
2011-04-23 17:14:05 +04:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::Description(aDesc);
|
2011-04-23 17:14:05 +04:00
|
|
|
}
|
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-10-22 04:49:28 +04:00
|
|
|
// XULListitemAccessible: Accessible
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2002-02-18 10:35:10 +03:00
|
|
|
/**
|
|
|
|
* If there is a Listcell as a child ( not anonymous ) use it, otherwise
|
2003-07-31 12:09:39 +04:00
|
|
|
* default to getting the name from GetXULName
|
2002-02-18 10:35:10 +03:00
|
|
|
*/
|
2012-10-14 08:18:39 +04:00
|
|
|
ENameValueFlag
|
|
|
|
XULListitemAccessible::NativeName(nsString& aName)
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2011-12-07 11:20:17 +04:00
|
|
|
nsIContent* childContent = mContent->GetFirstChild();
|
|
|
|
if (childContent) {
|
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcell,
|
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
childContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-10-14 08:18:39 +04:00
|
|
|
|
2013-12-08 01:37:04 +04:00
|
|
|
return Accessible::NativeName(aName);
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListitemAccessible::NativeRole()
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* list = GetListAccessible();
|
2010-09-05 06:14:01 +04:00
|
|
|
if (!list) {
|
|
|
|
NS_ERROR("No list accessible for listitem accessible!");
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::NOTHING;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
if (list->Role() == roles::TABLE)
|
|
|
|
return roles::ROW;
|
2010-09-05 06:14:01 +04:00
|
|
|
|
2004-06-09 08:11:01 +04:00
|
|
|
if (mIsCheckbox)
|
2012-03-24 05:09:10 +04:00
|
|
|
return roles::CHECK_RICH_OPTION;
|
2010-09-05 06:14:01 +04:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
if (mParent && mParent->Role() == roles::COMBOBOX_LIST)
|
|
|
|
return roles::COMBOBOX_OPTION;
|
2010-09-05 06:14:01 +04:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::RICH_OPTION;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListitemAccessible::NativeState()
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
if (mIsCheckbox)
|
2012-06-09 12:21:07 +04:00
|
|
|
return XULMenuitemAccessible::NativeState();
|
2004-07-27 23:53:07 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t states = NativeInteractiveState();
|
2009-09-11 05:07:56 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
|
2010-06-11 12:23:18 +04:00
|
|
|
do_QueryInterface(mContent);
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2002-02-18 10:35:10 +03:00
|
|
|
if (listItem) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isSelected;
|
2002-02-18 10:35:10 +03:00
|
|
|
listItem->GetSelected(&isSelected);
|
|
|
|
if (isSelected)
|
2011-04-10 03:38:06 +04:00
|
|
|
states |= states::SELECTED;
|
2002-02-18 10:35:10 +03:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
if (FocusMgr()->IsFocused(this))
|
2011-04-10 03:38:06 +04:00
|
|
|
states |= states::FOCUSED;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return states;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListitemAccessible::NativeInteractiveState() const
|
2012-06-04 09:41:06 +04:00
|
|
|
{
|
2012-06-06 18:35:41 +04:00
|
|
|
return NativelyUnavailable() || (mParent && mParent->NativelyUnavailable()) ?
|
2012-06-04 09:41:06 +04:00
|
|
|
states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
|
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
|
|
|
XULListitemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2004-06-09 08:11:01 +04:00
|
|
|
{
|
2007-02-25 06:43:20 +03:00
|
|
|
if (aIndex == eAction_Click && mIsCheckbox) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t states = NativeState();
|
2011-04-10 03:38:06 +04:00
|
|
|
if (states & states::CHECKED)
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("uncheck");
|
2004-06-09 08:11:01 +04:00
|
|
|
else
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("check");
|
2004-06-09 08:11:01 +04:00
|
|
|
}
|
|
|
|
}
|
2007-02-09 05:03:08 +03:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListitemAccessible: Widgets
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListitemAccessible::ContainerWidget() const
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
|
|
|
return Parent();
|
|
|
|
}
|
|
|
|
|
2008-02-19 16:47:19 +03:00
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListCellAccessible
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListCellAccessible::
|
|
|
|
XULListCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2014-10-22 04:49:28 +04:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2008-02-19 12:07:35 +03:00
|
|
|
{
|
2013-07-18 19:09:45 +04:00
|
|
|
mGenericTypes |= eTableCell;
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(XULListCellAccessible,
|
|
|
|
HyperTextAccessible)
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-10-22 04:49:28 +04:00
|
|
|
// XULListCellAccessible: TableCell
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
TableAccessible*
|
|
|
|
XULListCellAccessible::Table() const
|
2001-12-17 04:21:29 +03:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* thisRow = Parent();
|
2012-01-12 07:07:35 +04:00
|
|
|
if (!thisRow || thisRow->Role() != roles::ROW)
|
2012-08-09 10:24:31 +04:00
|
|
|
return nullptr;
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* table = thisRow->Parent();
|
2012-01-12 07:07:35 +04:00
|
|
|
if (!table || table->Role() != roles::TABLE)
|
2012-08-09 10:24:31 +04:00
|
|
|
return nullptr;
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
return table->AsTable();
|
2007-02-09 05:03:08 +03:00
|
|
|
}
|
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
uint32_t
|
|
|
|
XULListCellAccessible::ColIdx() const
|
2002-06-12 09:16:30 +04:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* row = Parent();
|
2010-09-07 06:41:53 +04:00
|
|
|
if (!row)
|
2012-08-09 10:24:31 +04:00
|
|
|
return 0;
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indexInRow = IndexInParent();
|
2012-08-09 10:24:31 +04:00
|
|
|
uint32_t colIdx = 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t idx = 0; idx < indexInRow; idx++) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* cell = row->GetChildAt(idx);
|
2012-01-12 07:07:35 +04:00
|
|
|
roles::Role role = cell->Role();
|
|
|
|
if (role == roles::CELL || role == roles::GRID_CELL ||
|
|
|
|
role == roles::ROWHEADER || role == roles::COLUMNHEADER)
|
2012-08-09 10:24:31 +04:00
|
|
|
colIdx++;
|
2006-05-03 17:36:46 +04:00
|
|
|
}
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
return colIdx;
|
2002-06-12 09:16:30 +04:00
|
|
|
}
|
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
uint32_t
|
|
|
|
XULListCellAccessible::RowIdx() const
|
2002-06-12 09:16:30 +04:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* row = Parent();
|
2010-09-07 06:41:53 +04:00
|
|
|
if (!row)
|
2012-08-09 10:24:31 +04:00
|
|
|
return 0;
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* table = row->Parent();
|
2010-09-07 06:41:53 +04:00
|
|
|
if (!table)
|
2012-08-09 10:24:31 +04:00
|
|
|
return 0;
|
2010-09-07 06:41:53 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indexInTable = row->IndexInParent();
|
2012-08-09 10:24:31 +04:00
|
|
|
uint32_t rowIdx = 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t idx = 0; idx < indexInTable; idx++) {
|
2010-09-07 06:41:53 +04:00
|
|
|
row = table->GetChildAt(idx);
|
2012-01-12 07:07:35 +04:00
|
|
|
if (row->Role() == roles::ROW)
|
2012-08-09 10:24:31 +04:00
|
|
|
rowIdx++;
|
2009-09-11 05:07:56 +04:00
|
|
|
}
|
2002-06-12 09:16:30 +04:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
return rowIdx;
|
2005-05-05 19:05:34 +04:00
|
|
|
}
|
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
void
|
|
|
|
XULListCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells)
|
2006-07-26 23:38:25 +04:00
|
|
|
{
|
2012-08-09 10:24:31 +04:00
|
|
|
TableAccessible* table = Table();
|
|
|
|
NS_ASSERTION(table, "cell not in a table!");
|
|
|
|
if (!table)
|
|
|
|
return;
|
2009-09-11 05:07:56 +04:00
|
|
|
|
|
|
|
// Get column header cell from XUL listhead.
|
2012-07-30 18:20:58 +04:00
|
|
|
Accessible* list = nullptr;
|
2010-05-18 18:03:56 +04:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
Accessible* tableAcc = table->AsAccessible();
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t tableChildCount = tableAcc->ChildCount();
|
|
|
|
for (uint32_t childIdx = 0; childIdx < tableChildCount; childIdx++) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* child = tableAcc->GetChildAt(childIdx);
|
2012-01-12 07:07:35 +04:00
|
|
|
if (child->Role() == roles::LIST) {
|
2010-05-18 18:03:56 +04:00
|
|
|
list = child;
|
2009-09-11 05:07:56 +04:00
|
|
|
break;
|
2010-05-18 18:03:56 +04:00
|
|
|
}
|
2005-04-05 15:11:57 +04:00
|
|
|
}
|
2009-06-18 11:37:38 +04:00
|
|
|
|
2009-09-11 05:07:56 +04:00
|
|
|
if (list) {
|
2012-08-09 10:24:31 +04:00
|
|
|
Accessible* headerCell = list->GetChildAt(ColIdx());
|
2009-09-11 05:07:56 +04:00
|
|
|
if (headerCell) {
|
2012-08-09 10:24:31 +04:00
|
|
|
aCells->AppendElement(headerCell);
|
|
|
|
return;
|
2009-09-11 05:07:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No column header cell from XUL markup, try to get it from ARIA markup.
|
2012-08-09 10:24:31 +04:00
|
|
|
TableCellAccessible::ColHeaderCells(aCells);
|
2005-04-05 15:11:57 +04:00
|
|
|
}
|
2006-07-26 23:38:25 +04:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
bool
|
|
|
|
XULListCellAccessible::Selected()
|
2007-01-11 23:07:36 +03:00
|
|
|
{
|
2012-08-09 10:24:31 +04:00
|
|
|
TableAccessible* table = Table();
|
|
|
|
NS_ENSURE_TRUE(table, false); // we expect to be in a listbox (table)
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-09 10:24:31 +04:00
|
|
|
return table->IsRowSelected(RowIdx());
|
2007-01-11 23:07:36 +03:00
|
|
|
}
|
|
|
|
|
2009-09-11 05:07:56 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-09 12:21:07 +04:00
|
|
|
// XULListCellAccessible. Accessible implementation
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-06-09 12:21:07 +04:00
|
|
|
XULListCellAccessible::NativeRole()
|
2007-01-11 23:07:36 +03:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::CELL;
|
2009-09-11 05:07:56 +04:00
|
|
|
}
|
2007-01-11 23:07:36 +03:00
|
|
|
|
2012-10-19 11:15:23 +04:00
|
|
|
already_AddRefed<nsIPersistentProperties>
|
|
|
|
XULListCellAccessible::NativeAttributes()
|
2009-09-11 05:07:56 +04:00
|
|
|
{
|
2012-10-19 11:15:23 +04:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes =
|
|
|
|
HyperTextAccessibleWrap::NativeAttributes();
|
2009-09-11 05:07:56 +04:00
|
|
|
|
|
|
|
// "table-cell-index" attribute
|
2012-08-09 10:24:31 +04:00
|
|
|
TableAccessible* table = Table();
|
2012-10-19 11:15:23 +04:00
|
|
|
if (!table) // we expect to be in a listbox (table)
|
|
|
|
return attributes.forget();
|
2009-09-11 05:07:56 +04:00
|
|
|
|
|
|
|
nsAutoString stringIdx;
|
2012-08-09 10:24:31 +04:00
|
|
|
stringIdx.AppendInt(table->CellIndexAt(RowIdx(), ColIdx()));
|
2012-10-19 11:15:23 +04:00
|
|
|
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
|
2007-01-11 23:07:36 +03:00
|
|
|
|
2012-10-19 11:15:23 +04:00
|
|
|
return attributes.forget();
|
2007-01-11 23:07:36 +03:00
|
|
|
}
|