Skip to content

Commit 5dfcdf2

Browse files
Merge pull request WebPlatformForEmbedded#3 from LibertyGlobal/jmanko/lgi-master
Jmanko/lgi master
2 parents 63e3cbd + c2e91d1 commit 5dfcdf2

42 files changed

Lines changed: 47 additions & 1260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/WebCore/CMakeLists.txt‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ set(WebCore_INCLUDE_DIRECTORIES
115115
"${WEBCORE_DIR}/platform/graphics/transforms"
116116
"${WEBCORE_DIR}/platform/mediastream"
117117
"${WEBCORE_DIR}/platform/mediastream/libwebrtc"
118-
"${WEBCORE_DIR}/platform/ttsclient"
119118
"${WEBCORE_DIR}/platform/mock"
120119
"${WEBCORE_DIR}/platform/mock/mediasource"
121120
"${WEBCORE_DIR}/platform/network"
@@ -380,7 +379,6 @@ set(WebCore_NON_SVG_IDL_FILES
380379
Modules/speech/DOMWindowSpeechSynthesis.idl
381380
Modules/speech/SpeechSynthesis.idl
382381
Modules/speech/SpeechSynthesisEvent.idl
383-
Modules/speech/SpeechSynthesisErrorEvent.idl
384382
Modules/speech/SpeechSynthesisUtterance.idl
385383
Modules/speech/SpeechSynthesisVoice.idl
386384

@@ -1123,8 +1121,6 @@ set(WebCore_LIBRARIES
11231121
${SQLITE_LIBRARIES}
11241122
${ZLIB_LIBRARIES}
11251123
PAL${DEBUG_SUFFIX}
1126-
rdkat
1127-
TTSClient
11281124
)
11291125

11301126
if (ENABLE_LEGACY_ENCRYPTED_MEDIA)

‎Source/WebCore/Modules/speech/SpeechSynthesis.cpp‎

Lines changed: 11 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
#include "EventNames.h"
3232
#include "PlatformSpeechSynthesisVoice.h"
3333
#include "PlatformSpeechSynthesizer.h"
34-
#include "SpeechSynthesisErrorEvent.h"
34+
#include "SpeechSynthesisEvent.h"
3535
#include "SpeechSynthesisUtterance.h"
3636
#include "UserGestureIndicator.h"
37-
#include "Logging.h"
3837
#include <wtf/NeverDestroyed.h>
3938

4039
namespace WebCore {
@@ -73,7 +72,7 @@ const Vector<Ref<SpeechSynthesisVoice>>& SpeechSynthesis::getVoices()
7372
return m_voiceList;
7473

7574
if (!m_platformSpeechSynthesizer)
76-
m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(this);
75+
m_platformSpeechSynthesizer = std::make_unique<PlatformSpeechSynthesizer>(this);
7776

7877
// If the voiceList is empty, that's the cue to get the voices from the platform again.
7978
for (auto& voice : m_platformSpeechSynthesizer->voiceList())
@@ -110,12 +109,12 @@ void SpeechSynthesis::startSpeakingImmediately(SpeechSynthesisUtterance& utteran
110109

111110
// Zero lengthed strings should immediately notify that the event is complete.
112111
if (utterance.text().isEmpty()) {
113-
handleSpeakingCompleted(utterance, SpeechErrorNone);
112+
handleSpeakingCompleted(utterance, false);
114113
return;
115114
}
116115

117116
if (!m_platformSpeechSynthesizer)
118-
m_platformSpeechSynthesizer = PlatformSpeechSynthesizer::create(this);
117+
m_platformSpeechSynthesizer = std::make_unique<PlatformSpeechSynthesizer>(this);
119118
m_platformSpeechSynthesizer->speak(utterance.platformUtterance());
120119
}
121120

@@ -141,19 +140,11 @@ void SpeechSynthesis::cancel()
141140
// Remove all the items from the utterance queue.
142141
// Hold on to the current utterance so the platform synthesizer can have a chance to clean up.
143142
RefPtr<SpeechSynthesisUtterance> current = m_currentSpeechUtterance;
144-
Deque<Ref<SpeechSynthesisUtterance>> utteranceQueue = WTFMove(m_utteranceQueue);
143+
m_utteranceQueue.clear();
145144
if (m_platformSpeechSynthesizer)
146145
m_platformSpeechSynthesizer->cancel();
147146
current = nullptr;
148147

149-
// Trigger canceled events for queued utterances
150-
while(utteranceQueue.size() > 0) {
151-
Ref<SpeechSynthesisUtterance> utterance = utteranceQueue.takeFirst();
152-
if(m_currentSpeechUtterance != utterance.ptr())
153-
fireErrorEvent(utterance, SpeechErrorCanceled);
154-
}
155-
utteranceQueue.clear();
156-
157148
// The platform should have called back immediately and cleared the current utterance.
158149
ASSERT(!m_currentSpeechUtterance);
159150
}
@@ -170,46 +161,19 @@ void SpeechSynthesis::resume()
170161
m_platformSpeechSynthesizer->resume();
171162
}
172163

173-
SpeechSynthesisErrorEvent::Code toSpeechSynthesisErrorEventCode(SpeechError error) {
174-
switch(error) {
175-
case SpeechErrorCanceled: return SpeechSynthesisErrorEvent::Code::Canceled;
176-
case SpeechErrorInterrupted: return SpeechSynthesisErrorEvent::Code::Interrupted;
177-
case SpeechErrorAudioBusy: return SpeechSynthesisErrorEvent::Code::AudioBusy;
178-
case SpeechErrorAudioHardware: return SpeechSynthesisErrorEvent::Code::AudioHardware;
179-
case SpeechErrorNetwork: return SpeechSynthesisErrorEvent::Code::Network;
180-
case SpeechErrorSynthesisUnavailable: return SpeechSynthesisErrorEvent::Code::SynthesisUnavailable;
181-
case SpeechErrorSynthesisFailed: return SpeechSynthesisErrorEvent::Code::SynthesisFailed;
182-
case SpeechErrorLanguageUnavailable: return SpeechSynthesisErrorEvent::Code::LanguageUnavailable;
183-
case SpeechErrorVoiceUnavailable: return SpeechSynthesisErrorEvent::Code::VoiceUnavailable;
184-
case SpeechErrorTextTooLong: return SpeechSynthesisErrorEvent::Code::TextTooLong;
185-
case SpeechErrorInvalidArgument: return SpeechSynthesisErrorEvent::Code::InvalidArgument;
186-
case SpeechErrorNotAllowed: return SpeechSynthesisErrorEvent::Code::NotAllowed;
187-
default: return SpeechSynthesisErrorEvent::Code::Interrupted;
188-
}
189-
}
190-
191164
void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtterance& utterance, unsigned long charIndex, const String& name)
192165
{
193166
utterance.dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, (MonotonicTime::now() - utterance.startTime()).seconds(), name));
194167
}
195168

196-
void SpeechSynthesis::fireErrorEvent(SpeechSynthesisUtterance& utterance, SpeechError error)
197-
{
198-
utterance.dispatchEvent(SpeechSynthesisErrorEvent::create(toSpeechSynthesisErrorEventCode(error)));
199-
}
200-
201-
void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance& utterance, SpeechError error)
169+
void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance& utterance, bool errorOccurred)
202170
{
203171
ASSERT(m_currentSpeechUtterance);
204172
Ref<SpeechSynthesisUtterance> protect(utterance);
205173

206-
if(m_currentSpeechUtterance == &utterance)
207-
m_currentSpeechUtterance = nullptr;
174+
m_currentSpeechUtterance = nullptr;
208175

209-
if(error == SpeechErrorNone)
210-
fireEvent(eventNames().endEvent, utterance, 0, String());
211-
else
212-
fireErrorEvent(utterance, error);
176+
fireEvent(errorOccurred ? eventNames().errorEvent : eventNames().endEvent, utterance, 0, String());
213177

214178
if (m_utteranceQueue.size()) {
215179
Ref<SpeechSynthesisUtterance> firstUtterance = m_utteranceQueue.takeFirst();
@@ -240,20 +204,6 @@ void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance& ut
240204
}
241205
}
242206

