Bug 738700 - unmark wrapped gray objects from nsISupports. r=smaug

This commit is contained in:
Andrew McCreight 2012-03-28 21:51:46 -07:00
parent 6b700b5814
commit a59c979d1b
6 changed files with 12 additions and 19 deletions

View File

@ -1110,9 +1110,7 @@ nsFrameMessageManager::MarkForCC()
{ {
PRUint32 len = mListeners.Length(); PRUint32 len = mListeners.Length();
for (PRUint32 i = 0; i < len; ++i) { for (PRUint32 i = 0; i < len; ++i) {
nsCOMPtr<nsIXPConnectWrappedJS> wjs = xpc_TryUnmarkWrappedGrayObject(mListeners[i].mListener);
do_QueryInterface(mListeners[i].mListener);
xpc_UnmarkGrayObject(wjs);
} }
return true; return true;
} }

View File

@ -4585,9 +4585,7 @@ void
nsGenericElement::MarkUserDataHandler(void* aObject, nsIAtom* aKey, nsGenericElement::MarkUserDataHandler(void* aObject, nsIAtom* aKey,
void* aChild, void* aData) void* aChild, void* aData)
{ {
nsCOMPtr<nsIXPConnectWrappedJS> wjs = xpc_TryUnmarkWrappedGrayObject(static_cast<nsISupports*>(aChild));
do_QueryInterface(static_cast<nsISupports*>(aChild));
xpc_UnmarkGrayObject(wjs);
} }
void void

View File

@ -199,11 +199,9 @@ private:
#define NS_DISCONNECT_EVENT_HANDLER(_event) \ #define NS_DISCONNECT_EVENT_HANDLER(_event) \
if (mOn##_event##Listener) { mOn##_event##Listener->Disconnect(); } if (mOn##_event##Listener) { mOn##_event##Listener->Disconnect(); }
#define NS_UNMARK_LISTENER_WRAPPER(_event) \ #define NS_UNMARK_LISTENER_WRAPPER(_event) \
if (tmp->mOn##_event##Listener) { \ if (tmp->mOn##_event##Listener) { \
nsCOMPtr<nsIXPConnectWrappedJS> wjs = \ xpc_TryUnmarkWrappedGrayObject(tmp->mOn##_event##Listener->GetInner()); \
do_QueryInterface(tmp->mOn##_event##Listener->GetInner()); \
xpc_UnmarkGrayObject(wjs); \
} }
#endif // nsDOMEventTargetHelper_h_ #endif // nsDOMEventTargetHelper_h_

View File

@ -1050,8 +1050,7 @@ nsEventListenerManager::UnmarkGrayJSListeners()
xpc_UnmarkGrayObject(jsl->GetHandler()); xpc_UnmarkGrayObject(jsl->GetHandler());
xpc_UnmarkGrayObject(jsl->GetEventScope()); xpc_UnmarkGrayObject(jsl->GetEventScope());
} else if (ls.mWrappedJS) { } else if (ls.mWrappedJS) {
nsCOMPtr<nsIXPConnectWrappedJS> wjs = do_QueryInterface(ls.mListener); xpc_TryUnmarkWrappedGrayObject(ls.mListener);
xpc_UnmarkGrayObject(wjs);
} }
} }
} }

View File

@ -860,11 +860,12 @@ xpc_MarkInCCGeneration(nsISupports* aVariant, PRUint32 aGeneration)
} }
void void
xpc_UnmarkGrayObject(nsIXPConnectWrappedJS* aWrappedJS) xpc_TryUnmarkWrappedGrayObject(nsISupports* aWrappedJS)
{ {
if (aWrappedJS) { nsCOMPtr<nsIXPConnectWrappedJS> wjs = do_QueryInterface(aWrappedJS);
if (wjs) {
// Unmarks gray JSObject. // Unmarks gray JSObject.
static_cast<nsXPCWrappedJS*>(aWrappedJS)->GetJSObject(); static_cast<nsXPCWrappedJS*>(wjs.get())->GetJSObject();
} }
} }

View File

@ -55,7 +55,6 @@
#include "nsTArray.h" #include "nsTArray.h"
class nsIPrincipal; class nsIPrincipal;
class nsIXPConnectWrappedJS;
struct nsDOMClassInfoData; struct nsDOMClassInfoData;
#ifndef BAD_TLS_INDEX #ifndef BAD_TLS_INDEX
@ -196,9 +195,9 @@ xpc_UnmarkGrayObject(JSObject *obj)
extern void extern void
xpc_MarkInCCGeneration(nsISupports* aVariant, PRUint32 aGeneration); xpc_MarkInCCGeneration(nsISupports* aVariant, PRUint32 aGeneration);
// Unmarks aWrappedJS's JSObject. // If aWrappedJS is a JS wrapper, unmark its JSObject.
extern void extern void
xpc_UnmarkGrayObject(nsIXPConnectWrappedJS* aWrappedJS); xpc_TryUnmarkWrappedGrayObject(nsISupports* aWrappedJS);
extern void extern void
xpc_UnmarkSkippableJSHolders(); xpc_UnmarkSkippableJSHolders();