Bug 1845134 - Part 4: Update existing ui-icons to use the latest source from acorn...
[gecko.git] / accessible / windows / msaa / EnumVariant.cpp
blob866e8f69a9af506af4a7b4c203147fdca6cd1566
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)
20 STDMETHODIMP
21 ChildrenEnumVariant::Next(ULONG aCount, VARIANT FAR* aItems,
22 ULONG FAR* aCountFetched) {
23 if (!aItems || !aCountFetched) return E_INVALIDARG;
25 *aCountFetched = 0;
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);
38 ++mCurIndex;
39 mCurAcc = anchor->ChildAt(mCurIndex);
41 // Don't output the accessible and count it as having been fetched unless
42 // it is non-null
43 MOZ_ASSERT(accNative);
44 if (!accNative) {
45 continue;
48 aItems[countFetched].pdispVal = accNative;
49 aItems[countFetched].vt = VT_DISPATCH;
50 ++countFetched;
53 (*aCountFetched) = countFetched;
55 return countFetched < aCount ? S_FALSE : S_OK;
58 STDMETHODIMP
59 ChildrenEnumVariant::Skip(ULONG aCount) {
60 Accessible* anchor = mAnchorMsaa->Acc();
61 if (!anchor || anchor->ChildAt(mCurIndex) != mCurAcc) {
62 return CO_E_OBJNOTCONNECTED;
65 mCurIndex += aCount;
66 mCurAcc = anchor->ChildAt(mCurIndex);
68 return mCurAcc ? S_OK : S_FALSE;
71 STDMETHODIMP
72 ChildrenEnumVariant::Reset() {
73 Accessible* anchor = mAnchorMsaa->Acc();
74 if (!anchor) return CO_E_OBJNOTCONNECTED;
76 mCurIndex = 0;
77 mCurAcc = anchor->ChildAt(0);
79 return S_OK;
82 STDMETHODIMP
83 ChildrenEnumVariant::Clone(IEnumVARIANT** aEnumVariant) {
84 if (!aEnumVariant) return E_INVALIDARG;
86 *aEnumVariant = new ChildrenEnumVariant(*this);
87 (*aEnumVariant)->AddRef();
89 return S_OK;