[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

satish at chromium.org satish at chromium.org
Wed Dec 22 14:56:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit bc97234a4a03acd2690f0bc1e0bc8ade5618cd25
Author: satish at chromium.org <satish at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 25 21:10:27 2010 +0000

    2010-10-21  Satish Sampath  <satish at 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 at 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>):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70490 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 8cccc96..e20b2e5 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -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 \
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c29a99b..b67adb6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-10-21  Satish Sampath  <satish at 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 at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 3c8783f..c6e3978 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -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 \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index cd65668..fba1c33 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -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',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index b555207..84869b4 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -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
 }
 
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 4c1e01d..0cbd7f0 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -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;
 		};
diff --git a/WebCore/page/SpeechInput.cpp b/WebCore/page/SpeechInput.cpp
index 234791b..b3f549e 100644
--- a/WebCore/page/SpeechInput.cpp
+++ b/WebCore/page/SpeechInput.cpp
@@ -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.
diff --git a/WebCore/page/SpeechInput.h b/WebCore/page/SpeechInput.h
index d10b789..b521f3a 100644
--- a/WebCore/page/SpeechInput.h
+++ b/WebCore/page/SpeechInput.h
@@ -68,7 +68,7 @@ public:
     // 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;
diff --git a/WebCore/page/SpeechInputListener.h b/WebCore/page/SpeechInputListener.h
index 36060fc..568b1b7 100644
--- a/WebCore/page/SpeechInputListener.h
+++ b/WebCore/page/SpeechInputListener.h
@@ -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 @@ public:
     // 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() { }
diff --git a/WebCore/page/SpeechInputResult.cpp b/WebCore/page/SpeechInputResult.cpp
new file mode 100644
index 0000000..f5b6972
--- /dev/null
+++ b/WebCore/page/SpeechInputResult.cpp
@@ -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)
diff --git a/WebCore/page/SpeechInputResult.h b/WebCore/page/SpeechInputResult.h
new file mode 100644
index 0000000..ef9fd10
--- /dev/null
+++ b/WebCore/page/SpeechInputResult.h
@@ -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
diff --git a/WebCore/platform/mock/SpeechInputClientMock.cpp b/WebCore/platform/mock/SpeechInputClientMock.cpp
index 6b64942..a1b4da9 100644
--- a/WebCore/platform/mock/SpeechInputClientMock.cpp
+++ b/WebCore/platform/mock/SpeechInputClientMock.cpp
@@ -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;
     }
diff --git a/WebCore/rendering/TextControlInnerElements.cpp b/WebCore/rendering/TextControlInnerElements.cpp
index 5d5b8b3..e193ebb 100644
--- a/WebCore/rendering/TextControlInnerElements.cpp
+++ b/WebCore/rendering/TextControlInnerElements.cpp
@@ -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();
 }
diff --git a/WebCore/rendering/TextControlInnerElements.h b/WebCore/rendering/TextControlInnerElements.h
index c146a42..46c1c8e 100644
--- a/WebCore/rendering/TextControlInnerElements.h
+++ b/WebCore/rendering/TextControlInnerElements.h
@@ -141,7 +141,7 @@ public:
     // 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 @@ private:
     bool m_capturing;
     SpeechInputState m_state;
     int m_listenerId;
+    SpeechInputResultArray m_results;
 };
 
 #endif // ENABLE(INPUT_SPEECH)
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 6816ebb..c5ba564 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,27 @@
+2010-10-21  Satish Sampath  <satish at 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 at gmail.com>
 
         Unreviewed, rolling out r70451.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index a77c6f3..484fb0d 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -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',
diff --git a/WebKit/chromium/public/WebSpeechInputListener.h b/WebKit/chromium/public/WebSpeechInputListener.h
index 6dc3d49..04d6f72 100644
--- a/WebKit/chromium/public/WebSpeechInputListener.h
+++ b/WebKit/chromium/public/WebSpeechInputListener.h
@@ -31,6 +31,8 @@
 #ifndef WebSpeechInputListener_h
 #define WebSpeechInputListener_h
 
