diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /accessible/html/HTMLListAccessible.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | accessible/html/HTMLListAccessible.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/accessible/html/HTMLListAccessible.cpp b/accessible/html/HTMLListAccessible.cpp new file mode 100644 index 0000000000..39fc6149b9 --- /dev/null +++ b/accessible/html/HTMLListAccessible.cpp @@ -0,0 +1,115 @@ +/* -*- 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/. */ + +#include "HTMLListAccessible.h" + +#include "AccAttributes.h" +#include "DocAccessible.h" +#include "EventTree.h" +#include "nsAccUtils.h" +#include "nsPersistentProperties.h" +#include "Role.h" +#include "States.h" + +#include "nsLayoutUtils.h" + +using namespace mozilla; +using namespace mozilla::a11y; + +//////////////////////////////////////////////////////////////////////////////// +// HTMLListAccessible +//////////////////////////////////////////////////////////////////////////////// + +role HTMLListAccessible::NativeRole() const { + a11y::role r = GetAccService()->MarkupRole(mContent); + return r != roles::NOTHING ? r : roles::LIST; +} + +uint64_t HTMLListAccessible::NativeState() const { + return HyperTextAccessibleWrap::NativeState() | states::READONLY; +} + +//////////////////////////////////////////////////////////////////////////////// +// HTMLLIAccessible +//////////////////////////////////////////////////////////////////////////////// + +HTMLLIAccessible::HTMLLIAccessible(nsIContent* aContent, DocAccessible* aDoc) + : HyperTextAccessibleWrap(aContent, aDoc) { + mType = eHTMLLiType; +} + +role HTMLLIAccessible::NativeRole() const { + a11y::role r = GetAccService()->MarkupRole(mContent); + return r != roles::NOTHING ? r : roles::LISTITEM; +} + +uint64_t HTMLLIAccessible::NativeState() const { + return HyperTextAccessibleWrap::NativeState() | states::READONLY; +} + +nsRect HTMLLIAccessible::BoundsInAppUnits() const { + nsRect rect = AccessibleWrap::BoundsInAppUnits(); + + LocalAccessible* bullet = Bullet(); + nsIFrame* frame = GetFrame(); + MOZ_ASSERT(!(bullet && !frame), "Cannot have a bullet if there is no frame"); + + if (bullet && frame && + frame->StyleList()->mListStylePosition != + StyleListStylePosition::Inside) { + nsRect bulletRect = bullet->BoundsInAppUnits(); + return rect.Union(bulletRect); + } + + return rect; +} + +LocalAccessible* HTMLLIAccessible::Bullet() const { + LocalAccessible* firstChild = LocalFirstChild(); + if (firstChild && firstChild->NativeRole() == roles::LISTITEM_MARKER) { + return firstChild; + } + + return nullptr; +} + +//////////////////////////////////////////////////////////////////////////////// +// HTMLListBulletAccessible +//////////////////////////////////////////////////////////////////////////////// +HTMLListBulletAccessible::HTMLListBulletAccessible(nsIContent* aContent, + DocAccessible* aDoc) + : LeafAccessible(aContent, aDoc) { + mGenericTypes |= eText; +} + +//////////////////////////////////////////////////////////////////////////////// +// HTMLListBulletAccessible: LocalAccessible + +ENameValueFlag HTMLListBulletAccessible::Name(nsString& aName) const { + nsLayoutUtils::GetMarkerSpokenText(mContent, aName); + return eNameOK; +} + +role HTMLListBulletAccessible::NativeRole() const { + return roles::LISTITEM_MARKER; +} + +uint64_t HTMLListBulletAccessible::NativeState() const { + return LeafAccessible::NativeState() | states::READONLY; +} + +already_AddRefed<AccAttributes> HTMLListBulletAccessible::NativeAttributes() { + RefPtr<AccAttributes> attributes = new AccAttributes(); + return attributes.forget(); +} + +void HTMLListBulletAccessible::AppendTextTo(nsAString& aText, + uint32_t aStartOffset, + uint32_t aLength) { + nsAutoString bulletText; + Name(bulletText); + aText.Append(Substring(bulletText, aStartOffset, aLength)); +} |