Line data Source code
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 0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SpeechRecognitionResult, mParent)
16 0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechRecognitionResult)
17 0 : 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 0 : SpeechRecognitionResult::SpeechRecognitionResult(SpeechRecognition* aParent)
24 0 : : mParent(aParent)
25 : {
26 0 : }
27 :
28 0 : SpeechRecognitionResult::~SpeechRecognitionResult()
29 : {
30 0 : }
31 :
32 : JSObject*
33 0 : SpeechRecognitionResult::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
34 : {
35 0 : return SpeechRecognitionResultBinding::Wrap(aCx, this, aGivenProto);
36 : }
37 :
38 : nsISupports*
39 0 : SpeechRecognitionResult::GetParentObject() const
40 : {
41 0 : return static_cast<DOMEventTargetHelper*>(mParent.get());
42 : }
43 :
44 : already_AddRefed<SpeechRecognitionAlternative>
45 0 : SpeechRecognitionResult::IndexedGetter(uint32_t aIndex, bool& aPresent)
46 : {
47 0 : if (aIndex >= Length()) {
48 0 : aPresent = false;
49 0 : return nullptr;
50 : }
51 :
52 0 : aPresent = true;
53 0 : return Item(aIndex);
54 : }
55 :
56 : uint32_t
57 0 : SpeechRecognitionResult::Length() const
58 : {
59 0 : return mItems.Length();
60 : }
61 :
62 : already_AddRefed<SpeechRecognitionAlternative>
63 0 : SpeechRecognitionResult::Item(uint32_t aIndex)
64 : {
65 0 : RefPtr<SpeechRecognitionAlternative> alternative = mItems.ElementAt(aIndex);
66 0 : return alternative.forget();
67 : }
68 :
69 : bool
70 0 : SpeechRecognitionResult::IsFinal() const
71 : {
72 0 : return true; // TODO
73 : }
74 :
75 : } // namespace dom
76 : } // namespace mozilla
|