Title: [274678] trunk/Source/WebCore
- Revision
- 274678
- Author
- [email protected]
- Date
- 2021-03-18 15:52:48 -0700 (Thu, 18 Mar 2021)
Log Message
SpeechSynthesis should honor audioPlaybackRequiresUserGesture setting on iOS.
https://bugs.webkit.org/show_bug.cgi?id=223473
rdar://problem/75586456
Reviewed by Chris Fleizach.
* Modules/speech/DOMWindowSpeechSynthesis.cpp:
(WebCore::DOMWindowSpeechSynthesis::speechSynthesis): Pass the document.
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::create): Pass the document.
(WebCore::SpeechSynthesis::SpeechSynthesis): Set the initial m_restrictions based on document.audioPlaybackRequiresUserGesture().
* Modules/speech/SpeechSynthesis.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274677 => 274678)
--- trunk/Source/WebCore/ChangeLog 2021-03-18 22:42:27 UTC (rev 274677)
+++ trunk/Source/WebCore/ChangeLog 2021-03-18 22:52:48 UTC (rev 274678)
@@ -1,3 +1,18 @@
+2021-03-18 Timothy Hatcher <[email protected]>
+
+ SpeechSynthesis should honor audioPlaybackRequiresUserGesture setting on iOS.
+ https://bugs.webkit.org/show_bug.cgi?id=223473
+ rdar://problem/75586456
+
+ Reviewed by Chris Fleizach.
+
+ * Modules/speech/DOMWindowSpeechSynthesis.cpp:
+ (WebCore::DOMWindowSpeechSynthesis::speechSynthesis): Pass the document.
+ * Modules/speech/SpeechSynthesis.cpp:
+ (WebCore::SpeechSynthesis::create): Pass the document.
+ (WebCore::SpeechSynthesis::SpeechSynthesis): Set the initial m_restrictions based on document.audioPlaybackRequiresUserGesture().
+ * Modules/speech/SpeechSynthesis.h:
+
2021-03-18 Chris Dumez <[email protected]>
Avoid heap allocation under AudioWorkletNode::process()
Modified: trunk/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp (274677 => 274678)
--- trunk/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp 2021-03-18 22:42:27 UTC (rev 274677)
+++ trunk/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp 2021-03-18 22:52:48 UTC (rev 274678)
@@ -70,8 +70,8 @@
SpeechSynthesis* DOMWindowSpeechSynthesis::speechSynthesis()
{
- if (!m_speechSynthesis && frame())
- m_speechSynthesis = SpeechSynthesis::create(makeWeakPtr(frame()->page()->speechSynthesisClient()));
+ if (!m_speechSynthesis && frame() && frame()->document())
+ m_speechSynthesis = SpeechSynthesis::create(makeWeakPtr(frame()->page()->speechSynthesisClient()), *frame()->document());
return m_speechSynthesis.get();
}
Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (274677 => 274678)
--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp 2021-03-18 22:42:27 UTC (rev 274677)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp 2021-03-18 22:52:48 UTC (rev 274678)
@@ -36,21 +36,29 @@
#include "UserGestureIndicator.h"
#include <wtf/NeverDestroyed.h>
+#if PLATFORM(IOS_FAMILY)
+#include "Document.h"
+#endif
+
namespace WebCore {
-Ref<SpeechSynthesis> SpeechSynthesis::create(WeakPtr<SpeechSynthesisClient> client)
+Ref<SpeechSynthesis> SpeechSynthesis::create(WeakPtr<SpeechSynthesisClient> client, Document& document)
{
- return adoptRef(*new SpeechSynthesis(client));
+ return adoptRef(*new SpeechSynthesis(client, document));
}
-SpeechSynthesis::SpeechSynthesis(WeakPtr<SpeechSynthesisClient> client)
+SpeechSynthesis::SpeechSynthesis(WeakPtr<SpeechSynthesisClient> client, Document& document)
: m_currentSpeechUtterance(nullptr)
, m_isPaused(false)
#if PLATFORM(IOS_FAMILY)
- , m_restrictions(RequireUserGestureForSpeechStartRestriction)
+ , m_restrictions(document.audioPlaybackRequiresUserGesture() ? RequireUserGestureForSpeechStartRestriction : NoRestrictions)
#endif
, m_speechSynthesisClient(client)
{
+#if !PLATFORM(IOS_FAMILY)
+ UNUSED_PARAM(document);
+#endif
+
if (m_speechSynthesisClient)
m_speechSynthesisClient->setObserver(makeWeakPtr(this));
}
Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h (274677 => 274678)
--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h 2021-03-18 22:42:27 UTC (rev 274677)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h 2021-03-18 22:52:48 UTC (rev 274678)
@@ -37,12 +37,13 @@
namespace WebCore {
+class Document;
class PlatformSpeechSynthesizerClient;
class SpeechSynthesisVoice;
class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public SpeechSynthesisClientObserver, public RefCounted<SpeechSynthesis> {
public:
- static Ref<SpeechSynthesis> create(WeakPtr<SpeechSynthesisClient>);
+ static Ref<SpeechSynthesis> create(WeakPtr<SpeechSynthesisClient>, Document&);
bool pending() const;
bool speaking() const;
@@ -59,7 +60,7 @@
WEBCORE_EXPORT void setPlatformSynthesizer(std::unique_ptr<PlatformSpeechSynthesizer>);
private:
- SpeechSynthesis(WeakPtr<SpeechSynthesisClient>);
+ SpeechSynthesis(WeakPtr<SpeechSynthesisClient>, Document&);
// PlatformSpeechSynthesizerClient override methods.
void voicesDidChange() override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes