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-06-04 16:32:29 +04:00
|
|
|
#include "BaseAccessibles.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "Accessible-inl.h"
|
2012-05-31 12:04:41 +04:00
|
|
|
#include "HyperTextAccessibleWrap.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsAccUtils.h"
|
2008-10-16 05:52:58 +04:00
|
|
|
#include "nsCoreUtils.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2005-01-30 04:31:50 +03:00
|
|
|
#include "nsIURI.h"
|
2001-10-10 01:52:36 +04:00
|
|
|
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2009-10-28 13:42:36 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 16:32:29 +04:00
|
|
|
// LeafAccessible
|
2009-10-28 13:42:36 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-10-10 01:52:36 +04:00
|
|
|
|
2012-06-04 16:32:29 +04:00
|
|
|
LeafAccessible::
|
|
|
|
LeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2001-10-10 01:52:36 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-04 16:32:29 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(LeafAccessible, Accessible)
|
2003-04-02 00:02:51 +04:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 16:32:29 +04:00
|
|
|
// LeafAccessible: Accessible public
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-08-22 19:56:38 +04:00
|
|
|
LeafAccessible::ChildAtPoint(int32_t aX, int32_t aY,
|
2012-06-04 16:32:29 +04:00
|
|
|
EWhichChildAtPoint aWhichChild)
|
2009-05-11 14:57:28 +04:00
|
|
|
{
|
|
|
|
// Don't walk into leaf accessibles.
|
2011-03-29 08:44:20 +04:00
|
|
|
return this;
|
2009-05-11 14:57:28 +04:00
|
|
|
}
|
|
|
|
|
2012-11-14 11:08:45 +04:00
|
|
|
bool
|
|
|
|
LeafAccessible::InsertChildAt(uint32_t aIndex, Accessible* aChild)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("InsertChildAt called on leaf accessible!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LeafAccessible::RemoveChild(Accessible* aChild)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("RemoveChild called on leaf accessible!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-25 18:42:52 +03:00
|
|
|
bool
|
|
|
|
LeafAccessible::IsAcceptableChild(nsIContent* aEl) const
|
|
|
|
{
|
|
|
|
// No children for leaf accessible.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 16:32:29 +04:00
|
|
|
// LeafAccessible: Accessible private
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2009-10-28 13:42:36 +03:00
|
|
|
void
|
2012-06-04 16:32:29 +04:00
|
|
|
LeafAccessible::CacheChildren()
|
2009-10-28 13:42:36 +03:00
|
|
|
{
|
|
|
|
// No children for leaf accessible.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-18 14:37:12 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 16:32:29 +04:00
|
|
|
// LinkableAccessible
|
2009-10-28 13:42:36 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-10-10 01:52:36 +04:00
|
|
|
|
2012-06-04 16:32:29 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(LinkableAccessible, AccessibleWrap)
|
2003-04-02 00:02:51 +04:00
|
|
|
|
2008-03-18 14:37:12 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 16:32:29 +04:00
|
|
|
// LinkableAccessible. nsIAccessible
|
2008-03-18 14:37:12 +03:00
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
2012-06-04 16:32:29 +04:00
|
|
|
LinkableAccessible::TakeFocus()
|
2008-03-18 14:37:12 +03:00
|
|
|
{
|
2015-08-05 06:33:54 +03:00
|
|
|
if (Accessible* actionAcc = ActionWalk()) {
|
|
|
|
actionAcc->TakeFocus();
|
|
|
|
} else {
|
2014-09-16 21:30:23 +04:00
|
|
|
AccessibleWrap::TakeFocus();
|
2015-08-05 06:33:54 +03:00
|
|
|
}
|
2002-07-03 20:38:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-06-04 16:32:29 +04:00
|
|
|
LinkableAccessible::NativeLinkState() const
|
2001-10-10 01:52:36 +04:00
|
|
|
{
|
2015-08-05 06:33:54 +03:00
|
|
|
bool isLink;
|
|
|
|
Accessible* actionAcc =
|
|
|
|
const_cast<LinkableAccessible*>(this)->ActionWalk(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
return states::LINKED | (actionAcc->LinkState() & states::TRAVERSED);
|
|
|
|
}
|
2002-01-09 13:02:29 +03:00
|
|
|
|
2012-05-17 13:37:37 +04:00
|
|
|
return 0;
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2012-04-09 13:48:41 +04:00
|
|
|
void
|
2012-06-04 16:32:29 +04:00
|
|
|
LinkableAccessible::Value(nsString& aValue)
|
2001-10-10 01:52:36 +04:00
|
|
|
{
|
2008-01-23 04:37:23 +03:00
|
|
|
aValue.Truncate();
|
2008-03-18 14:37:12 +03:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible::Value(aValue);
|
2015-08-05 06:33:54 +03:00
|
|
|
if (!aValue.IsEmpty()) {
|
2012-04-09 13:48:41 +04:00
|
|
|
return;
|
2015-08-05 06:33:54 +03:00
|
|
|
}
|
2008-01-23 04:37:23 +03:00
|
|
|
|
2015-08-05 06:33:54 +03:00
|
|
|
bool isLink;
|
|
|
|
Accessible* actionAcc = ActionWalk(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
actionAcc->Value(aValue);
|
|
|
|
}
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2012-06-04 16:32:29 +04:00
|
|
|
LinkableAccessible::ActionCount()
|
2001-10-10 01:52:36 +04:00
|
|
|
{
|
2016-01-14 23:37:15 +03:00
|
|
|
bool isLink, isOnclick, isLabelWithControl;
|
|
|
|
ActionWalk(&isLink, &isOnclick, &isLabelWithControl);
|
|
|
|
return (isLink || isOnclick || isLabelWithControl) ? 1 : 0;
|
2015-08-05 06:33:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Accessible*
|
2016-01-14 23:37:15 +03:00
|
|
|
LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick,
|
|
|
|
bool* aIsLabelWithControl)
|
2015-08-05 06:33:54 +03:00
|
|
|
{
|
|
|
|
if (aIsOnclick) {
|
|
|
|
*aIsOnclick = false;
|
|
|
|
}
|
|
|
|
if (aIsLink) {
|
|
|
|
*aIsLink = false;
|
|
|
|
}
|
2016-01-14 23:37:15 +03:00
|
|
|
if (aIsLabelWithControl) {
|
|
|
|
*aIsLabelWithControl = false;
|
|
|
|
}
|
2015-08-05 06:33:54 +03:00
|
|
|
|
|
|
|
if (nsCoreUtils::HasClickListener(mContent)) {
|
|
|
|
if (aIsOnclick) {
|
|
|
|
*aIsOnclick = true;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX: The logic looks broken since the click listener may be registered
|
|
|
|
// on non accessible node in parent chain but this node is skipped when tree
|
|
|
|
// is traversed.
|
|
|
|
Accessible* walkUpAcc = this;
|
|
|
|
while ((walkUpAcc = walkUpAcc->Parent()) && !walkUpAcc->IsDoc()) {
|
|
|
|
if (walkUpAcc->LinkState() & states::LINKED) {
|
|
|
|
if (aIsLink) {
|
|
|
|
*aIsLink = true;
|
|
|
|
}
|
|
|
|
return walkUpAcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCoreUtils::HasClickListener(walkUpAcc->GetContent())) {
|
|
|
|
if (aIsOnclick) {
|
|
|
|
*aIsOnclick = true;
|
|
|
|
}
|
|
|
|
return walkUpAcc;
|
|
|
|
}
|
2016-01-14 23:37:15 +03:00
|
|
|
|
|
|
|
if (nsCoreUtils::IsLabelWithControl(walkUpAcc->GetContent())) {
|
|
|
|
if (aIsLabelWithControl) {
|
|
|
|
*aIsLabelWithControl = true;
|
|
|
|
}
|
|
|
|
return walkUpAcc;
|
|
|
|
}
|
2015-08-05 06:33:54 +03:00
|
|
|
}
|
|
|
|
return nullptr;
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
void
|
|
|
|
LinkableAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2001-10-10 01:52:36 +04:00
|
|
|
{
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.Truncate();
|
2008-03-18 14:37:12 +03:00
|
|
|
|
|
|
|
// Action 0 (default action): Jump to link
|
2012-06-04 16:32:29 +04:00
|
|
|
if (aIndex == eAction_Jump) {
|
2016-01-14 23:37:15 +03:00
|
|
|
bool isOnclick, isLink, isLabelWithControl;
|
|
|
|
ActionWalk(&isLink, &isOnclick, &isLabelWithControl);
|
2015-08-05 06:33:54 +03:00
|
|
|
if (isLink) {
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("jump");
|
2016-01-14 23:37:15 +03:00
|
|
|
} else if (isOnclick || isLabelWithControl) {
|
2007-02-25 06:43:20 +03:00
|
|
|
aName.AssignLiteral("click");
|
2015-08-05 06:33:54 +03:00
|
|
|
}
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
LinkableAccessible::DoAction(uint8_t aIndex)
|
2001-10-10 01:52:36 +04:00
|
|
|
{
|
2015-08-05 06:33:54 +03:00
|
|
|
if (aIndex != eAction_Jump) {
|
2014-09-16 21:30:23 +04:00
|
|
|
return false;
|
2015-08-05 06:33:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Accessible* actionAcc = ActionWalk()) {
|
|
|
|
return actionAcc->DoAction(aIndex);
|
|
|
|
}
|
2010-05-25 12:05:52 +04:00
|
|
|
|
2015-08-05 06:33:54 +03:00
|
|
|
return AccessibleWrap::DoAction(aIndex);
|
2001-10-10 01:52:36 +04:00
|
|
|
}
|
|
|
|
|
2011-07-19 12:30:24 +04:00
|
|
|
KeyBinding
|
2012-06-04 16:32:29 +04:00
|
|
|
LinkableAccessible::AccessKey() const
|
2002-10-25 04:08:44 +04:00
|
|
|
{
|
2015-08-05 06:33:54 +03:00
|
|
|
if (const Accessible* actionAcc =
|
|
|
|
const_cast<LinkableAccessible*>(this)->ActionWalk()) {
|
|
|
|
return actionAcc->AccessKey();
|
|
|
|
}
|
2008-03-18 14:37:12 +03:00
|
|
|
|
2015-08-05 06:33:54 +03:00
|
|
|
return Accessible::AccessKey();
|
2003-04-15 12:45:55 +04:00
|
|
|
}
|
2004-07-07 04:58:57 +04:00
|
|
|
|
2010-09-01 07:26:13 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 16:32:29 +04:00
|
|
|
// LinkableAccessible: HyperLinkAccessible
|
2010-09-01 07:26:13 +04:00
|
|
|
|
|
|
|
already_AddRefed<nsIURI>
|
2012-08-22 19:56:38 +04:00
|
|
|
LinkableAccessible::AnchorURIAt(uint32_t aAnchorIndex)
|
2010-09-01 07:26:13 +04:00
|
|
|
{
|
2015-08-05 06:33:54 +03:00
|
|
|
bool isLink;
|
|
|
|
Accessible* actionAcc = ActionWalk(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
NS_ASSERTION(actionAcc->IsLink(), "HyperLink isn't implemented.");
|
2010-09-01 07:26:13 +04:00
|
|
|
|
2015-08-05 06:33:54 +03:00
|
|
|
if (actionAcc->IsLink()) {
|
|
|
|
return actionAcc->AnchorURIAt(aAnchorIndex);
|
|
|
|
}
|
2010-09-01 07:26:13 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-09-01 07:26:13 +04:00
|
|
|
}
|
|
|
|
|
2012-03-23 16:21:31 +04:00
|
|
|
|
2012-10-13 10:34:21 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// DummyAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
DummyAccessible::NativeState()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
uint64_t
|
|
|
|
DummyAccessible::NativeInteractiveState() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
DummyAccessible::NativeLinkState() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DummyAccessible::NativelyUnavailable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-10-31 06:25:17 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
DummyAccessible::ApplyARIAState(uint64_t* aState) const
|
|
|
|
{
|
|
|
|
}
|