mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
(bug 22795, r=vidur@netscape.com)
- Add "aShared" flag to nsIScriptContext::CompileEventHandler, telling it to clear the compiled event handler's scope chain if true, in order to (a) avoid entraining garbage (i.e., a shared compile-time-only parent object); and (b) cause later BindCompiledEventHandler calls to ensure that the event handler has the particular scope chain needed for the binding (to the target object that's receiving the event). - Use :: consistently (and all over the place) before calls to JS_ functions in nsJSEnvironment.cpp. - Eliminate tabs and barbarians-at-the-gate-of-Rome style, in favor of when-in-Rome style (hail Waterson Maximus!)
This commit is contained in:
parent
64b35bf780
commit
cfe8cb3e89
@ -122,13 +122,13 @@ nsVoidArray** nsEventListenerManager::GetListenersByIID(const nsIID& aIID)
|
||||
return &mPaintListeners;
|
||||
}
|
||||
else if (aIID.Equals(kIDOMTextListenerIID)) {
|
||||
return &mTextListeners;
|
||||
return &mTextListeners;
|
||||
}
|
||||
else if (aIID.Equals(kIDOMCompositionListenerIID)) {
|
||||
return &mCompositionListeners;
|
||||
return &mCompositionListeners;
|
||||
}
|
||||
else if (aIID.Equals(kIDOMMenuListenerIID)) {
|
||||
return &mMenuListeners;
|
||||
return &mMenuListeners;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
@ -553,7 +553,9 @@ nsEventListenerManager::AddScriptEventListener(nsIScriptContext* aContext,
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
rv = aContext->CompileEventHandler(scriptObject, aName, aBody, &handler);
|
||||
rv = aContext->CompileEventHandler(scriptObject, aName, aBody,
|
||||
(handlerOwner != nsnull),
|
||||
&handler);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (handlerOwner)
|
||||
@ -619,7 +621,9 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
|
||||
nsAutoString handlerBody;
|
||||
result = content->GetAttribute(kNameSpaceID_None, atom, handlerBody);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = scriptCX->CompileEventHandler(jsobj, atom, handlerBody, &handler);
|
||||
result = scriptCX->CompileEventHandler(jsobj, atom, handlerBody,
|
||||
(handlerOwner != nsnull),
|
||||
&handler);
|
||||
aListenerStruct->mHandlerIsString &= ~aSubType;
|
||||
if (handlerOwner)
|
||||
handlerOwner->SetCompiledEventHandler(atom, handler);
|
||||
@ -827,79 +831,79 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_COMPOSITION_START:
|
||||
case NS_COMPOSITION_END:
|
||||
case NS_COMPOSITION_QUERY:
|
||||
#if DEBUG_TAGUE
|
||||
printf("DOM: got composition event\n");
|
||||
#endif
|
||||
if (nsnull != mCompositionListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (NS_OK == ret) {
|
||||
for(int i=0;i<mTextListeners->Count();i++) {
|
||||
nsListenerStruct *ls;
|
||||
nsIDOMCompositionListener* mCompositionListener;
|
||||
ls =(nsListenerStruct*)mCompositionListeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (NS_OK == ls->mListener->QueryInterface(kIDOMCompositionListenerIID, (void**)&mCompositionListener)) {
|
||||
if (aEvent->message==NS_COMPOSITION_START) {
|
||||
ret = mCompositionListener->HandleStartComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_END) {
|
||||
ret = mCompositionListener->HandleEndComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_QUERY) {
|
||||
ret = mCompositionListener->HandleQueryComposition(*aDOMEvent);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(mCompositionListener);
|
||||
}
|
||||
else {
|
||||
PRBool correctSubType = PR_FALSE;
|
||||
case NS_COMPOSITION_START:
|
||||
case NS_COMPOSITION_END:
|
||||
case NS_COMPOSITION_QUERY:
|
||||
#if DEBUG_TAGUE
|
||||
printf("DOM: got composition event\n");
|
||||
#endif
|
||||
if (nsnull != mCompositionListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (NS_OK == ret) {
|
||||
for(int i=0;i<mTextListeners->Count();i++) {
|
||||
nsListenerStruct *ls;
|
||||
nsIDOMCompositionListener* mCompositionListener;
|
||||
ls =(nsListenerStruct*)mCompositionListeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (NS_OK == ls->mListener->QueryInterface(kIDOMCompositionListenerIID, (void**)&mCompositionListener)) {
|
||||
if (aEvent->message==NS_COMPOSITION_START) {
|
||||
ret = mCompositionListener->HandleStartComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_END) {
|
||||
ret = mCompositionListener->HandleEndComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_QUERY) {
|
||||
ret = mCompositionListener->HandleQueryComposition(*aDOMEvent);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(mCompositionListener);
|
||||
}
|
||||
else {
|
||||
PRBool correctSubType = PR_FALSE;
|
||||
PRUint32 subType = 0;
|
||||
switch(aEvent->message) {
|
||||
case NS_COMPOSITION_START:
|
||||
switch(aEvent->message) {
|
||||
case NS_COMPOSITION_START:
|
||||
subType = NS_EVENT_BITS_COMPOSITION_START;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_START) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_END:
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_START) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_END:
|
||||
subType = NS_EVENT_BITS_COMPOSITION_END;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_END) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_QUERY:
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_END) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_QUERY:
|
||||
subType = NS_EVENT_BITS_COMPOSITION_QUERY;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_QUERY) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (correctSubType || ls->mSubType == NS_EVENT_BITS_NONE) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, subType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_QUERY) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (correctSubType || ls->mSubType == NS_EVENT_BITS_NONE) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, subType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_TEXT_EVENT:
|
||||
case NS_TEXT_EVENT:
|
||||
#if DEBUG_TAGUE
|
||||
printf("DOM: got text event\n");
|
||||
printf("DOM: got text event\n");
|
||||
#endif
|
||||
if (nsnull != mTextListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (nsnull != mTextListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (NS_OK == ret) {
|
||||
for (int i=0; i<mTextListeners->Count(); i++) {
|
||||
nsListenerStruct *ls;
|
||||
@ -923,10 +927,10 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_DOWN:
|
||||
|
@ -142,6 +142,11 @@ public:
|
||||
* and ASCII, and should not be longer than 63 chars. This bound on
|
||||
* length is enforced only by assertions, so caveat caller!
|
||||
* @param aBody the event handler function's body
|
||||
* @param aShared flag telling whether the compiled event handler will be
|
||||
* shared via nsIScriptEventHandlerOwner, in which case any static
|
||||
* link compiled into it based on aTarget should be cleared, both
|
||||
* to avoid entraining garbage to be collected, and to trigger static
|
||||
* link re-binding in BindCompiledEventHandler (see below).
|
||||
* @param aHandler the out parameter in which a void pointer to the compiled
|
||||
* function object is returned on success; may be null, meaning the
|
||||
* caller doesn't need to store the handler for later use.
|
||||
@ -151,6 +156,7 @@ public:
|
||||
NS_IMETHOD CompileEventHandler(void* aTarget,
|
||||
nsIAtom* aName,
|
||||
const nsString& aBody,
|
||||
PRBool aShared,
|
||||
void** aHandler) = 0;
|
||||
|
||||
/**
|
||||
@ -172,7 +178,9 @@ public:
|
||||
/**
|
||||
* Bind an already-compiled event handler function to a name in the given
|
||||
* scope object. The same restrictions on aName (lowercase ASCII, not too
|
||||
* long) applies here as for CompileEventHandler.
|
||||
* long) applies here as for CompileEventHandler. Scripting languages with
|
||||
* static scoping must re-bind the scope chain for aHandler to begin (after
|
||||
* the activation scope for aHandler itself, typically) with aTarget's scope.
|
||||
*
|
||||
* @param aTarget an object telling the scope in which to bind the compiled
|
||||
* event handler function.
|
||||
|
@ -126,15 +126,15 @@ NS_ScriptErrorReporter(JSContext *cx,
|
||||
#endif
|
||||
|
||||
// XXX do we really want to be doing this?
|
||||
JS_ClearPendingException(cx);
|
||||
::JS_ClearPendingException(cx);
|
||||
}
|
||||
|
||||
nsJSContext::nsJSContext(JSRuntime *aRuntime)
|
||||
{
|
||||
mRefCnt = 0;
|
||||
mContext = JS_NewContext(aRuntime, gStackSize);
|
||||
mContext = ::JS_NewContext(aRuntime, gStackSize);
|
||||
if (mContext) {
|
||||
JS_SetContextPrivate(mContext, (void *)this);
|
||||
::JS_SetContextPrivate(mContext, (void *)this);
|
||||
|
||||
// Check for the JS strict option, which enables extra error checks
|
||||
nsresult rv;
|
||||
@ -158,7 +158,7 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime)
|
||||
}
|
||||
#endif
|
||||
if (options)
|
||||
JS_SetOptions(mContext, options);
|
||||
::JS_SetOptions(mContext, options);
|
||||
}
|
||||
}
|
||||
mIsInitialized = PR_FALSE;
|
||||
@ -183,8 +183,8 @@ nsJSContext::~nsJSContext()
|
||||
return;
|
||||
|
||||
/* Remove global object reference to window object, so it can be collected. */
|
||||
JS_SetGlobalObject(mContext, nsnull);
|
||||
JS_DestroyContext(mContext);
|
||||
::JS_SetGlobalObject(mContext, nsnull);
|
||||
::JS_DestroyContext(mContext);
|
||||
|
||||
// Let xpconnect resync its JSContext tracker (this is optional)
|
||||
nsresult rv;
|
||||
@ -218,7 +218,7 @@ nsJSContext::EvaluateString(const nsString& aScript,
|
||||
{
|
||||
nsresult rv;
|
||||
if (!aScopeObject)
|
||||
aScopeObject = JS_GetGlobalObject(mContext);
|
||||
aScopeObject = ::JS_GetGlobalObject(mContext);
|
||||
|
||||
// Safety first: get an object representing the script's principals, i.e.,
|
||||
// the entities who signed this script, or the fully-qualified-domain-name
|
||||
@ -276,12 +276,12 @@ nsJSContext::EvaluateString(const nsString& aScript,
|
||||
// and unknown. Do execute with the default version (and avoid thrashing
|
||||
// the context's version) if aVersion is not specified.
|
||||
ok = (!aVersion ||
|
||||
(newVersion = JS_StringToVersion(aVersion)) != JSVERSION_UNKNOWN);
|
||||
(newVersion = ::JS_StringToVersion(aVersion)) != JSVERSION_UNKNOWN);
|
||||
if (ok) {
|
||||
JSVersion oldVersion;
|
||||
|
||||
if (aVersion)
|
||||
oldVersion = JS_SetVersion(mContext, newVersion);
|
||||
oldVersion = ::JS_SetVersion(mContext, newVersion);
|
||||
mRef = nsnull;
|
||||
mTerminationFunc = nsnull;
|
||||
ok = ::JS_EvaluateUCScriptForPrincipals(mContext,
|
||||
@ -293,7 +293,7 @@ nsJSContext::EvaluateString(const nsString& aScript,
|
||||
aLineNo,
|
||||
&val);
|
||||
if (aVersion)
|
||||
JS_SetVersion(mContext, oldVersion);
|
||||
::JS_SetVersion(mContext, oldVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,9 +303,9 @@ nsJSContext::EvaluateString(const nsString& aScript,
|
||||
// If all went well, convert val to a string (XXXbe unless undefined?).
|
||||
if (ok) {
|
||||
*aIsUndefined = JSVAL_IS_VOID(val);
|
||||
JSString* jsstring = JS_ValueToString(mContext, val);
|
||||
JSString* jsstring = ::JS_ValueToString(mContext, val);
|
||||
if (jsstring)
|
||||
aRetValue.SetString(JS_GetStringChars(jsstring));
|
||||
aRetValue.SetString(::JS_GetStringChars(jsstring));
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -337,7 +337,7 @@ nsJSContext::CompileScript(const PRUnichar* aText,
|
||||
NS_ENSURE_ARG_POINTER(aPrincipal);
|
||||
|
||||
if (!aScopeObject)
|
||||
aScopeObject = JS_GetGlobalObject(mContext);
|
||||
aScopeObject = ::JS_GetGlobalObject(mContext);
|
||||
|
||||
JSPrincipals *jsprin;
|
||||
aPrincipal->GetJSPrincipals(&jsprin);
|
||||
@ -361,10 +361,10 @@ nsJSContext::CompileScript(const PRUnichar* aText,
|
||||
// and unknown. Do compile with the default version (and avoid thrashing
|
||||
// the context's version) if aVersion is not specified.
|
||||
if (!aVersion ||
|
||||
(newVersion = JS_StringToVersion(aVersion)) != JSVERSION_UNKNOWN) {
|
||||
(newVersion = ::JS_StringToVersion(aVersion)) != JSVERSION_UNKNOWN) {
|
||||
JSVersion oldVersion;
|
||||
if (aVersion)
|
||||
oldVersion = JS_SetVersion(mContext, newVersion);
|
||||
oldVersion = ::JS_SetVersion(mContext, newVersion);
|
||||
|
||||
JSScript* script =
|
||||
::JS_CompileUCScriptForPrincipals(mContext,
|
||||
@ -385,7 +385,7 @@ nsJSContext::CompileScript(const PRUnichar* aText,
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (aVersion)
|
||||
JS_SetVersion(mContext, oldVersion);
|
||||
::JS_SetVersion(mContext, oldVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ nsJSContext::ExecuteScript(void* aScriptObject,
|
||||
nsresult rv;
|
||||
|
||||
if (!aScopeObject)
|
||||
aScopeObject = JS_GetGlobalObject(mContext);
|
||||
aScopeObject = ::JS_GetGlobalObject(mContext);
|
||||
|
||||
// Push our JSContext on our thread's context stack, in case native code
|
||||
// called from JS calls back into JS via XPConnect.
|
||||
@ -423,7 +423,7 @@ nsJSContext::ExecuteScript(void* aScriptObject,
|
||||
mTerminationFunc = nsnull;
|
||||
ok = ::JS_ExecuteScript(mContext,
|
||||
(JSObject*) aScopeObject,
|
||||
(JSScript*) JS_GetPrivate(mContext,
|
||||
(JSScript*) ::JS_GetPrivate(mContext,
|
||||
(JSObject*)aScriptObject),
|
||||
&val);
|
||||
|
||||
@ -432,9 +432,9 @@ nsJSContext::ExecuteScript(void* aScriptObject,
|
||||
if (aIsUndefined)
|
||||
*aIsUndefined = JSVAL_IS_VOID(val);
|
||||
if (aRetValue) {
|
||||
JSString* jsstring = JS_ValueToString(mContext, val);
|
||||
JSString* jsstring = ::JS_ValueToString(mContext, val);
|
||||
if (jsstring)
|
||||
aRetValue->SetString(JS_GetStringChars(jsstring));
|
||||
aRetValue->SetString(::JS_GetStringChars(jsstring));
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -481,7 +481,7 @@ AtomToEventHandlerName(nsIAtom *aName, char *charName, PRUint32 charNameSize)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSContext::CompileEventHandler(void *aTarget, nsIAtom *aName, const nsString& aBody,
|
||||
void** aHandler)
|
||||
PRBool aShared, void** aHandler)
|
||||
{
|
||||
JSPrincipals *jsprin = nsnull;
|
||||
|
||||
@ -500,28 +500,27 @@ nsJSContext::CompileEventHandler(void *aTarget, nsIAtom *aName, const nsString&
|
||||
char charName[64];
|
||||
AtomToEventHandlerName(aName, charName, sizeof charName);
|
||||
|
||||
JSObject *target = (JSObject*)aTarget;
|
||||
JSFunction* fun =
|
||||
JS_CompileUCFunctionForPrincipals(mContext,
|
||||
(JSObject*)aTarget, jsprin,
|
||||
charName, 1, gEventArgv,
|
||||
(jschar*)aBody.GetUnicode(),
|
||||
aBody.Length(),
|
||||
//XXXbe filename, lineno:
|
||||
nsnull, 0);
|
||||
::JS_CompileUCFunctionForPrincipals(mContext, target, jsprin,
|
||||
charName, 1, gEventArgv,
|
||||
(jschar*)aBody.GetUnicode(),
|
||||
aBody.Length(),
|
||||
//XXXbe filename, lineno:
|
||||
nsnull, 0);
|
||||
|
||||
if (jsprin)
|
||||
JSPRINCIPALS_DROP(mContext, jsprin);
|
||||
if (!fun)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSObject *handler = ::JS_GetFunctionObject(fun);
|
||||
if (aHandler)
|
||||
*aHandler = (void*) JS_GetFunctionObject(fun);
|
||||
*aHandler = (void*) handler;
|
||||
|
||||
nsISupports* supports = NS_STATIC_CAST(nsISupports*, JS_GetPrivate(mContext, (JSObject*)aTarget));
|
||||
nsCOMPtr<nsIScriptEventHandlerOwner> owner = do_QueryInterface(supports);
|
||||
|
||||
if (owner) {
|
||||
/* Break scope link to avoid entraining compilation scope. */
|
||||
JS_SetParent(mContext, (JSObject *)*aHandler, nsnull);
|
||||
if (aShared) {
|
||||
/* Break scope link to avoid entraining shared compilation scope. */
|
||||
::JS_SetParent(mContext, handler, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -539,7 +538,7 @@ nsJSContext::CallEventHandler(void *aTarget, void *aHandler, PRUint32 argc,
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
jsval funval = OBJECT_TO_JSVAL(aHandler);
|
||||
JSFunction* fun = JS_ValueToFunction(mContext, funval);
|
||||
JSFunction* fun = ::JS_ValueToFunction(mContext, funval);
|
||||
|
||||
PRBool ok;
|
||||
rv = securityManager->CanExecuteFunction(fun, &ok);
|
||||
@ -561,8 +560,8 @@ nsJSContext::CallEventHandler(void *aTarget, void *aHandler, PRUint32 argc,
|
||||
|
||||
jsval val;
|
||||
if (ok) {
|
||||
ok = JS_CallFunctionValue(mContext, (JSObject *)aTarget, funval,
|
||||
argc, (jsval *)argv, &val);
|
||||
ok = ::JS_CallFunctionValue(mContext, (JSObject *)aTarget, funval,
|
||||
argc, (jsval *)argv, &val);
|
||||
}
|
||||
*aBoolResult = ok
|
||||
? !JSVAL_IS_BOOLEAN(val) || JSVAL_TO_BOOLEAN(val)
|
||||
@ -586,8 +585,8 @@ nsJSContext::BindCompiledEventHandler(void *aTarget, nsIAtom *aName, void *aHand
|
||||
JSObject *target = (JSObject*) aTarget;
|
||||
|
||||
// Make sure the handler function is parented by its event target object
|
||||
if (funobj && JS_GetParent(mContext, funobj) != target) {
|
||||
funobj = JS_CloneFunctionObject(mContext, funobj, target);
|
||||
if (funobj && ::JS_GetParent(mContext, funobj) != target) {
|
||||
funobj = ::JS_CloneFunctionObject(mContext, funobj, target);
|
||||
if (!funobj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -603,18 +602,18 @@ nsJSContext::BindCompiledEventHandler(void *aTarget, nsIAtom *aName, void *aHand
|
||||
NS_IMETHODIMP
|
||||
nsJSContext::SetDefaultLanguageVersion(const char* aVersion)
|
||||
{
|
||||
(void) JS_SetVersion(mContext, JS_StringToVersion(aVersion));
|
||||
(void) ::JS_SetVersion(mContext, ::JS_StringToVersion(aVersion));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIScriptGlobalObject*)
|
||||
nsJSContext::GetGlobalObject()
|
||||
{
|
||||
JSObject *global = JS_GetGlobalObject(mContext);
|
||||
JSObject *global = ::JS_GetGlobalObject(mContext);
|
||||
nsIScriptGlobalObject *script_global = nsnull;
|
||||
|
||||
if (nsnull != global) {
|
||||
nsISupports* sup = (nsISupports *)JS_GetPrivate(mContext, global);
|
||||
nsISupports* sup = (nsISupports *)::JS_GetPrivate(mContext, global);
|
||||
if (nsnull != sup) {
|
||||
sup->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**) &script_global);
|
||||
}
|
||||
@ -646,10 +645,10 @@ nsJSContext::InitContext(nsIScriptGlobalObject *aGlobalObject)
|
||||
|
||||
// init standard classes
|
||||
if (NS_SUCCEEDED(rv) && ::JS_InitStandardClasses(mContext, global)) {
|
||||
JS_SetGlobalObject(mContext, global);
|
||||
::JS_SetGlobalObject(mContext, global);
|
||||
rv = InitClasses(); // this will complete the global object initialization
|
||||
}
|
||||
// XXX there ought to be an else here!
|
||||
// XXX there ought to be an else here!
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
::JS_SetErrorReporter(mContext, NS_ScriptErrorReporter);
|
||||
@ -680,7 +679,7 @@ nsJSContext::InitializeLiveConnectClasses()
|
||||
if (NS_SUCCEEDED(jvmManager->IsJavaEnabled(&javaEnabled)) && javaEnabled) {
|
||||
nsCOMPtr<nsILiveConnectManager> liveConnectManager = do_QueryInterface(jvmManager);
|
||||
if (liveConnectManager) {
|
||||
rv = liveConnectManager->InitLiveConnectClasses(mContext, JS_GetGlobalObject(mContext));
|
||||
rv = liveConnectManager->InitLiveConnectClasses(mContext, ::JS_GetGlobalObject(mContext));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -716,7 +715,7 @@ nsJSContext::InitClasses()
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_WITH_SERVICE(nsIXPConnect, xpc, nsIXPConnect::GetCID(), &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = xpc->InitClasses(mContext, JS_GetGlobalObject(mContext));
|
||||
rv = xpc->InitClasses(mContext, ::JS_GetGlobalObject(mContext));
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to init xpconnect classes");
|
||||
}
|
||||
@ -745,7 +744,7 @@ nsJSContext::RemoveReference(void *aSlot, void *aScriptObject)
|
||||
NS_IMETHODIMP
|
||||
nsJSContext::GC()
|
||||
{
|
||||
JS_GC(mContext);
|
||||
::JS_GC(mContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -82,13 +82,14 @@ public:
|
||||
NS_IMETHOD CompileEventHandler(void *aTarget,
|
||||
nsIAtom *aName,
|
||||
const nsString& aBody,
|
||||
PRBool aShared,
|
||||
void** aHandler);
|
||||
NS_IMETHOD CallEventHandler(void *aTarget, void *aHandler,
|
||||
PRUint32 argc, void *argv,
|
||||
PRBool *aBoolResult);
|
||||
NS_IMETHOD BindCompiledEventHandler(void *aTarget,
|
||||
nsIAtom *aName,
|
||||
void *aHandler);
|
||||
nsIAtom *aName,
|
||||
void *aHandler);
|
||||
|
||||
NS_IMETHOD SetDefaultLanguageVersion(const char* aVersion);
|
||||
NS_IMETHOD_(nsIScriptGlobalObject*) GetGlobalObject();
|
||||
@ -97,7 +98,7 @@ public:
|
||||
NS_IMETHOD InitContext(nsIScriptGlobalObject *aGlobalObject);
|
||||
NS_IMETHOD IsContextInitialized();
|
||||
NS_IMETHOD AddNamedReference(void *aSlot, void *aScriptObject,
|
||||
const char *aName);
|
||||
const char *aName);
|
||||
NS_IMETHOD RemoveReference(void *aSlot, void *aScriptObject);
|
||||
NS_IMETHOD GC();
|
||||
NS_IMETHOD GetNameSpaceManager(nsIScriptNameSpaceManager** aInstancePtr);
|
||||
|
@ -122,13 +122,13 @@ nsVoidArray** nsEventListenerManager::GetListenersByIID(const nsIID& aIID)
|
||||
return &mPaintListeners;
|
||||
}
|
||||
else if (aIID.Equals(kIDOMTextListenerIID)) {
|
||||
return &mTextListeners;
|
||||
return &mTextListeners;
|
||||
}
|
||||
else if (aIID.Equals(kIDOMCompositionListenerIID)) {
|
||||
return &mCompositionListeners;
|
||||
return &mCompositionListeners;
|
||||
}
|
||||
else if (aIID.Equals(kIDOMMenuListenerIID)) {
|
||||
return &mMenuListeners;
|
||||
return &mMenuListeners;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
@ -553,7 +553,9 @@ nsEventListenerManager::AddScriptEventListener(nsIScriptContext* aContext,
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
rv = aContext->CompileEventHandler(scriptObject, aName, aBody, &handler);
|
||||
rv = aContext->CompileEventHandler(scriptObject, aName, aBody,
|
||||
(handlerOwner != nsnull),
|
||||
&handler);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (handlerOwner)
|
||||
@ -619,7 +621,9 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
|
||||
nsAutoString handlerBody;
|
||||
result = content->GetAttribute(kNameSpaceID_None, atom, handlerBody);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = scriptCX->CompileEventHandler(jsobj, atom, handlerBody, &handler);
|
||||
result = scriptCX->CompileEventHandler(jsobj, atom, handlerBody,
|
||||
(handlerOwner != nsnull),
|
||||
&handler);
|
||||
aListenerStruct->mHandlerIsString &= ~aSubType;
|
||||
if (handlerOwner)
|
||||
handlerOwner->SetCompiledEventHandler(atom, handler);
|
||||
@ -827,79 +831,79 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_COMPOSITION_START:
|
||||
case NS_COMPOSITION_END:
|
||||
case NS_COMPOSITION_QUERY:
|
||||
#if DEBUG_TAGUE
|
||||
printf("DOM: got composition event\n");
|
||||
#endif
|
||||
if (nsnull != mCompositionListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (NS_OK == ret) {
|
||||
for(int i=0;i<mTextListeners->Count();i++) {
|
||||
nsListenerStruct *ls;
|
||||
nsIDOMCompositionListener* mCompositionListener;
|
||||
ls =(nsListenerStruct*)mCompositionListeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (NS_OK == ls->mListener->QueryInterface(kIDOMCompositionListenerIID, (void**)&mCompositionListener)) {
|
||||
if (aEvent->message==NS_COMPOSITION_START) {
|
||||
ret = mCompositionListener->HandleStartComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_END) {
|
||||
ret = mCompositionListener->HandleEndComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_QUERY) {
|
||||
ret = mCompositionListener->HandleQueryComposition(*aDOMEvent);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(mCompositionListener);
|
||||
}
|
||||
else {
|
||||
PRBool correctSubType = PR_FALSE;
|
||||
case NS_COMPOSITION_START:
|
||||
case NS_COMPOSITION_END:
|
||||
case NS_COMPOSITION_QUERY:
|
||||
#if DEBUG_TAGUE
|
||||
printf("DOM: got composition event\n");
|
||||
#endif
|
||||
if (nsnull != mCompositionListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (NS_OK == ret) {
|
||||
for(int i=0;i<mTextListeners->Count();i++) {
|
||||
nsListenerStruct *ls;
|
||||
nsIDOMCompositionListener* mCompositionListener;
|
||||
ls =(nsListenerStruct*)mCompositionListeners->ElementAt(i);
|
||||
|
||||
if (ls->mFlags & aFlags) {
|
||||
if (NS_OK == ls->mListener->QueryInterface(kIDOMCompositionListenerIID, (void**)&mCompositionListener)) {
|
||||
if (aEvent->message==NS_COMPOSITION_START) {
|
||||
ret = mCompositionListener->HandleStartComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_END) {
|
||||
ret = mCompositionListener->HandleEndComposition(*aDOMEvent);
|
||||
}
|
||||
if (aEvent->message==NS_COMPOSITION_QUERY) {
|
||||
ret = mCompositionListener->HandleQueryComposition(*aDOMEvent);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(mCompositionListener);
|
||||
}
|
||||
else {
|
||||
PRBool correctSubType = PR_FALSE;
|
||||
PRUint32 subType = 0;
|
||||
switch(aEvent->message) {
|
||||
case NS_COMPOSITION_START:
|
||||
switch(aEvent->message) {
|
||||
case NS_COMPOSITION_START:
|
||||
subType = NS_EVENT_BITS_COMPOSITION_START;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_START) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_END:
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_START) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_END:
|
||||
subType = NS_EVENT_BITS_COMPOSITION_END;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_END) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_QUERY:
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_END) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_COMPOSITION_QUERY:
|
||||
subType = NS_EVENT_BITS_COMPOSITION_QUERY;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_QUERY) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (correctSubType || ls->mSubType == NS_EVENT_BITS_NONE) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, subType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (ls->mSubType & NS_EVENT_BITS_COMPOSITION_QUERY) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (correctSubType || ls->mSubType == NS_EVENT_BITS_NONE) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, subType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_TEXT_EVENT:
|
||||
case NS_TEXT_EVENT:
|
||||
#if DEBUG_TAGUE
|
||||
printf("DOM: got text event\n");
|
||||
printf("DOM: got text event\n");
|
||||
#endif
|
||||
if (nsnull != mTextListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (nsnull != mTextListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent,aPresContext,aEvent);
|
||||
}
|
||||
if (NS_OK == ret) {
|
||||
for (int i=0; i<mTextListeners->Count(); i++) {
|
||||
nsListenerStruct *ls;
|
||||
@ -923,10 +927,10 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_DOWN:
|
||||
|
@ -17,7 +17,7 @@
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
@ -213,28 +213,28 @@ public:
|
||||
|
||||
// nsIXULKeyListener
|
||||
NS_IMETHOD Init(
|
||||
nsIDOMElement * aElement,
|
||||
nsIDOMElement * aElement,
|
||||
nsIDOMDocument * aDocument);
|
||||
|
||||
// nsIDOMKeyListener
|
||||
|
||||
|
||||
/**
|
||||
* Processes a key pressed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
virtual nsresult KeyDown(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
/**
|
||||
* Processes a key release event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
virtual nsresult KeyUp(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
/**
|
||||
* Processes a key typed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*
|
||||
*/
|
||||
@ -247,11 +247,11 @@ protected:
|
||||
class nsIURIKey : public nsHashKey {
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mKey;
|
||||
|
||||
|
||||
public:
|
||||
nsIURIKey(nsIURI* key) : mKey(key) {}
|
||||
~nsIURIKey(void) {}
|
||||
|
||||
|
||||
PRUint32 HashValue(void) const {
|
||||
nsXPIDLCString spec;
|
||||
mKey->GetSpec(getter_Copies(spec));
|
||||
@ -276,26 +276,26 @@ private:
|
||||
|
||||
NS_IMETHOD GetKeyBindingDocument(nsCAutoString& aURLStr, nsIDOMXULDocument** aResult);
|
||||
NS_IMETHOD LoadKeyBindingDocument(nsIURI* aURI, nsIDOMXULDocument** aResult);
|
||||
NS_IMETHOD LocateAndExecuteKeyBinding(nsIDOMKeyEvent* aKeyEvent, eEventType aEventType,
|
||||
NS_IMETHOD LocateAndExecuteKeyBinding(nsIDOMKeyEvent* aKeyEvent, eEventType aEventType,
|
||||
nsIDOMXULDocument* aDocument, PRBool& aHandled);
|
||||
NS_IMETHOD HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsIDOMKeyEvent* aEvent, eEventType aEventType,
|
||||
NS_IMETHOD HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsIDOMKeyEvent* aEvent, eEventType aEventType,
|
||||
nsIDOMXULDocument* aDocument, PRBool& aHandledFlag);
|
||||
|
||||
|
||||
nsIDOMElement* element; // Weak reference. The element will go away first.
|
||||
nsIDOMXULDocument* mDOMDocument; // Weak reference.
|
||||
|
||||
static PRUint32 gRefCnt;
|
||||
static nsSupportsHashtable* mKeyBindingTable;
|
||||
|
||||
|
||||
// The "xul key" modifier can be any of the known modifiers:
|
||||
enum {
|
||||
xulKeyNone, xulKeyShift, xulKeyControl, xulKeyAlt, xulKeyMeta
|
||||
} mXULKeyModifier;
|
||||
};
|
||||
};
|
||||
|
||||
PRUint32 nsXULKeyListenerImpl::gRefCnt = 0;
|
||||
nsSupportsHashtable* nsXULKeyListenerImpl::mKeyBindingTable = nsnull;
|
||||
|
||||
|
||||
class nsProxyStream : public nsIInputStream
|
||||
{
|
||||
private:
|
||||
@ -354,7 +354,7 @@ NS_IMPL_ISUPPORTS(nsProxyStream, nsIInputStream::GetIID());
|
||||
|
||||
nsXULKeyListenerImpl::nsXULKeyListenerImpl(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_INIT_REFCNT();
|
||||
gRefCnt++;
|
||||
if (gRefCnt == 1) {
|
||||
mKeyBindingTable = new nsSupportsHashtable();
|
||||
@ -417,7 +417,7 @@ nsXULKeyListenerImpl::Init(
|
||||
mXULKeyModifier = xulKeyMeta;
|
||||
#elif XP_PC
|
||||
mXULKeyModifier = xulKeyControl;
|
||||
#else
|
||||
#else
|
||||
mXULKeyModifier = xulKeyAlt;
|
||||
#endif
|
||||
return NS_OK;
|
||||
@ -428,7 +428,7 @@ nsXULKeyListenerImpl::Init(
|
||||
|
||||
/**
|
||||
* Processes a key down event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
nsresult nsXULKeyListenerImpl::KeyDown(nsIDOMEvent* aKeyEvent)
|
||||
@ -439,7 +439,7 @@ nsresult nsXULKeyListenerImpl::KeyDown(nsIDOMEvent* aKeyEvent)
|
||||
////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Processes a key release event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
nsresult nsXULKeyListenerImpl::KeyUp(nsIDOMEvent* aKeyEvent)
|
||||
@ -450,11 +450,11 @@ nsresult nsXULKeyListenerImpl::KeyUp(nsIDOMEvent* aKeyEvent)
|
||||
////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Processes a key typed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*
|
||||
*/
|
||||
// // Get the main document
|
||||
// // Get the main document
|
||||
// // find the keyset
|
||||
// iterate over key(s) looking for appropriate handler
|
||||
nsresult nsXULKeyListenerImpl::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
@ -464,32 +464,32 @@ nsresult nsXULKeyListenerImpl::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
|
||||
nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventType)
|
||||
{
|
||||
static PRBool executingKeyBind = PR_FALSE;
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
if(executingKeyBind)
|
||||
return NS_OK;
|
||||
else
|
||||
executingKeyBind = PR_TRUE;
|
||||
static PRBool executingKeyBind = PR_FALSE;
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
if(!aKeyEvent) {
|
||||
executingKeyBind = PR_FALSE;
|
||||
return ret;
|
||||
}
|
||||
if (executingKeyBind)
|
||||
return NS_OK;
|
||||
|
||||
if(!mDOMDocument) {
|
||||
executingKeyBind = PR_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get DOMEvent target
|
||||
nsCOMPtr<nsIDOMNode> target = nsnull;
|
||||
aKeyEvent->GetTarget(getter_AddRefs(target));
|
||||
executingKeyBind = PR_TRUE;
|
||||
|
||||
if (!aKeyEvent) {
|
||||
executingKeyBind = PR_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!mDOMDocument) {
|
||||
executingKeyBind = PR_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Get DOMEvent target
|
||||
nsCOMPtr<nsIDOMNode> target = nsnull;
|
||||
aKeyEvent->GetTarget(getter_AddRefs(target));
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> piWindow;
|
||||
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
||||
// Find a keyset node
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
||||
// Find a keyset node
|
||||
// Get the current focused object from the command dispatcher
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
||||
mDOMDocument->GetCommandDispatcher(getter_AddRefs(commandDispatcher));
|
||||
@ -505,7 +505,7 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
|
||||
// See if it's a textarea or input field.
|
||||
// XXX Check to see if the "key-bindings" CSS property points us to a file.
|
||||
// Hopefully we can get Pierre to add this. ;)
|
||||
|
||||
|
||||
nsAutoString tagName;
|
||||
focusedElement->GetTagName(tagName);
|
||||
if (tagName.EqualsIgnoreCase("input")) {
|
||||
@ -522,21 +522,21 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
|
||||
platformKeyFile = "chrome://global/content/platformTextAreaBindings.xul";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> document;
|
||||
GetKeyBindingDocument(platformKeyFile, getter_AddRefs(document));
|
||||
|
||||
|
||||
// Locate the key node and execute the JS on a match.
|
||||
PRBool handled = PR_FALSE;
|
||||
if (document) // Local focused ELEMENT handling stage.
|
||||
LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled);
|
||||
|
||||
|
||||
if (!handled) {
|
||||
GetKeyBindingDocument(keyFile, getter_AddRefs(document));
|
||||
if (document) // Local focused ELEMENT handling stage.
|
||||
LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled);
|
||||
LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled);
|
||||
}
|
||||
|
||||
|
||||
nsCAutoString browserFile = "chrome://global/content/browserBindings.xul";
|
||||
nsCAutoString editorFile = "chrome://global/content/editorBindings.xul";
|
||||
nsCAutoString browserPlatformFile = "chrome://global/content/platformBrowserBindings.xul";
|
||||
@ -565,29 +565,23 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
webShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if (nsnull != cv)
|
||||
{
|
||||
if (nsnull != cv) {
|
||||
nsCOMPtr<nsIDocumentViewer> docv;
|
||||
cv->QueryInterface(nsIDocumentViewer::GetIID(), getter_AddRefs(docv));
|
||||
if (nsnull != docv)
|
||||
{
|
||||
if (nsnull != docv) {
|
||||
nsCOMPtr<nsIPresContext> cx;
|
||||
docv->GetPresContext(*getter_AddRefs(cx));
|
||||
if (nsnull != cx)
|
||||
{
|
||||
result = cx->GetShell(getter_AddRefs(presShell));
|
||||
}
|
||||
if (nsnull != cx) {
|
||||
result = cx->GetShell(getter_AddRefs(presShell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool editorHasBindings = PR_FALSE;
|
||||
nsCOMPtr<nsIDOMXULDocument> platformDoc;
|
||||
if (presShell)
|
||||
{
|
||||
if (presShell) {
|
||||
PRBool isEditor;
|
||||
if (NS_SUCCEEDED(presShell->GetDisplayNonTextSelection(&isEditor)) && isEditor)
|
||||
{
|
||||
if (NS_SUCCEEDED(presShell->GetDisplayNonTextSelection(&isEditor)) && isEditor) {
|
||||
editorHasBindings = PR_TRUE;
|
||||
GetKeyBindingDocument(editorPlatformFile, getter_AddRefs(platformDoc));
|
||||
GetKeyBindingDocument(editorFile, getter_AddRefs(document));
|
||||
@ -613,18 +607,18 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
|
||||
}
|
||||
}
|
||||
|
||||
executingKeyBind = PR_FALSE;
|
||||
return ret;
|
||||
executingKeyBind = PR_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
PRBool nsXULKeyListenerImpl::IsMatchingKeyCode(const PRUint32 theChar, const nsString &keyName)
|
||||
{
|
||||
PRBool ret = PR_FALSE;
|
||||
|
||||
|
||||
//printf("theChar = %d \n", theChar);
|
||||
//printf("keyName = %s \n", keyName.ToNewCString());
|
||||
//printf("\n");
|
||||
|
||||
|
||||
switch ( theChar ) {
|
||||
case VK_CANCEL:
|
||||
if(keyName == "VK_CANCEL")
|
||||
@ -1075,20 +1069,20 @@ PRBool nsXULKeyListenerImpl::IsMatchingKeyCode(const PRUint32 theChar, const nsS
|
||||
ret = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PRBool nsXULKeyListenerImpl::IsMatchingCharCode(const nsString &theChar, const nsString &keyName)
|
||||
{
|
||||
PRBool ret = PR_FALSE;
|
||||
|
||||
|
||||
//printf("theChar = %s \n", theChar.ToNewCString());
|
||||
//printf("keyName = %s \n", keyName.ToNewCString());
|
||||
//printf("\n");
|
||||
if(theChar == keyName)
|
||||
ret = PR_TRUE;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1106,7 +1100,7 @@ NS_IMETHODIMP nsXULKeyListenerImpl::GetKeyBindingDocument(nsCAutoString& aURLStr
|
||||
// We've got a file. Check our key binding file cache.
|
||||
nsIURIKey key(uri);
|
||||
document = dont_AddRef(NS_STATIC_CAST(nsIDOMXULDocument*, mKeyBindingTable->Get(&key)));
|
||||
|
||||
|
||||
if (!document) {
|
||||
LoadKeyBindingDocument(uri, getter_AddRefs(document));
|
||||
if (document) {
|
||||
@ -1162,7 +1156,7 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX
|
||||
xulDoc->SetMasterPrototype(proto);
|
||||
xulDoc->SetCurrentPrototype(proto);
|
||||
|
||||
|
||||
|
||||
rv = proto->SetURI(aURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -1217,7 +1211,7 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX
|
||||
nsProxyStream* proxy = new nsProxyStream();
|
||||
if (! proxy)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
listener->OnStartRequest(channel, nsnull);
|
||||
while (PR_TRUE) {
|
||||
char buf[1024];
|
||||
@ -1241,7 +1235,7 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX
|
||||
// don't leak proxy!
|
||||
proxy->Close();
|
||||
delete proxy;
|
||||
|
||||
|
||||
// The document is parsed. We now have a prototype document.
|
||||
// Everything worked, so we can just hand this back now.
|
||||
*aResult = doc;
|
||||
@ -1256,41 +1250,41 @@ nsXULKeyListenerImpl::LocateAndExecuteKeyBinding(nsIDOMKeyEvent* aEvent, eEventT
|
||||
aHandledFlag = PR_FALSE;
|
||||
|
||||
// locate the window element which holds the top level key bindings
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
aDocument->GetDocumentElement(getter_AddRefs(rootElement));
|
||||
if (!rootElement)
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
aDocument->GetDocumentElement(getter_AddRefs(rootElement));
|
||||
if (!rootElement)
|
||||
return NS_OK;
|
||||
|
||||
//nsAutoString rootName;
|
||||
//rootElement->GetNodeName(rootName);
|
||||
//printf("Root Node [%s] \n", rootName.ToNewCString()); // this leaks
|
||||
|
||||
nsCOMPtr<nsIDOMNode> currNode;
|
||||
rootElement->GetFirstChild(getter_AddRefs(currNode));
|
||||
|
||||
|
||||
//nsAutoString rootName;
|
||||
//rootElement->GetNodeName(rootName);
|
||||
//printf("Root Node [%s] \n", rootName.ToNewCString()); // this leaks
|
||||
|
||||
nsCOMPtr<nsIDOMNode> currNode;
|
||||
rootElement->GetFirstChild(getter_AddRefs(currNode));
|
||||
|
||||
while (currNode) {
|
||||
nsAutoString currNodeType;
|
||||
nsCOMPtr<nsIDOMElement> currElement(do_QueryInterface(currNode));
|
||||
nsAutoString currNodeType;
|
||||
nsCOMPtr<nsIDOMElement> currElement(do_QueryInterface(currNode));
|
||||
if (currElement) {
|
||||
currElement->GetNodeName(currNodeType);
|
||||
currElement->GetNodeName(currNodeType);
|
||||
if (currNodeType.Equals("keyset"))
|
||||
return HandleEventUsingKeyset(currElement, aEvent, aEventType, aDocument, aHandledFlag);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> prevNode(currNode);
|
||||
prevNode->GetNextSibling(getter_AddRefs(currNode));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> prevNode(currNode);
|
||||
prevNode->GetNextSibling(getter_AddRefs(currNode));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsIDOMKeyEvent* aKeyEvent, eEventType aEventType,
|
||||
nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsIDOMKeyEvent* aKeyEvent, eEventType aEventType,
|
||||
nsIDOMXULDocument* aDocument, PRBool& aHandledFlag)
|
||||
{
|
||||
|
||||
nsAutoString trueString = "true";
|
||||
nsAutoString falseString = "false";
|
||||
nsAutoString falseString = "false";
|
||||
|
||||
#undef DEBUG_XUL_KEYS
|
||||
#ifdef DEBUG_XUL_KEYS
|
||||
@ -1314,110 +1308,110 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
}
|
||||
#endif /* DEBUG_XUL_KEYS */
|
||||
|
||||
// Given the DOM node and Key Event
|
||||
// Walk the node's children looking for 'key' types
|
||||
// Given the DOM node and Key Event
|
||||
// Walk the node's children looking for 'key' types
|
||||
|
||||
// XXX Use the key-equivalent CSS3 property to obtain the
|
||||
// appropriate modifier for this keyset.
|
||||
// TODO. For now it's hardcoded.
|
||||
|
||||
// If the node isn't tagged disabled
|
||||
// Compares the received key code to found 'key' types
|
||||
// Executes command if found
|
||||
// Marks event as consumed
|
||||
|
||||
// If the node isn't tagged disabled
|
||||
// Compares the received key code to found 'key' types
|
||||
// Executes command if found
|
||||
// Marks event as consumed
|
||||
|
||||
nsCOMPtr<nsIDOMNode> keyNode;
|
||||
aKeysetElement->GetFirstChild(getter_AddRefs(keyNode));
|
||||
while (keyNode) {
|
||||
nsCOMPtr<nsIDOMElement> keyElement(do_QueryInterface(keyNode));
|
||||
nsCOMPtr<nsIDOMElement> keyElement(do_QueryInterface(keyNode));
|
||||
if (!keyElement)
|
||||
continue;
|
||||
|
||||
nsAutoString property;
|
||||
keyElement->GetNodeName(property);
|
||||
//printf("keyNodeType [%s] \n", keyNodeType.ToNewCString()); // this leaks
|
||||
nsAutoString property;
|
||||
keyElement->GetNodeName(property);
|
||||
//printf("keyNodeType [%s] \n", keyNodeType.ToNewCString()); // this leaks
|
||||
|
||||
if (property.Equals("key")) {
|
||||
//printf("onkeypress [%s] \n", cmdToExecute.ToNewCString()); // this leaks
|
||||
do {
|
||||
property = falseString;
|
||||
keyElement->GetAttribute(nsAutoString("disabled"), property);
|
||||
if (property == trueString) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoString keyName; // This should be phased out for keycode and charcode
|
||||
keyElement->GetAttribute(nsAutoString("key"), keyName);
|
||||
//printf("Found key [%s] \n", keyName.ToNewCString()); // this leaks
|
||||
|
||||
PRUint32 theChar;
|
||||
nsAutoString code; // either keycode or charcode
|
||||
PRBool gotCharCode = PR_FALSE;
|
||||
PRBool gotKeyCode = PR_FALSE;
|
||||
keyElement->GetAttribute(nsAutoString("charcode"), code);
|
||||
if(code.IsEmpty()) {
|
||||
keyElement->GetAttribute(nsAutoString("keycode"), code);
|
||||
//printf("onkeypress [%s] \n", cmdToExecute.ToNewCString()); // this leaks
|
||||
do {
|
||||
property = falseString;
|
||||
keyElement->GetAttribute(nsAutoString("disabled"), property);
|
||||
if (property == trueString) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoString keyName; // This should be phased out for keycode and charcode
|
||||
keyElement->GetAttribute(nsAutoString("key"), keyName);
|
||||
//printf("Found key [%s] \n", keyName.ToNewCString()); // this leaks
|
||||
|
||||
PRUint32 theChar;
|
||||
nsAutoString code; // either keycode or charcode
|
||||
PRBool gotCharCode = PR_FALSE;
|
||||
PRBool gotKeyCode = PR_FALSE;
|
||||
keyElement->GetAttribute(nsAutoString("charcode"), code);
|
||||
if(code.IsEmpty()) {
|
||||
keyElement->GetAttribute(nsAutoString("keycode"), code);
|
||||
if(code.IsEmpty()) {
|
||||
// HACK for temporary compatibility
|
||||
if(aEventType == eKeyPress)
|
||||
aKeyEvent->GetCharCode(&theChar);
|
||||
else
|
||||
aKeyEvent->GetKeyCode(&theChar);
|
||||
|
||||
|
||||
} else {
|
||||
// We want a keycode
|
||||
aKeyEvent->GetKeyCode(&theChar);
|
||||
gotKeyCode = PR_TRUE;
|
||||
}
|
||||
} else {
|
||||
// We want a charcode
|
||||
aKeyEvent->GetCharCode(&theChar);
|
||||
gotCharCode = PR_TRUE;
|
||||
}
|
||||
|
||||
char tempChar[2];
|
||||
tempChar[0] = theChar;
|
||||
tempChar[1] = 0;
|
||||
nsAutoString tempChar2 = tempChar;
|
||||
//printf("compare key [%s] \n", tempChar2.ToNewCString()); // this leaks
|
||||
// NOTE - convert theChar and keyName to upper
|
||||
keyName.ToUpperCase();
|
||||
tempChar2.ToUpperCase();
|
||||
|
||||
PRBool isMatching;
|
||||
if(gotCharCode){
|
||||
isMatching = IsMatchingCharCode(tempChar2, code);
|
||||
} else if(gotKeyCode){
|
||||
isMatching = IsMatchingKeyCode(theChar, code);
|
||||
}
|
||||
|
||||
// HACK for backward compatibility
|
||||
if(!gotCharCode && ! gotKeyCode){
|
||||
isMatching = IsMatchingCharCode(tempChar2, keyName);
|
||||
}
|
||||
|
||||
if (!isMatching) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// We want a charcode
|
||||
aKeyEvent->GetCharCode(&theChar);
|
||||
gotCharCode = PR_TRUE;
|
||||
}
|
||||
|
||||
char tempChar[2];
|
||||
tempChar[0] = theChar;
|
||||
tempChar[1] = 0;
|
||||
nsAutoString tempChar2 = tempChar;
|
||||
//printf("compare key [%s] \n", tempChar2.ToNewCString()); // this leaks
|
||||
// NOTE - convert theChar and keyName to upper
|
||||
keyName.ToUpperCase();
|
||||
tempChar2.ToUpperCase();
|
||||
|
||||
PRBool isMatching;
|
||||
if(gotCharCode){
|
||||
isMatching = IsMatchingCharCode(tempChar2, code);
|
||||
} else if(gotKeyCode){
|
||||
isMatching = IsMatchingKeyCode(theChar, code);
|
||||
}
|
||||
|
||||
// HACK for backward compatibility
|
||||
if(!gotCharCode && ! gotKeyCode){
|
||||
isMatching = IsMatchingCharCode(tempChar2, keyName);
|
||||
}
|
||||
|
||||
if (!isMatching) {
|
||||
break;
|
||||
}
|
||||
|
||||
// This is gross -- we're doing string compares
|
||||
// every time we loop over this list!
|
||||
|
||||
// Modifiers in XUL files are tri-state --
|
||||
// Modifiers in XUL files are tri-state --
|
||||
// true, false, and unspecified.
|
||||
// If a modifier is unspecified, we don't check
|
||||
// the status of that modifier (always match).
|
||||
|
||||
// Get the attribute for the "xulkey" modifier.
|
||||
// Get the attribute for the "xulkey" modifier.
|
||||
nsAutoString xproperty = "";
|
||||
keyElement->GetAttribute(nsAutoString("xulkey"),
|
||||
xproperty);
|
||||
|
||||
// Is the modifier key set in the event?
|
||||
PRBool isModKey = PR_FALSE;
|
||||
PRBool isModKey = PR_FALSE;
|
||||
|
||||
// Check whether the shift key fails to match:
|
||||
aKeyEvent->GetShiftKey(&isModKey);
|
||||
aKeyEvent->GetShiftKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("shift"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
@ -1430,10 +1424,10 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
break;
|
||||
|
||||
// and the control key:
|
||||
aKeyEvent->GetCtrlKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("control"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
aKeyEvent->GetCtrlKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("control"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
|| (property == falseString && isModKey))
|
||||
break;
|
||||
// and if xul is control:
|
||||
@ -1443,10 +1437,10 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
break;
|
||||
|
||||
// and the alt key
|
||||
aKeyEvent->GetAltKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("alt"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
aKeyEvent->GetAltKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("alt"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
|| (property == falseString && isModKey))
|
||||
break;
|
||||
// and if xul is alt:
|
||||
@ -1456,10 +1450,10 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
break;
|
||||
|
||||
// and the meta key
|
||||
aKeyEvent->GetMetaKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("meta"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
aKeyEvent->GetMetaKey(&isModKey);
|
||||
property = "";
|
||||
keyElement->GetAttribute(nsAutoString("meta"), property);
|
||||
if ((property == trueString && !isModKey)
|
||||
|| (property == falseString && isModKey))
|
||||
break;
|
||||
// and if xul is meta:
|
||||
@ -1478,33 +1472,33 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Modifier tests passed so execute onclick command
|
||||
nsAutoString cmdToExecute;
|
||||
nsAutoString oncommand;
|
||||
switch(aEventType) {
|
||||
case eKeyPress:
|
||||
keyElement->GetAttribute(nsAutoString("onkeypress"), cmdToExecute);
|
||||
// Modifier tests passed so execute onclick command
|
||||
nsAutoString cmdToExecute;
|
||||
nsAutoString oncommand;
|
||||
switch(aEventType) {
|
||||
case eKeyPress:
|
||||
keyElement->GetAttribute(nsAutoString("onkeypress"), cmdToExecute);
|
||||
#if defined(DEBUG_saari)
|
||||
printf("onkeypress = %s\n",
|
||||
printf("onkeypress = %s\n",
|
||||
cmdToExecute.ToNewCString());
|
||||
#endif
|
||||
|
||||
keyElement->GetAttribute(nsAutoString("oncommand"), oncommand);
|
||||
keyElement->GetAttribute(nsAutoString("oncommand"), oncommand);
|
||||
#if defined(DEBUG_saari)
|
||||
printf("oncommand = %s\n", oncommand.ToNewCString());
|
||||
printf("oncommand = %s\n", oncommand.ToNewCString());
|
||||
#endif
|
||||
break;
|
||||
case eKeyDown:
|
||||
keyElement->GetAttribute(nsAutoString("onkeydown"), cmdToExecute);
|
||||
break;
|
||||
case eKeyUp:
|
||||
keyElement->GetAttribute(nsAutoString("onkeyup"), cmdToExecute);
|
||||
break;
|
||||
}
|
||||
|
||||
// This code executes in every presentation context in which this
|
||||
// document is appearing.
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
|
||||
break;
|
||||
case eKeyDown:
|
||||
keyElement->GetAttribute(nsAutoString("onkeydown"), cmdToExecute);
|
||||
break;
|
||||
case eKeyUp:
|
||||
keyElement->GetAttribute(nsAutoString("onkeyup"), cmdToExecute);
|
||||
break;
|
||||
}
|
||||
|
||||
// This code executes in every presentation context in which this
|
||||
// document is appearing.
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(keyElement);
|
||||
if (aDocument != mDOMDocument) {
|
||||
nsCOMPtr<nsIScriptEventHandlerOwner> handlerOwner = do_QueryInterface(keyElement);
|
||||
@ -1529,19 +1523,19 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> masterGlobalObject;
|
||||
nsCOMPtr<nsIDocument> masterDoc = do_QueryInterface(mDOMDocument);
|
||||
masterDoc->GetScriptGlobalObject(getter_AddRefs(masterGlobalObject));
|
||||
masterDoc->GetScriptGlobalObject(getter_AddRefs(masterGlobalObject));
|
||||
nsCOMPtr<nsIScriptContext> masterContext;
|
||||
masterGlobalObject->GetContext(getter_AddRefs(masterContext));
|
||||
|
||||
|
||||
if (!handler) {
|
||||
// It hasn't been compiled before.
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
document->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
if (!globalObject) {
|
||||
NS_NewScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
document->SetScriptGlobalObject(globalObject);
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIScriptContext> context;
|
||||
globalObject->GetContext(getter_AddRefs(context));
|
||||
if (!context) {
|
||||
@ -1558,7 +1552,8 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
nsAutoString value;
|
||||
keyContent->GetAttribute(kNameSpaceID_None, eventName, value);
|
||||
if (value != "") {
|
||||
context->CompileEventHandler(scriptObject, eventName, value, &handler);
|
||||
context->CompileEventHandler(scriptObject, eventName, value,
|
||||
PR_TRUE, &handler);
|
||||
}
|
||||
|
||||
if (handler)
|
||||
@ -1567,7 +1562,7 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
|
||||
if (handler) {
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
mDOMDocument->GetDocumentElement(getter_AddRefs(rootElement));
|
||||
mDOMDocument->GetDocumentElement(getter_AddRefs(rootElement));
|
||||
nsCOMPtr<nsIScriptObjectOwner> owner = do_QueryInterface(rootElement);
|
||||
void* scriptObject;
|
||||
owner->GetScriptObject(masterContext, &scriptObject);
|
||||
@ -1627,11 +1622,11 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
return ret;
|
||||
} // end for (PRInt32 i = 0; i < count; i++)
|
||||
} while (PR_FALSE); // do { ...
|
||||
} // end if (keyNodeType.Equals("key"))
|
||||
|
||||
nsCOMPtr<nsIDOMNode> oldkeyNode(keyNode);
|
||||
} // end if (keyNodeType.Equals("key"))
|
||||
|
||||
nsCOMPtr<nsIDOMNode> oldkeyNode(keyNode);
|
||||
oldkeyNode->GetNextSibling(getter_AddRefs(keyNode));
|
||||
} // end while(keynode)
|
||||
} // end while(keynode)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1640,11 +1635,11 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
|
||||
nsresult
|
||||
NS_NewXULKeyListener(nsIXULKeyListener** aListener)
|
||||
{
|
||||
nsXULKeyListenerImpl * listener = new nsXULKeyListenerImpl();
|
||||
if (!listener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(listener);
|
||||
*aListener = listener;
|
||||
return NS_OK;
|
||||
nsXULKeyListenerImpl * listener = new nsXULKeyListenerImpl();
|
||||
if (!listener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(listener);
|
||||
*aListener = listener;
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user