OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef SpeechSynthesis_h | 26 #ifndef SpeechSynthesis_h |
27 #define SpeechSynthesis_h | 27 #define SpeechSynthesis_h |
28 | 28 |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/dom/ContextLifecycleObserver.h" | 30 #include "core/dom/ContextLifecycleObserver.h" |
31 #include "core/events/EventTarget.h" | 31 #include "core/events/EventTarget.h" |
32 #include "heap/Handle.h" | |
33 #include "modules/speech/SpeechSynthesisUtterance.h" | 32 #include "modules/speech/SpeechSynthesisUtterance.h" |
34 #include "modules/speech/SpeechSynthesisVoice.h" | 33 #include "modules/speech/SpeechSynthesisVoice.h" |
35 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" | 34 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" |
36 #include "platform/speech/PlatformSpeechSynthesizer.h" | 35 #include "platform/speech/PlatformSpeechSynthesizer.h" |
37 #include "wtf/Deque.h" | 36 #include "wtf/Deque.h" |
38 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
39 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
40 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
41 | 40 |
42 namespace WebCore { | 41 namespace WebCore { |
43 | 42 |
44 class ExceptionState; | 43 class ExceptionState; |
45 class PlatformSpeechSynthesizerClient; | 44 class PlatformSpeechSynthesizerClient; |
| 45 class SpeechSynthesisVoice; |
46 | 46 |
47 class SpeechSynthesis FINAL : public RefCountedWillBeRefCountedGarbageCollected<
SpeechSynthesis>, public PlatformSpeechSynthesizerClient, public ScriptWrappable
, public ContextLifecycleObserver, public EventTargetWithInlineData { | 47 class SpeechSynthesis FINAL : public PlatformSpeechSynthesizerClient, public Scr
iptWrappable, public RefCounted<SpeechSynthesis>, public ContextLifecycleObserve
r, public EventTargetWithInlineData { |
48 DECLARE_GC_INFO; | 48 REFCOUNTED_EVENT_TARGET(SpeechSynthesis); |
49 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<S
peechSynthesis>); | |
50 public: | 49 public: |
51 static PassRefPtrWillBeRawPtr<SpeechSynthesis> create(ExecutionContext*); | 50 static PassRefPtr<SpeechSynthesis> create(ExecutionContext*); |
52 | 51 |
53 bool pending() const; | 52 bool pending() const; |
54 bool speaking() const; | 53 bool speaking() const; |
55 bool paused() const; | 54 bool paused() const; |
56 | 55 |
57 void speak(SpeechSynthesisUtterance*, ExceptionState&); | 56 void speak(SpeechSynthesisUtterance*, ExceptionState&); |
58 void cancel(); | 57 void cancel(); |
59 void pause(); | 58 void pause(); |
60 void resume(); | 59 void resume(); |
61 | 60 |
62 const WillBeHeapVector<RefPtrWillBeMember<SpeechSynthesisVoice> >& getVoices
(); | 61 const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices(); |
63 | 62 |
64 // Used in testing to use a mock platform synthesizer | 63 // Used in testing to use a mock platform synthesizer |
65 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); | 64 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); |
66 | 65 |
67 DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged); | 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged); |
68 | 67 |
69 virtual ExecutionContext* executionContext() const OVERRIDE; | 68 virtual ExecutionContext* executionContext() const OVERRIDE; |
70 | 69 |
71 void trace(Visitor*); | |
72 | |
73 private: | 70 private: |
74 explicit SpeechSynthesis(ExecutionContext*); | 71 explicit SpeechSynthesis(ExecutionContext*); |
75 | 72 |
76 // PlatformSpeechSynthesizerClient override methods. | 73 // PlatformSpeechSynthesizerClient override methods. |
77 virtual void voicesDidChange() OVERRIDE; | 74 virtual void voicesDidChange() OVERRIDE; |
78 virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; | 75 virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; |
79 virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; | 76 virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; |
80 virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; | 77 virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; |
81 virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; | 78 virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>)
OVERRIDE; |
82 virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran
ce>) OVERRIDE; | 79 virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran
ce>) OVERRIDE; |
83 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran
ce>, SpeechBoundary, unsigned charIndex) OVERRIDE; | 80 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran
ce>, SpeechBoundary, unsigned charIndex) OVERRIDE; |
84 | 81 |
85 void startSpeakingImmediately(SpeechSynthesisUtterance*); | 82 void startSpeakingImmediately(SpeechSynthesisUtterance*); |
86 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); | 83 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); |
87 void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned
long charIndex, const String& name); | 84 void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned
long charIndex, const String& name); |
88 | 85 |
89 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; | 86 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; |
90 WillBeHeapVector<RefPtrWillBeMember<SpeechSynthesisVoice> > m_voiceList; | 87 Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList; |
91 RawPtrWillBeMember<SpeechSynthesisUtterance> m_currentSpeechUtterance; | 88 SpeechSynthesisUtterance* m_currentSpeechUtterance; |
92 Deque<RefPtrWillBeMember<SpeechSynthesisUtterance> > m_utteranceQueue; | 89 Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue; |
93 bool m_isPaused; | 90 bool m_isPaused; |
94 | 91 |
95 // EventTarget | 92 // EventTarget |
96 virtual const AtomicString& interfaceName() const OVERRIDE; | 93 virtual const AtomicString& interfaceName() const OVERRIDE; |
97 }; | 94 }; |
98 | 95 |
99 } // namespace WebCore | 96 } // namespace WebCore |
100 | 97 |
101 #endif // SpeechSynthesisEvent_h | 98 #endif // SpeechSynthesisEvent_h |
OLD | NEW |