2015-07-22 19:03:07 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_FileList_h
|
|
|
|
#define mozilla_dom_FileList_h
|
|
|
|
|
2015-07-28 10:38:16 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2016-03-20 13:56:10 +03:00
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
2015-07-28 10:38:16 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2015-07-22 19:03:07 +03:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-07-22 19:04:22 +03:00
|
|
|
class BlobImpls;
|
2015-07-22 19:03:07 +03:00
|
|
|
class File;
|
|
|
|
|
2018-03-16 22:55:32 +03:00
|
|
|
class FileList final : public nsISupports, public nsWrapperCache {
|
2015-07-22 19:03:07 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FileList)
|
|
|
|
|
|
|
|
explicit FileList(nsISupports* aParent) : mParent(aParent) {}
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() { return mParent; }
|
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
bool Append(File* aFile) {
|
|
|
|
MOZ_ASSERT(aFile);
|
|
|
|
return mFiles.AppendElement(aFile, fallible);
|
|
|
|
}
|
2015-07-22 19:03:07 +03:00
|
|
|
|
|
|
|
bool Remove(uint32_t aIndex) {
|
2016-04-12 15:51:52 +03:00
|
|
|
if (aIndex < mFiles.Length()) {
|
|
|
|
mFiles.RemoveElementAt(aIndex);
|
2015-07-22 19:03:07 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
void Clear() { return mFiles.Clear(); }
|
2015-07-22 19:03:07 +03:00
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
File* Item(uint32_t aIndex) const;
|
2016-03-20 13:56:10 +03:00
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
File* IndexedGetter(uint32_t aIndex, bool& aFound) const;
|
2015-07-22 19:03:07 +03:00
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
uint32_t Length() const { return mFiles.Length(); }
|
2016-03-20 00:29:47 +03:00
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
void ToSequence(Sequence<RefPtr<File>>& aSequence, ErrorResult& aRv) const;
|
2016-03-20 13:56:10 +03:00
|
|
|
|
2015-07-22 19:03:07 +03:00
|
|
|
private:
|
|
|
|
~FileList() {}
|
|
|
|
|
2016-04-12 15:51:52 +03:00
|
|
|
FallibleTArray<RefPtr<File>> mFiles;
|
2015-07-22 19:03:07 +03:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_FileList_h
|