content/media/webspeech/synth/SpeechSynthesisUtterance.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webspeech/synth/SpeechSynthesisUtterance.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_SpeechSynthesisUtterance_h
    1.11 +#define mozilla_dom_SpeechSynthesisUtterance_h
    1.12 +
    1.13 +#include "mozilla/DOMEventTargetHelper.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsString.h"
    1.16 +#include "js/TypeDecls.h"
    1.17 +
    1.18 +#include "nsSpeechTask.h"
    1.19 +
    1.20 +namespace mozilla {
    1.21 +namespace dom {
    1.22 +
    1.23 +class SpeechSynthesisVoice;
    1.24 +class SpeechSynthesis;
    1.25 +class nsSynthVoiceRegistry;
    1.26 +
    1.27 +class SpeechSynthesisUtterance MOZ_FINAL : public DOMEventTargetHelper
    1.28 +{
    1.29 +  friend class SpeechSynthesis;
    1.30 +  friend class nsSpeechTask;
    1.31 +  friend class nsSynthVoiceRegistry;
    1.32 +
    1.33 +public:
    1.34 +  SpeechSynthesisUtterance(nsPIDOMWindow* aOwnerWindow, const nsAString& aText);
    1.35 +  virtual ~SpeechSynthesisUtterance();
    1.36 +
    1.37 +  NS_DECL_ISUPPORTS_INHERITED
    1.38 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SpeechSynthesisUtterance,
    1.39 +                                           DOMEventTargetHelper)
    1.40 +  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    1.41 +
    1.42 +  nsISupports* GetParentObject() const;
    1.43 +
    1.44 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.45 +
    1.46 +  static
    1.47 +  already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
    1.48 +                                                         ErrorResult& aRv);
    1.49 +  static
    1.50 +  already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
    1.51 +                                                         const nsAString& aText,
    1.52 +                                                         ErrorResult& aRv);
    1.53 +
    1.54 +  void GetText(nsString& aResult) const;
    1.55 +
    1.56 +  void SetText(const nsAString& aText);
    1.57 +
    1.58 +  void GetLang(nsString& aResult) const;
    1.59 +
    1.60 +  void SetLang(const nsAString& aLang);
    1.61 +
    1.62 +  SpeechSynthesisVoice* GetVoice() const;
    1.63 +
    1.64 +  void SetVoice(SpeechSynthesisVoice* aVoice);
    1.65 +
    1.66 +  float Volume() const;
    1.67 +
    1.68 +  void SetVolume(float aVolume);
    1.69 +
    1.70 +  float Rate() const;
    1.71 +
    1.72 +  void SetRate(float aRate);
    1.73 +
    1.74 +  float Pitch() const;
    1.75 +
    1.76 +  void SetPitch(float aPitch);
    1.77 +
    1.78 +  enum {
    1.79 +    STATE_NONE,
    1.80 +    STATE_PENDING,
    1.81 +    STATE_SPEAKING,
    1.82 +    STATE_ENDED
    1.83 +  };
    1.84 +
    1.85 +  uint32_t GetState() { return mState; }
    1.86 +
    1.87 +  bool IsPaused() { return mPaused; }
    1.88 +
    1.89 +  IMPL_EVENT_HANDLER(start)
    1.90 +  IMPL_EVENT_HANDLER(end)
    1.91 +  IMPL_EVENT_HANDLER(error)
    1.92 +  IMPL_EVENT_HANDLER(pause)
    1.93 +  IMPL_EVENT_HANDLER(resume)
    1.94 +  IMPL_EVENT_HANDLER(mark)
    1.95 +  IMPL_EVENT_HANDLER(boundary)
    1.96 +
    1.97 +private:
    1.98 +
    1.99 +  void DispatchSpeechSynthesisEvent(const nsAString& aEventType,
   1.100 +                                    uint32_t aCharIndex,
   1.101 +                                    float aElapsedTime, const nsAString& aName);
   1.102 +
   1.103 +  nsString mText;
   1.104 +
   1.105 +  nsString mLang;
   1.106 +
   1.107 +  float mVolume;
   1.108 +
   1.109 +  float mRate;
   1.110 +
   1.111 +  float mPitch;
   1.112 +
   1.113 +  uint32_t mState;
   1.114 +
   1.115 +  bool mPaused;
   1.116 +
   1.117 +  nsRefPtr<SpeechSynthesisVoice> mVoice;
   1.118 +};
   1.119 +
   1.120 +} // namespace dom
   1.121 +} // namespace mozilla
   1.122 +
   1.123 +#endif

mercurial