Title: [150810] trunk
Revision
150810
Author
jer.no...@apple.com
Date
2013-05-28 10:54:20 -0700 (Tue, 28 May 2013)

Log Message

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (150809 => 150810)


--- trunk/LayoutTests/ChangeLog	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/LayoutTests/ChangeLog	2013-05-28 17:54:20 UTC (rev 150810)
@@ -1,3 +1,13 @@
+2013-05-28  Jer Noble  <jer.no...@apple.com>
+
+        Made AudioNode an EventTarget
+        https://bugs.webkit.org/show_bug.cgi?id=116871
+
+        Reviewed by Darin Adler.
+
+        * webaudio/audionode-expected.txt:
+        * webaudio/audionode.html:
+
 2013-05-28  Sergio Villar Senin  <svil...@igalia.com>
 
         Invalid block doesn't make declaration invalid

Modified: trunk/LayoutTests/webaudio/audionode-expected.txt (150809 => 150810)


--- trunk/LayoutTests/webaudio/audionode-expected.txt	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/LayoutTests/webaudio/audionode-expected.txt	2013-05-28 17:54:20 UTC (rev 150810)
@@ -16,6 +16,7 @@
 PASS audioNode.connect(context.destination) succeeded.
 PASS exception thrown when connecting to other context's node.
 PASS exception thrown when creating audio context with not enough arguments.
+PASS AudioNode is an EventTarget
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/webaudio/audionode.html (150809 => 150810)


--- trunk/LayoutTests/webaudio/audionode.html	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/LayoutTests/webaudio/audionode.html	2013-05-28 17:54:20 UTC (rev 150810)
@@ -101,6 +101,16 @@
         testPassed("exception thrown when creating audio context with not enough arguments.");
     }
 
+    // Ensure it is an EventTarget
+    try {
+        audioNode.addEventListener('testEvent', function(){
+            testPassed("AudioNode is an EventTarget");
+        });
+        audioNode.dispatchEvent(new Event('testEvent'));
+    } catch(e) {
+        testFailed("exception shouldn't be thrown when testing whether audio node is an event target");
+    }
+
     finishJSTest();
 }
 

Modified: trunk/Source/WebCore/ChangeLog (150809 => 150810)


--- trunk/Source/WebCore/ChangeLog	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/ChangeLog	2013-05-28 17:54:20 UTC (rev 150810)
@@ -1,3 +1,31 @@
+2013-05-28  Jer Noble  <jer.no...@apple.com>
+
+        Made AudioNode an EventTarget
+        https://bugs.webkit.org/show_bug.cgi?id=116871
+
+        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.
+
 2013-05-28  Arvid Nilsson  <anils...@rim.com>
 
         [BlackBerry] backface-visibility: hidden doesn't work properly with masks and filters

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp (150809 => 150810)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2013-05-28 17:54:20 UTC (rev 150810)
@@ -280,10 +280,20 @@
         input(i)->changedOutputs();
 }
 
+const AtomicString& AudioNode::interfaceName() const
+{
+    return eventNames().interfaceForAudioNode;
+}
+
+ScriptExecutionContext* AudioNode::scriptExecutionContext() const
+{
+    return const_cast<AudioNode*>(this)->context()->scriptExecutionContext();
+}
+
 void AudioNode::processIfNecessary(size_t framesToProcess)
 {
     ASSERT(context()->isAudioThread());
-    
+
     if (!isInitialized())
         return;
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.h (150809 => 150810)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.h	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.h	2013-05-28 17:54:20 UTC (rev 150810)
@@ -26,6 +26,7 @@
 #define AudioNode_h
 
 #include "AudioBus.h"
+#include "EventTarget.h"
 #include <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
@@ -49,7 +50,7 @@
 // An AudioDestinationNode has one input and no outputs and represents the final destination to the audio hardware.
 // Most processing nodes such as filters will have one input and one output, although multiple inputs and outputs are possible.
 
-class AudioNode {
+class AudioNode : public EventTarget {
 public:
     enum { ProcessingSizeInFrames = 128 };
 
@@ -178,6 +179,12 @@
     ChannelCountMode internalChannelCountMode() const { return m_channelCountMode; }
     AudioBus::ChannelInterpretation internalChannelInterpretation() const { return m_channelInterpretation; }
 
+    // EventTarget
+    virtual const AtomicString& interfaceName() const OVERRIDE;
+    virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
+    virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetData; }
+    virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventTargetData; }
+
 protected:
     // Inputs and outputs must be created before the AudioNode is initialized.
     void addInput(PassOwnPtr<AudioNodeInput>);
@@ -199,6 +206,8 @@
     Vector<OwnPtr<AudioNodeInput> > m_inputs;
     Vector<OwnPtr<AudioNodeOutput> > m_outputs;
 
+    EventTargetData m_eventTargetData;
+
     double m_lastProcessingTime;
     double m_lastNonSilentTime;
 
@@ -214,6 +223,9 @@
     static int s_nodeCount[NodeTypeEnd];
 #endif
 
+    virtual void refEventTarget() OVERRIDE { ref(); }
+    virtual void derefEventTarget() OVERRIDE { deref(); }
+
 protected:
     unsigned m_channelCount;
     ChannelCountMode m_channelCountMode;

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.idl (150809 => 150810)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.idl	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.idl	2013-05-28 17:54:20 UTC (rev 150810)
@@ -23,8 +23,12 @@
  */
 
 [
-    Conditional=WEB_AUDIO
-] interface AudioNode {
+    Conditional=WEB_AUDIO,
+    JSGenerateToJSObject,
+    JSGenerateToNativeObject,
+    GenerateIsReachable=Impl,
+    EventTarget
+] interface AudioNode : EventTarget {
     readonly attribute AudioContext context;
     readonly attribute unsigned long numberOfInputs;
     readonly attribute unsigned long numberOfOutputs;
@@ -46,4 +50,11 @@
 
     void disconnect([Default=Undefined] optional unsigned long output)
         raises(DOMException);
+
+    void addEventListener(DOMString type, EventListener listener, optional boolean useCapture);
+
+    void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture);
+
+    boolean dispatchEvent(Event event)
+        raises(EventException);
 };

