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 : #ifndef mozilla_dom_SpeechGrammarList_h
8 : #define mozilla_dom_SpeechGrammarList_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsCycleCollectionParticipant.h"
13 : #include "nsWrapperCache.h"
14 :
15 : struct JSContext;
16 :
17 : namespace mozilla {
18 :
19 : class ErrorResult;
20 :
21 : namespace dom {
22 :
23 : class GlobalObject;
24 : class SpeechGrammar;
25 : template<typename> class Optional;
26 :
27 : class SpeechGrammarList final : public nsISupports,
28 : public nsWrapperCache
29 : {
30 : public:
31 : explicit SpeechGrammarList(nsISupports* aParent);
32 :
33 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
34 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechGrammarList)
35 :
36 : static already_AddRefed<SpeechGrammarList> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
37 :
38 : nsISupports* GetParentObject() const;
39 :
40 : JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
41 :
42 : uint32_t Length() const;
43 :
44 : already_AddRefed<SpeechGrammar> Item(uint32_t aIndex, ErrorResult& aRv);
45 :
46 : void AddFromURI(const nsAString& aSrc, const Optional<float>& aWeight, ErrorResult& aRv);
47 :
48 : void AddFromString(const nsAString& aString, const Optional<float>& aWeight, ErrorResult& aRv);
49 :
50 : already_AddRefed<SpeechGrammar> IndexedGetter(uint32_t aIndex, bool& aPresent, ErrorResult& aRv);
51 :
52 : private:
53 : ~SpeechGrammarList();
54 :
55 : nsCOMPtr<nsISupports> mParent;
56 :
57 : nsTArray<RefPtr<SpeechGrammar>> mItems;
58 : };
59 :
60 : } // namespace dom
61 : } // namespace mozilla
62 :
63 : #endif
|