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
|
|
|
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
|
|
|
{
|
2015-08-04 20:33:54 -07:00
|
|
|
if (Accessible* actionAcc = ActionWalk()) {
|
|
|
|
actionAcc->TakeFocus();
|
|
|
|
} else {
|
2014-09-16 10:30:23 -07:00
|
|
|
AccessibleWrap::TakeFocus();
|
2015-08-04 20:33:54 -07:00
|
|
|
}
|
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
|
|
|
{
|
2015-08-04 20:33:54 -07:00
|
|
|
bool isLink;
|
|
|
|
Accessible* actionAcc =
|
|
|
|
const_cast<LinkableAccessible*>(this)->ActionWalk(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
return states::LINKED | (actionAcc->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);
|
2015-08-04 20:33:54 -07:00
|
|
|
if (!aValue.IsEmpty()) {
|
2012-04-09 02:48:41 -07:00
|
|
|
return;
|
2015-08-04 20:33:54 -07:00
|
|
|
}
|
2008-01-22 17:37:23 -08:00
|
|
|
|
2015-08-04 20:33:54 -07:00
|
|
|
bool isLink;
|
|
|
|
Accessible* actionAcc = ActionWalk(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
actionAcc->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
|
|
|
{
|
2015-08-04 20:33:54 -07:00
|
|
|
bool isLink, isOnclick;
|
|
|
|
ActionWalk(&isLink, &isOnclick);
|
|
|
|
return (isLink || isOnclick) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Accessible*
|
|
|
|
LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick)
|
|
|
|
{
|
|
|
|
if (aIsOnclick) {
|
|
|
|
*aIsOnclick = false;
|
|
|
|
}
|
|
|
|
if (aIsLink) {
|
|
|
|
*aIsLink = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
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) {
|
2015-08-04 20:33:54 -07:00
|
|
|
bool isOnclick, isLink;
|
|
|
|
ActionWalk(&isLink, &isOnclick);
|
|
|
|
if (isLink) {
|
2007-03-22 10:30:00 -07:00
|
|
|
aName.AssignLiteral("jump");
|
2015-08-04 20:33:54 -07:00
|
|
|
} else if (isOnclick) {
|
2007-03-22 10:30:00 -07:00
|
|
|
aName.AssignLiteral("click");
|
2015-08-04 20:33:54 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-08-04 20:33:54 -07:00
|
|
|
if (aIndex != eAction_Jump) {
|
2014-09-16 10:30:23 -07:00
|
|
|
return false;
|
2015-08-04 20:33:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Accessible* actionAcc = ActionWalk()) {
|
|
|
|
return actionAcc->DoAction(aIndex);
|
|
|
|
}
|
2010-05-25 01:05:52 -07:00
|
|
|
|
2015-08-04 20:33:54 -07:00
|
|
|
return 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
|
|
|
{
|
2015-08-04 20:33:54 -07:00
|
|
|
if (const Accessible* actionAcc =
|
|
|
|
const_cast<LinkableAccessible*>(this)->ActionWalk()) {
|
|
|
|
return actionAcc->AccessKey();
|
|
|
|
}
|
2008-03-18 04:37:12 -07:00
|
|
|
|
2015-08-04 20:33:54 -07:00
|
|
|
return Accessible::AccessKey();
|
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
|
|
|
{
|
2015-08-04 20:33:54 -07:00
|
|
|
bool isLink;
|
|
|
|
Accessible* actionAcc = ActionWalk(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
NS_ASSERTION(actionAcc->IsLink(), "HyperLink isn't implemented.");
|
2010-08-31 20:26:13 -07:00
|
|
|
|
2015-08-04 20:33:54 -07:00
|
|
|
if (actionAcc->IsLink()) {
|
|
|
|
return actionAcc->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
|
|
|
}
|
|
|
|
|
2012-03-23 05:21:31 -07: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
|
|
|
|
{
|
|
|
|
}
|