Speech JavaScript API: SpeechRecognitionEvent
authorhans@chromium.org <hans@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2012 11:27:51 +0000 (11:27 +0000)
committerhans@chromium.org <hans@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Mar 2012 11:27:51 +0000 (11:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80513

Reviewed by Adam Barth.

Source/WebCore:

Implement SpeechRecognitionEvent.
(Spec: http://speech-javascript-api-spec.googlecode.com/git/speechapi.html)

Test: fast/events/constructors/speech-recognition-event-constructor.html

* Modules/speech/DOMWindowSpeech.idl:
* Modules/speech/SpeechRecognitionEvent.cpp: Added.
(WebCore):
(WebCore::SpeechRecognitionEventInit::SpeechRecognitionEventInit):
(WebCore::SpeechRecognitionEvent::create):
(WebCore::SpeechRecognitionEvent::createResult):
(WebCore::SpeechRecognitionEvent::createNoMatch):
(WebCore::SpeechRecognitionEvent::createResultDeleted):
(WebCore::SpeechRecognitionEvent::createError):
(WebCore::SpeechRecognitionEvent::interfaceName):
(WebCore::SpeechRecognitionEvent::SpeechRecognitionEvent):
* Modules/speech/SpeechRecognitionEvent.h: Added.
(WebCore):
(SpeechRecognitionEventInit):
(SpeechRecognitionEvent):
(WebCore::SpeechRecognitionEvent::result):
(WebCore::SpeechRecognitionEvent::error):
(WebCore::SpeechRecognitionEvent::resultIndex):
(WebCore::SpeechRecognitionEvent::resultHistory):
* Modules/speech/SpeechRecognitionEvent.idl:
* WebCore.gypi:
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::webkitSpeechRecognitionEventEnabled):
* bindings/v8/OptionsObject.cpp:
(WebCore::OptionsObject::get):
(WebCore):
* bindings/v8/OptionsObject.h:
(WebCore):
(OptionsObject):
* dom/EventNames.h:
(WebCore):
* dom/EventNames.in:

LayoutTests:

Add test for SpeechRecognitionEvent.
Update Skipped files for all ports except Chromium.

* fast/events/constructors/speech-recognition-event-constructor-expected.txt: Added.
* fast/events/constructors/speech-recognition-event-constructor.html: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@110420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/constructors/speech-recognition-event-constructor-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/platform/wincairo/Skipped
Source/WebCore/ChangeLog
Source/WebCore/Modules/speech/DOMWindowSpeech.idl
Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp [new file with mode: 0644]
Source/WebCore/Modules/speech/SpeechRecognitionEvent.h [new file with mode: 0644]
Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl [new file with mode: 0644]
Source/WebCore/WebCore.gypi
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/bindings/v8/OptionsObject.cpp
Source/WebCore/bindings/v8/OptionsObject.h
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventNames.in

index e54a9c2..2e83266 100644 (file)
@@ -1,3 +1,21 @@
+2012-03-12  Hans Wennborg  <hans@chromium.org>
+
+        Speech JavaScript API: SpeechRecognitionEvent
+        https://bugs.webkit.org/show_bug.cgi?id=80513
+
+        Reviewed by Adam Barth.
+
+        Add test for SpeechRecognitionEvent.
+        Update Skipped files for all ports except Chromium.
+
+        * fast/events/constructors/speech-recognition-event-constructor-expected.txt: Added.
+        * fast/events/constructors/speech-recognition-event-constructor.html: Added.
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+
 2012-03-12  Andrey Kosyakov  <caseq@chromium.org>
 
         Unreviewed, remove flakiness flags for timeline-start-time.html following a fix in r100417.
diff --git a/LayoutTests/fast/events/constructors/speech-recognition-event-constructor-expected.txt b/LayoutTests/fast/events/constructors/speech-recognition-event-constructor-expected.txt
new file mode 100644 (file)
index 0000000..506e92d
--- /dev/null
@@ -0,0 +1,17 @@
+This tests the constructor for the SpeechRecognitionEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new webkitSpeechRecognitionEvent('eventType').bubbles is false
+PASS new webkitSpeechRecognitionEvent('eventType').cancelable is false
+PASS new webkitSpeechRecognitionEvent('eventType').result is null
+PASS new webkitSpeechRecognitionEvent('eventType').error is null
+PASS new webkitSpeechRecognitionEvent('eventType').resultIndex is 0
+PASS new webkitSpeechRecognitionEvent('eventType').resultHistory is null
+PASS new webkitSpeechRecognitionEvent('eventType', { bubbles: false }).bubbles is false
+PASS new webkitSpeechRecognitionEvent('eventType', { bubbles: true }).bubbles is true
+PASS new webkitSpeechRecognitionEvent('eventType', { cancelable: false }).cancelable is false
+PASS new webkitSpeechRecognitionEvent('eventType', { cancelable: true }).cancelable is true
+PASS new webkitSpeechRecognitionEvent('eventType', { resultIndex: 42 }).resultIndex is 42
+
diff --git a/LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html b/LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html
new file mode 100644 (file)
index 0000000..9396876
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("This tests the constructor for the SpeechRecognitionEvent DOM class.");
+
+// Test constructor without initializer.
+shouldBe("new webkitSpeechRecognitionEvent('eventType').bubbles", "false");
+shouldBe("new webkitSpeechRecognitionEvent('eventType').cancelable", "false");
+shouldBe("new webkitSpeechRecognitionEvent('eventType').result", "null");
+shouldBe("new webkitSpeechRecognitionEvent('eventType').error", "null");
+shouldBe("new webkitSpeechRecognitionEvent('eventType').resultIndex", "0");
+shouldBe("new webkitSpeechRecognitionEvent('eventType').resultHistory", "null");
+
+// Test passing bubbles in the initializer.
+shouldBe("new webkitSpeechRecognitionEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new webkitSpeechRecognitionEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// Test passing cancelable in the initializer.
+shouldBe("new webkitSpeechRecognitionEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new webkitSpeechRecognitionEvent('eventType', { cancelable: true }).cancelable", "true");
+
+// Test passing resultIndex in the initializer.
+shouldBe("new webkitSpeechRecognitionEvent('eventType', { resultIndex: 42 }).resultIndex", "42");
+
+</script>
+<script src="../../js/resource/js-test-post.js"></script>
+</body>
+</html>
+
index 14fbf91..36badb1 100644 (file)
@@ -258,6 +258,9 @@ gamepad/
 # Speech input is not yet enabled.
 fast/speech
 
+# Speech JavaScript API is not yet enabled.
+fast/events/constructors/speech-recognition-event-constructor.html
+
 # Web Timing is not enabled.
 # https://bugs.webkit.org/show_bug.cgi?id=42432
 fast/dom/Window/window-properties-performance.html
index 6dd458e..4a888e3 100644 (file)
@@ -230,6 +230,9 @@ gamepad/
 # Speech input is not yet enabled.
 fast/speech
 
+# Speech JavaScript API is not yet enabled.
+fast/events/constructors/speech-recognition-event-constructor.html
+
 # Media Stream API is not yet enabled.
 fast/dom/MediaStream
 
index e116862..1d66247 100644 (file)
@@ -88,6 +88,9 @@ gamepad/
 # ENABLE(INPUT_SPEECH) is disabled.
 fast/speech
 
+# ENABLE(SCRIPTEDSPEECH) is disabled.
+fast/events/constructors/speech-recognition-event-constructor.html
+
 # ENABLE(MEDIA_STREAM) is disabled.
 fast/dom/MediaStream
 fast/mediastream
index 0f8efed..fc736fa 100644 (file)
@@ -1173,6 +1173,9 @@ gamepad/
 # Speech input is not yet enabled.
 fast/speech
 
+# Speech JavaScript API is not yet enabled.
+fast/events/constructors/speech-recognition-event-constructor.html
+
 # Media Stream API is not yet enabled.
 fast/dom/MediaStream
 
index ced066d..ca82a16 100644 (file)
@@ -1690,6 +1690,9 @@ gamepad/
 # Speech input is not yet enabled.
 fast/speech
 
+# Speech JavaScript API is not yet enabled.
+fast/events/constructors/speech-recognition-event-constructor.html
+
 # Media Stream API is not yet enabled.
 fast/dom/MediaStream
 
index eb51ea8..6062cd4 100644 (file)
@@ -1,3 +1,48 @@
+2012-03-12  Hans Wennborg  <hans@chromium.org>
+
+        Speech JavaScript API: SpeechRecognitionEvent
+        https://bugs.webkit.org/show_bug.cgi?id=80513
+
+        Reviewed by Adam Barth.
+
+        Implement SpeechRecognitionEvent.
+        (Spec: http://speech-javascript-api-spec.googlecode.com/git/speechapi.html)
+
+        Test: fast/events/constructors/speech-recognition-event-constructor.html
+
+        * Modules/speech/DOMWindowSpeech.idl:
+        * Modules/speech/SpeechRecognitionEvent.cpp: Added.
+        (WebCore):
+        (WebCore::SpeechRecognitionEventInit::SpeechRecognitionEventInit):
+        (WebCore::SpeechRecognitionEvent::create):
+        (WebCore::SpeechRecognitionEvent::createResult):
+        (WebCore::SpeechRecognitionEvent::createNoMatch):
+        (WebCore::SpeechRecognitionEvent::createResultDeleted):
+        (WebCore::SpeechRecognitionEvent::createError):
+        (WebCore::SpeechRecognitionEvent::interfaceName):
+        (WebCore::SpeechRecognitionEvent::SpeechRecognitionEvent):
+        * Modules/speech/SpeechRecognitionEvent.h: Added.
+        (WebCore):
+        (SpeechRecognitionEventInit):
+        (SpeechRecognitionEvent):
+        (WebCore::SpeechRecognitionEvent::result):
+        (WebCore::SpeechRecognitionEvent::error):
+        (WebCore::SpeechRecognitionEvent::resultIndex):
+        (WebCore::SpeechRecognitionEvent::resultHistory):
+        * Modules/speech/SpeechRecognitionEvent.idl:
+        * WebCore.gypi:
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::webkitSpeechRecognitionEventEnabled):
+        * bindings/v8/OptionsObject.cpp:
+        (WebCore::OptionsObject::get):
+        (WebCore):
+        * bindings/v8/OptionsObject.h:
+        (WebCore):
+        (OptionsObject):
+        * dom/EventNames.h:
+        (WebCore):
+        * dom/EventNames.in:
+
 2012-03-12  Kent Tamura  <tkent@chromium.org>
 
         Use ICU C API instead of C++ API in LocalizedNumberICU
index 6d30bc6..70200b1 100644 (file)
@@ -29,6 +29,7 @@ module window {
         Supplemental=DOMWindow
     ] DOMWindowSpeech {
         attribute [V8EnabledAtRuntime] SpeechRecognitionErrorConstructor webkitSpeechRecognitionError;
+        attribute [V8EnabledAtRuntime] SpeechRecognitionEventConstructor webkitSpeechRecognitionEvent;
         attribute [V8EnabledAtRuntime] SpeechGrammarConstructor webkitSpeechGrammar;
         attribute [V8EnabledAtRuntime] SpeechGrammarListConstructor webkitSpeechGrammarList;
     };
diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp
new file mode 100644 (file)
index 0000000..c9f88e3
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2012 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"
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+#include "SpeechRecognitionEvent.h"
+
+namespace WebCore {
+
+SpeechRecognitionEventInit::SpeechRecognitionEventInit()
+    : resultIndex(0)
+{
+}
+
+PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::create()
+{
+    return adoptRef(new SpeechRecognitionEvent());
+}
+
+PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::create(const AtomicString& eventName, const SpeechRecognitionEventInit& initializer)
+{
+    return adoptRef(new SpeechRecognitionEvent(eventName, initializer));
+}
+
+PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::createResult(PassRefPtr<SpeechRecognitionResult> result, short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
+{
+    return adoptRef(new SpeechRecognitionEvent(eventNames().resultEvent, result, resultIndex, resultHistory));
+}
+
+PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::createNoMatch(PassRefPtr<SpeechRecognitionResult> result)
+{
+    return adoptRef(new SpeechRecognitionEvent(eventNames().nomatchEvent, result, 0, 0));
+}
+
+PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::createResultDeleted(short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
+{
+    return adoptRef(new SpeechRecognitionEvent(eventNames().resultdeletedEvent, 0, resultIndex, resultHistory));
+}
+
+PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::createError(PassRefPtr<SpeechRecognitionError> error)
+{
+    return adoptRef(new SpeechRecognitionEvent(error));
+}
+
+const AtomicString& SpeechRecognitionEvent::interfaceName() const
+{
+    return eventNames().interfaceForSpeechRecognitionEvent;
+}
+
+SpeechRecognitionEvent::SpeechRecognitionEvent()
+    : m_resultIndex(0)
+{
+}
+
+SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, const SpeechRecognitionEventInit& initializer)
+    : Event(eventName, initializer)
+    , m_result(initializer.result)
+    , m_error(initializer.error)
+    , m_resultIndex(initializer.resultIndex)
+    , m_resultHistory(initializer.resultHistory)
+{
+}
+
+SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, PassRefPtr<SpeechRecognitionResult> result, short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
+    : Event(eventName, /*canBubble=*/false, /*cancelable=*/false)
+    , m_result(result)
+    , m_error(0)
+    , m_resultIndex(resultIndex)
+    , m_resultHistory(resultHistory)
+{
+}
+
+SpeechRecognitionEvent::SpeechRecognitionEvent(PassRefPtr<SpeechRecognitionError> error)
+    : Event(eventNames().errorEvent, /*canBubble=*/false, /*cancelable=*/false) // FIXME: The spec should say whether these bubble or not.
+    , m_error(error)
+    , m_resultIndex(0)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h
new file mode 100644 (file)
index 0000000..443906e
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 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 SpeechRecognitionEvent_h
+#define SpeechRecognitionEvent_h
+
+#if ENABLE(SCRIPTED_SPEECH)
+
+#include "Event.h"
+#include "SpeechRecognitionError.h"
+#include "SpeechRecognitionResult.h"
+#include "SpeechRecognitionResultList.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class SpeechRecognitionError;
+class SpeechRecognitionResult;
+class SpeechRecognitionResultList;
+
+struct SpeechRecognitionEventInit : public EventInit {
+    SpeechRecognitionEventInit();
+
+    RefPtr<SpeechRecognitionResult> result;
+    RefPtr<SpeechRecognitionError> error;
+    short resultIndex;
+    RefPtr<SpeechRecognitionResultList> resultHistory;
+};
+
+class SpeechRecognitionEvent : public Event {
+public:
+    static PassRefPtr<SpeechRecognitionEvent> create();
+    static PassRefPtr<SpeechRecognitionEvent> create(const AtomicString&, const SpeechRecognitionEventInit&);
+
+    static PassRefPtr<SpeechRecognitionEvent> createResult(PassRefPtr<SpeechRecognitionResult>, short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory);
+    static PassRefPtr<SpeechRecognitionEvent> createNoMatch(PassRefPtr<SpeechRecognitionResult>);
+    static PassRefPtr<SpeechRecognitionEvent> createResultDeleted(short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory);
+    static PassRefPtr<SpeechRecognitionEvent> createError(PassRefPtr<SpeechRecognitionError>);
+
+    SpeechRecognitionResult* result() const { return m_result.get(); }
+    SpeechRecognitionError* error() const { return m_error.get(); }
+    short resultIndex() const { return m_resultIndex; } // FIXME: Spec says this should be short, but other indices are unsigned ints.
+    SpeechRecognitionResultList* resultHistory() const { return m_resultHistory.get(); }
+
+    // Event
+    virtual const AtomicString& interfaceName() const OVERRIDE;
+
+private:
+    SpeechRecognitionEvent();
+    SpeechRecognitionEvent(const AtomicString&, const SpeechRecognitionEventInit&);
+    SpeechRecognitionEvent(const AtomicString& eventName, PassRefPtr<SpeechRecognitionResult>, short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory);
+    SpeechRecognitionEvent(PassRefPtr<SpeechRecognitionError>);
+
+    RefPtr<SpeechRecognitionResult> m_result;
+    RefPtr<SpeechRecognitionError> m_error;
+    short m_resultIndex;
+    RefPtr<SpeechRecognitionResultList> m_resultHistory;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SCRIPTED_SPEECH)
+
+#endif // SpeechRecognitionEvent_h
diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl
new file mode 100644 (file)
index 0000000..4900081
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+module events {
+    interface [
+        Conditional=SCRIPTED_SPEECH,
+        ConstructorTemplate=Event
+    ] SpeechRecognitionEvent : Event {
+        readonly attribute [InitializedByEventConstructor] SpeechRecognitionResult result;
+        readonly attribute [InitializedByEventConstructor] SpeechRecognitionError error;
+        readonly attribute [InitializedByEventConstructor] short resultIndex;
+        readonly attribute [InitializedByEventConstructor] SpeechRecognitionResultList resultHistory;
+    };
+}
index 7685726..b8171ec 100644 (file)
             'Modules/speech/SpeechGrammarList.idl',
             'Modules/speech/SpeechRecognitionAlternative.idl',
             'Modules/speech/SpeechRecognitionError.idl',
+            'Modules/speech/SpeechRecognitionEvent.idl',
             'Modules/speech/SpeechRecognitionResult.idl',
             'Modules/speech/SpeechRecognitionResultList.idl',
             'Modules/webdatabase/DOMWindowSQLDatabase.idl',
             'Modules/speech/SpeechRecognitionAlternative.h',
             'Modules/speech/SpeechRecognitionError.cpp',
             'Modules/speech/SpeechRecognitionError.h',
+            'Modules/speech/SpeechRecognitionEvent.cpp',
+            'Modules/speech/SpeechRecognitionEvent.h',
             'Modules/speech/SpeechRecognitionResult.cpp',
             'Modules/speech/SpeechRecognitionResult.h',
             'Modules/speech/SpeechRecognitionResultList.cpp',
index 453b121..ee38d04 100644 (file)
@@ -152,6 +152,7 @@ public:
     static bool scriptedSpeechEnabled() { return isScriptedSpeechEnabled; }
     static bool webkitSpeechRecognitionEnabled() { return isScriptedSpeechEnabled; }
     static bool webkitSpeechRecognitionErrorEnabled() { return isScriptedSpeechEnabled; }
+    static bool webkitSpeechRecognitionEventEnabled() { return isScriptedSpeechEnabled; }
     static bool webkitSpeechGrammarEnabled() { return isScriptedSpeechEnabled; }
     static bool webkitSpeechGrammarListEnabled() { return isScriptedSpeechEnabled; }
 #endif
index f8db97e..e8c7dd9 100644 (file)
 #include "V8TextTrack.h"
 #endif
 
+#if ENABLE(SCRIPTED_SPEECH)
+#include "SpeechRecognitionError.h"
+#include "SpeechRecognitionResult.h"
+#include "SpeechRecognitionResultList.h"
+#include "V8SpeechRecognitionError.h"
+#include "V8SpeechRecognitionResult.h"
+#include "V8SpeechRecognitionResultList.h"
+#endif
+
 namespace WebCore {
 
 OptionsObject::OptionsObject()
@@ -168,6 +177,19 @@ bool OptionsObject::get(const String& key, unsigned short& value) const
     return true;
 }
 
+bool OptionsObject::get(const String& key, short& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32();
+    if (v8Int32.IsEmpty())
+        return false;
+    value = static_cast<short>(v8Int32->Value());
+    return true;
+}
+
 bool OptionsObject::get(const String& key, unsigned& value) const
 {
     v8::Local<v8::Value> v8Value;
@@ -293,4 +315,58 @@ bool OptionsObject::get(const String& key, RefPtr<TrackBase>& value) const
 }
 #endif
 
+#if ENABLE(SCRIPTED_SPEECH)
+bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionError>& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    SpeechRecognitionError* source = 0;
+    if (v8Value->IsObject()) {
+        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
+        v8::Handle<v8::Object> speechRecognitionError = V8DOMWrapper::lookupDOMWrapper(V8SpeechRecognitionError::GetTemplate(), wrapper);
+        if (!speechRecognitionError.IsEmpty())
+            source = V8SpeechRecognitionError::toNative(speechRecognitionError);
+    }
+    value = source;
+    return true;
+}
+
+bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionResult>& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    SpeechRecognitionResult* source = 0;
+    if (v8Value->IsObject()) {
+        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
+        v8::Handle<v8::Object> speechRecognitionResult = V8DOMWrapper::lookupDOMWrapper(V8SpeechRecognitionResult::GetTemplate(), wrapper);
+        if (!speechRecognitionResult.IsEmpty())
+            source = V8SpeechRecognitionResult::toNative(speechRecognitionResult);
+    }
+    value = source;
+    return true;
+}
+
+bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionResultList>& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    SpeechRecognitionResultList* source = 0;
+    if (v8Value->IsObject()) {
+        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
+        v8::Handle<v8::Object> speechRecognitionResultList = V8DOMWrapper::lookupDOMWrapper(V8SpeechRecognitionResultList::GetTemplate(), wrapper);
+        if (!speechRecognitionResultList.IsEmpty())
+            source = V8SpeechRecognitionResultList::toNative(speechRecognitionResultList);
+    }
+    value = source;
+    return true;
+}
+
+#endif
+
 } // namespace WebCore
