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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 { | 147 { |
148 if (executionContext() && !executionContext()->activeDOMObjectsAreStopped()) | 148 if (executionContext() && !executionContext()->activeDOMObjectsAreStopped()) |
149 utterance->dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, ( currentTime() - utterance->startTime()), name)); | 149 utterance->dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, ( currentTime() - utterance->startTime()), name)); |
150 } | 150 } |
151 | 151 |
152 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc e, bool errorOccurred) | 152 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc e, bool errorOccurred) |
153 { | 153 { |
154 ASSERT(utterance); | 154 ASSERT(utterance); |
155 | 155 |
156 bool didJustFinishCurrentUtterance = false; | 156 bool didJustFinishCurrentUtterance = false; |
157 int oldQueueSize = 0; | |
haraken
2014/08/21 01:01:22
Can we introduce something like a |shouldStartSpea
| |
157 // If the utterance that completed was the one we're currently speaking, | 158 // If the utterance that completed was the one we're currently speaking, |
158 // remove it from the queue and start speaking the next one. | 159 // remove it from the queue and start speaking the next one. |
159 if (utterance == currentSpeechUtterance()) { | 160 if (utterance == currentSpeechUtterance()) { |
160 m_utteranceQueue.removeFirst(); | 161 m_utteranceQueue.removeFirst(); |
162 oldQueueSize = m_utteranceQueue.size(); | |
161 didJustFinishCurrentUtterance = true; | 163 didJustFinishCurrentUtterance = true; |
162 } | 164 } |
163 | 165 |
164 // Always fire the event, because the platform may have asynchronously | 166 // Always fire the event, because the platform may have asynchronously |
165 // sent an event on an utterance before it got the message that we | 167 // sent an event on an utterance before it got the message that we |
166 // canceled it, and we should always report to the user what actually | 168 // canceled it, and we should always report to the user what actually |
167 // happened. | 169 // happened. |
168 fireEvent(errorOccurred ? EventTypeNames::error : EventTypeNames::end, utter ance, 0, String()); | 170 fireEvent(errorOccurred ? EventTypeNames::error : EventTypeNames::end, utter ance, 0, String()); |
169 | 171 |
170 // Start the next utterance if we just finished one and one was pending. | 172 // Start the next utterance if we just finished one and one was pending. |
171 if (didJustFinishCurrentUtterance && !m_utteranceQueue.isEmpty() && !utteran ce->startTime()) | 173 if (didJustFinishCurrentUtterance && !m_utteranceQueue.isEmpty() && oldQueue Size) |
172 startSpeakingImmediately(); | 174 startSpeakingImmediately(); |
173 } | 175 } |
174 | 176 |
175 void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance* ut terance, SpeechBoundary boundary, unsigned charIndex) | 177 void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance* ut terance, SpeechBoundary boundary, unsigned charIndex) |
176 { | 178 { |
177 DEFINE_STATIC_LOCAL(const String, wordBoundaryString, ("word")); | 179 DEFINE_STATIC_LOCAL(const String, wordBoundaryString, ("word")); |
178 DEFINE_STATIC_LOCAL(const String, sentenceBoundaryString, ("sentence")); | 180 DEFINE_STATIC_LOCAL(const String, sentenceBoundaryString, ("sentence")); |
179 | 181 |
180 switch (boundary) { | 182 switch (boundary) { |
181 case SpeechWordBoundary: | 183 case SpeechWordBoundary: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 void SpeechSynthesis::trace(Visitor* visitor) | 238 void SpeechSynthesis::trace(Visitor* visitor) |
237 { | 239 { |
238 visitor->trace(m_platformSpeechSynthesizer); | 240 visitor->trace(m_platformSpeechSynthesizer); |
239 visitor->trace(m_voiceList); | 241 visitor->trace(m_voiceList); |
240 visitor->trace(m_utteranceQueue); | 242 visitor->trace(m_utteranceQueue); |
241 PlatformSpeechSynthesizerClient::trace(visitor); | 243 PlatformSpeechSynthesizerClient::trace(visitor); |
242 EventTargetWithInlineData::trace(visitor); | 244 EventTargetWithInlineData::trace(visitor); |
243 } | 245 } |
244 | 246 |
245 } // namespace blink | 247 } // namespace blink |
OLD | NEW |