From c7b48e2ab30dde671946db890748fda9efd8b7dc Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Sun, 13 Feb 2000 21:59:22 +0000 Subject: [PATCH] Fix for bug#25565 git-svn-id: svn://10.0.0.236/trunk@60659 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/xbl/src/nsXBLEventHandler.cpp | 55 ++++--------------- mozilla/layout/xbl/src/nsXBLEventHandler.cpp | 55 ++++--------------- 2 files changed, 22 insertions(+), 88 deletions(-) diff --git a/mozilla/content/xbl/src/nsXBLEventHandler.cpp b/mozilla/content/xbl/src/nsXBLEventHandler.cpp index b5f4bc479ac..200b2b94251 100644 --- a/mozilla/content/xbl/src/nsXBLEventHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLEventHandler.cpp @@ -334,52 +334,16 @@ nsXBLEventHandler::ExecuteHandler(const nsString& aEventName, nsIDOMEvent* aEven onEvent += aEventName; nsCOMPtr onEventAtom = getter_AddRefs(NS_NewAtom(onEvent)); - nsCOMPtr handlerOwner = do_QueryInterface(mHandlerElement); - void* handler = nsnull; - if (handlerOwner) - handlerOwner->GetCompiledEventHandler(onEventAtom, &handler); + + // Compile the event handler. + nsAutoString handlerText; + mHandlerElement->GetAttribute(kNameSpaceID_None, kValueAtom, handlerText); + if (handlerText.IsEmpty()) + return NS_OK; // For whatever reason, they didn't give us anything to do. - if (!handler) { - // We've never compiled the event handler before. Let's get it - // compiled. - nsAutoString handlerText; - mHandlerElement->GetAttribute(kNameSpaceID_None, kValueAtom, handlerText); - if (handlerText.IsEmpty()) - return NS_OK; // For whatever reason, they didn't give us anything to do. - - nsCOMPtr document; - mHandlerElement->GetDocument(*getter_AddRefs(document)); - - // Ensure that a global object has been made for the XBL document. - nsCOMPtr globalObject; - document->GetScriptGlobalObject(getter_AddRefs(globalObject)); - if (!globalObject) { - NS_NewScriptGlobalObject(getter_AddRefs(globalObject)); - document->SetScriptGlobalObject(globalObject); - } - - // Ensure that we have a script context for the XBL document. - nsCOMPtr context; - globalObject->GetContext(getter_AddRefs(context)); - if (!context) { - NS_CreateScriptContext(globalObject, getter_AddRefs(context)); - nsCOMPtr domDoc = do_QueryInterface(document); - globalObject->SetNewDocument(domDoc); // Ensures document is set. - } - - nsCOMPtr owner = do_QueryInterface(mHandlerElement); - void* scriptObject; - owner->GetScriptObject(context, &scriptObject); - - if (handlerOwner) - handlerOwner->CompileEventHandler(context, scriptObject, onEventAtom, handlerText, &handler); - else context->CompileEventHandler(scriptObject, onEventAtom, handlerText, - PR_TRUE, &handler); - } - - // Now that the handler has been compiled, let's bind it to the - // element in question. + + // Compile the handler and bind it to the element. nsCOMPtr boundDocument; mBoundElement->GetDocument(*getter_AddRefs(boundDocument)); nsCOMPtr boundGlobal; @@ -392,6 +356,9 @@ nsXBLEventHandler::ExecuteHandler(const nsString& aEventName, nsIDOMEvent* aEven void* scriptObject; owner->GetScriptObject(boundContext, &scriptObject); + boundContext->CompileEventHandler(scriptObject, onEventAtom, handlerText, + PR_TRUE, &handler); + // Temporarily bind it to the bound element boundContext->BindCompiledEventHandler(scriptObject, onEventAtom, handler); diff --git a/mozilla/layout/xbl/src/nsXBLEventHandler.cpp b/mozilla/layout/xbl/src/nsXBLEventHandler.cpp index b5f4bc479ac..200b2b94251 100644 --- a/mozilla/layout/xbl/src/nsXBLEventHandler.cpp +++ b/mozilla/layout/xbl/src/nsXBLEventHandler.cpp @@ -334,52 +334,16 @@ nsXBLEventHandler::ExecuteHandler(const nsString& aEventName, nsIDOMEvent* aEven onEvent += aEventName; nsCOMPtr onEventAtom = getter_AddRefs(NS_NewAtom(onEvent)); - nsCOMPtr handlerOwner = do_QueryInterface(mHandlerElement); - void* handler = nsnull; - if (handlerOwner) - handlerOwner->GetCompiledEventHandler(onEventAtom, &handler); + + // Compile the event handler. + nsAutoString handlerText; + mHandlerElement->GetAttribute(kNameSpaceID_None, kValueAtom, handlerText); + if (handlerText.IsEmpty()) + return NS_OK; // For whatever reason, they didn't give us anything to do. - if (!handler) { - // We've never compiled the event handler before. Let's get it - // compiled. - nsAutoString handlerText; - mHandlerElement->GetAttribute(kNameSpaceID_None, kValueAtom, handlerText); - if (handlerText.IsEmpty()) - return NS_OK; // For whatever reason, they didn't give us anything to do. - - nsCOMPtr document; - mHandlerElement->GetDocument(*getter_AddRefs(document)); - - // Ensure that a global object has been made for the XBL document. - nsCOMPtr globalObject; - document->GetScriptGlobalObject(getter_AddRefs(globalObject)); - if (!globalObject) { - NS_NewScriptGlobalObject(getter_AddRefs(globalObject)); - document->SetScriptGlobalObject(globalObject); - } - - // Ensure that we have a script context for the XBL document. - nsCOMPtr context; - globalObject->GetContext(getter_AddRefs(context)); - if (!context) { - NS_CreateScriptContext(globalObject, getter_AddRefs(context)); - nsCOMPtr domDoc = do_QueryInterface(document); - globalObject->SetNewDocument(domDoc); // Ensures document is set. - } - - nsCOMPtr owner = do_QueryInterface(mHandlerElement); - void* scriptObject; - owner->GetScriptObject(context, &scriptObject); - - if (handlerOwner) - handlerOwner->CompileEventHandler(context, scriptObject, onEventAtom, handlerText, &handler); - else context->CompileEventHandler(scriptObject, onEventAtom, handlerText, - PR_TRUE, &handler); - } - - // Now that the handler has been compiled, let's bind it to the - // element in question. + + // Compile the handler and bind it to the element. nsCOMPtr boundDocument; mBoundElement->GetDocument(*getter_AddRefs(boundDocument)); nsCOMPtr boundGlobal; @@ -392,6 +356,9 @@ nsXBLEventHandler::ExecuteHandler(const nsString& aEventName, nsIDOMEvent* aEven void* scriptObject; owner->GetScriptObject(boundContext, &scriptObject); + boundContext->CompileEventHandler(scriptObject, onEventAtom, handlerText, + PR_TRUE, &handler); + // Temporarily bind it to the bound element boundContext->BindCompiledEventHandler(scriptObject, onEventAtom, handler);