no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / accessible / html / HTMLListAccessible.cpp
blobd7a2fc23aec15ecf7a9453cf6e7d42626bee47ad
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "HTMLListAccessible.h"
9 #include "AccAttributes.h"
10 #include "nsAccessibilityService.h"
11 #include "mozilla/a11y/Role.h"
12 #include "States.h"
14 #include "nsLayoutUtils.h"
16 using namespace mozilla;
17 using namespace mozilla::a11y;
19 ////////////////////////////////////////////////////////////////////////////////
20 // HTMLListAccessible
21 ////////////////////////////////////////////////////////////////////////////////
23 role HTMLListAccessible::NativeRole() const {
24 a11y::role r = GetAccService()->MarkupRole(mContent);
25 return r != roles::NOTHING ? r : roles::LIST;
28 uint64_t HTMLListAccessible::NativeState() const {
29 return HyperTextAccessible::NativeState() | states::READONLY;
32 ////////////////////////////////////////////////////////////////////////////////
33 // HTMLLIAccessible
34 ////////////////////////////////////////////////////////////////////////////////
36 HTMLLIAccessible::HTMLLIAccessible(nsIContent* aContent, DocAccessible* aDoc)
37 : HyperTextAccessible(aContent, aDoc) {
38 mType = eHTMLLiType;
41 role HTMLLIAccessible::NativeRole() const {
42 a11y::role r = GetAccService()->MarkupRole(mContent);
43 return r != roles::NOTHING ? r : roles::LISTITEM;
46 uint64_t HTMLLIAccessible::NativeState() const {
47 return HyperTextAccessible::NativeState() | states::READONLY;
50 nsRect HTMLLIAccessible::BoundsInAppUnits() const {
51 nsRect rect = AccessibleWrap::BoundsInAppUnits();
53 LocalAccessible* bullet = Bullet();
54 nsIFrame* frame = GetFrame();
55 MOZ_ASSERT(!(bullet && !frame), "Cannot have a bullet if there is no frame");
57 if (bullet && frame &&
58 frame->StyleList()->mListStylePosition !=
59 StyleListStylePosition::Inside) {
60 nsRect bulletRect = bullet->BoundsInAppUnits();
61 return rect.Union(bulletRect);
64 return rect;
67 LocalAccessible* HTMLLIAccessible::Bullet() const {
68 LocalAccessible* firstChild = LocalFirstChild();
69 if (firstChild && firstChild->NativeRole() == roles::LISTITEM_MARKER) {
70 return firstChild;
73 return nullptr;
76 ////////////////////////////////////////////////////////////////////////////////
77 // HTMLListBulletAccessible
78 ////////////////////////////////////////////////////////////////////////////////
79 HTMLListBulletAccessible::HTMLListBulletAccessible(nsIContent* aContent,
80 DocAccessible* aDoc)
81 : LeafAccessible(aContent, aDoc) {
82 mGenericTypes |= eText;
85 ////////////////////////////////////////////////////////////////////////////////
86 // HTMLListBulletAccessible: LocalAccessible
88 ENameValueFlag HTMLListBulletAccessible::Name(nsString& aName) const {
89 nsLayoutUtils::GetMarkerSpokenText(mContent, aName);
90 return eNameOK;
93 role HTMLListBulletAccessible::NativeRole() const {
94 return roles::LISTITEM_MARKER;
97 uint64_t HTMLListBulletAccessible::NativeState() const {
98 return LeafAccessible::NativeState() | states::READONLY;
101 already_AddRefed<AccAttributes> HTMLListBulletAccessible::NativeAttributes() {
102 RefPtr<AccAttributes> attributes = new AccAttributes();
103 return attributes.forget();
106 void HTMLListBulletAccessible::AppendTextTo(nsAString& aText,
107 uint32_t aStartOffset,
108 uint32_t aLength) {
109 nsAutoString bulletText;
110 Name(bulletText);
111 aText.Append(Substring(bulletText, aStartOffset, aLength));