content/media/webspeech/synth/SpeechSynthesisUtterance.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_SpeechSynthesisUtterance_h
michael@0 8 #define mozilla_dom_SpeechSynthesisUtterance_h
michael@0 9
michael@0 10 #include "mozilla/DOMEventTargetHelper.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsString.h"
michael@0 13 #include "js/TypeDecls.h"
michael@0 14
michael@0 15 #include "nsSpeechTask.h"
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18 namespace dom {
michael@0 19
michael@0 20 class SpeechSynthesisVoice;
michael@0 21 class SpeechSynthesis;
michael@0 22 class nsSynthVoiceRegistry;
michael@0 23
michael@0 24 class SpeechSynthesisUtterance MOZ_FINAL : public DOMEventTargetHelper
michael@0 25 {
michael@0 26 friend class SpeechSynthesis;
michael@0 27 friend class nsSpeechTask;
michael@0 28 friend class nsSynthVoiceRegistry;
michael@0 29
michael@0 30 public:
michael@0 31 SpeechSynthesisUtterance(nsPIDOMWindow* aOwnerWindow, const nsAString& aText);
michael@0 32 virtual ~SpeechSynthesisUtterance();
michael@0 33
michael@0 34 NS_DECL_ISUPPORTS_INHERITED
michael@0 35 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SpeechSynthesisUtterance,
michael@0 36 DOMEventTargetHelper)
michael@0 37 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
michael@0 38
michael@0 39 nsISupports* GetParentObject() const;
michael@0 40
michael@0 41 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 42
michael@0 43 static
michael@0 44 already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
michael@0 45 ErrorResult& aRv);
michael@0 46 static
michael@0 47 already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
michael@0 48 const nsAString& aText,
michael@0 49 ErrorResult& aRv);
michael@0 50
michael@0 51 void GetText(nsString& aResult) const;
michael@0 52
michael@0 53 void SetText(const nsAString& aText);
michael@0 54
michael@0 55 void GetLang(nsString& aResult) const;
michael@0 56
michael@0 57 void SetLang(const nsAString& aLang);
michael@0 58
michael@0 59 SpeechSynthesisVoice* GetVoice() const;
michael@0 60
michael@0 61 void SetVoice(SpeechSynthesisVoice* aVoice);
michael@0 62
michael@0 63 float Volume() const;
michael@0 64
michael@0 65 void SetVolume(float aVolume);
michael@0 66
michael@0 67 float Rate() const;
michael@0 68
michael@0 69 void SetRate(float aRate);
michael@0 70
michael@0 71 float Pitch() const;
michael@0 72
michael@0 73 void SetPitch(float aPitch);
michael@0 74
michael@0 75 enum {
michael@0 76 STATE_NONE,
michael@0 77 STATE_PENDING,
michael@0 78 STATE_SPEAKING,
michael@0 79 STATE_ENDED
michael@0 80 };
michael@0 81
michael@0 82 uint32_t GetState() { return mState; }
michael@0 83
michael@0 84 bool IsPaused() { return mPaused; }
michael@0 85
michael@0 86 IMPL_EVENT_HANDLER(start)
michael@0 87 IMPL_EVENT_HANDLER(end)
michael@0 88 IMPL_EVENT_HANDLER(error)
michael@0 89 IMPL_EVENT_HANDLER(pause)
michael@0 90 IMPL_EVENT_HANDLER(resume)
michael@0 91 IMPL_EVENT_HANDLER(mark)
michael@0 92 IMPL_EVENT_HANDLER(boundary)
michael@0 93
michael@0 94 private:
michael@0 95
michael@0 96 void DispatchSpeechSynthesisEvent(const nsAString& aEventType,
michael@0 97 uint32_t aCharIndex,
michael@0 98 float aElapsedTime, const nsAString& aName);
michael@0 99
michael@0 100 nsString mText;
michael@0 101
michael@0 102 nsString mLang;
michael@0 103
michael@0 104 float mVolume;
michael@0 105
michael@0 106 float mRate;
michael@0 107
michael@0 108 float mPitch;
michael@0 109
michael@0 110 uint32_t mState;
michael@0 111
michael@0 112 bool mPaused;
michael@0 113
michael@0 114 nsRefPtr<SpeechSynthesisVoice> mVoice;
michael@0 115 };
michael@0 116
michael@0 117 } // namespace dom
michael@0 118 } // namespace mozilla
michael@0 119
michael@0 120 #endif

mercurial