Bug 1867925 - Mark some storage-access-api tests as intermittent after wpt-sync....
[gecko.git] / accessible / xpcom / nsAccessibleRelation.cpp
blobd376c15e91538cc7a0bae6c6359bef61a63c7858
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 "xpcAccessibleDocument.h"
11 #include "nsArrayUtils.h"
12 #include "nsComponentManagerUtils.h"
14 using namespace mozilla::a11y;
16 nsAccessibleRelation::nsAccessibleRelation(uint32_t aType, Relation* aRel)
17 : mType(aType) {
18 mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
19 Accessible* targetAcc = nullptr;
20 while ((targetAcc = aRel->Next())) {
21 mTargets->AppendElement(static_cast<nsIAccessible*>(ToXPC(targetAcc)));
25 nsAccessibleRelation::~nsAccessibleRelation() {}
27 // nsISupports
28 NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
30 // nsIAccessibleRelation
31 NS_IMETHODIMP
32 nsAccessibleRelation::GetRelationType(uint32_t* aType) {
33 NS_ENSURE_ARG_POINTER(aType);
34 *aType = mType;
35 return NS_OK;
38 NS_IMETHODIMP
39 nsAccessibleRelation::GetTargetsCount(uint32_t* aCount) {
40 NS_ENSURE_ARG_POINTER(aCount);
41 *aCount = 0;
42 return mTargets->GetLength(aCount);
45 NS_IMETHODIMP
46 nsAccessibleRelation::GetTarget(uint32_t aIndex, nsIAccessible** aTarget) {
47 NS_ENSURE_ARG_POINTER(aTarget);
48 nsresult rv = NS_OK;
49 nsCOMPtr<nsIAccessible> target = do_QueryElementAt(mTargets, aIndex, &rv);
50 target.forget(aTarget);
51 return rv;
54 NS_IMETHODIMP
55 nsAccessibleRelation::GetTargets(nsIArray** aTargets) {
56 NS_ENSURE_ARG_POINTER(aTargets);
57 NS_ADDREF(*aTargets = mTargets);
58 return NS_OK;