Skip to content

Commit 8ebc2f3

Browse files
committed
Made AudioNode an EventTarget
https://bugs.webkit.org/show_bug.cgi?id=116871 Source/WebCore: Merge: https://chromium.googlesource.com/chromium/blink/+/ef37484162ddb95d677dcfdcdd778ec60590928b Reviewed by Darin Adler. Tests: webaudio/audionode-expected.txt: webaudio/audionode.html: Add the requisite boilerplate to allow AudioNode to become an EventTarget. Remove all that same boilerplate from ScriptProcessorNode now that it's base class is an EventTarget. * Modules/webaudio/AudioNode.cpp: (WebCore::AudioNode::interfaceName): Added boilerplate. (WebCore::AudioNode::scriptExecutionContext): Return the AudioContext's context. (WebCore::AudioNode::processIfNecessary): Whitespace. * Modules/webaudio/AudioNode.h: * Modules/webaudio/AudioNode.idl: Make AudioNode an EventTarget. * Modules/webaudio/ScriptProcessorNode.cpp: Remove EventTarget boilerplate. * Modules/webaudio/ScriptProcessorNode.h: Ditto. * Modules/webaudio/ScriptProcessorNode.idl: Ditto. * dom/EventTarget.h: Mark AudioNode as an EventTarget. * dom/EventTargetFactory.in: Ditto. LayoutTests: Reviewed by Darin Adler. * webaudio/audionode-expected.txt: * webaudio/audionode.html: Canonical link: https://commits.webkit.org/135175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@150810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 4173aca commit 8ebc2f3

12 files changed

Lines changed: 91 additions & 34 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2013-05-28 Jer Noble <jer.noble@apple.com>
2+
3+
Made AudioNode an EventTarget
4+
https://bugs.webkit.org/show_bug.cgi?id=116871
5+
6+
Reviewed by Darin Adler.
7+
8+
* webaudio/audionode-expected.txt:
9+
* webaudio/audionode.html:
10+
111
2013-05-28 Sergio Villar Senin <svillar@igalia.com>
212

313
Invalid block doesn't make declaration invalid

LayoutTests/webaudio/audionode-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PASS connect() exception thrown for illegal input index.
1616
PASS audioNode.connect(context.destination) succeeded.
1717
PASS exception thrown when connecting to other context's node.
1818
PASS exception thrown when creating audio context with not enough arguments.
19+
PASS AudioNode is an EventTarget
1920
PASS successfullyParsed is true
2021

2122
TEST COMPLETE

LayoutTests/webaudio/audionode.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@
101101
testPassed("exception thrown when creating audio context with not enough arguments.");
102102
}
103103

104+
// Ensure it is an EventTarget
105+
try {
106+
audioNode.addEventListener('testEvent', function(){
107+
testPassed("AudioNode is an EventTarget");
108+
});
109+
audioNode.dispatchEvent(new Event('testEvent'));
110+
} catch(e) {
111+
testFailed("exception shouldn't be thrown when testing whether audio node is an event target");
112+
}
113+
104114
finishJSTest();
105115
}
106116

Source/WebCore/ChangeLog

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
2013-05-28 Jer Noble <jer.noble@apple.com>
2+
3+
Made AudioNode an EventTarget
4+
https://bugs.webkit.org/show_bug.cgi?id=116871
5+
6+
Merge: https://chromium.googlesource.com/chromium/blink/+/ef37484162ddb95d677dcfdcdd778ec60590928b
7+
8+
Reviewed by Darin Adler.
9+
10+
Tests: webaudio/audionode-expected.txt:
11+
webaudio/audionode.html:
12+
13+
Add the requisite boilerplate to allow AudioNode to become an EventTarget. Remove
14+
all that same boilerplate from ScriptProcessorNode now that it's base class
15+
is an EventTarget.
16+
17+
* Modules/webaudio/AudioNode.cpp:
18+
(WebCore::AudioNode::interfaceName): Added boilerplate.
19+
(WebCore::AudioNode::scriptExecutionContext): Return the AudioContext's context.
20+
(WebCore::AudioNode::processIfNecessary): Whitespace.
21+
* Modules/webaudio/AudioNode.h:
22+
* Modules/webaudio/AudioNode.idl: Make AudioNode an EventTarget.
23+
* Modules/webaudio/ScriptProcessorNode.cpp: Remove EventTarget boilerplate.
24+
* Modules/webaudio/ScriptProcessorNode.h: Ditto.
25+
* Modules/webaudio/ScriptProcessorNode.idl: Ditto.
26+
* dom/EventTarget.h: Mark AudioNode as an EventTarget.
27+
* dom/EventTargetFactory.in: Ditto.
28+
129
2013-05-28 Arvid Nilsson <anilsson@rim.com>
230

