зеркало из https://github.com/mozilla/gecko-dev.git
Bug 984253 part.4 Rename nsJSEventListener to mozilla::JSEventHandler r=smaug
This commit is contained in:
Родитель
41ae81eb58
Коммит
d1419e8935
|
@ -2968,7 +2968,7 @@ nsContentUtils::GetEventArgNames(int32_t aNameSpaceID,
|
|||
*aArgCount = sizeof(names)/sizeof(names[0]); \
|
||||
*aArgArray = names;
|
||||
|
||||
// nsJSEventListener is what does the arg magic for onerror, and it does
|
||||
// JSEventHandler is what does the arg magic for onerror, and it does
|
||||
// not seem to take the namespace into account. So we let onerror in all
|
||||
// namespaces get the 3 arg names.
|
||||
if (aEventName == nsGkAtoms::onerror) {
|
||||
|
|
|
@ -613,22 +613,22 @@ EventListenerManager::SetEventHandlerInternal(
|
|||
EventListenerFlags flags;
|
||||
flags.mListenerIsJSListener = true;
|
||||
|
||||
nsCOMPtr<nsJSEventListener> jsListener;
|
||||
nsCOMPtr<JSEventHandler> jsEventHandler;
|
||||
NS_NewJSEventHandler(mTarget, aName,
|
||||
aTypedHandler, getter_AddRefs(jsListener));
|
||||
EventListenerHolder listenerHolder(jsListener);
|
||||
aTypedHandler, getter_AddRefs(jsEventHandler));
|
||||
EventListenerHolder listenerHolder(jsEventHandler);
|
||||
AddEventListenerInternal(listenerHolder, eventType, aName, aTypeString,
|
||||
flags, true);
|
||||
|
||||
listener = FindEventHandler(eventType, aName, aTypeString);
|
||||
} else {
|
||||
nsJSEventListener* jsListener = listener->GetJSListener();
|
||||
MOZ_ASSERT(jsListener,
|
||||
"How can we have an event handler with no nsJSEventListener?");
|
||||
JSEventHandler* jsEventHandler = listener->GetJSEventHandler();
|
||||
MOZ_ASSERT(jsEventHandler,
|
||||
"How can we have an event handler with no JSEventHandler?");
|
||||
|
||||
bool same = jsListener->GetTypedEventHandler() == aTypedHandler;
|
||||
bool same = jsEventHandler->GetTypedEventHandler() == aTypedHandler;
|
||||
// Possibly the same listener, but update still the context and scope.
|
||||
jsListener->SetHandler(aTypedHandler);
|
||||
jsEventHandler->SetHandler(aTypedHandler);
|
||||
if (mTarget && !same && aName) {
|
||||
mTarget->EventListenerRemoved(aName);
|
||||
mTarget->EventListenerAdded(aName);
|
||||
|
@ -783,10 +783,10 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||
const nsAString* aBody,
|
||||
Element* aElement)
|
||||
{
|
||||
MOZ_ASSERT(aListener->GetJSListener());
|
||||
MOZ_ASSERT(aListener->GetJSEventHandler());
|
||||
MOZ_ASSERT(aListener->mHandlerIsString, "Why are we compiling a non-string JS listener?");
|
||||
nsJSEventListener* jsListener = aListener->GetJSListener();
|
||||
MOZ_ASSERT(!jsListener->GetTypedEventHandler().HasEventHandler(),
|
||||
JSEventHandler* jsEventHandler = aListener->GetJSEventHandler();
|
||||
MOZ_ASSERT(!jsEventHandler->GetTypedEventHandler().HasEventHandler(),
|
||||
"What is there to compile?");
|
||||
|
||||
nsresult result = NS_OK;
|
||||
|
@ -813,7 +813,7 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||
// <html:frameset> or <xul:window> or the like.
|
||||
// XXX I don't like that we have to reference content from
|
||||
// here. The alternative is to store the event handler string on
|
||||
// the nsJSEventListener itself, and that still doesn't address
|
||||
// the JSEventHandler itself, and that still doesn't address
|
||||
// the arg names issue.
|
||||
nsCOMPtr<Element> element = do_QueryInterface(mTarget);
|
||||
MOZ_ASSERT(element || aBody, "Where will we get our body?");
|
||||
|
@ -908,18 +908,18 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||
NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mTarget);
|
||||
if (jsListener->EventName() == nsGkAtoms::onerror && win) {
|
||||
if (jsEventHandler->EventName() == nsGkAtoms::onerror && win) {
|
||||
nsRefPtr<OnErrorEventHandlerNonNull> handlerCallback =
|
||||
new OnErrorEventHandlerNonNull(handler, /* aIncumbentGlobal = */ nullptr);
|
||||
jsListener->SetHandler(handlerCallback);
|
||||
} else if (jsListener->EventName() == nsGkAtoms::onbeforeunload && win) {
|
||||
jsEventHandler->SetHandler(handlerCallback);
|
||||
} else if (jsEventHandler->EventName() == nsGkAtoms::onbeforeunload && win) {
|
||||
nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handlerCallback =
|
||||
new OnBeforeUnloadEventHandlerNonNull(handler, /* aIncumbentGlobal = */ nullptr);
|
||||
jsListener->SetHandler(handlerCallback);
|
||||
jsEventHandler->SetHandler(handlerCallback);
|
||||
} else {
|
||||
nsRefPtr<EventHandlerNonNull> handlerCallback =
|
||||
new EventHandlerNonNull(handler, /* aIncumbentGlobal = */ nullptr);
|
||||
jsListener->SetHandler(handlerCallback);
|
||||
jsEventHandler->SetHandler(handlerCallback);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1282,13 +1282,14 @@ EventListenerManager::GetTypedEventHandler(nsIAtom* aEventName,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsJSEventListener* jsListener = listener->GetJSListener();
|
||||
JSEventHandler* jsEventHandler = listener->GetJSEventHandler();
|
||||
|
||||
if (listener->mHandlerIsString) {
|
||||
CompileEventHandlerInternal(listener, nullptr, nullptr);
|
||||
}
|
||||
|
||||
const TypedEventHandler& typedHandler = jsListener->GetTypedEventHandler();
|
||||
const TypedEventHandler& typedHandler =
|
||||
jsEventHandler->GetTypedEventHandler();
|
||||
return typedHandler.HasEventHandler() ? &typedHandler : nullptr;
|
||||
}
|
||||
|
||||
|
@ -1299,9 +1300,10 @@ EventListenerManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|||
n += mListeners.SizeOfExcludingThis(aMallocSizeOf);
|
||||
uint32_t count = mListeners.Length();
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
nsJSEventListener* jsl = mListeners.ElementAt(i).GetJSListener();
|
||||
if (jsl) {
|
||||
n += jsl->SizeOfIncludingThis(aMallocSizeOf);
|
||||
JSEventHandler* jsEventHandler =
|
||||
mListeners.ElementAt(i).GetJSEventHandler();
|
||||
if (jsEventHandler) {
|
||||
n += jsEventHandler->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
|
@ -1313,10 +1315,10 @@ EventListenerManager::MarkForCC()
|
|||
uint32_t count = mListeners.Length();
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
const Listener& listener = mListeners.ElementAt(i);
|
||||
nsJSEventListener* jsListener = listener.GetJSListener();
|
||||
if (jsListener) {
|
||||
JSEventHandler* jsEventHandler = listener.GetJSEventHandler();
|
||||
if (jsEventHandler) {
|
||||
const TypedEventHandler& typedHandler =
|
||||
jsListener->GetTypedEventHandler();
|
||||
jsEventHandler->GetTypedEventHandler();
|
||||
if (typedHandler.HasEventHandler()) {
|
||||
JS::ExposeObjectToActiveJS(typedHandler.Ptr()->Callable());
|
||||
}
|
||||
|
|
|
@ -174,10 +174,10 @@ public:
|
|||
|
||||
EventListenerFlags mFlags;
|
||||
|
||||
nsJSEventListener* GetJSListener() const
|
||||
JSEventHandler* GetJSEventHandler() const
|
||||
{
|
||||
return (mListenerType == eJSEventListener) ?
|
||||
static_cast<nsJSEventListener*>(mListener.GetXPCOMCallback()) :
|
||||
static_cast<JSEventHandler*>(mListener.GetXPCOMCallback()) :
|
||||
nullptr;
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ public:
|
|||
~Listener()
|
||||
{
|
||||
if ((mListenerType == eJSEventListener) && mListener) {
|
||||
static_cast<nsJSEventListener*>(
|
||||
static_cast<JSEventHandler*>(
|
||||
mListener.GetXPCOMCallback())->Disconnect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,10 +101,10 @@ EventListenerInfo::GetJSVal(JSContext* aCx,
|
|||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsJSEventListener> jsl = do_QueryInterface(mListener);
|
||||
if (jsl && jsl->GetTypedEventHandler().HasEventHandler()) {
|
||||
nsCOMPtr<JSEventHandler> jsHandler = do_QueryInterface(mListener);
|
||||
if (jsHandler && jsHandler->GetTypedEventHandler().HasEventHandler()) {
|
||||
JS::Handle<JSObject*> handler =
|
||||
jsl->GetTypedEventHandler().Ptr()->Callable();
|
||||
jsHandler->GetTypedEventHandler().Ptr()->Callable();
|
||||
if (handler) {
|
||||
aAc.construct(aCx, handler);
|
||||
aJSVal.setObject(*handler);
|
||||
|
|
|
@ -23,29 +23,13 @@
|
|||
#include "mozilla/dom/ErrorEvent.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
namespace mozilla {
|
||||
|
||||
#include "nspr.h" // PR_fprintf
|
||||
using namespace dom;
|
||||
|
||||
class EventListenerCounter
|
||||
{
|
||||
public:
|
||||
~EventListenerCounter() {
|
||||
}
|
||||
};
|
||||
|
||||
static EventListenerCounter sEventListenerCounter;
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
/*
|
||||
* nsJSEventListener implementation
|
||||
*/
|
||||
nsJSEventListener::nsJSEventListener(nsISupports *aTarget,
|
||||
nsIAtom* aType,
|
||||
const TypedEventHandler& aTypedHandler)
|
||||
JSEventHandler::JSEventHandler(nsISupports* aTarget,
|
||||
nsIAtom* aType,
|
||||
const TypedEventHandler& aTypedHandler)
|
||||
: mEventName(aType)
|
||||
, mTypedHandler(aTypedHandler)
|
||||
{
|
||||
|
@ -53,26 +37,26 @@ nsJSEventListener::nsJSEventListener(nsISupports *aTarget,
|
|||
mTarget = base.get();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(JSEventHandler)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(JSEventHandler)
|
||||
tmp->mTypedHandler.ForgetHandler();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(JSEventHandler)
|
||||
if (MOZ_UNLIKELY(cb.WantDebugInfo()) && tmp->mEventName) {
|
||||
nsAutoCString name;
|
||||
name.AppendLiteral("nsJSEventListener handlerName=");
|
||||
name.AppendLiteral("JSEventHandler handlerName=");
|
||||
name.Append(
|
||||
NS_ConvertUTF16toUTF8(nsDependentAtomString(tmp->mEventName)).get());
|
||||
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name.get());
|
||||
} else {
|
||||
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSEventListener, tmp->mRefCnt.get())
|
||||
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(JSEventHandler, tmp->mRefCnt.get())
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mTypedHandler.Ptr())
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(JSEventHandler)
|
||||
if (tmp->IsBlackForCC()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -91,25 +75,25 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsJSEventListener)
|
|||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(JSEventHandler)
|
||||
return tmp->IsBlackForCC();
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(JSEventHandler)
|
||||
return tmp->IsBlackForCC();
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsJSEventListener)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JSEventHandler)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsJSEventListener)
|
||||
NS_INTERFACE_MAP_ENTRY(JSEventHandler)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(JSEventHandler)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(JSEventHandler)
|
||||
|
||||
bool
|
||||
nsJSEventListener::IsBlackForCC()
|
||||
JSEventHandler::IsBlackForCC()
|
||||
{
|
||||
// We can claim to be black if all the things we reference are
|
||||
// effectively black already.
|
||||
|
@ -118,7 +102,7 @@ nsJSEventListener::IsBlackForCC()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
JSEventHandler::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<EventTarget> target = do_QueryInterface(mTarget);
|
||||
if (!target || !mTypedHandler.HasEventHandler() ||
|
||||
|
@ -235,6 +219,10 @@ nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/*
|
||||
* Factory functions
|
||||
*/
|
||||
|
@ -243,11 +231,11 @@ nsresult
|
|||
NS_NewJSEventHandler(nsISupports* aTarget,
|
||||
nsIAtom* aEventType,
|
||||
const TypedEventHandler& aTypedHandler,
|
||||
nsJSEventListener** aReturn)
|
||||
JSEventHandler** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG(aEventType || !NS_IsMainThread());
|
||||
nsJSEventListener* it =
|
||||
new nsJSEventListener(aTarget, aEventType, aTypedHandler);
|
||||
JSEventHandler* it =
|
||||
new JSEventHandler(aTarget, aEventType, aTypedHandler);
|
||||
NS_ADDREF(*aReturn = it);
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -161,29 +161,27 @@ private:
|
|||
uintptr_t mBits;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* Implemented by script event listeners. Used to retrieve the script object
|
||||
* corresponding to the event target and the handler itself.
|
||||
*
|
||||
* Note, mTarget is a raw pointer and the owner of the nsJSEventListener object
|
||||
* Note, mTarget is a raw pointer and the owner of the JSEventHandler object
|
||||
* is expected to call Disconnect()!
|
||||
*/
|
||||
|
||||
#define NS_JSEVENTLISTENER_IID \
|
||||
#define NS_JSEVENTHANDLER_IID \
|
||||
{ 0x4f486881, 0x1956, 0x4079, \
|
||||
{ 0x8c, 0xa0, 0xf3, 0xbd, 0x60, 0x5c, 0xc2, 0x79 } }
|
||||
|
||||
class nsJSEventListener : public nsIDOMEventListener
|
||||
class JSEventHandler : public nsIDOMEventListener
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_JSEVENTLISTENER_IID)
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_JSEVENTHANDLER_IID)
|
||||
|
||||
nsJSEventListener(nsISupports* aTarget, nsIAtom* aType,
|
||||
const mozilla::TypedEventHandler& aTypedHandler);
|
||||
JSEventHandler(nsISupports* aTarget, nsIAtom* aType,
|
||||
const TypedEventHandler& aTypedHandler);
|
||||
|
||||
virtual ~nsJSEventListener()
|
||||
virtual ~JSEventHandler()
|
||||
{
|
||||
NS_ASSERTION(!mTarget, "Should have called Disconnect()!");
|
||||
}
|
||||
|
@ -203,7 +201,7 @@ public:
|
|||
mTarget = nullptr;
|
||||
}
|
||||
|
||||
const mozilla::TypedEventHandler& GetTypedEventHandler() const
|
||||
const TypedEventHandler& GetTypedEventHandler() const
|
||||
{
|
||||
return mTypedHandler;
|
||||
}
|
||||
|
@ -220,24 +218,24 @@ public:
|
|||
|
||||
// Set a handler for this event listener. The handler must already
|
||||
// be bound to the right target.
|
||||
void SetHandler(const mozilla::TypedEventHandler& aTypedHandler)
|
||||
void SetHandler(const TypedEventHandler& aTypedHandler)
|
||||
{
|
||||
mTypedHandler.SetHandler(aTypedHandler);
|
||||
}
|
||||
void SetHandler(mozilla::dom::EventHandlerNonNull* aHandler)
|
||||
void SetHandler(dom::EventHandlerNonNull* aHandler)
|
||||
{
|
||||
mTypedHandler.SetHandler(aHandler);
|
||||
}
|
||||
void SetHandler(mozilla::dom::OnBeforeUnloadEventHandlerNonNull* aHandler)
|
||||
void SetHandler(dom::OnBeforeUnloadEventHandlerNonNull* aHandler)
|
||||
{
|
||||
mTypedHandler.SetHandler(aHandler);
|
||||
}
|
||||
void SetHandler(mozilla::dom::OnErrorEventHandlerNonNull* aHandler)
|
||||
void SetHandler(dom::OnErrorEventHandlerNonNull* aHandler)
|
||||
{
|
||||
mTypedHandler.SetHandler(aHandler);
|
||||
}
|
||||
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
|
@ -250,22 +248,24 @@ public:
|
|||
// - mEventName: shared with others
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsJSEventListener)
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(JSEventHandler)
|
||||
|
||||
bool IsBlackForCC();
|
||||
|
||||
protected:
|
||||
nsISupports* mTarget;
|
||||
nsCOMPtr<nsIAtom> mEventName;
|
||||
mozilla::TypedEventHandler mTypedHandler;
|
||||
TypedEventHandler mTypedHandler;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsJSEventListener, NS_JSEVENTLISTENER_IID)
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(JSEventHandler, NS_JSEVENTHANDLER_IID)
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* Factory function. aHandler must already be bound to aTarget.
|
||||
|
@ -274,7 +274,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsJSEventListener, NS_JSEVENTLISTENER_IID)
|
|||
nsresult NS_NewJSEventHandler(nsISupports* aTarget,
|
||||
nsIAtom* aType,
|
||||
const mozilla::TypedEventHandler& aTypedHandler,
|
||||
nsJSEventListener** aReturn);
|
||||
mozilla::JSEventHandler** aReturn);
|
||||
|
||||
#endif // mozilla_JSEventHandler_h_
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
|||
scriptTarget = aTarget;
|
||||
}
|
||||
|
||||
// We're about to create a new nsJSEventListener, which means that we're
|
||||
// We're about to create a new JSEventHandler, which means that we're
|
||||
// responsible for pushing the context of the event target. See the similar
|
||||
// comment in nsEventManagerListener.cpp.
|
||||
nsCxPusher pusher;
|
||||
|
@ -325,15 +325,15 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
|
|||
TypedEventHandler typedHandler(handlerCallback);
|
||||
|
||||
// Execute it.
|
||||
nsCOMPtr<nsJSEventListener> eventListener;
|
||||
nsCOMPtr<JSEventHandler> jsEventHandler;
|
||||
rv = NS_NewJSEventHandler(scriptTarget, onEventAtom,
|
||||
typedHandler,
|
||||
getter_AddRefs(eventListener));
|
||||
getter_AddRefs(jsEventHandler));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Handle the event.
|
||||
eventListener->HandleEvent(aEvent);
|
||||
eventListener->Disconnect();
|
||||
jsEventHandler->HandleEvent(aEvent);
|
||||
jsEventHandler->Disconnect();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче