2012-04-13 18:17:03 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_a11y_Accessible_inl_h_
|
|
|
|
#define mozilla_a11y_Accessible_inl_h_
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
#include "DocAccessible.h"
|
2013-04-25 07:48:26 +04:00
|
|
|
#include "ARIAMap.h"
|
2014-09-16 21:30:23 +04:00
|
|
|
#include "nsCoreUtils.h"
|
2012-04-13 18:17:03 +04:00
|
|
|
|
2016-07-13 06:15:22 +03:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
#include "Logging.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-18 06:01:44 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
inline mozilla::a11y::role
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible::Role()
|
2012-04-13 18:17:03 +04:00
|
|
|
{
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
|
|
|
if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole)
|
2012-04-13 18:17:03 +04:00
|
|
|
return ARIATransformRole(NativeRole());
|
|
|
|
|
2016-07-12 22:34:13 +03:00
|
|
|
return ARIATransformRole(roleMapEntry->role);
|
2012-04-13 18:17:03 +04:00
|
|
|
}
|
|
|
|
|
2016-07-18 19:40:53 +03:00
|
|
|
inline bool
|
|
|
|
Accessible::HasARIARole() const
|
|
|
|
{
|
|
|
|
return mRoleMapEntryIndex != aria::NO_ROLE_MAP_ENTRY_INDEX;
|
|
|
|
}
|
|
|
|
|
2013-11-13 17:58:12 +04:00
|
|
|
inline bool
|
|
|
|
Accessible::IsARIARole(nsIAtom* aARIARole) const
|
|
|
|
{
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
|
|
|
return roleMapEntry && roleMapEntry->Is(aARIARole);
|
2013-11-13 17:58:12 +04:00
|
|
|
}
|
|
|
|
|
2014-08-16 00:49:02 +04:00
|
|
|
inline bool
|
|
|
|
Accessible::HasStrongARIARole() const
|
|
|
|
{
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
|
|
|
return roleMapEntry && roleMapEntry->roleRule == kUseMapRole;
|
2014-08-16 00:49:02 +04:00
|
|
|
}
|
|
|
|
|
2016-07-18 19:40:53 +03:00
|
|
|
inline const nsRoleMapEntry*
|
|
|
|
Accessible::ARIARoleMap() const
|
|
|
|
{
|
|
|
|
return aria::GetRoleMapFromIndex(mRoleMapEntryIndex);
|
|
|
|
}
|
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
inline mozilla::a11y::role
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible::ARIARole()
|
2012-04-13 18:17:03 +04:00
|
|
|
{
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
|
|
|
if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole)
|
2012-04-13 18:17:03 +04:00
|
|
|
return mozilla::a11y::roles::NOTHING;
|
|
|
|
|
2016-07-12 22:34:13 +03:00
|
|
|
return ARIATransformRole(roleMapEntry->role);
|
2012-04-13 18:17:03 +04:00
|
|
|
}
|
|
|
|
|
2016-07-18 19:40:53 +03:00
|
|
|
inline void
|
|
|
|
Accessible::SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry)
|
|
|
|
{
|
|
|
|
mRoleMapEntryIndex = aria::GetIndexFromRoleMap(aRoleMapEntry);
|
|
|
|
}
|
|
|
|
|
2015-03-01 01:25:06 +03:00
|
|
|
inline bool
|
|
|
|
Accessible::IsSearchbox() const
|
|
|
|
{
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
|
|
|
return (roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) ||
|
2015-03-03 14:08:59 +03:00
|
|
|
(mContent->IsHTMLElement(nsGkAtoms::input) &&
|
2015-03-01 01:25:06 +03:00
|
|
|
mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::textInputType, eCaseMatters));
|
|
|
|
}
|
|
|
|
|
2012-12-21 07:16:44 +04:00
|
|
|
inline bool
|
|
|
|
Accessible::HasGenericType(AccGenericType aType) const
|
2012-11-11 06:16:17 +04:00
|
|
|
{
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
2012-12-21 07:16:44 +04:00
|
|
|
return (mGenericTypes & aType) ||
|
2016-07-12 22:34:13 +03:00
|
|
|
(roleMapEntry && roleMapEntry->IsOfType(aType));
|
2012-11-11 06:16:17 +04:00
|
|
|
}
|
|
|
|
|
2012-10-04 18:34:56 +04:00
|
|
|
inline bool
|
|
|
|
Accessible::HasNumericValue() const
|
|
|
|
{
|
2012-12-11 07:31:42 +04:00
|
|
|
if (mStateFlags & eHasNumericValue)
|
2012-10-04 18:34:56 +04:00
|
|
|
return true;
|
|
|
|
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
|
|
|
return roleMapEntry && roleMapEntry->valueRule != eNoValue;
|
2012-10-04 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
inline void
|
|
|
|
Accessible::ScrollTo(uint32_t aHow) const
|
|
|
|
{
|
|
|
|
if (mContent)
|
|
|
|
nsCoreUtils::ScrollTo(mDoc->PresShell(), mContent, aHow);
|
|
|
|
}
|
|
|
|
|
2016-07-13 06:15:22 +03:00
|
|
|
inline bool
|
|
|
|
Accessible::InsertAfter(Accessible* aNewChild, Accessible* aRefChild)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aNewChild, "No new child to insert");
|
|
|
|
|
|
|
|
if (aRefChild && aRefChild->Parent() != this) {
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
logging::TreeInfo("broken accessible tree", 0,
|
|
|
|
"parent", this, "prev sibling parent",
|
|
|
|
aRefChild->Parent(), "child", aNewChild, nullptr);
|
|
|
|
if (logging::IsEnabled(logging::eVerbose)) {
|
|
|
|
logging::Tree("TREE", "Document tree", mDoc);
|
|
|
|
logging::DOMTree("TREE", "DOM document tree", mDoc);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Broken accessible tree");
|
|
|
|
mDoc->UnbindFromDocument(aNewChild);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return InsertChildAt(aRefChild ? aRefChild->IndexInParent() + 1 : 0,
|
|
|
|
aNewChild);
|
|
|
|
}
|
|
|
|
|
2012-11-18 06:01:44 +04:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#endif
|