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"
|
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"
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
nsAccessibleRelation::nsAccessibleRelation(PRUint32 aType,
|
|
|
|
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);
|
2011-08-09 18:44:00 -07:00
|
|
|
nsIAccessible* targetAcc = nsnull;
|
|
|
|
while ((targetAcc = aRel->Next()))
|
|
|
|
mTargets->AppendElement(targetAcc, false);
|
2007-05-19 19:41:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// nsISupports
|
2011-08-09 18:44:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS1(nsAccessibleRelation, nsIAccessibleRelation)
|
2007-05-19 19:41:33 -07:00
|
|
|
|
|
|
|
// nsIAccessibleRelation
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibleRelation::GetRelationType(PRUint32 *aType)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aType);
|
|
|
|
*aType = mType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibleRelation::GetTargetsCount(PRUint32 *aCount)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
nsAccessibleRelation::GetTarget(PRUint32 aIndex, nsIAccessible **aTarget)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|