2001-10-10 01:52:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; 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-10-10 01:52:36 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
#include "XULFormControlAccessible.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "Accessible-inl.h"
|
2012-04-12 15:11:40 +04:00
|
|
|
#include "HTMLFormControlAccessible.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccUtils.h"
|
2012-05-27 13:01:40 +04:00
|
|
|
#include "DocAccessible.h"
|
2012-04-12 15:11:40 +04:00
|
|
|
#include "nsIAccessibleRelation.h"
|
2011-08-10 05:44:00 +04:00
|
|
|
#include "Relation.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Role.h"
|
2011-04-10 03:38:06 +04:00
|
|
|
#include "States.h"
|
2012-11-19 13:20:09 +04:00
|
|
|
#include "TreeWalker.h"
|
2012-06-11 03:44:50 +04:00
|
|
|
#include "XULMenuAccessible.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2001-10-10 01:52:36 +04:00
|
|
|
#include "nsIDOMXULButtonElement.h"
|
2002-01-11 06:48:02 +03:00
|
|
|
#include "nsIDOMXULMenuListElement.h"
|
2019-01-11 07:52:50 +03:00
|
|
|
#include "nsIDOMXULRadioGroupElement.h"
|
2001-11-07 03:12:16 +03:00
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2007-08-14 20:25:24 +04:00
|
|
|
#include "nsIEditor.h"
|
2006-07-12 17:14:53 +04:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsITextControlFrame.h"
|
2011-09-28 05:46:11 +04:00
|
|
|
#include "nsMenuPopupFrame.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2001-10-10 01:52:36 +04:00
|
|
|
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2009-11-10 08:58:52 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULButtonAccessible
|
2009-11-10 08:58:52 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULButtonAccessible::XULButtonAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-05-29 05:18:45 +04:00
|
|
|
: AccessibleWrap(aContent, aDoc) {
|
2014-04-04 12:01:19 +04:00
|
|
|
if (ContainsMenu()) {
|
2012-12-18 09:22:26 +04:00
|
|
|
mGenericTypes |= eMenuButton;
|
2014-04-04 12:01:19 +04:00
|
|
|
} else {
|
|
|
|
mGenericTypes |= eButton;
|
|
|
|
}
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:18 +04:00
|
|
|
XULButtonAccessible::~XULButtonAccessible() {}
|
|
|
|
|
2009-11-10 08:58:52 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULButtonAccessible: nsISupports
|
2009-11-10 08:58:52 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULButtonAccessible: nsIAccessible
|
2009-11-10 08:58:52 +03:00
|
|
|
|
2018-05-15 20:40:22 +03:00
|
|
|
uint8_t XULButtonAccessible::ActionCount() const { return 1; }
|
2001-10-10 01:52:36 +04:00
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void XULButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName) {
|
|
|
|
if (aIndex == eAction_Click) aName.AssignLiteral("press");
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2018-05-15 20:40:22 +03:00
|
|
|
bool XULButtonAccessible::DoAction(uint8_t aIndex) const {
|
2010-01-25 18:09:25 +03:00
|
|
|
if (aIndex != 0) return false;
|
2009-11-10 08:58:52 +03:00
|
|
|
|
2010-01-25 18:09:25 +03:00
|
|
|
DoCommand();
|
2014-09-16 21:30:23 +04:00
|
|
|
return true;
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2009-11-10 08:58:52 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-29 05:18:45 +04:00
|
|
|
// XULButtonAccessible: Accessible
|
2009-11-10 08:58:52 +03:00
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULButtonAccessible::NativeRole() const { return roles::PUSHBUTTON; }
|
2001-10-10 01:52:36 +04:00
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULButtonAccessible::NativeState() const {
|
2009-11-10 08:58:52 +03:00
|
|
|
// Possible states: focused, focusable, unavailable(disabled).
|
|
|
|
|
2001-11-07 03:12:16 +03:00
|
|
|
// get focus and disable status from base class
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = Accessible::NativeState();
|
2002-01-09 13:02:29 +03:00
|
|
|
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
// Buttons can be checked -- they simply appear pressed in rather than checked
|
2018-12-04 19:32:15 +03:00
|
|
|
nsCOMPtr<nsIDOMXULButtonElement> xulButtonElement = Elm()->AsXULButton();
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
if (xulButtonElement) {
|
2007-05-06 18:50:03 +04:00
|
|
|
nsAutoString type;
|
|
|
|
xulButtonElement->GetType(type);
|
|
|
|
if (type.EqualsLiteral("checkbox") || type.EqualsLiteral("radio")) {
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::CHECKABLE;
|
2018-11-23 01:39:51 +03:00
|
|
|
}
|
|
|
|
// Some buttons can have their checked state set without being of type
|
|
|
|
// checkbox or radio. Expose the pressed state unconditionally.
|
|
|
|
bool checked = false;
|
|
|
|
xulButtonElement->GetChecked(&checked);
|
|
|
|
if (checked) {
|
|
|
|
state |= states::PRESSED;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
if (ContainsMenu()) state |= states::HASPOPUP;
|
2005-04-02 05:00:20 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::_default))
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::DEFAULT;
|
2002-03-10 08:14:24 +03:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULButtonAccessible: Widgets
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
bool XULButtonAccessible::IsWidget() const { return true; }
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
bool XULButtonAccessible::IsActiveWidget() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
bool XULButtonAccessible::AreItemsOperable() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
if (IsMenuButton()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
Accessible* menuPopup = mChildren.SafeElementAt(0, nullptr);
|
2011-09-28 05:46:11 +04:00
|
|
|
if (menuPopup) {
|
|
|
|
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
|
|
|
|
return menuPopupFrame->IsOpen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false; // no items
|
|
|
|
}
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
Accessible* XULButtonAccessible::ContainerWidget() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
if (IsMenuButton() && mParent && mParent->IsAutoComplete()) return mParent;
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
|
2016-02-24 16:01:21 +03:00
|
|
|
bool XULButtonAccessible::IsAcceptableChild(nsIContent* aEl) const {
|
2009-11-10 08:58:52 +03:00
|
|
|
// In general XUL button has not accessible children. Nevertheless menu
|
2018-08-29 16:04:25 +03:00
|
|
|
// buttons can have popup accessibles (@type="menu" or columnpicker).
|
|
|
|
return aEl->IsXULElement(nsGkAtoms::menupopup) ||
|
|
|
|
aEl->IsXULElement(nsGkAtoms::popup);
|
2002-01-09 13:02:29 +03:00
|
|
|
}
|
|
|
|
|
2009-11-10 08:58:52 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULButtonAccessible protected
|
2009-11-10 08:58:52 +03:00
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool XULButtonAccessible::ContainsMenu() const {
|
2018-08-29 16:04:25 +03:00
|
|
|
return mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::menu, eCaseMatters);
|
2009-11-10 08:58:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULDropmarkerAccessible
|
2009-11-10 08:58:52 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULDropmarkerAccessible::XULDropmarkerAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-06-04 16:32:29 +04:00
|
|
|
: LeafAccessible(aContent, aDoc) {}
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2018-05-15 20:40:22 +03:00
|
|
|
uint8_t XULDropmarkerAccessible::ActionCount() const { return 1; }
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen) const {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOpen = false;
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2015-10-13 19:19:41 +03:00
|
|
|
nsIContent* parent = mContent->GetFlattenedTreeParent();
|
|
|
|
|
|
|
|
while (parent) {
|
|
|
|
nsCOMPtr<nsIDOMXULButtonElement> parentButtonElement =
|
2018-12-04 19:32:15 +03:00
|
|
|
parent->AsElement()->AsXULButton();
|
2015-10-13 19:19:41 +03:00
|
|
|
if (parentButtonElement) {
|
|
|
|
parentButtonElement->GetOpen(&isOpen);
|
|
|
|
if (aToggleOpen) parentButtonElement->SetOpen(!isOpen);
|
|
|
|
return isOpen;
|
|
|
|
}
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> parentMenuListElement =
|
2018-12-04 19:32:15 +03:00
|
|
|
parent->AsElement()->AsXULMenuList();
|
2002-01-11 06:48:02 +03:00
|
|
|
if (parentMenuListElement) {
|
|
|
|
parentMenuListElement->GetOpen(&isOpen);
|
|
|
|
if (aToggleOpen) parentMenuListElement->SetOpen(!isOpen);
|
2015-10-13 19:19:41 +03:00
|
|
|
return isOpen;
|
2002-01-11 06:48:02 +03:00
|
|
|
}
|
2015-10-13 19:19:41 +03:00
|
|
|
parent = parent->GetFlattenedTreeParent();
|
2002-01-11 06:48:02 +03:00
|
|
|
}
|
2002-01-09 13:02:29 +03:00
|
|
|
|
|
|
|
return isOpen;
|
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void XULDropmarkerAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName) {
|
|
|
|
aName.Truncate();
|
2007-02-25 06:43:20 +03:00
|
|
|
if (aIndex == eAction_Click) {
|
2011-10-17 18:59:28 +04:00
|
|
|
if (DropmarkerOpen(false))
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("close");
|
2002-01-09 13:02:29 +03:00
|
|
|
else
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("open");
|
2002-01-09 13:02:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 20:40:22 +03:00
|
|
|
bool XULDropmarkerAccessible::DoAction(uint8_t index) const {
|
2002-01-09 13:02:29 +03:00
|
|
|
if (index == eAction_Click) {
|
2011-10-17 18:59:28 +04:00
|
|
|
DropmarkerOpen(true); // Reverse the open attribute
|
2014-09-16 21:30:23 +04:00
|
|
|
return true;
|
2002-01-09 13:02:29 +03:00
|
|
|
}
|
2014-09-16 21:30:23 +04:00
|
|
|
return false;
|
2002-01-09 13:02:29 +03:00
|
|
|
}
|
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULDropmarkerAccessible::NativeRole() const { return roles::PUSHBUTTON; }
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULDropmarkerAccessible::NativeState() const {
|
2011-10-17 18:59:28 +04:00
|
|
|
return DropmarkerOpen(false) ? states::PRESSED : 0;
|
2002-01-09 13:02:29 +03:00
|
|
|
}
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULGroupboxAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULGroupboxAccessible::XULGroupboxAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-05-29 05:18:45 +04:00
|
|
|
: AccessibleWrap(aContent, aDoc) {}
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULGroupboxAccessible::NativeRole() const { return roles::GROUPING; }
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
|
2018-05-15 19:13:02 +03:00
|
|
|
ENameValueFlag XULGroupboxAccessible::NativeName(nsString& aName) const {
|
2009-02-10 13:03:30 +03:00
|
|
|
// XXX: we use the first related accessible only.
|
2013-10-19 22:19:50 +04:00
|
|
|
Accessible* label = RelationByType(RelationType::LABELLED_BY).Next();
|
2012-10-14 08:18:39 +04:00
|
|
|
if (label) return label->Name(aName);
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
}
|
|
|
|
|
2018-05-15 16:47:10 +03:00
|
|
|
Relation XULGroupboxAccessible::RelationByType(RelationType aType) const {
|
2012-05-29 05:18:45 +04:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2018-11-15 15:05:09 +03:00
|
|
|
|
|
|
|
// The label for xul:groupbox is generated from the first xul:label
|
|
|
|
if (aType == RelationType::LABELLED_BY && ChildCount() > 0) {
|
|
|
|
Accessible* childAcc = GetChildAt(0);
|
|
|
|
if (childAcc->Role() == roles::LABEL &&
|
|
|
|
childAcc->GetContent()->IsXULElement(nsGkAtoms::label)) {
|
|
|
|
rel.AppendTarget(childAcc);
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
}
|
|
|
|
}
|
2007-07-01 00:06:13 +04:00
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
return rel;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
}
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULRadioButtonAccessible
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-12-11 23:49:49 +03:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULRadioButtonAccessible::XULRadioButtonAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-04-12 15:11:40 +04:00
|
|
|
: RadioButtonAccessible(aContent, aDoc) {}
|
2001-12-11 23:49:49 +03:00
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULRadioButtonAccessible::NativeState() const {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = LeafAccessible::NativeState();
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::CHECKABLE;
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> radioButton =
|
2018-12-04 19:32:15 +03:00
|
|
|
Elm()->AsXULSelectControlItem();
|
2004-07-02 00:43:03 +04:00
|
|
|
if (radioButton) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool selected = false; // Radio buttons can be selected
|
2001-12-11 23:49:49 +03:00
|
|
|
radioButton->GetSelected(&selected);
|
2004-07-02 00:43:03 +04:00
|
|
|
if (selected) {
|
2011-04-10 03:38:06 +04:00
|
|
|
state |= states::CHECKED;
|
2002-06-21 08:54:34 +04:00
|
|
|
}
|
|
|
|
}
|
2001-12-11 23:49:49 +03:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
return state;
|
2001-12-11 23:49:49 +03:00
|
|
|
}
|
|
|
|
|
2012-06-04 09:41:06 +04:00
|
|
|
uint64_t XULRadioButtonAccessible::NativeInteractiveState() const {
|
|
|
|
return NativelyUnavailable() ? states::UNAVAILABLE : states::FOCUSABLE;
|
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULRadioButtonAccessible: Widgets
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
Accessible* XULRadioButtonAccessible::ContainerWidget() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULRadioGroupAccessible
|
2010-01-06 13:36:50 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-27 16:17:11 +04:00
|
|
|
|
2001-12-11 23:49:49 +03:00
|
|
|
/**
|
|
|
|
* XUL Radio Group
|
|
|
|
* The Radio Group proxies for the Radio Buttons themselves. The Group gets
|
|
|
|
* focus whereas the Buttons do not. So we only have an accessible object for
|
2017-07-06 15:00:35 +03:00
|
|
|
* this for the purpose of getting the proper RadioButton. Need this here to
|
2001-12-11 23:49:49 +03:00
|
|
|
* avoid circular reference problems when navigating the accessible tree and
|
|
|
|
* for getting to the radiobuttons.
|
|
|
|
*/
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULRadioGroupAccessible::XULRadioGroupAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-01-12 07:07:35 +04:00
|
|
|
: XULSelectControlAccessible(aContent, aDoc) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULRadioGroupAccessible::NativeRole() const { return roles::RADIO_GROUP; }
|
2002-06-21 08:54:34 +04:00
|
|
|
|
2012-06-04 09:41:06 +04:00
|
|
|
uint64_t XULRadioGroupAccessible::NativeInteractiveState() const {
|
2008-11-27 07:04:05 +03:00
|
|
|
// The radio group is not focusable. Sometimes the focus controller will
|
|
|
|
// report that it is focused. That means that the actual selected radio button
|
|
|
|
// should be considered focused.
|
2012-06-04 09:41:06 +04:00
|
|
|
return NativelyUnavailable() ? states::UNAVAILABLE : 0;
|
2002-06-21 08:54:34 +04:00
|
|
|
}
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULRadioGroupAccessible: Widgets
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
bool XULRadioGroupAccessible::IsWidget() const { return true; }
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
bool XULRadioGroupAccessible::IsActiveWidget() const {
|
2011-09-28 05:46:11 +04:00
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
bool XULRadioGroupAccessible::AreItemsOperable() const { return true; }
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2019-01-11 07:52:50 +03:00
|
|
|
Accessible* XULRadioGroupAccessible::CurrentItem() const {
|
|
|
|
if (!mSelectControl) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Element> currentItemElm;
|
|
|
|
nsCOMPtr<nsIDOMXULRadioGroupElement> group =
|
|
|
|
mSelectControl->AsXULRadioGroup();
|
|
|
|
if (group) {
|
|
|
|
group->GetFocusedItem(getter_AddRefs(currentItemElm));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentItemElm) {
|
|
|
|
DocAccessible* document = Document();
|
|
|
|
if (document) {
|
|
|
|
return document->GetAccessible(currentItemElm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void XULRadioGroupAccessible::SetCurrentItem(const Accessible* aItem) {
|
|
|
|
if (!mSelectControl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<Element> itemElm = aItem->Elm();
|
|
|
|
nsCOMPtr<nsIDOMXULRadioGroupElement> group =
|
|
|
|
mSelectControl->AsXULRadioGroup();
|
|
|
|
if (group) {
|
|
|
|
group->SetFocusedItem(itemElm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULStatusBarAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULStatusBarAccessible::XULStatusBarAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-05-29 05:18:45 +04:00
|
|
|
: AccessibleWrap(aContent, aDoc) {}
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULStatusBarAccessible::NativeRole() const { return roles::STATUSBAR; }
|
2010-06-11 12:23:18 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULToolbarButtonAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULToolbarButtonAccessible::XULToolbarButtonAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-04-12 15:11:40 +04:00
|
|
|
: XULButtonAccessible(aContent, aDoc) {}
|
2007-07-11 11:58:50 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void XULToolbarButtonAccessible::GetPositionAndSizeInternal(int32_t* aPosInSet,
|
|
|
|
int32_t* aSetSize) {
|
|
|
|
int32_t setSize = 0;
|
|
|
|
int32_t posInSet = 0;
|
2007-07-11 11:58:50 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* parent = Parent();
|
2011-07-23 12:38:33 +04:00
|
|
|
if (!parent) return;
|
2010-01-11 17:14:06 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t childCount = parent->ChildCount();
|
|
|
|
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* child = parent->GetChildAt(childIdx);
|
2010-01-11 17:14:06 +03:00
|
|
|
if (IsSeparator(child)) { // end of a group of buttons
|
|
|
|
if (posInSet) break; // we've found our group, so we're done
|
|
|
|
|
|
|
|
setSize = 0; // not our group, so start a new group
|
|
|
|
|
|
|
|
} else {
|
|
|
|
setSize++; // another button in the group
|
|
|
|
|
|
|
|
if (child == this) posInSet = setSize; // we've found our button
|
2007-07-11 11:58:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-06 13:36:50 +03:00
|
|
|
*aPosInSet = posInSet;
|
|
|
|
*aSetSize = setSize;
|
2007-07-11 11:58:50 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
bool XULToolbarButtonAccessible::IsSeparator(Accessible* aAccessible) {
|
2012-02-07 17:18:33 +04:00
|
|
|
nsIContent* content = aAccessible->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
return content && content->IsAnyOfXULElements(nsGkAtoms::toolbarseparator,
|
|
|
|
nsGkAtoms::toolbarspacer,
|
|
|
|
nsGkAtoms::toolbarspring);
|
|
|
|
}
|
2007-07-11 11:58:50 +04:00
|
|
|
|
2018-11-22 08:57:48 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// XULToolbarButtonAccessible: Widgets
|
|
|
|
|
|
|
|
bool XULToolbarButtonAccessible::IsAcceptableChild(nsIContent* aEl) const {
|
|
|
|
// In general XUL button has not accessible children. Nevertheless menu
|
|
|
|
// buttons can have popup accessibles (@type="menu" or columnpicker).
|
|
|
|
// Also: Toolbar buttons can have labels as children.
|
Bug 1512411 - Don't expose broken label children accessibles on a XUL toolbarbutton which specifies the label attribute, r=Jamie
In bug 1507365, we introduced the ability of nested label children of toolbar buttons to provide the accessible name for a xul:toolbarbutton element. However, the XBL of xul:toolbarbutton causes the creation of a label accessible even if no xul:label child is present, and only the label attribute is being used. The nsIAccessibleText interface on such labels is, however, completely broken. This causes NVDA's mouse tracking, which always uses the deepest nested child, to fail. As a result, when hovering over Hamburger menu items, the announcement would be wrong, e. g., lag one behind the actual button the mouse is hovering over.
To fix this, we only accept xul:label children if they come from real XUL markup, not from the label attribute and the XBL creating the label. This means that some of the test changes from bug 1507365 have to be reverted to accommodate the new old behavior. But the new test for an actual label child still passes.
Differential Revision: https://phabricator.services.mozilla.com/D14469
--HG--
extra : moz-landing-system : lando
2018-12-14 11:20:02 +03:00
|
|
|
// But only if the label attribute is not present.
|
2018-11-22 08:57:48 +03:00
|
|
|
return aEl->IsXULElement(nsGkAtoms::menupopup) ||
|
|
|
|
aEl->IsXULElement(nsGkAtoms::popup) ||
|
Bug 1512411 - Don't expose broken label children accessibles on a XUL toolbarbutton which specifies the label attribute, r=Jamie
In bug 1507365, we introduced the ability of nested label children of toolbar buttons to provide the accessible name for a xul:toolbarbutton element. However, the XBL of xul:toolbarbutton causes the creation of a label accessible even if no xul:label child is present, and only the label attribute is being used. The nsIAccessibleText interface on such labels is, however, completely broken. This causes NVDA's mouse tracking, which always uses the deepest nested child, to fail. As a result, when hovering over Hamburger menu items, the announcement would be wrong, e. g., lag one behind the actual button the mouse is hovering over.
To fix this, we only accept xul:label children if they come from real XUL markup, not from the label attribute and the XBL creating the label. This means that some of the test changes from bug 1507365 have to be reverted to accommodate the new old behavior. But the new test for an actual label child still passes.
Differential Revision: https://phabricator.services.mozilla.com/D14469
--HG--
extra : moz-landing-system : lando
2018-12-14 11:20:02 +03:00
|
|
|
(aEl->IsXULElement(nsGkAtoms::label) &&
|
|
|
|
!mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::label));
|
2018-11-22 08:57:48 +03:00
|
|
|
}
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULToolbarAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
XULToolbarAccessible::XULToolbarAccessible(nsIContent* aContent,
|
|
|
|
DocAccessible* aDoc)
|
2012-05-29 05:18:45 +04:00
|
|
|
: AccessibleWrap(aContent, aDoc) {}
|
2002-11-06 04:29:58 +03:00
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULToolbarAccessible::NativeRole() const { return roles::TOOLBAR; }
|
2002-11-06 04:29:58 +03:00
|
|
|
|
2018-05-15 19:13:02 +03:00
|
|
|
ENameValueFlag XULToolbarAccessible::NativeName(nsString& aName) const {
|
2017-12-07 21:13:50 +03:00
|
|
|
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname,
|
|
|
|
aName))
|
2012-10-14 08:18:39 +04:00
|
|
|
aName.CompressWhitespace();
|
2010-05-12 11:29:51 +04:00
|
|
|
|
2012-10-14 08:18:39 +04:00
|
|
|
return eNameOK;
|
2010-05-12 11:29:51 +04:00
|
|
|
}
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-12 15:11:40 +04:00
|
|
|
// XULToolbarAccessible
|
2010-06-11 12:23:18 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 15:11:40 +04:00
|
|
|
XULToolbarSeparatorAccessible::XULToolbarSeparatorAccessible(
|
2012-05-27 13:01:40 +04:00
|
|
|
nsIContent* aContent, DocAccessible* aDoc)
|
2012-06-04 16:32:29 +04:00
|
|
|
: LeafAccessible(aContent, aDoc) {}
|
2002-11-06 04:29:58 +03:00
|
|
|
|
2018-05-07 22:05:50 +03:00
|
|
|
role XULToolbarSeparatorAccessible::NativeRole() const {
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::SEPARATOR;
|
2002-11-06 04:29:58 +03:00
|
|
|
}
|
|
|
|
|
2018-05-15 21:04:50 +03:00
|
|
|
uint64_t XULToolbarSeparatorAccessible::NativeState() const { return 0; }
|