+#include "WebSpeechInputResult.h"
+
 namespace WebKit {
 
 class WebString;
@@ -47,19 +49,28 @@ 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(int) = 0;
+    virtual void didCompleteRecording(int) { WEBKIT_ASSERT_NOT_REACHED(); }
 
     // 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(int, const WebString&) = 0;
+    virtual void setRecognitionResult(int, const WebSpeechInputResultArray&) { WEBKIT_ASSERT_NOT_REACHED(); }
+
+    // FIXME: Remove this once the chromium side is able to send multiple recognition results
+    // using the above call.
+    virtual void setRecognitionResult(int requestId, const WebString& result)
+    {
+        WebSpeechInputResultArray results(1U);
+        results[0].set(result, 1.0);
+        setRecognitionResult(requestId, results);
+    }
 
     // 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(int) = 0;
+    virtual void didCompleteRecognition(int) { WEBKIT_ASSERT_NOT_REACHED(); }
 
 protected:
     ~WebSpeechInputListener() { }
diff --git a/WebKit/chromium/public/WebSpeechInputResult.h b/WebKit/chromium/public/WebSpeechInputResult.h
new file mode 100644
index 0000000..8f1a8f5
--- /dev/null
+++ b/WebKit/chromium/public/WebSpeechInputResult.h
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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 WebSpeechInputResult_h
+#define WebSpeechInputResult_h
+
+#include "WebCommon.h"
+#include "WebPrivatePtr.h"
+#include "WebString.h"
+#include "WebVector.h"
+
+namespace WebCore {
+class SpeechInputResult;
+}
+
+namespace WebKit {
+
+// This class holds one speech recognition result including the text and other related
+// fields, as received from the embedder.
+class WebSpeechInputResult {
+public:
+    WebSpeechInputResult() { }
+    ~WebSpeechInputResult() { reset(); }
+
+    WEBKIT_API void set(const WebString& utterance, double confidence);
+    WEBKIT_API void reset();
+
+#if WEBKIT_IMPLEMENTATION
+    WebSpeechInputResult(const WTF::PassRefPtr<WebCore::SpeechInputResult>&);
+    operator WTF::PassRefPtr<WebCore::SpeechInputResult>() const;
+#endif
+
+private:
+    WebPrivatePtr<WebCore::SpeechInputResult> m_private;
+};
+
+typedef WebVector<WebSpeechInputResult> WebSpeechInputResultArray;
+
+} // namespace WebKit
+
+#endif // WebSpeechInputResult_h
diff --git a/WebKit/chromium/src/SpeechInputClientImpl.cpp b/WebKit/chromium/src/SpeechInputClientImpl.cpp
index 963d440..88e13a7 100644
--- a/WebKit/chromium/src/SpeechInputClientImpl.cpp
+++ b/WebKit/chromium/src/SpeechInputClientImpl.cpp
@@ -86,10 +86,13 @@ void SpeechInputClientImpl::didCompleteRecognition(int requestId)
     m_listener->didCompleteRecognition(requestId);
 }
 
-void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebString& result)
+void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebSpeechInputResultArray& results)
 {
     ASSERT(m_listener);
-    m_listener->setRecognitionResult(requestId, result);
+    WebCore::SpeechInputResultArray webcoreResults(results.size());
+    for (size_t i = 0; i < results.size(); ++i)
+        webcoreResults[i] = results[i];
+    m_listener->setRecognitionResult(requestId, webcoreResults);
 }
 
 } // namespace WebKit
diff --git a/WebKit/chromium/src/SpeechInputClientImpl.h b/WebKit/chromium/src/SpeechInputClientImpl.h
index 817b32b..c8c23f8 100644
--- a/WebKit/chromium/src/SpeechInputClientImpl.h
+++ b/WebKit/chromium/src/SpeechInputClientImpl.h
@@ -60,7 +60,7 @@ public:
 
     // WebSpeechInputListener methods.
     void didCompleteRecording(int);
-    void setRecognitionResult(int, const WebString&);
+    void setRecognitionResult(int, const WebSpeechInputResultArray&);
     void didCompleteRecognition(int);
 
 private:
diff --git a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
index 60c4fed..bd15fa4 100644
--- a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
+++ b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
@@ -70,7 +70,7 @@ void WebSpeechInputControllerMockImpl::didCompleteRecognition(int requestId)
     m_listener->didCompleteRecognition(requestId);
 }
 
-void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WTF::String& result)
+void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result)
 {
     m_listener->setRecognitionResult(requestId, result);
 }
diff --git a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
index edbfca3..5d10f89 100644
--- a/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
+++ b/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
@@ -54,7 +54,7 @@ public:
     // WebCore::SpeechInputListener methods.
     void didCompleteRecording(int requestId);
     void didCompleteRecognition(int requestId);
-    void setRecognitionResult(int requestId, const WTF::String& result);
+    void setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result);
 
     // WebSpeechInputController methods.
     bool startRecognition(int requestId, const WebRect& elementRect);
diff --git a/WebKit/chromium/src/WebSpeechInputResult.cpp b/WebKit/chromium/src/WebSpeechInputResult.cpp
new file mode 100644
index 0000000..1cafc84
--- /dev/null
+++ b/WebKit/chromium/src/WebSpeechInputResult.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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 "WebSpeechInputResult.h"
+
+#include "SpeechInputResult.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+void WebSpeechInputResult::reset()
+{
+    m_private.reset();
+}
+
+WebSpeechInputResult::WebSpeechInputResult(const PassRefPtr<WebCore::SpeechInputResult>& value)
+    : m_private(value)
+{
+}
+
+void WebSpeechInputResult::set(const WebString& utterance, double confidence)
+{
+    m_private = WebCore::SpeechInputResult::create(utterance, confidence);
+}
+
+WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>() const
+{
+    return m_private.get();
+}
+
+} // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list