Commit 7ae04f2f authored by sigbjornf@opera.com's avatar sigbjornf@opera.com

Oilpan: move platform speech objects to the heap.

With the Speech API now using Oilpan by default, follow up and also
heap allocate the platform-level intermediary objects.

R=tkent@chromium.org,haraken@chromium.org
BUG=340522

Review URL: https://codereview.chromium.org/339823003

git-svn-id: svn://svn.chromium.org/blink/trunk@176321 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3658653b
......@@ -171,7 +171,7 @@ SpeechRecognition::SpeechRecognition(ExecutionContext* context)
, m_continuous(false)
, m_interimResults(false)
, m_maxAlternatives(1)
, m_controller(0)
, m_controller(nullptr)
, m_stoppedByActiveDOMObject(false)
, m_started(false)
, m_stopping(false)
......@@ -195,6 +195,9 @@ SpeechRecognition::~SpeechRecognition()
void SpeechRecognition::trace(Visitor* visitor)
{
visitor->trace(m_grammars);
#if ENABLE(OILPAN)
visitor->trace(m_controller);
#endif
visitor->trace(m_finalResults);
EventTargetWithInlineData::trace(visitor);
}
......
......@@ -50,7 +50,7 @@ public:
virtual ~SpeechRecognition();
// Attributes.
SpeechGrammarList* grammars() { return m_grammars.get(); }
SpeechGrammarList* grammars() { return m_grammars; }
void setGrammars(SpeechGrammarList* grammars) { m_grammars = grammars; }
String lang() { return m_lang; }
void setLang(const String& lang) { m_lang = lang; }
......@@ -110,7 +110,7 @@ private:
bool m_interimResults;
unsigned long m_maxAlternatives;
SpeechRecognitionController* m_controller;
RawPtrWillBeMember<SpeechRecognitionController> m_controller;
bool m_stoppedByActiveDOMObject;
bool m_started;
bool m_stopping;
......
......@@ -47,7 +47,7 @@ SpeechSynthesis::SpeechSynthesis(ExecutionContext* context)
ScriptWrappable::init(this);
}
void SpeechSynthesis::setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer> synthesizer)
void SpeechSynthesis::setPlatformSynthesizer(PlatformSpeechSynthesizer* synthesizer)
{
m_platformSpeechSynthesizer = synthesizer;
}
......@@ -70,10 +70,10 @@ const HeapVector<Member<SpeechSynthesisVoice> >& SpeechSynthesis::getVoices()
return m_voiceList;
// 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();
const HeapVector<Member<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]));
m_voiceList.append(SpeechSynthesisVoice::create(platformVoices[k].get()));
return m_voiceList;
}
......@@ -172,7 +172,7 @@ void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc
startSpeakingImmediately();
}
void SpeechSynthesis::boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance, SpeechBoundary boundary, unsigned charIndex)
void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance* utterance, SpeechBoundary boundary, unsigned charIndex)
{
DEFINE_STATIC_LOCAL(const String, wordBoundaryString, ("word"));
DEFINE_STATIC_LOCAL(const String, sentenceBoundaryString, ("sentence"));
......@@ -189,33 +189,33 @@ void SpeechSynthesis::boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUt
}
}
void SpeechSynthesis::didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void SpeechSynthesis::didStartSpeaking(PlatformSpeechSynthesisUtterance* utterance)
{
if (utterance->client())
fireEvent(EventTypeNames::start, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
void SpeechSynthesis::didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void SpeechSynthesis::didPauseSpeaking(PlatformSpeechSynthesisUtterance* utterance)
{
m_isPaused = true;
if (utterance->client())
fireEvent(EventTypeNames::pause, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
void SpeechSynthesis::didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void SpeechSynthesis::didResumeSpeaking(PlatformSpeechSynthesisUtterance* utterance)
{
m_isPaused = false;
if (utterance->client())
fireEvent(EventTypeNames::resume, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
void SpeechSynthesis::didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void SpeechSynthesis::didFinishSpeaking(PlatformSpeechSynthesisUtterance* utterance)
{
if (utterance->client())
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), false);
}
void SpeechSynthesis::speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void SpeechSynthesis::speakingErrorOccurred(PlatformSpeechSynthesisUtterance* utterance)
{
if (utterance->client())
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), true);
......@@ -235,8 +235,10 @@ const AtomicString& SpeechSynthesis::interfaceName() const
void SpeechSynthesis::trace(Visitor* visitor)
{
visitor->trace(m_platformSpeechSynthesizer);
visitor->trace(m_voiceList);
visitor->trace(m_utteranceQueue);
PlatformSpeechSynthesizerClient::trace(visitor);
EventTargetWithInlineData::trace(visitor);
}
......
......@@ -34,7 +34,6 @@
#include "platform/heap/Handle.h"
#include "platform/speech/PlatformSpeechSynthesisUtterance.h"
#include "platform/speech/PlatformSpeechSynthesizer.h"
#include "wtf/PassRefPtr.h"
namespace WebCore {
......@@ -43,7 +42,7 @@ class PlatformSpeechSynthesizerClient;
class SpeechSynthesis FINAL : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<SpeechSynthesis>, public PlatformSpeechSynthesizerClient, public ScriptWrappable, public ContextLifecycleObserver, public EventTargetWithInlineData {
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<SpeechSynthesis>);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesis);
USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesis);
public:
static SpeechSynthesis* create(ExecutionContext*);
......@@ -59,7 +58,7 @@ public:
const HeapVector<Member<SpeechSynthesisVoice> >& getVoices();
// Used in testing to use a mock platform synthesizer
void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>);
void setPlatformSynthesizer(PlatformSpeechSynthesizer*);
DEFINE_ATTRIBUTE_EVENT_LISTENER(voiceschanged);
......@@ -72,12 +71,12 @@ private:
// 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 didStartSpeaking(PlatformSpeechSynthesisUtterance*) OVERRIDE;
virtual void didPauseSpeaking(PlatformSpeechSynthesisUtterance*) OVERRIDE;
virtual void didResumeSpeaking(PlatformSpeechSynthesisUtterance*) OVERRIDE;
virtual void didFinishSpeaking(PlatformSpeechSynthesisUtterance*) OVERRIDE;
virtual void speakingErrorOccurred(PlatformSpeechSynthesisUtterance*) OVERRIDE;
virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance*, SpeechBoundary, unsigned charIndex) OVERRIDE;
void startSpeakingImmediately();
void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred);
......@@ -86,7 +85,7 @@ private:
// Returns the utterance at the front of the queue.
SpeechSynthesisUtterance* currentSpeechUtterance() const;
OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer;
Member<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer;
HeapVector<Member<SpeechSynthesisVoice> > m_voiceList;
HeapDeque<Member<SpeechSynthesisUtterance> > m_utteranceQueue;
bool m_isPaused;
......
......@@ -43,7 +43,6 @@ SpeechSynthesisUtterance::SpeechSynthesisUtterance(ExecutionContext* context, co
SpeechSynthesisUtterance::~SpeechSynthesisUtterance()
{
m_platformUtterance->setClient(0);
}
ExecutionContext* SpeechSynthesisUtterance::executionContext() const
......@@ -73,6 +72,7 @@ void SpeechSynthesisUtterance::setVoice(SpeechSynthesisVoice* voice)
void SpeechSynthesisUtterance::trace(Visitor* visitor)
{
visitor->trace(m_platformUtterance);
visitor->trace(m_voice);
EventTargetWithInlineData::trace(visitor);
}
......
......@@ -38,7 +38,7 @@ namespace WebCore {
class SpeechSynthesisUtterance FINAL : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<SpeechSynthesisUtterance>, public PlatformSpeechSynthesisUtteranceClient, public ScriptWrappable, public ContextLifecycleObserver, public EventTargetWithInlineData {
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<SpeechSynthesisUtterance>);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesisUtterance);
USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesisUtterance);
public:
static SpeechSynthesisUtterance* create(ExecutionContext*, const String&);
......@@ -75,13 +75,13 @@ public:
virtual ExecutionContext* executionContext() const OVERRIDE;
PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance.get(); }
PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance; }
virtual void trace(Visitor*) OVERRIDE;
private:
SpeechSynthesisUtterance(ExecutionContext*, const String&);
RefPtr<PlatformSpeechSynthesisUtterance> m_platformUtterance;
Member<PlatformSpeechSynthesisUtterance> m_platformUtterance;
Member<SpeechSynthesisVoice> m_voice;
// EventTarget
......
......@@ -28,15 +28,20 @@
namespace WebCore {
SpeechSynthesisVoice* SpeechSynthesisVoice::create(PassRefPtr<PlatformSpeechSynthesisVoice> voice)
SpeechSynthesisVoice* SpeechSynthesisVoice::create(PlatformSpeechSynthesisVoice* voice)
{
return new SpeechSynthesisVoice(voice);
}
SpeechSynthesisVoice::SpeechSynthesisVoice(PassRefPtr<PlatformSpeechSynthesisVoice> voice)
SpeechSynthesisVoice::SpeechSynthesisVoice(PlatformSpeechSynthesisVoice* voice)
: m_platformVoice(voice)
{
ScriptWrappable::init(this);
}
void SpeechSynthesisVoice::trace(Visitor* visitor)
{
visitor->trace(m_platformVoice);
}
} // namespace WebCore
......@@ -29,15 +29,13 @@
#include "bindings/v8/ScriptWrappable.h"
#include "platform/heap/Handle.h"
#include "platform/speech/PlatformSpeechSynthesisVoice.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class SpeechSynthesisVoice FINAL : public GarbageCollectedFinalized<SpeechSynthesisVoice>, public ScriptWrappable {
public:
static SpeechSynthesisVoice* create(PassRefPtr<PlatformSpeechSynthesisVoice>);
static SpeechSynthesisVoice* create(PlatformSpeechSynthesisVoice*);
const String& voiceURI() const { return m_platformVoice->voiceURI(); }
const String& name() const { return m_platformVoice->name(); }
......@@ -45,14 +43,14 @@ public:
bool localService() const { return m_platformVoice->localService(); }
bool isDefault() const { return m_platformVoice->isDefault(); }
PlatformSpeechSynthesisVoice* platformVoice() const { return m_platformVoice.get(); }
PlatformSpeechSynthesisVoice* platformVoice() const { return m_platformVoice; }
void trace(Visitor*) { }
void trace(Visitor*);
private:
explicit SpeechSynthesisVoice(PassRefPtr<PlatformSpeechSynthesisVoice>);
explicit SpeechSynthesisVoice(PlatformSpeechSynthesisVoice*);
RefPtr<PlatformSpeechSynthesisVoice> m_platformVoice;
Member<PlatformSpeechSynthesisVoice> m_platformVoice;
};
} // namespace WebCore
......
......@@ -31,12 +31,12 @@
namespace WebCore {
PassOwnPtr<PlatformSpeechSynthesizerMock> PlatformSpeechSynthesizerMock::create(PlatformSpeechSynthesizerClient* client)
PlatformSpeechSynthesizerMock* PlatformSpeechSynthesizerMock::create(PlatformSpeechSynthesizerClient* client)
{
OwnPtr<PlatformSpeechSynthesizerMock> synthesizer = adoptPtr(new PlatformSpeechSynthesizerMock(client));
PlatformSpeechSynthesizerMock* synthesizer = new PlatformSpeechSynthesizerMock(client);
synthesizer->initializeVoiceList();
client->voicesDidChange();
return synthesizer.release();
return synthesizer;
}
PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(PlatformSpeechSynthesizerClient* client)
......@@ -74,7 +74,7 @@ void PlatformSpeechSynthesizerMock::initializeVoiceList()
m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.logan"), String("logan"), String("fr-CA"), true, true));
}
void PlatformSpeechSynthesizerMock::speak(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void PlatformSpeechSynthesizerMock::speak(PlatformSpeechSynthesisUtterance* utterance)
{
ASSERT(!m_utterance);
m_utterance = utterance;
......@@ -107,5 +107,10 @@ void PlatformSpeechSynthesizerMock::resume()
client()->didResumeSpeaking(m_utterance);
}
void PlatformSpeechSynthesizerMock::trace(Visitor* visitor)
{
visitor->trace(m_utterance);
PlatformSpeechSynthesizer::trace(visitor);
}
} // namespace WebCore
......@@ -27,21 +27,23 @@
#define PlatformSpeechSynthesizerMock_h
#include "platform/Timer.h"
#include "platform/heap/Handle.h"
#include "platform/speech/PlatformSpeechSynthesizer.h"
#include "wtf/PassOwnPtr.h"
namespace WebCore {
class PlatformSpeechSynthesizerMock FINAL : public PlatformSpeechSynthesizer {
public:
static PassOwnPtr<PlatformSpeechSynthesizerMock> create(PlatformSpeechSynthesizerClient*);
static PlatformSpeechSynthesizerMock* create(PlatformSpeechSynthesizerClient*);
virtual ~PlatformSpeechSynthesizerMock();
virtual void speak(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
virtual void speak(PlatformSpeechSynthesisUtterance*) OVERRIDE;
virtual void pause() OVERRIDE;
virtual void resume() OVERRIDE;
virtual void cancel() OVERRIDE;
virtual void trace(Visitor*) OVERRIDE;
private:
explicit PlatformSpeechSynthesizerMock(PlatformSpeechSynthesizerClient*);
virtual void initializeVoiceList() OVERRIDE;
......@@ -50,7 +52,7 @@ private:
Timer<PlatformSpeechSynthesizerMock> m_speakingFinishedTimer;
Timer<PlatformSpeechSynthesizerMock> m_speakingErrorOccurredTimer;
RefPtr<PlatformSpeechSynthesisUtterance> m_utterance;
Member<PlatformSpeechSynthesisUtterance> m_utterance;
};
} // namespace WebCore
......
......@@ -35,7 +35,7 @@ using namespace WebCore;
namespace blink {
WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance(const PassRefPtr<PlatformSpeechSynthesisUtterance>& utterance)
WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance(WebCore::PlatformSpeechSynthesisUtterance* utterance)
: m_private(utterance)
{
}
......@@ -56,11 +56,6 @@ void WebSpeechSynthesisUtterance::reset()
m_private.reset();
}
WebSpeechSynthesisUtterance::operator PassRefPtr<PlatformSpeechSynthesisUtterance>() const
{
return m_private.get();
}
WebSpeechSynthesisUtterance::operator PlatformSpeechSynthesisUtterance*() const
{
return m_private.get();
......
......@@ -72,7 +72,7 @@ void WebSpeechSynthesisVoice::setIsDefault(bool isDefault)
m_private->setIsDefault(isDefault);
}
WebSpeechSynthesisVoice::operator PassRefPtr<WebCore::PlatformSpeechSynthesisVoice>() const
WebSpeechSynthesisVoice::operator WebCore::PlatformSpeechSynthesisVoice*() const
{
return m_private.get();
}
......
......@@ -42,9 +42,9 @@ WebSpeechSynthesizerClientImpl::~WebSpeechSynthesizerClientImpl()
void WebSpeechSynthesizerClientImpl::setVoiceList(const blink::WebVector<blink::WebSpeechSynthesisVoice>& voices)
{
Vector<RefPtr<PlatformSpeechSynthesisVoice> > outVoices;
HeapVector<Member<PlatformSpeechSynthesisVoice> > outVoices;
for (size_t i = 0; i < voices.size(); i++)
outVoices.append(PassRefPtr<PlatformSpeechSynthesisVoice>(voices[i]));
outVoices.append(voices[i]);
m_synthesizer->setVoiceList(outVoices);
m_client->voicesDidChange();
}
......@@ -84,4 +84,10 @@ void WebSpeechSynthesizerClientImpl::sentenceBoundaryEventOccurred(const blink::
m_client->boundaryEventOccurred(utterance, SpeechSentenceBoundary, charIndex);
}
void WebSpeechSynthesizerClientImpl::trace(Visitor* visitor)
{
visitor->trace(m_synthesizer);
visitor->trace(m_client);
}
} // namespace WebCore
......@@ -26,21 +26,20 @@
#ifndef WebSpeechSynthesizerClientImpl_h
#define WebSpeechSynthesizerClientImpl_h
#include "platform/heap/Handle.h"
#include "platform/speech/PlatformSpeechSynthesizer.h"
#include "public/platform/WebSpeechSynthesisUtterance.h"
#include "public/platform/WebSpeechSynthesisVoice.h"
#include "public/platform/WebSpeechSynthesizerClient.h"
#include "wtf/HashMap.h"
#include "wtf/Vector.h"
namespace WebCore {
class PlatformSpeechSynthesizer;
class PlatformSpeechSynthesizerClient;
class WebSpeechSynthesizerClientImpl : public blink::WebSpeechSynthesizerClient {
class WebSpeechSynthesizerClientImpl FINAL : public GarbageCollectedFinalized<WebSpeechSynthesizerClientImpl>, public blink::WebSpeechSynthesizerClient {
public:
explicit WebSpeechSynthesizerClientImpl(PlatformSpeechSynthesizer*, PlatformSpeechSynthesizerClient*);
WebSpeechSynthesizerClientImpl(PlatformSpeechSynthesizer*, PlatformSpeechSynthesizerClient*);
virtual ~WebSpeechSynthesizerClientImpl();
virtual void setVoiceList(const blink::WebVector<blink::WebSpeechSynthesisVoice>& voices);
......@@ -52,9 +51,11 @@ public:
virtual void wordBoundaryEventOccurred(const blink::WebSpeechSynthesisUtterance&, unsigned charIndex);
virtual void sentenceBoundaryEventOccurred(const blink::WebSpeechSynthesisUtterance&, unsigned charIndex);
void trace(Visitor*);
private:
PlatformSpeechSynthesizer* m_synthesizer;
PlatformSpeechSynthesizerClient* m_client;
Member<PlatformSpeechSynthesizer> m_synthesizer;
Member<PlatformSpeechSynthesizerClient> m_client;
};
} // namespace WebCore
......
......@@ -28,9 +28,9 @@
namespace WebCore {
PassRefPtr<PlatformSpeechSynthesisUtterance> PlatformSpeechSynthesisUtterance::create(PlatformSpeechSynthesisUtteranceClient* client)
PlatformSpeechSynthesisUtterance* PlatformSpeechSynthesisUtterance::create(PlatformSpeechSynthesisUtteranceClient* client)
{
return adoptRef(new PlatformSpeechSynthesisUtterance(client));
return new PlatformSpeechSynthesisUtterance(client);
}
PlatformSpeechSynthesisUtterance::PlatformSpeechSynthesisUtterance(PlatformSpeechSynthesisUtteranceClient* client)
......@@ -41,4 +41,10 @@ PlatformSpeechSynthesisUtterance::PlatformSpeechSynthesisUtterance(PlatformSpeec
{
}
void PlatformSpeechSynthesisUtterance::trace(Visitor* visitor)
{
visitor->trace(m_client);
visitor->trace(m_voice);
}
} // namespace WebCore
......@@ -27,23 +27,22 @@
#define PlatformSpeechSynthesisUtterance_h
#include "platform/PlatformExport.h"
#include "platform/heap/Handle.h"
#include "platform/speech/PlatformSpeechSynthesisVoice.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class PlatformSpeechSynthesisUtteranceClient {
class PlatformSpeechSynthesisUtteranceClient : public GarbageCollectedMixin {
public:
// Implement methods as needed.
protected:
virtual ~PlatformSpeechSynthesisUtteranceClient() { }
};
class PLATFORM_EXPORT PlatformSpeechSynthesisUtterance : public RefCounted<PlatformSpeechSynthesisUtterance> {
class PLATFORM_EXPORT PlatformSpeechSynthesisUtterance FINAL : public GarbageCollectedFinalized<PlatformSpeechSynthesisUtterance> {
public:
static PassRefPtr<PlatformSpeechSynthesisUtterance> create(PlatformSpeechSynthesisUtteranceClient*);
static PlatformSpeechSynthesisUtterance* create(PlatformSpeechSynthesisUtteranceClient*);
const String& text() const { return m_text; }
void setText(const String& text) { m_text = text; }
......@@ -51,7 +50,7 @@ public:
const String& lang() const { return m_lang; }
void setLang(const String& lang) { m_lang = lang; }
PlatformSpeechSynthesisVoice* voice() const { return m_voice.get(); }
PlatformSpeechSynthesisVoice* voice() const { return m_voice; }
void setVoice(PlatformSpeechSynthesisVoice* voice) { m_voice = voice; }
// Range = [0, 1] where 1 is the default.
......@@ -70,15 +69,16 @@ public:
void setStartTime(double startTime) { m_startTime = startTime; }
PlatformSpeechSynthesisUtteranceClient* client() const { return m_client; }
void setClient(PlatformSpeechSynthesisUtteranceClient* client) { m_client = client; }
void trace(Visitor*);
private:
explicit PlatformSpeechSynthesisUtterance(PlatformSpeechSynthesisUtteranceClient*);
PlatformSpeechSynthesisUtteranceClient* m_client;
Member<PlatformSpeechSynthesisUtteranceClient> m_client;
String m_text;
String m_lang;
RefPtr<PlatformSpeechSynthesisVoice> m_voice;
Member<PlatformSpeechSynthesisVoice> m_voice;
float m_volume;
float m_rate;
float m_pitch;
......
......@@ -28,14 +28,14 @@
namespace WebCore {
PassRefPtr<PlatformSpeechSynthesisVoice> PlatformSpeechSynthesisVoice::create(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault)
PlatformSpeechSynthesisVoice* PlatformSpeechSynthesisVoice::create(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault)
{
return adoptRef(new PlatformSpeechSynthesisVoice(voiceURI, name, lang, localService, isDefault));
return new PlatformSpeechSynthesisVoice(voiceURI, name, lang, localService, isDefault);
}
PassRefPtr<PlatformSpeechSynthesisVoice> PlatformSpeechSynthesisVoice::create()
PlatformSpeechSynthesisVoice* PlatformSpeechSynthesisVoice::create()
{
return adoptRef(new PlatformSpeechSynthesisVoice());
return new PlatformSpeechSynthesisVoice();
}
PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault)
......
......@@ -27,16 +27,15 @@
#define PlatformSpeechSynthesisVoice_h
#include "platform/PlatformExport.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "platform/heap/Handle.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class PLATFORM_EXPORT PlatformSpeechSynthesisVoice : public RefCounted<PlatformSpeechSynthesisVoice> {
class PLATFORM_EXPORT PlatformSpeechSynthesisVoice FINAL : public GarbageCollectedFinalized<PlatformSpeechSynthesisVoice> {
public:
static PassRefPtr<PlatformSpeechSynthesisVoice> create(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault);
static PassRefPtr<PlatformSpeechSynthesisVoice> create();
static PlatformSpeechSynthesisVoice* create(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault);
static PlatformSpeechSynthesisVoice* create();
const String& voiceURI() const { return m_voiceURI; }
void setVoiceURI(const String& voiceURI) { m_voiceURI = voiceURI; }
......@@ -53,6 +52,8 @@ public:
bool isDefault() const { return m_default; }
void setIsDefault(bool isDefault) { m_default = isDefault; }
void trace(Visitor*) { }
private:
PlatformSpeechSynthesisVoice(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault);
PlatformSpeechSynthesisVoice();
......
......@@ -36,25 +36,25 @@
namespace WebCore {
PassOwnPtr<PlatformSpeechSynthesizer> PlatformSpeechSynthesizer::create(PlatformSpeechSynthesizerClient* client)
PlatformSpeechSynthesizer* PlatformSpeechSynthesizer::create(PlatformSpeechSynthesizerClient* client)
{
OwnPtr<PlatformSpeechSynthesizer> synthesizer = adoptPtr(new PlatformSpeechSynthesizer(client));
PlatformSpeechSynthesizer* synthesizer = new PlatformSpeechSynthesizer(client);
synthesizer->initializeVoiceList();
return synthesizer.release();
return synthesizer;
}
PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
: m_speechSynthesizerClient(client)
{
m_webSpeechSynthesizerClient = adoptPtr(new WebSpeechSynthesizerClientImpl(this, client));
m_webSpeechSynthesizer = adoptPtr(blink::Platform::current()->createSpeechSynthesizer(m_webSpeechSynthesizerClient.get()));
m_webSpeechSynthesizerClient = new WebSpeechSynthesizerClientImpl(this, client);
m_webSpeechSynthesizer = adoptPtr(blink::Platform::current()->createSpeechSynthesizer(m_webSpeechSynthesizerClient));
}
PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer()
{
}
void PlatformSpeechSynthesizer::speak(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
void PlatformSpeechSynthesizer::speak(PlatformSpeechSynthesisUtterance* utterance)
{
if (!m_webSpeechSynthesizer || !m_webSpeechSynthesizerClient)
return;
......@@ -80,7 +80,7 @@ void PlatformSpeechSynthesizer::cancel()
m_webSpeechSynthesizer->cancel();
}
void PlatformSpeechSynthesizer::setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voices)
void PlatformSpeechSynthesizer::setVoiceList(HeapVector<Member<PlatformSpeechSynthesisVoice> >& voices)
{
m_voiceList = voices;
}
......@@ -91,4 +91,11 @@ void PlatformSpeechSynthesizer::initializeVoiceList()
m_webSpeechSynthesizer->updateVoiceList();
}
void PlatformSpeechSynthesizer::trace(Visitor* visitor)
{
visitor->trace(m_speechSynthesizerClient);
visitor->trace(m_voiceList);
visitor->trace(m_webSpeechSynthesizerClient);
}
} // namespace WebCore
......@@ -27,8 +27,8 @@
#define PlatformSpeechSynthesizer_h
#include "platform/PlatformExport.h"
#include "platform/heap/Handle.h"
#include "platform/speech/PlatformSpeechSynthesisVoice.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
namespace blink {
......@@ -44,47 +44,54 @@ enum SpeechBoundary {
};
class PlatformSpeechSynthesisUtterance;
class WebSpeechSynthesizerClientImpl;
class PlatformSpeechSynthesizerClient {
class PlatformSpeechSynthesizerClient : public GarbageCollectedMixin {
public:
virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>, SpeechBoundary, unsigned charIndex) = 0;
virtual void didStartSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
virtual void didFinishSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
virtual void didPauseSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
virtual void didResumeSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
virtual void speakingErrorOccurred(PlatformSpeechSynthesisUtterance*) = 0;
virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance*, SpeechBoundary, unsigned charIndex) = 0;
virtual void voicesDidChange() = 0;
virtual void trace(Visitor*) { }
protected:
virtual ~PlatformSpeechSynthesizerClient() { }
};
class PLATFORM_EXPORT PlatformSpeechSynthesizer {
class PLATFORM_EXPORT PlatformSpeechSynthesizer : public GarbageCollectedFinalized<PlatformSpeechSynthesizer> {
WTF_MAKE_NONCOPYABLE(PlatformSpeechSynthesizer);
public:
static PassOwnPtr<PlatformSpeechSynthesizer> create(PlatformSpeechSynthesizerClient*);
static PlatformSpeechSynthesizer* create(PlatformSpeechSynthesizerClient*);
virtual ~PlatformSpeechSynthesizer();
const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
virtual void speak(PassRefPtr<PlatformSpeechSynthesisUtterance>);
const HeapVector<Member<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
virtual void speak(PlatformSpeechSynthesisUtterance*);
virtual void pause();
virtual void resume();
virtual void cancel();
PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
void setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >&);
void setVoiceList(HeapVector<Member<PlatformSpeechSynthesisVoice> >&);
virtual void trace(Visitor*);
protected:
virtual void initializeVoiceList();
explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
Vector<RefPtr<PlatformSpeechSynthesisVoice> > m_voiceList;
virtual void initializeVoiceList();
HeapVector<Member<PlatformSpeechSynthesisVoice> > m_voiceList;
private:
PlatformSpeechSynthesizerClient* m_speechSynthesizerClient;
Member<PlatformSpeechSynthesizerClient> m_speechSynthesizerClient;
OwnPtr<blink::WebSpeechSynthesizer> m_webSpeechSynthesizer;
OwnPtr<blink::WebSpeechSynthesizerClient> m_webSpeechSynthesizerClient;
Member<WebCore::WebSpeechSynthesizerClientImpl> m_webSpeechSynthesizerClient;
};
} // namespace WebCore
......
......@@ -62,9 +62,8 @@ public:
BLINK_PLATFORM_EXPORT double startTime() const; // In seconds.
#if INSIDE_BLINK
BLINK_PLATFORM_EXPORT WebSpeechSynthesisUtterance(const PassRefPtr<WebCore::PlatformSpeechSynthesisUtterance>&);
BLINK_PLATFORM_EXPORT WebSpeechSynthesisUtterance(WebCore::PlatformSpeechSynthesisUtterance*);
BLINK_PLATFORM_EXPORT WebSpeechSynthesisUtterance& operator=(WebCore::PlatformSpeechSynthesisUtterance*);
BLINK_PLATFORM_EXPORT operator PassRefPtr<WebCore::PlatformSpeechSynthesisUtterance>() const;
BLINK_PLATFORM_EXPORT operator WebCore::PlatformSpeechSynthesisUtterance*() const;
#endif
......
......@@ -58,7 +58,7 @@ public:
BLINK_PLATFORM_EXPORT void setIsDefault(bool);
#if INSIDE_BLINK
BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<WebCore::PlatformSpeechSynthesisVoice>() const;
BLINK_PLATFORM_EXPORT operator WebCore::PlatformSpeechSynthesisVoice*() const;
#endif
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment