Skip to content
Permalink
Browse files
2010-10-21 Satish Sampath <satish@chromium.org>
        Reviewed by Jeremy Orlow.

        Allow embedder to pass on all the speech recognition results to the input element.
        https://bugs.webkit.org/show_bug.cgi?id=48068

        No new tests added as functionality has not changed, tests will be added in the next
        patch where these results are exposed as an attribute to scripts.

        * Android.mk: Added new source files.
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * page/SpeechInput.cpp:
        (WebCore::SpeechInput::setRecognitionResult): Accept an array instead of a single string.
        * page/SpeechInput.h:
        * page/SpeechInputListener.h:
        * page/SpeechInputResult.cpp: Added, defines a class for managing a speech input result.
        (WebCore::SpeechInputResult::create):
        (WebCore::SpeechInputResult::SpeechInputResult):
        (WebCore::SpeechInputResult::confidence):
        (WebCore::SpeechInputResult::utterance):
        * page/SpeechInputResult.h: Added.
        * platform/mock/SpeechInputClientMock.cpp:
        (WebCore::SpeechInputClientMock::timerFired):
        * rendering/TextControlInnerElements.cpp:
        (WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
        * rendering/TextControlInnerElements.h:
2010-10-21  Satish Sampath  <satish@chromium.org>

        Reviewed by Jeremy Orlow.

        Allow embedder to pass on all the speech recognition results to the input element.
        https://bugs.webkit.org/show_bug.cgi?id=48068

        * WebKit.gyp: Added new files
        * public/WebSpeechInputListener.h:
        * public/WebSpeechInputResult.h: Added, wrapper around WebCore::SpeechInputResult
        (WebKit::WebSpeechInputResult::WebSpeechInputResult):
        (WebKit::WebSpeechInputResult::~WebSpeechInputResult):
        * src/SpeechInputClientImpl.cpp:
        (WebKit::SpeechInputClientImpl::setRecognitionResult): Accepts an array instead of a single string.
        * src/SpeechInputClientImpl.h:
        * src/WebSpeechInputControllerMockImpl.cpp:
        (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
        * src/WebSpeechInputControllerMockImpl.h:
        * src/WebSpeechInputResult.cpp: Added.
        (WebKit::WebSpeechInputResult::reset):
        (WebKit::WebSpeechInputResult::WebSpeechInputResult):
        (WebKit::WebSpeechInputResult::set):
        (WebKit::WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>):

Canonical link: https://commits.webkit.org/61024@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Satish Sampath committed Oct 25, 2010
1 parent c2135e1 commit ffd293b404738ea5719412b22ad9706b44642ed8
Showing 23 changed files with 339 additions and 15 deletions.
@@ -425,6 +425,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
page/Settings.cpp \
page/SpatialNavigation.cpp \
page/SpeechInput.cpp \
page/SpeechInputResult.cpp \
page/SuspendableTimer.cpp \
page/Timing.cpp \
page/UserContentURLPattern.cpp \
@@ -1,3 +1,34 @@
2010-10-21 Satish Sampath <satish@chromium.org>

Reviewed by Jeremy Orlow.

Allow embedder to pass on all the speech recognition results to the input element.
https://bugs.webkit.org/show_bug.cgi?id=48068

No new tests added as functionality has not changed, tests will be added in the next
patch where these results are exposed as an attribute to scripts.

* Android.mk: Added new source files.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* page/SpeechInput.cpp:
(WebCore::SpeechInput::setRecognitionResult): Accept an array instead of a single string.
* page/SpeechInput.h:
* page/SpeechInputListener.h:
* page/SpeechInputResult.cpp: Added, defines a class for managing a speech input result.
(WebCore::SpeechInputResult::create):
(WebCore::SpeechInputResult::SpeechInputResult):
(WebCore::SpeechInputResult::confidence):
(WebCore::SpeechInputResult::utterance):
* page/SpeechInputResult.h: Added.
* platform/mock/SpeechInputClientMock.cpp:
(WebCore::SpeechInputClientMock::timerFired):
* rendering/TextControlInnerElements.cpp:
(WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
* rendering/TextControlInnerElements.h:

2010-10-25 Jian Li <jianli@chromium.org>

Reviewed by David Levin.
@@ -2126,6 +2126,8 @@ webcore_sources += \
WebCore/page/SpeechInput.cpp \
WebCore/page/SpeechInput.h \
WebCore/page/SpeechInputListener.h \
WebCore/page/SpeechInputResult.cpp \
WebCore/page/SpeechInputResult.h \
WebCore/page/SuspendableTimer.cpp \
WebCore/page/SuspendableTimer.h \
WebCore/page/Timing.cpp \
@@ -2263,6 +2263,8 @@
'page/SpeechInput.h',
'page/SpeechInputClient.h',
'page/SpeechInputListener.h',
'page/SpeechInputResult.cpp',
'page/SpeechInputResult.h',
'page/SuspendableTimer.cpp',
'page/SuspendableTimer.h',
'page/Timing.cpp',
@@ -1999,6 +1999,7 @@ HEADERS += \
page/SpeechInput.h \
page/SpeechInputClient.h \
page/SpeechInputListener.h \
page/SpeechInputResult.h \
page/WindowFeatures.h \
page/WorkerNavigator.h \
page/XSSAuditor.h \
@@ -3103,6 +3104,7 @@ contains(DEFINES, ENABLE_SHARED_WORKERS=1) {
contains(DEFINES, ENABLE_INPUT_SPEECH=1) {
SOURCES += \
page/SpeechInput.cpp \
page/SpeechInputResult.cpp \
rendering/RenderInputSpeech.cpp
}

@@ -1478,6 +1478,8 @@
75793ED30D0CE85B007FC0AC /* DOMMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED00D0CE85B007FC0AC /* DOMMessageEvent.h */; };
75793ED40D0CE85B007FC0AC /* DOMMessageEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */; };
75793ED50D0CE85B007FC0AC /* DOMMessageEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */; };
758978EC127090D60076D5A9 /* SpeechInputResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 758978EA127090D60076D5A9 /* SpeechInputResult.cpp */; };
758978ED127090D60076D5A9 /* SpeechInputResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 758978EB127090D60076D5A9 /* SpeechInputResult.h */; };
7637C541112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7637C540112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp */; };
7637C543112E7B7E003D6CDC /* WebSocketHandshakeRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7637C542112E7B7E003D6CDC /* WebSocketHandshakeRequest.h */; };
767F99BE11A1194A0080C51D /* WebSocketHandshakeResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 767F99BD11A1194A0080C51D /* WebSocketHandshakeResponse.cpp */; };
@@ -7589,6 +7591,8 @@
75793ED00D0CE85B007FC0AC /* DOMMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMMessageEvent.h; sourceTree = "<group>"; };
75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMMessageEvent.mm; sourceTree = "<group>"; };
75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMMessageEventInternal.h; sourceTree = "<group>"; };
758978EA127090D60076D5A9 /* SpeechInputResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpeechInputResult.cpp; sourceTree = "<group>"; };
758978EB127090D60076D5A9 /* SpeechInputResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeechInputResult.h; sourceTree = "<group>"; };
7637C540112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketHandshakeRequest.cpp; sourceTree = "<group>"; };
7637C542112E7B7E003D6CDC /* WebSocketHandshakeRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketHandshakeRequest.h; sourceTree = "<group>"; };
767F99BD11A1194A0080C51D /* WebSocketHandshakeResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketHandshakeResponse.cpp; sourceTree = "<group>"; };
@@ -13216,6 +13220,8 @@
7578F90911DDF26900D933C5 /* SpeechInput.h */,
7578F90A11DDF26900D933C5 /* SpeechInputClient.h */,
7578F91E11E4E32800D933C5 /* SpeechInputListener.h */,
758978EA127090D60076D5A9 /* SpeechInputResult.cpp */,
758978EB127090D60076D5A9 /* SpeechInputResult.h */,
62C1217A11AB9E76003C462C /* SuspendableTimer.cpp */,
62C1217B11AB9E77003C462C /* SuspendableTimer.h */,
8AF4E55811DC5A63000ED3DE /* Timing.cpp */,
@@ -21155,6 +21161,7 @@
089021AD126EF5E90092D5EA /* SVGAnimatedLengthList.h in Headers */,
8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */,
087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */,
758978ED127090D60076D5A9 /* SpeechInputResult.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -23708,6 +23715,7 @@
E18772F1126E2629003DD586 /* Language.cpp in Sources */,
7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */,
758978EC127090D60076D5A9 /* SpeechInputResult.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -85,7 +85,7 @@ void SpeechInput::didCompleteRecognition(int listenerId)
m_listeners.get(listenerId)->didCompleteRecognition(listenerId);
}

void SpeechInput::setRecognitionResult(int listenerId, const String& result)
void SpeechInput::setRecognitionResult(int listenerId, const SpeechInputResultArray& result)
{
// Don't assert if not present as the element might have been removed by the page while
// this event was on the way.
@@ -68,7 +68,7 @@ class SpeechInput : public Noncopyable, public SpeechInputListener {
// SpeechInputListener methods.
virtual void didCompleteRecording(int);
virtual void didCompleteRecognition(int);
virtual void setRecognitionResult(int, const String&);
virtual void setRecognitionResult(int, const SpeechInputResultArray&);

private:
SpeechInputClient* m_client;
@@ -33,10 +33,13 @@

#if ENABLE(INPUT_SPEECH)

#include "SpeechInputResult.h"
#include <wtf/Forward.h>

namespace WebCore {

typedef Vector<RefPtr<SpeechInputResult> > SpeechInputResultArray;

// Interface to be implemented by the element which invokes SpeechInput.
class SpeechInputListener {
public:
@@ -53,7 +56,7 @@ class SpeechInputListener {
// 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(int requestId, const String& result) = 0;
virtual void setRecognitionResult(int requestId, const SpeechInputResultArray&) = 0;

protected:
virtual ~SpeechInputListener() { }
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "SpeechInputResult.h"

#if ENABLE(INPUT_SPEECH)

namespace WebCore {

PassRefPtr<SpeechInputResult> SpeechInputResult::create(const String& utterance, double confidence)
{
return adoptRef(new SpeechInputResult(utterance, confidence));
}

SpeechInputResult::SpeechInputResult(const String& utterance, double confidence)
: m_utterance(utterance)
, m_confidence(confidence)
{
}

double SpeechInputResult::confidence() const
{
return m_confidence;
}

const String& SpeechInputResult::utterance() const
{
return m_utterance;
}

} // namespace WebCore

#endif // ENABLE(INPUT_SPEECH)
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef SpeechInputResult_h
#define SpeechInputResult_h

#if ENABLE(INPUT_SPEECH)

#include "PlatformString.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>

namespace WebCore {

// This class holds one speech recognition result including the text and other related
// fields, as received from the embedder.
class SpeechInputResult : public RefCounted<SpeechInputResult> {
public:
static PassRefPtr<SpeechInputResult> create(const String& utterance, double confidence);

double confidence() const;
const String& utterance() const;

private:
SpeechInputResult(const String& utterance, double confidence);

String m_utterance;
double m_confidence;
};

} // namespace WebCore

#endif // ENABLE(INPUT_SPEECH)

#endif // SpeechInputResult_h
@@ -92,7 +92,9 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
m_listener->didCompleteRecording(m_requestId);
m_timer.startOneShot(0);
} else {
m_listener->setRecognitionResult(m_requestId, m_recognitionResult);
SpeechInputResultArray results;
results.append(SpeechInputResult::create(m_recognitionResult, 1.0));
m_listener->setRecognitionResult(m_requestId, results);
m_listener->didCompleteRecognition(m_requestId);
m_requestId = 0;
}
@@ -471,14 +471,16 @@ void InputFieldSpeechButtonElement::didCompleteRecognition(int)
setState(Idle);
}

void InputFieldSpeechButtonElement::setRecognitionResult(int, const String& result)
void InputFieldSpeechButtonElement::setRecognitionResult(int, const SpeechInputResultArray& results)
{
m_results = results;

HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
// The call to setValue() below dispatches an event, and an event handler in the page might
// remove the input element from DOM. To make sure it remains valid until we finish our work
// here, we take a temporary reference.
RefPtr<HTMLInputElement> holdRef(input);
input->setValue(result);
input->setValue(results.isEmpty() ? "" : results[0]->utterance());
input->dispatchWebkitSpeechChangeEvent();
renderer()->repaint();
}
@@ -141,7 +141,7 @@ class InputFieldSpeechButtonElement
// SpeechInputListener methods.
void didCompleteRecording(int);
void didCompleteRecognition(int);
void setRecognitionResult(int, const String& result);
void setRecognitionResult(int, const SpeechInputResultArray&);

private:
InputFieldSpeechButtonElement(HTMLElement*);
@@ -151,6 +151,7 @@ class InputFieldSpeechButtonElement
bool m_capturing;
SpeechInputState m_state;
int m_listenerId;
SpeechInputResultArray m_results;
};

#endif // ENABLE(INPUT_SPEECH)
@@ -1,3 +1,27 @@
2010-10-21 Satish Sampath <satish@chromium.org>

Reviewed by Jeremy Orlow.

Allow embedder to pass on all the speech recognition results to the input element.
https://bugs.webkit.org/show_bug.cgi?id=48068

* WebKit.gyp: Added new files
* public/WebSpeechInputListener.h:
* public/WebSpeechInputResult.h: Added, wrapper around WebCore::SpeechInputResult
(WebKit::WebSpeechInputResult::WebSpeechInputResult):
(WebKit::WebSpeechInputResult::~WebSpeechInputResult):
* src/SpeechInputClientImpl.cpp:
(WebKit::SpeechInputClientImpl::setRecognitionResult): Accepts an array instead of a single string.
* src/SpeechInputClientImpl.h:
* src/WebSpeechInputControllerMockImpl.cpp:
(WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
* src/WebSpeechInputControllerMockImpl.h:
* src/WebSpeechInputResult.cpp: Added.
(WebKit::WebSpeechInputResult::reset):
(WebKit::WebSpeechInputResult::WebSpeechInputResult):
(WebKit::WebSpeechInputResult::set):
(WebKit::WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>):

2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r70451.
@@ -257,6 +257,7 @@
'public/WebSpeechInputController.h',
'public/WebSpeechInputControllerMock.h',
'public/WebSpeechInputListener.h',
'public/WebSpeechInputResult.h',
'public/WebStorageArea.h',
'public/WebStorageEventDispatcher.h',
'public/WebStorageNamespace.h',
@@ -518,6 +519,7 @@
'src/WebSharedWorkerImpl.h',
'src/WebSpeechInputControllerMockImpl.cpp',
'src/WebSpeechInputControllerMockImpl.h',
'src/WebSpeechInputResult.cpp',
'src/WebStorageAreaImpl.cpp',
'src/WebStorageAreaImpl.h',
'src/WebStorageEventDispatcherImpl.cpp',

0 comments on commit ffd293b

Please sign in to comment.