1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "EnumVariant.h"
9 using namespace mozilla
;
10 using namespace mozilla::a11y
;
12 ////////////////////////////////////////////////////////////////////////////////
13 // ChildrenEnumVariant
14 ////////////////////////////////////////////////////////////////////////////////
16 IMPL_IUNKNOWN_QUERY_HEAD(ChildrenEnumVariant
)
17 IMPL_IUNKNOWN_QUERY_IFACE(IEnumVARIANT
)
18 IMPL_IUNKNOWN_QUERY_TAIL_AGGREGATED(mAnchorMsaa
)
21 ChildrenEnumVariant::Next(ULONG aCount
, VARIANT FAR
* aItems
,
22 ULONG FAR
* aCountFetched
) {
23 if (!aItems
|| !aCountFetched
) return E_INVALIDARG
;
27 Accessible
* anchor
= mAnchorMsaa
->Acc();
28 if (!anchor
|| anchor
->ChildAt(mCurIndex
) != mCurAcc
) {
29 return CO_E_OBJNOTCONNECTED
;
32 ULONG countFetched
= 0;
33 while (mCurAcc
&& countFetched
< aCount
) {
34 VariantInit(aItems
+ countFetched
);
36 IDispatch
* accNative
= MsaaAccessible::NativeAccessible(mCurAcc
);
39 mCurAcc
= anchor
->ChildAt(mCurIndex
);
41 // Don't output the accessible and count it as having been fetched unless
43 MOZ_ASSERT(accNative
);
48 aItems
[countFetched
].pdispVal
= accNative
;
49 aItems
[countFetched
].vt
= VT_DISPATCH
;
53 (*aCountFetched
) = countFetched
;
55 return countFetched
< aCount
? S_FALSE
: S_OK
;
59 ChildrenEnumVariant::Skip(ULONG aCount
) {
60 Accessible
* anchor
= mAnchorMsaa
->Acc();
61 if (!anchor
|| anchor
->ChildAt(mCurIndex
) != mCurAcc
) {
62 return CO_E_OBJNOTCONNECTED
;
66 mCurAcc
= anchor
->ChildAt(mCurIndex
);
68 return mCurAcc
? S_OK
: S_FALSE
;
72 ChildrenEnumVariant::Reset() {
73 Accessible
* anchor
= mAnchorMsaa
->Acc();
74 if (!anchor
) return CO_E_OBJNOTCONNECTED
;
77 mCurAcc
= anchor
->ChildAt(0);
83 ChildrenEnumVariant::Clone(IEnumVARIANT
** aEnumVariant
) {
84 if (!aEnumVariant
) return E_INVALIDARG
;
86 *aEnumVariant
= new ChildrenEnumVariant(*this);
87 (*aEnumVariant
)->AddRef();