Bug 497178 - Make nsPIDOMEventTarget::GetListenerManager to return nsIEventListenerManager*, r+sr=peterv

--HG--
extra : rebase_source : e92146a2236fe857aff7b2a9b1516b30174b8d83
This commit is contained in:
Olli Pettay 2009-06-23 14:23:52 +03:00
parent 94a314575e
commit 1a534bf2c2
29 changed files with 221 additions and 363 deletions

View File

@ -78,8 +78,8 @@ PRBool
nsCoreUtils::HasListener(nsIContent *aContent, const nsAString& aEventType)
{
NS_ENSURE_TRUE(aContent, PR_FALSE);
nsCOMPtr<nsIEventListenerManager> listenerManager;
aContent->GetListenerManager(PR_FALSE, getter_AddRefs(listenerManager));
nsIEventListenerManager* listenerManager =
aContent->GetListenerManager(PR_FALSE);
return listenerManager && listenerManager->HasListenersFor(aEventType);
}

View File

@ -937,11 +937,9 @@ public:
* @param aNode The node for which to get the eventlistener manager.
* @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if
* one already exists.
* @param aResult [out] Set to the eventlistener manager for aNode.
*/
static nsresult GetListenerManager(nsINode *aNode,
PRBool aCreateIfNotFound,
nsIEventListenerManager **aResult);
static nsIEventListenerManager* GetListenerManager(nsINode* aNode,
PRBool aCreateIfNotFound);
/**
* Remove the eventlistener manager for aNode.

View File

@ -3389,8 +3389,7 @@ nsContentUtils::HasMutationListeners(nsINode* aNode,
if (aNode->IsInDoc()) {
nsCOMPtr<nsPIDOMEventTarget> piTarget(do_QueryInterface(window));
if (piTarget) {
nsCOMPtr<nsIEventListenerManager> manager;
piTarget->GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsIEventListenerManager* manager = piTarget->GetListenerManager(PR_FALSE);
if (manager) {
PRBool hasListeners = PR_FALSE;
manager->HasMutationListeners(&hasListeners);
@ -3405,8 +3404,7 @@ nsContentUtils::HasMutationListeners(nsINode* aNode,
// might not be in our chain. If we don't have a window, we might have a
// mutation listener. Check quickly to see.
while (aNode) {
nsCOMPtr<nsIEventListenerManager> manager;
aNode->GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsIEventListenerManager* manager = aNode->GetListenerManager(PR_FALSE);
if (manager) {
PRBool hasListeners = PR_FALSE;
manager->HasMutationListeners(&hasListeners);
@ -3450,22 +3448,19 @@ nsContentUtils::TraverseListenerManager(nsINode *aNode,
}
}
nsresult
nsIEventListenerManager*
nsContentUtils::GetListenerManager(nsINode *aNode,
PRBool aCreateIfNotFound,
nsIEventListenerManager **aResult)
PRBool aCreateIfNotFound)
{
*aResult = nsnull;
if (!aCreateIfNotFound && !aNode->HasFlag(NODE_HAS_LISTENERMANAGER)) {
return NS_OK;
return nsnull;
}
if (!sEventListenerManagersHash.ops) {
// We're already shut down, don't bother creating an event listener
// manager.
return NS_ERROR_NOT_AVAILABLE;
return nsnull;
}
if (!aCreateIfNotFound) {
@ -3474,10 +3469,9 @@ nsContentUtils::GetListenerManager(nsINode *aNode,
(PL_DHashTableOperate(&sEventListenerManagersHash, aNode,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
*aResult = entry->mListenerManager;
NS_ADDREF(*aResult);
return entry->mListenerManager;
}
return NS_OK;
return nsnull;
}
EventListenerManagerMapEntry *entry =
@ -3486,7 +3480,7 @@ nsContentUtils::GetListenerManager(nsINode *aNode,
PL_DHASH_ADD));
if (!entry) {
return NS_ERROR_OUT_OF_MEMORY;
return nsnull;
}
if (!entry->mListenerManager) {
@ -3496,7 +3490,7 @@ nsContentUtils::GetListenerManager(nsINode *aNode,
if (NS_FAILED(rv)) {
PL_DHashTableRawRemove(&sEventListenerManagersHash, entry);
return rv;
return nsnull;
}
entry->mListenerManager->SetListenerTarget(aNode);
@ -3504,9 +3498,7 @@ nsContentUtils::GetListenerManager(nsINode *aNode,
aNode->SetFlags(NODE_HAS_LISTENERMANAGER);
}
NS_ADDREF(*aResult = entry->mListenerManager);
return NS_OK;
return entry->mListenerManager;
}
/* static */

