@@ -167,7 +167,7 @@ void SpeechSynthesis::cancel()
167167 m_speechSynthesisClient->cancel ();
168168 // If we wait for cancel to callback speakingErrorOccurred, then m_currentSpeechUtterance will be null
169169 // and the event won't be processed. Instead we process the error immediately.
170- speakingErrorOccurred ();
170+ speakingErrorOccurred (SpeechSynthesisErrorCode::Canceled );
171171 m_currentSpeechUtterance = nullptr ;
172172 } else if (m_platformSpeechSynthesizer)
173173 m_platformSpeechSynthesizer->cancel ();
@@ -195,18 +195,18 @@ void SpeechSynthesis::resume()
195195 }
196196}
197197
198- void SpeechSynthesis::handleSpeakingCompleted (SpeechSynthesisUtterance& utterance, bool errorOccurred )
198+ void SpeechSynthesis::handleSpeakingCompleted (SpeechSynthesisUtterance& utterance, std::optional<SpeechSynthesisErrorCode> error )
199199{
200200 ASSERT (m_currentSpeechUtterance);
201201 Ref<SpeechSynthesisUtterance> protect (utterance);
202202
203203 m_currentSpeechUtterance = nullptr ;
204204
205- if (errorOccurred )
206- utterance.errorEventOccurred (eventNames ().errorEvent , SpeechSynthesisErrorCode::Canceled );
205+ if (error )
206+ utterance.errorEventOccurred (eventNames ().errorEvent , *error );
207207 else
208208 utterance.eventOccurred (eventNames ().endEvent , 0 , 0 , String ());
209-
209+
210210 if (m_utteranceQueue.size ()) {
211211 Ref<SpeechSynthesisUtterance> firstUtterance = m_utteranceQueue.takeFirst ();
212212 ASSERT (&utterance == firstUtterance.ptr ());
@@ -265,11 +265,11 @@ void SpeechSynthesis::didResumeSpeaking()
265265 didResumeSpeaking (*m_currentSpeechUtterance->platformUtterance ());
266266}
267267
268- void SpeechSynthesis::speakingErrorOccurred ()
268+ void SpeechSynthesis::speakingErrorOccurred (std::optional<SpeechSynthesisErrorCode> error )
269269{
270270 if (!m_currentSpeechUtterance)
271271 return ;
272- speakingErrorOccurred (*m_currentSpeechUtterance->platformUtterance ());
272+ speakingErrorOccurred (*m_currentSpeechUtterance->platformUtterance (), error );
273273}
274274
275275void SpeechSynthesis::boundaryEventOccurred (bool wordBoundary, unsigned charIndex, unsigned charLength)
@@ -307,13 +307,13 @@ void SpeechSynthesis::didResumeSpeaking(PlatformSpeechSynthesisUtterance& uttera
307307void SpeechSynthesis::didFinishSpeaking (PlatformSpeechSynthesisUtterance& utterance)
308308{
309309 if (utterance.client ())
310- handleSpeakingCompleted (static_cast <SpeechSynthesisUtterance&>(*utterance.client ()), false );
310+ handleSpeakingCompleted (static_cast <SpeechSynthesisUtterance&>(*utterance.client ()), std:: nullopt );
311311}
312312
313- void SpeechSynthesis::speakingErrorOccurred (PlatformSpeechSynthesisUtterance& utterance)
313+ void SpeechSynthesis::speakingErrorOccurred (PlatformSpeechSynthesisUtterance& utterance, std::optional<SpeechSynthesisErrorCode> error )
314314{
315315 if (utterance.client ())
316- handleSpeakingCompleted (static_cast <SpeechSynthesisUtterance&>(*utterance.client ()), true );
316+ handleSpeakingCompleted (static_cast <SpeechSynthesisUtterance&>(*utterance.client ()), error );
317317}
318318
319319} // namespace WebCore
0 commit comments