Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(910)

Side by Side Diff: Source/modules/speech/SpeechSynthesis.h

Issue 27477002: Add support for onvoiceschanged event. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@platform_speech_chromium
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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"
31 #include "core/events/EventTarget.h"
30 #include "core/platform/PlatformSpeechSynthesisUtterance.h" 32 #include "core/platform/PlatformSpeechSynthesisUtterance.h"
31 #include "core/platform/PlatformSpeechSynthesizer.h" 33 #include "core/platform/PlatformSpeechSynthesizer.h"
32 #include "modules/speech/SpeechSynthesisUtterance.h" 34 #include "modules/speech/SpeechSynthesisUtterance.h"
33 #include "modules/speech/SpeechSynthesisVoice.h" 35 #include "modules/speech/SpeechSynthesisVoice.h"
34 #include "wtf/Deque.h" 36 #include "wtf/Deque.h"
35 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
36 #include "wtf/RefCounted.h" 38 #include "wtf/RefCounted.h"
37 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
38 40
39 namespace WebCore { 41 namespace WebCore {
40 42
41 class PlatformSpeechSynthesizerClient; 43 class PlatformSpeechSynthesizerClient;
42 class SpeechSynthesisVoice; 44 class SpeechSynthesisVoice;
43 45
44 class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public ScriptWra ppable, public RefCounted<SpeechSynthesis> { 46 class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public ScriptWra ppable, public RefCounted<SpeechSynthesis>, public ContextLifecycleObserver, pub lic EventTargetWithInlineData {
45 public: 47 public:
46 static PassRefPtr<SpeechSynthesis> create(); 48 static PassRefPtr<SpeechSynthesis> create(ExecutionContext*);
47 49
48 bool pending() const; 50 bool pending() const;
49 bool speaking() const; 51 bool speaking() const;
50 bool paused() const; 52 bool paused() const;
51 53
52 void speak(SpeechSynthesisUtterance*); 54 void speak(SpeechSynthesisUtterance*);
53 void cancel(); 55 void cancel();
54 void pause(); 56 void pause();
55 void resume(); 57 void resume();
56 58
57 const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices(); 59 const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices();
58 60
59 // Used in testing to use a mock platform synthesizer 61 // Used in testing to use a mock platform synthesizer
60 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); 62 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>);
61 63
64 DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged);
65
66 using RefCounted<SpeechSynthesis>::ref;
67 using RefCounted<SpeechSynthesis>::deref;
abarth-chromium 2013/10/16 19:25:06 There's a macro that does this work now, I believe
dmazzoni 2013/10/16 22:09:06 I can't seem to find it from a code search and a s
abarth-chromium 2013/10/17 02:00:53 http://src.chromium.org/viewvc/blink?view=revision
dmazzoni 2013/10/17 15:28:59 Thanks. No wonder I missed it, it hadn't even roll
68
69 virtual ExecutionContext* executionContext() const;
70
62 private: 71 private:
63 SpeechSynthesis(); 72 SpeechSynthesis(ExecutionContext*);
abarth-chromium 2013/10/16 19:25:06 Please mark one-argument constructors explicit.
dmazzoni 2013/10/16 22:09:06 Done.
64 73
65 // PlatformSpeechSynthesizerClient override methods. 74 // PlatformSpeechSynthesizerClient override methods.
66 virtual void voicesDidChange() OVERRIDE; 75 virtual void voicesDidChange() OVERRIDE;
67 virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 76 virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
68 virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 77 virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
69 virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 78 virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
70 virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 79 virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
71 virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>) OVERRIDE; 80 virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>) OVERRIDE;
72 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>, SpeechBoundary, unsigned charIndex) OVERRIDE; 81 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>, SpeechBoundary, unsigned charIndex) OVERRIDE;
73 82
74 void startSpeakingImmediately(SpeechSynthesisUtterance*); 83 void startSpeakingImmediately(SpeechSynthesisUtterance*);
75 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); 84 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred);
76 void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned long charIndex, const String& name); 85 void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned long charIndex, const String& name);
77 86
78 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; 87 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer;
79 Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList; 88 Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList;
80 SpeechSynthesisUtterance* m_currentSpeechUtterance; 89 SpeechSynthesisUtterance* m_currentSpeechUtterance;
81 Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue; 90 Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue;
82 bool m_isPaused; 91 bool m_isPaused;
92
93 // EventTarget
94 virtual const AtomicString& interfaceName() const OVERRIDE;
95 virtual void refEventTarget() OVERRIDE { ref(); }
96 virtual void derefEventTarget() OVERRIDE { deref(); }
83 }; 97 };
84 98
85 } // namespace WebCore 99 } // namespace WebCore
86 100
87 #endif // SpeechSynthesisEvent_h 101 #endif // SpeechSynthesisEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698