Commit ec32fe67 authored by hans@chromium.org's avatar hans@chromium.org

Speech JavaScript API: Add SpeechRecognition.interimResults attribute

https://bugs.webkit.org/show_bug.cgi?id=98279

Reviewed by Adam Barth.

Source/WebCore:

Add the interimResults attribute and pass it to the embedder. It was
added to the spec draft in
http://dvcs.w3.org/hg/speech-api/rev/d25fea0d029c

Tested in fast/speech/scripted/basics.html

* Modules/speech/SpeechRecognition.cpp:
(WebCore::SpeechRecognition::start):
(WebCore::SpeechRecognition::SpeechRecognition):
* Modules/speech/SpeechRecognition.h:
(WebCore::SpeechRecognition::interimResults):
(WebCore::SpeechRecognition::setInterimResults):
* Modules/speech/SpeechRecognition.idl:
* Modules/speech/SpeechRecognitionClient.h:
(SpeechRecognitionClient):
* Modules/speech/SpeechRecognitionController.h:
(WebCore::SpeechRecognitionController::start):

Source/WebKit/chromium:

Plumb interimResults through to Chromium.

* public/WebSpeechRecognitionParams.h:
(WebKit::WebSpeechRecognitionParams::WebSpeechRecognitionParams):
(WebKit::WebSpeechRecognitionParams::interimResults):
(WebSpeechRecognitionParams):
* src/SpeechRecognitionClientProxy.cpp:
(WebKit::SpeechRecognitionClientProxy::start):
* src/SpeechRecognitionClientProxy.h:
(SpeechRecognitionClientProxy):

LayoutTests:

Update test to check for the interimResults attribute.

