2007-05-20 02:41:33 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-05-20 02:41:33 +00:00
|
|
|
|
|
|
|
#include "nsAccessibleRelation.h"
|
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
#include "Relation.h"
|
2012-05-29 01:18:45 +00:00
|
|
|
#include "Accessible.h"
|
2014-10-22 00:49:28 +00:00
|
|
|
#include "xpcAccessibleDocument.h"
|
2011-08-10 01:44:00 +00:00
|
|
|
|
2009-02-10 10:03:30 +00:00
|
|
|
#include "nsArrayUtils.h"
|
2007-05-20 02:41:33 +00:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
|
2012-06-10 22:18:31 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
|
2011-08-10 01:44:00 +00:00
|
|
|
Relation* aRel) :
|
2009-02-10 10:03:30 +00:00
|
|
|
mType(aType)
|
2007-05-20 02:41:33 +00:00
|
|
|
{
|
2009-02-10 10:03:30 +00:00
|
|
|
mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
2014-10-22 00:49:28 +00:00
|
|
|
Accessible* targetAcc = nullptr;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((targetAcc = aRel->Next()))
|
2014-10-22 00:49:28 +00:00
|
|
|
mTargets->AppendElement(static_cast<nsIAccessible*>(ToXPC(targetAcc)), false);
|
2007-05-20 02:41:33 +00:00
|
|
|
}
|
|
|
|
|
2016-05-27 16:49:38 +00:00
|
|
|
nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
|
|
|
|
const nsTArray<ProxyAccessible*>* aTargets) :
|
|
|
|
mType(aType)
|
|
|
|
{
|
|
|
|
mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
|
|
|
for (uint32_t idx = 0; idx < aTargets->Length(); ++idx) {
|
|
|
|
mTargets->AppendElement(
|
|
|
|
static_cast<nsIAccessible*>(ToXPC(aTargets->ElementAt(idx))),
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-23 19:56:09 +00:00
|
|
|
nsAccessibleRelation::~nsAccessibleRelation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-20 02:41:33 +00:00
|
|
|
// nsISupports
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
|
2007-05-20 02:41:33 +00:00
|
|
|
|
|
|
|
// nsIAccessibleRelation
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAccessibleRelation::GetRelationType(uint32_t *aType)
|
2007-05-20 02:41:33 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
|
|
|
*aType = mType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAccessibleRelation::GetTargetsCount(uint32_t *aCount)
|
2007-05-20 02:41:33 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCount);
|
2009-02-10 10:03:30 +00:00
|
|
|
*aCount = 0;
|
|
|
|
return mTargets->GetLength(aCount);
|
2007-05-20 02:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsAccessibleRelation::GetTarget(uint32_t aIndex, nsIAccessible **aTarget)
|
2007-05-20 02:41:33 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTarget);
|
2009-02-10 10:03:30 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIAccessible> target = do_QueryElementAt(mTargets, aIndex, &rv);
|
2011-08-10 01:44:00 +00:00
|
|
|
target.forget(aTarget);
|
|
|
|
return rv;
|
2007-05-20 02:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-02-10 10:03:30 +00:00
|
|
|
nsAccessibleRelation::GetTargets(nsIArray **aTargets)
|
2007-05-20 02:41:33 +00:00
|
|
|
{
|
2009-02-10 10:03:30 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aTargets);
|
|
|
|
NS_ADDREF(*aTargets = mTargets);
|
2007-05-20 02:41:33 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|