<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[247970] branches/safari-608-branch/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/247970">247970</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2019-07-29 20:55:10 -0700 (Mon, 29 Jul 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/247755">r247755</a>. rdar://problem/53575423

    AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak
    https://bugs.webkit.org/show_bug.cgi?id=199988

    Reviewed by Per Arne Vollan.

    Source/WebCore:

    Implement the reset state to cancel current speech jobs.

    * Modules/speech/SpeechSynthesis.cpp:
    (WebCore::SpeechSynthesis::startSpeakingImmediately):
    (WebCore::SpeechSynthesis::cancel):
    * platform/PlatformSpeechSynthesizer.h:
    * platform/ios/PlatformSpeechSynthesizerIOS.mm:
    (WebCore::PlatformSpeechSynthesizer::resetState):
    * platform/mac/PlatformSpeechSynthesizerMac.mm:
    (WebCore::PlatformSpeechSynthesizer::resetState):

    Source/WebKit:

    Improvements to WebSpeechSynthesis to avoid crashing and improve correctness.
    - Reset and cancel speech jobs on page close or reload (otherwise the synthesizer keeps talking after your page is gone)
    - Have a separate speech finish callback mechanism, use the start speaking callback when the synthesizer tells us.
    - Move an assert on utterance state to only apply when we use the in process synthesizer.

    * UIProcess/Cocoa/WebPageProxyCocoa.mm:
    (WebKit::WebPageProxy::didStartSpeaking):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::reload):
    (WebKit::WebPageProxy::resetState):
    (WebKit::WebPageProxy::resetSpeechSynthesizer):
    (WebKit::WebPageProxy::speechSynthesisSetFinishedCallback):
    (WebKit::WebPageProxy::speechSynthesisSpeak):
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:
    (WebKit::WebSpeechSynthesisClient::speak):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247755 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari608branchSourceWebCoreChangeLog">branches/safari-608-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari608branchSourceWebCoreModulesspeechSpeechSynthesiscpp">branches/safari-608-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformPlatformSpeechSynthesizerh">branches/safari-608-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformiosPlatformSpeechSynthesizerIOSmm">branches/safari-608-branch/Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm</a></li>
<li><a href="#branchessafari608branchSourceWebCoreplatformmacPlatformSpeechSynthesizerMacmm">branches/safari-608-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm</a></li>
<li><a href="#branchessafari608branchSourceWebKitChangeLog">branches/safari-608-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari608branchSourceWebKitUIProcessCocoaWebPageProxyCocoamm">branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm</a></li>
<li><a href="#branchessafari608branchSourceWebKitUIProcessWebPageProxycpp">branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari608branchSourceWebKitUIProcessWebPageProxyh">branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#branchessafari608branchSourceWebKitUIProcessWebPageProxymessagesin">branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#branchessafari608branchSourceWebKitWebProcessWebCoreSupportWebSpeechSynthesisClientcpp">branches/safari-608-branch/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari608branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/ChangeLog      2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog 2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -1,5 +1,68 @@
</span><span class="cx"> 2019-07-29  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r247755. rdar://problem/53575423
+
+    AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak
+    https://bugs.webkit.org/show_bug.cgi?id=199988
+    
+    Reviewed by Per Arne Vollan.
+    
+    Source/WebCore:
+    
+    Implement the reset state to cancel current speech jobs.
+    
+    * Modules/speech/SpeechSynthesis.cpp:
+    (WebCore::SpeechSynthesis::startSpeakingImmediately):
+    (WebCore::SpeechSynthesis::cancel):
+    * platform/PlatformSpeechSynthesizer.h:
+    * platform/ios/PlatformSpeechSynthesizerIOS.mm:
+    (WebCore::PlatformSpeechSynthesizer::resetState):
+    * platform/mac/PlatformSpeechSynthesizerMac.mm:
+    (WebCore::PlatformSpeechSynthesizer::resetState):
+    
+    Source/WebKit:
+    
+    Improvements to WebSpeechSynthesis to avoid crashing and improve correctness.
+    - Reset and cancel speech jobs on page close or reload (otherwise the synthesizer keeps talking after your page is gone)
+    - Have a separate speech finish callback mechanism, use the start speaking callback when the synthesizer tells us.
+    - Move an assert on utterance state to only apply when we use the in process synthesizer.
+    
+    * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+    (WebKit::WebPageProxy::didStartSpeaking):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::reload):
+    (WebKit::WebPageProxy::resetState):
+    (WebKit::WebPageProxy::resetSpeechSynthesizer):
+    (WebKit::WebPageProxy::speechSynthesisSetFinishedCallback):
+    (WebKit::WebPageProxy::speechSynthesisSpeak):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:
+    (WebKit::WebSpeechSynthesisClient::speak):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247755 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-23  Chris Fleizach  <cfleizach@apple.com>
+
+            AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak
+            https://bugs.webkit.org/show_bug.cgi?id=199988
+
+            Reviewed by Per Arne Vollan.
+
+            Implement the reset state to cancel current speech jobs.
+
+            * Modules/speech/SpeechSynthesis.cpp:
+            (WebCore::SpeechSynthesis::startSpeakingImmediately):
+            (WebCore::SpeechSynthesis::cancel):
+            * platform/PlatformSpeechSynthesizer.h:
+            * platform/ios/PlatformSpeechSynthesizerIOS.mm:
+            (WebCore::PlatformSpeechSynthesizer::resetState):
+            * platform/mac/PlatformSpeechSynthesizerMac.mm:
+            (WebCore::PlatformSpeechSynthesizer::resetState):
+
+2019-07-29  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r247734. rdar://problem/53575394
</span><span class="cx"> 
</span><span class="cx">     Fix crashes in ScrollingStateNode::insertChild()
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreModulesspeechSpeechSynthesiscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp     2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebCore/Modules/speech/SpeechSynthesis.cpp        2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -110,7 +110,6 @@
</span><span class="cx"> 
</span><span class="cx"> void SpeechSynthesis::startSpeakingImmediately(SpeechSynthesisUtterance& utterance)
</span><span class="cx"> {
</span><del>-    ASSERT(!m_currentSpeechUtterance);
</del><span class="cx">     utterance.setStartTime(MonotonicTime::now());
</span><span class="cx">     m_currentSpeechUtterance = &utterance;
</span><span class="cx">     m_isPaused = false;
</span><span class="lines">@@ -152,12 +151,12 @@
</span><span class="cx">     m_utteranceQueue.clear();
</span><span class="cx">     if (m_speechSynthesisClient)
</span><span class="cx">         m_speechSynthesisClient->cancel();
</span><del>-    else if (m_platformSpeechSynthesizer)
</del><ins>+    else if (m_platformSpeechSynthesizer) {
</ins><span class="cx">         m_platformSpeechSynthesizer->cancel();
</span><ins>+        // The platform should have called back immediately and cleared the current utterance.
+        ASSERT(!m_currentSpeechUtterance);
+    }
</ins><span class="cx">     current = nullptr;
</span><del>-
-    // The platform should have called back immediately and cleared the current utterance.
-    ASSERT(!m_currentSpeechUtterance);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SpeechSynthesis::pause()
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformPlatformSpeechSynthesizerh"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h   2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebCore/platform/PlatformSpeechSynthesizer.h      2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">     virtual void resume();
</span><span class="cx">     virtual void cancel();
</span><span class="cx"> 
</span><ins>+    void resetState();
</ins><span class="cx">     PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformiosPlatformSpeechSynthesizerIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm   2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm      2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -291,6 +291,11 @@
</span><span class="cx">     [m_platformSpeechWrapper.get() cancel];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PlatformSpeechSynthesizer::resetState()
+{
+    [m_platformSpeechWrapper.get() cancel];
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SPEECH_SYNTHESIS) && PLATFORM(IOS_FAMILY)
</span></span></pre></div>
<a id="branchessafari608branchSourceWebCoreplatformmacPlatformSpeechSynthesizerMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm   2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm      2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -277,6 +277,11 @@
</span><span class="cx">     [m_platformSpeechWrapper.get() cancel];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PlatformSpeechSynthesizer::resetState()
+{
+    [m_platformSpeechWrapper.get() cancel];
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SPEECH_SYNTHESIS) && PLATFORM(MAC)
</span></span></pre></div>
<a id="branchessafari608branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebKit/ChangeLog       2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog  2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -1,5 +1,75 @@
</span><span class="cx"> 2019-07-29  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r247755. rdar://problem/53575423
+
+    AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak
+    https://bugs.webkit.org/show_bug.cgi?id=199988
+    
+    Reviewed by Per Arne Vollan.
+    
+    Source/WebCore:
+    
+    Implement the reset state to cancel current speech jobs.
+    
+    * Modules/speech/SpeechSynthesis.cpp:
+    (WebCore::SpeechSynthesis::startSpeakingImmediately):
+    (WebCore::SpeechSynthesis::cancel):
+    * platform/PlatformSpeechSynthesizer.h:
+    * platform/ios/PlatformSpeechSynthesizerIOS.mm:
+    (WebCore::PlatformSpeechSynthesizer::resetState):
+    * platform/mac/PlatformSpeechSynthesizerMac.mm:
+    (WebCore::PlatformSpeechSynthesizer::resetState):
+    
+    Source/WebKit:
+    
+    Improvements to WebSpeechSynthesis to avoid crashing and improve correctness.
+    - Reset and cancel speech jobs on page close or reload (otherwise the synthesizer keeps talking after your page is gone)
+    - Have a separate speech finish callback mechanism, use the start speaking callback when the synthesizer tells us.
+    - Move an assert on utterance state to only apply when we use the in process synthesizer.
+    
+    * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+    (WebKit::WebPageProxy::didStartSpeaking):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::reload):
+    (WebKit::WebPageProxy::resetState):
+    (WebKit::WebPageProxy::resetSpeechSynthesizer):
+    (WebKit::WebPageProxy::speechSynthesisSetFinishedCallback):
+    (WebKit::WebPageProxy::speechSynthesisSpeak):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:
+    (WebKit::WebSpeechSynthesisClient::speak):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247755 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-23  Chris Fleizach  <cfleizach@apple.com>
+
+            AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak
+            https://bugs.webkit.org/show_bug.cgi?id=199988
+
+            Reviewed by Per Arne Vollan.
+
+            Improvements to WebSpeechSynthesis to avoid crashing and improve correctness.
+            - Reset and cancel speech jobs on page close or reload (otherwise the synthesizer keeps talking after your page is gone)
+            - Have a separate speech finish callback mechanism, use the start speaking callback when the synthesizer tells us.
+            - Move an assert on utterance state to only apply when we use the in process synthesizer.
+
+            * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+            (WebKit::WebPageProxy::didStartSpeaking):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::reload):
+            (WebKit::WebPageProxy::resetState):
+            (WebKit::WebPageProxy::resetSpeechSynthesizer):
+            (WebKit::WebPageProxy::speechSynthesisSetFinishedCallback):
+            (WebKit::WebPageProxy::speechSynthesisSpeak):
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:
+            (WebKit::WebSpeechSynthesisClient::speak):
+
+2019-07-29  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r247722. rdar://problem/53647293
</span><span class="cx"> 
</span><span class="cx">     [macOS 10.15] Web process crashes when attempting to show the font panel via Font > Show Fonts
</span></span></pre></div>
<a id="branchessafari608branchSourceWebKitUIProcessCocoaWebPageProxyCocoamm"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm    2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm       2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -258,21 +258,26 @@
</span><span class="cx"> #if ENABLE(SPEECH_SYNTHESIS)
</span><span class="cx"> void WebPageProxy::didStartSpeaking(WebCore::PlatformSpeechSynthesisUtterance&)
</span><span class="cx"> {
</span><ins>+    if (speechSynthesisData().speakingStartedCompletionHandler)
+        speechSynthesisData().speakingStartedCompletionHandler();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::didFinishSpeaking(WebCore::PlatformSpeechSynthesisUtterance&)
</span><span class="cx"> {
</span><del>-    m_speechSynthesisData->speakingFinishedCompletionHandler();
</del><ins>+    if (speechSynthesisData().speakingFinishedCompletionHandler)
+        speechSynthesisData().speakingFinishedCompletionHandler();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::didPauseSpeaking(WebCore::PlatformSpeechSynthesisUtterance&)
</span><span class="cx"> {
</span><del>-    m_speechSynthesisData->speakingPausedCompletionHandler();
</del><ins>+    if (speechSynthesisData().speakingPausedCompletionHandler)
+        speechSynthesisData().speakingPausedCompletionHandler();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::didResumeSpeaking(WebCore::PlatformSpeechSynthesisUtterance&)
</span><span class="cx"> {
</span><del>-    m_speechSynthesisData->speakingResumedCompletionHandler();
</del><ins>+    if (speechSynthesisData().speakingResumedCompletionHandler)
+        speechSynthesisData().speakingResumedCompletionHandler();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::speakingErrorOccurred(WebCore::PlatformSpeechSynthesisUtterance&)
</span></span></pre></div>
<a id="branchessafari608branchSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -1359,6 +1359,10 @@
</span><span class="cx">     m_process->send(Messages::WebPage::Reload(navigation->navigationID(), options.toRaw(), sandboxExtensionHandle), m_pageID);
</span><span class="cx">     m_process->responsivenessTimer().start();
</span><span class="cx"> 
</span><ins>+#if ENABLE(SPEECH_SYNTHESIS)
+    resetSpeechSynthesizer();
+#endif
+
</ins><span class="cx">     return navigation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -7053,6 +7057,10 @@
</span><span class="cx"> #if ENABLE(POINTER_LOCK)
</span><span class="cx">     requestPointerUnlock();
</span><span class="cx"> #endif
</span><ins>+    
+#if ENABLE(SPEECH_SYNTHESIS)
+    resetSpeechSynthesizer();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::resetStateAfterProcessExited(ProcessTerminationReason terminationReason)
</span><span class="lines">@@ -9126,10 +9134,25 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SPEECH_SYNTHESIS)
</span><ins>+
+void WebPageProxy::resetSpeechSynthesizer()
+{
+    if (!m_speechSynthesisData)
+        return;
+    
+    auto& synthesisData = speechSynthesisData();
+    synthesisData.speakingFinishedCompletionHandler = nullptr;
+    synthesisData.speakingStartedCompletionHandler = nullptr;
+    synthesisData.speakingPausedCompletionHandler = nullptr;
+    synthesisData.speakingResumedCompletionHandler = nullptr;
+    if (synthesisData.synthesizer)
+        synthesisData.synthesizer->resetState();
+}
+
</ins><span class="cx"> WebPageProxy::SpeechSynthesisData& WebPageProxy::speechSynthesisData()
</span><span class="cx"> {
</span><span class="cx">     if (!m_speechSynthesisData)
</span><del>-        m_speechSynthesisData = SpeechSynthesisData { std::make_unique<PlatformSpeechSynthesizer>(this), nullptr, nullptr, nullptr, nullptr };
</del><ins>+        m_speechSynthesisData = SpeechSynthesisData { std::make_unique<PlatformSpeechSynthesizer>(this), nullptr, nullptr, nullptr, nullptr, nullptr };
</ins><span class="cx">     return *m_speechSynthesisData;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -9143,6 +9166,11 @@
</span><span class="cx">     completionHandler(WTFMove(result));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::speechSynthesisSetFinishedCallback(CompletionHandler<void()>&& completionHandler)
+{
+    speechSynthesisData().speakingFinishedCompletionHandler = WTFMove(completionHandler);
+}
+
</ins><span class="cx"> void WebPageProxy::speechSynthesisSpeak(const String& text, const String& lang, float volume, float rate, float pitch, MonotonicTime startTime, const String& voiceURI, const String& voiceName, const String& voiceLang, bool localService, bool defaultVoice, CompletionHandler<void()>&& completionHandler)
</span><span class="cx"> {
</span><span class="cx">     auto voice = WebCore::PlatformSpeechSynthesisVoice::create(voiceURI, voiceName, voiceLang, localService, defaultVoice);
</span><span class="lines">@@ -9154,8 +9182,8 @@
</span><span class="cx">     utterance->setPitch(pitch);
</span><span class="cx">     utterance->setVoice(&voice.get());
</span><span class="cx"> 
</span><ins>+    speechSynthesisData().speakingStartedCompletionHandler = WTFMove(completionHandler);
</ins><span class="cx">     speechSynthesisData().utterance = WTFMove(utterance);
</span><del>-    speechSynthesisData().speakingFinishedCompletionHandler = WTFMove(completionHandler);
</del><span class="cx">     speechSynthesisData().synthesizer->speak(m_speechSynthesisData->utterance.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari608branchSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h        2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.h   2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -1533,6 +1533,7 @@
</span><span class="cx"> #if ENABLE(SPEECH_SYNTHESIS)
</span><span class="cx">     void speechSynthesisVoiceList(CompletionHandler<void(Vector<WebSpeechSynthesisVoice>&&)>&&);
</span><span class="cx">     void speechSynthesisSpeak(const String&, const String&, float volume, float rate, float pitch, MonotonicTime startTime, const String& voiceURI, const String& voiceName, const String& voiceLang, bool localService, bool defaultVoice, CompletionHandler<void()>&&);
</span><ins>+    void speechSynthesisSetFinishedCallback(CompletionHandler<void()>&&);
</ins><span class="cx">     void speechSynthesisCancel();
</span><span class="cx">     void speechSynthesisPause(CompletionHandler<void()>&&);
</span><span class="cx">     void speechSynthesisResume(CompletionHandler<void()>&&);
</span><span class="lines">@@ -2096,6 +2097,7 @@
</span><span class="cx"> 
</span><span class="cx">     struct SpeechSynthesisData;
</span><span class="cx">     SpeechSynthesisData& speechSynthesisData();
</span><ins>+    void resetSpeechSynthesizer();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="lines">@@ -2533,6 +2535,7 @@
</span><span class="cx">     struct SpeechSynthesisData {
</span><span class="cx">         std::unique_ptr<WebCore::PlatformSpeechSynthesizer> synthesizer;
</span><span class="cx">         RefPtr<WebCore::PlatformSpeechSynthesisUtterance> utterance;
</span><ins>+        CompletionHandler<void()> speakingStartedCompletionHandler;
</ins><span class="cx">         CompletionHandler<void()> speakingFinishedCompletionHandler;
</span><span class="cx">         CompletionHandler<void()> speakingPausedCompletionHandler;
</span><span class="cx">         CompletionHandler<void()> speakingResumedCompletionHandler;
</span></span></pre></div>
<a id="branchessafari608branchSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in      2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in 2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -558,6 +558,7 @@
</span><span class="cx"> #if ENABLE(SPEECH_SYNTHESIS)
</span><span class="cx">     SpeechSynthesisVoiceList() -> (Vector<WebKit::WebSpeechSynthesisVoice> voiceList) Synchronous
</span><span class="cx">     SpeechSynthesisSpeak(String text, String lang, float volume, float rate, float pitch, MonotonicTime startTime, String voiceURI, String voiceName, String voiceLang, bool localService, bool defaultVoice) -> () Async
</span><ins>+    SpeechSynthesisSetFinishedCallback() -> () Async
</ins><span class="cx">     SpeechSynthesisCancel()
</span><span class="cx">     SpeechSynthesisPause() -> () Async
</span><span class="cx">     SpeechSynthesisResume() -> () Async
</span></span></pre></div>
<a id="branchessafari608branchSourceWebKitWebProcessWebCoreSupportWebSpeechSynthesisClientcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp (247969 => 247970)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608-branch/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp  2019-07-30 03:55:05 UTC (rev 247969)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp     2019-07-30 03:55:10 UTC (rev 247970)
</span><span class="lines">@@ -57,10 +57,17 @@
</span><span class="cx"> 
</span><span class="cx"> void WebSpeechSynthesisClient::speak(RefPtr<WebCore::PlatformSpeechSynthesisUtterance> utterance)
</span><span class="cx"> {
</span><del>-    WTF::CompletionHandler<void()> completionHandler = [this, weakThis = makeWeakPtr(*this)]() mutable {
</del><ins>+    WTF::CompletionHandler<void()> startedCompletionHandler = [this, weakThis = makeWeakPtr(*this)]() mutable {
</ins><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="cx">         if (auto observer = corePageObserver())
</span><ins>+            observer->didStartSpeaking();
+    };
+
+    WTF::CompletionHandler<void()> finishedCompletionHandler = [this, weakThis = makeWeakPtr(*this)]() mutable {
+        if (!weakThis)
+            return;
+        if (auto observer = corePageObserver())
</ins><span class="cx">             observer->didFinishSpeaking();
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -70,10 +77,9 @@
</span><span class="cx">     auto lang = voice ? voice->lang() : "";
</span><span class="cx">     auto localService = voice ? voice->localService() : false;
</span><span class="cx">     auto isDefault = voice ? voice->isDefault() : false;
</span><del>-
-    m_page.sendWithAsyncReply(Messages::WebPageProxy::SpeechSynthesisSpeak(utterance->text(), utterance->lang(), utterance->volume(), utterance->rate(), utterance->pitch(), utterance->startTime(), voiceURI, name, lang, localService, isDefault), WTFMove(completionHandler));
-    if (auto observer = corePageObserver())
-        observer->didStartSpeaking();
</del><ins>+    
+    m_page.sendWithAsyncReply(Messages::WebPageProxy::SpeechSynthesisSetFinishedCallback(), WTFMove(finishedCompletionHandler));
+    m_page.sendWithAsyncReply(Messages::WebPageProxy::SpeechSynthesisSpeak(utterance->text(), utterance->lang(), utterance->volume(), utterance->rate(), utterance->pitch(), utterance->startTime(), voiceURI, name, lang, localService, isDefault), WTFMove(startedCompletionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebSpeechSynthesisClient::cancel()
</span></span></pre>
</div>
</div>

</body>
</html>