Changeset 144220 in webkit
- Timestamp:
- Feb 27, 2013 12:14:45 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r144215 r144220 1 2013-02-27 Chris Fleizach <cfleizach@apple.com> 2 3 WebSpeech: Support pause/resume ability 4 https://bugs.webkit.org/show_bug.cgi?id=107345 5 6 Reviewed by Beth Dakin. 7 8 * platform/mac/fast/speechsynthesis/speech-synthesis-pause-resume-expected.txt: Added. 9 * platform/mac/fast/speechsynthesis/speech-synthesis-pause-resume.html: Added. 10 1 11 2013-02-27 Stephen Chenney <schenney@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r144216 r144220 1 2013-02-27 Chris Fleizach <cfleizach@apple.com> 2 3 WebSpeech: Support pause/resume ability 4 https://bugs.webkit.org/show_bug.cgi?id=107345 5 6 Reviewed by Beth Dakin. 7 8 Add in the pause/resume functionality to SpeechSynthesis. Also hook up 9 the callback events. 10 11 Test: platform/mac/fast/speechsynthesis/speech-synthesis-pause-resume.html 12 13 * Modules/speech/SpeechSynthesis.cpp: 14 (WebCore::SpeechSynthesis::SpeechSynthesis): 15 (WebCore::SpeechSynthesis::pending): 16 (WebCore::SpeechSynthesis::paused): 17 (WebCore::SpeechSynthesis::startSpeakingImmediately): 18 (WebCore::SpeechSynthesis::pause): 19 (WebCore::SpeechSynthesis::resume): 20 (WebCore): 21 (WebCore::SpeechSynthesis::didPauseSpeaking): 22 (WebCore::SpeechSynthesis::didResumeSpeaking): 23 * Modules/speech/SpeechSynthesis.h: 24 (SpeechSynthesis): 25 * platform/PlatformSpeechSynthesizer.h: 26 (PlatformSpeechSynthesizerClient): 27 (PlatformSpeechSynthesizer): 28 * platform/mac/PlatformSpeechSynthesizerMac.mm: 29 (-[WebSpeechSynthesisWrapper speakUtterance:WebCore::]): 30 (-[WebSpeechSynthesisWrapper pause]): 31 (-[WebSpeechSynthesisWrapper resume]): 32 (-[WebSpeechSynthesisWrapper speechSynthesizer:didFinishSpeaking:]): 33 (WebCore::PlatformSpeechSynthesizer::pause): 34 (WebCore): 35 (WebCore::PlatformSpeechSynthesizer::resume): 36 1 37 2013-02-26 Alexey Proskuryakov <ap@apple.com> 2 38 -
trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp
r143136 r144220 45 45 : m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this)) 46 46 , m_currentSpeechUtterance(0) 47 , m_isPaused(false) 47 48 { 48 49 } … … 81 82 bool SpeechSynthesis::pending() const 82 83 { 83 return false; 84 // This is true if there are any utterances that have not started. 85 // That means there will be more than one in the queue. 86 return m_utteranceQueue.size() > 1; 84 87 } 85 88 86 89 bool SpeechSynthesis::paused() const 87 90 { 88 return false;91 return m_isPaused; 89 92 } 90 93 … … 94 97 utterance->setStartTime(monotonicallyIncreasingTime()); 95 98 m_currentSpeechUtterance = utterance; 99 m_isPaused = false; 96 100 m_platformSpeechSynthesizer->speak(utterance->platformUtterance()); 97 101 } … … 112 116 void SpeechSynthesis::pause() 113 117 { 118 if (!m_isPaused) 119 m_platformSpeechSynthesizer->pause(); 114 120 } 115 121 116 122 void SpeechSynthesis::resume() 117 123 { 124 m_platformSpeechSynthesizer->resume(); 118 125 } 119 126 … … 145 152 fireEvent(eventNames().startEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String()); 146 153 } 154 155 void SpeechSynthesis::didPauseSpeaking(const PlatformSpeechSynthesisUtterance* utterance) 156 { 157 m_isPaused = true; 158 fireEvent(eventNames().pauseEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String()); 159 } 160 161 void SpeechSynthesis::didResumeSpeaking(const PlatformSpeechSynthesisUtterance* utterance) 162 { 163 m_isPaused = false; 164 fireEvent(eventNames().resumeEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String()); 165 } 147 166 148 167 void SpeechSynthesis::didFinishSpeaking(const PlatformSpeechSynthesisUtterance* utterance) -
trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h
r143136 r144220 67 67 virtual void voicesDidChange() OVERRIDE; 68 68 virtual void didStartSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE; 69 virtual void didPauseSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE; 70 virtual void didResumeSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE; 69 71 virtual void didFinishSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE; 70 72 virtual void speakingErrorOccurred(const PlatformSpeechSynthesisUtterance*) OVERRIDE; … … 78 80 SpeechSynthesisUtterance* m_currentSpeechUtterance; 79 81 Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue; 80 82 bool m_isPaused; 81 83 }; 82 84 -
trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h
r143136 r144220 46 46 virtual void didStartSpeaking(const PlatformSpeechSynthesisUtterance*) = 0; 47 47 virtual void didFinishSpeaking(const PlatformSpeechSynthesisUtterance*) = 0; 48 virtual void didPauseSpeaking(const PlatformSpeechSynthesisUtterance*) = 0; 49 virtual void didResumeSpeaking(const PlatformSpeechSynthesisUtterance*) = 0; 48 50 virtual void speakingErrorOccurred(const PlatformSpeechSynthesisUtterance*) = 0; 49 51 … … 61 63 const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; } 62 64 virtual void speak(const PlatformSpeechSynthesisUtterance&); 65 virtual void pause(); 66 virtual void resume(); 63 67 64 68 PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; } -
trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm
r142503 r144220 99 99 } 100 100 101 NSString *voiceURI = nil; 101 102 if (utteranceVoiceByURI) 102 [m_synthesizer setVoice:utteranceVoiceByURI->voiceURI()];103 voiceURI = utteranceVoiceByURI->voiceURI(); 103 104 else if (utteranceVoiceByLanguage) 104 [m_synthesizer setVoice:utteranceVoiceByLanguage->voiceURI()];105 voiceURI = utteranceVoiceByLanguage->voiceURI(); 105 106 else 106 [m_synthesizer setVoice:[NSSpeechSynthesizer defaultVoice]]; 107 voiceURI = [NSSpeechSynthesizer defaultVoice]; 108 109 // Don't set the voice unless necessary. There's a bug in NSSpeechSynthesizer such that 110 // setting the voice for the first time will cause the first speechDone callback to report it was unsuccessful. 111 if (![[m_synthesizer voice] isEqualToString:voiceURI]) 112 [m_synthesizer setVoice:voiceURI]; 107 113 108 114 [m_synthesizer setRate:[self convertRateToWPM:utterance->rate()]]; … … 114 120 } 115 121 122 - (void)pause 123 { 124 if (!m_utterance) 125 return; 126 127 [m_synthesizer pauseSpeakingAtBoundary:NSSpeechImmediateBoundary]; 128 m_synthesizerObject->client()->didPauseSpeaking(m_utterance); 129 } 130 131 - (void)resume 132 { 133 if (!m_utterance) 134 return; 135 136 [m_synthesizer continueSpeaking]; 137 m_synthesizerObject->client()->didResumeSpeaking(m_utterance); 138 } 139 116 140 - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking 117 141 { 142 ASSERT(m_utterance); 118 143 UNUSED_PARAM(sender); 119 144 … … 154 179 } 155 180 181 void PlatformSpeechSynthesizer::pause() 182 { 183 [m_platformSpeechWrapper.get() pause]; 184 } 185 186 void PlatformSpeechSynthesizer::resume() 187 { 188 [m_platformSpeechWrapper.get() resume]; 189 } 190 156 191 void PlatformSpeechSynthesizer::speak(const PlatformSpeechSynthesisUtterance& utterance) 157 192 { -
trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp
r143136 r144220 66 66 m_utterance = &utterance; 67 67 client()->didStartSpeaking(m_utterance); 68 m_speakingFinishedTimer.startOneShot(0); 68 69 // Give the fake speech job some time so that pause and other functions have time to be called. 70 m_speakingFinishedTimer.startOneShot(.1); 69 71 } 70 72 73 void PlatformSpeechSynthesizerMock::pause() 74 { 75 client()->didPauseSpeaking(m_utterance); 76 } 77 78 void PlatformSpeechSynthesizerMock::resume() 79 { 80 client()->didResumeSpeaking(m_utterance); 81 } 82 83 71 84 } // namespace WebCore 72 85 -
trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.h
r143136 r144220 41 41 virtual ~PlatformSpeechSynthesizerMock(); 42 42 virtual void speak(const PlatformSpeechSynthesisUtterance&); 43 virtual void pause(); 44 virtual void resume(); 43 45 44 46 private:
Note: See TracChangeset
for help on using the changeset viewer.