accessible/src/xpcom/nsAccessibleRelation.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 "Accessible.h"
    11 #include "nsArrayUtils.h"
    12 #include "nsComponentManagerUtils.h"
    14 using namespace mozilla::a11y;
    16 nsAccessibleRelation::nsAccessibleRelation(uint32_t aType,
    17                                            Relation* aRel) :
    18   mType(aType)
    19 {
    20   mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID);
    21   nsIAccessible* targetAcc = nullptr;
    22   while ((targetAcc = aRel->Next()))
    23     mTargets->AppendElement(targetAcc, false);
    24 }
    26 // nsISupports
    27 NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation)
    29 // nsIAccessibleRelation
    30 NS_IMETHODIMP
    31 nsAccessibleRelation::GetRelationType(uint32_t *aType)
    32 {
    33   NS_ENSURE_ARG_POINTER(aType);
    34   *aType = mType;
    35   return NS_OK;
    36 }
    38 NS_IMETHODIMP
    39 nsAccessibleRelation::GetTargetsCount(uint32_t *aCount)
    40 {
    41   NS_ENSURE_ARG_POINTER(aCount);
    42   *aCount = 0;
    43   return mTargets->GetLength(aCount);
    44 }
    46 NS_IMETHODIMP
    47 nsAccessibleRelation::GetTarget(uint32_t aIndex, nsIAccessible **aTarget)
    48 {
    49   NS_ENSURE_ARG_POINTER(aTarget);
    50   nsresult rv = NS_OK;
    51   nsCOMPtr<nsIAccessible> target = do_QueryElementAt(mTargets, aIndex, &rv);
    52   target.forget(aTarget);
    53   return rv;
    54 }
    56 NS_IMETHODIMP
    57 nsAccessibleRelation::GetTargets(nsIArray **aTargets)
    58 {
    59   NS_ENSURE_ARG_POINTER(aTargets);
    60   NS_ADDREF(*aTargets = mTargets);
    61   return NS_OK;
    62 }

mercurial