View File

@ -757,46 +757,37 @@ nsDOMAttribute::DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
aPresContext, aEventStatus);
}
nsresult
nsDOMAttribute::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult)
nsIEventListenerManager*
nsDOMAttribute::GetListenerManager(PRBool aCreateIfNotFound)
{
return nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult);
return nsContentUtils::GetListenerManager(this, aCreateIfNotFound);
}
nsresult
nsDOMAttribute::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
nsDOMAttribute::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_FALSE, getter_AddRefs(elm));
if (elm) {
return elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return NS_OK;
nsIEventListenerManager* elm = GetListenerManager(PR_FALSE);
return elm ?
elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE) :
NS_OK;
}
nsresult
nsDOMAttribute::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->GetSystemEventGroupLM(aGroup);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->GetSystemEventGroupLM(aGroup);
}
nsresult

View File

@ -104,8 +104,7 @@ public:
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -6016,42 +6016,27 @@ nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
return nsINode::GetOwnerDocument(aOwnerDocument);
}
nsresult
nsDocument::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aInstancePtrResult)
nsIEventListenerManager*
nsDocument::GetListenerManager(PRBool aCreateIfNotFound)
{
if (mListenerManager) {
*aInstancePtrResult = mListenerManager;
NS_ADDREF(*aInstancePtrResult);
return NS_OK;
}
if (!aCreateIfNotFound) {
*aInstancePtrResult = nsnull;
return NS_OK;
if (mListenerManager || !aCreateIfNotFound) {
return mListenerManager;
}
nsresult rv = NS_NewEventListenerManager(getter_AddRefs(mListenerManager));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, nsnull);
mListenerManager->SetListenerTarget(static_cast<nsIDocument *>(this));
*aInstancePtrResult = mListenerManager;
NS_ADDREF(*aInstancePtrResult);
return NS_OK;
return mListenerManager;
}
nsresult
nsDocument::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
{
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_SUCCEEDED(GetListenerManager(PR_TRUE, getter_AddRefs(manager))) &&
manager) {
return manager->GetSystemEventGroupLM(aGroup);
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
return manager->GetSystemEventGroupLM(aGroup);
}
nsresult
@ -6091,28 +6076,19 @@ nsresult
nsDocument::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(PR_TRUE, getter_AddRefs(manager));
if (manager) {
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
return NS_OK;
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
return manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
nsDocument::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
if (!mListenerManager) {
return NS_ERROR_FAILURE;
}
mListenerManager->RemoveEventListenerByIID(aListener, aIID,
NS_EVENT_FLAG_BUBBLE);
return NS_OK;
return mListenerManager ?
mListenerManager->RemoveEventListenerByIID(aListener, aIID,
NS_EVENT_FLAG_BUBBLE) :
NS_OK;
}
nsresult
@ -6157,17 +6133,10 @@ nsDocument::AddGroupedEventListener(const nsAString& aType,
PRBool aUseCapture,
nsIDOMEventGroup *aEvtGrp)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(manager));
if (NS_SUCCEEDED(rv) && manager) {
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
return NS_OK;
}
return rv;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
return manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
}
NS_IMETHODIMP
@ -6176,14 +6145,11 @@ nsDocument::RemoveGroupedEventListener(const nsAString& aType,
PRBool aUseCapture,
nsIDOMEventGroup *aEvtGrp)
{
if (!mListenerManager) {
return NS_ERROR_FAILURE;
if (mListenerManager) {
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
mListenerManager->RemoveEventListenerByType(aListener, aType, flags,
aEvtGrp);
}
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
mListenerManager->RemoveEventListenerByType(aListener, aType, flags,
aEvtGrp);
return NS_OK;
}
@ -6204,9 +6170,8 @@ nsDocument::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture, PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(manager));
NS_ENSURE_SUCCESS(rv, rv);
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
@ -6851,8 +6816,8 @@ nsDocument::CanSavePresentation(nsIRequest *aNewRequest)
// Check our event listener manager for unload/beforeunload listeners.
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(mScriptGlobalObject);
if (piTarget) {
nsCOMPtr<nsIEventListenerManager> manager;
piTarget->GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsIEventListenerManager* manager =
piTarget->GetListenerManager(PR_FALSE);
if (manager && manager->HasUnloadListeners()) {
return PR_FALSE;
}

View File

@ -816,8 +816,7 @@ public:
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -686,46 +686,37 @@ nsGenericDOMDataNode::DispatchDOMEvent(nsEvent* aEvent,
aPresContext, aEventStatus);
}
nsresult
nsGenericDOMDataNode::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult)
nsIEventListenerManager*
nsGenericDOMDataNode::GetListenerManager(PRBool aCreateIfNotFound)
{
return nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult);
return nsContentUtils::GetListenerManager(this, aCreateIfNotFound);
}
nsresult
nsGenericDOMDataNode::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
nsGenericDOMDataNode::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_FALSE, getter_AddRefs(elm));
if (elm) {
return elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return NS_OK;
nsIEventListenerManager* elm = GetListenerManager(PR_FALSE);
return elm ?
elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE) :
NS_OK;
}
nsresult
nsGenericDOMDataNode::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->GetSystemEventGroupLM(aGroup);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->GetSystemEventGroupLM(aGroup);
}
PRUint32

