Backed out changeset 4c66c0ddf562 (bug 1178738)

This commit is contained in:
Sebastian Hengst 2016-06-02 20:32:46 +02:00
Родитель af455b44c1
Коммит 4263412d7e
9 изменённых файлов: 24 добавлений и 53 удалений

Просмотреть файл

@ -35,7 +35,6 @@ public:
: mTask(aTask)
, mSpeechSynthesizer(aSynth)
, mOffsets(aOffsets)
, mCanceled(false)
{
mStartingTime = TimeStamp::Now();
}
@ -62,7 +61,6 @@ private:
TimeStamp mStartingTime;
uint32_t mCurrentIndex;
nsTArray<size_t> mOffsets;
bool mCanceled;
};
NS_IMPL_CYCLE_COLLECTION(SpeechTaskCallback, mTask);
@ -80,7 +78,6 @@ SpeechTaskCallback::OnCancel()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
mCanceled = true;
[mSpeechSynthesizer stopSpeaking];
return NS_OK;
@ -166,12 +163,7 @@ SpeechTaskCallback::OnError(uint32_t aIndex)
void
SpeechTaskCallback::OnDidFinishSpeaking()
{
if (mCanceled) {
mTask->DispatchError(GetTimeDurationFromStart(), mCurrentIndex,
uint32_t(dom::SpeechSynthesisErrorCode::Interrupted));
} else {
mTask->DispatchEnd(GetTimeDurationFromStart(), mCurrentIndex);
}
// no longer needed
[mSpeechSynthesizer setDelegate:nil];
mTask = nullptr;

Просмотреть файл

@ -411,7 +411,7 @@ nsSpeechTask::DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex)
DestroyAudioChannelAgent();
MOZ_ASSERT(mUtterance);
if(NS_WARN_IF(mUtterance->mState != SpeechSynthesisUtterance::STATE_SPEAKING)) {
if(NS_WARN_IF(mUtterance->mState == SpeechSynthesisUtterance::STATE_ENDED)) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -426,10 +426,14 @@ nsSpeechTask::DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex)
mSpeechSynthesis->OnEnd(this);
}
if (utterance->mState == SpeechSynthesisUtterance::STATE_PENDING) {
utterance->mState = SpeechSynthesisUtterance::STATE_NONE;
} else {
utterance->mState = SpeechSynthesisUtterance::STATE_ENDED;
utterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("end"),
aCharIndex, aElapsedTime,
EmptyString());
}
return NS_OK;
}
@ -509,12 +513,6 @@ nsSpeechTask::DispatchError(float aElapsedTime, uint32_t aCharIndex, uint32_t aE
return NS_ERROR_FAILURE;
}
return DispatchErrorInner(aElapsedTime, aCharIndex, aError);
}
nsresult
nsSpeechTask::DispatchErrorInner(float aElapsedTime, uint32_t aCharIndex, uint32_t aError)
{
if (!mPreCanceled) {
nsSynthVoiceRegistry::GetInstance()->SpeakNext();
}
@ -534,12 +532,9 @@ nsSpeechTask::DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex, uint32_
mSpeechSynthesis->OnEnd(this);
}
RefPtr<SpeechSynthesisUtterance> utterance = mUtterance;
utterance->mState = (utterance->mState == SpeechSynthesisUtterance::STATE_SPEAKING) ?
SpeechSynthesisUtterance::STATE_ENDED : SpeechSynthesisUtterance::STATE_NONE;
utterance->DispatchSpeechSynthesisErrorEvent(aCharIndex, aElapsedTime,
mUtterance->mState = SpeechSynthesisUtterance::STATE_ENDED;
mUtterance->DispatchSpeechSynthesisErrorEvent(aCharIndex, aElapsedTime,
SpeechSynthesisErrorCode(aError));
return NS_OK;
}
@ -665,8 +660,7 @@ nsSpeechTask::Cancel()
}
if (!mIndirectAudio) {
DispatchErrorInner(GetCurrentTime(), GetCurrentCharOffset(),
uint32_t(SpeechSynthesisErrorCode::Interrupted));
DispatchEndInner(GetCurrentTime(), GetCurrentCharOffset());
}
}

Просмотреть файл

@ -109,8 +109,6 @@ private:
nsresult DispatchEndInner(float aElapsedTime, uint32_t aCharIndex);
nsresult DispatchErrorInner(float aElapsedTime, uint32_t aCharIndex, uint32_t aError);
void CreateAudioChannelAgent();
void DestroyAudioChannelAgent();

Просмотреть файл

