michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "HTMLElementAccessibles.h" michael@0: michael@0: #include "DocAccessible.h" michael@0: #include "nsAccUtils.h" michael@0: #include "nsIAccessibleRelation.h" michael@0: #include "nsIPersistentProperties2.h" michael@0: #include "nsTextEquivUtils.h" michael@0: #include "Relation.h" michael@0: #include "Role.h" michael@0: #include "States.h" michael@0: michael@0: #include "mozilla/dom/HTMLLabelElement.h" michael@0: michael@0: using namespace mozilla::a11y; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLHRAccessible michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: role michael@0: HTMLHRAccessible::NativeRole() michael@0: { michael@0: return roles::SEPARATOR; michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLBRAccessible michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: role michael@0: HTMLBRAccessible::NativeRole() michael@0: { michael@0: return roles::WHITESPACE; michael@0: } michael@0: michael@0: uint64_t michael@0: HTMLBRAccessible::NativeState() michael@0: { michael@0: return states::READONLY; michael@0: } michael@0: michael@0: ENameValueFlag michael@0: HTMLBRAccessible::NativeName(nsString& aName) michael@0: { michael@0: aName = static_cast('\n'); // Newline char michael@0: return eNameOK; michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLLabelAccessible michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: NS_IMPL_ISUPPORTS_INHERITED0(HTMLLabelAccessible, HyperTextAccessible) michael@0: michael@0: ENameValueFlag michael@0: HTMLLabelAccessible::NativeName(nsString& aName) michael@0: { michael@0: nsTextEquivUtils::GetNameFromSubtree(this, aName); michael@0: return aName.IsEmpty() ? eNameOK : eNameFromSubtree; michael@0: } michael@0: michael@0: Relation michael@0: HTMLLabelAccessible::RelationByType(RelationType aType) michael@0: { michael@0: Relation rel = AccessibleWrap::RelationByType(aType); michael@0: if (aType == RelationType::LABEL_FOR) { michael@0: nsRefPtr label = dom::HTMLLabelElement::FromContent(mContent); michael@0: rel.AppendTarget(mDoc, label->GetControl()); michael@0: } michael@0: michael@0: return rel; michael@0: } michael@0: michael@0: role michael@0: HTMLLabelAccessible::NativeRole() michael@0: { michael@0: return roles::LABEL; michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // nsHTMLOuputAccessible michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: NS_IMPL_ISUPPORTS_INHERITED0(HTMLOutputAccessible, HyperTextAccessible) michael@0: michael@0: Relation michael@0: HTMLOutputAccessible::RelationByType(RelationType aType) michael@0: { michael@0: Relation rel = AccessibleWrap::RelationByType(aType); michael@0: if (aType == RelationType::CONTROLLED_BY) michael@0: rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for)); michael@0: michael@0: return rel; michael@0: } michael@0: michael@0: role michael@0: HTMLOutputAccessible::NativeRole() michael@0: { michael@0: return roles::SECTION; michael@0: } michael@0: michael@0: already_AddRefed michael@0: HTMLOutputAccessible::NativeAttributes() michael@0: { michael@0: nsCOMPtr attributes = michael@0: AccessibleWrap::NativeAttributes(); michael@0: nsAccUtils::SetAccAttr(attributes, nsGkAtoms::live, michael@0: NS_LITERAL_STRING("polite")); michael@0: michael@0: return attributes.forget(); michael@0: } michael@0: