1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2013 Apple Inc. All rights reserved.
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modification, are permitted provided that the following conditions
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * are met:
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    documentation and/or other materials provided with the distribution.
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */
25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#ifndef SpeechSynthesisUtterance_h
27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define SpeechSynthesisUtterance_h
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "bindings/v8/ScriptWrappable.h"
30591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/dom/ContextLifecycleObserver.h"
31d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)#include "modules/EventTargetModules.h"
3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "modules/speech/SpeechSynthesisVoice.h"
3310f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch#include "platform/heap/Handle.h"
34a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/speech/PlatformSpeechSynthesisUtterance.h"
3553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "wtf/PassRefPtr.h"
36926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
37926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace WebCore {
3893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
395d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)class SpeechSynthesisUtterance FINAL : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<SpeechSynthesisUtterance>, public PlatformSpeechSynthesisUtteranceClient, public ScriptWrappable, public ContextLifecycleObserver, public EventTargetWithInlineData {
405d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<SpeechSynthesisUtterance>);
415d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesisUtterance);
42926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public:
435d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    static SpeechSynthesisUtterance* create(ExecutionContext*, const String&);
4493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    virtual ~SpeechSynthesisUtterance();
46926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
47926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    const String& text() const { return m_platformUtterance->text(); }
48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setText(const String& text) { m_platformUtterance->setText(text); }
49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    const String& lang() const { return m_platformUtterance->lang(); }
51926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setLang(const String& lang) { m_platformUtterance->setLang(lang); }
52926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
53926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    SpeechSynthesisVoice* voice() const;
54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setVoice(SpeechSynthesisVoice*);
55926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    float volume() const { return m_platformUtterance->volume(); }
57926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setVolume(float volume) { m_platformUtterance->setVolume(volume); }
58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
59926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    float rate() const { return m_platformUtterance->rate(); }
60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setRate(float rate) { m_platformUtterance->setRate(rate); }
61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
62926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    float pitch() const { return m_platformUtterance->pitch(); }
63926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setPitch(float pitch) { m_platformUtterance->setPitch(pitch); }
64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    double startTime() const { return m_platformUtterance->startTime(); }
66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void setStartTime(double startTime) { m_platformUtterance->setStartTime(startTime); }
6793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(start);
69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(end);
70926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
71926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(pause);
72926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(resume);
73926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(mark);
74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    DEFINE_ATTRIBUTE_EVENT_LISTENER(boundary);
75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
7609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    virtual ExecutionContext* executionContext() const OVERRIDE;
77926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
785d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance; }
79926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
80d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    virtual void trace(Visitor*) OVERRIDE;
8109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
82926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private:
831e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    SpeechSynthesisUtterance(ExecutionContext*, const String&);
845d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    Member<PlatformSpeechSynthesisUtterance> m_platformUtterance;
855d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    Member<SpeechSynthesisVoice> m_voice;
8693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
87926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    // EventTarget
88926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual const AtomicString& interfaceName() const OVERRIDE;
89926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
9093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
91926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} // namespace WebCore
92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
93926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif // SpeechSynthesisUtterance_h
94