diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
commit | dd91e772430dc294e3bf478c119ef8d43c0a3358 (patch) | |
tree | 6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/WebCore/Modules/speech | |
parent | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff) | |
download | qtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz |
Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422)
This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API.
Diffstat (limited to 'Source/WebCore/Modules/speech')
22 files changed, 1172 insertions, 0 deletions
diff --git a/Source/WebCore/Modules/speech/DOMWindowSpeech.idl b/Source/WebCore/Modules/speech/DOMWindowSpeech.idl new file mode 100644 index 000000000..70200b1be --- /dev/null +++ b/Source/WebCore/Modules/speech/DOMWindowSpeech.idl @@ -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 window { + interface [ + Conditional=SCRIPTED_SPEECH, + 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/SpeechGrammar.cpp b/Source/WebCore/Modules/speech/SpeechGrammar.cpp new file mode 100644 index 000000000..1736e1e4a --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechGrammar.cpp @@ -0,0 +1,66 @@ +/* + * 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 "SpeechGrammar.h" + +#include "Document.h" + +namespace WebCore { + +PassRefPtr<SpeechGrammar> SpeechGrammar::create() +{ + return adoptRef(new SpeechGrammar); +} + +PassRefPtr<SpeechGrammar> SpeechGrammar::create(const KURL& src, double weight) +{ + return adoptRef(new SpeechGrammar(src, weight)); +} + +void SpeechGrammar::setSrc(ScriptExecutionContext* scriptExecutionContext, const String& src) +{ + ASSERT(scriptExecutionContext->isDocument()); + Document* document = static_cast<Document*>(scriptExecutionContext); + m_src = document->completeURL(src); +} + +SpeechGrammar::SpeechGrammar() + : m_weight(1.0) +{ +} + +SpeechGrammar::SpeechGrammar(const KURL& src, double weight) + : m_src(src) + , m_weight(weight) +{ +} + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechGrammar.h b/Source/WebCore/Modules/speech/SpeechGrammar.h new file mode 100644 index 000000000..62088c18b --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechGrammar.h @@ -0,0 +1,62 @@ +/* + * 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 SpeechGrammar_h +#define SpeechGrammar_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "KURL.h" +#include "PlatformString.h" +#include <wtf/RefCounted.h> + +namespace WebCore { + +class ScriptExecutionContext; + +class SpeechGrammar : public RefCounted<SpeechGrammar> { +public: + static PassRefPtr<SpeechGrammar> create(); // FIXME: The spec is not clear on what the constructor should look like. + static PassRefPtr<SpeechGrammar> create(const KURL& src, double weight); + + const KURL& src(ScriptExecutionContext*) const { return m_src; } + void setSrc(ScriptExecutionContext*, const String& src); + + double weight() const { return m_weight; } + void setWeight(double weight) { m_weight = weight; } + +private: + SpeechGrammar(); + SpeechGrammar(const KURL& src, double weight); + + KURL m_src; + double m_weight; +}; + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // SpeechGrammar_h diff --git a/Source/WebCore/Modules/speech/SpeechGrammar.idl b/Source/WebCore/Modules/speech/SpeechGrammar.idl new file mode 100644 index 000000000..b793ac3ab --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechGrammar.idl @@ -0,0 +1,34 @@ +/* + * 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 core { + interface [ + Conditional=SCRIPTED_SPEECH, + Constructor + ] SpeechGrammar { + attribute [URL,CallWith=ScriptExecutionContext] DOMString src; + attribute float weight; + }; +} diff --git a/Source/WebCore/Modules/speech/SpeechGrammarList.cpp b/Source/WebCore/Modules/speech/SpeechGrammarList.cpp new file mode 100644 index 000000000..841df2948 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechGrammarList.cpp @@ -0,0 +1,68 @@ +/* + * 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 "SpeechGrammarList.h" + +#include "Document.h" + +namespace WebCore { + +PassRefPtr<SpeechGrammarList> SpeechGrammarList::create() +{ + return adoptRef(new SpeechGrammarList); +} + +SpeechGrammar* SpeechGrammarList::item(unsigned long index) const +{ + if (index >= m_grammars.size()) + return 0; + + return m_grammars[index].get(); +} + +void SpeechGrammarList::addFromUri(ScriptExecutionContext* scriptExecutionContext, const String& src, double weight) +{ + ASSERT(scriptExecutionContext->isDocument()); + Document* document = static_cast<Document*>(scriptExecutionContext); + m_grammars.append(SpeechGrammar::create(document->completeURL(src), weight)); +} + +void SpeechGrammarList::addFromString(const String& string, double weight) +{ + String urlString = String("data:application/xml,") + encodeWithURLEscapeSequences(string); + m_grammars.append(SpeechGrammar::create(KURL(KURL(), urlString), weight)); +} + +SpeechGrammarList::SpeechGrammarList() +{ +} + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechGrammarList.h b/Source/WebCore/Modules/speech/SpeechGrammarList.h new file mode 100644 index 000000000..d7b53d757 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechGrammarList.h @@ -0,0 +1,59 @@ +/* + * 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 SpeechGrammarList_h +#define SpeechGrammarList_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "SpeechGrammar.h" +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class ScriptExecutionContext; + +class SpeechGrammarList : public RefCounted<SpeechGrammarList> { +public: + static PassRefPtr<SpeechGrammarList> create(); + + unsigned long length() const { return m_grammars.size(); } + SpeechGrammar* item(unsigned long) const; + + void addFromUri(ScriptExecutionContext*, const String& src, double weight = 1.0); + void addFromString(const String&, double weight = 1.0); + +private: + SpeechGrammarList(); + + Vector<RefPtr<SpeechGrammar> > m_grammars; +}; + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // SpeechGrammarList_h diff --git a/Source/WebCore/Modules/speech/SpeechGrammarList.idl b/Source/WebCore/Modules/speech/SpeechGrammarList.idl new file mode 100644 index 000000000..bf4d7c69f --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechGrammarList.idl @@ -0,0 +1,37 @@ +/* + * 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 core { + interface [ + Conditional=SCRIPTED_SPEECH, + IndexedGetter, + Constructor, + ] SpeechGrammarList { + readonly attribute unsigned long length; + SpeechGrammar item(in [IsIndex] unsigned long index); + [CallWith=ScriptExecutionContext] void addFromUri(in DOMString src, in [Optional] float weight); + void addFromString(in DOMString string, in [Optional] float weight); + }; +} diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.cpp new file mode 100644 index 000000000..c58c1e78e --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.cpp @@ -0,0 +1,47 @@ +/* + * 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 "SpeechRecognitionAlternative.h" + +namespace WebCore { + +PassRefPtr<SpeechRecognitionAlternative> SpeechRecognitionAlternative::create(const String& transcript, double confidence) +{ + return adoptRef(new SpeechRecognitionAlternative(transcript, confidence)); +} + +SpeechRecognitionAlternative::SpeechRecognitionAlternative(const String& transcript, double confidence) + : m_transcript(transcript) + , m_confidence(confidence) +{ +} + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.h b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.h new file mode 100644 index 000000000..c577ea7ce --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.h @@ -0,0 +1,56 @@ +/* + * 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 SpeechRecognitionAlternative_h +#define SpeechRecognitionAlternative_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "PlatformString.h" +#include <wtf/RefCounted.h> + +namespace WebCore { + +class ScriptExecutionContext; + +class SpeechRecognitionAlternative : public RefCounted<SpeechRecognitionAlternative> { +public: + static PassRefPtr<SpeechRecognitionAlternative> create(const String&, double); + + const String& transcript() const { return m_transcript; } + double confidence() const { return m_confidence; } + +private: + SpeechRecognitionAlternative(const String&, double); + + String m_transcript; + double m_confidence; +}; + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // SpeechRecognitionAlternative_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.idl b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.idl new file mode 100644 index 000000000..a9d4dec3d --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.idl @@ -0,0 +1,34 @@ +/* + * 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 core { + interface [ + Conditional=SCRIPTED_SPEECH + ] SpeechRecognitionAlternative { + readonly attribute DOMString transcript; + readonly attribute float confidence; + }; +} + diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp new file mode 100644 index 000000000..b7b507237 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp @@ -0,0 +1,47 @@ +/* + * 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 "SpeechRecognitionError.h" + +namespace WebCore { + +PassRefPtr<SpeechRecognitionError> SpeechRecognitionError::create(Code code, const String& message) +{ + return adoptRef(new SpeechRecognitionError(code, message)); +} + +SpeechRecognitionError::SpeechRecognitionError(Code code, const String& message) + : m_code(code) + , m_message(message) +{ +} + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionError.h b/Source/WebCore/Modules/speech/SpeechRecognitionError.h new file mode 100644 index 000000000..daf945c58 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionError.h @@ -0,0 +1,66 @@ +/* + * 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 SpeechRecognitionError_h +#define SpeechRecognitionError_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "PlatformString.h" +#include <wtf/RefCounted.h> + +namespace WebCore { + +class SpeechRecognitionError : public RefCounted<SpeechRecognitionError> { +public: + enum Code { + OTHER = 0, + NO_SPEECH = 1, + ABORTED = 2, + AUDIO_CAPTURE = 3, + NETWORK = 4, + NOT_ALLOWED = 5, + SERVICE_NOT_ALLOWED = 6, + BAD_GRAMMAR = 7, + LANGUAGE_NOT_SUPPORTED = 8 + }; + + static PassRefPtr<SpeechRecognitionError> create(Code, const String&); + + Code code() { return m_code; } + const String& message() { return m_message; } + +private: + SpeechRecognitionError(Code, const String&); + + Code m_code; + String m_message; +}; + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // SpeechRecognitionError_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionError.idl b/Source/WebCore/Modules/speech/SpeechRecognitionError.idl new file mode 100644 index 000000000..39ecb1d0a --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionError.idl @@ -0,0 +1,43 @@ +/* + * 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 core { + interface [ + Conditional=SCRIPTED_SPEECH + ] SpeechRecognitionError { + const unsigned short OTHER = 0; + const unsigned short NO_SPEECH = 1; + const unsigned short ABORTED = 2; + const unsigned short AUDIO_CAPTURE = 3; + const unsigned short NETWORK = 4; + const unsigned short NOT_ALLOWED = 5; + const unsigned short SERVICE_NOT_ALLOWED = 6; + const unsigned short BAD_GRAMMAR = 7; + const unsigned short LANGUAGE_NOT_SUPPORTED = 8; + + readonly attribute unsigned short code; + readonly attribute DOMString message; + }; +} diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp new file mode 100644 index 000000000..c9f88e3a9 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp @@ -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 index 000000000..443906e88 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h @@ -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 index 000000000..49000810c --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl @@ -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; + }; +} diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp new file mode 100644 index 000000000..1dff24c19 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp @@ -0,0 +1,55 @@ +/* + * 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 "SpeechRecognitionResult.h" + +namespace WebCore { + +PassRefPtr<SpeechRecognitionResult> SpeechRecognitionResult::create(const Vector<RefPtr<SpeechRecognitionAlternative> >& alternatives, bool final) +{ + return adoptRef(new SpeechRecognitionResult(alternatives, final)); +} + +SpeechRecognitionAlternative* SpeechRecognitionResult::item(unsigned long index) +{ + if (index >= m_alternatives.size()) + return 0; + + return m_alternatives[index].get(); +} + +SpeechRecognitionResult::SpeechRecognitionResult(const Vector<RefPtr<SpeechRecognitionAlternative> >& alternatives, bool final) + : m_alternatives(alternatives) + , m_final(final) +{ +} + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResult.h b/Source/WebCore/Modules/speech/SpeechRecognitionResult.h new file mode 100644 index 000000000..38645cb04 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionResult.h @@ -0,0 +1,56 @@ +/* + * 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 SpeechRecognitionResult_h +#define SpeechRecognitionResult_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "SpeechRecognitionAlternative.h" +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class SpeechRecognitionResult : public RefCounted<SpeechRecognitionResult> { +public: + static PassRefPtr<SpeechRecognitionResult> create(const Vector<RefPtr<SpeechRecognitionAlternative> >&, bool final); + + unsigned long length() { return m_alternatives.size(); } + SpeechRecognitionAlternative* item(unsigned long index); + bool final() { return m_final; } + +private: + SpeechRecognitionResult(const Vector<RefPtr<SpeechRecognitionAlternative> >&, bool final); + + Vector<RefPtr<SpeechRecognitionAlternative> > m_alternatives; + bool m_final; +}; + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // SpeechRecognitionResult_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResult.idl b/Source/WebCore/Modules/speech/SpeechRecognitionResult.idl new file mode 100644 index 000000000..3f912621c --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionResult.idl @@ -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 core { + interface [ + Conditional=SCRIPTED_SPEECH, + IndexedGetter + ] SpeechRecognitionResult { + readonly attribute unsigned long length; + SpeechRecognitionAlternative item(in [IsIndex] unsigned long index); + readonly attribute boolean final; + }; +} + diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.cpp new file mode 100644 index 000000000..e8b2419c3 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.cpp @@ -0,0 +1,54 @@ +/* + * 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 "SpeechRecognitionResultList.h" + +namespace WebCore { + +PassRefPtr<SpeechRecognitionResultList> SpeechRecognitionResultList::create(const Vector<RefPtr<SpeechRecognitionResult> >& results) +{ + return adoptRef(new SpeechRecognitionResultList(results)); +} + +SpeechRecognitionResult* SpeechRecognitionResultList::item(unsigned long index) +{ + if (index >= m_results.size()) + return 0; + + return m_results[index].get(); +} + +SpeechRecognitionResultList::SpeechRecognitionResultList(const Vector<RefPtr<SpeechRecognitionResult> >& results) + : m_results(results) +{ +} + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.h b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.h new file mode 100644 index 000000000..22e3d4f19 --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.h @@ -0,0 +1,54 @@ +/* + * 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 SpeechRecognitionResultList_h +#define SpeechRecognitionResultList_h + +#if ENABLE(SCRIPTED_SPEECH) + +#include "SpeechRecognitionResult.h" +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class SpeechRecognitionResultList : public RefCounted<SpeechRecognitionResultList> { +public: + static PassRefPtr<SpeechRecognitionResultList> create(const Vector<RefPtr<SpeechRecognitionResult> >&); + + unsigned long length() { return m_results.size(); } + SpeechRecognitionResult* item(unsigned long index); + +private: + SpeechRecognitionResultList(const Vector<RefPtr<SpeechRecognitionResult> >&); + + Vector<RefPtr<SpeechRecognitionResult> > m_results; +}; + +} // namespace WebCore + +#endif // ENABLE(SCRIPTED_SPEECH) + +#endif // SpeechRecognitionResultList_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.idl b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.idl new file mode 100644 index 000000000..fd7be4f1c --- /dev/null +++ b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.idl @@ -0,0 +1,34 @@ +/* + * 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 core { + interface [ + Conditional=SCRIPTED_SPEECH, + IndexedGetter + ] SpeechRecognitionResultList { + readonly attribute unsigned long length; + SpeechRecognitionResult item(in [IsIndex] unsigned long index); + }; +} |