mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 950657. Give WebIDL callbacks an operator== that does the right thing. r=smaug
This commit is contained in:
parent
62323b2df8
commit
5636812c55
@ -102,6 +102,15 @@ protected:
|
||||
Init(aCallbackObject->mCallback, aCallbackObject->mIncumbentGlobal);
|
||||
}
|
||||
|
||||
bool operator==(const CallbackObject& aOther) const
|
||||
{
|
||||
JSObject* thisObj =
|
||||
js::UncheckedUnwrap(CallbackPreserveColor());
|
||||
JSObject* otherObj =
|
||||
js::UncheckedUnwrap(aOther.CallbackPreserveColor());
|
||||
return thisObj == otherObj;
|
||||
}
|
||||
|
||||
private:
|
||||
inline void Init(JSObject* aCallback, nsIGlobalObject* aIncumbentGlobal)
|
||||
{
|
||||
@ -304,11 +313,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject* thisObj =
|
||||
js::UncheckedUnwrap(GetWebIDLCallback()->CallbackPreserveColor());
|
||||
JSObject* otherObj =
|
||||
js::UncheckedUnwrap(aOtherCallback->CallbackPreserveColor());
|
||||
return thisObj == otherObj;
|
||||
return *GetWebIDLCallback() == *aOtherCallback;
|
||||
}
|
||||
|
||||
bool operator==(XPCOMCallbackT* aOtherCallback) const
|
||||
|
@ -10726,6 +10726,12 @@ class CGCallback(CGClass):
|
||||
realMethods.append(method)
|
||||
else:
|
||||
realMethods.extend(self.getMethodImpls(method))
|
||||
realMethods.append(
|
||||
ClassMethod("operator==", "bool",
|
||||
[Argument("const %s&" % name, "aOther")],
|
||||
inline=True, bodyInHeader=True,
|
||||
const=True,
|
||||
body=("return %s::operator==(aOther);" % baseName)))
|
||||
CGClass.__init__(self, name,
|
||||
bases=[ClassBase(baseName)],
|
||||
constructors=self.getConstructors(),
|
||||
|
@ -137,11 +137,8 @@ MediaQueryList::AddListener(MediaQueryListListener& aListener)
|
||||
RecomputeMatches();
|
||||
}
|
||||
|
||||
CallbackType callback(&aListener);
|
||||
|
||||
for (uint32_t i = 0; i < mCallbacks.Length(); ++i) {
|
||||
CallbackType thisCallback(mCallbacks[i]);
|
||||
if (callback == thisCallback) {
|
||||
if (aListener == *mCallbacks[i]) {
|
||||
// Already registered
|
||||
return;
|
||||
}
|
||||
@ -172,11 +169,8 @@ MediaQueryList::RemoveListener(nsIDOMMediaQueryListListener *aListener)
|
||||
void
|
||||
MediaQueryList::RemoveListener(MediaQueryListListener& aListener)
|
||||
{
|
||||
CallbackType callback(&aListener);
|
||||
|
||||
for (uint32_t i = 0; i < mCallbacks.Length(); ++i) {
|
||||
CallbackType thisCallback(mCallbacks[i]);
|
||||
if (callback == thisCallback) {
|
||||
if (aListener == *mCallbacks[i]) {
|
||||
mCallbacks.RemoveElementAt(i);
|
||||
if (!HasListeners()) {
|
||||
// See NS_ADDREF_THIS() in AddListener.
|
||||
|
@ -44,9 +44,6 @@ public:
|
||||
|
||||
nsISupports* GetParentObject() const;
|
||||
|
||||
typedef CallbackObjectHolder<mozilla::dom::MediaQueryListListener,
|
||||
nsIDOMMediaQueryListListener> CallbackType;
|
||||
|
||||
struct HandleChangeData {
|
||||
nsRefPtr<MediaQueryList> mql;
|
||||
nsCOMPtr<nsIDOMMediaQueryListListener> listener;
|
||||
|
Loading…
Reference in New Issue
Block a user