Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / media / webspeech / recognition / SpeechRecognitionResultList.cpp
blob2aa81a5982a61537a868731cc9ff9a12e682e5b4
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,
16 mItems)
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)
22 NS_INTERFACE_MAP_END
24 SpeechRecognitionResultList::SpeechRecognitionResultList(
25 SpeechRecognition* aParent)
26 : mParent(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()) {
42 aPresent = false;
43 return nullptr;
46 aPresent = true;
47 return Item(aIndex);
50 uint32_t SpeechRecognitionResultList::Length() const { return mItems.Length(); }
52 already_AddRefed<SpeechRecognitionResult> SpeechRecognitionResultList::Item(
53 uint32_t aIndex) {
54 RefPtr<SpeechRecognitionResult> result = mItems.ElementAt(aIndex);
55 return result.forget();
58 } // namespace mozilla::dom