Title: [146601] trunk
Revision
146601
Author
[email protected]
Date
2013-03-22 06:43:08 -0700 (Fri, 22 Mar 2013)

Log Message

Source/WebCore: Clean up the speech recognintion API
https://bugs.webkit.org/show_bug.cgi?id=112916

Reviewed by Adam Barth.

This patch cleans away deprecated parts, fixes so that stop() can be called more than once and adds
the missing emma attribute on SpeechRecognitionEvent (which is always null).

Patch covered by existing tests.

* Modules/speech/SpeechRecognition.cpp:
(WebCore::SpeechRecognition::stopFunction):
(WebCore::SpeechRecognition::abort):
(WebCore::SpeechRecognition::didEnd):
(WebCore::SpeechRecognition::SpeechRecognition):
* Modules/speech/SpeechRecognition.h:
(SpeechRecognition):
* Modules/speech/SpeechRecognitionEvent.cpp:
(WebCore::SpeechRecognitionEvent::createResult):
(WebCore::SpeechRecognitionEvent::createNoMatch):
(WebCore::SpeechRecognitionEvent::SpeechRecognitionEvent):
* Modules/speech/SpeechRecognitionEvent.h:
(WebCore):
(SpeechRecognitionEventInit):
(SpeechRecognitionEvent):
(WebCore::SpeechRecognitionEvent::emma):
* Modules/speech/SpeechRecognitionEvent.idl:

Source/WebKit/chromium: Clean up the speach recognintion API
https://bugs.webkit.org/show_bug.cgi?id=112916

Reviewed by Adam Barth.

* public/WebSpeechRecognizerClient.h:
* src/SpeechRecognitionClientProxy.cpp:
* src/SpeechRecognitionClientProxy.h:
(SpeechRecognitionClientProxy):

LayoutTests: Clean up the speech recognintion API
https://bugs.webkit.org/show_bug.cgi?id=112916

Reviewed by Adam Barth.

* fast/events/constructors/speech-recognition-event-constructor-expected.txt:
* fast/events/constructors/speech-recognition-event-constructor.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (146600 => 146601)


--- trunk/LayoutTests/ChangeLog	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/LayoutTests/ChangeLog	2013-03-22 13:43:08 UTC (rev 146601)
@@ -1,3 +1,13 @@
+2013-03-22  Tommy Widenflycht  <[email protected]>
+
+        Clean up the speech recognintion API
+        https://bugs.webkit.org/show_bug.cgi?id=112916
+
+        Reviewed by Adam Barth.
+
+        * fast/events/constructors/speech-recognition-event-constructor-expected.txt:
+        * fast/events/constructors/speech-recognition-event-constructor.html:
+
 2013-03-22  Emil A Eklund  <[email protected]>
 
         Floor cell widths in AutoTableLayout::recalcColumn

Modified: trunk/LayoutTests/fast/events/constructors/speech-recognition-event-constructor-expected.txt (146600 => 146601)


--- trunk/LayoutTests/fast/events/constructors/speech-recognition-event-constructor-expected.txt	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/LayoutTests/fast/events/constructors/speech-recognition-event-constructor-expected.txt	2013-03-22 13:43:08 UTC (rev 146601)
@@ -5,9 +5,8 @@
 
 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').results 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

Modified: trunk/LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html (146600 => 146601)


--- trunk/LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html	2013-03-22 13:43:08 UTC (rev 146601)
@@ -13,9 +13,8 @@
 // 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').results", "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");

Modified: trunk/Source/WebCore/ChangeLog (146600 => 146601)