331
[BlackBerry] backface-visibility: hidden doesn't work properly with masks and filters

Source/WebCore/Modules/webaudio/AudioNode.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,20 @@ void AudioNode::updateChannelsForInputs()
280280
input(i)->changedOutputs();
281281
}
282282

283+
const AtomicString& AudioNode::interfaceName() const
284+
{
285+
return eventNames().interfaceForAudioNode;
286+
}
287+
288+
ScriptExecutionContext* AudioNode::scriptExecutionContext() const
289+
{
290+
return const_cast<AudioNode*>(this)->context()->scriptExecutionContext();
291+
}
292+
283293
void AudioNode::processIfNecessary(size_t framesToProcess)
284294
{
285295
ASSERT(context()->isAudioThread());
286-
296+
287297
if (!isInitialized())
288298
return;
289299

Source/WebCore/Modules/webaudio/AudioNode.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define AudioNode_h
2727

2828
#include "AudioBus.h"
29+
#include "EventTarget.h"
2930
#include <wtf/Forward.h>
3031
#include <wtf/OwnPtr.h>
3132
#include <wtf/PassOwnPtr.h>
@@ -49,7 +50,7 @@ typedef int ExceptionCode;
4950
// An AudioDestinationNode has one input and no outputs and represents the final destination to the audio hardware.
5051
// Most processing nodes such as filters will have one input and one output, although multiple inputs and outputs are possible.
5152

52-
class AudioNode {
53+
class AudioNode : public EventTarget {
5354
public:
5455
enum { ProcessingSizeInFrames = 128 };
5556

@@ -178,6 +179,12 @@ class AudioNode {
178179
ChannelCountMode internalChannelCountMode() const { return m_channelCountMode; }
179180
AudioBus::ChannelInterpretation internalChannelInterpretation() const { return m_channelInterpretation; }
180181

182+
// EventTarget
183+
virtual const AtomicString& interfaceName() const OVERRIDE;
184+
virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
185+
virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetData; }
186+
virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventTargetData; }
187+
181188
protected:
182189
// Inputs and outputs must be created before the AudioNode is initialized.
183190
void addInput(PassOwnPtr<AudioNodeInput>);
@@ -199,6 +206,8 @@ class AudioNode {
199206
Vector<OwnPtr<AudioNodeInput> > m_inputs;
200207
Vector<OwnPtr<AudioNodeOutput> > m_outputs;
201208

209+
EventTargetData m_eventTargetData;
210+
202211
double m_lastProcessingTime;
203212
double m_lastNonSilentTime;
204213

@@ -214,6 +223,9 @@ class AudioNode {
214223
static int s_nodeCount[NodeTypeEnd];
215224
#endif
216225

226+
virtual void refEventTarget() OVERRIDE { ref(); }
227+
virtual void derefEventTarget() OVERRIDE { deref(); }
228+
217229
protected:
218230
unsigned m_channelCount;
219231
ChannelCountMode m_channelCountMode;

Source/WebCore/Modules/webaudio/AudioNode.idl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
*/
2424

2525
[
26-
Conditional=WEB_AUDIO
27-
] interface AudioNode {
26+
Conditional=WEB_AUDIO,
27+
JSGenerateToJSObject,
28+
JSGenerateToNativeObject,
29+
GenerateIsReachable=Impl,
30+
EventTarget
31+
] interface AudioNode : EventTarget {
2832
readonly attribute AudioContext context;
2933
readonly attribute unsigned long numberOfInputs;
3034
readonly attribute unsigned long numberOfOutputs;
@@ -46,4 +50,11 @@
4650

4751
void disconnect([Default=Undefined] optional unsigned long output)
4852
raises(DOMException);
53+
54+
void addEventListener(DOMString type, EventListener listener, optional boolean useCapture);
55+
56+
void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture);
57+
58+
boolean dispatchEvent(Event event)
59+
raises(EventException);
4960
};

Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ void ScriptProcessorNode::reset()
263263
}
264264
}
265265

266-
const AtomicString& ScriptProcessorNode::interfaceName() const
267-
{
268-
return eventNames().interfaceForScriptProcessorNode;
269-
}
270-
271-
ScriptExecutionContext* ScriptProcessorNode::scriptExecutionContext() const
272-
{
273-
return const_cast<ScriptProcessorNode*>(this)->context()->scriptExecutionContext();
274-
}
275-
276266
double ScriptProcessorNode::tailTime() const
277267
{
278268
return std::numeric_limits<double>::infinity();

Source/WebCore/Modules/webaudio/ScriptProcessorNode.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class AudioProcessingEvent;
4747
// The "onaudioprocess" attribute is an event listener which will get called periodically with an AudioProcessingEvent which has
4848
// AudioBuffers for each input and output.
4949

50-
// FIXME: EventTarget should be introduced at the base of the inheritance hierarchy (i.e., as a base class for AudioNode).
51-
class ScriptProcessorNode : public AudioNode, public EventTarget {
50+
class ScriptProcessorNode : public AudioNode {
5251
public:
5352
// bufferSize must be one of the following values: 256, 512, 1024, 2048, 4096, 8192, 16384.
5453
// This value controls how frequently the onaudioprocess event handler is called and how many sample-frames need to be processed each call.
@@ -64,19 +63,9 @@ class ScriptProcessorNode : public AudioNode, public EventTarget {
6463
virtual void initialize();
6564
virtual void uninitialize();
6665

67-
// EventTarget
68-
virtual const AtomicString& interfaceName() const;
69-
virtual ScriptExecutionContext* scriptExecutionContext() const;
70-
virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
71-
virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
72-
7366
size_t bufferSize() const { return m_bufferSize; }
7467

7568
DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess);
76-
77-
// Reconcile ref/deref which are defined both in AudioNode and EventTarget.
78-
using AudioNode::ref;
79-
using AudioNode::deref;
8069

8170
private:
8271
virtual double tailTime() const OVERRIDE;
@@ -95,10 +84,6 @@ class ScriptProcessorNode : public AudioNode, public EventTarget {
9584
Vector<RefPtr<AudioBuffer> > m_inputBuffers;
9685
Vector<RefPtr<AudioBuffer> > m_outputBuffers;
9786

98-
virtual void refEventTarget() { ref(); }
99-
virtual void derefEventTarget() { deref(); }
100-
EventTargetData m_eventTargetData;
101-
10287
size_t m_bufferSize;
10388
unsigned m_bufferReadWriteIndex;
10489
volatile bool m_isRequestOutstanding;

Source/WebCore/Modules/webaudio/ScriptProcessorNode.idl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
[
2727
Conditional=WEB_AUDIO,
2828
JSGenerateToJSObject,
29-
JSGenerateToNativeObject,
30-
EventTarget
29+
JSGenerateToNativeObject
3130
] interface ScriptProcessorNode : AudioNode {
3231
// Rendering callback
3332
attribute EventListener onaudioprocess;
34-
33+
3534
readonly attribute long bufferSize;
3635
};

0 commit comments

Comments
 (0)