|
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_SpeechSynthesis_h |
|
8 #define mozilla_dom_SpeechSynthesis_h |
|
9 |
|
10 #include "nsCOMPtr.h" |
|
11 #include "nsString.h" |
|
12 #include "nsWrapperCache.h" |
|
13 #include "nsRefPtrHashtable.h" |
|
14 #include "js/TypeDecls.h" |
|
15 |
|
16 #include "SpeechSynthesisUtterance.h" |
|
17 #include "SpeechSynthesisVoice.h" |
|
18 |
|
19 class nsIDOMWindow; |
|
20 |
|
21 namespace mozilla { |
|
22 namespace dom { |
|
23 |
|
24 class nsSpeechTask; |
|
25 |
|
26 class SpeechSynthesis MOZ_FINAL : public nsISupports, |
|
27 public nsWrapperCache |
|
28 { |
|
29 public: |
|
30 SpeechSynthesis(nsPIDOMWindow* aParent); |
|
31 virtual ~SpeechSynthesis(); |
|
32 |
|
33 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
34 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechSynthesis) |
|
35 |
|
36 nsIDOMWindow* GetParentObject() const; |
|
37 |
|
38 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
39 |
|
40 bool Pending() const; |
|
41 |
|
42 bool Speaking() const; |
|
43 |
|
44 bool Paused() const; |
|
45 |
|
46 void Speak(SpeechSynthesisUtterance& aUtterance); |
|
47 |
|
48 void Cancel(); |
|
49 |
|
50 void Pause(); |
|
51 |
|
52 void Resume(); |
|
53 |
|
54 void OnEnd(const nsSpeechTask* aTask); |
|
55 |
|
56 void GetVoices(nsTArray< nsRefPtr<SpeechSynthesisVoice> >& aResult); |
|
57 |
|
58 private: |
|
59 |
|
60 void AdvanceQueue(); |
|
61 |
|
62 nsCOMPtr<nsPIDOMWindow> mParent; |
|
63 |
|
64 nsTArray<nsRefPtr<SpeechSynthesisUtterance> > mSpeechQueue; |
|
65 |
|
66 nsRefPtr<nsSpeechTask> mCurrentTask; |
|
67 |
|
68 nsRefPtrHashtable<nsStringHashKey, SpeechSynthesisVoice> mVoiceCache; |
|
69 }; |
|
70 |
|
71 } // namespace dom |
|
72 } // namespace mozilla |
|
73 |
|
74 #endif |