Bug 815454 - Clean up Traverse/Unlink of web audio. r=smaug

This commit is contained in:
Andrew McCreight 2012-11-27 15:08:22 -08:00
parent 0bda3d7c46
commit 6998222f29
8 changed files with 29 additions and 94 deletions

View File

@ -12,36 +12,26 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
template <typename T> inline void
static void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
TraverseElements(nsCycleCollectionTraversalCallback& cb, mozilla::dom::AudioNode::Output& aField,
const nsTArray<T>& array, const char* aName,
const char* name) unsigned aFlags)
{ {
for (uint32_t i = 0, length = array.Length(); i < length; ++i) { CycleCollectionNoteChild(aCallback, aField.mDestination.get(), aName, aFlags);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, name);
AudioNode* node = array[i].get();
cb.NoteXPCOMChild(node);
}
} }
NS_IMPL_CYCLE_COLLECTION_CLASS(AudioNode) inline void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
mozilla::dom::AudioNode::Input& aField,
const char* aName,
unsigned aFlags)
{
CycleCollectionNoteChild(aCallback, aField.mSource.get(), aName, aFlags);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioNode) NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_3(AudioNode,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext) mContext, mInputs, mOutputs)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputs)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOutputs)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
TraverseElements(cb, tmp->mInputs, "mInputs[i]");
TraverseElements(cb, tmp->mOutputs, "mOutputs[i]");
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(AudioNode)
NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioNode) NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioNode)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioNode) NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioNode)

View File

@ -81,11 +81,6 @@ public:
return ConvertibleToBool(mDestination && mInput != InvalidIndex); return ConvertibleToBool(mDestination && mInput != InvalidIndex);
} }
// Needed for the CC traversal
AudioNode* get() const {
return mDestination;
}
nsRefPtr<AudioNode> mDestination; nsRefPtr<AudioNode> mDestination;
// This is an index into mDestination->mInputs which specifies the Input // This is an index into mDestination->mInputs which specifies the Input
// object corresponding to this Output node. // object corresponding to this Output node.
@ -109,11 +104,6 @@ public:
return ConvertibleToBool(mSource && mOutput != InvalidIndex); return ConvertibleToBool(mSource && mOutput != InvalidIndex);
} }
// Needed for the CC traversal
AudioNode* get() const {
return mSource;
}
nsRefPtr<AudioNode> mSource; nsRefPtr<AudioNode> mSource;
// This is an index into mSource->mOutputs which specifies the Output // This is an index into mSource->mOutputs which specifies the Output
// object corresponding to this Input node. // object corresponding to this Input node.
@ -130,4 +120,3 @@ private:
} }
#endif #endif

View File

@ -10,17 +10,8 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(BiquadFilterNode) NS_IMPL_CYCLE_COLLECTION_INHERITED_3(BiquadFilterNode, AudioNode,
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BiquadFilterNode, AudioNode) mFrequency, mQ, mGain)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrequency)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mQ)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGain)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BiquadFilterNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrequency)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQ)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGain)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BiquadFilterNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BiquadFilterNode)
NS_INTERFACE_MAP_END_INHERITING(AudioNode) NS_INTERFACE_MAP_END_INHERITING(AudioNode)

View File

@ -10,13 +10,8 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(DelayNode) NS_IMPL_CYCLE_COLLECTION_INHERITED_1(DelayNode, AudioNode,
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DelayNode, AudioNode) mDelay)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDelay)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DelayNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDelay)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DelayNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DelayNode)
NS_INTERFACE_MAP_END_INHERITING(AudioNode) NS_INTERFACE_MAP_END_INHERITING(AudioNode)

View File

@ -10,23 +10,13 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(DynamicsCompressorNode) NS_IMPL_CYCLE_COLLECTION_INHERITED_6(DynamicsCompressorNode, AudioNode,
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DynamicsCompressorNode, AudioNode) mThreshold,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mThreshold) mKnee,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mKnee) mRatio,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRatio) mReduction,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReduction) mAttack,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttack) mRelease)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelease)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DynamicsCompressorNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mThreshold)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mKnee)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRatio)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReduction)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttack)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelease)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DynamicsCompressorNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DynamicsCompressorNode)
NS_INTERFACE_MAP_END_INHERITING(AudioNode) NS_INTERFACE_MAP_END_INHERITING(AudioNode)

View File

@ -10,13 +10,8 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(GainNode) NS_IMPL_CYCLE_COLLECTION_INHERITED_1(GainNode, AudioNode,
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(GainNode, AudioNode) mGain)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGain)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(GainNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGain)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GainNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GainNode)
NS_INTERFACE_MAP_END_INHERITING(AudioNode) NS_INTERFACE_MAP_END_INHERITING(AudioNode)

View File

@ -10,18 +10,6 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(PannerNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PannerNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PannerNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PannerNode)
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
NS_IMPL_ADDREF_INHERITED(PannerNode, AudioNode)
NS_IMPL_RELEASE_INHERITED(PannerNode, AudioNode)
PannerNode::PannerNode(AudioContext* aContext) PannerNode::PannerNode(AudioContext* aContext)
: AudioNode(aContext) : AudioNode(aContext)
, mPanningModel(PanningModelEnum::HRTF) , mPanningModel(PanningModelEnum::HRTF)

View File

@ -36,9 +36,6 @@ class PannerNode : public AudioNode
public: public:
explicit PannerNode(AudioContext* aContext); explicit PannerNode(AudioContext* aContext);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PannerNode, AudioNode)
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope, virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap); bool* aTriedToWrap);