/src/mozilla-central/dom/media/webspeech/synth/SpeechSynthesisVoice.cpp
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 | | #include "SpeechSynthesis.h" |
8 | | #include "nsSynthVoiceRegistry.h" |
9 | | #include "mozilla/dom/SpeechSynthesisVoiceBinding.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace dom { |
13 | | |
14 | | NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SpeechSynthesisVoice, mParent) |
15 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechSynthesisVoice) |
16 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechSynthesisVoice) |
17 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechSynthesisVoice) |
18 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
19 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
20 | 0 | NS_INTERFACE_MAP_END |
21 | | |
22 | | SpeechSynthesisVoice::SpeechSynthesisVoice(nsISupports* aParent, |
23 | | const nsAString& aUri) |
24 | | : mParent(aParent) |
25 | | , mUri(aUri) |
26 | 0 | { |
27 | 0 | } |
28 | | |
29 | | SpeechSynthesisVoice::~SpeechSynthesisVoice() |
30 | 0 | { |
31 | 0 | } |
32 | | |
33 | | JSObject* |
34 | | SpeechSynthesisVoice::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
35 | 0 | { |
36 | 0 | return SpeechSynthesisVoice_Binding::Wrap(aCx, this, aGivenProto); |
37 | 0 | } |
38 | | |
39 | | nsISupports* |
40 | | SpeechSynthesisVoice::GetParentObject() const |
41 | 0 | { |
42 | 0 | return mParent; |
43 | 0 | } |
44 | | |
45 | | void |
46 | | SpeechSynthesisVoice::GetVoiceURI(nsString& aRetval) const |
47 | 0 | { |
48 | 0 | aRetval = mUri; |
49 | 0 | } |
50 | | |
51 | | void |
52 | | SpeechSynthesisVoice::GetName(nsString& aRetval) const |
53 | 0 | { |
54 | 0 | DebugOnly<nsresult> rv = |
55 | 0 | nsSynthVoiceRegistry::GetInstance()->GetVoiceName(mUri, aRetval); |
56 | 0 | NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), |
57 | 0 | "Failed to get SpeechSynthesisVoice.name"); |
58 | 0 | } |
59 | | |
60 | | void |
61 | | SpeechSynthesisVoice::GetLang(nsString& aRetval) const |
62 | 0 | { |
63 | 0 | DebugOnly<nsresult> rv = |
64 | 0 | nsSynthVoiceRegistry::GetInstance()->GetVoiceLang(mUri, aRetval); |
65 | 0 | NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), |
66 | 0 | "Failed to get SpeechSynthesisVoice.lang"); |
67 | 0 | } |
68 | | |
69 | | bool |
70 | | SpeechSynthesisVoice::LocalService() const |
71 | 0 | { |
72 | 0 | bool isLocal; |
73 | 0 | DebugOnly<nsresult> rv = |
74 | 0 | nsSynthVoiceRegistry::GetInstance()->IsLocalVoice(mUri, &isLocal); |
75 | 0 | NS_WARNING_ASSERTION( |
76 | 0 | NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.localService"); |
77 | 0 |
|
78 | 0 | return isLocal; |
79 | 0 | } |
80 | | |
81 | | bool |
82 | | SpeechSynthesisVoice::Default() const |
83 | 0 | { |
84 | 0 | bool isDefault; |
85 | 0 | DebugOnly<nsresult> rv = |
86 | 0 | nsSynthVoiceRegistry::GetInstance()->IsDefaultVoice(mUri, &isDefault); |
87 | 0 | NS_WARNING_ASSERTION( |
88 | 0 | NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.default"); |
89 | 0 |
|
90 | 0 | return isDefault; |
91 | 0 | } |
92 | | |
93 | | } // namespace dom |
94 | | } // namespace mozilla |