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