Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: Source/modules/speech/SpeechSynthesis.cpp

Issue 330603002: Make SpeechSynthesis gracefully handle ExecutionContext-less operation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 ExecutionContext* SpeechSynthesis::executionContext() const 55 ExecutionContext* SpeechSynthesis::executionContext() const
56 { 56 {
57 return ContextLifecycleObserver::executionContext(); 57 return ContextLifecycleObserver::executionContext();
58 } 58 }
59 59
60 void SpeechSynthesis::voicesDidChange() 60 void SpeechSynthesis::voicesDidChange()
61 { 61 {
62 m_voiceList.clear(); 62 m_voiceList.clear();
63 if (!executionContext()->activeDOMObjectsAreStopped()) 63 if (executionContext() && !executionContext()->activeDOMObjectsAreStopped())
64 dispatchEvent(Event::create(EventTypeNames::voiceschanged)); 64 dispatchEvent(Event::create(EventTypeNames::voiceschanged));
65 } 65 }
66 66
67 const WillBeHeapVector<RefPtrWillBeMember<SpeechSynthesisVoice> >& SpeechSynthes is::getVoices() 67 const WillBeHeapVector<RefPtrWillBeMember<SpeechSynthesisVoice> >& SpeechSynthes is::getVoices()
68 { 68 {
69 if (m_voiceList.size()) 69 if (m_voiceList.size())
70 return m_voiceList; 70 return m_voiceList;
71 71
72 // If the voiceList is empty, that's the cue to get the voices from the plat form again. 72 // If the voiceList is empty, that's the cue to get the voices from the plat form again.
73 const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& platformVoices = m_plat formSpeechSynthesizer->voiceList(); 73 const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& platformVoices = m_plat formSpeechSynthesizer->voiceList();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 void SpeechSynthesis::resume() 139 void SpeechSynthesis::resume()
140 { 140 {
141 if (!currentSpeechUtterance()) 141 if (!currentSpeechUtterance())
142 return; 142 return;
143 m_platformSpeechSynthesizer->resume(); 143 m_platformSpeechSynthesizer->resume();
144 } 144 }
145 145
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() && !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 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. 157 // is holding the last reference to it.
158 RefPtrWillBeRawPtr<SpeechSynthesisUtterance> protect(utterance); 158 RefPtrWillBeRawPtr<SpeechSynthesisUtterance> protect(utterance);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 239
240 void SpeechSynthesis::trace(Visitor* visitor) 240 void SpeechSynthesis::trace(Visitor* visitor)
241 { 241 {
242 visitor->trace(m_voiceList); 242 visitor->trace(m_voiceList);
243 visitor->trace(m_utteranceQueue); 243 visitor->trace(m_utteranceQueue);
244 EventTargetWithInlineData::trace(visitor); 244 EventTargetWithInlineData::trace(visitor);
245 } 245 }
246 246
247 } // namespace WebCore 247 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698