There is an old weak reference implementation (i.e. not nsIWeakReference) called nsCWeakReference, which is only used by nsListControlFrame. It looks like this really doesn't need to use a weak reference at all, since the frame can just null out the event listener's back pointer from its destructor. Patch coming up (which will make the previous sentence make more sense)
Created attachment 138686 [details] [diff] [review] patch - remove nsCWeakReference.* - simplify the list control frame's event listener significantly by removing the internal XPCOM interface and nulling out the frame pointer when the frame goes away. - stop making nsListControlFrame claim to implement nsIDOM*Listener, and only forward the events the frame actually cares about to the frame.
Comment on attachment 138686 [details] [diff] [review] patch (if either if you want to r+sr, that would be good)
Comment on attachment 138686 [details] [diff] [review] patch r+sr=dbaron if you use nsRefPtr<nsListEventListener> mEventListener and simplify the casts (you'll need a one-step cast to cast to nsIDOMMouseListener* for the registration, and can remove the nsListEventListener* casts and the cast of the result of new). Or, alternatively, just remove the two two-step casts that do nothing. If you do the former, you may want to do separate (one-step, since nsIDOMMouseListener* -> nsIDOMEventListener* happens automatically) casts for the (Add|Remove)EventListenerByIID calls to pass the right interface, although that apparently doesn't matter.