--- trunk/Source/WebCore/ChangeLog	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebCore/ChangeLog	2013-03-22 13:43:08 UTC (rev 146601)
@@ -1,3 +1,33 @@
+2013-03-22  Tommy Widenflycht  <[email protected]>
+
+        Clean up the speech recognintion API
+        https://bugs.webkit.org/show_bug.cgi?id=112916
+
+        Reviewed by Adam Barth.
+
+        This patch cleans away deprecated parts, fixes so that stop() can be called more than once and adds
+        the missing emma attribute on SpeechRecognitionEvent (which is always null).
+
+        Patch covered by existing tests.
+
+        * Modules/speech/SpeechRecognition.cpp:
+        (WebCore::SpeechRecognition::stopFunction):
+        (WebCore::SpeechRecognition::abort):
+        (WebCore::SpeechRecognition::didEnd):
+        (WebCore::SpeechRecognition::SpeechRecognition):
+        * Modules/speech/SpeechRecognition.h:
+        (SpeechRecognition):
+        * Modules/speech/SpeechRecognitionEvent.cpp:
+        (WebCore::SpeechRecognitionEvent::createResult):
+        (WebCore::SpeechRecognitionEvent::createNoMatch):
+        (WebCore::SpeechRecognitionEvent::SpeechRecognitionEvent):
+        * Modules/speech/SpeechRecognitionEvent.h:
+        (WebCore):
+        (SpeechRecognitionEventInit):
+        (SpeechRecognitionEvent):
+        (WebCore::SpeechRecognitionEvent::emma):
+        * Modules/speech/SpeechRecognitionEvent.idl:
+
 2013-03-22  Emil A Eklund  <[email protected]>
 
         Floor cell widths in AutoTableLayout::recalcColumn

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognition.cpp (146600 => 146601)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognition.cpp	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognition.cpp	2013-03-22 13:43:08 UTC (rev 146601)
@@ -62,13 +62,19 @@
 void SpeechRecognition::stopFunction()
 {
     ASSERT(m_controller);
-    m_controller->stop(this);
+    if (m_started && !m_stopping) {
+        m_stopping = true;
+        m_controller->stop(this);
+    }
 }
 
 void SpeechRecognition::abort()
 {
     ASSERT(m_controller);
-    m_controller->abort(this);
+    if (m_started && !m_stopping) {
+        m_stopping = true;
+        m_controller->abort(this);
+    }
 }
 
 void SpeechRecognition::didStartAudio()
@@ -101,11 +107,6 @@
     dispatchEvent(Event::create(eventNames().audioendEvent, /*canBubble=*/false, /*cancelable=*/false));
 }
 
-void SpeechRecognition::didReceiveResult(PassRefPtr<SpeechRecognitionResult> result, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
-{
-    dispatchEvent(SpeechRecognitionEvent::createResult(result, resultIndex, resultHistory));
-}
-
 void SpeechRecognition::didReceiveResults(const Vector<RefPtr<SpeechRecognitionResult> >& newFinalResults, const Vector<RefPtr<SpeechRecognitionResult> >& currentInterimResults)
 {
     unsigned long resultIndex = m_finalResults.size();
@@ -139,6 +140,7 @@
 void SpeechRecognition::didEnd()
 {
     m_started = false;
+    m_stopping = false;
     if (!m_stoppedByActiveDOMObject)
         dispatchEvent(Event::create(eventNames().endEvent, /*canBubble=*/false, /*cancelable=*/false));
     unsetPendingActivity(this);
@@ -170,6 +172,7 @@
     , m_controller(0)
     , m_stoppedByActiveDOMObject(false)
     , m_started(false)
+    , m_stopping(false)
 {
     Document* document = toDocument(scriptExecutionContext());
 

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognition.h (146600 => 146601)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognition.h	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognition.h	2013-03-22 13:43:08 UTC (rev 146601)
@@ -74,8 +74,6 @@
     void didEndSound();
     void didEndAudio();
     void didReceiveResults(const Vector<RefPtr<SpeechRecognitionResult> >& newFinalResults, const Vector<RefPtr<SpeechRecognitionResult> >& currentInterimResults);
-    // FIXME: Remove this once we start using didReceiveResults.
-    void didReceiveResult(PassRefPtr<SpeechRecognitionResult>, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory);
     void didReceiveNoMatch(PassRefPtr<SpeechRecognitionResult>);
     void didReceiveError(PassRefPtr<SpeechRecognitionError>);
     void didStart();
@@ -126,6 +124,7 @@
     SpeechRecognitionController* m_controller;
     bool m_stoppedByActiveDOMObject;
     bool m_started;
+    bool m_stopping;
     Vector<RefPtr<SpeechRecognitionResult> > m_finalResults;
 };
 

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp (146600 => 146601)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp	2013-03-22 13:43:08 UTC (rev 146601)
@@ -46,19 +46,20 @@
     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::createResult(unsigned long resultIndex, const Vector<RefPtr<SpeechRecognitionResult> >& results)
 {
-    return adoptRef(new SpeechRecognitionEvent(eventNames().resultEvent, resultIndex, results));
+    return adoptRef(new SpeechRecognitionEvent(eventNames().resultEvent, resultIndex, SpeechRecognitionResultList::create(results)));
 }
 
 PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::createNoMatch(PassRefPtr<SpeechRecognitionResult> result)
 {
-    return adoptRef(new SpeechRecognitionEvent(eventNames().nomatchEvent, result, 0, 0));
+    if (result) {
+        Vector<RefPtr<SpeechRecognitionResult> > results;
+        results.append(result);
+        return adoptRef(new SpeechRecognitionEvent(eventNames().nomatchEvent, 0, SpeechRecognitionResultList::create(results)));
+    }
+
+    return adoptRef(new SpeechRecognitionEvent(eventNames().nomatchEvent, 0, 0));
 }
 
 const AtomicString& SpeechRecognitionEvent::interfaceName() const
@@ -74,26 +75,17 @@
 SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, const SpeechRecognitionEventInit& initializer)
     : Event(eventName, initializer)
     , m_resultIndex(initializer.resultIndex)
-    , m_result(initializer.result)
-    , m_resultHistory(initializer.resultHistory)
+    , m_results(initializer.results)
 {
 }
 
-SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, PassRefPtr<SpeechRecognitionResult> result, short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory)
+SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> results)
     : Event(eventName, /*canBubble=*/false, /*cancelable=*/false)
     , m_resultIndex(resultIndex)
