accessible/src/html/HTMLElementAccessibles.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 #include "HTMLElementAccessibles.h"
     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"
    17 #include "mozilla/dom/HTMLLabelElement.h"
    19 using namespace mozilla::a11y;
    21 ////////////////////////////////////////////////////////////////////////////////
    22 // HTMLHRAccessible
    23 ////////////////////////////////////////////////////////////////////////////////
    25 role
    26 HTMLHRAccessible::NativeRole()
    27 {
    28   return roles::SEPARATOR;
    29 }
    31 ////////////////////////////////////////////////////////////////////////////////
    32 // HTMLBRAccessible
    33 ////////////////////////////////////////////////////////////////////////////////
    35 role
    36 HTMLBRAccessible::NativeRole()
    37 {
    38   return roles::WHITESPACE;
    39 }
    41 uint64_t
    42 HTMLBRAccessible::NativeState()
    43 {
    44   return states::READONLY;
    45 }
    47 ENameValueFlag
    48 HTMLBRAccessible::NativeName(nsString& aName)
    49 {
    50   aName = static_cast<char16_t>('\n');    // Newline char
    51   return eNameOK;
    52 }
    54 ////////////////////////////////////////////////////////////////////////////////
    55 // HTMLLabelAccessible
    56 ////////////////////////////////////////////////////////////////////////////////
    58 NS_IMPL_ISUPPORTS_INHERITED0(HTMLLabelAccessible, HyperTextAccessible)
    60 ENameValueFlag
    61 HTMLLabelAccessible::NativeName(nsString& aName)
    62 {
    63   nsTextEquivUtils::GetNameFromSubtree(this, aName);
    64   return aName.IsEmpty() ? eNameOK : eNameFromSubtree;
    65 }
    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   }
    76   return rel;
    77 }
    79 role
    80 HTMLLabelAccessible::NativeRole()
    81 {
    82   return roles::LABEL;
    83 }
    85 ////////////////////////////////////////////////////////////////////////////////
    86 // nsHTMLOuputAccessible
    87 ////////////////////////////////////////////////////////////////////////////////
    89 NS_IMPL_ISUPPORTS_INHERITED0(HTMLOutputAccessible, HyperTextAccessible)
    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));
    98   return rel;
    99 }
   101 role
   102 HTMLOutputAccessible::NativeRole()
   103 {
   104   return roles::SECTION;
   105 }
   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"));
   115   return attributes.forget();
   116 }

mercurial