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"
|
2019-04-13 15:13:15 +03:00
|
|
|
#include "mozilla/PresShell.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 Accessible::Role() const {
|
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;
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
inline bool Accessible::IsARIARole(nsAtom* 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 Accessible::ARIARole() {
|
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) &&
|
2017-12-07 21:13:50 +03:00
|
|
|
mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::search, eCaseMatters));
|
2015-03-01 01:25:06 +03:00
|
|
|
}
|
|
|
|
|
2012-12-21 07:16:44 +04:00
|
|
|
inline bool Accessible::HasGenericType(AccGenericType aType) const {
|
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
|
|
|
}
|
|
|
|
|
2019-08-29 09:39:28 +03:00
|
|
|
inline bool Accessible::NativeHasNumericValue() const {
|
|
|
|
return mStateFlags & eHasNumericValue;
|
|
|
|
}
|
2012-10-04 18:34:56 +04:00
|
|
|
|
2019-08-29 09:39:28 +03:00
|
|
|
inline bool Accessible::ARIAHasNumericValue() const {
|
2016-07-12 22:34:13 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
2017-06-28 14:11:00 +03:00
|
|
|
if (!roleMapEntry || roleMapEntry->valueRule == eNoValue) return false;
|
|
|
|
|
|
|
|
if (roleMapEntry->valueRule == eHasValueMinMaxIfFocusable)
|
|
|
|
return InteractiveState() & states::FOCUSABLE;
|
|
|
|
|
|
|
|
return true;
|
2012-10-04 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
2019-08-29 09:39:28 +03:00
|
|
|
inline bool Accessible::HasNumericValue() const {
|
|
|
|
return NativeHasNumericValue() || ARIAHasNumericValue();
|
|
|
|
}
|
|
|
|
|
2018-02-28 00:34:12 +03:00
|
|
|
inline bool Accessible::IsDefunct() const {
|
|
|
|
MOZ_ASSERT(mStateFlags & eIsDefunct || IsApplication() || IsDoc() ||
|
|
|
|
mStateFlags & eSharedNode || mContent,
|
|
|
|
"No content");
|
|
|
|
return mStateFlags & eIsDefunct;
|
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
inline void Accessible::ScrollTo(uint32_t aHow) const {
|
2019-04-13 15:13:13 +03:00
|
|
|
if (mContent) {
|
2019-04-13 15:13:15 +03:00
|
|
|
RefPtr<PresShell> presShell = mDoc->PresShellPtr();
|
2019-04-13 15:13:13 +03:00
|
|
|
nsCOMPtr<nsIContent> content = mContent;
|
|
|
|
nsCoreUtils::ScrollTo(presShell, content, aHow);
|
|
|
|
}
|
2014-09-16 21:30:23 +04:00
|
|
|
}
|
|
|
|
|
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
|