Modified: trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp (150809 => 150810)


--- trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp	2013-05-28 17:54:20 UTC (rev 150810)
@@ -263,16 +263,6 @@
     }
 }
 
-const AtomicString& ScriptProcessorNode::interfaceName() const
-{
-    return eventNames().interfaceForScriptProcessorNode;
-}
-
-ScriptExecutionContext* ScriptProcessorNode::scriptExecutionContext() const
-{
-    return const_cast<ScriptProcessorNode*>(this)->context()->scriptExecutionContext();
-}
-
 double ScriptProcessorNode::tailTime() const
 {
     return std::numeric_limits<double>::infinity();

Modified: trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h (150809 => 150810)


--- trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h	2013-05-28 17:54:20 UTC (rev 150810)
@@ -47,8 +47,7 @@
 // The "onaudioprocess" attribute is an event listener which will get called periodically with an AudioProcessingEvent which has
 // AudioBuffers for each input and output.
 
-// FIXME: EventTarget should be introduced at the base of the inheritance hierarchy (i.e., as a base class for AudioNode).
-class ScriptProcessorNode : public AudioNode, public EventTarget {
+class ScriptProcessorNode : public AudioNode {
 public:
     // bufferSize must be one of the following values: 256, 512, 1024, 2048, 4096, 8192, 16384.
     // 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 @@
     virtual void initialize();
     virtual void uninitialize();
 
-    // EventTarget
-    virtual const AtomicString& interfaceName() const;
-    virtual ScriptExecutionContext* scriptExecutionContext() const;
-    virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
-    virtual EventTargetData* ensureEventTargetData()  { return &m_eventTargetData; }
-
     size_t bufferSize() const { return m_bufferSize; }
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess);
-
-    // Reconcile ref/deref which are defined both in AudioNode and EventTarget.
-    using AudioNode::ref;
-    using AudioNode::deref;
     
 private:
     virtual double tailTime() const OVERRIDE;
@@ -95,10 +84,6 @@
     Vector<RefPtr<AudioBuffer> > m_inputBuffers;
     Vector<RefPtr<AudioBuffer> > m_outputBuffers;
 
-    virtual void refEventTarget() { ref(); }
-    virtual void derefEventTarget() { deref(); }
-    EventTargetData m_eventTargetData;
-
     size_t m_bufferSize;
     unsigned m_bufferReadWriteIndex;
     volatile bool m_isRequestOutstanding;

Modified: trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.idl (150809 => 150810)


--- trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.idl	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.idl	2013-05-28 17:54:20 UTC (rev 150810)
@@ -26,11 +26,10 @@
 [
     Conditional=WEB_AUDIO,
     JSGenerateToJSObject,
-    JSGenerateToNativeObject,
-    EventTarget
+    JSGenerateToNativeObject
 ] interface ScriptProcessorNode : AudioNode {
     // Rendering callback
     attribute EventListener onaudioprocess;
-    
+
     readonly attribute long bufferSize;
 };

Modified: trunk/Source/WebCore/dom/EventTarget.h (150809 => 150810)


--- trunk/Source/WebCore/dom/EventTarget.h	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/dom/EventTarget.h	2013-05-28 17:54:20 UTC (rev 150810)
@@ -40,6 +40,7 @@
 
 namespace WebCore {
 
+    class AudioNode;
     class AudioContext;
     class AudioTrackList;
     class DedicatedWorkerContext;

Modified: trunk/Source/WebCore/dom/EventTargetFactory.in (150809 => 150810)


--- trunk/Source/WebCore/dom/EventTargetFactory.in	2013-05-28 17:28:35 UTC (rev 150809)
+++ trunk/Source/WebCore/dom/EventTargetFactory.in	2013-05-28 17:54:20 UTC (rev 150810)
@@ -1,5 +1,6 @@
 namespace="EventTarget"
 
+AudioNode conditional=WEB_AUDIO
 AudioContext conditional=WEB_AUDIO
 AudioTrackList conditional=VIDEO_TRACK
 BatteryManager conditional=BATTERY_STATUS
@@ -14,7 +15,6 @@
 IDBOpenDBRequest conditional=INDEXED_DATABASE
 IDBRequest conditional=INDEXED_DATABASE
 IDBTransaction conditional=INDEXED_DATABASE
-ScriptProcessorNode conditional=WEB_AUDIO
 LocalMediaStream conditional=MEDIA_STREAM
 MediaKeySession conditional=ENCRYPTED_MEDIA_V2
 MediaController conditional=VIDEO
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to