Diff
Modified: trunk/LayoutTests/ChangeLog (144678 => 144679)
--- trunk/LayoutTests/ChangeLog 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/LayoutTests/ChangeLog 2013-03-04 22:41:13 UTC (rev 144679)
@@ -1,3 +1,13 @@
+2013-03-04 Chris Fleizach <[email protected]>
+
+ WebSpeech: change voiceURI to voice
+ https://bugs.webkit.org/show_bug.cgi?id=110773
+
+ Reviewed by Tim Horton.
+
+ * platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice-expected.txt: Added.
+ * platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice.html: Added.
+
2013-03-04 Victor Costan <[email protected]>
Filename passed to FormData.append() takes precedence over filename in
Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice-expected.txt (0 => 144679)
--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice-expected.txt 2013-03-04 22:41:13 UTC (rev 144679)
@@ -0,0 +1,12 @@
+This tests that we can get synthesizer voices on the Mac
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Verify that setting and retrieving the voice works.
+PASS u.voice.name == voice.name is true
+Speech job finished successfully.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice.html (0 => 144679)
--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice.html (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice.html 2013-03-04 22:41:13 UTC (rev 144679)
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="console"></div>
+
+<script>
+ description("This tests that we can get synthesizer voices on the Mac");
+
+ if (window.internals)
+ window.internals.enableMockSpeechSynthesizer();
+
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ window.jsTestIsAsync = true;
+
+ var list = speechSynthesis.getVoices();
+ var voice = list[0];
+
+ // Start a very short speaking job that will finish quickly.
+ var u = new SpeechSynthesisUtterance("this is a test string.");
+ u.voice = voice;
+
+ debug("Verify that setting and retrieving the voice works.");
+ shouldBeTrue("u.voice.name == voice.name");
+
+ u._onend_ = function(event) {
+ debug("Speech job finished successfully.");
+ finishJSTest();
+ }
+
+ speechSynthesis.speak(u);
+
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (144678 => 144679)
--- trunk/Source/WebCore/ChangeLog 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/ChangeLog 2013-03-04 22:41:13 UTC (rev 144679)
@@ -1,3 +1,34 @@
+2013-03-04 Chris Fleizach <[email protected]>
+
+ WebSpeech: change voiceURI to voice
+ https://bugs.webkit.org/show_bug.cgi?id=110773
+
+ Reviewed by Tim Horton.
+
+ Change the voiceURI property to a voice property that takes a SpeechSynthesisVoice.
+ This was recently added to the errata of the WebSpeech spec.
+
+ Test: platform/mac/fast/speechsynthesis/speech-synthesis-utterance-uses-voice.html
+
+ * Modules/speech/SpeechSynthesisUtterance.cpp:
+ (WebCore):
+ (WebCore::SpeechSynthesisUtterance::voice):
+ (WebCore::SpeechSynthesisUtterance::setVoice):
+ * Modules/speech/SpeechSynthesisUtterance.h:
+ (SpeechSynthesisUtterance):
+ * Modules/speech/SpeechSynthesisUtterance.idl:
+ * Modules/speech/SpeechSynthesisVoice.h:
+ (WebCore::SpeechSynthesisVoice::platformVoice):
+ (SpeechSynthesisVoice):
+ * platform/PlatformSpeechSynthesisUtterance.cpp:
+ (WebCore::PlatformSpeechSynthesisUtterance::PlatformSpeechSynthesisUtterance):
+ * platform/PlatformSpeechSynthesisUtterance.h:
+ (WebCore::PlatformSpeechSynthesisUtterance::voice):
+ (WebCore::PlatformSpeechSynthesisUtterance::setVoice):
+ (PlatformSpeechSynthesisUtterance):
+ * platform/mac/PlatformSpeechSynthesizerMac.mm:
+ (-[WebSpeechSynthesisWrapper speakUtterance:WebCore::]):
+
2013-03-04 Victor Costan <[email protected]>
Filename passed to FormData.append() takes precedence over filename in
Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp (144678 => 144679)
--- trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp 2013-03-04 22:41:13 UTC (rev 144679)
@@ -51,7 +51,22 @@
{
return eventNames().interfaceForSpeechSynthesisUtterance;
}
+
+SpeechSynthesisVoice* SpeechSynthesisUtterance::voice() const
+{
+ return m_voice.get();
+}
+
+void SpeechSynthesisUtterance::setVoice(SpeechSynthesisVoice* voice)
+{
+ // Cache our own version of the SpeechSynthesisVoice so that we don't have to do some lookup
+ // to go from the platform voice back to the speech synthesis voice in the read property.
+ m_voice = voice;
+ if (voice)
+ m_platformUtterance.setVoice(voice->platformVoice());
+}
+
} // namespace WebCore
#endif // ENABLE(SPEECH_SYNTHESIS)
Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h (144678 => 144679)
--- trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h 2013-03-04 22:41:13 UTC (rev 144679)
@@ -31,6 +31,7 @@
#include "ContextDestructionObserver.h"
#include "EventTarget.h"
#include "PlatformSpeechSynthesisUtterance.h"
+#include "SpeechSynthesisVoice.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -46,8 +47,8 @@
const String& lang() const { return m_platformUtterance.lang(); }
void setLang(const String& lang) { m_platformUtterance.setLang(lang); }
- const String& voiceURI() const { return m_platformUtterance.voiceURI(); }
- void setVoiceURI(const String& voiceURI) { m_platformUtterance.setVoiceURI(voiceURI); }
+ SpeechSynthesisVoice* voice() const;
+ void setVoice(SpeechSynthesisVoice*);
float volume() const { return m_platformUtterance.volume(); }
void setVolume(float volume) { m_platformUtterance.setVolume(volume); }
@@ -79,6 +80,7 @@
private:
SpeechSynthesisUtterance(ScriptExecutionContext*, const String&);
PlatformSpeechSynthesisUtterance m_platformUtterance;
+ RefPtr<SpeechSynthesisVoice> m_voice;
// EventTarget
EventTargetData m_eventTargetData;
Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl (144678 => 144679)
--- trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl 2013-03-04 22:41:13 UTC (rev 144679)
@@ -31,7 +31,7 @@
] interface SpeechSynthesisUtterance {
attribute DOMString text;
attribute DOMString lang;
- attribute DOMString voiceURI;
+ attribute SpeechSynthesisVoice voice;
attribute float volume;
attribute float rate;
attribute float pitch;
Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h (144678 => 144679)
--- trunk/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h 2013-03-04 22:41:13 UTC (rev 144679)
@@ -45,6 +45,8 @@
bool localService() const { return m_platformVoice->localService(); }
bool isDefault() const { return m_platformVoice->isDefault(); }
+ PlatformSpeechSynthesisVoice* platformVoice() const { return m_platformVoice.get(); }
+
private:
explicit SpeechSynthesisVoice(PassRefPtr<PlatformSpeechSynthesisVoice>);
Modified: trunk/Source/WebCore/platform/PlatformSpeechSynthesisUtterance.h (144678 => 144679)
--- trunk/Source/WebCore/platform/PlatformSpeechSynthesisUtterance.h 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/platform/PlatformSpeechSynthesisUtterance.h 2013-03-04 22:41:13 UTC (rev 144679)
@@ -28,6 +28,7 @@
#if ENABLE(SPEECH_SYNTHESIS)
+#include "PlatformSpeechSynthesisVoice.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -49,9 +50,9 @@
const String& lang() const { return m_lang; }
void setLang(const String& lang) { m_lang = lang; }
- const String& voiceURI() const { return m_voiceURI; }
- void setVoiceURI(const String& voiceURI) { m_voiceURI = voiceURI; }
-
+ PlatformSpeechSynthesisVoice* voice() const { return m_voice.get(); }
+ void setVoice(PlatformSpeechSynthesisVoice* voice) { m_voice = voice; }
+
// Range = [0, 1] where 1 is the default.
float volume() const { return m_volume; }
void setVolume(float volume) { m_volume = std::max(std::min(1.0f, volume), 0.0f); }
@@ -73,7 +74,7 @@
PlatformSpeechSynthesisUtteranceClient* m_client;
String m_text;
String m_lang;
- String m_voiceURI;
+ RefPtr<PlatformSpeechSynthesisVoice> m_voice;
float m_volume;
float m_rate;
float m_pitch;
Modified: trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm (144678 => 144679)
--- trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm 2013-03-04 22:29:43 UTC (rev 144678)
+++ trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm 2013-03-04 22:41:13 UTC (rev 144679)
@@ -98,26 +98,20 @@
Vector<RefPtr<WebCore::PlatformSpeechSynthesisVoice> > voiceList = m_synthesizerObject->voiceList();
size_t voiceListSize = voiceList.size();
- WebCore::PlatformSpeechSynthesisVoice *utteranceVoiceByURI = 0;
- WebCore::PlatformSpeechSynthesisVoice *utteranceVoiceByLanguage = 0;
- for (size_t k = 0; k < voiceListSize; k++) {
- if (utterance->voiceURI() == voiceList[k]->voiceURI()) {
- utteranceVoiceByURI = voiceList[k].get();
- break;
- } else if (!utteranceVoiceByLanguage && equalIgnoringCase(utterance->lang(), voiceList[k]->lang())) {
- utteranceVoiceByLanguage = voiceList[k].get();
-
- // If there was no voiceURI specified, then once we find a language we're good to go.
- if (utterance->voiceURI().isEmpty())
+ WebCore::PlatformSpeechSynthesisVoice* utteranceVoice = utterance->voice();
+ // If no voice was specified, try to match by language.
+ if (!utteranceVoice && !utterance->lang().isEmpty()) {
+ for (size_t k = 0; k < voiceListSize; k++) {
+ if (equalIgnoringCase(utterance->lang(), voiceList[k]->lang())) {
+ utteranceVoice = voiceList[k].get();
break;
+ }
}
}
NSString *voiceURI = nil;
- if (utteranceVoiceByURI)
- voiceURI = utteranceVoiceByURI->voiceURI();
- else if (utteranceVoiceByLanguage)
- voiceURI = utteranceVoiceByLanguage->voiceURI();
+ if (utteranceVoice)
+ voiceURI = utteranceVoice->voiceURI();
else
voiceURI = [NSSpeechSynthesizer defaultVoice];