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 "DocAccessible.h"
11 #include "EventTree.h"
12 #include "nsAccUtils.h"
13 #include "nsPersistentProperties.h"
17 #include "nsLayoutUtils.h"
19 using namespace mozilla
;
20 using namespace mozilla::a11y
;
22 ////////////////////////////////////////////////////////////////////////////////
24 ////////////////////////////////////////////////////////////////////////////////
26 role
HTMLListAccessible::NativeRole() const {
27 a11y::role r
= GetAccService()->MarkupRole(mContent
);
28 return r
!= roles::NOTHING
? r
: roles::LIST
;
31 uint64_t HTMLListAccessible::NativeState() const {
32 return HyperTextAccessibleWrap::NativeState() | states::READONLY
;
35 ////////////////////////////////////////////////////////////////////////////////
37 ////////////////////////////////////////////////////////////////////////////////
39 HTMLLIAccessible::HTMLLIAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
40 : HyperTextAccessibleWrap(aContent
, aDoc
) {
44 role
HTMLLIAccessible::NativeRole() const {
45 a11y::role r
= GetAccService()->MarkupRole(mContent
);
46 return r
!= roles::NOTHING
? r
: roles::LISTITEM
;
49 uint64_t HTMLLIAccessible::NativeState() const {
50 return HyperTextAccessibleWrap::NativeState() | states::READONLY
;
53 nsRect
HTMLLIAccessible::BoundsInAppUnits() const {
54 nsRect rect
= AccessibleWrap::BoundsInAppUnits();
56 LocalAccessible
* bullet
= Bullet();
57 nsIFrame
* frame
= GetFrame();
58 MOZ_ASSERT(!(bullet
&& !frame
), "Cannot have a bullet if there is no frame");
60 if (bullet
&& frame
&&
61 frame
->StyleList()->mListStylePosition
!=
62 NS_STYLE_LIST_STYLE_POSITION_INSIDE
) {
63 nsRect bulletRect
= bullet
->BoundsInAppUnits();
64 return rect
.Union(bulletRect
);
70 LocalAccessible
* HTMLLIAccessible::Bullet() const {
71 LocalAccessible
* firstChild
= LocalFirstChild();
72 if (firstChild
&& firstChild
->NativeRole() == roles::LISTITEM_MARKER
) {
79 ////////////////////////////////////////////////////////////////////////////////
80 // HTMLListBulletAccessible
81 ////////////////////////////////////////////////////////////////////////////////
82 HTMLListBulletAccessible::HTMLListBulletAccessible(nsIContent
* aContent
,
84 : LeafAccessible(aContent
, aDoc
) {
85 mGenericTypes
|= eText
;
88 ////////////////////////////////////////////////////////////////////////////////
89 // HTMLListBulletAccessible: LocalAccessible
91 ENameValueFlag
HTMLListBulletAccessible::Name(nsString
& aName
) const {
92 nsLayoutUtils::GetMarkerSpokenText(mContent
, aName
);
96 role
HTMLListBulletAccessible::NativeRole() const {
97 return roles::LISTITEM_MARKER
;
100 uint64_t HTMLListBulletAccessible::NativeState() const {
101 return LeafAccessible::NativeState() | states::READONLY
;
104 already_AddRefed
<AccAttributes
> HTMLListBulletAccessible::NativeAttributes() {
105 RefPtr
<AccAttributes
> attributes
= new AccAttributes();
106 return attributes
.forget();
109 void HTMLListBulletAccessible::AppendTextTo(nsAString
& aText
,
110 uint32_t aStartOffset
,
112 nsAutoString bulletText
;
114 aText
.Append(Substring(bulletText
, aStartOffset
, aLength
));