Changeset 70567 in webkit


Ignore:
Timestamp:
Oct 26, 2010 1:40:37 PM (13 years ago)
Author:
satish@chromium.org
Message:

2010-10-26 Satish Sampath <satish@chromium.org>

Reviewed by Jeremy Orlow.

Add a 'grammar' attribute for speech input.
https://bugs.webkit.org/show_bug.cgi?id=48339

To differentiate between various types of speech input, we add a 'x-webkit-grammar' attribute to a
speech enabled input element. This is passed without validation to the speech recognizer. Typical values
could be "builtin:search", "builtin:dictation" and even an externally hosted SRGS grammar XML file URI.
It is up to the recognizer to interpret the value and use it as an aid in recognition.

  • bindings/generic/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webkitGrammarEnabled):
  • html/HTMLAttributeNames.in:
  • html/HTMLInputElement.idl:
  • page/SpeechInput.cpp: (WebCore::SpeechInput::startRecognition):
  • page/SpeechInput.h:
  • page/SpeechInputClient.h:
  • platform/mock/SpeechInputClientMock.cpp: (WebCore::SpeechInputClientMock::startRecognition):
  • platform/mock/SpeechInputClientMock.h:
  • rendering/TextControlInnerElements.cpp: (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):

2010-10-26 Satish Sampath <satish@chromium.org>

Reviewed by Jeremy Orlow.

Add a 'grammar' attribute for speech input.
https://bugs.webkit.org/show_bug.cgi?id=48339

