/work/obj-fuzz/dist/include/mozilla/dom/SpeechSynthesisUtterance.h
Line | Count | Source (jump to first uncovered line) |
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_SpeechSynthesisUtterance_h |
8 | | #define mozilla_dom_SpeechSynthesisUtterance_h |
9 | | |
10 | | #include "mozilla/DOMEventTargetHelper.h" |
11 | | #include "nsCOMPtr.h" |
12 | | #include "nsString.h" |
13 | | #include "js/TypeDecls.h" |
14 | | |
15 | | #include "nsSpeechTask.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | class SpeechSynthesisVoice; |
21 | | class SpeechSynthesis; |
22 | | class nsSynthVoiceRegistry; |
23 | | |
24 | | class SpeechSynthesisUtterance final : public DOMEventTargetHelper |
25 | | { |
26 | | friend class SpeechSynthesis; |
27 | | friend class nsSpeechTask; |
28 | | friend class nsSynthVoiceRegistry; |
29 | | |
30 | | public: |
31 | | SpeechSynthesisUtterance(nsPIDOMWindowInner* aOwnerWindow, const nsAString& aText); |
32 | | |
33 | | NS_DECL_ISUPPORTS_INHERITED |
34 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SpeechSynthesisUtterance, |
35 | | DOMEventTargetHelper) |
36 | | |
37 | | nsISupports* GetParentObject() const; |
38 | | |
39 | | JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
40 | | |
41 | | static |
42 | | already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal, |
43 | | ErrorResult& aRv); |
44 | | static |
45 | | already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal, |
46 | | const nsAString& aText, |
47 | | ErrorResult& aRv); |
48 | | |
49 | | void GetText(nsString& aResult) const; |
50 | | |
51 | | void SetText(const nsAString& aText); |
52 | | |
53 | | void GetLang(nsString& aResult) const; |
54 | | |
55 | | void SetLang(const nsAString& aLang); |
56 | | |
57 | | SpeechSynthesisVoice* GetVoice() const; |
58 | | |
59 | | void SetVoice(SpeechSynthesisVoice* aVoice); |
60 | | |
61 | | float Volume() const; |
62 | | |
63 | | void SetVolume(float aVolume); |
64 | | |
65 | | float Rate() const; |
66 | | |
67 | | void SetRate(float aRate); |
68 | | |
69 | | float Pitch() const; |
70 | | |
71 | | void SetPitch(float aPitch); |
72 | | |
73 | | void GetChosenVoiceURI(nsString& aResult) const; |
74 | | |
75 | | enum { |
76 | | STATE_NONE, |
77 | | STATE_PENDING, |
78 | | STATE_SPEAKING, |
79 | | STATE_ENDED |
80 | | }; |
81 | | |
82 | 0 | uint32_t GetState() { return mState; } |
83 | | |
84 | 0 | bool IsPaused() { return mPaused; } |
85 | | |
86 | | IMPL_EVENT_HANDLER(start) |
87 | | IMPL_EVENT_HANDLER(end) |
88 | | IMPL_EVENT_HANDLER(error) |
89 | | IMPL_EVENT_HANDLER(pause) |
90 | | IMPL_EVENT_HANDLER(resume) |
91 | | IMPL_EVENT_HANDLER(mark) |
92 | | IMPL_EVENT_HANDLER(boundary) |
93 | | |
94 | | private: |
95 | | virtual ~SpeechSynthesisUtterance(); |
96 | | |
97 | | void DispatchSpeechSynthesisEvent(const nsAString& aEventType, |
98 | | uint32_t aCharIndex, |
99 | | const Nullable<uint32_t>& aCharLength, |
100 | | float aElapsedTime, const nsAString& aName); |
101 | | |
102 | | nsString mText; |
103 | | |
104 | | nsString mLang; |
105 | | |
106 | | float mVolume; |
107 | | |
108 | | float mRate; |
109 | | |
110 | | float mPitch; |
111 | | |
112 | | nsString mChosenVoiceURI; |
113 | | |
114 | | uint32_t mState; |
115 | | |
116 | | bool mPaused; |
117 | | |
118 | | RefPtr<SpeechSynthesisVoice> mVoice; |
119 | | }; |
120 | | |
121 | | } // namespace dom |
122 | | } // namespace mozilla |
123 | | |
124 | | #endif |