-    , m_result(result)
-    , m_resultHistory(resultHistory)
+    , m_results(results)
 {
 }
 
-SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, unsigned long resultIndex, const Vector<RefPtr<SpeechRecognitionResult> >& results)
-    : Event(eventName, /*canBubble=*/false, /*cancelable=*/false)
-    , m_resultIndex(resultIndex)
-    , m_results(SpeechRecognitionResultList::create(results))
-{
-}
-
 SpeechRecognitionEvent::~SpeechRecognitionEvent()
 {
 }

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h (146600 => 146601)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h	2013-03-22 13:43:08 UTC (rev 146601)
@@ -29,24 +29,17 @@
 #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;
+class Document;
 
 struct SpeechRecognitionEventInit : public EventInit {
     SpeechRecognitionEventInit();
 
-    // DEPRECATED
-    RefPtr<SpeechRecognitionResult> result;
-    RefPtr<SpeechRecognitionResultList> resultHistory;
-
     unsigned long resultIndex;
     RefPtr<SpeechRecognitionResultList> results;
 };
@@ -57,35 +50,23 @@
     static PassRefPtr<SpeechRecognitionEvent> create(const AtomicString&, const SpeechRecognitionEventInit&);
     virtual ~SpeechRecognitionEvent();
 
-    // DEPRECATED
-    static PassRefPtr<SpeechRecognitionEvent> createResult(PassRefPtr<SpeechRecognitionResult>, short resultIndex, PassRefPtr<SpeechRecognitionResultList> resultHistory);
-
     static PassRefPtr<SpeechRecognitionEvent> createResult(unsigned long resultIndex, const Vector<RefPtr<SpeechRecognitionResult> >& results);
     static PassRefPtr<SpeechRecognitionEvent> createNoMatch(PassRefPtr<SpeechRecognitionResult>);
 
     unsigned long resultIndex() const { return m_resultIndex; }
     SpeechRecognitionResultList* results() const { return m_results.get(); }
+    Document* emma() { return 0; }
 
-    // DEPRECATED
-    SpeechRecognitionResult* result() const { return m_result.get(); }
-    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); // FIXME: Remove.
-    SpeechRecognitionEvent(const AtomicString& eventName, unsigned long resultIndex, const Vector<RefPtr<SpeechRecognitionResult> >& results);
-    explicit SpeechRecognitionEvent(PassRefPtr<SpeechRecognitionError>);
+    SpeechRecognitionEvent(const AtomicString& eventName, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> results);
 
     unsigned long m_resultIndex;
     RefPtr<SpeechRecognitionResultList> m_results;
-
-    // DEPRECATED
-    RefPtr<SpeechRecognitionResult> m_result;
-    RefPtr<SpeechRecognitionResultList> m_resultHistory;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl (146600 => 146601)


--- trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl	2013-03-22 13:43:08 UTC (rev 146601)
@@ -27,11 +27,8 @@
     Conditional=SCRIPTED_SPEECH,
     ConstructorTemplate=Event,
 ] interface SpeechRecognitionEvent : Event {
-    // DEPRECATED
-    [InitializedByEventConstructor] readonly attribute SpeechRecognitionResult result;
-    [InitializedByEventConstructor] readonly attribute SpeechRecognitionResultList resultHistory;
-
     [InitializedByEventConstructor] readonly attribute unsigned long resultIndex;
     [InitializedByEventConstructor] readonly attribute SpeechRecognitionResultList results;
-    // FIXME: Add the emma attribute.
+
+    readonly attribute Document emma;
 };

