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: #ifndef mozilla_dom_SpeechSynthesisUtterance_h michael@0: #define mozilla_dom_SpeechSynthesisUtterance_h michael@0: michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: #include "js/TypeDecls.h" michael@0: michael@0: #include "nsSpeechTask.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class SpeechSynthesisVoice; michael@0: class SpeechSynthesis; michael@0: class nsSynthVoiceRegistry; michael@0: michael@0: class SpeechSynthesisUtterance MOZ_FINAL : public DOMEventTargetHelper michael@0: { michael@0: friend class SpeechSynthesis; michael@0: friend class nsSpeechTask; michael@0: friend class nsSynthVoiceRegistry; michael@0: michael@0: public: michael@0: SpeechSynthesisUtterance(nsPIDOMWindow* aOwnerWindow, const nsAString& aText); michael@0: virtual ~SpeechSynthesisUtterance(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SpeechSynthesisUtterance, michael@0: DOMEventTargetHelper) michael@0: NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) michael@0: michael@0: nsISupports* GetParentObject() const; michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: static michael@0: already_AddRefed Constructor(GlobalObject& aGlobal, michael@0: ErrorResult& aRv); michael@0: static michael@0: already_AddRefed Constructor(GlobalObject& aGlobal, michael@0: const nsAString& aText, michael@0: ErrorResult& aRv); michael@0: michael@0: void GetText(nsString& aResult) const; michael@0: michael@0: void SetText(const nsAString& aText); michael@0: michael@0: void GetLang(nsString& aResult) const; michael@0: michael@0: void SetLang(const nsAString& aLang); michael@0: michael@0: SpeechSynthesisVoice* GetVoice() const; michael@0: michael@0: void SetVoice(SpeechSynthesisVoice* aVoice); michael@0: michael@0: float Volume() const; michael@0: michael@0: void SetVolume(float aVolume); michael@0: michael@0: float Rate() const; michael@0: michael@0: void SetRate(float aRate); michael@0: michael@0: float Pitch() const; michael@0: michael@0: void SetPitch(float aPitch); michael@0: michael@0: enum { michael@0: STATE_NONE, michael@0: STATE_PENDING, michael@0: STATE_SPEAKING, michael@0: STATE_ENDED michael@0: }; michael@0: michael@0: uint32_t GetState() { return mState; } michael@0: michael@0: bool IsPaused() { return mPaused; } michael@0: michael@0: IMPL_EVENT_HANDLER(start) michael@0: IMPL_EVENT_HANDLER(end) michael@0: IMPL_EVENT_HANDLER(error) michael@0: IMPL_EVENT_HANDLER(pause) michael@0: IMPL_EVENT_HANDLER(resume) michael@0: IMPL_EVENT_HANDLER(mark) michael@0: IMPL_EVENT_HANDLER(boundary) michael@0: michael@0: private: michael@0: michael@0: void DispatchSpeechSynthesisEvent(const nsAString& aEventType, michael@0: uint32_t aCharIndex, michael@0: float aElapsedTime, const nsAString& aName); michael@0: michael@0: nsString mText; michael@0: michael@0: nsString mLang; michael@0: michael@0: float mVolume; michael@0: michael@0: float mRate; michael@0: michael@0: float mPitch; michael@0: michael@0: uint32_t mState; michael@0: michael@0: bool mPaused; michael@0: michael@0: nsRefPtr mVoice; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif