1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/html/HTMLElementAccessibles.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "HTMLElementAccessibles.h" 1.10 + 1.11 +#include "DocAccessible.h" 1.12 +#include "nsAccUtils.h" 1.13 +#include "nsIAccessibleRelation.h" 1.14 +#include "nsIPersistentProperties2.h" 1.15 +#include "nsTextEquivUtils.h" 1.16 +#include "Relation.h" 1.17 +#include "Role.h" 1.18 +#include "States.h" 1.19 + 1.20 +#include "mozilla/dom/HTMLLabelElement.h" 1.21 + 1.22 +using namespace mozilla::a11y; 1.23 + 1.24 +//////////////////////////////////////////////////////////////////////////////// 1.25 +// HTMLHRAccessible 1.26 +//////////////////////////////////////////////////////////////////////////////// 1.27 + 1.28 +role 1.29 +HTMLHRAccessible::NativeRole() 1.30 +{ 1.31 + return roles::SEPARATOR; 1.32 +} 1.33 + 1.34 +//////////////////////////////////////////////////////////////////////////////// 1.35 +// HTMLBRAccessible 1.36 +//////////////////////////////////////////////////////////////////////////////// 1.37 + 1.38 +role 1.39 +HTMLBRAccessible::NativeRole() 1.40 +{ 1.41 + return roles::WHITESPACE; 1.42 +} 1.43 + 1.44 +uint64_t 1.45 +HTMLBRAccessible::NativeState() 1.46 +{ 1.47 + return states::READONLY; 1.48 +} 1.49 + 1.50 +ENameValueFlag 1.51 +HTMLBRAccessible::NativeName(nsString& aName) 1.52 +{ 1.53 + aName = static_cast<char16_t>('\n'); // Newline char 1.54 + return eNameOK; 1.55 +} 1.56 + 1.57 +//////////////////////////////////////////////////////////////////////////////// 1.58 +// HTMLLabelAccessible 1.59 +//////////////////////////////////////////////////////////////////////////////// 1.60 + 1.61 +NS_IMPL_ISUPPORTS_INHERITED0(HTMLLabelAccessible, HyperTextAccessible) 1.62 + 1.63 +ENameValueFlag 1.64 +HTMLLabelAccessible::NativeName(nsString& aName) 1.65 +{ 1.66 + nsTextEquivUtils::GetNameFromSubtree(this, aName); 1.67 + return aName.IsEmpty() ? eNameOK : eNameFromSubtree; 1.68 +} 1.69 + 1.70 +Relation 1.71 +HTMLLabelAccessible::RelationByType(RelationType aType) 1.72 +{ 1.73 + Relation rel = AccessibleWrap::RelationByType(aType); 1.74 + if (aType == RelationType::LABEL_FOR) { 1.75 + nsRefPtr<dom::HTMLLabelElement> label = dom::HTMLLabelElement::FromContent(mContent); 1.76 + rel.AppendTarget(mDoc, label->GetControl()); 1.77 + } 1.78 + 1.79 + return rel; 1.80 +} 1.81 + 1.82 +role 1.83 +HTMLLabelAccessible::NativeRole() 1.84 +{ 1.85 + return roles::LABEL; 1.86 +} 1.87 + 1.88 +//////////////////////////////////////////////////////////////////////////////// 1.89 +// nsHTMLOuputAccessible 1.90 +//////////////////////////////////////////////////////////////////////////////// 1.91 + 1.92 +NS_IMPL_ISUPPORTS_INHERITED0(HTMLOutputAccessible, HyperTextAccessible) 1.93 + 1.94 +Relation 1.95 +HTMLOutputAccessible::RelationByType(RelationType aType) 1.96 +{ 1.97 + Relation rel = AccessibleWrap::RelationByType(aType); 1.98 + if (aType == RelationType::CONTROLLED_BY) 1.99 + rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for)); 1.100 + 1.101 + return rel; 1.102 +} 1.103 + 1.104 +role 1.105 +HTMLOutputAccessible::NativeRole() 1.106 +{ 1.107 + return roles::SECTION; 1.108 +} 1.109 + 1.110 +already_AddRefed<nsIPersistentProperties> 1.111 +HTMLOutputAccessible::NativeAttributes() 1.112 +{ 1.113 + nsCOMPtr<nsIPersistentProperties> attributes = 1.114 + AccessibleWrap::NativeAttributes(); 1.115 + nsAccUtils::SetAccAttr(attributes, nsGkAtoms::live, 1.116 + NS_LITERAL_STRING("polite")); 1.117 + 1.118 + return attributes.forget(); 1.119 +} 1.120 +