зеркало из https://github.com/mozilla/pjs.git
Fixing bug 233142. Correct event default action prevention logic to match what we used to do before bug 226462 was fixed. r=bzbarsky@mit.edu, sr=bryner@brianryner.com.
This commit is contained in:
Родитель
32eb2c4962
Коммит
f218d03481
|
@ -1515,25 +1515,22 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
// Try the type-specific listener interface
|
||||
PRBool hasInterface = PR_FALSE;
|
||||
if (typeData)
|
||||
ret = DispatchToInterface(*aDOMEvent, ls->mListener,
|
||||
dispData->method, *typeData->iid,
|
||||
&hasInterface);
|
||||
DispatchToInterface(*aDOMEvent, ls->mListener,
|
||||
dispData->method, *typeData->iid,
|
||||
&hasInterface);
|
||||
|
||||
// If it doesn't implement that, call the generic HandleEvent()
|
||||
if (!hasInterface && (ls->mSubType == NS_EVENT_BITS_NONE ||
|
||||
ls->mSubType & dispData->bits))
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, aCurrentTarget,
|
||||
dispData ? dispData->bits : NS_EVENT_BITS_NONE,
|
||||
aFlags);
|
||||
HandleEventSubType(ls, *aDOMEvent, aCurrentTarget,
|
||||
dispData ? dispData->bits : NS_EVENT_BITS_NONE,
|
||||
aFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX (NS_OK != ret) is going away,
|
||||
// (aEvent->flags & NS_EVENT_FLAG_NO_DEFAULT) is correct
|
||||
if ((NS_OK != ret) ||
|
||||
(aEvent->flags & NS_EVENT_FLAG_NO_DEFAULT)) {
|
||||
if (aEvent->flags & NS_EVENT_FLAG_NO_DEFAULT) {
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
|
|
|
@ -5025,7 +5025,6 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
nsTimeoutImpl dummy_timeout;
|
||||
JSContext *cx;
|
||||
PRInt64 now, deadline;
|
||||
nsresult rv;
|
||||
PRUint32 firingDepth = mTimeoutFiringDepth + 1;
|
||||
|
||||
// Make sure that the window and the script context don't go away as
|
||||
|
@ -5124,10 +5123,10 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
|
||||
nsAutoString retval;
|
||||
PRBool is_undefined;
|
||||
rv = mContext->EvaluateString(nsDependentString(script), mJSObject,
|
||||
timeout->mPrincipal, timeout->mFileName,
|
||||
timeout->mLineNo, timeout->mVersion,
|
||||
retval, &is_undefined);
|
||||
mContext->EvaluateString(nsDependentString(script), mJSObject,
|
||||
timeout->mPrincipal, timeout->mFileName,
|
||||
timeout->mLineNo, timeout->mVersion, retval,
|
||||
&is_undefined);
|
||||
} else {
|
||||
PRInt64 lateness64;
|
||||
PRInt32 lateness;
|
||||
|
@ -5140,9 +5139,8 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
timeout->mArgv[timeout->mArgc] = INT_TO_JSVAL((jsint) lateness);
|
||||
|
||||
jsval dummy;
|
||||
rv = mContext->CallEventHandler(mJSObject, timeout->mFunObj,
|
||||
timeout->mArgc + 1, timeout->mArgv,
|
||||
&dummy);
|
||||
mContext->CallEventHandler(mJSObject, timeout->mFunObj,
|
||||
timeout->mArgc + 1, timeout->mArgv, &dummy);
|
||||
}
|
||||
|
||||
--mTimeoutFiringDepth;
|
||||
|
@ -5209,9 +5207,9 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
// Reschedule the OS timer. Don't bother returning any error
|
||||
// codes if this fails since nobody who cares about them is
|
||||
// listening anyways.
|
||||
rv = timeout->mTimer->InitWithFuncCallback(TimerCallback, timeout,
|
||||
delay32,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
nsresult rv =
|
||||
timeout->mTimer->InitWithFuncCallback(TimerCallback, timeout, delay32,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Error initializing timer for DOM timeout!");
|
||||
|
|
|
@ -1277,13 +1277,16 @@ nsJSContext::CallEventHandler(JSObject *aTarget, JSObject *aHandler,
|
|||
|
||||
// Don't pass back results from failed calls.
|
||||
*rval = JSVAL_VOID;
|
||||
|
||||
// Tell the caller that the handler threw an error.
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(stack->Pop(nsnull)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -100,7 +100,8 @@ nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
//if (mReturnResult == nsReturnResult_eNotSet) {
|
||||
if (eventString.Equals(NS_LITERAL_STRING("error")) || eventString.Equals(NS_LITERAL_STRING("mouseover"))) {
|
||||
if (eventString.Equals(NS_LITERAL_STRING("error")) ||
|
||||
eventString.Equals(NS_LITERAL_STRING("mouseover"))) {
|
||||
mReturnResult = nsReturnResult_eReverseReturnResult;
|
||||
}
|
||||
else {
|
||||
|
@ -197,18 +198,19 @@ nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
beforeUnload->text = nsDependentJSString(JSVAL_TO_STRING(rval));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (JSVAL_IS_BOOLEAN(rval)) {
|
||||
// if the handler returned false and its sense is not reversed,
|
||||
// or the handler returned true and its sense is reversed from
|
||||
// the usual (false means cancel), then prevent default.
|
||||
|
||||
PRBool jsBoolResult = !JSVAL_IS_BOOLEAN(rval) || JSVAL_TO_BOOLEAN(rval);
|
||||
|
||||
if (jsBoolResult ==
|
||||
if (JSVAL_TO_BOOLEAN(rval) ==
|
||||
(mReturnResult == nsReturnResult_eReverseReturnResult)) {
|
||||
aEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
} else if (eventString.Equals(NS_LITERAL_STRING("onsubmit"))) {
|
||||
// Don't submit any data if the event handler failed
|
||||
aEvent->PreventDefault();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче