Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/webspeech/recognition/SpeechRecognitionResult.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
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 "SpeechRecognitionResult.h"
8
#include "mozilla/dom/SpeechRecognitionResultBinding.h"
9
10
#include "SpeechRecognition.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SpeechRecognitionResult, mParent)
16
NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechRecognitionResult)
17
NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechRecognitionResult)
18
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechRecognitionResult)
19
0
  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
20
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
21
0
NS_INTERFACE_MAP_END
22
23
SpeechRecognitionResult::SpeechRecognitionResult(SpeechRecognition* aParent)
24
  : mParent(aParent)
25
0
{
26
0
}
27
28
SpeechRecognitionResult::~SpeechRecognitionResult()
29
0
{
30
0
}
31
32
JSObject*
33
SpeechRecognitionResult::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
34
0
{
35
0
  return SpeechRecognitionResult_Binding::Wrap(aCx, this, aGivenProto);
36
0
}
37
38
nsISupports*
39
SpeechRecognitionResult::GetParentObject() const
40
0
{
41
0
  return static_cast<DOMEventTargetHelper*>(mParent.get());
42
0
}
43
44
already_AddRefed<SpeechRecognitionAlternative>
45
SpeechRecognitionResult::IndexedGetter(uint32_t aIndex, bool& aPresent)
46
0
{
47
0
  if (aIndex >= Length()) {
48
0
    aPresent = false;
49
0
    return nullptr;
50
0
  }
51
0
52
0
  aPresent = true;
53
0
  return Item(aIndex);
54
0
}
55
56
uint32_t
57
SpeechRecognitionResult::Length() const
58
0
{
59
0
  return mItems.Length();
60
0
}
61
62
already_AddRefed<SpeechRecognitionAlternative>
63
SpeechRecognitionResult::Item(uint32_t aIndex)
64
0
{
65
0
  RefPtr<SpeechRecognitionAlternative> alternative = mItems.ElementAt(aIndex);
66
0
  return alternative.forget();
67
0
}
68
69
bool
70
SpeechRecognitionResult::IsFinal() const
71
0
{
72
0
  return true; // TODO
73
0
}
74
75
} // namespace dom
76
} // namespace mozilla