diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/Modules/speech | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/Modules/speech')
42 files changed, 137 insertions, 1879 deletions
diff --git a/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp b/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp index ccc9593b2..af0b11987 100644 --- a/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp +++ b/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp @@ -57,16 +57,17 @@ DOMWindowSpeechSynthesis* DOMWindowSpeechSynthesis::from(DOMWindow* window) { DOMWindowSpeechSynthesis* supplement = static_cast<DOMWindowSpeechSynthesis*>(Supplement<DOMWindow>::from(window, supplementName())); if (!supplement) { - supplement = new DOMWindowSpeechSynthesis(window); - provideTo(window, supplementName(), adoptPtr(supplement)); + auto newSupplement = std::make_unique<DOMWindowSpeechSynthesis>(window); + supplement = newSupplement.get(); + provideTo(window, supplementName(), WTFMove(newSupplement)); } return supplement; } // static -SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis(DOMWindow* window) +SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis(DOMWindow& window) { - return DOMWindowSpeechSynthesis::from(window)->speechSynthesis(); + return DOMWindowSpeechSynthesis::from(&window)->speechSynthesis(); } SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis() diff --git a/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.h b/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.h index c51d1f465..423231db6 100644 --- a/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.h +++ b/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.h @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -38,14 +38,13 @@ class DOMWindow; class DOMWindowSpeechSynthesis : public Supplement<DOMWindow>, public DOMWindowProperty { public: + explicit DOMWindowSpeechSynthesis(DOMWindow*); virtual ~DOMWindowSpeechSynthesis(); - static SpeechSynthesis* speechSynthesis(DOMWindow*); + WEBCORE_EXPORT static SpeechSynthesis* speechSynthesis(DOMWindow&); static DOMWindowSpeechSynthesis* from(DOMWindow*); private: - explicit DOMWindowSpeechSynthesis(DOMWindow*); - SpeechSynthesis* speechSynthesis(); static const char* supplementName(); diff --git a/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.idl b/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.idl index 0744f07f0..37040777e 100644 --- a/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.idl +++ b/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.idl @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 diff --git a/Source/WebCore/Modules/speech/SpeechGrammar.cpp b/Source/WebCore/Modules/speech/SpeechGrammar.cpp deleted file mode 100644 index 59d42f988..000000000 --- a/Source/WebCore/Modules/speech/SpeechGrammar.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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) -{ - Document* document = toDocument(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 deleted file mode 100644 index 74b00ad76..000000000 --- a/Source/WebCore/Modules/speech/SpeechGrammar.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 <wtf/RefCounted.h> -#include <wtf/text/WTFString.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; } - const KURL& src() 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 deleted file mode 100644 index 143d58e50..000000000 --- a/Source/WebCore/Modules/speech/SpeechGrammar.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - */ - -[ - Conditional=SCRIPTED_SPEECH, - Constructor, - ImplementationLacksVTable, - InterfaceName=webkitSpeechGrammar -] interface SpeechGrammar { - [URL,CallWith=ScriptExecutionContext] attribute DOMString src; - attribute float weight; -}; diff --git a/Source/WebCore/Modules/speech/SpeechGrammarList.cpp b/Source/WebCore/Modules/speech/SpeechGrammarList.cpp deleted file mode 100644 index c3ddbe11f..000000000 --- a/Source/WebCore/Modules/speech/SpeechGrammarList.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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) -{ - Document* document = toDocument(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 deleted file mode 100644 index d7b53d757..000000000 --- a/Source/WebCore/Modules/speech/SpeechGrammarList.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 deleted file mode 100644 index e33360b56..000000000 --- a/Source/WebCore/Modules/speech/SpeechGrammarList.idl +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -[ - Conditional=SCRIPTED_SPEECH, - Constructor, - ImplementationLacksVTable, - InterfaceName=webkitSpeechGrammarList -] interface SpeechGrammarList { - readonly attribute unsigned long length; - getter SpeechGrammar item([IsIndex] unsigned long index); - [CallWith=ScriptExecutionContext] void addFromUri(DOMString src, optional float weight); - void addFromString(DOMString string, optional float weight); -}; diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.cpp b/Source/WebCore/Modules/speech/SpeechRecognition.cpp deleted file mode 100644 index 2a1953388..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognition.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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 "SpeechRecognition.h" - -#include "Document.h" -#include "ExceptionCode.h" -#include "Page.h" -#include "SpeechRecognitionController.h" -#include "SpeechRecognitionError.h" -#include "SpeechRecognitionEvent.h" - -namespace WebCore { - -PassRefPtr<SpeechRecognition> SpeechRecognition::create(ScriptExecutionContext* context) -{ - RefPtr<SpeechRecognition> speechRecognition(adoptRef(new SpeechRecognition(context))); - speechRecognition->suspendIfNeeded(); - return speechRecognition.release(); -} - -void SpeechRecognition::start(ExceptionCode& ec) -{ - ASSERT(m_controller); - if (m_started) { - ec = INVALID_STATE_ERR; - return; - } - - setPendingActivity(this); - m_finalResults.clear(); - m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimResults, m_maxAlternatives); - m_started = true; -} - -void SpeechRecognition::stopFunction() -{ - ASSERT(m_controller); - if (m_started && !m_stopping) { - m_stopping = true; - m_controller->stop(this); - } -} - -void SpeechRecognition::abort() -{ - ASSERT(m_controller); - if (m_started && !m_stopping) { - m_stopping = true; - m_controller->abort(this); - } -} - -void SpeechRecognition::didStartAudio() -{ - dispatchEvent(Event::create(eventNames().audiostartEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didStartSound() -{ - dispatchEvent(Event::create(eventNames().soundstartEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didStartSpeech() -{ - dispatchEvent(Event::create(eventNames().speechstartEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didEndSpeech() -{ - dispatchEvent(Event::create(eventNames().speechendEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didEndSound() -{ - dispatchEvent(Event::create(eventNames().soundendEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didEndAudio() -{ - dispatchEvent(Event::create(eventNames().audioendEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didReceiveResults(const Vector<RefPtr<SpeechRecognitionResult> >& newFinalResults, const Vector<RefPtr<SpeechRecognitionResult> >& currentInterimResults) -{ - unsigned long resultIndex = m_finalResults.size(); - - for (size_t i = 0; i < newFinalResults.size(); ++i) - m_finalResults.append(newFinalResults[i]); - - Vector<RefPtr<SpeechRecognitionResult> > results = m_finalResults; - for (size_t i = 0; i < currentInterimResults.size(); ++i) - results.append(currentInterimResults[i]); - - dispatchEvent(SpeechRecognitionEvent::createResult(resultIndex, results)); -} - -void SpeechRecognition::didReceiveNoMatch(PassRefPtr<SpeechRecognitionResult> result) -{ - dispatchEvent(SpeechRecognitionEvent::createNoMatch(result)); -} - -void SpeechRecognition::didReceiveError(PassRefPtr<SpeechRecognitionError> error) -{ - dispatchEvent(error); - m_started = false; -} - -void SpeechRecognition::didStart() -{ - dispatchEvent(Event::create(eventNames().startEvent, /*canBubble=*/false, /*cancelable=*/false)); -} - -void SpeechRecognition::didEnd() -{ - m_started = false; - m_stopping = false; - if (!m_stoppedByActiveDOMObject) - dispatchEvent(Event::create(eventNames().endEvent, /*canBubble=*/false, /*cancelable=*/false)); - unsetPendingActivity(this); -} - -const AtomicString& SpeechRecognition::interfaceName() const -{ - return eventNames().interfaceForSpeechRecognition; -} - -ScriptExecutionContext* SpeechRecognition::scriptExecutionContext() const -{ - return ActiveDOMObject::scriptExecutionContext(); -} - -void SpeechRecognition::stop() -{ - m_stoppedByActiveDOMObject = true; - if (hasPendingActivity()) - abort(); -} - -SpeechRecognition::SpeechRecognition(ScriptExecutionContext* context) - : ActiveDOMObject(context) - , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute. - , m_continuous(false) - , m_interimResults(false) - , m_maxAlternatives(1) - , m_controller(0) - , m_stoppedByActiveDOMObject(false) - , m_started(false) - , m_stopping(false) -{ - Document* document = toDocument(scriptExecutionContext()); - - Page* page = document->page(); - ASSERT(page); - - m_controller = SpeechRecognitionController::from(page); - ASSERT(m_controller); - - // FIXME: Need to hook up with Page to get notified when the visibility changes. -} - -SpeechRecognition::~SpeechRecognition() -{ -} - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.h b/Source/WebCore/Modules/speech/SpeechRecognition.h deleted file mode 100644 index 5053bcfa7..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognition.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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 SpeechRecognition_h -#define SpeechRecognition_h - -#if ENABLE(SCRIPTED_SPEECH) - -#include "ActiveDOMObject.h" -#include "EventTarget.h" -#include "SpeechGrammarList.h" -#include <wtf/Compiler.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/text/WTFString.h> - -namespace WebCore { - -class ScriptExecutionContext; -class SpeechRecognitionController; -class SpeechRecognitionError; -class SpeechRecognitionResult; -class SpeechRecognitionResultList; - -class SpeechRecognition : public RefCounted<SpeechRecognition>, public ActiveDOMObject, public EventTarget { -public: - static PassRefPtr<SpeechRecognition> create(ScriptExecutionContext*); - ~SpeechRecognition(); - - // Attributes. - PassRefPtr<SpeechGrammarList> grammars() { return m_grammars; } - void setGrammars(PassRefPtr<SpeechGrammarList> grammars) { m_grammars = grammars; } - String lang() { return m_lang; } - void setLang(const String& lang) { m_lang = lang; } - bool continuous() { return m_continuous; } - void setContinuous(bool continuous) { m_continuous = continuous; } - bool interimResults() { return m_interimResults; } - void setInterimResults(bool interimResults) { m_interimResults = interimResults; } - unsigned long maxAlternatives() { return m_maxAlternatives; } - void setMaxAlternatives(unsigned long maxAlternatives) { m_maxAlternatives = maxAlternatives; } - - // Callable by the user. - void start(ExceptionCode&); - void stopFunction(); - void abort(); - - // Called by the SpeechRecognitionClient. - void didStartAudio(); - void didStartSound(); - void didStartSpeech(); - void didEndSpeech(); - void didEndSound(); - void didEndAudio(); - void didReceiveResults(const Vector<RefPtr<SpeechRecognitionResult> >& newFinalResults, const Vector<RefPtr<SpeechRecognitionResult> >& currentInterimResults); - void didReceiveNoMatch(PassRefPtr<SpeechRecognitionResult>); - void didReceiveError(PassRefPtr<SpeechRecognitionError>); - void didStart(); - void didEnd(); - - // EventTarget. - virtual const AtomicString& interfaceName() const OVERRIDE; - virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; - - // ActiveDOMObject. - virtual void stop() OVERRIDE; - - using RefCounted<SpeechRecognition>::ref; - using RefCounted<SpeechRecognition>::deref; - - DEFINE_ATTRIBUTE_EVENT_LISTENER(audiostart); - DEFINE_ATTRIBUTE_EVENT_LISTENER(soundstart); - DEFINE_ATTRIBUTE_EVENT_LISTENER(speechstart); - DEFINE_ATTRIBUTE_EVENT_LISTENER(speechend); - DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend); - DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend); - DEFINE_ATTRIBUTE_EVENT_LISTENER(result); - DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch); - DEFINE_ATTRIBUTE_EVENT_LISTENER(error); - DEFINE_ATTRIBUTE_EVENT_LISTENER(start); - DEFINE_ATTRIBUTE_EVENT_LISTENER(end); - -private: - friend class RefCounted<SpeechRecognition>; - - explicit SpeechRecognition(ScriptExecutionContext*); - - - // EventTarget - virtual void refEventTarget() OVERRIDE { ref(); } - virtual void derefEventTarget() OVERRIDE { deref(); } - virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetData; } - virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventTargetData; } - - RefPtr<SpeechGrammarList> m_grammars; - String m_lang; - bool m_continuous; - bool m_interimResults; - unsigned long m_maxAlternatives; - - EventTargetData m_eventTargetData; - - SpeechRecognitionController* m_controller; - bool m_stoppedByActiveDOMObject; - bool m_started; - bool m_stopping; - Vector<RefPtr<SpeechRecognitionResult> > m_finalResults; -}; - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) - -#endif // SpeechRecognition_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognition.idl b/Source/WebCore/Modules/speech/SpeechRecognition.idl deleted file mode 100644 index 371acf568..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognition.idl +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ - -[ - Conditional=SCRIPTED_SPEECH, - ActiveDOMObject, - Constructor, - ConstructorCallWith=ScriptExecutionContext, - EventTarget, - InterfaceName=webkitSpeechRecognition -] interface SpeechRecognition { - attribute SpeechGrammarList grammars; - attribute DOMString lang; - attribute boolean continuous; - attribute boolean interimResults; - attribute unsigned long maxAlternatives; - - [RaisesException] void start(); - [ImplementedAs=stopFunction] void stop(); - void abort(); - - attribute EventListener onaudiostart; - attribute EventListener onsoundstart; - attribute EventListener onspeechstart; - attribute EventListener onspeechend; - attribute EventListener onsoundend; - attribute EventListener onaudioend; - attribute EventListener onresult; - attribute EventListener onnomatch; - attribute EventListener onerror; - attribute EventListener onstart; - attribute EventListener onend; - - // EventTarget interface - void addEventListener(DOMString type, - EventListener listener, - optional boolean useCapture); - void removeEventListener(DOMString type, - EventListener listener, - optional boolean useCapture); - [RaisesException] boolean dispatchEvent(Event evt); -}; diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.cpp deleted file mode 100644 index c58c1e78e..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2f2801480..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 <wtf/RefCounted.h> -#include <wtf/text/WTFString.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 deleted file mode 100644 index 230c824bb..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionAlternative.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -[ - NoInterfaceObject, - Conditional=SCRIPTED_SPEECH, - ImplementationLacksVTable -] interface SpeechRecognitionAlternative { - readonly attribute DOMString transcript; - readonly attribute float confidence; -}; diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionClient.h b/Source/WebCore/Modules/speech/SpeechRecognitionClient.h deleted file mode 100644 index 683ae2186..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionClient.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 SpeechRecognitionClient_h -#define SpeechRecognitionClient_h - -#if ENABLE(SCRIPTED_SPEECH) - -#include <wtf/text/WTFString.h> - -namespace WebCore { - -class Page; -class SpeechGrammarList; -class SpeechRecognition; - -class SpeechRecognitionClient { -public: - virtual void start(SpeechRecognition*, const SpeechGrammarList*, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives) = 0; - virtual void stop(SpeechRecognition*) = 0; - virtual void abort(SpeechRecognition*) = 0; - - virtual ~SpeechRecognitionClient() { } -}; - -void provideSpeechRecognitionTo(Page*, SpeechRecognitionClient*); - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) - -#endif // SpeechRecognitionClient_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionController.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionController.cpp deleted file mode 100644 index 26d4baa9f..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionController.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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" -#include "SpeechRecognitionController.h" - -#if ENABLE(SCRIPTED_SPEECH) - -namespace WebCore { - -const char* SpeechRecognitionController::supplementName() -{ - return "SpeechRecognitionController"; -} - -SpeechRecognitionController::SpeechRecognitionController(SpeechRecognitionClient* client) - : m_client(client) -{ -} - -SpeechRecognitionController::~SpeechRecognitionController() -{ - // FIXME: Call m_client->pageDestroyed(); once we have implemented a client. -} - -PassOwnPtr<SpeechRecognitionController> SpeechRecognitionController::create(SpeechRecognitionClient* client) -{ - return adoptPtr(new SpeechRecognitionController(client)); -} - -void provideSpeechRecognitionTo(Page* page, SpeechRecognitionClient* client) -{ - SpeechRecognitionController::provideTo(page, SpeechRecognitionController::supplementName(), SpeechRecognitionController::create(client)); -} - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionController.h b/Source/WebCore/Modules/speech/SpeechRecognitionController.h deleted file mode 100644 index efb3c39ca..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionController.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 SpeechRecognitionController_h -#define SpeechRecognitionController_h - -#if ENABLE(SCRIPTED_SPEECH) - -#include "Page.h" -#include "SpeechRecognitionClient.h" -#include <wtf/PassOwnPtr.h> - -namespace WebCore { - -class SpeechRecognitionController : public Supplement<Page> { -public: - virtual ~SpeechRecognitionController(); - - void start(SpeechRecognition* recognition, const SpeechGrammarList* grammars, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives) - { - m_client->start(recognition, grammars, lang, continuous, interimResults, maxAlternatives); - } - - void stop(SpeechRecognition* recognition) { m_client->stop(recognition); } - void abort(SpeechRecognition* recognition) { m_client->abort(recognition); } - - static PassOwnPtr<SpeechRecognitionController> create(SpeechRecognitionClient*); - static const char* supplementName(); - static SpeechRecognitionController* from(Page* page) { return static_cast<SpeechRecognitionController*>(Supplement<Page>::from(page, supplementName())); } - -private: - explicit SpeechRecognitionController(SpeechRecognitionClient*); - - SpeechRecognitionClient* m_client; -}; - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) - -#endif // SpeechRecognitionController_h diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp deleted file mode 100644 index 3fe584481..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionError.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 { - -static String ErrorCodeToString(SpeechRecognitionError::ErrorCode code) -{ - switch (code) { - case SpeechRecognitionError::ErrorCodeOther: - return ASCIILiteral("other"); - case SpeechRecognitionError::ErrorCodeNoSpeech: - return ASCIILiteral("no-speech"); - case SpeechRecognitionError::ErrorCodeAborted: - return ASCIILiteral("aborted"); - case SpeechRecognitionError::ErrorCodeAudioCapture: - return ASCIILiteral("audio-capture"); - case SpeechRecognitionError::ErrorCodeNetwork: - return ASCIILiteral("network"); - case SpeechRecognitionError::ErrorCodeNotAllowed: - return ASCIILiteral("not-allowed"); - case SpeechRecognitionError::ErrorCodeServiceNotAllowed: - return ASCIILiteral("service-not-allowed"); - case SpeechRecognitionError::ErrorCodeBadGrammar: - return ASCIILiteral("bad-grammar"); - case SpeechRecognitionError::ErrorCodeLanguageNotSupported: - return ASCIILiteral("language-not-supported"); - } - - ASSERT_NOT_REACHED(); - return String(); -} - -PassRefPtr<SpeechRecognitionError> SpeechRecognitionError::create(ErrorCode code, const String& message) -{ - return adoptRef(new SpeechRecognitionError(ErrorCodeToString(code), message)); -} - -PassRefPtr<SpeechRecognitionError> SpeechRecognitionError::create() -{ - return adoptRef(new SpeechRecognitionError(emptyString(), emptyString())); -} - -PassRefPtr<SpeechRecognitionError> SpeechRecognitionError::create(const AtomicString& eventName, const SpeechRecognitionErrorInit& initializer) -{ - return adoptRef(new SpeechRecognitionError(eventName, initializer)); -} - -SpeechRecognitionError::SpeechRecognitionError(const String& error, const String& message) - : Event(eventNames().errorEvent, /*canBubble=*/false, /*cancelable=*/false) - , m_error(error) - , m_message(message) -{ -} - -SpeechRecognitionError::SpeechRecognitionError(const AtomicString& eventName, const SpeechRecognitionErrorInit& initializer) - : Event(eventName, initializer) - , m_error(initializer.error) - , m_message(initializer.message) -{ -} - -const AtomicString& SpeechRecognitionError::interfaceName() const -{ - return eventNames().interfaceForSpeechRecognitionError; -} - -SpeechRecognitionErrorInit::SpeechRecognitionErrorInit() -{ -} - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionError.h b/Source/WebCore/Modules/speech/SpeechRecognitionError.h deleted file mode 100644 index 427e832fe..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionError.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 "Event.h" -#include <wtf/RefCounted.h> -#include <wtf/text/WTFString.h> - -namespace WebCore { - -struct SpeechRecognitionErrorInit : public EventInit { - SpeechRecognitionErrorInit(); - - String error; - String message; -}; - -class SpeechRecognitionError : public Event { -public: - enum ErrorCode { - // FIXME: This is an unspecified error and Chromium should stop using it. - ErrorCodeOther = 0, - - ErrorCodeNoSpeech = 1, - ErrorCodeAborted = 2, - ErrorCodeAudioCapture = 3, - ErrorCodeNetwork = 4, - ErrorCodeNotAllowed = 5, - ErrorCodeServiceNotAllowed = 6, - ErrorCodeBadGrammar = 7, - ErrorCodeLanguageNotSupported = 8 - }; - - static PassRefPtr<SpeechRecognitionError> create(ErrorCode, const String&); - static PassRefPtr<SpeechRecognitionError> create(); - static PassRefPtr<SpeechRecognitionError> create(const AtomicString&, const SpeechRecognitionErrorInit&); - - const String& error() { return m_error; } - const String& message() { return m_message; } - - virtual const AtomicString& interfaceName() const OVERRIDE; - -private: - SpeechRecognitionError(const String&, const String&); - SpeechRecognitionError(const AtomicString&, const SpeechRecognitionErrorInit&); - - String m_error; - 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 deleted file mode 100644 index 7d5e8d0c6..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionError.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -[ - Conditional=SCRIPTED_SPEECH, - ConstructorTemplate=Event, - InterfaceName=webkitSpeechRecognitionError -] interface SpeechRecognitionError : Event { - [InitializedByEventConstructor] readonly attribute DOMString error; - [InitializedByEventConstructor] readonly attribute DOMString message; -}; diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp deleted file mode 100644 index d2d6be6e8..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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(unsigned long resultIndex, const Vector<RefPtr<SpeechRecognitionResult> >& results) -{ - return adoptRef(new SpeechRecognitionEvent(eventNames().resultEvent, resultIndex, SpeechRecognitionResultList::create(results))); -} - -PassRefPtr<SpeechRecognitionEvent> SpeechRecognitionEvent::createNoMatch(PassRefPtr<SpeechRecognitionResult> result) -{ - 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 -{ - return eventNames().interfaceForSpeechRecognitionEvent; -} - -SpeechRecognitionEvent::SpeechRecognitionEvent() - : m_resultIndex(0) -{ -} - -SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, const SpeechRecognitionEventInit& initializer) - : Event(eventName, initializer) - , m_resultIndex(initializer.resultIndex) - , m_results(initializer.results) -{ -} - -SpeechRecognitionEvent::SpeechRecognitionEvent(const AtomicString& eventName, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> results) - : Event(eventName, /*canBubble=*/false, /*cancelable=*/false) - , m_resultIndex(resultIndex) - , m_results(results) -{ -} - -SpeechRecognitionEvent::~SpeechRecognitionEvent() -{ -} - -} // namespace WebCore - -#endif // ENABLE(SCRIPTED_SPEECH) diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h b/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h deleted file mode 100644 index 650aa6ece..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 "SpeechRecognitionResult.h" -#include "SpeechRecognitionResultList.h" -#include <wtf/RefPtr.h> - -namespace WebCore { - -class Document; - -struct SpeechRecognitionEventInit : public EventInit { - SpeechRecognitionEventInit(); - - unsigned long resultIndex; - RefPtr<SpeechRecognitionResultList> results; -}; - -class SpeechRecognitionEvent : public Event { -public: - static PassRefPtr<SpeechRecognitionEvent> create(); - static PassRefPtr<SpeechRecognitionEvent> create(const AtomicString&, const SpeechRecognitionEventInit&); - virtual ~SpeechRecognitionEvent(); - - 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; } - - // Event - virtual const AtomicString& interfaceName() const OVERRIDE; - -private: - SpeechRecognitionEvent(); - SpeechRecognitionEvent(const AtomicString&, const SpeechRecognitionEventInit&); - SpeechRecognitionEvent(const AtomicString& eventName, unsigned long resultIndex, PassRefPtr<SpeechRecognitionResultList> results); - - unsigned long m_resultIndex; - RefPtr<SpeechRecognitionResultList> m_results; -}; - -} // 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 deleted file mode 100644 index 65e3f2967..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ - -[ - Conditional=SCRIPTED_SPEECH, - ConstructorTemplate=Event, - InterfaceName=webkitSpeechRecognitionEvent -] interface SpeechRecognitionEvent : Event { - [InitializedByEventConstructor] readonly attribute unsigned long resultIndex; - [InitializedByEventConstructor] readonly attribute SpeechRecognitionResultList results; - - readonly attribute Document emma; -}; diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp deleted file mode 100644 index 9248744ef..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionResult.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 { - -SpeechRecognitionResult::~SpeechRecognitionResult() -{ -} - -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 deleted file mode 100644 index 74cc7b309..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionResult.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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: - ~SpeechRecognitionResult(); - static PassRefPtr<SpeechRecognitionResult> create(const Vector<RefPtr<SpeechRecognitionAlternative> >&, bool final); - - unsigned long length() { return m_alternatives.size(); } - SpeechRecognitionAlternative* item(unsigned long index); - bool isFinal() { 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 deleted file mode 100644 index cc7213bab..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionResult.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - */ - -[ - NoInterfaceObject, - Conditional=SCRIPTED_SPEECH, - ImplementationLacksVTable -] interface SpeechRecognitionResult { - readonly attribute unsigned long length; - getter SpeechRecognitionAlternative item([IsIndex] unsigned long index); - readonly attribute boolean isFinal; -}; diff --git a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.cpp b/Source/WebCore/Modules/speech/SpeechRecognitionResultList.cpp deleted file mode 100644 index e8b2419c3..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 deleted file mode 100644 index e5dc0e56e..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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: - explicit 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 deleted file mode 100644 index 46356519c..000000000 --- a/Source/WebCore/Modules/speech/SpeechRecognitionResultList.idl +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -[ - NoInterfaceObject, - Conditional=SCRIPTED_SPEECH, - ImplementationLacksVTable -] interface SpeechRecognitionResultList { - readonly attribute unsigned long length; - getter SpeechRecognitionResult item([IsIndex] unsigned long index); -}; diff --git a/Source/WebCore/Modules/speech/SpeechSynthesis.cpp b/Source/WebCore/Modules/speech/SpeechSynthesis.cpp index bad82da8c..7f17503d7 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesis.cpp +++ b/Source/WebCore/Modules/speech/SpeechSynthesis.cpp @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -30,28 +30,33 @@ #include "PlatformSpeechSynthesisVoice.h" #include "PlatformSpeechSynthesizer.h" +#include "ScriptController.h" #include "SpeechSynthesisEvent.h" #include "SpeechSynthesisUtterance.h" #include <wtf/CurrentTime.h> +#include <wtf/NeverDestroyed.h> namespace WebCore { -PassRefPtr<SpeechSynthesis> SpeechSynthesis::create() +Ref<SpeechSynthesis> SpeechSynthesis::create() { - return adoptRef(new SpeechSynthesis); + return adoptRef(*new SpeechSynthesis); } SpeechSynthesis::SpeechSynthesis() - : m_currentSpeechUtterance(0) + : m_currentSpeechUtterance(nullptr) , m_isPaused(false) +#if PLATFORM(IOS) + , m_restrictions(RequireUserGestureForSpeechStartRestriction) +#endif { } -void SpeechSynthesis::setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer> synthesizer) +void SpeechSynthesis::setPlatformSynthesizer(std::unique_ptr<PlatformSpeechSynthesizer> synthesizer) { - m_platformSpeechSynthesizer = synthesizer; + m_platformSpeechSynthesizer = WTFMove(synthesizer); m_voiceList.clear(); - m_currentSpeechUtterance = 0; + m_currentSpeechUtterance = nullptr; m_utteranceQueue.clear(); m_isPaused = false; } @@ -61,19 +66,17 @@ void SpeechSynthesis::voicesDidChange() m_voiceList.clear(); } -const Vector<RefPtr<SpeechSynthesisVoice> >& SpeechSynthesis::getVoices() +const Vector<RefPtr<SpeechSynthesisVoice>>& SpeechSynthesis::getVoices() { if (m_voiceList.size()) return m_voiceList; if (!m_platformSpeechSynthesizer) - m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(this); + m_platformSpeechSynthesizer = std::make_unique<PlatformSpeechSynthesizer>(this); // If the voiceList is empty, that's the cue to get the voices from the platform again. - const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& platformVoices = m_platformSpeechSynthesizer->voiceList(); - size_t voiceCount = platformVoices.size(); - for (size_t k = 0; k < voiceCount; k++) - m_voiceList.append(SpeechSynthesisVoice::create(platformVoices[k])); + for (auto& voice : m_platformSpeechSynthesizer->voiceList()) + m_voiceList.append(SpeechSynthesisVoice::create(voice)); return m_voiceList; } @@ -103,8 +106,15 @@ void SpeechSynthesis::startSpeakingImmediately(SpeechSynthesisUtterance* utteran utterance->setStartTime(monotonicallyIncreasingTime()); m_currentSpeechUtterance = utterance; m_isPaused = false; + + // Zero lengthed strings should immediately notify that the event is complete. + if (utterance->text().isEmpty()) { + handleSpeakingCompleted(utterance, false); + return; + } + if (!m_platformSpeechSynthesizer) - m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(this); + m_platformSpeechSynthesizer = std::make_unique<PlatformSpeechSynthesizer>(this); m_platformSpeechSynthesizer->speak(utterance->platformUtterance()); } @@ -112,6 +122,14 @@ void SpeechSynthesis::speak(SpeechSynthesisUtterance* utterance) { if (!utterance) return; + + // Like Audio, we should require that the user interact to start a speech synthesis session. +#if PLATFORM(IOS) + if (ScriptController::processingUserGesture()) + removeBehaviorRestriction(RequireUserGestureForSpeechStartRestriction); + else if (userGestureRequiredForSpeechStart()) + return; +#endif m_utteranceQueue.append(utterance); @@ -128,7 +146,7 @@ void SpeechSynthesis::cancel() m_utteranceQueue.clear(); if (m_platformSpeechSynthesizer) m_platformSpeechSynthesizer->cancel(); - current = 0; + current = nullptr; // The platform should have called back immediately and cleared the current utterance. ASSERT(!m_currentSpeechUtterance); @@ -155,7 +173,9 @@ void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc { ASSERT(utterance); ASSERT(m_currentSpeechUtterance); - m_currentSpeechUtterance = 0; + RefPtr<SpeechSynthesisUtterance> protect(utterance); + + m_currentSpeechUtterance = nullptr; fireEvent(errorOccurred ? eventNames().errorEvent : eventNames().endEvent, utterance, 0, String()); @@ -173,8 +193,8 @@ void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc void SpeechSynthesis::boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance, SpeechBoundary boundary, unsigned charIndex) { - DEFINE_STATIC_LOCAL(const String, wordBoundaryString, (ASCIILiteral("word"))); - DEFINE_STATIC_LOCAL(const String, sentenceBoundaryString, (ASCIILiteral("sentence"))); + static NeverDestroyed<const String> wordBoundaryString(ASCIILiteral("word")); + static NeverDestroyed<const String> sentenceBoundaryString(ASCIILiteral("sentence")); switch (boundary) { case SpeechWordBoundary: @@ -222,4 +242,4 @@ void SpeechSynthesis::speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUt } // namespace WebCore -#endif // ENABLE(INPUT_SPEECH) +#endif // ENABLE(SPEECH_SYNTHESIS) diff --git a/Source/WebCore/Modules/speech/SpeechSynthesis.h b/Source/WebCore/Modules/speech/SpeechSynthesis.h index 5393dfefa..0b718ce67 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesis.h +++ b/Source/WebCore/Modules/speech/SpeechSynthesis.h @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -28,6 +28,7 @@ #if ENABLE(SPEECH_SYNTHESIS) +#include "PlatformExportMacros.h" #include "PlatformSpeechSynthesisUtterance.h" #include "PlatformSpeechSynthesizer.h" #include "SpeechSynthesisUtterance.h" @@ -44,7 +45,7 @@ class SpeechSynthesisVoice; class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public RefCounted<SpeechSynthesis> { public: - static PassRefPtr<SpeechSynthesis> create(); + static Ref<SpeechSynthesis> create(); bool pending() const; bool speaking() const; @@ -55,32 +56,46 @@ public: void pause(); void resume(); - const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices(); + const Vector<RefPtr<SpeechSynthesisVoice>>& getVoices(); // Used in testing to use a mock platform synthesizer - void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); + WEBCORE_EXPORT void setPlatformSynthesizer(std::unique_ptr<PlatformSpeechSynthesizer>); private: SpeechSynthesis(); // PlatformSpeechSynthesizerClient override methods. - virtual void voicesDidChange() OVERRIDE; - virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; - virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; - virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; - virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; - virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE; - virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>, SpeechBoundary, unsigned charIndex) OVERRIDE; + virtual void voicesDidChange() override; + virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) override; + virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) override; + virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) override; + virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) override; + virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>) override; + virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>, SpeechBoundary, unsigned charIndex) override; void startSpeakingImmediately(SpeechSynthesisUtterance*); void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned long charIndex, const String& name); - OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; - Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList; +#if PLATFORM(IOS) + // Restrictions to change default behaviors. + enum BehaviorRestrictionFlags { + NoRestrictions = 0, + RequireUserGestureForSpeechStartRestriction = 1 << 0, + }; + typedef unsigned BehaviorRestrictions; + + bool userGestureRequiredForSpeechStart() const { return m_restrictions & RequireUserGestureForSpeechStartRestriction; } + void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; } +#endif + std::unique_ptr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; + Vector<RefPtr<SpeechSynthesisVoice>> m_voiceList; SpeechSynthesisUtterance* m_currentSpeechUtterance; - Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue; + Deque<RefPtr<SpeechSynthesisUtterance>> m_utteranceQueue; bool m_isPaused; +#if PLATFORM(IOS) + BehaviorRestrictions m_restrictions; +#endif }; } // namespace WebCore diff --git a/Source/WebCore/Modules/speech/SpeechSynthesis.idl b/Source/WebCore/Modules/speech/SpeechSynthesis.idl index 32419c0d4..dff8c216c 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesis.idl +++ b/Source/WebCore/Modules/speech/SpeechSynthesis.idl @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -25,7 +25,7 @@ [ NoInterfaceObject, - Conditional=SPEECH_SYNTHESIS + Conditional=SPEECH_SYNTHESIS, ] interface SpeechSynthesis { readonly attribute boolean pending; readonly attribute boolean speaking; diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp b/Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp index ff3d55b48..ec4a7f7b1 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp +++ b/Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -29,22 +29,13 @@ #if ENABLE(SPEECH_SYNTHESIS) namespace WebCore { - -PassRefPtr<SpeechSynthesisEvent> SpeechSynthesisEvent::create() -{ - return adoptRef(new SpeechSynthesisEvent()); -} - -PassRefPtr<SpeechSynthesisEvent> SpeechSynthesisEvent::create(const AtomicString& type, unsigned long charIndex, float elapsedTime, const String& name) -{ - return adoptRef(new SpeechSynthesisEvent(type, charIndex, elapsedTime, name)); -} -SpeechSynthesisEvent::SpeechSynthesisEvent() +Ref<SpeechSynthesisEvent> SpeechSynthesisEvent::create(const AtomicString& type, unsigned charIndex, float elapsedTime, const String& name) { + return adoptRef(*new SpeechSynthesisEvent(type, charIndex, elapsedTime, name)); } -SpeechSynthesisEvent::SpeechSynthesisEvent(const AtomicString& type, unsigned long charIndex, float elapsedTime, const String& name) +SpeechSynthesisEvent::SpeechSynthesisEvent(const AtomicString& type, unsigned charIndex, float elapsedTime, const String& name) : Event(type, false, false) , m_charIndex(charIndex) , m_elapsedTime(elapsedTime) diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisEvent.h b/Source/WebCore/Modules/speech/SpeechSynthesisEvent.h index ddb4d63fa..01e788e65 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisEvent.h +++ b/Source/WebCore/Modules/speech/SpeechSynthesisEvent.h @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -35,18 +35,16 @@ namespace WebCore { class SpeechSynthesisEvent : public Event { public: - static PassRefPtr<SpeechSynthesisEvent> create(); - static PassRefPtr<SpeechSynthesisEvent> create(const AtomicString& type, unsigned long charIndex, float elapsedTime, const String& name); + static Ref<SpeechSynthesisEvent> create(const AtomicString& type, unsigned charIndex, float elapsedTime, const String& name); unsigned long charIndex() const { return m_charIndex; } float elapsedTime() const { return m_elapsedTime; } const String& name() const { return m_name; } - virtual const AtomicString& interfaceName() const { return eventNames().interfaceForSpeechSynthesisEvent; } + virtual EventInterface eventInterface() const { return SpeechSynthesisEventInterfaceType; } private: - SpeechSynthesisEvent(); - SpeechSynthesisEvent(const AtomicString& type, unsigned long charIndex, float elapsedTime, const String& name); + SpeechSynthesisEvent(const AtomicString& type, unsigned charIndex, float elapsedTime, const String& name); unsigned long m_charIndex; float m_elapsedTime; diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl b/Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl index fbc7514fc..8403f1398 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl +++ b/Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -27,6 +27,6 @@ Conditional=SPEECH_SYNTHESIS ] interface SpeechSynthesisEvent : Event { readonly attribute unsigned long charIndex; - readonly attribute float elapsedTime; + readonly attribute unrestricted float elapsedTime; readonly attribute DOMString name; }; diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp index b21ce667b..d8bc7a55c 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp +++ b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -30,13 +30,13 @@ namespace WebCore { -PassRefPtr<SpeechSynthesisUtterance> SpeechSynthesisUtterance::create(ScriptExecutionContext* context, const String& text) +Ref<SpeechSynthesisUtterance> SpeechSynthesisUtterance::create(ScriptExecutionContext& context, const String& text) { - return adoptRef(new SpeechSynthesisUtterance(context, text)); + return adoptRef(*new SpeechSynthesisUtterance(context, text)); } -SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext* context, const String& text) - : ContextDestructionObserver(context) +SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext& context, const String& text) + : ContextDestructionObserver(&context) , m_platformUtterance(PlatformSpeechSynthesisUtterance::create(this)) { m_platformUtterance->setText(text); @@ -44,17 +44,7 @@ SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext* conte SpeechSynthesisUtterance::~SpeechSynthesisUtterance() { - m_platformUtterance->setClient(0); -} - -ScriptExecutionContext* SpeechSynthesisUtterance::scriptExecutionContext() const -{ - return ContextDestructionObserver::scriptExecutionContext(); -} - -const AtomicString& SpeechSynthesisUtterance::interfaceName() const -{ - return eventNames().interfaceForSpeechSynthesisUtterance; + m_platformUtterance->setClient(nullptr); } SpeechSynthesisVoice* SpeechSynthesisUtterance::voice() const diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h index 0bfb7c40b..19016dfd5 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h +++ b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -36,10 +36,10 @@ #include <wtf/RefCounted.h> namespace WebCore { - -class SpeechSynthesisUtterance : public PlatformSpeechSynthesisUtteranceClient, public RefCounted<SpeechSynthesisUtterance>, public ContextDestructionObserver, public EventTarget { + +class SpeechSynthesisUtterance final : public PlatformSpeechSynthesisUtteranceClient, public RefCounted<SpeechSynthesisUtterance>, public ContextDestructionObserver, public EventTargetWithInlineData { public: - static PassRefPtr<SpeechSynthesisUtterance> create(ScriptExecutionContext*, const String&); + static Ref<SpeechSynthesisUtterance> create(ScriptExecutionContext&, const String&); ~SpeechSynthesisUtterance(); @@ -64,34 +64,21 @@ public: double startTime() const { return m_platformUtterance->startTime(); } void setStartTime(double startTime) { m_platformUtterance->setStartTime(startTime); } - DEFINE_ATTRIBUTE_EVENT_LISTENER(start); - DEFINE_ATTRIBUTE_EVENT_LISTENER(end); - DEFINE_ATTRIBUTE_EVENT_LISTENER(error); - DEFINE_ATTRIBUTE_EVENT_LISTENER(pause); - DEFINE_ATTRIBUTE_EVENT_LISTENER(resume); - DEFINE_ATTRIBUTE_EVENT_LISTENER(mark); - DEFINE_ATTRIBUTE_EVENT_LISTENER(boundary); - using RefCounted<SpeechSynthesisUtterance>::ref; using RefCounted<SpeechSynthesisUtterance>::deref; - virtual ScriptExecutionContext* scriptExecutionContext() const; + virtual ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); } PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance.get(); } private: - SpeechSynthesisUtterance(ScriptExecutionContext*, const String&); + SpeechSynthesisUtterance(ScriptExecutionContext&, const String&); RefPtr<PlatformSpeechSynthesisUtterance> m_platformUtterance; RefPtr<SpeechSynthesisVoice> m_voice; - - // EventTarget - EventTargetData m_eventTargetData; - - virtual const AtomicString& interfaceName() const OVERRIDE; - virtual void refEventTarget() OVERRIDE { ref(); } - virtual void derefEventTarget() OVERRIDE { deref(); } - virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetData; } - virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventTargetData; } + + virtual EventTargetInterface eventTargetInterface() const override { return SpeechSynthesisUtteranceEventTargetInterfaceType; } + virtual void refEventTarget() override { ref(); } + virtual void derefEventTarget() override { deref(); } }; } // namespace WebCore diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl index e82da4291..cf4373e6a 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl +++ b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -25,22 +25,21 @@ [ Conditional=SPEECH_SYNTHESIS, - EventTarget, ConstructorCallWith=ScriptExecutionContext, Constructor([Default=NullString] optional DOMString text) -] interface SpeechSynthesisUtterance { +] interface SpeechSynthesisUtterance : EventTarget { attribute DOMString text; attribute DOMString lang; attribute SpeechSynthesisVoice voice; - attribute float volume; - attribute float rate; - attribute float pitch; + attribute unrestricted float volume; + attribute unrestricted float rate; + attribute unrestricted float pitch; - attribute EventListener onstart; - attribute EventListener onend; - attribute EventListener onerror; - attribute EventListener onpause; - attribute EventListener onresume; - attribute EventListener onmark; - attribute EventListener onboundary; + attribute EventHandler onstart; + attribute EventHandler onend; + attribute EventHandler onerror; + attribute EventHandler onpause; + attribute EventHandler onresume; + attribute EventHandler onmark; + attribute EventHandler onboundary; }; diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisVoice.cpp b/Source/WebCore/Modules/speech/SpeechSynthesisVoice.cpp index 36ee5e48a..dd1cf09c2 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisVoice.cpp +++ b/Source/WebCore/Modules/speech/SpeechSynthesisVoice.cpp @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -30,9 +30,9 @@ namespace WebCore { -PassRefPtr<SpeechSynthesisVoice> SpeechSynthesisVoice::create(PassRefPtr<PlatformSpeechSynthesisVoice> voice) +Ref<SpeechSynthesisVoice> SpeechSynthesisVoice::create(PassRefPtr<PlatformSpeechSynthesisVoice> voice) { - return adoptRef(new SpeechSynthesisVoice(voice)); + return adoptRef(*new SpeechSynthesisVoice(voice)); } SpeechSynthesisVoice::SpeechSynthesisVoice(PassRefPtr<PlatformSpeechSynthesisVoice> voice) diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h b/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h index 76c95cbe9..d5b8848bb 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h +++ b/Source/WebCore/Modules/speech/SpeechSynthesisVoice.h @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -38,7 +38,7 @@ namespace WebCore { class SpeechSynthesisVoice : public RefCounted<SpeechSynthesisVoice> { public: virtual ~SpeechSynthesisVoice() { } - static PassRefPtr<SpeechSynthesisVoice> create(PassRefPtr<PlatformSpeechSynthesisVoice>); + static Ref<SpeechSynthesisVoice> create(PassRefPtr<PlatformSpeechSynthesisVoice>); const String& voiceURI() const { return m_platformVoice->voiceURI(); } const String& name() const { return m_platformVoice->name(); } diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisVoice.idl b/Source/WebCore/Modules/speech/SpeechSynthesisVoice.idl index e64646671..9aa489e05 100644 --- a/Source/WebCore/Modules/speech/SpeechSynthesisVoice.idl +++ b/Source/WebCore/Modules/speech/SpeechSynthesisVoice.idl @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 |