* fast/speech/scripted/basics-expected.txt:
* fast/speech/scripted/basics.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130308 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bf790a87
2012-10-03 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Add SpeechRecognition.interimResults attribute
https://bugs.webkit.org/show_bug.cgi?id=98279
Reviewed by Adam Barth.
Update test to check for the interimResults attribute.
* fast/speech/scripted/basics-expected.txt:
* fast/speech/scripted/basics.html:
2012-10-03 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Remove resultdeleted event
......
......@@ -11,6 +11,7 @@ PASS speechReco.grammars == null is false
PASS speechReco.grammars.length === 0 is true
PASS 'lang' in speechReco is true
PASS 'continuous' in speechReco is true
PASS 'interimResults' in speechReco is true
PASS 'maxAlternatives' in speechReco is true
PASS 'start' in speechReco is true
PASS 'stop' in speechReco is true
......
......@@ -20,6 +20,7 @@ function run() {
shouldBeTrue("speechReco.grammars.length === 0");
shouldBeTrue("'lang' in speechReco");
shouldBeTrue("'continuous' in speechReco");
shouldBeTrue("'interimResults' in speechReco");
shouldBeTrue("'maxAlternatives' in speechReco");
shouldBeTrue("'start' in speechReco");
shouldBeTrue("'stop' in speechReco");
......
2012-10-03 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Add SpeechRecognition.interimResults attribute
https://bugs.webkit.org/show_bug.cgi?id=98279
Reviewed by Adam Barth.
Add the interimResults attribute and pass it to the embedder. It was
added to the spec draft in
http://dvcs.w3.org/hg/speech-api/rev/d25fea0d029c
Tested in fast/speech/scripted/basics.html
* Modules/speech/SpeechRecognition.cpp:
(WebCore::SpeechRecognition::start):
(WebCore::SpeechRecognition::SpeechRecognition):
* Modules/speech/SpeechRecognition.h:
(WebCore::SpeechRecognition::interimResults):
(WebCore::SpeechRecognition::setInterimResults):
* Modules/speech/SpeechRecognition.idl:
* Modules/speech/SpeechRecognitionClient.h:
(SpeechRecognitionClient):
* Modules/speech/SpeechRecognitionController.h:
(WebCore::SpeechRecognitionController::start):
2012-10-03 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Remove resultdeleted event
......
......@@ -54,7 +54,7 @@ void SpeechRecognition::start(ExceptionCode& ec)
}
setPendingActivity(this);
m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_maxAlternatives);
m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimResults, m_maxAlternatives);
m_started = true;
}
......@@ -150,6 +150,7 @@ SpeechRecognition::SpeechRecognition(ScriptExecutionContext* context)
: ActiveDOMObject(context, this)
, m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute.
, m_continuous(false)
, m_interimResults(false)
, m_maxAlternatives(1)
, m_controller(0)
, m_stoppedByActiveDOMObject(false)
......
......@@ -56,6 +56,8 @@ public:
void setLang(const String& lang) { m_lang = lang; }
bool continuous() { return m_continuous; }
void setContinuous(bool continuous) { m_continuous = continuous; }
bool interimResults() { return m_interimResults; }
void setInterimResults(bool interimResults) { m_interimResults = interimResults; }
unsigned long maxAlternatives() { return m_maxAlternatives; }
void setMaxAlternatives(unsigned long maxAlternatives) { m_maxAlternatives = maxAlternatives; }
......@@ -114,6 +116,7 @@ private:
RefPtr<SpeechGrammarList> m_grammars;
String m_lang;
bool m_continuous;
bool m_interimResults;
unsigned long m_maxAlternatives;
EventTargetData m_eventTargetData;
......
......@@ -34,6 +34,7 @@ module core {
attribute SpeechGrammarList grammars;
attribute DOMString lang;
attribute boolean continuous;
attribute boolean interimResults;
attribute unsigned long maxAlternatives;
void start() raises (DOMException);
......
......@@ -38,7 +38,7 @@ class SpeechRecognition;
class SpeechRecognitionClient {
public:
virtual void start(SpeechRecognition*, const SpeechGrammarList*, const String& lang, bool continuous, unsigned long maxAlternatives) = 0;
virtual void start(SpeechRecognition*, const SpeechGrammarList*, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives) = 0;
virtual void stop(SpeechRecognition*) = 0;
virtual void abort(SpeechRecognition*) = 0;
......
......@@ -38,9 +38,9 @@ class SpeechRecognitionController : public Supplement<Page> {
public:
virtual ~SpeechRecognitionController();
void start(SpeechRecognition* recognition, const SpeechGrammarList* grammars, const String& lang, bool continuous, unsigned long maxAlternatives)
void start(SpeechRecognition* recognition, const SpeechGrammarList* grammars, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives)
{
m_client->start(recognition, grammars, lang, continuous, maxAlternatives);
m_client->start(recognition, grammars, lang, continuous, interimResults, maxAlternatives);
}
void stop(SpeechRecognition* recognition) { m_client->stop(recognition); }
......
2012-10-03 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Add SpeechRecognition.interimResults attribute
https://bugs.webkit.org/show_bug.cgi?id=98279
Reviewed by Adam Barth.
Plumb interimResults through to Chromium.
* public/WebSpeechRecognitionParams.h:
(WebKit::WebSpeechRecognitionParams::WebSpeechRecognitionParams):
(WebKit::WebSpeechRecognitionParams::interimResults):
(WebSpeechRecognitionParams):
* src/SpeechRecognitionClientProxy.cpp:
(WebKit::SpeechRecognitionClientProxy::start):
* src/SpeechRecognitionClientProxy.h:
(SpeechRecognitionClientProxy):
2012-10-03 Hans Wennborg <hans@chromium.org>
Speech JavaScript API: Remove resultdeleted event
......
......@@ -37,10 +37,11 @@ class WebSpeechGrammar;
class WebSpeechRecognitionParams {
public:
WebSpeechRecognitionParams(const WebVector<WebSpeechGrammar>& grammars, const WebString& language, bool continuous, unsigned long maxAlternatives, const WebSecurityOrigin& origin)
WebSpeechRecognitionParams(const WebVector<WebSpeechGrammar>& grammars, const WebString& language, bool continuous, bool interimResults, unsigned long maxAlternatives, const WebSecurityOrigin& origin)
: m_grammars(grammars)
, m_language(language)
, m_continuous(continuous)
, m_interimResults(interimResults)
, m_maxAlternatives(maxAlternatives)
, m_origin(origin)
{
......@@ -49,6 +50,7 @@ public:
const WebVector<WebSpeechGrammar>& grammars() const { return m_grammars; }
const WebString& language() const { return m_language; }
bool continuous() const { return m_continuous; }
bool interimResults() const { return m_interimResults; }
unsigned long maxAlternatives() const { return m_maxAlternatives; }
const WebSecurityOrigin& origin() const { return m_origin; }
......@@ -56,6 +58,7 @@ private:
WebVector<WebSpeechGrammar> m_grammars;
WebString m_language;
bool m_continuous;
bool m_interimResults;
unsigned long m_maxAlternatives;
WebSecurityOrigin m_origin;
};
......
......@@ -55,13 +55,13 @@ PassOwnPtr<SpeechRecognitionClientProxy> SpeechRecognitionClientProxy::create(We
return adoptPtr(new SpeechRecognitionClientProxy(recognizer));
}
void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const SpeechGrammarList* grammarList, const String& lang, bool continuous, unsigned long maxAlternatives)
void SpeechRecognitionClientProxy::start(SpeechRecognition* recognition, const SpeechGrammarList* grammarList, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives)
{
WebVector<WebSpeechGrammar> webSpeechGrammars(static_cast<size_t>(grammarList->length()));
for (unsigned long i = 0; i < grammarList->length(); ++i)
webSpeechGrammars[i] = grammarList->item(i);
WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, maxAlternatives, WebSecurityOrigin(recognition->scriptExecutionContext()->securityOrigin()));
WebSpeechRecognitionParams params(webSpeechGrammars, lang, continuous, interimResults, maxAlternatives, WebSecurityOrigin(recognition->scriptExecutionContext()->securityOrigin()));
m_recognizer->start(WebSpeechRecognitionHandle(recognition), params, this);
}
......
......@@ -46,7 +46,7 @@ public:
static PassOwnPtr<SpeechRecognitionClientProxy> create(WebSpeechRecognizer*);
// WebCore::SpeechRecognitionClient:
virtual void start(WebCore::SpeechRecognition*, const WebCore::SpeechGrammarList*, const String& lang, bool continuous, unsigned long maxAlternatives) OVERRIDE;
virtual void start(WebCore::SpeechRecognition*, const WebCore::SpeechGrammarList*, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives) OVERRIDE;
virtual void stop(WebCore::SpeechRecognition*) OVERRIDE;
virtual void abort(WebCore::SpeechRecognition*) OVERRIDE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment