1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_FileList_h
8 #define mozilla_dom_FileList_h
11 #include "js/TypeDecls.h"
12 #include "mozilla/Assertions.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsISupports.h"
17 #include "nsWrapperCache.h"
19 class nsCycleCollectionTraversalCallback
;
32 class FileList final
: public nsISupports
, public nsWrapperCache
{
34 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
35 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(FileList
)
37 explicit FileList(nsISupports
* aParent
);
39 JSObject
* WrapObject(JSContext
* aCx
,
40 JS::Handle
<JSObject
*> aGivenProto
) override
;
42 nsISupports
* GetParentObject() { return mParent
; }
44 bool Append(File
* aFile
);
46 bool Remove(uint32_t aIndex
);
50 File
* Item(uint32_t aIndex
) const;
52 File
* IndexedGetter(uint32_t aIndex
, bool& aFound
) const;
54 uint32_t Length() const { return mFiles
.Length(); }
56 void ToSequence(Sequence
<RefPtr
<File
>>& aSequence
, ErrorResult
& aRv
) const;
61 FallibleTArray
<RefPtr
<File
>> mFiles
;
62 nsCOMPtr
<nsISupports
> mParent
;
66 } // namespace mozilla
68 #endif // mozilla_dom_FileList_h