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

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: Check activeDOMObjectsAreStopped, address other feedback 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 ExceptionState; 43 class ExceptionState;
42 class PlatformSpeechSynthesizerClient; 44 class PlatformSpeechSynthesizerClient;
43 class SpeechSynthesisVoice; 45 class SpeechSynthesisVoice;
44 46
45 class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public ScriptWra ppable, public RefCounted<SpeechSynthesis> { 47 class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public ScriptWra ppable, public RefCounted<SpeechSynthesis>, public ContextLifecycleObserver, pub lic EventTargetWithInlineData {
48 REFCOUNTED_EVENT_TARGET(SpeechSynthesis);
46 public: 49 public:
47 static PassRefPtr<SpeechSynthesis> create(); 50 static PassRefPtr<SpeechSynthesis> create(ExecutionContext*);
48 51
49 bool pending() const; 52 bool pending() const;
50 bool speaking() const; 53 bool speaking() const;
51 bool paused() const; 54 bool paused() const;
52 55
53 void speak(SpeechSynthesisUtterance*, ExceptionState&); 56 void speak(SpeechSynthesisUtterance*, ExceptionState&);
54 void cancel(); 57 void cancel();
55 void pause(); 58 void pause();
56 void resume(); 59 void resume();
57 60
58 const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices(); 61 const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices();
59 62
60 // Used in testing to use a mock platform synthesizer 63 // Used in testing to use a mock platform synthesizer
61 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); 64 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>);
62 65
66 DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged);
67
68 virtual ExecutionContext* executionContext() const;
69
63 private: 70 private:
64 SpeechSynthesis(); 71 explicit SpeechSynthesis(ExecutionContext*);
65 72
66 // PlatformSpeechSynthesizerClient override methods. 73 // PlatformSpeechSynthesizerClient override methods.
67 virtual void voicesDidChange() OVERRIDE; 74 virtual void voicesDidChange() OVERRIDE;
68 virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 75 virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
69 virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 76 virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
70 virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 77 virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
71 virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; 78 virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
72 virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>) OVERRIDE; 79 virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>) OVERRIDE;
73 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>, SpeechBoundary, unsigned charIndex) OVERRIDE; 80 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran ce>, SpeechBoundary, unsigned charIndex) OVERRIDE;
74 81
75 void startSpeakingImmediately(SpeechSynthesisUtterance*); 82 void startSpeakingImmediately(SpeechSynthesisUtterance*);
76 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); 83 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred);
77 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);
78 85
79 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; 86 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer;
80 Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList; 87 Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList;
81 SpeechSynthesisUtterance* m_currentSpeechUtterance; 88 SpeechSynthesisUtterance* m_currentSpeechUtterance;
82 Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue; 89 Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue;
83 bool m_isPaused; 90 bool m_isPaused;
91
92 // EventTarget
93 virtual const AtomicString& interfaceName() const OVERRIDE;
84 }; 94 };
85 95
86 } // namespace WebCore 96 } // namespace WebCore
87 97
88 #endif // SpeechSynthesisEvent_h 98 #endif // SpeechSynthesisEvent_h
OLDNEW
« no previous file with comments | « Source/modules/speech/DOMWindowSpeechSynthesis.cpp ('k') | Source/modules/speech/SpeechSynthesis.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698