Bug 720536 - unmark ELM listeners, r=mccr8

--HG--
extra : rebase_source : 9c4bdf80b23e4c95c114de83977f813f6c977516
This commit is contained in:
Olli Pettay 2012-01-26 15:45:12 +01:00
Родитель 3352edee98
Коммит 100aa0a448
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -104,4 +104,11 @@ protected:
nsCOMPtr<nsPIDOMWindow> mOwner; // Inner window. nsCOMPtr<nsPIDOMWindow> mOwner; // Inner window.
}; };
#define NS_UNMARK_LISTENER_WRAPPER(_event) \
if (tmp->mOn##_event##Listener) { \
nsCOMPtr<nsIXPConnectWrappedJS> wjs = \
do_QueryInterface(tmp->mOn##_event##Listener->GetInner()); \
xpc_UnmarkGrayObject(wjs); \
}
#endif // nsDOMEventTargetHelper_h_ #endif // nsDOMEventTargetHelper_h_

Просмотреть файл

@ -82,6 +82,7 @@
#include "nsDOMEvent.h" #include "nsDOMEvent.h"
#include "nsIContentSecurityPolicy.h" #include "nsIContentSecurityPolicy.h"
#include "nsJSEnvironment.h" #include "nsJSEnvironment.h"
#include "xpcpublic.h"
#include "sampler.h" #include "sampler.h"
using namespace mozilla::dom; using namespace mozilla::dom;
@ -240,9 +241,14 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
ls->mListener = aListener; ls->mListener = aListener;
ls->mEventType = aType; ls->mEventType = aType;
ls->mTypeAtom = aTypeAtom; ls->mTypeAtom = aTypeAtom;
ls->mWrappedJS = false;
ls->mFlags = aFlags; ls->mFlags = aFlags;
ls->mHandlerIsString = false; ls->mHandlerIsString = false;
nsCOMPtr<nsIXPConnectWrappedJS> wjs = do_QueryInterface(aListener);
if (wjs) {
ls->mWrappedJS = true;
}
if (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) { if (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
mMayHaveSystemGroupListeners = true; mMayHaveSystemGroupListeners = true;
} }
@ -1013,3 +1019,20 @@ nsEventListenerManager::SizeOf() const
} }
return size; return size;
} }
void
nsEventListenerManager::UnmarkGrayJSListeners()
{
PRUint32 count = mListeners.Length();
for (PRUint32 i = 0; i < count; ++i) {
const nsListenerStruct& ls = mListeners.ElementAt(i);
nsIJSEventListener* jsl = ls.GetJSListener();
if (jsl) {
xpc_UnmarkGrayObject(jsl->GetHandler());
xpc_UnmarkGrayObject(jsl->GetEventScope());
} else if (ls.mWrappedJS) {
nsCOMPtr<nsIXPConnectWrappedJS> wjs = do_QueryInterface(ls.mListener);
xpc_UnmarkGrayObject(wjs);
}
}
}

Просмотреть файл

@ -70,6 +70,7 @@ struct nsListenerStruct
nsCOMPtr<nsIAtom> mTypeAtom; nsCOMPtr<nsIAtom> mTypeAtom;
PRUint16 mFlags; PRUint16 mFlags;
bool mHandlerIsString; bool mHandlerIsString;
bool mWrappedJS;
nsIJSEventListener* GetJSListener() const { nsIJSEventListener* GetJSListener() const {
return (mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) ? return (mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) ?
@ -243,6 +244,9 @@ public:
bool MayHaveMouseEnterLeaveEventListener() { return mMayHaveMouseEnterLeaveEventListener; } bool MayHaveMouseEnterLeaveEventListener() { return mMayHaveMouseEnterLeaveEventListener; }
PRInt64 SizeOf() const; PRInt64 SizeOf() const;
void UnmarkGrayJSListeners();
protected: protected:
nsresult HandleEventSubType(nsListenerStruct* aListenerStruct, nsresult HandleEventSubType(nsListenerStruct* aListenerStruct,
nsIDOMEventListener* aListener, nsIDOMEventListener* aListener,