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