accessible/src/html/HTMLElementAccessibles.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial