[macOS] Broker access to Speech Synthesis
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2019 18:18:36 +0000 (18:18 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Mar 2019 18:18:36 +0000 (18:18 +0000)
commit600fb60d9f9ea615b9ceef3fbf4814fd4bbe2068
treef8e838580e6b5105068bd1df466e51b84bdf7be4
parentdb5d5f50bf34e1f0d9b07abaeb7de5b7806bce4b
[macOS] Broker access to Speech Synthesis
https://bugs.webkit.org/show_bug.cgi?id=195645
<rdar://problem/35369026>

Reviewed by Brent Fulgham.

To be able to close the connection to the speech synthesis daemon in the WebContent process,
speech synthesis should be performed in the UI process. This patch forwards speech synthesis
requests to the UI process by sending messages. On the UI process side, the speech synthesis
is performed by simply using the existing platform speech synthesizer. Speech synthesis
events are sent back to the WebContent process. All messages are async, except for the
message to get the list of available voices.

Source/WebCore:

No new tests, covered by existing tests.

* Modules/speech/DOMWindowSpeechSynthesis.cpp:
(WebCore::DOMWindowSpeechSynthesis::speechSynthesis):
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::create):
(WebCore::SpeechSynthesis::SpeechSynthesis):
(WebCore::SpeechSynthesis::setPlatformSynthesizer):
(WebCore::SpeechSynthesis::getVoices):
(WebCore::SpeechSynthesis::startSpeakingImmediately):
(WebCore::SpeechSynthesis::cancel):
(WebCore::SpeechSynthesis::pause):
(WebCore::SpeechSynthesis::resume):
(WebCore::SpeechSynthesis::boundaryEventOccurred):
(WebCore::SpeechSynthesis::didStartSpeaking):
(WebCore::SpeechSynthesis::didFinishSpeaking):
(WebCore::SpeechSynthesis::didPauseSpeaking):
(WebCore::SpeechSynthesis::didResumeSpeaking):
(WebCore::SpeechSynthesis::speakingErrorOccurred):
(WebCore::SpeechSynthesis::voicesChanged):
* Modules/speech/SpeechSynthesis.h:
* WebCore.xcodeproj/project.pbxproj:
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore::Page::speechSynthesisClient const):
* page/PageConfiguration.cpp:
* page/PageConfiguration.h:
* page/SpeechSynthesisClient.h: Added.
* platform/PlatformSpeechSynthesisUtterance.h:
* platform/PlatformSpeechSynthesizer.h:
* platform/ios/PlatformSpeechSynthesizerIOS.mm:
(-[WebSpeechSynthesisWrapper speechSynthesizer:willSpeakRangeOfSpeechString:utterance:]):
* platform/mac/PlatformSpeechSynthesizerMac.mm:
(-[WebSpeechSynthesisWrapper speechSynthesizer:willSpeakWord:ofString:]):
* platform/mock/PlatformSpeechSynthesizerMock.cpp:
(WebCore::PlatformSpeechSynthesizerMock::speak):

Source/WebKit:

* Sources.txt:
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::didStartSpeaking):
(WebKit::WebPageProxy::didFinishSpeaking):
(WebKit::WebPageProxy::didPauseSpeaking):
(WebKit::WebPageProxy::didResumeSpeaking):
(WebKit::WebPageProxy::speakingErrorOccurred):
(WebKit::WebPageProxy::boundaryEventOccurred):
(WebKit::WebPageProxy::voicesDidChange):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::ensureSpeechSynthesisData):
(WebKit::WebPageProxy::speechSynthesisVoiceList):
(WebKit::WebPageProxy::speechSynthesisSpeak):
(WebKit::WebPageProxy::speechSynthesisCancel):
(WebKit::WebPageProxy::speechSynthesisPause):
(WebKit::WebPageProxy::speechSynthesisResume):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp: Added.
(WebKit::WebSpeechSynthesisClient::voiceList):
(WebKit::WebSpeechSynthesisClient::speak):
(WebKit::WebSpeechSynthesisClient::cancel):
(WebKit::WebSpeechSynthesisClient::pause):
(WebKit::WebSpeechSynthesisClient::resume):
* WebProcess/WebCoreSupport/WebSpeechSynthesisClient.h: Added.
(WebKit::WebSpeechSynthesisClient::WebSpeechSynthesisClient):
(WebKit::WebSpeechSynthesisClient::~WebSpeechSynthesisClient):
* WebProcess/WebCoreSupport/WebSpeechSynthesisVoice.h: Added.
(WebKit::WebSpeechSynthesisVoice::encode const):
(WebKit::WebSpeechSynthesisVoice::decode):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_hostFileDescriptor):
(WebKit::WebPage::speakingErrorOccurred):
(WebKit::WebPage::boundaryEventOccurred):
(WebKit::WebPage::voicesDidChange):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/com.apple.WebProcess.sb.in:
* WebProcess/glib/WebProcessGLib.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243002 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp
Source/WebCore/Modules/speech/SpeechSynthesis.cpp
Source/WebCore/Modules/speech/SpeechSynthesis.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/page/SpeechSynthesisClient.h [new file with mode: 0644]
Source/WebCore/platform/PlatformSpeechSynthesisUtterance.h
Source/WebCore/platform/PlatformSpeechSynthesizer.h
Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm
Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm
Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp
Source/WebKit/ChangeLog
Source/WebKit/Sources.txt
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.h [new file with mode: 0644]
Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisVoice.h [new file with mode: 0644]
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/com.apple.WebProcess.sb.in
Source/WebKit/WebProcess/glib/WebProcessGLib.cpp