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 "SpeechRecognitionResultList.h"
9 #include "mozilla/dom/SpeechRecognitionResultListBinding.h"
11 #include "SpeechRecognition.h"
13 namespace mozilla::dom
{
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SpeechRecognitionResultList
, mParent
,
17 NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechRecognitionResultList
)
18 NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechRecognitionResultList
)
19 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechRecognitionResultList
)
20 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
21 NS_INTERFACE_MAP_ENTRY(nsISupports
)
24 SpeechRecognitionResultList::SpeechRecognitionResultList(
25 SpeechRecognition
* aParent
)
28 SpeechRecognitionResultList::~SpeechRecognitionResultList() = default;
30 nsISupports
* SpeechRecognitionResultList::GetParentObject() const {
31 return static_cast<EventTarget
*>(mParent
.get());
34 JSObject
* SpeechRecognitionResultList::WrapObject(
35 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
36 return SpeechRecognitionResultList_Binding::Wrap(aCx
, this, aGivenProto
);
39 already_AddRefed
<SpeechRecognitionResult
>
40 SpeechRecognitionResultList::IndexedGetter(uint32_t aIndex
, bool& aPresent
) {
41 if (aIndex
>= Length()) {
50 uint32_t SpeechRecognitionResultList::Length() const { return mItems
.Length(); }
52 already_AddRefed
<SpeechRecognitionResult
> SpeechRecognitionResultList::Item(
54 RefPtr
<SpeechRecognitionResult
> result
= mItems
.ElementAt(aIndex
);
55 return result
.forget();
58 } // namespace mozilla::dom