michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "SpeechSynthesis.h" michael@0: #include "nsSynthVoiceRegistry.h" michael@0: #include "mozilla/dom/SpeechSynthesisVoiceBinding.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(SpeechSynthesisVoice, mParent) michael@0: NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechSynthesisVoice) michael@0: NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechSynthesisVoice) michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechSynthesisVoice) michael@0: NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: SpeechSynthesisVoice::SpeechSynthesisVoice(nsISupports* aParent, michael@0: const nsAString& aUri) michael@0: : mParent(aParent) michael@0: , mUri(aUri) michael@0: { michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: SpeechSynthesisVoice::~SpeechSynthesisVoice() michael@0: { michael@0: } michael@0: michael@0: JSObject* michael@0: SpeechSynthesisVoice::WrapObject(JSContext* aCx) michael@0: { michael@0: return SpeechSynthesisVoiceBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: nsISupports* michael@0: SpeechSynthesisVoice::GetParentObject() const michael@0: { michael@0: return mParent; michael@0: } michael@0: michael@0: void michael@0: SpeechSynthesisVoice::GetVoiceURI(nsString& aRetval) const michael@0: { michael@0: aRetval = mUri; michael@0: } michael@0: michael@0: void michael@0: SpeechSynthesisVoice::GetName(nsString& aRetval) const michael@0: { michael@0: DebugOnly rv = michael@0: nsSynthVoiceRegistry::GetInstance()->GetVoiceName(mUri, aRetval); michael@0: NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.name"); michael@0: } michael@0: michael@0: void michael@0: SpeechSynthesisVoice::GetLang(nsString& aRetval) const michael@0: { michael@0: DebugOnly rv = michael@0: nsSynthVoiceRegistry::GetInstance()->GetVoiceLang(mUri, aRetval); michael@0: NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.lang"); michael@0: } michael@0: michael@0: bool michael@0: SpeechSynthesisVoice::LocalService() const michael@0: { michael@0: bool isLocal; michael@0: DebugOnly rv = michael@0: nsSynthVoiceRegistry::GetInstance()->IsLocalVoice(mUri, &isLocal); michael@0: NS_WARN_IF_FALSE( michael@0: NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.localService"); michael@0: michael@0: return isLocal; michael@0: } michael@0: michael@0: bool michael@0: SpeechSynthesisVoice::Default() const michael@0: { michael@0: bool isDefault; michael@0: DebugOnly rv = michael@0: nsSynthVoiceRegistry::GetInstance()->IsDefaultVoice(mUri, &isDefault); michael@0: NS_WARN_IF_FALSE( michael@0: NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.default"); michael@0: michael@0: return isDefault; michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla