Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsAccessibleRelation.h" |
michael@0 | 7 | |
michael@0 | 8 | #include "Relation.h" |
michael@0 | 9 | #include "Accessible.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "nsArrayUtils.h" |
michael@0 | 12 | #include "nsComponentManagerUtils.h" |
michael@0 | 13 | |
michael@0 | 14 | using namespace mozilla::a11y; |
michael@0 | 15 | |
michael@0 | 16 | nsAccessibleRelation::nsAccessibleRelation(uint32_t aType, |
michael@0 | 17 | Relation* aRel) : |
michael@0 | 18 | mType(aType) |
michael@0 | 19 | { |
michael@0 | 20 | mTargets = do_CreateInstance(NS_ARRAY_CONTRACTID); |
michael@0 | 21 | nsIAccessible* targetAcc = nullptr; |
michael@0 | 22 | while ((targetAcc = aRel->Next())) |
michael@0 | 23 | mTargets->AppendElement(targetAcc, false); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | // nsISupports |
michael@0 | 27 | NS_IMPL_ISUPPORTS(nsAccessibleRelation, nsIAccessibleRelation) |
michael@0 | 28 | |
michael@0 | 29 | // nsIAccessibleRelation |
michael@0 | 30 | NS_IMETHODIMP |
michael@0 | 31 | nsAccessibleRelation::GetRelationType(uint32_t *aType) |
michael@0 | 32 | { |
michael@0 | 33 | NS_ENSURE_ARG_POINTER(aType); |
michael@0 | 34 | *aType = mType; |
michael@0 | 35 | return NS_OK; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | NS_IMETHODIMP |
michael@0 | 39 | nsAccessibleRelation::GetTargetsCount(uint32_t *aCount) |
michael@0 | 40 | { |
michael@0 | 41 | NS_ENSURE_ARG_POINTER(aCount); |
michael@0 | 42 | *aCount = 0; |
michael@0 | 43 | return mTargets->GetLength(aCount); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | NS_IMETHODIMP |
michael@0 | 47 | nsAccessibleRelation::GetTarget(uint32_t aIndex, nsIAccessible **aTarget) |
michael@0 | 48 | { |
michael@0 | 49 | NS_ENSURE_ARG_POINTER(aTarget); |
michael@0 | 50 | nsresult rv = NS_OK; |
michael@0 | 51 | nsCOMPtr<nsIAccessible> target = do_QueryElementAt(mTargets, aIndex, &rv); |
michael@0 | 52 | target.forget(aTarget); |
michael@0 | 53 | return rv; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | NS_IMETHODIMP |
michael@0 | 57 | nsAccessibleRelation::GetTargets(nsIArray **aTargets) |
michael@0 | 58 | { |
michael@0 | 59 | NS_ENSURE_ARG_POINTER(aTargets); |
michael@0 | 60 | NS_ADDREF(*aTargets = mTargets); |
michael@0 | 61 | return NS_OK; |
michael@0 | 62 | } |