To differentiate between various types of speech input, we add a 'x-webkit-grammar' attribute to a
speech enabled input element. This is passed without validation to the speech recognizer. Typical values
could be "builtin:search", "builtin:dictation" and even an externally hosted SRGS grammar XML file URI.
It is up to the recognizer to interpret the value and use it as an aid in recognition.

  • public/WebSpeechInputController.h: (WebKit::WebSpeechInputController::startRecognition):
  • src/SpeechInputClientImpl.cpp: (WebKit::SpeechInputClientImpl::startRecognition):
  • src/SpeechInputClientImpl.h:
  • src/WebSpeechInputControllerMockImpl.cpp: (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
  • src/WebSpeechInputControllerMockImpl.h:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70566 r70567  
     12010-10-26  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Add a 'grammar' attribute for speech input.
     6        https://bugs.webkit.org/show_bug.cgi?id=48339
     7
     8        To differentiate between various types of speech input, we add a 'x-webkit-grammar' attribute to a
     9        speech enabled input element. This is passed without validation to the speech recognizer. Typical values
     10        could be "builtin:search", "builtin:dictation" and even an externally hosted SRGS grammar XML file URI.
     11        It is up to the recognizer to interpret the value and use it as an aid in recognition.
     12
     13        * bindings/generic/RuntimeEnabledFeatures.h:
     14        (WebCore::RuntimeEnabledFeatures::webkitGrammarEnabled):
     15        * html/HTMLAttributeNames.in:
     16        * html/HTMLInputElement.idl:
     17        * page/SpeechInput.cpp:
     18        (WebCore::SpeechInput::startRecognition):
     19        * page/SpeechInput.h:
     20        * page/SpeechInputClient.h:
     21        * platform/mock/SpeechInputClientMock.cpp:
     22        (WebCore::SpeechInputClientMock::startRecognition):
     23        * platform/mock/SpeechInputClientMock.h:
     24        * rendering/TextControlInnerElements.cpp:
     25        (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
     26
    1272010-10-26  Pavel Feldman  <pfeldman@chromium.org>
    228
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.h

    r70478 r70567  
    140140    static bool speechInputEnabled() { return isSpeechInputEnabled; }
    141141    static bool webkitSpeechEnabled() { return isSpeechInputEnabled; }
     142    static bool webkitGrammarEnabled() { return isSpeechInputEnabled; }
    142143
    143144#if ENABLE(XHR_RESPONSE_BLOB)
  • trunk/WebCore/html/HTMLAttributeNames.in

    r69100 r70567  
    261261span
    262262x-webkit-speech
     263x-webkit-grammar
    263264spellcheck
    264265src
  • trunk/WebCore/html/HTMLInputElement.idl

    r69100 r70567  
    102102#if defined(ENABLE_INPUT_SPEECH) && ENABLE_INPUT_SPEECH
    103103        attribute [Reflect, EnabledAtRuntime] boolean webkitSpeech;
     104        attribute [Reflect, EnabledAtRuntime] boolean webkitGrammar;
    104105        attribute [DontEnum] EventListener onwebkitspeechchange;
    105106#endif
  • trunk/WebCore/page/SpeechInput.cpp

    r70490 r70567  
    9494}
    9595
    96 bool SpeechInput::startRecognition(int listenerId, const IntRect& elementRect)
     96bool SpeechInput::startRecognition(int listenerId, const IntRect& elementRect, const String& grammar)
    9797{
    9898    ASSERT(m_listeners.contains(listenerId));
    99     return m_client->startRecognition(listenerId, elementRect);
     99    return m_client->startRecognition(listenerId, elementRect, grammar);
    100100}
    101101
  • trunk/WebCore/page/SpeechInput.h

    r70490 r70567  
    6262
    6363    // Methods invoked by the input elements.
    64     bool startRecognition(int, const IntRect&);
     64    bool startRecognition(int listenerId, const IntRect& elementRect, const String& grammar);
    6565    void stopRecording(int);
    6666    void cancelRecognition(int);
  • trunk/WebCore/page/SpeechInputClient.h

    r70302 r70567  
    3232#define SpeechInputClient_h
    3333
     34#include <wtf/Forward.h>
     35
    3436#if ENABLE(INPUT_SPEECH)
    3537
     
    4951
    5052    // Starts speech recognition and audio recording.
    51     virtual bool startRecognition(int requestId, const IntRect& elementRect) = 0;
     53    virtual bool startRecognition(int requestId, const IntRect& elementRect, const String& grammar) = 0;
    5254
    5355    // Stops audio recording and performs recognition with the audio recorded until now
  • trunk/WebCore/platform/mock/SpeechInputClientMock.cpp

    r70490 r70567  
    5151}
    5252
    53 bool SpeechInputClientMock::startRecognition(int requestId, const IntRect&)
     53bool SpeechInputClientMock::startRecognition(int requestId, const IntRect& elementRect, const String& grammar)
    5454{
    5555    if (m_timer.isActive())
  • trunk/WebCore/platform/mock/SpeechInputClientMock.h

    r70302 r70567  
    5151    // SpeechInputClient methods.
    5252    void setListener(SpeechInputListener*);
    53     bool startRecognition(int, const IntRect&);
     53    bool startRecognition(int requestId, const IntRect& elementRect, const String& grammar);
    5454    void stopRecording(int);
    5555    void cancelRecognition(int);
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r70490 r70567  
    432432        switch (m_state) {
    433433        case Idle:
    434             if (speechInput()->startRecognition(m_listenerId, input->renderer()->absoluteBoundingBoxRect()))
     434            if (speechInput()->startRecognition(m_listenerId, input->renderer()->absoluteBoundingBoxRect(), input->getAttribute(webkitgrammarAttr)))
    435435                setState(Recording);
    436436            break;
  • trunk/WebKit/chromium/ChangeLog

    r70559 r70567  
     12010-10-26  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Add a 'grammar' attribute for speech input.
     6        https://bugs.webkit.org/show_bug.cgi?id=48339
     7
     8        To differentiate between various types of speech input, we add a 'x-webkit-grammar' attribute to a
     9        speech enabled input element. This is passed without validation to the speech recognizer. Typical values
     10        could be "builtin:search", "builtin:dictation" and even an externally hosted SRGS grammar XML file URI.
     11        It is up to the recognizer to interpret the value and use it as an aid in recognition.
     12
     13        * public/WebSpeechInputController.h:
     14        (WebKit::WebSpeechInputController::startRecognition):
     15        * src/SpeechInputClientImpl.cpp:
     16        (WebKit::SpeechInputClientImpl::startRecognition):
     17        * src/SpeechInputClientImpl.h:
     18        * src/WebSpeechInputControllerMockImpl.cpp:
     19        (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
     20        * src/WebSpeechInputControllerMockImpl.h:
     21
    1222010-10-26  Hans Wennborg  <hans@chromium.org>
    223
  • trunk/WebKit/chromium/public/WebSpeechInputController.h

    r70302 r70567  
    3737
    3838struct WebRect;
     39class WebString;
    3940
    4041// Provides an embedder API called by WebKit.
     
    4445    // runs to the limit or stopRecording is called. Progress indications and the recognized
    4546    // text are returned via the listener interface.
     47    virtual bool startRecognition(int requestId, const WebRect& elementRect, const WebString& grammar)
     48    {
     49        startRecognition(requestId, elementRect);
     50        return false;
     51    }
     52
     53    // FIXME: Remove this method once chromium implements the above method.
    4654    virtual bool startRecognition(int requestId, const WebRect&)
    4755    {
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.cpp

    r70490 r70567  
    5757}
    5858
    59 bool SpeechInputClientImpl::startRecognition(int requestId, const WebCore::IntRect& elementRect)
     59bool SpeechInputClientImpl::startRecognition(int requestId, const WebCore::IntRect& elementRect, const WTF::String& grammar)
    6060{
    6161    ASSERT(m_listener);
    62     return m_controller->startRecognition(requestId, elementRect);
     62    return m_controller->startRecognition(requestId, elementRect, grammar);
    6363}
    6464
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.h

    r70490 r70567  
    5555    // SpeechInputClient methods.
    5656    void setListener(WebCore::SpeechInputListener*);
    57     bool startRecognition(int, const WebCore::IntRect&);
     57    bool startRecognition(int requestId, const WebCore::IntRect& elementRect, const WTF::String& grammar);
    5858    void stopRecording(int);
    5959    void cancelRecognition(int);
  • trunk/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp

    r70490 r70567  
    7676}
    7777
    78 bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect)
     78bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect, const WebString& grammar)
    7979{
    80     return m_webcoreMock->startRecognition(requestId, elementRect);
     80    return m_webcoreMock->startRecognition(requestId, elementRect, grammar);
    8181}
    8282
  • trunk/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h

    r70490 r70567  
    5858
    5959    // WebSpeechInputController methods.
    60     bool startRecognition(int requestId, const WebRect& elementRect);
     60    bool startRecognition(int requestId, const WebRect& elementRect, const WebString& grammar);
    6161    void cancelRecognition(int requestId);
    6262    void stopRecording(int requestId);
Note: See TracChangeset for help on using the changeset viewer.