View File

@ -172,8 +172,7 @@ public:
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -251,46 +251,37 @@ nsINode::UnsetProperty(PRUint16 aCategory, nsIAtom *aPropertyName,
aStatus);
}
nsresult
nsGenericElement::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult)
nsIEventListenerManager*
nsGenericElement::GetListenerManager(PRBool aCreateIfNotFound)
{
return nsContentUtils::GetListenerManager(this, aCreateIfNotFound, aResult);
return nsContentUtils::GetListenerManager(this, aCreateIfNotFound);
}
nsresult
nsGenericElement::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
nsGenericElement::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_FALSE, getter_AddRefs(elm));
if (elm) {
return elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return NS_OK;
nsIEventListenerManager* elm = GetListenerManager(PR_FALSE);
return elm ?
elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE) :
NS_OK;
}
nsresult
nsGenericElement::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->GetSystemEventGroupLM(aGroup);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->GetSystemEventGroupLM(aGroup);
}
nsINode::nsSlots*
@ -1618,11 +1609,9 @@ nsDOMEventRTTearoff::LastRelease()
nsresult
nsDOMEventRTTearoff::GetDOM3EventTarget(nsIDOM3EventTarget **aTarget)
{
nsCOMPtr<nsIEventListenerManager> listener_manager;
nsresult rv =
mNode->GetListenerManager(PR_TRUE, getter_AddRefs(listener_manager));
NS_ENSURE_SUCCESS(rv, rv);
nsIEventListenerManager* listener_manager =
mNode->GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(listener_manager);
return CallQueryInterface(listener_manager, aTarget);
}
@ -1662,11 +1651,8 @@ nsDOMEventRTTearoff::RemoveEventListener(const nsAString& aType,
NS_IMETHODIMP
nsDOMEventRTTearoff::DispatchEvent(nsIDOMEvent *aEvt, PRBool* _retval)
{
nsCOMPtr<nsIEventListenerManager> listener_manager;
nsresult rv =
mNode->GetListenerManager(PR_TRUE, getter_AddRefs(listener_manager));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(listener_manager);
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(mNode->GetListenerManager(PR_TRUE));
NS_ENSURE_STATE(target);
return target->DispatchEvent(aEvt, _retval);
}
@ -1719,10 +1705,9 @@ nsDOMEventRTTearoff::AddEventListener(const nsAString& aType,
PRBool aUseCapture,
PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> listener_manager;
nsresult rv =
mNode->GetListenerManager(PR_TRUE, getter_AddRefs(listener_manager));
NS_ENSURE_SUCCESS(rv, rv);
nsIEventListenerManager* listener_manager =
mNode->GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(listener_manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
@ -4136,21 +4121,16 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aEventName,
PRBool defer = PR_TRUE;
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetEventListenerManagerForAttr(getter_AddRefs(manager),
getter_AddRefs(target),
&defer);
NS_ENSURE_SUCCESS(rv, rv);
GetEventListenerManagerForAttr(getter_AddRefs(manager),
getter_AddRefs(target),
&defer);
NS_ENSURE_STATE(manager);
if (manager) {
defer = defer && aDefer; // only defer if everyone agrees...
PRUint32 lang = GetScriptTypeID();
rv =
manager->AddScriptEventListener(target, aEventName, aValue, lang, defer,
!nsContentUtils::IsChromeDoc(ownerDoc));
}
return rv;
defer = defer && aDefer; // only defer if everyone agrees...
PRUint32 lang = GetScriptTypeID();
return
manager->AddScriptEventListener(target, aEventName, aValue, lang, defer,
!nsContentUtils::IsChromeDoc(ownerDoc));
}
@ -4390,12 +4370,12 @@ nsGenericElement::GetEventListenerManagerForAttr(nsIEventListenerManager** aMana
nsISupports** aTarget,
PRBool* aDefer)
{
nsresult rv = GetListenerManager(PR_TRUE, aManager);
if (NS_SUCCEEDED(rv)) {
NS_ADDREF(*aTarget = static_cast<nsIContent*>(this));
}
*aManager = GetListenerManager(PR_TRUE);
*aDefer = PR_TRUE;
return rv;
NS_ENSURE_STATE(*aManager);
NS_ADDREF(*aManager);
NS_ADDREF(*aTarget = static_cast<nsIContent*>(this));
return NS_OK;
}
nsGenericElement::nsAttrInfo

View File

@ -360,8 +360,7 @@ public:
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -222,9 +222,8 @@ nsNodeUtils::LastRelease(nsINode* aNode)
if (aNode->HasFlag(NODE_HAS_LISTENERMANAGER)) {
#ifdef DEBUG
if (nsContentUtils::IsInitialized()) {
nsCOMPtr<nsIEventListenerManager> manager;
nsContentUtils::GetListenerManager(aNode, PR_FALSE,
getter_AddRefs(manager));
nsIEventListenerManager* manager =
nsContentUtils::GetListenerManager(aNode, PR_FALSE);
if (!manager) {
NS_ERROR("Huh, our bit says we have a listener manager list, "
"but there's nothing in the hash!?!!");
@ -583,8 +582,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
nsPIDOMWindow* window = newDoc->GetInnerWindow();
if (window) {
nsCOMPtr<nsIEventListenerManager> elm;
aNode->GetListenerManager(PR_FALSE, getter_AddRefs(elm));
nsIEventListenerManager* elm = aNode->GetListenerManager(PR_FALSE);
if (elm) {
window->SetMutationListeners(elm->MutationListenerBits());
if (elm->MayHavePaintEventListener()) {

View File

@ -50,10 +50,10 @@ class nsIDOMEventListener;
class nsIDOMEventGroup;
class nsIScriptContext;
// 25982813-af2e-4ab6-b512-e6c6ada6d0ec
// e6579895-a23c-4afc-872a-d53da71def5d
#define NS_PIDOMEVENTTARGET_IID \
{ 0x358f2990, 0x5107, 0x49ba, \
{ 0x88, 0x94, 0x14, 0x34, 0x86, 0xd5, 0x99, 0x85 } }
{ 0xe6579895, 0xa23c, 0x4afc, \
{ 0x87, 0x2a, 0xd5, 0x3d, 0xa7, 0x1d, 0xef, 0x5d } }
class nsPIDOMEventTarget : public nsISupports
{
@ -137,12 +137,10 @@ public:
/**
* Get the event listener manager, the guy you talk to to register for events
* on this node.
* @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if
* one already exists. [IN]
* @param aResult The event listener manager [OUT]
* @param aMayCreate If PR_FALSE, returns a listener manager only if
* one already exists.
*/
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult) = 0;
virtual nsIEventListenerManager* GetListenerManager(PRBool aMayCreate) = 0;
/**
* Add an event listener for nsIID.

View File

@ -111,8 +111,7 @@ nsDOMEventTargetHelper::RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_FALSE, getter_AddRefs(elm));
nsIEventListenerManager* elm = GetListenerManager(PR_FALSE);
if (elm) {
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
elm->RemoveEventListenerByType(aListener, aType, flags, nsnull);
@ -127,8 +126,7 @@ nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,
PRBool aUseCapture,
PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_TRUE, getter_AddRefs(elm));
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted) {
@ -220,57 +218,46 @@ nsDOMEventTargetHelper::DispatchDOMEvent(nsEvent* aEvent,
aEventStatus);
}
nsresult
nsDOMEventTargetHelper::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult)
nsIEventListenerManager*
nsDOMEventTargetHelper::GetListenerManager(PRBool aCreateIfNotFound)
{
if (!mListenerManager) {
if (!aCreateIfNotFound) {
*aResult = nsnull;
return NS_OK;
return nsnull;
}
nsresult rv = NS_NewEventListenerManager(getter_AddRefs(mListenerManager));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, nsnull);
mListenerManager->SetListenerTarget(static_cast<nsPIDOMEventTarget*>(this));
}
NS_ADDREF(*aResult = mListenerManager);
return NS_OK;
return mListenerManager;
}
nsresult
nsDOMEventTargetHelper::AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return NS_OK;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
nsDOMEventTargetHelper::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> elm;
GetListenerManager(PR_FALSE, getter_AddRefs(elm));
if (elm) {
return elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
return NS_OK;
nsIEventListenerManager* elm = GetListenerManager(PR_FALSE);
return elm ?
elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE) :
NS_OK;
}
nsresult
nsDOMEventTargetHelper::GetSystemEventGroup(nsIDOMEventGroup** aGroup)
{
nsCOMPtr<nsIEventListenerManager> elm;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(elm));
if (elm) {
return elm->GetSystemEventGroupLM(aGroup);
}
return rv;
nsIEventListenerManager* elm = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(elm);
return elm->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*

View File

@ -85,8 +85,7 @@ public:
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -233,7 +233,7 @@ nsEventTargetChainItem::HandleEvent(nsEventChainPostVisitor& aVisitor,
if (!aMayHaveNewListenerManagers) {
return NS_OK;
}
mTarget->GetListenerManager(PR_FALSE, getter_AddRefs(mManager));
mManager = mTarget->GetListenerManager(PR_FALSE);
}
if (mManager) {
NS_ASSERTION(aVisitor.mEvent->currentTarget == nsnull,

View File

@ -527,6 +527,7 @@ nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener,
(EVENT_TYPE_EQUALS(ls, aType, aUserType) ||
(!(ls->mEventType) &&
EVENT_TYPE_DATA_EQUALS(ls->mTypeData, aTypeData)))) {
nsRefPtr<nsEventListenerManager> kungFuDeathGrip = this;
mListeners.RemoveElementAt(i);
mNoListenerForEvent = NS_EVENT_TYPE_NULL;
mNoListenerForEventAtom = nsnull;

View File

@ -1083,10 +1083,11 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIEventListenerManager** a
nsCOMPtr<nsPIDOMEventTarget> piTarget(do_QueryInterface(win));
NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
rv = piTarget->GetListenerManager(PR_TRUE, aManager);
*aManager = piTarget->GetListenerManager(PR_TRUE);
if (NS_SUCCEEDED(rv)) {
if (*aManager) {
NS_ADDREF(*aTarget = win);
NS_ADDREF(*aManager);
}
*aDefer = PR_FALSE;
} else {
@ -1145,9 +1146,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
// Check for event handlers
if (aNameSpaceID == kNameSpaceID_None) {
if (nsContentUtils::IsEventAttributeName(aAttribute, EventNameType_HTML)) {
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsIEventListenerManager* manager = GetListenerManager(PR_FALSE);
if (manager) {
manager->RemoveScriptEventListener(aAttribute);
}

View File

@ -500,8 +500,7 @@ nsSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
mContentStyleRule = nsnull;
if (IsEventName(aName)) {
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsIEventListenerManager* manager = GetListenerManager(PR_FALSE);
if (manager) {
nsIAtom* eventName = GetEventNameForAttr(aName);
manager->RemoveScriptEventListener(eventName);

View File

@ -835,8 +835,8 @@ nsXBLBinding::InstallEventHandlers()
nsXBLPrototypeHandler* handlerChain = mPrototypeBinding->GetPrototypeHandlers();
if (handlerChain) {
nsCOMPtr<nsIEventListenerManager> manager;
mBoundElement->GetListenerManager(PR_TRUE, getter_AddRefs(manager));
nsIEventListenerManager* manager =
mBoundElement->GetListenerManager(PR_TRUE);
if (!manager)
return;
@ -996,8 +996,8 @@ nsXBLBinding::UnhookEventHandlers()
nsXBLPrototypeHandler* handlerChain = mPrototypeBinding->GetPrototypeHandlers();
if (handlerChain) {
nsCOMPtr<nsIEventListenerManager> manager;
mBoundElement->GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsCOMPtr<nsIEventListenerManager> manager =
mBoundElement->GetListenerManager(PR_FALSE);
if (!manager) {
return;
}

View File

@ -508,12 +508,12 @@ nsXULElement::GetEventListenerManagerForAttr(nsIEventListenerManager** aManager,
if (!piTarget)
return NS_ERROR_UNEXPECTED;
nsresult rv = piTarget->GetListenerManager(PR_TRUE, aManager);
if (NS_SUCCEEDED(rv)) {
NS_ADDREF(*aTarget = window);
}
*aDefer = PR_FALSE;
return rv;
*aManager = piTarget->GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(*aManager);
NS_ADDREF(*aManager);
NS_ADDREF(*aTarget = window);
return NS_OK;
}
return nsGenericElement::GetEventListenerManagerForAttr(aManager,

View File

@ -7333,8 +7333,7 @@ nsEventReceiverSH::RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
return NS_OK;
}
nsCOMPtr<nsIEventListenerManager> manager;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(manager));
nsIEventListenerManager* manager = piTarget->GetListenerManager(PR_TRUE);
NS_ENSURE_TRUE(manager, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIAtom> atom(do_GetAtom(nsDependentJSString(id)));

View File

@ -328,18 +328,18 @@ static PRBool gDOMWindowDumpEnabled = PR_FALSE;
// Same as FORWARD_TO_INNER, but this will create a fresh inner if an
// inner doesn't already exists.
#define FORWARD_TO_INNER_CREATE(method, args) \
#define FORWARD_TO_INNER_CREATE(method, args, err_rval) \
PR_BEGIN_MACRO \
if (IsOuterWindow()) { \
if (!mInnerWindow) { \
if (mIsClosed) { \
return NS_ERROR_NOT_AVAILABLE; \
return err_rval; \
} \
nsCOMPtr<nsIDOMDocument> doc; \
nsresult fwdic_nr = GetDocument(getter_AddRefs(doc)); \
NS_ENSURE_SUCCESS(fwdic_nr, fwdic_nr); \
NS_ENSURE_SUCCESS(fwdic_nr, err_rval); \
if (!mInnerWindow) { \
return NS_ERROR_NOT_AVAILABLE; \
return err_rval; \
} \
} \
return GetCurrentInnerWindowInternal()->method args; \
@ -6336,7 +6336,8 @@ nsGlobalWindow::AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
FORWARD_TO_INNER_CREATE(AddEventListener, (aType, aListener, aUseCapture));
FORWARD_TO_INNER_CREATE(AddEventListener, (aType, aListener, aUseCapture),
NS_ERROR_NOT_AVAILABLE);
return AddEventListener(aType, aListener, aUseCapture,
!nsContentUtils::IsChromeDoc(mDoc));
@ -6387,17 +6388,13 @@ nsGlobalWindow::AddGroupedEventListener(const nsAString & aType,
nsIDOMEventGroup *aEvtGrp)
{
FORWARD_TO_INNER_CREATE(AddGroupedEventListener,
(aType, aListener, aUseCapture, aEvtGrp));
(aType, aListener, aUseCapture, aEvtGrp),
NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_SUCCEEDED(GetListenerManager(PR_TRUE, getter_AddRefs(manager)))) {
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
return NS_OK;
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
return manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
}
NS_IMETHODIMP
@ -6437,9 +6434,8 @@ nsGlobalWindow::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture, PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(manager));
NS_ENSURE_SUCCESS(rv, rv);
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
@ -6454,13 +6450,9 @@ nsresult
nsGlobalWindow::AddEventListenerByIID(nsIDOMEventListener* aListener,
const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_SUCCEEDED(GetListenerManager(PR_TRUE, getter_AddRefs(manager)))) {
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
return NS_OK;
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
return manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
@ -6478,42 +6470,35 @@ nsGlobalWindow::RemoveEventListenerByIID(nsIDOMEventListener* aListener,
return NS_ERROR_FAILURE;
}
nsresult
nsGlobalWindow::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult)
nsIEventListenerManager*
nsGlobalWindow::GetListenerManager(PRBool aCreateIfNotFound)
{
FORWARD_TO_INNER_CREATE(GetListenerManager, (aCreateIfNotFound, aResult));
FORWARD_TO_INNER_CREATE(GetListenerManager, (aCreateIfNotFound), nsnull);
if (!mListenerManager) {
if (!aCreateIfNotFound) {
*aResult = nsnull;
return NS_OK;
return nsnull;
}
static NS_DEFINE_CID(kEventListenerManagerCID,
NS_EVENTLISTENERMANAGER_CID);
nsresult rv;
mListenerManager = do_CreateInstance(kEventListenerManagerCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mListenerManager->SetListenerTarget(
static_cast<nsPIDOMEventTarget*>(this));
mListenerManager = do_CreateInstance(kEventListenerManagerCID);
if (mListenerManager) {
mListenerManager->SetListenerTarget(
static_cast<nsPIDOMEventTarget*>(this));
}
}
NS_ADDREF(*aResult = mListenerManager);
return NS_OK;
return mListenerManager;
}
nsresult
nsGlobalWindow::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
{
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_SUCCEEDED(GetListenerManager(PR_TRUE, getter_AddRefs(manager))) &&
manager) {
return manager->GetSystemEventGroupLM(aGroup);
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
return manager->GetSystemEventGroupLM(aGroup);
}
nsIScriptContext*

View File

@ -327,8 +327,7 @@ public:
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual NS_HIDDEN_(nsresult) GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual NS_HIDDEN_(nsIEventListenerManager*) GetListenerManager(PRBool aCreateIfNotFound);
virtual NS_HIDDEN_(nsresult) AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual NS_HIDDEN_(nsresult) RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -126,14 +126,10 @@ NS_IMETHODIMP
nsWindowRoot::AddGroupedEventListener(const nsAString & aType, nsIDOMEventListener *aListener,
PRBool aUseCapture, nsIDOMEventGroup *aEvtGrp)
{
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_SUCCEEDED(GetListenerManager(PR_TRUE, getter_AddRefs(manager)))) {
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
return NS_OK;
}
return NS_ERROR_FAILURE;
nsCOMPtr<nsIEventListenerManager> manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
return manager->AddEventListenerByType(aListener, aType, flags, aEvtGrp);
}
NS_IMETHODIMP
@ -142,10 +138,10 @@ nsWindowRoot::RemoveGroupedEventListener(const nsAString & aType, nsIDOMEventLis
{
if (mListenerManager) {
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
mListenerManager->RemoveEventListenerByType(aListener, aType, flags, aEvtGrp);
return NS_OK;
return mListenerManager->RemoveEventListenerByType(aListener, aType, flags,
aEvtGrp);
}
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_IMETHODIMP
@ -165,9 +161,8 @@ nsWindowRoot::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture, PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(PR_TRUE, getter_AddRefs(manager));
NS_ENSURE_SUCCESS(rv, rv);
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
@ -181,57 +176,46 @@ nsWindowRoot::AddEventListener(const nsAString& aType,
nsresult
nsWindowRoot::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(PR_TRUE, getter_AddRefs(manager));
if (manager) {
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
return NS_OK;
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
return manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
}
nsresult
nsWindowRoot::RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
{
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(PR_TRUE, getter_AddRefs(manager));
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
if (manager) {
manager->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
return NS_OK;
return manager->RemoveEventListenerByIID(aListener, aIID,
NS_EVENT_FLAG_BUBBLE);
}
return NS_ERROR_FAILURE;
return NS_OK;
}
nsresult
nsWindowRoot::GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult)
nsIEventListenerManager*
nsWindowRoot::GetListenerManager(PRBool aCreateIfNotFound)
{
if (!mListenerManager) {
if (!aCreateIfNotFound) {
*aResult = nsnull;
return NS_OK;
return nsnull;
}
mListenerManager = do_CreateInstance(kEventListenerManagerCID);
if (mListenerManager) {
mListenerManager->SetListenerTarget(
static_cast<nsPIDOMEventTarget*>(this));
}
nsresult rv;
mListenerManager = do_CreateInstance(kEventListenerManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
mListenerManager->SetListenerTarget(
static_cast<nsPIDOMEventTarget*>(this));
}
*aResult = mListenerManager;
NS_ADDREF(*aResult);
return NS_OK;
return mListenerManager;
}
nsresult
nsWindowRoot::GetSystemEventGroup(nsIDOMEventGroup **aGroup)
{
nsCOMPtr<nsIEventListenerManager> manager;
if (NS_SUCCEEDED(GetListenerManager(PR_TRUE, getter_AddRefs(manager))) &&
manager) {
return manager->GetSystemEventGroupLM(aGroup);
}
return NS_ERROR_FAILURE;
nsIEventListenerManager* manager = GetListenerManager(PR_TRUE);
NS_ENSURE_STATE(manager);
return manager->GetSystemEventGroupLM(aGroup);
}

View File

@ -76,8 +76,7 @@ public:
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus);
virtual nsresult GetListenerManager(PRBool aCreateIfNotFound,
nsIEventListenerManager** aResult);
virtual nsIEventListenerManager* GetListenerManager(PRBool aCreateIfNotFound);
virtual nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener,

View File

@ -334,8 +334,7 @@ nsEditor::InstallEventListeners()
// register the event listeners with the listener manager
nsCOMPtr<nsIDOMEventGroup> sysGroup;
piTarget->GetSystemEventGroup(getter_AddRefs(sysGroup));
nsCOMPtr<nsIEventListenerManager> elmP;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(elmP));
nsIEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
if (sysGroup && elmP)
{
@ -398,8 +397,8 @@ nsEditor::RemoveEventListeners()
if (piTarget)
{
// unregister the event listeners with the DOM event target
nsCOMPtr<nsIEventListenerManager> elmP;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(elmP));
nsCOMPtr<nsIEventListenerManager> elmP =
piTarget->GetListenerManager(PR_TRUE);
if (mKeyListenerP)
{
nsCOMPtr<nsIDOMEventGroup> sysGroup;

View File

@ -645,8 +645,7 @@ mozInlineSpellChecker::RegisterEventListeners()
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIEventListenerManager> elmP;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(elmP));
nsIEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
if (elmP) {
// Focus event doesn't bubble so adding the listener to capturing phase
elmP->AddEventListenerByIID(static_cast<nsIDOMFocusListener *>(this),
@ -679,8 +678,8 @@ mozInlineSpellChecker::UnregisterEventListeners()
nsCOMPtr<nsPIDOMEventTarget> piTarget = do_QueryInterface(doc);
NS_ENSURE_TRUE(piTarget, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIEventListenerManager> elmP;
piTarget->GetListenerManager(PR_TRUE, getter_AddRefs(elmP));
nsCOMPtr<nsIEventListenerManager> elmP =
piTarget->GetListenerManager(PR_TRUE);
if (elmP) {
elmP->RemoveEventListenerByIID(static_cast<nsIDOMFocusListener *>(this),
NS_GET_IID(nsIDOMFocusListener),

View File

@ -1991,8 +1991,8 @@ static PRBool MayHavePaintEventListener(nsPIDOMWindow* aInnerWindow)
if (window)
return MayHavePaintEventListener(window);
nsCOMPtr<nsIEventListenerManager> manager;
chromeEventHandler->GetListenerManager(PR_FALSE, getter_AddRefs(manager));
nsIEventListenerManager* manager =
chromeEventHandler->GetListenerManager(PR_FALSE);
if (manager && manager->MayHavePaintEventListener())
return PR_TRUE;