|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "HTMLElementAccessibles.h" |
|
7 |
|
8 #include "DocAccessible.h" |
|
9 #include "nsAccUtils.h" |
|
10 #include "nsIAccessibleRelation.h" |
|
11 #include "nsIPersistentProperties2.h" |
|
12 #include "nsTextEquivUtils.h" |
|
13 #include "Relation.h" |
|
14 #include "Role.h" |
|
15 #include "States.h" |
|
16 |
|
17 #include "mozilla/dom/HTMLLabelElement.h" |
|
18 |
|
19 using namespace mozilla::a11y; |
|
20 |
|
21 //////////////////////////////////////////////////////////////////////////////// |
|
22 // HTMLHRAccessible |
|
23 //////////////////////////////////////////////////////////////////////////////// |
|
24 |
|
25 role |
|
26 HTMLHRAccessible::NativeRole() |
|
27 { |
|
28 return roles::SEPARATOR; |
|
29 } |
|
30 |
|
31 //////////////////////////////////////////////////////////////////////////////// |
|
32 // HTMLBRAccessible |
|
33 //////////////////////////////////////////////////////////////////////////////// |
|
34 |
|
35 role |
|
36 HTMLBRAccessible::NativeRole() |
|
37 { |
|
38 return roles::WHITESPACE; |
|
39 } |
|
40 |
|
41 uint64_t |
|
42 HTMLBRAccessible::NativeState() |
|
43 { |
|
44 return states::READONLY; |
|
45 } |
|
46 |
|
47 ENameValueFlag |
|
48 HTMLBRAccessible::NativeName(nsString& aName) |
|
49 { |
|
50 aName = static_cast<char16_t>('\n'); // Newline char |
|
51 return eNameOK; |
|
52 } |
|
53 |
|
54 //////////////////////////////////////////////////////////////////////////////// |
|
55 // HTMLLabelAccessible |
|
56 //////////////////////////////////////////////////////////////////////////////// |
|
57 |
|
58 NS_IMPL_ISUPPORTS_INHERITED0(HTMLLabelAccessible, HyperTextAccessible) |
|
59 |
|
60 ENameValueFlag |
|
61 HTMLLabelAccessible::NativeName(nsString& aName) |
|
62 { |
|
63 nsTextEquivUtils::GetNameFromSubtree(this, aName); |
|
64 return aName.IsEmpty() ? eNameOK : eNameFromSubtree; |
|
65 } |
|
66 |
|
67 Relation |
|
68 HTMLLabelAccessible::RelationByType(RelationType aType) |
|
69 { |
|
70 Relation rel = AccessibleWrap::RelationByType(aType); |
|
71 if (aType == RelationType::LABEL_FOR) { |
|
72 nsRefPtr<dom::HTMLLabelElement> label = dom::HTMLLabelElement::FromContent(mContent); |
|
73 rel.AppendTarget(mDoc, label->GetControl()); |
|
74 } |
|
75 |
|
76 return rel; |
|
77 } |
|
78 |
|
79 role |
|
80 HTMLLabelAccessible::NativeRole() |
|
81 { |
|
82 return roles::LABEL; |
|
83 } |
|
84 |
|
85 //////////////////////////////////////////////////////////////////////////////// |
|
86 // nsHTMLOuputAccessible |
|
87 //////////////////////////////////////////////////////////////////////////////// |
|
88 |
|
89 NS_IMPL_ISUPPORTS_INHERITED0(HTMLOutputAccessible, HyperTextAccessible) |
|
90 |
|
91 Relation |
|
92 HTMLOutputAccessible::RelationByType(RelationType aType) |
|
93 { |
|
94 Relation rel = AccessibleWrap::RelationByType(aType); |
|
95 if (aType == RelationType::CONTROLLED_BY) |
|
96 rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for)); |
|
97 |
|
98 return rel; |
|
99 } |
|
100 |
|
101 role |
|
102 HTMLOutputAccessible::NativeRole() |
|
103 { |
|
104 return roles::SECTION; |
|
105 } |
|
106 |
|
107 already_AddRefed<nsIPersistentProperties> |
|
108 HTMLOutputAccessible::NativeAttributes() |
|
109 { |
|
110 nsCOMPtr<nsIPersistentProperties> attributes = |
|
111 AccessibleWrap::NativeAttributes(); |
|
112 nsAccUtils::SetAccAttr(attributes, nsGkAtoms::live, |
|
113 NS_LITERAL_STRING("polite")); |
|
114 |
|
115 return attributes.forget(); |
|
116 } |
|
117 |