index 2c7e80a..3260378 100644 (file)
@@ -40,6 +40,9 @@ class DOMWindow;
 class IDBKeyRange;
 class Storage;
 class TrackBase;
+class SpeechRecognitionError;
+class SpeechRecognitionResult;
+class SpeechRecognitionResultList;
 
 class OptionsObject {
 public:
@@ -57,6 +60,7 @@ public:
     bool get(const String&, double&) const;
     bool get(const String&, String&) const;
     bool get(const String&, ScriptValue&) const;
+    bool get(const String&, short&) const;
     bool get(const String&, unsigned short&) const;
     bool get(const String&, unsigned&) const;
     bool get(const String&, unsigned long long&) const;
@@ -66,6 +70,11 @@ public:
 #if ENABLE(VIDEO_TRACK)
     bool get(const String&, RefPtr<TrackBase>&) const;
 #endif
+#if ENABLE(SCRIPTED_SPEECH)
+    bool get(const String&, RefPtr<SpeechRecognitionError>&) const;
+    bool get(const String&, RefPtr<SpeechRecognitionResult>&) const;
+    bool get(const String&, RefPtr<SpeechRecognitionResultList>&) const;
+#endif
     bool get(const String&, HashSet<AtomicString>&) const;
 
     bool getWithUndefinedOrNullCheck(const String&, String&) const;
index a616f74..8604232 100644 (file)
@@ -185,6 +185,18 @@ namespace WebCore {
     \
     macro(webkitspeechchange) \
     \
+    macro(audiostart) \
+    macro(soundstart) \
+    macro(speechstart) \
+    macro(speechend) \
+    macro(soundend) \
+    macro(audioend) \
+    macro(result) \
+    macro(nomatch) \
+    macro(resultdeleted) \
+    macro(start) \
+    macro(end) \
+    \
     macro(webglcontextlost) \
     macro(webglcontextrestored) \
     macro(webglcontextcreationerror) \
index 1b500cd..d866112 100644 (file)
@@ -31,6 +31,7 @@ AudioProcessingEvent conditional=WEB_AUDIO
 OfflineAudioCompletionEvent conditional=WEB_AUDIO
 MediaStreamEvent conditional=MEDIA_STREAM
 SpeechInputEvent conditional=INPUT_SPEECH
+SpeechRecognitionEvent conditional=SCRIPTED_SPEECH
 WebGLContextEvent conditional=WEBGL
 StorageEvent
 SVGEvents interfaceName=Event, conditional=SVG