Changeset 244899 in webkit
- Timestamp:
- May 2, 2019 9:28:13 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244894 r244899 1 2019-05-02 Youenn Fablet <youenn@apple.com> 2 3 Make AudioContext::scriptExecutionContext() private 4 https://bugs.webkit.org/show_bug.cgi?id=197512 5 6 Reviewed by Eric Carlson. 7 8 Refactor code to make audio nodes not rely on AudioContext::scriptExecutionContext. 9 Instead, let AudioContext provide the necessary API for its nodes. 10 Covered by existing tests. 11 12 * Modules/webaudio/AudioBufferSourceNode.cpp: 13 (WebCore::AudioBufferSourceNode::looping): 14 (WebCore::AudioBufferSourceNode::setLooping): 15 * Modules/webaudio/AudioContext.cpp: 16 (WebCore::AudioContext::postTask): 17 (WebCore::AudioContext::origin const): 18 (WebCore::AudioContext::addConsoleMessage): 19 * Modules/webaudio/AudioContext.h: 20 (WebCore::AudioContext::isStopped const): 21 * Modules/webaudio/AudioNode.cpp: 22 (WebCore::AudioNode::scriptExecutionContext const): 23 * Modules/webaudio/AudioNode.h: 24 * Modules/webaudio/AudioScheduledSourceNode.cpp: 25 (WebCore::AudioScheduledSourceNode::finish): 26 * Modules/webaudio/DefaultAudioDestinationNode.cpp: 27 (WebCore::DefaultAudioDestinationNode::resume): 28 (WebCore::DefaultAudioDestinationNode::suspend): 29 (WebCore::DefaultAudioDestinationNode::close): 30 * Modules/webaudio/MediaElementAudioSourceNode.cpp: 31 (WebCore::MediaElementAudioSourceNode::wouldTaintOrigin): 32 * Modules/webaudio/MediaStreamAudioDestinationNode.cpp: 33 (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode): 34 * Modules/webaudio/ScriptProcessorNode.cpp: 35 (WebCore::ScriptProcessorNode::fireProcessEvent): 36 1 37 2019-05-02 Ryosuke Niwa <rniwa@webkit.org> 2 38 -
trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp
r243887 r244899 534 534 { 535 535 static bool firstTime = true; 536 if (firstTime && context().scriptExecutionContext()) {537 context(). scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s);536 if (firstTime) { 537 context().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s); 538 538 firstTime = false; 539 539 } … … 545 545 { 546 546 static bool firstTime = true; 547 if (firstTime && context().scriptExecutionContext()) {548 context(). scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s);547 if (firstTime) { 548 context().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."_s); 549 549 firstTime = false; 550 550 } -
trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp
r244860 r244899 1321 1321 } 1322 1322 1323 void AudioContext::postTask(WTF::Function<void()>&& task) 1324 { 1325 if (m_isStopScheduled) 1326 return; 1327 1328 m_scriptExecutionContext->postTask(WTFMove(task)); 1329 } 1330 1331 const SecurityOrigin* AudioContext::origin() const 1332 { 1333 return m_scriptExecutionContext ? m_scriptExecutionContext->securityOrigin() : nullptr; 1334 } 1335 1336 void AudioContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message) 1337 { 1338 if (m_scriptExecutionContext) 1339 m_scriptExecutionContext->addConsoleMessage(source, level, message); 1340 } 1341 1323 1342 #if !RELEASE_LOG_DISABLED 1324 1343 WTFLogChannel& AudioContext::logChannel() const -
trunk/Source/WebCore/Modules/webaudio/AudioContext.h
r244825 r244899 35 35 #include "MediaProducer.h" 36 36 #include "PlatformMediaSession.h" 37 #include "ScriptExecutionContext.h" 37 38 #include "VisibilityChangeClient.h" 39 #include <JavaScriptCore/ConsoleTypes.h> 38 40 #include <JavaScriptCore/Float32Array.h> 39 41 #include <atomic> … … 73 75 class PeriodicWave; 74 76 class ScriptProcessorNode; 77 class SecurityOrigin; 75 78 class WaveShaperNode; 76 79 … … 250 253 // EventTarget 251 254 EventTargetInterface eventTargetInterface() const final { return AudioContextEventTargetInterfaceType; } 252 ScriptExecutionContext* scriptExecutionContext() const final;253 255 254 256 // Reconcile ref/deref which are defined both in ThreadSafeRefCounted and EventTarget. … … 285 287 #endif 286 288 289 void postTask(WTF::Function<void()>&&); 290 bool isStopped() const { return m_isStopScheduled; } 291 const SecurityOrigin* origin() const; 292 void addConsoleMessage(MessageSource, MessageLevel, const String& message); 293 287 294 protected: 288 295 explicit AudioContext(Document&); … … 310 317 311 318 void mediaCanStart(Document&) override; 319 320 // EventTarget 321 ScriptExecutionContext* scriptExecutionContext() const final; 312 322 313 323 // MediaProducer -
trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp
r243887 r244899 360 360 ScriptExecutionContext* AudioNode::scriptExecutionContext() const 361 361 { 362 return const_cast<AudioNode*>(this)->context().scriptExecutionContext();362 return static_cast<ActiveDOMObject&>(const_cast<AudioNode*>(this)->context()).scriptExecutionContext(); 363 363 } 364 364 -
trunk/Source/WebCore/Modules/webaudio/AudioNode.h
r243887 r244899 182 182 AudioBus::ChannelInterpretation internalChannelInterpretation() const { return m_channelInterpretation; } 183 183 184 // EventTarget185 EventTargetInterface eventTargetInterface() const override;186 ScriptExecutionContext* scriptExecutionContext() const final;187 188 184 protected: 189 185 // Inputs and outputs must be created before the AudioNode is initialized. … … 207 203 208 204 private: 205 // EventTarget 206 EventTargetInterface eventTargetInterface() const override; 207 ScriptExecutionContext* scriptExecutionContext() const final; 208 209 209 volatile bool m_isInitialized; 210 210 NodeType m_nodeType; -
trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp
r243887 r244899 178 178 return; 179 179 180 auto* scriptExecutionContext = this->scriptExecutionContext(); 181 if (!scriptExecutionContext) 182 return; 183 184 scriptExecutionContext->postTask([this, protectedThis = makeRef(*this)] (auto&) { 185 // Make sure ActiveDOMObjects have not been stopped after scheduling this task. 186 if (!this->scriptExecutionContext()) 180 context().postTask([this, protectedThis = makeRef(*this)] { 181 if (context().isStopped()) 187 182 return; 188 189 183 this->dispatchEvent(Event::create(eventNames().endedEvent, Event::CanBubble::No, Event::IsCancelable::No)); 190 184 }); -
trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp
r243887 r244899 119 119 if (isInitialized()) 120 120 m_destination->start(); 121 if (auto scriptExecutionContext = context().scriptExecutionContext()) 122 scriptExecutionContext->postTask(WTFMove(function)); 121 context().postTask(WTFMove(function)); 123 122 } 124 123 … … 128 127 if (isInitialized()) 129 128 m_destination->stop(); 130 if (auto scriptExecutionContext = context().scriptExecutionContext()) 131 scriptExecutionContext->postTask(WTFMove(function)); 129 context().postTask(WTFMove(function)); 132 130 } 133 131 … … 136 134 ASSERT(isInitialized()); 137 135 uninitialize(); 138 if (auto scriptExecutionContext = context().scriptExecutionContext()) 139 scriptExecutionContext->postTask(WTFMove(function)); 136 context().postTask(WTFMove(function)); 140 137 } 141 138 -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp
r243887 r244899 114 114 return false; 115 115 116 if (auto* scriptExecutionContext = context().scriptExecutionContext()) { 117 if (auto* origin = scriptExecutionContext->securityOrigin()) 118 return m_mediaElement->wouldTaintOrigin(*origin); 119 } 116 if (auto* origin = context().origin()) 117 return m_mediaElement->wouldTaintOrigin(*origin); 120 118 121 119 return true; -
trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp
r243887 r244899 30 30 #include "AudioContext.h" 31 31 #include "AudioNodeInput.h" 32 #include "Document.h" 32 33 #include "MediaStream.h" 33 34 #include "MediaStreamAudioSource.h" … … 47 48 : AudioBasicInspectorNode(context, context.sampleRate(), numberOfChannels) 48 49 , m_source(MediaStreamAudioSource::create(context.sampleRate())) 49 , m_stream(MediaStream::create(*context. scriptExecutionContext(), MediaStreamPrivate::create(m_source.copyRef())))50 , m_stream(MediaStream::create(*context.document(), MediaStreamPrivate::create(m_source.copyRef()))) 50 51 { 51 52 setNodeType(NodeTypeMediaStreamAudioDestination); -
trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp
r243887 r244899 223 223 224 224 // Avoid firing the event if the document has already gone away. 225 if ( context().scriptExecutionContext()) {225 if (!context().isStopped()) { 226 226 // Let the audio thread know we've gotten to the point where it's OK for it to make another request. 227 227 m_isRequestOutstanding = false;
Note: See TracChangeset
for help on using the changeset viewer.