Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / media / webspeech / recognition / SpeechGrammarList.h
blob7f1e09cd9e0b7695365848563e5b92a76402e3d2
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 #ifndef mozilla_dom_SpeechGrammarList_h
8 #define mozilla_dom_SpeechGrammarList_h
10 #include "mozilla/Attributes.h"
11 #include "nsCOMPtr.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsTArray.h"
14 #include "nsWrapperCache.h"
16 struct JSContext;
18 namespace mozilla {
20 class ErrorResult;
22 namespace dom {
24 class GlobalObject;
25 class SpeechGrammar;
26 template <typename>
27 class Optional;
29 class SpeechGrammarList final : public nsISupports, public nsWrapperCache {
30 public:
31 explicit SpeechGrammarList(nsISupports* aParent);
33 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
34 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(SpeechGrammarList)
36 static already_AddRefed<SpeechGrammarList> Constructor(
37 const GlobalObject& aGlobal);
39 static already_AddRefed<SpeechGrammarList> WebkitSpeechGrammarList(
40 const GlobalObject& aGlobal, ErrorResult& aRv) {
41 return Constructor(aGlobal);
44 nsISupports* GetParentObject() const;
46 JSObject* WrapObject(JSContext* aCx,
47 JS::Handle<JSObject*> aGivenProto) override;
49 uint32_t Length() const;
51 already_AddRefed<SpeechGrammar> Item(uint32_t aIndex, ErrorResult& aRv);
53 void AddFromURI(const nsAString& aSrc, const Optional<float>& aWeight,
54 ErrorResult& aRv);
56 void AddFromString(const nsAString& aString, const Optional<float>& aWeight,
57 ErrorResult& aRv);
59 already_AddRefed<SpeechGrammar> IndexedGetter(uint32_t aIndex, bool& aPresent,
60 ErrorResult& aRv);
62 private:
63 ~SpeechGrammarList();
65 nsCOMPtr<nsISupports> mParent;
67 nsTArray<RefPtr<SpeechGrammar>> mItems;
70 } // namespace dom
71 } // namespace mozilla
73 #endif