Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/file/FileList.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#include "mozilla/dom/Directory.h"
8
#include "mozilla/dom/FileList.h"
9
#include "mozilla/dom/FileListBinding.h"
10
#include "mozilla/dom/File.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileList, mFiles, mParent)
16
17
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileList)
18
0
  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
19
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
20
0
NS_INTERFACE_MAP_END
21
22
NS_IMPL_CYCLE_COLLECTING_ADDREF(FileList)
23
NS_IMPL_CYCLE_COLLECTING_RELEASE(FileList)
24
25
JSObject*
26
FileList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
27
0
{
28
0
  return mozilla::dom::FileList_Binding::Wrap(aCx, this, aGivenProto);
29
0
}
30
31
File*
32
FileList::Item(uint32_t aIndex) const
33
0
{
34
0
  if (aIndex >= mFiles.Length()) {
35
0
    return nullptr;
36
0
  }
37
0
38
0
  return mFiles[aIndex];
39
0
}
40
41
File*
42
FileList::IndexedGetter(uint32_t aIndex, bool& aFound) const
43
0
{
44
0
  aFound = aIndex < mFiles.Length();
45
0
  return Item(aIndex);
46
0
}
47
48
void
49
FileList::ToSequence(Sequence<RefPtr<File>>& aSequence,
50
                     ErrorResult& aRv) const
51
0
{
52
0
  MOZ_ASSERT(aSequence.IsEmpty());
53
0
  if (mFiles.IsEmpty()) {
54
0
    return;
55
0
  }
56
0
57
0
  if (!aSequence.SetLength(mFiles.Length(),
58
0
                           mozilla::fallible_t())) {
59
0
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
60
0
    return;
61
0
  }
62
0
63
0
  for (uint32_t i = 0; i < mFiles.Length(); ++i) {
64
0
    aSequence[i] = mFiles[i];
65
0
  }
66
0
}
67
68
} // namespace dom
69
} // namespace mozilla