2001-10-09 21:52:36 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-09 21:52:36 +00:00
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
#include "BaseAccessibles.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
2012-04-13 14:17:03 +00:00
|
|
|
#include "Accessible-inl.h"
|
2012-05-31 08:04:41 +00:00
|
|
|
#include "HyperTextAccessibleWrap.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsAccUtils.h"
|
2008-10-16 01:52:58 +00:00
|
|
|
#include "nsCoreUtils.h"
|
2012-01-12 03:07:35 +00:00
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2005-01-30 01:31:50 +00:00
|
|
|
#include "nsIURI.h"
|
2001-10-09 21:52:36 +00:00
|
|
|
|
2011-07-27 12:43:01 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2009-10-28 10:42:36 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LeafAccessible
|
2009-10-28 10:42:36 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-10-09 21:52:36 +00:00
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
LeafAccessible::
|
|
|
|
LeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(LeafAccessible, Accessible)
|
2003-04-01 20:02:51 +00:00
|
|
|
|
2009-12-10 19:12:19 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LeafAccessible: Accessible public
|
2009-12-10 19:12:19 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible*
|
2012-08-22 15:56:38 +00:00
|
|
|
LeafAccessible::ChildAtPoint(int32_t aX, int32_t aY,
|
2012-06-04 12:32:29 +00:00
|
|
|
EWhichChildAtPoint aWhichChild)
|
2009-05-11 10:57:28 +00:00
|
|
|
{
|
|
|
|
// Don't walk into leaf accessibles.
|
2011-03-29 04:44:20 +00:00
|
|
|
return this;
|
2009-05-11 10:57:28 +00:00
|
|
|
}
|
|
|
|
|
2012-11-14 07:08:45 +00: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;
|
|
|
|
}
|
|
|
|
|
2009-12-10 19:12:19 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LeafAccessible: Accessible private
|
2009-12-10 19:12:19 +00:00
|
|
|
|
2009-10-28 10:42:36 +00:00
|
|
|
void
|
2012-06-04 12:32:29 +00:00
|
|
|
LeafAccessible::CacheChildren()
|
2009-10-28 10:42:36 +00:00
|
|
|
{
|
|
|
|
// No children for leaf accessible.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-18 11:37:12 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LinkableAccessible
|
2009-10-28 10:42:36 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-10-09 21:52:36 +00:00
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::
|
|
|
|
LinkableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap(aContent, aDoc),
|
2012-07-30 14:20:58 +00:00
|
|
|
mActionAcc(nullptr),
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsLink(false),
|
|
|
|
mIsOnclick(false)
|
2005-08-10 01:51:39 +00:00
|
|
|
{
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(LinkableAccessible, AccessibleWrap)
|
2003-04-01 20:02:51 +00:00
|
|
|
|
2008-03-18 11:37:12 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LinkableAccessible. nsIAccessible
|
2008-03-18 11:37:12 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::TakeFocus()
|
2008-03-18 11:37:12 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
return mActionAcc ? mActionAcc->TakeFocus() : AccessibleWrap::TakeFocus();
|
2002-07-03 16:38:15 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::NativeLinkState() const
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2012-05-17 09:37:37 +00:00
|
|
|
if (mIsLink)
|
|
|
|
return states::LINKED | (mActionAcc->LinkState() & states::TRAVERSED);
|
2002-01-09 10:02:29 +00:00
|
|
|
|
2012-05-17 09:37:37 +00:00
|
|
|
return 0;
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-09 09:48:41 +00:00
|
|
|
void
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::Value(nsString& aValue)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2008-01-23 01:37:23 +00:00
|
|
|
aValue.Truncate();
|
2008-03-18 11:37:12 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible::Value(aValue);
|
2008-01-23 01:37:23 +00:00
|
|
|
if (!aValue.IsEmpty())
|
2012-04-09 09:48:41 +00:00
|
|
|
return;
|
2008-01-23 01:37:23 +00:00
|
|
|
|
2012-04-09 09:48:41 +00:00
|
|
|
if (aValue.IsEmpty() && mIsLink)
|
|
|
|
mActionAcc->Value(aValue);
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::ActionCount()
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2011-06-05 19:35:43 +00:00
|
|
|
return (mIsOnclick || mIsLink) ? 1 : 0;
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:37:12 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
LinkableAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.Truncate();
|
2008-03-18 11:37:12 +00:00
|
|
|
|
|
|
|
// Action 0 (default action): Jump to link
|
2012-06-04 12:32:29 +00:00
|
|
|
if (aIndex == eAction_Jump) {
|
2005-08-10 01:51:39 +00:00
|
|
|
if (mIsLink) {
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.AssignLiteral("jump");
|
|
|
|
return NS_OK;
|
2005-08-10 01:51:39 +00:00
|
|
|
}
|
|
|
|
else if (mIsOnclick) {
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.AssignLiteral("click");
|
|
|
|
return NS_OK;
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
2002-03-01 07:27:29 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
2002-03-01 07:27:29 +00:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:37:12 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
LinkableAccessible::DoAction(uint8_t aIndex)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2008-08-08 14:44:26 +00:00
|
|
|
if (aIndex != eAction_Jump)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2010-05-25 08:05:52 +00:00
|
|
|
|
2011-05-21 07:00:07 +00:00
|
|
|
return mActionAcc ? mActionAcc->DoAction(aIndex) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap::DoAction(aIndex);
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
2011-07-19 08:30:24 +00:00
|
|
|
KeyBinding
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::AccessKey() const
|
2002-10-25 00:08:44 +00:00
|
|
|
{
|
2011-07-19 08:30:24 +00:00
|
|
|
return mActionAcc ?
|
2012-05-29 01:18:45 +00:00
|
|
|
mActionAcc->AccessKey() : Accessible::AccessKey();
|
2002-10-25 00:08:44 +00:00
|
|
|
}
|
2001-10-09 21:52:36 +00:00
|
|
|
|
2008-03-18 11:37:12 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2013-10-29 03:30:55 +00:00
|
|
|
// LinkableAccessible. Accessible
|
2008-03-18 11:37:12 +00:00
|
|
|
|
2010-06-12 04:04:35 +00:00
|
|
|
void
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::Shutdown()
|
2003-04-15 08:45:55 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsLink = false;
|
|
|
|
mIsOnclick = false;
|
2012-07-30 14:20:58 +00:00
|
|
|
mActionAcc = nullptr;
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap::Shutdown();
|
2003-04-15 08:45:55 +00:00
|
|
|
}
|
2004-07-07 00:58:57 +00:00
|
|
|
|
2010-09-01 03:26:13 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LinkableAccessible: HyperLinkAccessible
|
2010-09-01 03:26:13 +00:00
|
|
|
|
|
|
|
already_AddRefed<nsIURI>
|
2012-08-22 15:56:38 +00:00
|
|
|
LinkableAccessible::AnchorURIAt(uint32_t aAnchorIndex)
|
2010-09-01 03:26:13 +00:00
|
|
|
{
|
|
|
|
if (mIsLink) {
|
2011-06-24 04:29:43 +00:00
|
|
|
NS_ASSERTION(mActionAcc->IsLink(),
|
2011-05-21 07:00:07 +00:00
|
|
|
"nsIAccessibleHyperLink isn't implemented.");
|
2010-09-01 03:26:13 +00:00
|
|
|
|
2011-06-24 04:29:43 +00:00
|
|
|
if (mActionAcc->IsLink())
|
2011-06-14 03:56:42 +00:00
|
|
|
return mActionAcc->AnchorURIAt(aAnchorIndex);
|
2010-09-01 03:26:13 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-09-01 03:26:13 +00:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:37:12 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// LinkableAccessible: Accessible protected
|
2008-03-18 11:37:12 +00:00
|
|
|
|
|
|
|
void
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::BindToParent(Accessible* aParent,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aIndexInParent)
|
2008-03-18 11:37:12 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap::BindToParent(aParent, aIndexInParent);
|
2010-11-12 19:01:04 +00:00
|
|
|
|
|
|
|
// Cache action content.
|
2012-07-30 14:20:58 +00:00
|
|
|
mActionAcc = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsLink = false;
|
|
|
|
mIsOnclick = false;
|
2010-11-12 19:01:04 +00:00
|
|
|
|
2011-05-21 07:00:07 +00:00
|
|
|
if (nsCoreUtils::HasClickListener(mContent)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsOnclick = true;
|
2008-03-18 11:37:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-21 07:00:07 +00:00
|
|
|
// 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.
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* walkUpAcc = this;
|
2011-07-23 08:38:33 +00:00
|
|
|
while ((walkUpAcc = walkUpAcc->Parent()) && !walkUpAcc->IsDoc()) {
|
2012-05-17 09:37:37 +00:00
|
|
|
if (walkUpAcc->LinkState() & states::LINKED) {
|
|
|
|
mIsLink = true;
|
|
|
|
mActionAcc = walkUpAcc;
|
|
|
|
return;
|
2008-03-18 11:37:12 +00:00
|
|
|
}
|
|
|
|
|
2011-05-21 07:00:07 +00:00
|
|
|
if (nsCoreUtils::HasClickListener(walkUpAcc->GetContent())) {
|
|
|
|
mActionAcc = walkUpAcc;
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsOnclick = true;
|
2008-03-18 11:37:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-23 12:21:31 +00:00
|
|
|
void
|
2012-06-04 12:32:29 +00:00
|
|
|
LinkableAccessible::UnbindFromParent()
|
2012-03-23 12:21:31 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
mActionAcc = nullptr;
|
2012-03-23 12:21:31 +00:00
|
|
|
mIsLink = false;
|
|
|
|
mIsOnclick = false;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap::UnbindFromParent();
|
2012-03-23 12:21:31 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 08:23:18 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-04 12:32:29 +00:00
|
|
|
// EnumRoleAccessible
|
2010-06-11 08:23:18 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2005-09-30 02:16:13 +00:00
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
EnumRoleAccessible::
|
|
|
|
EnumRoleAccessible(nsIContent* aNode, DocAccessible* aDoc, roles::Role aRole) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap(aNode, aDoc), mRole(aRole)
|
2005-09-30 02:16:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(EnumRoleAccessible, Accessible)
|
2009-03-07 15:38:58 +00:00
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2012-06-04 12:32:29 +00:00
|
|
|
EnumRoleAccessible::NativeRole()
|
2009-03-07 15:38:58 +00:00
|
|
|
{
|
2010-09-05 02:14:01 +00:00
|
|
|
return mRole;
|
2009-03-07 15:38:58 +00:00
|
|
|
}
|
2012-10-13 06:34:21 +00: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 02:25:17 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
DummyAccessible::ApplyARIAState(uint64_t* aState) const
|
|
|
|
{
|
|
|
|
}
|