summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/mock
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/platform/mock
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/platform/mock')
-rw-r--r--Source/WebCore/platform/mock/SpeechInputClientMock.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/Source/WebCore/platform/mock/SpeechInputClientMock.cpp b/Source/WebCore/platform/mock/SpeechInputClientMock.cpp
index 16f2825..16a7c76 100644
--- a/Source/WebCore/platform/mock/SpeechInputClientMock.cpp
+++ b/Source/WebCore/platform/mock/SpeechInputClientMock.cpp
@@ -72,8 +72,8 @@ void SpeechInputClientMock::stopRecording(int requestId)
void SpeechInputClientMock::cancelRecognition(int requestId)
{
- ASSERT(requestId == m_requestId);
if (m_timer.isActive()) {
+ ASSERT(requestId == m_requestId);
m_timer.stop();
m_recording = false;
m_listener->didCompleteRecognition(m_requestId);
@@ -107,15 +107,20 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
} else {
bool noResultsFound = false;
+ // We take a copy of the requestId here so that if scripts destroyed the input element
+ // inside one of the callbacks below, we'll still know what this session's requestId was.
+ int requestId = m_requestId;
+ m_requestId = 0;
+
// Empty language case must be handled separately to avoid problems with HashMap and empty keys.
if (m_language.isEmpty()) {
if (!m_resultsForEmptyLanguage.isEmpty())
- m_listener->setRecognitionResult(m_requestId, m_resultsForEmptyLanguage);
+ m_listener->setRecognitionResult(requestId, m_resultsForEmptyLanguage);
else
noResultsFound = true;
} else {
if (m_recognitionResults.contains(m_language))
- m_listener->setRecognitionResult(m_requestId, m_recognitionResults.get(m_language));
+ m_listener->setRecognitionResult(requestId, m_recognitionResults.get(m_language));
else
noResultsFound = true;
}
@@ -128,11 +133,10 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
error.append("'");
SpeechInputResultArray results;
results.append(SpeechInputResult::create(error, 1.0));
- m_listener->setRecognitionResult(m_requestId, results);
+ m_listener->setRecognitionResult(requestId, results);
}
- m_listener->didCompleteRecognition(m_requestId);
- m_requestId = 0;
+ m_listener->didCompleteRecognition(requestId);
}
}