243-
double SpeechSynthesis::getPageMediaVolume()
244-
{
245-
if(m_currentSpeechUtterance)
246-
return m_currentSpeechUtterance->getPageMediaVolume();
247-
248-
return 0.0;
249-
}
250-
251-
void SpeechSynthesis::setPageMediaVolume(double volume)
252-
{
253-
if(m_currentSpeechUtterance)
254-
m_currentSpeechUtterance->setPageMediaVolume(volume);
255-
}
256-
257207
void SpeechSynthesis::didStartSpeaking(PlatformSpeechSynthesisUtterance& utterance)
258208
{
259209
if (utterance.client())
@@ -277,13 +227,13 @@ void SpeechSynthesis::didResumeSpeaking(PlatformSpeechSynthesisUtterance& uttera
277227
void SpeechSynthesis::didFinishSpeaking(PlatformSpeechSynthesisUtterance& utterance)
278228
{
279229
if (utterance.client())
280-
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance&>(*utterance.client()), SpeechErrorNone);
230+
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance&>(*utterance.client()), false);
281231
}
282232

283-
void SpeechSynthesis::speakingErrorOccurred(PlatformSpeechSynthesisUtterance& utterance, SpeechError error)
233+
void SpeechSynthesis::speakingErrorOccurred(PlatformSpeechSynthesisUtterance& utterance)
284234
{
285235
if (utterance.client())
286-
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance&>(*utterance.client()), error);
236+
handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance&>(*utterance.client()), true);
287237
}
288238

289239
} // namespace WebCore

‎Source/WebCore/Modules/speech/SpeechSynthesis.h‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,12 @@ class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public RefCounte
6666
void didPauseSpeaking(PlatformSpeechSynthesisUtterance&) override;
6767
void didResumeSpeaking(PlatformSpeechSynthesisUtterance&) override;
6868
void didFinishSpeaking(PlatformSpeechSynthesisUtterance&) override;
69-
void speakingErrorOccurred(PlatformSpeechSynthesisUtterance&, SpeechError) override;
69+
void speakingErrorOccurred(PlatformSpeechSynthesisUtterance&) override;
7070
void boundaryEventOccurred(PlatformSpeechSynthesisUtterance&, SpeechBoundary, unsigned charIndex) override;
71-
virtual double getPageMediaVolume() override;
72-
virtual void setPageMediaVolume(double volume) override;
7371

7472
void startSpeakingImmediately(SpeechSynthesisUtterance&);
75-
void handleSpeakingCompleted(SpeechSynthesisUtterance&, SpeechError);
73+
void handleSpeakingCompleted(SpeechSynthesisUtterance&, bool errorOccurred);
7674
void fireEvent(const AtomicString& type, SpeechSynthesisUtterance&, unsigned long charIndex, const String& name);
77-
void fireErrorEvent(SpeechSynthesisUtterance&, SpeechError);
7875

7976
#if PLATFORM(IOS)
8077
// Restrictions to change default behaviors.

‎Source/WebCore/Modules/speech/SpeechSynthesisErrorEvent.cpp‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

‎Source/WebCore/Modules/speech/SpeechSynthesisErrorEvent.h‎

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎Source/WebCore/Modules/speech/SpeechSynthesisErrorEvent.idl‎

Lines changed: 0 additions & 46 deletions
This file was deleted.

‎Source/WebCore/Modules/speech/SpeechSynthesisEvent.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ class SpeechSynthesisEvent : public Event {
4141

4242
virtual EventInterface eventInterface() const { return SpeechSynthesisEventInterfaceType; }
4343

44-
protected:
44+
private:
4545
SpeechSynthesisEvent(const AtomicString& type, unsigned charIndex, float elapsedTime, const String& name);
4646

47-
private:
4847
unsigned long m_charIndex;
4948
float m_elapsedTime;
5049
String m_name;

0 commit comments

Comments
 (0)