Tue, 06 Jan 2015 21:39:09 +0100
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.
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 "nsAccessibleRelation.h"
8 #include "Relation.h"
9 #include "Accessible.h"
11 #include "nsArrayUtils.h"
12 #include "nsComponentManagerUtils.h"
14 using namespace mozilla::a11y;
16 nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
17 Relation* aRel) :
18 mType(aType)
19 {
20 mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
21 nsIAccessible* targetAcc = nullptr;
22 while ((targetAcc = aRel->Next()))
23 mTargets->AppendElement(targetAcc, false);
24 }
26 // nsISupports
27 NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
29 // nsIAccessibleRelation
30 NS_IMETHODIMP
31 nsAccessibleRelation::GetRelationType(uint32_t *aType)
32 {
33 NS_ENSURE_ARG_POINTER(aType);
34 *aType = mType;
35 return NS_OK;
36 }
38 NS_IMETHODIMP
39 nsAccessibleRelation::GetTargetsCount(uint32_t *aCount)
40 {
41 NS_ENSURE_ARG_POINTER(aCount);
42 *aCount = 0;
43 return mTargets->GetLength(aCount);
44 }
46 NS_IMETHODIMP
47 nsAccessibleRelation::GetTarget(uint32_t aIndex, nsIAccessible **aTarget)
48 {
49 NS_ENSURE_ARG_POINTER(aTarget);
50 nsresult rv = NS_OK;
51 nsCOMPtr<nsIAccessible> target = do_QueryElementAt(mTargets, aIndex, &rv);
52 target.forget(aTarget);
53 return rv;
54 }
56 NS_IMETHODIMP
57 nsAccessibleRelation::GetTargets(nsIArray **aTargets)
58 {
59 NS_ENSURE_ARG_POINTER(aTargets);
60 NS_ADDREF(*aTargets = mTargets);
61 return NS_OK;
62 }