| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtteran
ce* utterance, unsigned long charIndex, const String& name) | 146 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtteran
ce* utterance, unsigned long charIndex, const String& name) |
| 147 { | 147 { |
| 148 if (!executionContext()->activeDOMObjectsAreStopped()) | 148 if (!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 // Keep the utterance around long enough to fire an event on it in case m_ut
teranceQueue |
| 157 // is holding the last reference to it. |
| 158 RefPtrWillBeRawPtr<SpeechSynthesisUtterance> protect(utterance); |
| 159 |
| 156 bool didJustFinishCurrentUtterance = false; | 160 bool didJustFinishCurrentUtterance = false; |
| 157 // If the utterance that completed was the one we're currently speaking, | 161 // If the utterance that completed was the one we're currently speaking, |
| 158 // remove it from the queue and start speaking the next one. | 162 // remove it from the queue and start speaking the next one. |
| 159 if (utterance == currentSpeechUtterance()) { | 163 if (utterance == currentSpeechUtterance()) { |
| 160 m_utteranceQueue.removeFirst(); | 164 m_utteranceQueue.removeFirst(); |
| 161 didJustFinishCurrentUtterance = true; | 165 didJustFinishCurrentUtterance = true; |
| 162 } | 166 } |
| 163 | 167 |
| 164 // Always fire the event, because the platform may have asynchronously | 168 // Always fire the event, because the platform may have asynchronously |
| 165 // sent an event on an utterance before it got the message that we | 169 // sent an event on an utterance before it got the message that we |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return EventTargetNames::SpeechSynthesisUtterance; | 237 return EventTargetNames::SpeechSynthesisUtterance; |
| 234 } | 238 } |
| 235 | 239 |
| 236 void SpeechSynthesis::trace(Visitor* visitor) | 240 void SpeechSynthesis::trace(Visitor* visitor) |
| 237 { | 241 { |
| 238 visitor->trace(m_voiceList); | 242 visitor->trace(m_voiceList); |
| 239 visitor->trace(m_utteranceQueue); | 243 visitor->trace(m_utteranceQueue); |
| 240 } | 244 } |
| 241 | 245 |
| 242 } // namespace WebCore | 246 } // namespace WebCore |
| OLD | NEW |