Modified: trunk/Source/WebKit/chromium/ChangeLog (146600 => 146601)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-03-22 13:43:08 UTC (rev 146601)
@@ -1,3 +1,15 @@
+2013-03-22  Tommy Widenflycht  <[email protected]>
+
+        Clean up the speach recognintion API
+        https://bugs.webkit.org/show_bug.cgi?id=112916
+
+        Reviewed by Adam Barth.
+
+        * public/WebSpeechRecognizerClient.h:
+        * src/SpeechRecognitionClientProxy.cpp:
+        * src/SpeechRecognitionClientProxy.h:
+        (SpeechRecognitionClientProxy):
+
 2013-03-22  Hajime Morrita  <[email protected]>
 
         Custom Elements: "readyCallback" lifecycle callback should be called.

Modified: trunk/Source/WebKit/chromium/public/WebSpeechRecognizerClient.h (146600 => 146601)


--- trunk/Source/WebKit/chromium/public/WebSpeechRecognizerClient.h	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebKit/chromium/public/WebSpeechRecognizerClient.h	2013-03-22 13:43:08 UTC (rev 146601)
@@ -67,10 +67,6 @@
     // This is expected to be called after didEndSound.
     virtual void didEndAudio(const WebSpeechRecognitionHandle&) = 0;
 
-    // To be called when the speech recognizer returns a result.
-    // FIXME: Remove this when we have moved over to only use the function below.
-    virtual void didReceiveResult(const WebSpeechRecognitionHandle&, const WebSpeechRecognitionResult&, unsigned long resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory) = 0;
-
     // To be called when the speech recognizer provides new results.
     // - newFinalResults contains zero or more final results that are new since
     // the last time the function was called.

Modified: trunk/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.cpp (146600 => 146601)


--- trunk/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.cpp	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.cpp	2013-03-22 13:43:08 UTC (rev 146601)
@@ -101,18 +101,6 @@
     recognition->didEndAudio();
 }
 
-void SpeechRecognitionClientProxy::didReceiveResult(const WebSpeechRecognitionHandle& handle, const WebSpeechRecognitionResult& result, unsigned long resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory)
-{
-    RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);
-
-    Vector<RefPtr<SpeechRecognitionResult> > resultHistoryVector(resultHistory.size());
-    for (size_t i = 0; i < resultHistory.size(); ++i)
-        resultHistoryVector[i] = static_cast<PassRefPtr<SpeechRecognitionResult> >(resultHistory[i]);
-
-    recognition->didReceiveResult(result, resultIndex, SpeechRecognitionResultList::create(resultHistoryVector));
-
-}
-
 void SpeechRecognitionClientProxy::didReceiveResults(const WebSpeechRecognitionHandle& handle, const WebVector<WebSpeechRecognitionResult>& newFinalResults, const WebVector<WebSpeechRecognitionResult>& currentInterimResults)
 {
     RefPtr<SpeechRecognition> recognition = PassRefPtr<SpeechRecognition>(handle);

Modified: trunk/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.h (146600 => 146601)


--- trunk/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.h	2013-03-22 13:40:57 UTC (rev 146600)
+++ trunk/Source/WebKit/chromium/src/SpeechRecognitionClientProxy.h	2013-03-22 13:43:08 UTC (rev 146601)
@@ -55,7 +55,6 @@
     virtual void didStartSound(const WebSpeechRecognitionHandle&) OVERRIDE;
     virtual void didEndSound(const WebSpeechRecognitionHandle&) OVERRIDE;
     virtual void didEndAudio(const WebSpeechRecognitionHandle&) OVERRIDE;
-    virtual void didReceiveResult(const WebSpeechRecognitionHandle&, const WebSpeechRecognitionResult&, unsigned long resultIndex, const WebVector<WebSpeechRecognitionResult>& resultHistory) OVERRIDE;
     virtual void didReceiveResults(const WebSpeechRecognitionHandle&, const WebVector<WebSpeechRecognitionResult>& newFinalResults, const WebVector<WebSpeechRecognitionResult>& currentInterimResults) OVERRIDE;
     virtual void didReceiveNoMatch(const WebSpeechRecognitionHandle&, const WebSpeechRecognitionResult&) OVERRIDE;
     virtual void didReceiveError(const WebSpeechRecognitionHandle&, const WebString& message, WebSpeechRecognizerClient::ErrorCode) OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to