mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1162692 - Add SpeechSynthesisUtterance.chosenVoiceURI for testing purposes. r=smaug
This commit is contained in:
parent
dc5fad2c10
commit
fa57071cf6
@ -147,6 +147,12 @@ SpeechSynthesisUtterance::SetPitch(float aPitch)
|
||||
mPitch = aPitch;
|
||||
}
|
||||
|
||||
void
|
||||
SpeechSynthesisUtterance::GetChosenVoiceURI(nsString& aResult) const
|
||||
{
|
||||
aResult = mChosenVoiceURI;
|
||||
}
|
||||
|
||||
void
|
||||
SpeechSynthesisUtterance::DispatchSpeechSynthesisEvent(const nsAString& aEventType,
|
||||
uint32_t aCharIndex,
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
|
||||
void SetPitch(float aPitch);
|
||||
|
||||
void GetChosenVoiceURI(nsString& aResult) const;
|
||||
|
||||
enum {
|
||||
STATE_NONE,
|
||||
STATE_PENDING,
|
||||
@ -107,6 +109,8 @@ private:
|
||||
|
||||
float mPitch;
|
||||
|
||||
nsString mChosenVoiceURI;
|
||||
|
||||
uint32_t mState;
|
||||
|
||||
bool mPaused;
|
||||
|
@ -25,7 +25,7 @@ async protocol PSpeechSynthesisRequest
|
||||
|
||||
__delete__(bool aIsError, float aElapsedTime, uint32_t aCharIndex);
|
||||
|
||||
OnStart();
|
||||
OnStart(nsString aUri);
|
||||
|
||||
OnPause(float aElapsedTime, uint32_t aCharIndex);
|
||||
|
||||
|
@ -73,9 +73,9 @@ SpeechSynthesisRequestChild::~SpeechSynthesisRequestChild()
|
||||
}
|
||||
|
||||
bool
|
||||
SpeechSynthesisRequestChild::RecvOnStart()
|
||||
SpeechSynthesisRequestChild::RecvOnStart(const nsString& aUri)
|
||||
{
|
||||
mTask->DispatchStartImpl();
|
||||
mTask->DispatchStartImpl(aUri);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
virtual ~SpeechSynthesisRequestChild();
|
||||
|
||||
protected:
|
||||
virtual bool RecvOnStart() override;
|
||||
virtual bool RecvOnStart(const nsString& aUri) override;
|
||||
|
||||
virtual bool Recv__delete__(const bool& aIsError,
|
||||
const float& aElapsedTime,
|
||||
|
@ -120,10 +120,10 @@ SpeechSynthesisRequestParent::RecvCancel()
|
||||
// SpeechTaskParent
|
||||
|
||||
nsresult
|
||||
SpeechTaskParent::DispatchStartImpl()
|
||||
SpeechTaskParent::DispatchStartImpl(const nsAString& aUri)
|
||||
{
|
||||
MOZ_ASSERT(mActor);
|
||||
NS_ENSURE_TRUE(mActor->SendOnStart(), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mActor->SendOnStart(nsString(aUri)), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
SpeechTaskParent(float aVolume, const nsAString& aUtterance)
|
||||
: nsSpeechTask(aVolume, aUtterance) {}
|
||||
|
||||
virtual nsresult DispatchStartImpl();
|
||||
virtual nsresult DispatchStartImpl(const nsAString& aUri);
|
||||
|
||||
virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
|
||||
|
||||
|
@ -140,6 +140,12 @@ nsSpeechTask::BindStream(ProcessedMediaStream* aStream)
|
||||
mPort = aStream->AllocateInputPort(mStream, 0);
|
||||
}
|
||||
|
||||
void
|
||||
nsSpeechTask::SetChosenVoiceURI(const nsAString& aUri)
|
||||
{
|
||||
mChosenVoiceURI = aUri;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSpeechTask::Setup(nsISpeechTaskCallback* aCallback,
|
||||
uint32_t aChannels, uint32_t aRate, uint8_t argc)
|
||||
@ -281,6 +287,12 @@ nsSpeechTask::DispatchStart()
|
||||
|
||||
nsresult
|
||||
nsSpeechTask::DispatchStartImpl()
|
||||
{
|
||||
return DispatchStartImpl(mChosenVoiceURI);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSpeechTask::DispatchStartImpl(const nsAString& aUri)
|
||||
{
|
||||
LOG(PR_LOG_DEBUG, ("nsSpeechTask::DispatchStart"));
|
||||
|
||||
@ -289,6 +301,7 @@ nsSpeechTask::DispatchStartImpl()
|
||||
NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
mUtterance->mState = SpeechSynthesisUtterance::STATE_SPEAKING;
|
||||
mUtterance->mChosenVoiceURI = aUri;
|
||||
mUtterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("start"), 0, 0,
|
||||
NS_LITERAL_STRING(""));
|
||||
|
||||
|
@ -47,10 +47,14 @@ public:
|
||||
|
||||
void BindStream(ProcessedMediaStream* aStream);
|
||||
|
||||
void SetChosenVoiceURI(const nsAString& aUri);
|
||||
|
||||
protected:
|
||||
virtual ~nsSpeechTask();
|
||||
|
||||
virtual nsresult DispatchStartImpl();
|
||||
nsresult DispatchStartImpl();
|
||||
|
||||
virtual nsresult DispatchStartImpl(const nsAString& aUri);
|
||||
|
||||
virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
|
||||
|
||||
@ -89,6 +93,8 @@ private:
|
||||
nsRefPtr<SpeechSynthesis> mSpeechSynthesis;
|
||||
|
||||
bool mIndirectAudio;
|
||||
|
||||
nsString mChosenVoiceURI;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -561,6 +561,8 @@ nsSynthVoiceRegistry::Speak(const nsAString& aText,
|
||||
|
||||
VoiceData* voice = FindBestMatch(aUri, aLang);
|
||||
|
||||
aTask->SetChosenVoiceURI(voice->mUri);
|
||||
|
||||
if (!voice) {
|
||||
NS_WARNING("No voices found.");
|
||||
aTask->DispatchError(0, 0);
|
||||
|
@ -28,4 +28,7 @@ interface SpeechSynthesisUtterance : EventTarget {
|
||||
attribute EventHandler onresume;
|
||||
attribute EventHandler onmark;
|
||||
attribute EventHandler onboundary;
|
||||
|
||||
[ChromeOnly]
|
||||
readonly attribute DOMString chosenVoiceURI;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user