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 "nsIAutoCompletePopup.h"
|
|
|
|
#include "nsIDOMXULMenuListElement.h"
|
2008-03-06 07:14:10 +03:00
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
2011-09-28 05:46:11 +04:00
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2018-04-26 00:01:30 +03:00
|
|
|
#include "nsINodeList.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
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
role XULColumAccessible::NativeRole() const { return roles::LIST; }
|
2007-09-19 07:31:14 +04:00
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULColumAccessible::NativeState() const { return states::READONLY; }
|
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
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULColumnItemAccessible::NativeRole() const { return roles::COLUMNHEADER; }
|
2007-09-19 07:31:14 +04:00
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULColumnItemAccessible::NativeState() const {
|
2011-04-12 10:18:42 +04:00
|
|
|
return states::READONLY;
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2018-05-15 20:40:22 +03:00
|
|
|
uint8_t XULColumnItemAccessible::ActionCount() const { 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) {
|
|
|
|
if (aIndex == eAction_Click) aName.AssignLiteral("click");
|
2007-09-19 07:31:14 +04:00
|
|
|
}
|
|
|
|
|
2018-05-15 20:40:22 +03:00
|
|
|
bool XULColumnItemAccessible::DoAction(uint8_t aIndex) const {
|
2007-09-19 07:31:14 +04:00
|
|
|
if (aIndex != eAction_Click) return false;
|
|
|
|
|
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) {
|
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 =
|
2019-07-18 07:47:42 +03:00
|
|
|
parentContent->AsElement()->AsAutoCompletePopup();
|
2012-12-18 09:22:26 +04:00
|
|
|
if (autoCompletePopupElm) 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
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULListboxAccessible::NativeState() const {
|
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
|
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->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
|
|
|
}
|
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULListboxAccessible::NativeRole() const {
|
2010-06-11 12:23:18 +04:00
|
|
|
// A richlistbox is used with the new autocomplete URL bar, and has a parent
|
|
|
|
// popup <panel>.
|
2017-12-20 08:00:00 +03:00
|
|
|
if (mContent->GetParent() &&
|
|
|
|
mContent->GetParent()->IsXULElement(nsGkAtoms::panel))
|
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
|
|
|
|
2018-05-05 18:55:29 +03:00
|
|
|
uint32_t XULListboxAccessible::ColCount() const { return 0; }
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
uint32_t XULListboxAccessible::RowCount() {
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> element = Elm()->AsXULSelectControl();
|
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-08-22 19:56:38 +04:00
|
|
|
Accessible* XULListboxAccessible::CellAt(uint32_t aRowIndex,
|
|
|
|
uint32_t aColumnIndex) {
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> control = Elm()->AsXULSelectControl();
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(control, nullptr);
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2019-11-29 23:39:36 +03:00
|
|
|
RefPtr<dom::Element> element;
|
2018-12-04 19:25:41 +03:00
|
|
|
control->GetItemAtIndex(aRowIndex, getter_AddRefs(element));
|
|
|
|
if (!element) return nullptr;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
Accessible* row = mDoc->GetAccessible(element);
|
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-08-22 19:56:38 +04:00
|
|
|
bool XULListboxAccessible::IsColSelected(uint32_t aColIdx) {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
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-08-22 19:56:38 +04:00
|
|
|
bool XULListboxAccessible::IsRowSelected(uint32_t aRowIdx) {
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlElement> control = Elm()->AsXULSelectControl();
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control, "Doesn't implement nsIDOMXULSelectControlElement.");
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2019-11-29 23:39:36 +03:00
|
|
|
RefPtr<dom::Element> element;
|
2018-12-04 19:25:41 +03:00
|
|
|
nsresult rv = control->GetItemAtIndex(aRowIdx, getter_AddRefs(element));
|
2012-06-15 12:03:51 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2018-12-18 04:02:11 +03:00
|
|
|
if (!element) {
|
|
|
|
return false;
|
|
|
|
}
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
|
|
|
element->AsXULSelectControlItem();
|
2018-12-04 19:25:41 +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-08-22 19:56:38 +04:00
|
|
|
bool XULListboxAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
|
2012-06-15 12:03:51 +04:00
|
|
|
return IsRowSelected(aRowIdx);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-06-20 22:05:31 +04:00
|
|
|
uint32_t XULListboxAccessible::SelectedCellCount() {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
nsCOMPtr<nsINodeList> selectedItems;
|
2008-03-06 07:14:10 +03:00
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems) return 0;
|
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
uint32_t selectedItemsCount = selectedItems->Length();
|
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-06-20 22:05:31 +04:00
|
|
|
uint32_t XULListboxAccessible::SelectedColCount() {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
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-06-20 22:05:31 +04:00
|
|
|
uint32_t XULListboxAccessible::SelectedRowCount() {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
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 =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
2009-09-11 05:07:56 +04:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
nsCOMPtr<nsINodeList> selectedItems;
|
2009-09-11 05:07:56 +04:00
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems) return;
|
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
uint32_t selectedItemsCount = selectedItems->Length();
|
2009-09-11 05:07:56 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t index = 0; index < selectedItemsCount; index++) {
|
2018-04-26 00:01:30 +03:00
|
|
|
nsIContent* itemContent = selectedItems->Item(index);
|
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) aCells->AppendElement(cell);
|
2009-09-11 05:07:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void XULListboxAccessible::SelectedCellIndices(nsTArray<uint32_t>* aCells) {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
nsCOMPtr<nsINodeList> selectedItems;
|
2008-03-06 07:14:10 +03:00
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems) return;
|
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
uint32_t selectedItemsCount = selectedItems->Length();
|
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; selItemsIdx < selectedItemsCount;
|
2012-06-24 02:34:44 +04:00
|
|
|
selItemsIdx++) {
|
2018-04-26 00:01:30 +03:00
|
|
|
nsIContent* itemContent = selectedItems->Item(selItemsIdx);
|
2008-03-06 07:14:10 +03:00
|
|
|
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
|
|
|
itemContent->AsElement()->AsXULSelectControlItem();
|
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)
|
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-08-22 19:56:38 +04:00
|
|
|
void XULListboxAccessible::SelectedColIndices(nsTArray<uint32_t>* aCols) {
|
|
|
|
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-08-22 19:56:38 +04:00
|
|
|
void XULListboxAccessible::SelectedRowIndices(nsTArray<uint32_t>* aRows) {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
nsCOMPtr<nsINodeList> selectedItems;
|
2008-03-06 07:14:10 +03:00
|
|
|
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
|
|
|
if (!selectedItems) return;
|
2012-05-30 04:51:08 +04:00
|
|
|
|
2018-04-26 00:01:30 +03:00
|
|
|
uint32_t rowCount = selectedItems->Length();
|
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++) {
|
2018-04-26 00:01:30 +03:00
|
|
|
nsIContent* itemContent = selectedItems->Item(rowIdx);
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
|
2018-12-04 19:32:15 +03:00
|
|
|
itemContent->AsElement()->AsXULSelectControlItem();
|
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-08-22 19:56:38 +04:00
|
|
|
void XULListboxAccessible::SelectRow(uint32_t aRowIdx) {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2019-11-29 23:39:36 +03:00
|
|
|
RefPtr<dom::Element> item;
|
2012-06-11 09:25:07 +04:00
|
|
|
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
2018-12-18 04:02:11 +03:00
|
|
|
if (!item) {
|
|
|
|
return;
|
|
|
|
}
|
2018-12-04 19:25:41 +03:00
|
|
|
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
|
|
|
|
item->AsXULSelectControlItem();
|
2018-12-04 19:25:41 +03:00
|
|
|
control->SelectItem(itemElm);
|
2008-02-19 12:07:35 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void XULListboxAccessible::UnselectRow(uint32_t aRowIdx) {
|
2008-03-06 07:14:10 +03:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULMultiSelectControl();
|
2008-03-06 07:14:10 +03:00
|
|
|
NS_ASSERTION(control,
|
|
|
|
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
|
|
|
|
2019-11-29 23:39:36 +03:00
|
|
|
RefPtr<dom::Element> item;
|
2012-06-11 09:25:07 +04:00
|
|
|
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
2018-12-18 04:02:11 +03:00
|
|
|
if (!item) {
|
|
|
|
return;
|
|
|
|
}
|
2018-12-04 19:25:41 +03:00
|
|
|
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
|
|
|
|
item->AsXULSelectControlItem();
|
2018-12-04 19:25:41 +03:00
|
|
|
control->RemoveItemFromSelection(itemElm);
|
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
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
bool XULListboxAccessible::IsWidget() const { return true; }
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
bool XULListboxAccessible::IsActiveWidget() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
if (IsAutoCompletePopup()) {
|
2019-07-18 07:47:42 +03:00
|
|
|
nsIContent* parentContent = mContent->GetParent();
|
|
|
|
if (parentContent) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
parentContent->AsElement()->AsAutoCompletePopup();
|
|
|
|
if (autoCompletePopupElm) {
|
|
|
|
bool isOpen = false;
|
|
|
|
autoCompletePopupElm->GetPopupOpen(&isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
bool XULListboxAccessible::AreItemsOperable() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
if (IsAutoCompletePopup()) {
|
2019-07-18 07:47:42 +03:00
|
|
|
nsIContent* parentContent = mContent->GetParent();
|
|
|
|
if (parentContent) {
|
|
|
|
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
|
|
|
|
parentContent->AsElement()->AsAutoCompletePopup();
|
|
|
|
if (autoCompletePopupElm) {
|
|
|
|
bool isOpen = false;
|
|
|
|
autoCompletePopupElm->GetPopupOpen(&isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
Accessible* XULListboxAccessible::ContainerWidget() const {
|
2018-12-04 19:32:15 +03:00
|
|
|
if (IsAutoCompletePopup() && mContent->GetParent()) {
|
2011-09-28 05:46:11 +04:00
|
|
|
// 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 =
|
2018-12-04 19:32:15 +03:00
|
|
|
mContent->GetParent()->AsElement()->AsXULMenuList();
|
2011-09-28 05:46:11 +04:00
|
|
|
if (menuListElm) {
|
2018-05-30 05:58:47 +03:00
|
|
|
RefPtr<mozilla::dom::Element> inputElm;
|
2011-09-28 05:46:11 +04:00
|
|
|
menuListElm->GetInputField(getter_AddRefs(inputElm));
|
|
|
|
if (inputElm) {
|
2018-05-30 05:58:47 +03:00
|
|
|
Accessible* input = mDoc->GetAccessible(inputElm);
|
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) {
|
2017-12-07 21:13:50 +03:00
|
|
|
mIsCheckbox = mContent->AsElement()->AttrValueIs(
|
|
|
|
kNameSpaceID_None, nsGkAtoms::type, nsGkAtoms::checkbox, eCaseMatters);
|
2014-03-31 18:30:46 +04:00
|
|
|
mType = eXULListItemType;
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:18 +04:00
|
|
|
XULListitemAccessible::~XULListitemAccessible() {}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
Accessible* XULListitemAccessible::GetListAccessible() const {
|
2008-02-19 12:07:35 +03:00
|
|
|
if (IsDefunct()) return nullptr;
|
2014-04-26 06:42:19 +04:00
|
|
|
|
2008-02-19 12:07:35 +03:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULSelectControlItem();
|
2012-07-30 18:20:58 +04:00
|
|
|
if (!listItem) return nullptr;
|
2008-02-22 14:07:54 +03:00
|
|
|
|
2019-11-29 23:39:36 +03:00
|
|
|
RefPtr<dom::Element> listElement;
|
2018-12-04 19:25:41 +03:00
|
|
|
listItem->GetControl(getter_AddRefs(listElement));
|
|
|
|
if (!listElement) return nullptr;
|
2008-02-19 12:07:35 +03:00
|
|
|
|
2018-12-04 19:25:41 +03:00
|
|
|
return mDoc->GetAccessible(listElement);
|
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
|
|
|
|
2012-06-09 12:21:07 +04:00
|
|
|
void XULListitemAccessible::Description(nsString& aDesc) {
|
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
|
|
|
/**
|
2018-07-18 13:23:32 +03:00
|
|
|
* Get the name from GetXULName.
|
|
|
|
*/
|
2018-05-15 19:13:02 +03:00
|
|
|
ENameValueFlag XULListitemAccessible::NativeName(nsString& aName) const {
|
2013-12-08 01:37:04 +04:00
|
|
|
return Accessible::NativeName(aName);
|
2002-02-18 10:35:10 +03:00
|
|
|
}
|
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULListitemAccessible::NativeRole() const {
|
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
|
|
|
|
2012-03-24 05:09:10 +04:00
|
|
|
if (mIsCheckbox) 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
|
|
|
}
|
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULListitemAccessible::NativeState() const {
|
2012-06-09 12:21:07 +04:00
|
|
|
if (mIsCheckbox) 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 =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULSelectControlItem();
|
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);
|
2011-04-10 03:38:06 +04:00
|
|
|
if (isSelected) states |= states::SELECTED;
|
2002-02-18 10:35:10 +03:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
if (FocusMgr()->IsFocused(this)) 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-06-09 12:21:07 +04:00
|
|
|
uint64_t XULListitemAccessible::NativeInteractiveState() const {
|
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) {
|
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-06-09 12:21:07 +04:00
|
|
|
Accessible* XULListitemAccessible::ContainerWidget() const { return Parent(); }
|