Tue, 06 Jan 2015 21:39:09 +0100
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.
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/. */
7 #ifndef mozilla_dom_SpeechSynthesisUtterance_h
8 #define mozilla_dom_SpeechSynthesisUtterance_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "nsCOMPtr.h"
12 #include "nsString.h"
13 #include "js/TypeDecls.h"
15 #include "nsSpeechTask.h"
17 namespace mozilla {
18 namespace dom {
20 class SpeechSynthesisVoice;
21 class SpeechSynthesis;
22 class nsSynthVoiceRegistry;
24 class SpeechSynthesisUtterance MOZ_FINAL : public DOMEventTargetHelper
25 {
26 friend class SpeechSynthesis;
27 friend class nsSpeechTask;
28 friend class nsSynthVoiceRegistry;
30 public:
31 SpeechSynthesisUtterance(nsPIDOMWindow* aOwnerWindow, const nsAString& aText);
32 virtual ~SpeechSynthesisUtterance();
34 NS_DECL_ISUPPORTS_INHERITED
35 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SpeechSynthesisUtterance,
36 DOMEventTargetHelper)
37 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
39 nsISupports* GetParentObject() const;
41 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
43 static
44 already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
45 ErrorResult& aRv);
46 static
47 already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
48 const nsAString& aText,
49 ErrorResult& aRv);
51 void GetText(nsString& aResult) const;
53 void SetText(const nsAString& aText);
55 void GetLang(nsString& aResult) const;
57 void SetLang(const nsAString& aLang);
59 SpeechSynthesisVoice* GetVoice() const;
61 void SetVoice(SpeechSynthesisVoice* aVoice);
63 float Volume() const;
65 void SetVolume(float aVolume);
67 float Rate() const;
69 void SetRate(float aRate);
71 float Pitch() const;
73 void SetPitch(float aPitch);
75 enum {
76 STATE_NONE,
77 STATE_PENDING,
78 STATE_SPEAKING,
79 STATE_ENDED
80 };
82 uint32_t GetState() { return mState; }
84 bool IsPaused() { return mPaused; }
86 IMPL_EVENT_HANDLER(start)
87 IMPL_EVENT_HANDLER(end)
88 IMPL_EVENT_HANDLER(error)
89 IMPL_EVENT_HANDLER(pause)
90 IMPL_EVENT_HANDLER(resume)
91 IMPL_EVENT_HANDLER(mark)
92 IMPL_EVENT_HANDLER(boundary)
94 private:
96 void DispatchSpeechSynthesisEvent(const nsAString& aEventType,
97 uint32_t aCharIndex,
98 float aElapsedTime, const nsAString& aName);
100 nsString mText;
102 nsString mLang;
104 float mVolume;
106 float mRate;
108 float mPitch;
110 uint32_t mState;
112 bool mPaused;
114 nsRefPtr<SpeechSynthesisVoice> mVoice;
115 };
117 } // namespace dom
118 } // namespace mozilla
120 #endif