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

Unified Diff: Source/modules/speech/SpeechSynthesis.cpp

Issue 27477002: Add support for onvoiceschanged event. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@platform_speech_chromium
Patch Set: Check activeDOMObjectsAreStopped, address other feedback Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/speech/SpeechSynthesis.h ('k') | Source/modules/speech/SpeechSynthesis.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/speech/SpeechSynthesis.cpp
diff --git a/Source/modules/speech/SpeechSynthesis.cpp b/Source/modules/speech/SpeechSynthesis.cpp
index b12f14619b8048908e88318e40bf5c326eba2353..c2b7f5da90030b279a84ffd29bdba2532fb48cb1 100644
--- a/Source/modules/speech/SpeechSynthesis.cpp
+++ b/Source/modules/speech/SpeechSynthesis.cpp
@@ -27,6 +27,7 @@
#include "modules/speech/SpeechSynthesis.h"
#include "bindings/v8/ExceptionState.h"
+#include "core/dom/ExecutionContext.h"
#include "core/platform/PlatformSpeechSynthesisVoice.h"
#include "core/platform/PlatformSpeechSynthesizer.h"
#include "modules/speech/SpeechSynthesisEvent.h"
@@ -35,13 +36,14 @@
namespace WebCore {
-PassRefPtr<SpeechSynthesis> SpeechSynthesis::create()
+PassRefPtr<SpeechSynthesis> SpeechSynthesis::create(ExecutionContext* context)
{
- return adoptRef(new SpeechSynthesis());
+ return adoptRef(new SpeechSynthesis(context));
}
-SpeechSynthesis::SpeechSynthesis()
- : m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this))
+SpeechSynthesis::SpeechSynthesis(ExecutionContext* context)
+ : ContextLifecycleObserver(context)
+ , m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this))
, m_currentSpeechUtterance(0)
, m_isPaused(false)
{
@@ -53,9 +55,16 @@ void SpeechSynthesis::setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesize
m_platformSpeechSynthesizer = synthesizer;
}
+ExecutionContext* SpeechSynthesis::executionContext() const
+{
+ return ContextLifecycleObserver::executionContext();
+}
+
void SpeechSynthesis::voicesDidChange()
{
m_voiceList.clear();
+ if (!executionContext()->activeDOMObjectsAreStopped())
+ dispatchEvent(Event::create(EventTypeNames::voiceschanged));
}
const Vector<RefPtr<SpeechSynthesisVoice> >& SpeechSynthesis::getVoices()
@@ -142,7 +151,8 @@ void SpeechSynthesis::resume()
void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtterance* utterance, unsigned long charIndex, const String& name)
{
- utterance->dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, (currentTime() - utterance->startTime()), name));
+ if (!executionContext()->activeDOMObjectsAreStopped())
+ utterance->dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, (currentTime() - utterance->startTime()), name));
}
void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utterance, bool errorOccurred)
@@ -214,4 +224,9 @@ void SpeechSynthesis::speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUt
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), true);
}
+const AtomicString& SpeechSynthesis::interfaceName() const
+{
+ return EventTargetNames::SpeechSynthesisUtterance;
+}
+
} // namespace WebCore
« no previous file with comments | « Source/modules/speech/SpeechSynthesis.h ('k') | Source/modules/speech/SpeechSynthesis.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698