@ -8,7 +8,6 @@
#include "mozilla/dom/nsSpeechTask.h"
#include "mozilla/dom/nsSynthVoiceRegistry.h"
#include "mozilla/dom/SpeechSynthesisErrorEvent.h"
#include "mozilla/Preferences.h"
#include "nsEscape.h"
#include "nsISupports.h"
@ -252,11 +251,6 @@ SpeechDispatcherCallback::OnSpeechEvent(SPDNotificationType state)
break;
case SPD_EVENT_CANCEL:
mTask->DispatchError((TimeStamp::Now() - mStartTime).ToSeconds(), 0,
uint32_t(SpeechSynthesisErrorCode::Interrupted));
remove = true;
break;
case SPD_EVENT_END:
mTask->DispatchEnd((TimeStamp::Now() - mStartTime).ToSeconds(), 0);
remove = true;

Просмотреть файл

@ -41,7 +41,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
var utterance5 = new win2.SpeechSynthesisUtterance("u5: hello, losers too");
utterance5.lang = 'it-IT-noend';
var eventOrder = ['start1', 'end1', 'start2', 'error2'];
var eventOrder = ['start1', 'end1', 'start2', 'end2'];
utterance1.addEventListener('start', function(e) {
is(eventOrder.shift(), 'start1', 'start1');
testSynthState(win1, { speaking: true, pending: true });
@ -61,8 +61,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1188099
testSynthState(win2, { speaking: true, pending: false });
win1.speechSynthesis.cancel();
});
utterance2.addEventListener('error', function(e) {
is(eventOrder.shift(), 'error2', 'error2');
utterance2.addEventListener('end', function(e) {
is(eventOrder.shift(), 'end2', 'end2');
testSynthState(win1, { speaking: false, pending: false });
testSynthState(win2, { speaking: false, pending: false });
SimpleTest.finish();

Просмотреть файл

@ -50,7 +50,7 @@ function testFunc(done_cb) {
speechSynthesis.cancel();
});
utterance.addEventListener('error', function(e) {
utterance.addEventListener('end', function(e) {
ok(e.charIndex, 1, 'resume event charIndex matches service arguments');
ok(e.elapsedTime, 1.5, 'end event elapsedTime matches service arguments');
test_no_events();

Просмотреть файл

@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1150315
/** Test for Bug 1150315 **/
function testFunc(done_cb) {
var gotErrorEvent = false;
var gotEndEvent = false;
// A long utterance that we will interrupt.
var utterance = new SpeechSynthesisUtterance("Donec ac nunc feugiat, posuere " +
"mauris id, pharetra velit. Donec fermentum orci nunc, sit amet maximus" +
@ -63,14 +63,13 @@ function testFunc(done_cb) {
speechSynthesis.cancel();
speechSynthesis.speak(utterance3);
});
utterance2.addEventListener('error', function(e) {
gotErrorEvent = true;
is(e.error, "interrupted", "Error event is has right error.")
utterance2.addEventListener('end', function(e) {
gotEndEvent = true;
});
var utterance3 = new SpeechSynthesisUtterance("Hello, world 3!");
utterance3.addEventListener('start', function() {
ok(gotErrorEvent, "didn't get error event for previous utterance");
ok(gotEndEvent, "didn't get start event for this utterance");
});
utterance3.addEventListener('end', done_cb);

Просмотреть файл

@ -90,8 +90,7 @@ public:
NS_IMETHOD OnCancel() override
{
if (mTask) {
mTask->DispatchError(1.5, 1,
uint32_t(SpeechSynthesisErrorCode::Interrupted));
mTask->DispatchEnd(1.5, 1);
}
return NS_OK;

Просмотреть файл

@ -13,7 +13,6 @@
#include "mozilla/dom/nsSynthVoiceRegistry.h"
#include "mozilla/dom/nsSpeechTask.h"
#include "mozilla/dom/SpeechSynthesisErrorEvent.h"
#include "mozilla/Preferences.h"
namespace mozilla {
@ -132,13 +131,9 @@ SapiCallback::OnSpeechEvent(const SPEVENT& speechEvent)
break;
case SPEI_END_INPUT_STREAM:
if (mSpeakTextLen) {
// mSpeakTextLen will be > 0 on any utterance except a cancel utterance.
mCurrentIndex = mSpeakTextLen;
mTask->DispatchEnd(GetTickCount() - mStartingTime, mCurrentIndex);
} else {
mTask->DispatchError(GetTickCount() - mStartingTime, mCurrentIndex,
uint32_t(SpeechSynthesisErrorCode::Interrupted));
}
mTask->DispatchEnd(GetTickCount() - mStartingTime, mCurrentIndex);
mTask = nullptr;
break;
case SPEI_TTS_BOOKMARK: