Title: [151086] branches/safari-537.43-branch/Source/WebCore

Diff

Modified: branches/safari-537.43-branch/Source/WebCore/ChangeLog (151085 => 151086)


--- branches/safari-537.43-branch/Source/WebCore/ChangeLog	2013-06-02 21:32:20 UTC (rev 151085)
+++ branches/safari-537.43-branch/Source/WebCore/ChangeLog	2013-06-02 23:33:25 UTC (rev 151086)
@@ -1,57 +1,7 @@
-2013-06-02  Babak Shafiei  <[email protected]>
+2013-06-02  Steve Falkenburg  <[email protected]>
 
-        Merge r151076
+    Rollout r151084
 
-    2013-06-01  Darin Adler  <[email protected]>
-
-            window.speechSynthesis needs to be cheap
-            https://bugs.webkit.org/show_bug.cgi?id=117111
-            rdar://problem/14042030
-
-            Reviewed by Dean Jackson.
-
-            Add the traditional laziness to all of the speech synthesis code, wherever
-            it was omitted.
-
-            * Modules/speech/SpeechSynthesis.cpp:
-            (WebCore::SpeechSynthesis::create): Tweaked style (took out unneeded parentheses).
-            (WebCore::SpeechSynthesis::SpeechSynthesis): Don't create m_platformSpeechSynthesizer.
-            (WebCore::SpeechSynthesis::setPlatformSynthesizer): Clear state when changing the
-            platform speech synthesizer. Since this code is only used to set up a mock in the
-            test runner, the fact that it was wrong before was harmless, but still not good.
-            (WebCore::SpeechSynthesis::getVoices): Create the platform speech synthesizer here
-            so we can get the voice list from it.
-            (WebCore::SpeechSynthesis::startSpeakingImmediately): Create the platform speech
-            synthesizer here.
-            (WebCore::SpeechSynthesis::cancel): Check the platform speech synthesizer for
-            null and do nothing if it's not present.
-            (WebCore::SpeechSynthesis::pause): Ditto.
-            (WebCore::SpeechSynthesis::resume): Ditto.
-
-            * platform/PlatformSpeechSynthesizer.cpp:
-            (WebCore::PlatformSpeechSynthesizer::create): Don't call initializeVoiceList just
-            to create a synthesizer.
-            (WebCore::PlatformSpeechSynthesizer::voiceList): Do call initializeVoiceList once
-            when asked for a voice list.
-
-            * platform/PlatformSpeechSynthesizer.h: The voiceList function is no longer inlined.
-            The unused setVoiceList function has been removed. The initializeVoiceList is now
-            private rather than protected. Added a new m_voiceListIsInitialized boolean.
-
-            * platform/mac/PlatformSpeechSynthesizerMac.mm:
-            (WebCore::PlatformSpeechSynthesizer::PlatformSpeechSynthesizer): Initialize
-            m_voiceListIsInitialized to false.
-
-            * platform/mock/PlatformSpeechSynthesizerMock.cpp:
-            (WebCore::PlatformSpeechSynthesizerMock::create): Don't call initializeVoiceList just
-            to create a synthesizer.
-            (WebCore::PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock):
-            Removed unneeded call to m_speakingFinishedTimer.stop() since timers automatically
-            stop when you destroy them.
-            (WebCore::PlatformSpeechSynthesizerMock::initializeVoiceList): Removed unneeded
-            call to m_voiceList.clear(), since the caller only calls this once when the
-            voice list is already clear.
-
 2013-05-31  Lucas Forschler  <[email protected]>
 
         Merge r151040

Modified: branches/safari-537.43-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (151085 => 151086)


--- branches/safari-537.43-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-06-02 21:32:20 UTC (rev 151085)
+++ branches/safari-537.43-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-06-02 23:33:25 UTC (rev 151086)
@@ -38,11 +38,12 @@
     
 PassRefPtr<SpeechSynthesis> SpeechSynthesis::create()
 {
-    return adoptRef(new SpeechSynthesis);
+    return adoptRef(new SpeechSynthesis());
 }
     
 SpeechSynthesis::SpeechSynthesis()
-    : m_currentSpeechUtterance(0)
+    : m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this))
+    , m_currentSpeechUtterance(0)
     , m_isPaused(false)
 {
 }
@@ -50,10 +51,6 @@
 void SpeechSynthesis::setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer> synthesizer)
 {
     m_platformSpeechSynthesizer = synthesizer;
-    m_voiceList.clear();
-    m_currentSpeechUtterance = 0;
-    m_utteranceQueue.clear();
-    m_isPaused = false;
 }
     
 void SpeechSynthesis::voicesDidChange()
@@ -65,10 +62,7 @@
 {
     if (m_voiceList.size())
         return m_voiceList;
-
-    if (!m_platformSpeechSynthesizer)
-        m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(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();
@@ -103,8 +97,6 @@
     utterance->setStartTime(monotonicallyIncreasingTime());
     m_currentSpeechUtterance = utterance;
     m_isPaused = false;
-    if (!m_platformSpeechSynthesizer)
-        m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(this);
     m_platformSpeechSynthesizer->speak(utterance->platformUtterance());
 }
 
@@ -126,8 +118,7 @@
     // Hold on to the current utterance so the platform synthesizer can have a chance to clean up.
     RefPtr<SpeechSynthesisUtterance> current = m_currentSpeechUtterance;
     m_utteranceQueue.clear();
-    if (m_platformSpeechSynthesizer)
-        m_platformSpeechSynthesizer->cancel();
+    m_platformSpeechSynthesizer->cancel();
     current = 0;
     
     // The platform should have called back immediately and cleared the current utterance.
@@ -136,14 +127,15 @@
 
 void SpeechSynthesis::pause()
 {
-    if (!m_isPaused && m_platformSpeechSynthesizer)
+    if (!m_isPaused)
         m_platformSpeechSynthesizer->pause();
 }
 
 void SpeechSynthesis::resume()
 {
-    if (m_currentSpeechUtterance && m_platformSpeechSynthesizer)
-        m_platformSpeechSynthesizer->resume();
+    if (!m_currentSpeechUtterance)
+        return;
+    m_platformSpeechSynthesizer->resume();
 }
 
 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtterance* utterance, unsigned long charIndex, const String& name)

Modified: branches/safari-537.43-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.cpp (151085 => 151086)


--- branches/safari-537.43-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.cpp	2013-06-02 21:32:20 UTC (rev 151085)
+++ branches/safari-537.43-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.cpp	2013-06-02 23:33:25 UTC (rev 151086)
@@ -32,19 +32,17 @@
     
 PassOwnPtr<PlatformSpeechSynthesizer> PlatformSpeechSynthesizer::create(PlatformSpeechSynthesizerClient* client)
 {
-    return adoptPtr(new PlatformSpeechSynthesizer(client));
+    OwnPtr<PlatformSpeechSynthesizer> synthesizer = adoptPtr(new PlatformSpeechSynthesizer(client));
+    synthesizer->initializeVoiceList();
+    return synthesizer.release();
 }
 
-const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& PlatformSpeechSynthesizer::voiceList() const
+void PlatformSpeechSynthesizer::setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voices)
 {
-    if (!m_voiceListIsInitialized) {
-        ASSERT(m_voiceList.isEmpty());
-        const_cast<PlatformSpeechSynthesizer*>(this)->initializeVoiceList();
-        const_cast<PlatformSpeechSynthesizer*>(this)->m_voiceListIsInitialized = true;
-    }
-    return m_voiceList;
+    m_voiceList = voices;
 }
 
+
 } // namespace WebCore
 
 #endif // ENABLE(SPEECH_SYNTHESIS)

Modified: branches/safari-537.43-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h (151085 => 151086)


--- branches/safari-537.43-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h	2013-06-02 21:32:20 UTC (rev 151085)
+++ branches/safari-537.43-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h	2013-06-02 23:33:25 UTC (rev 151086)
@@ -58,16 +58,14 @@
 protected:
     virtual ~PlatformSpeechSynthesizerClient() { }
 };
-
+    
 class PlatformSpeechSynthesizer {
 public:
     static PassOwnPtr<PlatformSpeechSynthesizer> create(PlatformSpeechSynthesizerClient*);
 
-    // FIXME: We have multiple virtual functions just so we can support a mock for testing.
-    // Seems wasteful. Would be nice to find a better way.
     virtual ~PlatformSpeechSynthesizer();
     
-    const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const;
+    const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
     virtual void speak(PassRefPtr<PlatformSpeechSynthesisUtterance>);
     virtual void pause();
     virtual void resume();
@@ -75,15 +73,14 @@
     
     PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
 
+    void setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >&);
+
 protected:
+    virtual void initializeVoiceList();
     explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
-
     Vector<RefPtr<PlatformSpeechSynthesisVoice> > m_voiceList;
-
+    
 private:
-    virtual void initializeVoiceList();
-
-    bool m_voiceListIsInitialized;
     PlatformSpeechSynthesizerClient* m_speechSynthesizerClient;
     
 #if PLATFORM(MAC)

Modified: branches/safari-537.43-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm (151085 => 151086)


--- branches/safari-537.43-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm	2013-06-02 21:32:20 UTC (rev 151085)
+++ branches/safari-537.43-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm	2013-06-02 23:33:25 UTC (rev 151086)
@@ -201,8 +201,7 @@
 namespace WebCore {
 
 PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
-    : m_voiceListIsInitialized(false)
-    , m_speechSynthesizerClient(client)
+    : m_speechSynthesizerClient(client)
 {
 }
 

Modified: branches/safari-537.43-branch/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp (151085 => 151086)


--- branches/safari-537.43-branch/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp	2013-06-02 21:32:20 UTC (rev 151085)
+++ branches/safari-537.43-branch/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp	2013-06-02 23:33:25 UTC (rev 151086)
@@ -33,7 +33,9 @@
 
 PassOwnPtr<PlatformSpeechSynthesizerMock> PlatformSpeechSynthesizerMock::create(PlatformSpeechSynthesizerClient* client)
 {
-    return adoptPtr(new PlatformSpeechSynthesizerMock(client));
+    OwnPtr<PlatformSpeechSynthesizerMock> synthesizer = adoptPtr(new PlatformSpeechSynthesizerMock(client));
+    synthesizer->initializeVoiceList();
+    return synthesizer.release();
 }
     
 PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(PlatformSpeechSynthesizerClient* client)
@@ -44,6 +46,7 @@
     
 PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock()
 {
+    m_speakingFinishedTimer.stop();
 }
 
 void PlatformSpeechSynthesizerMock::speakingFinished(Timer<PlatformSpeechSynthesizerMock>*)
@@ -55,6 +58,7 @@
     
 void PlatformSpeechSynthesizerMock::initializeVoiceList()
 {
+    m_voiceList.clear();
     m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.bruce"), String("bruce"), String("en-US"), true, true));
     m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.clark"), String("clark"), String("en-US"), true, false));
     m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.logan"), String("logan"), String("fr-CA"), true, true));
@@ -94,6 +98,7 @@
     client()->didResumeSpeaking(m_utterance);
 }
 
+    
 } // namespace WebCore
 
 #endif // ENABLE(SPEECH_SYNTHESIS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to