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/. */
7 #include "SpeechRecognitionResult.h"
8 #include "mozilla/dom/SpeechRecognitionResultBinding.h"
10 #include "SpeechRecognition.h"
12 namespace mozilla::dom
{
14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SpeechRecognitionResult
, mParent
)
15 NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechRecognitionResult
)
16 NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechRecognitionResult
)
17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechRecognitionResult
)
18 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
19 NS_INTERFACE_MAP_ENTRY(nsISupports
)
22 SpeechRecognitionResult::SpeechRecognitionResult(SpeechRecognition
* aParent
)
25 SpeechRecognitionResult::~SpeechRecognitionResult() = default;
27 JSObject
* SpeechRecognitionResult::WrapObject(
28 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
29 return SpeechRecognitionResult_Binding::Wrap(aCx
, this, aGivenProto
);
32 nsISupports
* SpeechRecognitionResult::GetParentObject() const {
33 return static_cast<EventTarget
*>(mParent
.get());
36 already_AddRefed
<SpeechRecognitionAlternative
>
37 SpeechRecognitionResult::IndexedGetter(uint32_t aIndex
, bool& aPresent
) {
38 if (aIndex
>= Length()) {
47 uint32_t SpeechRecognitionResult::Length() const { return mItems
.Length(); }
49 already_AddRefed
<SpeechRecognitionAlternative
> SpeechRecognitionResult::Item(
51 RefPtr
<SpeechRecognitionAlternative
> alternative
= mItems
.ElementAt(aIndex
);
52 return alternative
.forget();
55 bool SpeechRecognitionResult::IsFinal() const {
59 } // namespace mozilla::dom