Changeset 70490 in webkit


Ignore:
Timestamp:
Oct 25, 2010 2:10:27 PM (14 years ago)
Author:
satish@chromium.org
Message:

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>):
Location:
trunk
Files:
4 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.mk

    r70318 r70490  
    426426        page/SpatialNavigation.cpp \
    427427        page/SpeechInput.cpp \
     428        page/SpeechInputResult.cpp \
    428429        page/SuspendableTimer.cpp \
    429430        page/Timing.cpp \
  • trunk/WebCore/ChangeLog

    r70488 r70490  
     12010-10-21  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Allow embedder to pass on all the speech recognition results to the input element.
     6        https://bugs.webkit.org/show_bug.cgi?id=48068
     7
     8        No new tests added as functionality has not changed, tests will be added in the next
     9        patch where these results are exposed as an attribute to scripts.
     10
     11        * Android.mk: Added new source files.
     12        * GNUmakefile.am:
     13        * WebCore.gypi:
     14        * WebCore.pro:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * page/SpeechInput.cpp:
     17        (WebCore::SpeechInput::setRecognitionResult): Accept an array instead of a single string.
     18        * page/SpeechInput.h:
     19        * page/SpeechInputListener.h:
     20        * page/SpeechInputResult.cpp: Added, defines a class for managing a speech input result.
     21        (WebCore::SpeechInputResult::create):
     22        (WebCore::SpeechInputResult::SpeechInputResult):
     23        (WebCore::SpeechInputResult::confidence):
     24        (WebCore::SpeechInputResult::utterance):
     25        * page/SpeechInputResult.h: Added.
     26        * platform/mock/SpeechInputClientMock.cpp:
     27        (WebCore::SpeechInputClientMock::timerFired):
     28        * rendering/TextControlInnerElements.cpp:
     29        (WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
     30        * rendering/TextControlInnerElements.h:
     31
    1322010-10-25  Jian Li  <jianli@chromium.org>
    233
  • trunk/WebCore/GNUmakefile.am

    r70410 r70490  
    21272127        WebCore/page/SpeechInput.h \
    21282128        WebCore/page/SpeechInputListener.h \
     2129        WebCore/page/SpeechInputResult.cpp \
     2130        WebCore/page/SpeechInputResult.h \
    21292131        WebCore/page/SuspendableTimer.cpp \
    21302132        WebCore/page/SuspendableTimer.h \
  • trunk/WebCore/WebCore.gypi

    r70410 r70490  
    22642264            'page/SpeechInputClient.h',
    22652265            'page/SpeechInputListener.h',
     2266            'page/SpeechInputResult.cpp',
     2267            'page/SpeechInputResult.h',
    22662268            'page/SuspendableTimer.cpp',
    22672269            'page/SuspendableTimer.h',
  • trunk/WebCore/WebCore.pro

    r70485 r70490  
    20002000    page/SpeechInputClient.h \
    20012001    page/SpeechInputListener.h \
     2002    page/SpeechInputResult.h \
    20022003    page/WindowFeatures.h \
    20032004    page/WorkerNavigator.h \
     
    31043105    SOURCES += \
    31053106        page/SpeechInput.cpp \
     3107        page/SpeechInputResult.cpp \
    31063108        rendering/RenderInputSpeech.cpp
    31073109}
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r70410 r70490  
    14791479                75793ED40D0CE85B007FC0AC /* DOMMessageEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */; };
    14801480                75793ED50D0CE85B007FC0AC /* DOMMessageEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */; };
     1481                758978EC127090D60076D5A9 /* SpeechInputResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 758978EA127090D60076D5A9 /* SpeechInputResult.cpp */; };
     1482                758978ED127090D60076D5A9 /* SpeechInputResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 758978EB127090D60076D5A9 /* SpeechInputResult.h */; };
    14811483                7637C541112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7637C540112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp */; };
    14821484                7637C543112E7B7E003D6CDC /* WebSocketHandshakeRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7637C542112E7B7E003D6CDC /* WebSocketHandshakeRequest.h */; };
     
    75907592                75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMMessageEvent.mm; sourceTree = "<group>"; };
    75917593                75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMMessageEventInternal.h; sourceTree = "<group>"; };
     7594                758978EA127090D60076D5A9 /* SpeechInputResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpeechInputResult.cpp; sourceTree = "<group>"; };
     7595                758978EB127090D60076D5A9 /* SpeechInputResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeechInputResult.h; sourceTree = "<group>"; };
    75927596                7637C540112E7B74003D6CDC /* WebSocketHandshakeRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketHandshakeRequest.cpp; sourceTree = "<group>"; };
    75937597                7637C542112E7B7E003D6CDC /* WebSocketHandshakeRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketHandshakeRequest.h; sourceTree = "<group>"; };
     
    1321713221                                7578F90A11DDF26900D933C5 /* SpeechInputClient.h */,
    1321813222                                7578F91E11E4E32800D933C5 /* SpeechInputListener.h */,
     13223                                758978EA127090D60076D5A9 /* SpeechInputResult.cpp */,
     13224                                758978EB127090D60076D5A9 /* SpeechInputResult.h */,
    1321913225                                62C1217A11AB9E76003C462C /* SuspendableTimer.cpp */,
    1322013226                                62C1217B11AB9E77003C462C /* SuspendableTimer.h */,
     
    2115621162                                8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */,
    2115721163                                087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */,
     21164                                758978ED127090D60076D5A9 /* SpeechInputResult.h in Headers */,
    2115821165                        );
    2115921166                        runOnlyForDeploymentPostprocessing = 0;
     
    2370923716                                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
    2371023717                                E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */,
     23718                                758978EC127090D60076D5A9 /* SpeechInputResult.cpp in Sources */,
    2371123719                        );
    2371223720                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/page/SpeechInput.cpp

    r70302 r70490  
    8686}
    8787
    88 void SpeechInput::setRecognitionResult(int listenerId, const String& result)
     88void SpeechInput::setRecognitionResult(int listenerId, const SpeechInputResultArray& result)
    8989{
    9090    // Don't assert if not present as the element might have been removed by the page while
  • trunk/WebCore/page/SpeechInput.h

    r70302 r70490  
    6969    virtual void didCompleteRecording(int);
    7070    virtual void didCompleteRecognition(int);
    71     virtual void setRecognitionResult(int, const String&);
     71    virtual void setRecognitionResult(int, const SpeechInputResultArray&);
    7272
    7373private:
  • trunk/WebCore/page/SpeechInputListener.h

    r65327 r70490  
    3434#if ENABLE(INPUT_SPEECH)
    3535
     36#include "SpeechInputResult.h"
    3637#include <wtf/Forward.h>
    3738
    3839namespace WebCore {
     40
     41typedef Vector<RefPtr<SpeechInputResult> > SpeechInputResultArray;
    3942
    4043// Interface to be implemented by the element which invokes SpeechInput.
     
    5457    // available as the user keeps speaking. If the speech could not be recognized properly
    5558    // or if there was any other errors in the process, this method may never be called.
    56     virtual void setRecognitionResult(int requestId, const String& result) = 0;
     59    virtual void setRecognitionResult(int requestId, const SpeechInputResultArray&) = 0;
    5760
    5861protected:
  • trunk/WebCore/platform/mock/SpeechInputClientMock.cpp

    r70302 r70490  
    9393        m_timer.startOneShot(0);
    9494    } else {
    95         m_listener->setRecognitionResult(m_requestId, m_recognitionResult);
     95        SpeechInputResultArray results;
     96        results.append(SpeechInputResult::create(m_recognitionResult, 1.0));
     97        m_listener->setRecognitionResult(m_requestId, results);
    9698        m_listener->didCompleteRecognition(m_requestId);
    9799        m_requestId = 0;
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r70302 r70490  
    472472}
    473473
    474 void InputFieldSpeechButtonElement::setRecognitionResult(int, const String& result)
    475 {
     474void InputFieldSpeechButtonElement::setRecognitionResult(int, const SpeechInputResultArray& results)
     475{
     476    m_results = results;
     477
    476478    HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
    477479    // The call to setValue() below dispatches an event, and an event handler in the page might
     
    479481    // here, we take a temporary reference.
    480482    RefPtr<HTMLInputElement> holdRef(input);
    481     input->setValue(result);
     483    input->setValue(results.isEmpty() ? "" : results[0]->utterance());
    482484    input->dispatchWebkitSpeechChangeEvent();
    483485    renderer()->repaint();
  • trunk/WebCore/rendering/TextControlInnerElements.h

    r66001 r70490  
    142142    void didCompleteRecording(int);
    143143    void didCompleteRecognition(int);
    144     void setRecognitionResult(int, const String& result);
     144    void setRecognitionResult(int, const SpeechInputResultArray&);
    145145
    146146private:
     
    152152    SpeechInputState m_state;
    153153    int m_listenerId;
     154    SpeechInputResultArray m_results;
    154155};
    155156
  • trunk/WebKit/chromium/ChangeLog

    r70463 r70490  
     12010-10-21  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Allow embedder to pass on all the speech recognition results to the input element.
     6        https://bugs.webkit.org/show_bug.cgi?id=48068
     7
     8        * WebKit.gyp: Added new files
     9        * public/WebSpeechInputListener.h:
     10        * public/WebSpeechInputResult.h: Added, wrapper around WebCore::SpeechInputResult
     11        (WebKit::WebSpeechInputResult::WebSpeechInputResult):
     12        (WebKit::WebSpeechInputResult::~WebSpeechInputResult):
     13        * src/SpeechInputClientImpl.cpp:
     14        (WebKit::SpeechInputClientImpl::setRecognitionResult): Accepts an array instead of a single string.
     15        * src/SpeechInputClientImpl.h:
     16        * src/WebSpeechInputControllerMockImpl.cpp:
     17        (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
     18        * src/WebSpeechInputControllerMockImpl.h:
     19        * src/WebSpeechInputResult.cpp: Added.
     20        (WebKit::WebSpeechInputResult::reset):
     21        (WebKit::WebSpeechInputResult::WebSpeechInputResult):
     22        (WebKit::WebSpeechInputResult::set):
     23        (WebKit::WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>):
     24
    1252010-10-25  Sheriff Bot  <webkit.review.bot@gmail.com>
    226
  • trunk/WebKit/chromium/WebKit.gyp

    r70273 r70490  
    258258                'public/WebSpeechInputControllerMock.h',
    259259                'public/WebSpeechInputListener.h',
     260                'public/WebSpeechInputResult.h',
    260261                'public/WebStorageArea.h',
    261262                'public/WebStorageEventDispatcher.h',
     
    519520                'src/WebSpeechInputControllerMockImpl.cpp',
    520521                'src/WebSpeechInputControllerMockImpl.h',
     522                'src/WebSpeechInputResult.cpp',
    521523                'src/WebStorageAreaImpl.cpp',
    522524                'src/WebStorageAreaImpl.h',
  • trunk/WebKit/chromium/public/WebSpeechInputListener.h

    r65815 r70490  
    3232#define WebSpeechInputListener_h
    3333
     34#include "WebSpeechInputResult.h"
     35
    3436namespace WebKit {
    3537
     
    4850    // Typically after this call the listener would update the UI to reflect that recognition is
    4951    // in progress.
    50     virtual void didCompleteRecording(int) = 0;
     52    virtual void didCompleteRecording(int) { WEBKIT_ASSERT_NOT_REACHED(); }
    5153
    5254    // Gives results from speech recognition, either partial or the final results.
     
    5456    // available as the user keeps speaking. If the speech could not be recognized properly
    5557    // or if there was any other errors in the process, this method may never be called.
    56     virtual void setRecognitionResult(int, const WebString&) = 0;
     58    virtual void setRecognitionResult(int, const WebSpeechInputResultArray&) { WEBKIT_ASSERT_NOT_REACHED(); }
     59
     60    // FIXME: Remove this once the chromium side is able to send multiple recognition results
     61    // using the above call.
     62    virtual void setRecognitionResult(int requestId, const WebString& result)
     63    {
     64        WebSpeechInputResultArray results(1U);
     65        results[0].set(result, 1.0);
     66        setRecognitionResult(requestId, results);
     67    }
    5768
    5869    // Informs that speech recognition has completed. This gets invoked irrespective of whether
     
    6071    // handler typically frees up any temporary resources allocated and waits for the next speech
    6172    // recognition request.
    62     virtual void didCompleteRecognition(int) = 0;
     73    virtual void didCompleteRecognition(int) { WEBKIT_ASSERT_NOT_REACHED(); }
    6374
    6475protected:
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.cpp

    r70302 r70490  
    8787}
    8888
    89 void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebString& result)
     89void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebSpeechInputResultArray& results)
    9090{
    9191    ASSERT(m_listener);
    92     m_listener->setRecognitionResult(requestId, result);
     92    WebCore::SpeechInputResultArray webcoreResults(results.size());
     93    for (size_t i = 0; i < results.size(); ++i)
     94        webcoreResults[i] = results[i];
     95    m_listener->setRecognitionResult(requestId, webcoreResults);
    9396}
    9497
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.h

    r70302 r70490  
    6161    // WebSpeechInputListener methods.
    6262    void didCompleteRecording(int);
    63     void setRecognitionResult(int, const WebString&);
     63    void setRecognitionResult(int, const WebSpeechInputResultArray&);
    6464    void didCompleteRecognition(int);
    6565
  • trunk/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp

    r70302 r70490  
    7171}
    7272
    73 void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WTF::String& result)
     73void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result)
    7474{
    7575    m_listener->setRecognitionResult(requestId, result);
  • trunk/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h

    r70302 r70490  
    5555    void didCompleteRecording(int requestId);
    5656    void didCompleteRecognition(int requestId);
    57     void setRecognitionResult(int requestId, const WTF::String& result);
     57    void setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result);
    5858
    5959    // WebSpeechInputController methods.
Note: See TracChangeset for help on using the changeset viewer.