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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 , m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this)) | 42 , m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this)) |
43 , m_isPaused(false) | 43 , m_isPaused(false) |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 void SpeechSynthesis::setPlatformSynthesizer(PlatformSpeechSynthesizer* synthesi
zer) | 47 void SpeechSynthesis::setPlatformSynthesizer(PlatformSpeechSynthesizer* synthesi
zer) |
48 { | 48 { |
49 m_platformSpeechSynthesizer = synthesizer; | 49 m_platformSpeechSynthesizer = synthesizer; |
50 } | 50 } |
51 | 51 |
52 ExecutionContext* SpeechSynthesis::executionContext() const | 52 ExecutionContext* SpeechSynthesis::getExecutionContext() const |
53 { | 53 { |
54 return ContextLifecycleObserver::executionContext(); | 54 return ContextLifecycleObserver::getExecutionContext(); |
55 } | 55 } |
56 | 56 |
57 void SpeechSynthesis::voicesDidChange() | 57 void SpeechSynthesis::voicesDidChange() |
58 { | 58 { |
59 m_voiceList.clear(); | 59 m_voiceList.clear(); |
60 if (executionContext() && !executionContext()->activeDOMObjectsAreStopped()) | 60 if (getExecutionContext() && !getExecutionContext()->activeDOMObjectsAreStop
ped()) |
61 dispatchEvent(Event::create(EventTypeNames::voiceschanged)); | 61 dispatchEvent(Event::create(EventTypeNames::voiceschanged)); |
62 } | 62 } |
63 | 63 |
64 const HeapVector<Member<SpeechSynthesisVoice>>& SpeechSynthesis::getVoices() | 64 const HeapVector<Member<SpeechSynthesisVoice>>& SpeechSynthesis::getVoices() |
65 { | 65 { |
66 if (m_voiceList.size()) | 66 if (m_voiceList.size()) |
67 return m_voiceList; | 67 return m_voiceList; |
68 | 68 |
69 // If the voiceList is empty, that's the cue to get the voices from the plat
form again. | 69 // If the voiceList is empty, that's the cue to get the voices from the plat
form again. |
70 const Vector<RefPtr<PlatformSpeechSynthesisVoice>>& platformVoices = m_platf
ormSpeechSynthesizer->voiceList(); | 70 const Vector<RefPtr<PlatformSpeechSynthesisVoice>>& platformVoices = m_platf
ormSpeechSynthesizer->voiceList(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 void SpeechSynthesis::resume() | 133 void SpeechSynthesis::resume() |
134 { | 134 { |
135 if (!currentSpeechUtterance()) | 135 if (!currentSpeechUtterance()) |
136 return; | 136 return; |
137 m_platformSpeechSynthesizer->resume(); | 137 m_platformSpeechSynthesizer->resume(); |
138 } | 138 } |
139 | 139 |
140 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtteran
ce* utterance, unsigned long charIndex, const String& name) | 140 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtteran
ce* utterance, unsigned long charIndex, const String& name) |
141 { | 141 { |
142 if (executionContext() && !executionContext()->activeDOMObjectsAreStopped()) | 142 if (getExecutionContext() && !getExecutionContext()->activeDOMObjectsAreStop
ped()) |
143 utterance->dispatchEvent(SpeechSynthesisEvent::create(type, utterance, c
harIndex, (currentTime() - utterance->startTime()), name)); | 143 utterance->dispatchEvent(SpeechSynthesisEvent::create(type, utterance, c
harIndex, (currentTime() - utterance->startTime()), name)); |
144 } | 144 } |
145 | 145 |
146 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc
e, bool errorOccurred) | 146 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc
e, bool errorOccurred) |
147 { | 147 { |
148 ASSERT(utterance); | 148 ASSERT(utterance); |
149 | 149 |
150 bool shouldStartSpeaking = false; | 150 bool shouldStartSpeaking = false; |
151 // If the utterance that completed was the one we're currently speaking, | 151 // If the utterance that completed was the one we're currently speaking, |
152 // remove it from the queue and start speaking the next one. | 152 // remove it from the queue and start speaking the next one. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 { | 232 { |
233 visitor->trace(m_platformSpeechSynthesizer); | 233 visitor->trace(m_platformSpeechSynthesizer); |
234 visitor->trace(m_voiceList); | 234 visitor->trace(m_voiceList); |
235 visitor->trace(m_utteranceQueue); | 235 visitor->trace(m_utteranceQueue); |
236 PlatformSpeechSynthesizerClient::trace(visitor); | 236 PlatformSpeechSynthesizerClient::trace(visitor); |
237 RefCountedGarbageCollectedEventTargetWithInlineData<SpeechSynthesis>::trace(
visitor); | 237 RefCountedGarbageCollectedEventTargetWithInlineData<SpeechSynthesis>::trace(
visitor); |
238 ContextLifecycleObserver::trace(visitor); | 238 ContextLifecycleObserver::trace(visitor); |
239 } | 239 } |
240 | 240 |
241 } // namespace blink | 241 } // namespace blink |
OLD | NEW |