[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 12:04:34 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 27a9e2979628c808def79820820861a11e9761b2
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 13 16:49:30 2010 +0000
2010-08-13 Satish Sampath <satish at chromium.org>
Reviewed by Jeremy Orlow.
Support for multiple speech enabled elements in same page.
https://bugs.webkit.org/show_bug.cgi?id=43922
* page/SpeechInput.cpp: Generates request ids as necessary when each speech enabled input element gets
created/destroyed and multiplexes the listener callbacks to the appropriate input element based on the request id.
(WebCore::SpeechInput::SpeechInput):
(WebCore::SpeechInput::~SpeechInput):
(WebCore::SpeechInput::registerListener):
(WebCore::SpeechInput::unregisterListener):
(WebCore::SpeechInput::didCompleteRecording):
(WebCore::SpeechInput::didCompleteRecognition):
(WebCore::SpeechInput::setRecognitionResult):
(WebCore::SpeechInput::startRecognition):
(WebCore::SpeechInput::stopRecording):
(WebCore::SpeechInput::cancelRecognition):
* page/SpeechInput.h:
* page/SpeechInputClient.h: Now requires a one time set for the WebCore::SpeechInputListener and
takes in a 'requestId' for all calls.
* page/SpeechInputListener.h: Now returns the above mentioned requestId in all the listener callbacks for
identifying which input element the event goes to.
* platform/mock/SpeechInputClientMock.cpp:
(WebCore::SpeechInputClientMock::SpeechInputClientMock):
(WebCore::SpeechInputClientMock::setListener):
(WebCore::SpeechInputClientMock::startRecognition):
(WebCore::SpeechInputClientMock::stopRecording):
(WebCore::SpeechInputClientMock::cancelRecognition):
(WebCore::SpeechInputClientMock::timerFired):
* platform/mock/SpeechInputClientMock.h:
* rendering/TextControlInnerElements.cpp:
(WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
(WebCore::InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement):
(WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
(WebCore::InputFieldSpeechButtonElement::speechInput):
(WebCore::InputFieldSpeechButtonElement::didCompleteRecording):
(WebCore::InputFieldSpeechButtonElement::didCompleteRecognition):
(WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
* rendering/TextControlInnerElements.h:
2010-08-13 Satish Sampath <satish at chromium.org>
Reviewed by Jeremy Orlow.
Support for multiple speech enabled elements in same page.
https://bugs.webkit.org/show_bug.cgi?id=43922
* public/WebSpeechInputController.h: Bubbles up the requestId given by webcore to the embedder.
(WebKit::WebSpeechInputController::startRecognition):
(WebKit::WebSpeechInputController::cancelRecognition):
(WebKit::WebSpeechInputController::stopRecording):
* public/WebSpeechInputListener.h: Passes down the requestId given by embedder to webcore.
(WebKit::WebSpeechInputListener::didCompleteRecording):
(WebKit::WebSpeechInputListener::setRecognitionResult):
(WebKit::WebSpeechInputListener::didCompleteRecognition):
* src/SpeechInputClientImpl.cpp:
(WebKit::SpeechInputClientImpl::setListener):
(WebKit::SpeechInputClientImpl::startRecognition):
(WebKit::SpeechInputClientImpl::stopRecording):
(WebKit::SpeechInputClientImpl::cancelRecognition):
(WebKit::SpeechInputClientImpl::didCompleteRecording):
(WebKit::SpeechInputClientImpl::didCompleteRecognition):
(WebKit::SpeechInputClientImpl::setRecognitionResult):
* src/SpeechInputClientImpl.h:
* src/WebSpeechInputControllerMockImpl.cpp:
(WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl):
(WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl):
(WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording):
(WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition):
(WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
(WebKit::WebSpeechInputControllerMockImpl::startRecognition):
(WebKit::WebSpeechInputControllerMockImpl::cancelRecognition):
(WebKit::WebSpeechInputControllerMockImpl::stopRecording):
* src/WebSpeechInputControllerMockImpl.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0d459eb..ddadf7c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-08-13 Satish Sampath <satish at chromium.org>
+
+ Reviewed by Jeremy Orlow.
+
+ Support for multiple speech enabled elements in same page.
+ https://bugs.webkit.org/show_bug.cgi?id=43922
+
+ * page/SpeechInput.cpp: Generates request ids as necessary when each speech enabled input element gets
+ created/destroyed and multiplexes the listener callbacks to the appropriate input element based on the request id.
+ (WebCore::SpeechInput::SpeechInput):
+ (WebCore::SpeechInput::~SpeechInput):
+ (WebCore::SpeechInput::registerListener):
+ (WebCore::SpeechInput::unregisterListener):
+ (WebCore::SpeechInput::didCompleteRecording):
+ (WebCore::SpeechInput::didCompleteRecognition):
+ (WebCore::SpeechInput::setRecognitionResult):
+ (WebCore::SpeechInput::startRecognition):
+ (WebCore::SpeechInput::stopRecording):
+ (WebCore::SpeechInput::cancelRecognition):
+ * page/SpeechInput.h:
+ * page/SpeechInputClient.h: Now requires a one time set for the WebCore::SpeechInputListener and
+ takes in a 'requestId' for all calls.
+ * page/SpeechInputListener.h: Now returns the above mentioned requestId in all the listener callbacks for
+ identifying which input element the event goes to.
+ * platform/mock/SpeechInputClientMock.cpp:
+ (WebCore::SpeechInputClientMock::SpeechInputClientMock):
+ (WebCore::SpeechInputClientMock::setListener):
+ (WebCore::SpeechInputClientMock::startRecognition):
+ (WebCore::SpeechInputClientMock::stopRecording):
+ (WebCore::SpeechInputClientMock::cancelRecognition):
+ (WebCore::SpeechInputClientMock::timerFired):
+ * platform/mock/SpeechInputClientMock.h:
+ * rendering/TextControlInnerElements.cpp:
+ (WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
+ (WebCore::InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement):
+ (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
+ (WebCore::InputFieldSpeechButtonElement::speechInput):
+ (WebCore::InputFieldSpeechButtonElement::didCompleteRecording):
+ (WebCore::InputFieldSpeechButtonElement::didCompleteRecognition):
+ (WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
+ * rendering/TextControlInnerElements.h:
+
2010-08-13 Eric Carlson <eric.carlson at apple.com>
Reviewed by David Kilzer.
diff --git a/WebCore/page/SpeechInput.cpp b/WebCore/page/SpeechInput.cpp
index 4f37988..24b52d2 100644
--- a/WebCore/page/SpeechInput.cpp
+++ b/WebCore/page/SpeechInput.cpp
@@ -41,46 +41,74 @@ namespace WebCore {
SpeechInput::SpeechInput(SpeechInputClient* client)
: m_client(client)
- , m_listener(0)
+ , m_nextListenerId(1)
{
+ m_client->setListener(this);
}
-void SpeechInput::didCompleteRecording()
+SpeechInput::~SpeechInput()
{
- ASSERT(m_listener);
- m_listener->didCompleteRecording();
+ m_client->setListener(0);
}
-void SpeechInput::didCompleteRecognition()
+int SpeechInput::registerListener(SpeechInputListener* listener)
{
- ASSERT(m_listener);
- m_listener->didCompleteRecognition();
- m_listener = 0;
+#if defined(DEBUG)
+ // Check if already present.
+ for (HashMap<int, SpeechInputListener*>::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
+ ASSERT(it->second != listener);
+#endif
+
+ m_listeners.add(m_nextListenerId, listener);
+ return m_nextListenerId++;
+}
+
+void SpeechInput::unregisterListener(int listenerId)
+{
+ if (m_listeners.contains(listenerId))
+ m_listeners.remove(listenerId);
+}
+
+void SpeechInput::didCompleteRecording(int listenerId)
+{
+ // Don't assert if not present as the element might have been removed by the page while
+ // this event was on the way.
+ if (m_listeners.contains(listenerId))
+ m_listeners.get(listenerId)->didCompleteRecording(listenerId);
+}
+
+void SpeechInput::didCompleteRecognition(int listenerId)
+{
+ // Don't assert if not present as the element might have been removed by the page while
+ // this event was on the way.
+ if (m_listeners.contains(listenerId))
+ m_listeners.get(listenerId)->didCompleteRecognition(listenerId);
+}
+
+void SpeechInput::setRecognitionResult(int listenerId, const String& result)
+{
+ // Don't assert if not present as the element might have been removed by the page while
+ // this event was on the way.
+ if (m_listeners.contains(listenerId))
+ m_listeners.get(listenerId)->setRecognitionResult(listenerId, result);
}
-void SpeechInput::setRecognitionResult(const String& result)
+bool SpeechInput::startRecognition(int listenerId)
{
- ASSERT(m_listener);
- m_listener->setRecognitionResult(result);
+ ASSERT(m_listeners.contains(listenerId));
+ return m_client->startRecognition(listenerId);
}
-bool SpeechInput::startRecognition(SpeechInputListener* listener)
+void SpeechInput::stopRecording(int listenerId)
{
- // Cancel any ongoing recognition first.
- if (m_listener) {
- m_listener->didCompleteRecognition();
- m_listener = 0;
- m_client->cancelRecognition();
- }
-
- m_listener = listener;
- return m_client->startRecognition(this);
+ ASSERT(m_listeners.contains(listenerId));
+ m_client->stopRecording(listenerId);
}
-void SpeechInput::stopRecording()
+void SpeechInput::cancelRecognition(int listenerId)
{
- ASSERT(m_listener);
- m_client->stopRecording();
+ ASSERT(m_listeners.contains(listenerId));
+ m_client->cancelRecognition(listenerId);
}
} // namespace WebCore
diff --git a/WebCore/page/SpeechInput.h b/WebCore/page/SpeechInput.h
index 58f4efe..f36194c 100644
--- a/WebCore/page/SpeechInput.h
+++ b/WebCore/page/SpeechInput.h
@@ -35,6 +35,7 @@
#include "SpeechInputListener.h"
#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
@@ -48,20 +49,30 @@ class SpeechInputListener;
class SpeechInput : public Noncopyable, public SpeechInputListener {
public:
SpeechInput(SpeechInputClient*);
- virtual ~SpeechInput() { }
+ virtual ~SpeechInput();
+
+ // Generates a unique ID for the given listener to be used for speech requests.
+ // This should be the first call made by listeners before anything else.
+ int registerListener(SpeechInputListener*);
+
+ // Invoked when the listener is done with recording or getting destroyed.
+ // Failure to unregister may result in crashes if there were any pending speech events.
+ void unregisterListener(int);
// Methods invoked by the input elements.
- bool startRecognition(SpeechInputListener* listener);
- void stopRecording();
+ bool startRecognition(int);
+ void stopRecording(int);
+ void cancelRecognition(int);
// SpeechInputListener methods.
- virtual void didCompleteRecording();
- virtual void didCompleteRecognition();
- virtual void setRecognitionResult(const String&);
+ virtual void didCompleteRecording(int);
+ virtual void didCompleteRecognition(int);
+ virtual void setRecognitionResult(int, const String&);
private:
SpeechInputClient* m_client;
- SpeechInputListener* m_listener;
+ HashMap<int, SpeechInputListener*> m_listeners;
+ int m_nextListenerId;
};
} // namespace WebCore
diff --git a/WebCore/page/SpeechInputClient.h b/WebCore/page/SpeechInputClient.h
index f6c61cf..87ff7b9 100644
--- a/WebCore/page/SpeechInputClient.h
+++ b/WebCore/page/SpeechInputClient.h
@@ -40,15 +40,22 @@ class SpeechInputListener;
// Provides an interface for SpeechInput to call into the embedder.
class SpeechInputClient {
public:
- virtual bool startRecognition(SpeechInputListener* listener) = 0;
+ // This is the first call made by a listener, registering itself for future callbacks.
+ // When the listener no longer needs speech input (for e.g. when it gets destroyed),
+ // it should set a null listener to stop receiving callbacks.
+ // The client does not take ownership of the pointer.
+ virtual void setListener(SpeechInputListener*) = 0;
+
+ // Starts speech recognition and audio recording.
+ virtual bool startRecognition(int requestId) = 0;
// Stops audio recording and performs recognition with the audio recorded until now
// (does not discard audio).
- virtual void stopRecording() = 0;
+ virtual void stopRecording(int requestId) = 0;
// Cancels an ongoing recognition and discards any audio recorded so far. No partial
// recognition results are returned to the listener.
- virtual void cancelRecognition() = 0;
+ virtual void cancelRecognition(int requestId) = 0;
protected:
virtual ~SpeechInputClient() { }
diff --git a/WebCore/page/SpeechInputListener.h b/WebCore/page/SpeechInputListener.h
index 143984d..36060fc 100644
--- a/WebCore/page/SpeechInputListener.h
+++ b/WebCore/page/SpeechInputListener.h
@@ -41,19 +41,19 @@ namespace WebCore {
class SpeechInputListener {
public:
// Informs that audio recording has completed and recognition is underway.
- virtual void didCompleteRecording() = 0;
+ virtual void didCompleteRecording(int requestId) = 0;
// Informs that speech recognition has completed. This gets invoked irrespective of whether
// recognition was succesful or not, whether setRecognitionResult() was invoked or not. The
// handler typically frees up any temporary resources allocated and waits for the next speech
// recognition request.
- virtual void didCompleteRecognition() = 0;
+ virtual void didCompleteRecognition(int requestId) = 0;
// Gives results from speech recognition, either partial or the final results.
// This method can potentially get called multiple times if there are partial results
// available as the user keeps speaking. If the speech could not be recognized properly
// or if there was any other errors in the process, this method may never be called.
- virtual void setRecognitionResult(const String& result) = 0;
+ virtual void setRecognitionResult(int requestId, const String& result) = 0;
protected:
virtual ~SpeechInputListener() { }
diff --git a/WebCore/platform/mock/SpeechInputClientMock.cpp b/WebCore/platform/mock/SpeechInputClientMock.cpp
index 74a3151..c3d74d1 100644
--- a/WebCore/platform/mock/SpeechInputClientMock.cpp
+++ b/WebCore/platform/mock/SpeechInputClientMock.cpp
@@ -41,34 +41,42 @@ SpeechInputClientMock::SpeechInputClientMock()
: m_recording(false)
, m_timer(this, &SpeechInputClientMock::timerFired)
, m_listener(0)
+ , m_requestId(0)
{
}
-bool SpeechInputClientMock::startRecognition(SpeechInputListener* listener)
+void SpeechInputClientMock::setListener(SpeechInputListener* listener)
+{
+ m_listener = listener;
+}
+
+bool SpeechInputClientMock::startRecognition(int requestId)
{
if (m_timer.isActive())
return false;
- m_listener = listener;
+ m_requestId = requestId;
m_recording = true;
m_timer.startOneShot(0);
return true;
}
-void SpeechInputClientMock::stopRecording()
+void SpeechInputClientMock::stopRecording(int requestId)
{
+ ASSERT(requestId == m_requestId);
if (m_timer.isActive() && m_recording) {
m_timer.stop();
timerFired(&m_timer);
}
}
-void SpeechInputClientMock::cancelRecognition()
+void SpeechInputClientMock::cancelRecognition(int requestId)
{
+ ASSERT(requestId == m_requestId);
if (m_timer.isActive()) {
m_timer.stop();
m_recording = false;
- m_listener->didCompleteRecognition();
- m_listener = 0;
+ m_listener->didCompleteRecognition(m_requestId);
+ m_requestId = 0;
}
}
@@ -81,12 +89,12 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
{
if (m_recording) {
m_recording = false;
- m_listener->didCompleteRecording();
+ m_listener->didCompleteRecording(m_requestId);
m_timer.startOneShot(0);
} else {
- m_listener->setRecognitionResult(m_recognitionResult);
- m_listener->didCompleteRecognition();
- m_listener = 0;
+ m_listener->setRecognitionResult(m_requestId, m_recognitionResult);
+ m_listener->didCompleteRecognition(m_requestId);
+ m_requestId = 0;
}
}
diff --git a/WebCore/platform/mock/SpeechInputClientMock.h b/WebCore/platform/mock/SpeechInputClientMock.h
index faca444..7d5fda2 100644
--- a/WebCore/platform/mock/SpeechInputClientMock.h
+++ b/WebCore/platform/mock/SpeechInputClientMock.h
@@ -49,9 +49,10 @@ public:
void setRecognitionResult(const String& result);
// SpeechInputClient methods.
- bool startRecognition(SpeechInputListener*);
- void stopRecording();
- void cancelRecognition();
+ void setListener(SpeechInputListener*);
+ bool startRecognition(int);
+ void stopRecording(int);
+ void cancelRecognition(int);
private:
void timerFired(Timer<SpeechInputClientMock>*);
@@ -59,6 +60,7 @@ private:
bool m_recording;
Timer<SpeechInputClientMock> m_timer;
SpeechInputListener* m_listener;
+ int m_requestId;
String m_recognitionResult;
};
diff --git a/WebCore/rendering/TextControlInnerElements.cpp b/WebCore/rendering/TextControlInnerElements.cpp
index f532101..9852aa6 100644
--- a/WebCore/rendering/TextControlInnerElements.cpp
+++ b/WebCore/rendering/TextControlInnerElements.cpp
@@ -346,9 +346,20 @@ inline InputFieldSpeechButtonElement::InputFieldSpeechButtonElement(Node* shadow
: TextControlInnerElement(shadowParent->document(), shadowParent)
, m_capturing(false)
, m_state(Idle)
+ , m_listenerId(document()->page()->speechInput()->registerListener(this))
{
}
+InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement()
+{
+ SpeechInput* speech = speechInput();
+ if (speech) { // Could be null when page is unloading.
+ if (m_state != Idle)
+ speech->cancelRecognition(m_listenerId);
+ speech->unregisterListener(m_listenerId);
+ }
+}
+
PassRefPtr<InputFieldSpeechButtonElement> InputFieldSpeechButtonElement::create(Node* shadowParent)
{
return adoptRef(new InputFieldSpeechButtonElement(shadowParent));
@@ -386,11 +397,11 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
if (event->type() == eventNames().clickEvent) {
switch (m_state) {
case Idle:
- if (speechInput()->startRecognition(this))
+ if (speechInput()->startRecognition(m_listenerId))
setState(Recording);
break;
case Recording:
- speechInput()->stopRecording();
+ speechInput()->stopRecording(m_listenerId);
break;
case Recognizing:
// Nothing to do here, we will continue to wait for results.
@@ -413,20 +424,20 @@ void InputFieldSpeechButtonElement::setState(SpeechInputState state)
SpeechInput* InputFieldSpeechButtonElement::speechInput()
{
- return document()->page()->speechInput();
+ return document()->page() ? document()->page()->speechInput() : 0;
}
-void InputFieldSpeechButtonElement::didCompleteRecording()
+void InputFieldSpeechButtonElement::didCompleteRecording(int)
{
setState(Recognizing);
}
-void InputFieldSpeechButtonElement::didCompleteRecognition()
+void InputFieldSpeechButtonElement::didCompleteRecognition(int)
{
setState(Idle);
}
-void InputFieldSpeechButtonElement::setRecognitionResult(const String& result)
+void InputFieldSpeechButtonElement::setRecognitionResult(int, const String& result)
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
// The call to setValue() below dispatches an event, and an event handler in the page might
diff --git a/WebCore/rendering/TextControlInnerElements.h b/WebCore/rendering/TextControlInnerElements.h
index e7ee98f..3fbc9c8 100644
--- a/WebCore/rendering/TextControlInnerElements.h
+++ b/WebCore/rendering/TextControlInnerElements.h
@@ -126,15 +126,16 @@ public:
};
static PassRefPtr<InputFieldSpeechButtonElement> create(Node*);
+ virtual ~InputFieldSpeechButtonElement();
virtual void detach();
virtual void defaultEventHandler(Event*);
SpeechInputState state() const { return m_state; }
// SpeechInputListener methods.
- void didCompleteRecording();
- void didCompleteRecognition();
- void setRecognitionResult(const String& result);
+ void didCompleteRecording(int);
+ void didCompleteRecognition(int);
+ void setRecognitionResult(int, const String& result);
private:
InputFieldSpeechButtonElement(Node*);
@@ -143,6 +144,7 @@ private:
bool m_capturing;
SpeechInputState m_state;
+ int m_listenerId;
};
#endif // ENABLE(INPUT_SPEECH)
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 2ad136b..a43139f 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,38 @@
+2010-08-13 Satish Sampath <satish at chromium.org>
+
+ Reviewed by Jeremy Orlow.
+
+ Support for multiple speech enabled elements in same page.
+ https://bugs.webkit.org/show_bug.cgi?id=43922
+
+ * public/WebSpeechInputController.h: Bubbles up the requestId given by webcore to the embedder.
+ (WebKit::WebSpeechInputController::startRecognition):
+ (WebKit::WebSpeechInputController::cancelRecognition):
+ (WebKit::WebSpeechInputController::stopRecording):
+ * public/WebSpeechInputListener.h: Passes down the requestId given by embedder to webcore.
+ (WebKit::WebSpeechInputListener::didCompleteRecording):
+ (WebKit::WebSpeechInputListener::setRecognitionResult):
+ (WebKit::WebSpeechInputListener::didCompleteRecognition):
+ * src/SpeechInputClientImpl.cpp:
+ (WebKit::SpeechInputClientImpl::setListener):
+ (WebKit::SpeechInputClientImpl::startRecognition):
+ (WebKit::SpeechInputClientImpl::stopRecording):
+ (WebKit::SpeechInputClientImpl::cancelRecognition):
+ (WebKit::SpeechInputClientImpl::didCompleteRecording):
+ (WebKit::SpeechInputClientImpl::didCompleteRecognition):
+ (WebKit::SpeechInputClientImpl::setRecognitionResult):
+ * src/SpeechInputClientImpl.h:
+ * src/WebSpeechInputControllerMockImpl.cpp:
+ (WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl):
+ (WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl):
+ (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording):
+ (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition):
+ (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
+ (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
+ (WebKit::WebSpeechInputControllerMockImpl::cancelRecognition):
+ (WebKit::WebSpeechInputControllerMockImpl::stopRecording):
+ * src/WebSpeechInputControllerMockImpl.h:
+
2010-08-12 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebKit/chromium/public/WebSpeechInputController.h b/WebKit/chromium/public/WebSpeechInputController.h
index 3dba5fb..b85fde6 100644
--- a/WebKit/chromium/public/WebSpeechInputController.h
+++ b/WebKit/chromium/public/WebSpeechInputController.h
@@ -41,14 +41,21 @@ public:
// Starts speech recognition. Speech will get recorded until the endpointer detects silence,
// runs to the limit or stopRecording is called. Progress indications and the recognized
// text are returned via the listener interface.
+ virtual bool startRecognition(int)
+ {
+ return startRecognition();
+ }
+ // FIXME: Remove this once chromium has picked up this change.
virtual bool startRecognition()
{
- WEBKIT_ASSERT_NOT_REACHED();
- return false;
+ WEBKIT_ASSERT_NOT_REACHED();
+ return false;
}
// Cancels an ongoing recognition and discards any audio recorded so far. No partial
// recognition results are returned to the listener.
+ virtual void cancelRecognition(int) { cancelRecognition(); }
+ // FIXME: Remove this once chromium has picked up this change.
virtual void cancelRecognition() { WEBKIT_ASSERT_NOT_REACHED(); }
// Stops audio recording and performs recognition with the audio recorded until now
@@ -56,6 +63,8 @@ public:
// wants to stop recording audio as soon as they finished speaking. Otherwise, the speech
// recording 'endpointer' should detect silence in the input and stop recording automatically.
// Call startRecognition() to record audio and recognize speech again.
+ virtual void stopRecording(int) { stopRecording(); }
+ // FIXME: Remove this once chromium has picked up this change.
virtual void stopRecording() { WEBKIT_ASSERT_NOT_REACHED(); }
protected:
diff --git a/WebKit/chromium/public/WebSpeechInputListener.h b/WebKit/chromium/public/WebSpeechInputListener.h
index f1756af..e779c3a 100644
--- a/WebKit/chromium/public/WebSpeechInputListener.h
+++ b/WebKit/chromium/public/WebSpeechInputListener.h
@@ -47,19 +47,34 @@ public:
// WebSpeechInputController::stopRecording() was called.
// Typically after this call the listener would update the UI to reflect that recognition is
// in progress.
- virtual void didCompleteRecording() = 0;
+ virtual void didCompleteRecording(int) = 0;
+ // FIXME: Remove this once chromium has picked up this change.
+ virtual void didCompleteRecording()
+ {
+ didCompleteRecording(1);
+ }
// Gives results from speech recognition, either partial or the final results.
// This method can potentially get called multiple times if there are partial results
// available as the user keeps speaking. If the speech could not be recognized properly
// or if there was any other errors in the process, this method may never be called.
- virtual void setRecognitionResult(const WebString&) = 0;
+ virtual void setRecognitionResult(int, const WebString&) = 0;
+ // FIXME: Remove this once chromium has picked up this change.
+ virtual void setRecognitionResult(const WebString& result)
+ {
+ setRecognitionResult(1, result);
+ }
// Informs that speech recognition has completed. This gets invoked irrespective of whether
// recognition was succesful or not, whether setRecognitionResult() was invoked or not. The
// handler typically frees up any temporary resources allocated and waits for the next speech
// recognition request.
- virtual void didCompleteRecognition() = 0;
+ virtual void didCompleteRecognition(int) = 0;
+ // FIXME: Remove this once chromium has picked up this change.
+ virtual void didCompleteRecognition()
+ {
+ didCompleteRecognition(1);
+ }
protected:
~WebSpeechInputListener() { }
diff --git a/WebKit/chromium/src/SpeechInputClientImpl.cpp b/WebKit/chromium/src/SpeechInputClientImpl.cpp
index 66525e3..9c59bae 100644
--- a/WebKit/chromium/src/SpeechInputClientImpl.cpp
+++ b/WebKit/chromium/src/SpeechInputClientImpl.cpp
@@ -51,41 +51,45 @@ SpeechInputClientImpl::~SpeechInputClientImpl()
{
}
-bool SpeechInputClientImpl::startRecognition(WebCore::SpeechInputListener* listener)
+void SpeechInputClientImpl::setListener(WebCore::SpeechInputListener* listener)
{
m_listener = listener;
- return m_controller->startRecognition();
}
-void SpeechInputClientImpl::stopRecording()
+bool SpeechInputClientImpl::startRecognition(int requestId)
{
ASSERT(m_listener);
- m_controller->stopRecording();
+ return m_controller->startRecognition(requestId);
}
-void SpeechInputClientImpl::cancelRecognition()
+void SpeechInputClientImpl::stopRecording(int requestId)
{
ASSERT(m_listener);
- m_controller->cancelRecognition();
+ m_controller->stopRecording(requestId);
}
-void SpeechInputClientImpl::didCompleteRecording()
+void SpeechInputClientImpl::cancelRecognition(int requestId)
{
ASSERT(m_listener);
- m_listener->didCompleteRecording();
+ m_controller->cancelRecognition(requestId);
}
-void SpeechInputClientImpl::didCompleteRecognition()
+void SpeechInputClientImpl::didCompleteRecording(int requestId)
{
ASSERT(m_listener);
- m_listener->didCompleteRecognition();
- m_listener = 0;
+ m_listener->didCompleteRecording(requestId);
}
-void SpeechInputClientImpl::setRecognitionResult(const WebString& result)
+void SpeechInputClientImpl::didCompleteRecognition(int requestId)
{
ASSERT(m_listener);
- m_listener->setRecognitionResult(result);
+ m_listener->didCompleteRecognition(requestId);
+}
+
+void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebString& result)
+{
+ ASSERT(m_listener);
+ m_listener->setRecognitionResult(requestId, result);
}
} // namespace WebKit
diff --git a/WebKit/chromium/src/SpeechInputClientImpl.h b/WebKit/chromium/src/SpeechInputClientImpl.h
index 5762da8..0ab54c1 100644
--- a/WebKit/chromium/src/SpeechInputClientImpl.h
+++ b/WebKit/chromium/src/SpeechInputClientImpl.h
@@ -53,18 +53,19 @@ public:
virtual ~SpeechInputClientImpl();
// SpeechInputClient methods.
- bool startRecognition(WebCore::SpeechInputListener*);
- void stopRecording();
- void cancelRecognition();
+ void setListener(WebCore::SpeechInputListener*);
+ bool startRecognition(int);
+ void stopRecording(int);
+ void cancelRecognition(int);
// WebSpeechInputListener methods.
- void didCompleteRecording();
- void setRecognitionResult(const WebString&);
- void didCompleteRecognition();
+ void didCompleteRecording(int);
+ void setRecognitionResult(int, const WebString&);
+ void didCompleteRecognition(int);
private:
WebSpeechInputController* m_controller; // To call into the embedder.
- WebCore::SpeechInputListener* m_listener; // Valid when recognition is in progress.
+ WebCore::SpeechInputListener* m_listener;
};
} // namespace WebKit
diff --git a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
index 6b04320..57e3635 100644
--- a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
+++ b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
@@ -46,6 +46,12 @@ WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl(
: m_webcoreMock(new WebCore::SpeechInputClientMock())
, m_listener(listener)
{
+ m_webcoreMock->setListener(this);
+}
+
+WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl()
+{
+ m_webcoreMock->setListener(0);
}
void WebSpeechInputControllerMockImpl::setMockRecognitionResult(const WebString& result)
@@ -53,34 +59,34 @@ void WebSpeechInputControllerMockImpl::setMockRecognitionResult(const WebString&
m_webcoreMock->setRecognitionResult(result);
}
-void WebSpeechInputControllerMockImpl::didCompleteRecording()
+void WebSpeechInputControllerMockImpl::didCompleteRecording(int requestId)
{
- m_listener->didCompleteRecording();
+ m_listener->didCompleteRecording(requestId);
}
-void WebSpeechInputControllerMockImpl::didCompleteRecognition()
+void WebSpeechInputControllerMockImpl::didCompleteRecognition(int requestId)
{
- m_listener->didCompleteRecognition();
+ m_listener->didCompleteRecognition(requestId);
}
-void WebSpeechInputControllerMockImpl::setRecognitionResult(const WTF::String& result)
+void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WTF::String& result)
{
- m_listener->setRecognitionResult(result);
+ m_listener->setRecognitionResult(requestId, result);
}
-bool WebSpeechInputControllerMockImpl::startRecognition()
+bool WebSpeechInputControllerMockImpl::startRecognition(int requestId)
{
- return m_webcoreMock->startRecognition(this);
+ return m_webcoreMock->startRecognition(requestId);
}
-void WebSpeechInputControllerMockImpl::cancelRecognition()
+void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId)
{
- m_webcoreMock->cancelRecognition();
+ m_webcoreMock->cancelRecognition(requestId);
}
-void WebSpeechInputControllerMockImpl::stopRecording()
+void WebSpeechInputControllerMockImpl::stopRecording(int requestId)
{
- m_webcoreMock->stopRecording();
+ m_webcoreMock->stopRecording(requestId);
}
} // namespace WebKit
diff --git a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
index 046abf3..38a15df 100644
--- a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
+++ b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
@@ -47,16 +47,17 @@ class WebSpeechInputControllerMockImpl : public WebCore::SpeechInputListener
, public WebSpeechInputControllerMock {
public:
WebSpeechInputControllerMockImpl(WebSpeechInputListener*);
+ virtual ~WebSpeechInputControllerMockImpl();
// WebCore::SpeechInputListener methods.
- void didCompleteRecording();
- void didCompleteRecognition();
- void setRecognitionResult(const WTF::String& result);
+ void didCompleteRecording(int requestId);
+ void didCompleteRecognition(int requestId);
+ void setRecognitionResult(int requestId, const WTF::String& result);
// WebSpeechInputController methods.
- bool startRecognition();
- void cancelRecognition();
- void stopRecording();
+ bool startRecognition(int requestId);
+ void cancelRecognition(int requestId);
+ void stopRecording(int requestId);
// WebSpeechInputControllerMock methods.
void setMockRecognitionResult(const WebString& result);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list