Changeset 150810 in webkit


Ignore:
Timestamp:
May 28, 2013 10:54:20 AM (11 years ago)
Author:
jer.noble@apple.com
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:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r150803 r150810  
     12013-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
    1112013-05-28  Sergio Villar Senin  <svillar@igalia.com>
    212
  • trunk/LayoutTests/webaudio/audionode-expected.txt

    r137516 r150810  
    1717PASS exception thrown when connecting to other context's node.
    1818PASS exception thrown when creating audio context with not enough arguments.
     19PASS AudioNode is an EventTarget
    1920PASS successfullyParsed is true
    2021
  • trunk/LayoutTests/webaudio/audionode.html

    r121877 r150810  
    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}
  • trunk/Source/WebCore/ChangeLog

    r150809 r150810  
     12013-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
    1292013-05-28  Arvid Nilsson  <anilsson@rim.com>
    230
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp

    r148921 r150810  
    281281}
    282282
     283const AtomicString& AudioNode::interfaceName() const
     284{
     285    return eventNames().interfaceForAudioNode;
     286}
     287
     288ScriptExecutionContext* AudioNode::scriptExecutionContext() const
     289{
     290    return const_cast<AudioNode*>(this)->context()->scriptExecutionContext();
     291}
     292
    283293void AudioNode::processIfNecessary(size_t framesToProcess)
    284294{
    285295    ASSERT(context()->isAudioThread());
    286    
     296
    287297    if (!isInitialized())
    288298        return;
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.h

    r148921 r150810  
    2727
    2828#include "AudioBus.h"
     29#include "EventTarget.h"
    2930#include <wtf/Forward.h>
    3031#include <wtf/OwnPtr.h>
     
    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 {
     53class AudioNode : public EventTarget {
    5354public:
    5455    enum { ProcessingSizeInFrames = 128 };
     
    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
    181188protected:
    182189    // Inputs and outputs must be created before the AudioNode is initialized.
     
    200207    Vector<OwnPtr<AudioNodeOutput> > m_outputs;
    201208
     209    EventTargetData m_eventTargetData;
     210
    202211    double m_lastProcessingTime;
    203212    double m_lastNonSilentTime;
     
    215224#endif
    216225
     226    virtual void refEventTarget() OVERRIDE { ref(); }
     227    virtual void derefEventTarget() OVERRIDE { deref(); }
     228
    217229protected:
    218230    unsigned m_channelCount;
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.idl

    r149920 r150810  
    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;
     
    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};
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp

    r149817 r150810  
    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 
    276266double ScriptProcessorNode::tailTime() const
    277267{
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h

    r149817 r150810  
    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 {
     50class ScriptProcessorNode : public AudioNode {
    5251public:
    5352    // bufferSize must be one of the following values: 256, 512, 1024, 2048, 4096, 8192, 16384.
     
    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   
    8170private:
     
    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;
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.idl

    r149920 r150810  
    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};
  • trunk/Source/WebCore/dom/EventTarget.h

    r149173 r150810  
    4141namespace WebCore {
    4242
     43    class AudioNode;
    4344    class AudioContext;
    4445    class AudioTrackList;
  • trunk/Source/WebCore/dom/EventTargetFactory.in

    r149999 r150810  
    11namespace="EventTarget"
    22
     3AudioNode conditional=WEB_AUDIO
    34AudioContext conditional=WEB_AUDIO
    45AudioTrackList conditional=VIDEO_TRACK
     
    1516IDBRequest conditional=INDEXED_DATABASE
    1617IDBTransaction conditional=INDEXED_DATABASE
    17 ScriptProcessorNode conditional=WEB_AUDIO
    1818LocalMediaStream conditional=MEDIA_STREAM
    1919MediaKeySession conditional=ENCRYPTED_MEDIA_V2
Note: See TracChangeset for help on using the changeset viewer.