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"
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
)
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() {}
28 NS_IMPL_ISUPPORTS(nsAccessibleRelation
, nsIAccessibleRelation
)
30 // nsIAccessibleRelation
32 nsAccessibleRelation::GetRelationType(uint32_t* aType
) {
33 NS_ENSURE_ARG_POINTER(aType
);
39 nsAccessibleRelation::GetTargetsCount(uint32_t* aCount
) {
40 NS_ENSURE_ARG_POINTER(aCount
);
42 return mTargets
->GetLength(aCount
);
46 nsAccessibleRelation::GetTarget(uint32_t aIndex
, nsIAccessible
** aTarget
) {
47 NS_ENSURE_ARG_POINTER(aTarget
);
49 nsCOMPtr
<nsIAccessible
> target
= do_QueryElementAt(mTargets
, aIndex
, &rv
);
50 target
.forget(aTarget
);
55 nsAccessibleRelation::GetTargets(nsIArray
** aTargets
) {
56 NS_ENSURE_ARG_POINTER(aTargets
);
57 NS_ADDREF(*aTargets
= mTargets
);