WebKit Bugzilla
Attachment 368838 Details for
Bug 197512
: Make AudioContext::scriptExecutionContext() private
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197512-20190502161203.patch (text/plain), 13.85 KB, created by
youenn fablet
on 2019-05-02 16:12:03 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-05-02 16:12:03 PDT
Size:
13.85 KB
patch
obsolete
>Subversion Revision: 244802 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4ea65fd6c1e3f6ea7dbba282136a1edeef03a953..926ff4f7643efac2a9dd261221733a007a0f5cab 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,39 @@ >+2019-05-02 Youenn Fablet <youenn@apple.com> >+ >+ Make AudioContext::scriptExecutionContext() private >+ https://bugs.webkit.org/show_bug.cgi?id=197512 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Refactor code to make audio nodes not rely on AudioContext::scriptExecutionContext. >+ Instead, let AudioContext provide the necessary API for its nodes. >+ Covered by existing tests. >+ >+ * Modules/webaudio/AudioBufferSourceNode.cpp: >+ (WebCore::AudioBufferSourceNode::looping): >+ (WebCore::AudioBufferSourceNode::setLooping): >+ * Modules/webaudio/AudioContext.cpp: >+ (WebCore::AudioContext::postTask): >+ (WebCore::AudioContext::origin const): >+ (WebCore::AudioContext::addConsoleMessage): >+ * Modules/webaudio/AudioContext.h: >+ (WebCore::AudioContext::isStopped const): >+ * Modules/webaudio/AudioNode.cpp: >+ (WebCore::AudioNode::scriptExecutionContext const): >+ * Modules/webaudio/AudioNode.h: >+ * Modules/webaudio/AudioScheduledSourceNode.cpp: >+ (WebCore::AudioScheduledSourceNode::finish): >+ * Modules/webaudio/DefaultAudioDestinationNode.cpp: >+ (WebCore::DefaultAudioDestinationNode::resume): >+ (WebCore::DefaultAudioDestinationNode::suspend): >+ (WebCore::DefaultAudioDestinationNode::close): >+ * Modules/webaudio/MediaElementAudioSourceNode.cpp: >+ (WebCore::MediaElementAudioSourceNode::wouldTaintOrigin): >+ * Modules/webaudio/MediaStreamAudioDestinationNode.cpp: >+ (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode): >+ * Modules/webaudio/ScriptProcessorNode.cpp: >+ (WebCore::ScriptProcessorNode::fireProcessEvent): >+ > 2019-05-01 Youenn Fablet <youenn@apple.com> > > Cache.add and Cache.addAll should compute a correct response body size >diff --git a/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp b/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp >index 5f76fc595c62842727a9e14f03ca55a13bcf798e..40ac32c5c55c3d32d0e14b6a7d22b2467390f4bf 100644 >--- a/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp >@@ -533,8 +533,8 @@ double AudioBufferSourceNode::totalPitchRate() > bool AudioBufferSourceNode::looping() > { > static bool firstTime = true; >- if (firstTime && context().scriptExecutionContext()) { >- context().scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s); >+ if (firstTime) { >+ context().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s); > firstTime = false; > } > >@@ -544,8 +544,8 @@ bool AudioBufferSourceNode::looping() > void AudioBufferSourceNode::setLooping(bool looping) > { > static bool firstTime = true; >- if (firstTime && context().scriptExecutionContext()) { >- context().scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s); >+ if (firstTime) { >+ context().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s); > firstTime = false; > } > >diff --git a/Source/WebCore/Modules/webaudio/AudioContext.cpp b/Source/WebCore/Modules/webaudio/AudioContext.cpp >index ed8ae491cc8cfc5e103d9feab9fd95f91c7b38b7..6aabd2b166e523703c2190c30cb8daa8f66098e7 100644 >--- a/Source/WebCore/Modules/webaudio/AudioContext.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioContext.cpp >@@ -1320,6 +1320,25 @@ void AudioContext::mayResumePlayback(bool shouldResume) > }); > } > >+void AudioContext::postTask(WTF::Function<void()>&& task) >+{ >+ if (m_isStopScheduled) >+ return; >+ >+ m_scriptExecutionContext->postTask(WTFMove(task)); >+} >+ >+const SecurityOrigin* AudioContext::origin() const >+{ >+ return m_scriptExecutionContext ? m_scriptExecutionContext->securityOrigin() : nullptr; >+} >+ >+void AudioContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message) >+{ >+ if (m_scriptExecutionContext) >+ m_scriptExecutionContext->addConsoleMessage(source, level, message); >+} >+ > #if !RELEASE_LOG_DISABLED > WTFLogChannel& AudioContext::logChannel() const > { >diff --git a/Source/WebCore/Modules/webaudio/AudioContext.h b/Source/WebCore/Modules/webaudio/AudioContext.h >index 3705c4953eac66052d6bd310fbe4fa8038ae1bc5..eb347202487bbc8057c4f83216d997e192b25d0b 100644 >--- a/Source/WebCore/Modules/webaudio/AudioContext.h >+++ b/Source/WebCore/Modules/webaudio/AudioContext.h >@@ -34,7 +34,9 @@ > #include "MediaCanStartListener.h" > #include "MediaProducer.h" > #include "PlatformMediaSession.h" >+#include "ScriptExecutionContext.h" > #include "VisibilityChangeClient.h" >+#include <JavaScriptCore/ConsoleTypes.h> > #include <JavaScriptCore/Float32Array.h> > #include <atomic> > #include <wtf/HashSet.h> >@@ -72,6 +74,7 @@ class OscillatorNode; > class PannerNode; > class PeriodicWave; > class ScriptProcessorNode; >+class SecurityOrigin; > class WaveShaperNode; > > // AudioContext is the cornerstone of the web audio API and all AudioNodes are created from it. >@@ -249,7 +252,6 @@ public: > > // EventTarget > EventTargetInterface eventTargetInterface() const final { return AudioContextEventTargetInterfaceType; } >- ScriptExecutionContext* scriptExecutionContext() const final; > > // Reconcile ref/deref which are defined both in ThreadSafeRefCounted and EventTarget. > using ThreadSafeRefCounted::ref; >@@ -284,6 +286,11 @@ public: > const void* nextAudioParameterLogIdentifier() { return childLogIdentifier(++m_nextAudioParameterIdentifier); } > #endif > >+ void postTask(WTF::Function<void()>&&); >+ bool isStopped() const { return m_isStopScheduled; } >+ const SecurityOrigin* origin() const; >+ void addConsoleMessage(MessageSource, MessageLevel, const String& message); >+ > protected: > explicit AudioContext(Document&); > AudioContext(Document&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate); >@@ -310,6 +317,9 @@ private: > > void mediaCanStart(Document&) override; > >+ // EventTarget >+ ScriptExecutionContext* scriptExecutionContext() const final; >+ > // MediaProducer > MediaProducer::MediaStateFlags mediaState() const override; > void pageMutedStateDidChange() override; >diff --git a/Source/WebCore/Modules/webaudio/AudioNode.cpp b/Source/WebCore/Modules/webaudio/AudioNode.cpp >index 2ab672670ad0a771512a4ad05ae9a262a18cf234..807f009f0076e7ef412c35b73f87e353f98c6267 100644 >--- a/Source/WebCore/Modules/webaudio/AudioNode.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioNode.cpp >@@ -359,7 +359,7 @@ EventTargetInterface AudioNode::eventTargetInterface() const > > ScriptExecutionContext* AudioNode::scriptExecutionContext() const > { >- return const_cast<AudioNode*>(this)->context().scriptExecutionContext(); >+ return static_cast<ActiveDOMObject&>(const_cast<AudioNode*>(this)->context()).scriptExecutionContext(); > } > > void AudioNode::processIfNecessary(size_t framesToProcess) >diff --git a/Source/WebCore/Modules/webaudio/AudioNode.h b/Source/WebCore/Modules/webaudio/AudioNode.h >index d26f23f86f3af202d54c8fc015f8e19797d36977..32f8a7214b6c348078be64c6729dbea3f3ebb568 100644 >--- a/Source/WebCore/Modules/webaudio/AudioNode.h >+++ b/Source/WebCore/Modules/webaudio/AudioNode.h >@@ -181,10 +181,6 @@ public: > ChannelCountMode internalChannelCountMode() const { return m_channelCountMode; } > AudioBus::ChannelInterpretation internalChannelInterpretation() const { return m_channelInterpretation; } > >- // EventTarget >- EventTargetInterface eventTargetInterface() const override; >- ScriptExecutionContext* scriptExecutionContext() const final; >- > protected: > // Inputs and outputs must be created before the AudioNode is initialized. > void addInput(std::unique_ptr<AudioNodeInput>); >@@ -206,6 +202,10 @@ protected: > #endif > > private: >+ // EventTarget >+ EventTargetInterface eventTargetInterface() const override; >+ ScriptExecutionContext* scriptExecutionContext() const final; >+ > volatile bool m_isInitialized; > NodeType m_nodeType; > Ref<AudioContext> m_context; >diff --git a/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp b/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp >index 1954c7ba0354f1ab41ff0bd1064f18f81d4b2938..9eed877c264a5b3f11eedc885c1ceea49324e139 100644 >--- a/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp >@@ -177,15 +177,9 @@ void AudioScheduledSourceNode::finish() > if (!m_hasEndedListener) > return; > >- auto* scriptExecutionContext = this->scriptExecutionContext(); >- if (!scriptExecutionContext) >- return; >- >- scriptExecutionContext->postTask([this, protectedThis = makeRef(*this)] (auto&) { >- // Make sure ActiveDOMObjects have not been stopped after scheduling this task. >- if (!this->scriptExecutionContext()) >+ context().postTask([this, protectedThis = makeRef(*this)] { >+ if (context().isStopped()) > return; >- > this->dispatchEvent(Event::create(eventNames().endedEvent, Event::CanBubble::No, Event::IsCancelable::No)); > }); > } >diff --git a/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp b/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp >index 4836cee34d4a1942b0cc85ba5a5dd52cfc0932dd..2672d65e68feb01628bef0f0e0b0ad4d31f45b7c 100644 >--- a/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp >+++ b/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp >@@ -118,8 +118,7 @@ void DefaultAudioDestinationNode::resume(Function<void ()>&& function) > ASSERT(isInitialized()); > if (isInitialized()) > m_destination->start(); >- if (auto scriptExecutionContext = context().scriptExecutionContext()) >- scriptExecutionContext->postTask(WTFMove(function)); >+ context().postTask(WTFMove(function)); > } > > void DefaultAudioDestinationNode::suspend(Function<void ()>&& function) >@@ -127,16 +126,14 @@ void DefaultAudioDestinationNode::suspend(Function<void ()>&& function) > ASSERT(isInitialized()); > if (isInitialized()) > m_destination->stop(); >- if (auto scriptExecutionContext = context().scriptExecutionContext()) >- scriptExecutionContext->postTask(WTFMove(function)); >+ context().postTask(WTFMove(function)); > } > > void DefaultAudioDestinationNode::close(Function<void()>&& function) > { > ASSERT(isInitialized()); > uninitialize(); >- if (auto scriptExecutionContext = context().scriptExecutionContext()) >- scriptExecutionContext->postTask(WTFMove(function)); >+ context().postTask(WTFMove(function)); > } > > unsigned DefaultAudioDestinationNode::maxChannelCount() const >diff --git a/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp b/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp >index 66111b620f774f80832055915c47d5abd69729bf..99de98bbfa434abeb1891bc505c6132c6a703ed9 100644 >--- a/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp >+++ b/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp >@@ -113,10 +113,8 @@ bool MediaElementAudioSourceNode::wouldTaintOrigin() > if (m_mediaElement->didPassCORSAccessCheck()) > return false; > >- if (auto* scriptExecutionContext = context().scriptExecutionContext()) { >- if (auto* origin = scriptExecutionContext->securityOrigin()) >- return m_mediaElement->wouldTaintOrigin(*origin); >- } >+ if (auto* origin = context().origin()) >+ return m_mediaElement->wouldTaintOrigin(*origin); > > return true; > } >diff --git a/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp b/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp >index 4442cbe4a69a2c6a9cd98d7b85fbfa4a4ff070cb..c0bb38ed2dcbd6d28020f4a4a0daeaf544ab75db 100644 >--- a/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp >+++ b/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp >@@ -29,6 +29,7 @@ > > #include "AudioContext.h" > #include "AudioNodeInput.h" >+#include "Document.h" > #include "MediaStream.h" > #include "MediaStreamAudioSource.h" > #include <wtf/IsoMallocInlines.h> >@@ -46,7 +47,7 @@ Ref<MediaStreamAudioDestinationNode> MediaStreamAudioDestinationNode::create(Aud > MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext& context, size_t numberOfChannels) > : AudioBasicInspectorNode(context, context.sampleRate(), numberOfChannels) > , m_source(MediaStreamAudioSource::create(context.sampleRate())) >- , m_stream(MediaStream::create(*context.scriptExecutionContext(), MediaStreamPrivate::create(m_source.copyRef()))) >+ , m_stream(MediaStream::create(*context.document(), MediaStreamPrivate::create(m_source.copyRef()))) > { > setNodeType(NodeTypeMediaStreamAudioDestination); > initialize(); >diff --git a/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp b/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp >index 960e97841be61d153590b745c69387857acd5b1a..d5ebd1f922ab163572bbd3b198aedd6f3236bdee 100644 >--- a/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp >+++ b/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp >@@ -222,7 +222,7 @@ void ScriptProcessorNode::fireProcessEvent() > return; > > // Avoid firing the event if the document has already gone away. >- if (context().scriptExecutionContext()) { >+ if (!context().isStopped()) { > // Let the audio thread know we've gotten to the point where it's OK for it to make another request. > m_isRequestOutstanding = false; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197512
:
368776
|
368814
| 368838