Continuing fix for bug 18843. Added onload and onerror events for loaded scripts. r=nisheeth, sr=jst

This commit is contained in:
vidur%netscape.com 2001-05-19 01:21:57 +00:00
Родитель 3018715592
Коммит ae0d3ddcd3
5 изменённых файлов: 44 добавлений и 7 удалений

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

@ -1471,7 +1471,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
PRBool intermediateCapture = PR_FALSE;
//Capturing stage evaluation
if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD) {
if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD
&& aEvent->message != NS_SCRIPT_LOAD) {
//Initiate capturing phase. Special case first call to document
if (parent) {
parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
@ -1510,7 +1511,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
//Bubbling stage
if (NS_EVENT_FLAG_CAPTURE != aFlags && mDocument &&
aEvent->message != NS_PAGE_LOAD) {
aEvent->message != NS_PAGE_LOAD &&
aEvent->message != NS_SCRIPT_LOAD) {
if (parent) {
/*
* If there's a parent we pass the event to the parent...

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

@ -1342,6 +1342,7 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return mEventNames[eDOMEvents_close];
case NS_PAGE_LOAD:
case NS_IMAGE_LOAD:
case NS_SCRIPT_LOAD:
return mEventNames[eDOMEvents_load];
case NS_PAGE_UNLOAD:
return mEventNames[eDOMEvents_unload];

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

@ -191,14 +191,14 @@ nsEventListenerManager::QueryInterface(REFNSIID aIID, void** aInstancePtr)
AddRef();
return NS_OK;
}
if (mTarget) {
return mTarget->QueryInterface(aIID, aInstancePtr);
}
if (aIID.Equals(NS_GET_IID(nsISupports))) {
*aInstancePtr = (void*)(nsISupports*)(nsIEventListenerManager*)this;
AddRef();
return NS_OK;
}
if (mTarget) {
return mTarget->QueryInterface(aIID, aInstancePtr);
}
return NS_NOINTERFACE;
}
@ -981,6 +981,8 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
if (NS_FAILED(rv = securityManager->CheckPropertyAccess(cx, jsobj,
"EventTarget","addEventListener",
nsIXPCSecurityManager::ACCESS_SET_PROPERTY))) {
@ -1762,6 +1764,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
case NS_PAGE_UNLOAD:
case NS_IMAGE_LOAD:
case NS_IMAGE_ERROR:
case NS_SCRIPT_LOAD:
case NS_SCRIPT_ERROR:
listeners = GetListenersByType(eEventArrayType_Load, nsnull, PR_FALSE);
if (listeners) {
@ -1778,6 +1781,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
switch(aEvent->message) {
case NS_PAGE_LOAD:
case NS_IMAGE_LOAD:
case NS_SCRIPT_LOAD:
ret = loadListener->Load(*aDOMEvent);
break;
case NS_PAGE_UNLOAD:
@ -1796,6 +1800,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
switch(aEvent->message) {
case NS_PAGE_LOAD:
case NS_IMAGE_LOAD:
case NS_SCRIPT_LOAD:
subType = NS_EVENT_BITS_LOAD_LOAD;
if (ls->mSubType & NS_EVENT_BITS_LOAD_LOAD) {
correctSubType = PR_TRUE;

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

@ -296,6 +296,20 @@ nsHTMLScriptElement::ScriptAvailable(nsresult aResult,
PRInt32 aLineNo,
const nsAString& aScript)
{
nsresult rv = NS_OK;
if (!aIsInline && NS_FAILED(aResult)) {
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(this, getter_AddRefs(presContext));
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_SCRIPT_ERROR;
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}
return NS_OK;
}
@ -306,7 +320,21 @@ nsHTMLScriptElement::ScriptEvaluated(nsresult aResult,
PRBool aIsInline,
PRBool aWasPending)
{
return NS_OK;
nsresult rv = NS_OK;
if (!aIsInline) {
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(this, getter_AddRefs(presContext));
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR;
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}
return rv;
}
NS_IMETHODIMP

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

@ -444,7 +444,8 @@ enum nsDragDropEventStatus {
#define NS_IMAGE_LOAD (NS_STREAM_EVENT_START + 2)
#define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
#define NS_IMAGE_ERROR (NS_STREAM_EVENT_START + 4)
#define NS_SCRIPT_LOAD (NS_STREAM_EVENT_START + 5)
#define NS_FORM_EVENT_START 1200
#define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
#define NS_FORM_RESET (NS_FORM_EVENT_START + 1)