| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define SpeechSynthesis_h | 27 #define SpeechSynthesis_h |
| 28 | 28 |
| 29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
| 30 #include "core/dom/ContextLifecycleObserver.h" | 30 #include "core/dom/ContextLifecycleObserver.h" |
| 31 #include "modules/EventTargetModules.h" | 31 #include "modules/EventTargetModules.h" |
| 32 #include "modules/speech/SpeechSynthesisUtterance.h" | 32 #include "modules/speech/SpeechSynthesisUtterance.h" |
| 33 #include "modules/speech/SpeechSynthesisVoice.h" | 33 #include "modules/speech/SpeechSynthesisVoice.h" |
| 34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
| 35 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" | 35 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" |
| 36 #include "platform/speech/PlatformSpeechSynthesizer.h" | 36 #include "platform/speech/PlatformSpeechSynthesizer.h" |
| 37 #include "wtf/Deque.h" |
| 37 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" |
| 40 #include "wtf/RefPtr.h" |
| 38 | 41 |
| 39 namespace WebCore { | 42 namespace WebCore { |
| 40 | 43 |
| 41 class ExceptionState; | 44 class ExceptionState; |
| 42 class PlatformSpeechSynthesizerClient; | 45 class PlatformSpeechSynthesizerClient; |
| 43 | 46 |
| 44 class SpeechSynthesis FINAL : public RefCountedGarbageCollected<SpeechSynthesis>
, public PlatformSpeechSynthesizerClient, public ScriptWrappable, public Context
LifecycleObserver, public EventTargetWithInlineData { | 47 class SpeechSynthesis FINAL : public RefCountedWillBeRefCountedGarbageCollected<
SpeechSynthesis>, public PlatformSpeechSynthesizerClient, public ScriptWrappable
, public ContextLifecycleObserver, public EventTargetWithInlineData { |
| 45 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedGarbageCollected<SpeechSynthesis>)
; | 48 REFCOUNTED_EVENT_TARGET(SpeechSynthesis); |
| 46 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesis); | 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesis); |
| 47 public: | 50 public: |
| 48 static SpeechSynthesis* create(ExecutionContext*); | 51 static PassRefPtrWillBeRawPtr<SpeechSynthesis> create(ExecutionContext*); |
| 49 | 52 |
| 50 bool pending() const; | 53 bool pending() const; |
| 51 bool speaking() const; | 54 bool speaking() const; |
| 52 bool paused() const; | 55 bool paused() const; |
| 53 | 56 |
| 54 void speak(SpeechSynthesisUtterance*, ExceptionState&); | 57 void speak(SpeechSynthesisUtterance*, ExceptionState&); |
| 55 void cancel(); | 58 void cancel(); |
| 56 void pause(); | 59 void pause(); |
| 57 void resume(); | 60 void resume(); |
| 58 | 61 |
| 59 const HeapVector<Member<SpeechSynthesisVoice> >& getVoices(); | 62 const WillBeHeapVector<RefPtrWillBeMember<SpeechSynthesisVoice> >& getVoices
(); |
| 60 | 63 |
| 61 // Used in testing to use a mock platform synthesizer | 64 // Used in testing to use a mock platform synthesizer |
| 62 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); | 65 void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>); |
| 63 | 66 |
| 64 DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged); | 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged); |
| 65 | 68 |
| 66 virtual ExecutionContext* executionContext() const OVERRIDE; | 69 virtual ExecutionContext* executionContext() const OVERRIDE; |
| 67 | 70 |
| 68 virtual void trace(Visitor*) OVERRIDE; | 71 virtual void trace(Visitor*) OVERRIDE; |
| 69 | 72 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 80 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran
ce>, SpeechBoundary, unsigned charIndex) OVERRIDE; | 83 virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtteran
ce>, SpeechBoundary, unsigned charIndex) OVERRIDE; |
| 81 | 84 |
| 82 void startSpeakingImmediately(); | 85 void startSpeakingImmediately(); |
| 83 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); | 86 void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred); |
| 84 void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned
long charIndex, const String& name); | 87 void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned
long charIndex, const String& name); |
| 85 | 88 |
| 86 // Returns the utterance at the front of the queue. | 89 // Returns the utterance at the front of the queue. |
| 87 SpeechSynthesisUtterance* currentSpeechUtterance() const; | 90 SpeechSynthesisUtterance* currentSpeechUtterance() const; |
| 88 | 91 |
| 89 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; | 92 OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer; |
| 90 HeapVector<Member<SpeechSynthesisVoice> > m_voiceList; | 93 WillBeHeapVector<RefPtrWillBeMember<SpeechSynthesisVoice> > m_voiceList; |
| 91 HeapDeque<Member<SpeechSynthesisUtterance> > m_utteranceQueue; | 94 Deque<RefPtrWillBeMember<SpeechSynthesisUtterance> > m_utteranceQueue; |
| 92 bool m_isPaused; | 95 bool m_isPaused; |
| 93 | 96 |
| 94 // EventTarget | 97 // EventTarget |
| 95 virtual const AtomicString& interfaceName() const OVERRIDE; | 98 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 } // namespace WebCore | 101 } // namespace WebCore |
| 99 | 102 |
| 100 #endif // SpeechSynthesisEvent_h | 103 #endif // SpeechSynthesisEvent_h |
| OLD | NEW |