本文整理汇总了C++中Listener::GetJSListener方法的典型用法代码示例。如果您正苦于以下问题:C++ Listener::GetJSListener方法的具体用法?C++ Listener::GetJSListener怎么用?C++ Listener::GetJSListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Listener
的用法示例。
在下文中一共展示了Listener::GetJSListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listenerHolder
EventListenerManager::Listener*
EventListenerManager::SetEventHandlerInternal(
JS::Handle<JSObject*> aScopeObject,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents)
{
MOZ_ASSERT(aScopeObject || aHandler.HasEventHandler(),
"Must have one or the other!");
MOZ_ASSERT(aName || !aTypeString.IsEmpty());
uint32_t eventType = nsContentUtils::GetEventId(aName);
Listener* listener = FindEventHandler(eventType, aName, aTypeString);
if (!listener) {
// If we didn't find a script listener or no listeners existed
// create and add a new one.
EventListenerFlags flags;
flags.mListenerIsJSListener = true;
nsCOMPtr<nsIJSEventListener> jsListener;
NS_NewJSEventListener(aScopeObject, mTarget, aName,
aHandler, getter_AddRefs(jsListener));
EventListenerHolder listenerHolder(jsListener);
AddEventListenerInternal(listenerHolder, eventType, aName, aTypeString,
flags, true);
listener = FindEventHandler(eventType, aName, aTypeString);
} else {
nsIJSEventListener* jsListener = listener->GetJSListener();
MOZ_ASSERT(jsListener,
"How can we have an event handler with no nsIJSEventListener?");
bool same = jsListener->GetHandler() == aHandler;
// Possibly the same listener, but update still the context and scope.
jsListener->SetHandler(aHandler, aScopeObject);
if (mTarget && !same && aName) {
mTarget->EventListenerRemoved(aName);
mTarget->EventListenerAdded(aName);
}
}
// Set flag to indicate possible need for compilation later
listener->mHandlerIsString = !aHandler.HasEventHandler();
if (aPermitUntrustedEvents) {
listener->mFlags.mAllowUntrustedEvents = true;
}
return listener;
}
示例2: FindEventHandler
const nsEventHandler*
EventListenerManager::GetEventHandlerInternal(nsIAtom* aEventName,
const nsAString& aTypeString)
{
uint32_t eventType = nsContentUtils::GetEventId(aEventName);
Listener* listener = FindEventHandler(eventType, aEventName, aTypeString);
if (!listener) {
return nullptr;
}
nsIJSEventListener* jsListener = listener->GetJSListener();
if (listener->mHandlerIsString) {
CompileEventHandlerInternal(listener, nullptr, nullptr);
}
const nsEventHandler& handler = jsListener->GetHandler();
if (handler.HasEventHandler()) {
return &handler;
}
return nullptr;
}