2007-05-19 19:41:33 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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-19 19:41:33 -07:00
|
|
|
|
|
|
|
#include "nsAccessibleRelation.h"
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "Relation.h"
|
2012-05-28 18:18:45 -07:00
|
|
|
#include "Accessible.h"
|
2014-10-21 17:49:28 -07:00
|
|
|
#include "xpcAccessibleDocument.h"
|
2011-08-09 18:44:00 -07:00
|
|
|
|
2009-02-10 02:03:30 -08:00
|
|
|
#include "nsArrayUtils.h"
|
2007-05-19 19:41:33 -07:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
|
2012-06-10 15:18:31 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation* aRel) :
|
2009-02-10 02:03:30 -08:00
|
|
|
mType(aType)
|
2007-05-19 19:41:33 -07:00
|
|
|
{
|
2009-02-10 02:03:30 -08:00
|
|
|
mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
2014-10-21 17:49:28 -07:00
|
|
|
Accessible* targetAcc = nullptr;
|
2011-08-09 18:44:00 -07:00
|
|
|
while ((targetAcc = aRel->Next()))
|
2014-10-21 17:49:28 -07:00
|
|
|
mTargets->AppendElement(static_cast<nsIAccessible*>(ToXPC(targetAcc)), false);
|
2007-05-19 19:41:33 -07:00
|
|
|
}
|
|
|
|
|
2014-06-23 12:56:09 -07:00
|
|
|
nsAccessibleRelation::~nsAccessibleRelation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-19 19:41:33 -07:00
|
|
|
// nsISupports
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
|
2007-05-19 19:41:33 -07:00
|
|
|
|
|
|
|
// nsIAccessibleRelation
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAccessibleRelation::GetRelationType(uint32_t *aType)
|
2007-05-19 19:41:33 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
|
|
|
*aType = mType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAccessibleRelation::GetTargetsCount(uint32_t *aCount)
|
2007-05-19 19:41:33 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCount);
|
2009-02-10 02:03:30 -08:00
|
|
|
*aCount = 0;
|
|
|
|
return mTargets->GetLength(aCount);
|
2007-05-19 19:41:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAccessibleRelation::GetTarget(uint32_t aIndex, nsIAccessible **aTarget)
|
2007-05-19 19:41:33 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTarget);
|
2009-02-10 02:03:30 -08:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIAccessible> target = do_QueryElementAt(mTargets, aIndex, &rv);
|
2011-08-09 18:44:00 -07:00
|
|
|
target.forget(aTarget);
|
|
|
|
return rv;
|
2007-05-19 19:41:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-02-10 02:03:30 -08:00
|
|
|
nsAccessibleRelation::GetTargets(nsIArray **aTargets)
|
2007-05-19 19:41:33 -07:00
|
|
|
{
|
2009-02-10 02:03:30 -08:00
|
|
|
NS_ENSURE_ARG_POINTER(aTargets);
|
|
|
|
NS_ADDREF(*aTargets = mTargets);
|
2007-05-19 19:41:33 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|