Fixing an XBL event handling bug and a menu shortcut bug. r=brendan, a=leaf
This commit is contained in:
Родитель
17a5546da1
Коммит
2ffbbf0cf2
|
@ -29,6 +29,7 @@
|
|||
class nsIScriptContext;
|
||||
class nsIScriptObjectOwner;
|
||||
class nsIDOMEventListener;
|
||||
class nsString;
|
||||
|
||||
#define NS_IJSEVENTLISTENER_IID \
|
||||
{ 0xa6cf9118, 0x15b3, 0x11d2, \
|
||||
|
@ -41,6 +42,7 @@ public:
|
|||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IJSEVENTLISTENER_IID)
|
||||
|
||||
NS_IMETHOD GetEventTarget(nsIScriptContext** aContext, nsIScriptObjectOwner** aOwner) = 0;
|
||||
NS_IMETHOD SetEventName(nsIAtom* aName) = 0;
|
||||
};
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewJSEventListener(nsIDOMEventListener ** aInstancePtrResult, nsIScriptContext *aContext, nsIScriptObjectOwner* aOwner);
|
||||
|
|
|
@ -80,6 +80,12 @@ NS_IMPL_RELEASE(nsJSEventListener)
|
|||
|
||||
//static nsString onPrefix = "on";
|
||||
|
||||
nsresult nsJSEventListener::SetEventName(nsIAtom* aName)
|
||||
{
|
||||
mEventName = aName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
jsval funval;
|
||||
|
@ -94,12 +100,18 @@ nsresult nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
JSObject* obj;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (NS_OK != aEvent->GetType(eventString)) {
|
||||
//JS can't handle this event yet or can't handle it at all
|
||||
return NS_OK;
|
||||
if (!mEventName) {
|
||||
if (NS_OK != aEvent->GetType(eventString)) {
|
||||
//JS can't handle this event yet or can't handle it at all
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
eventString.InsertWithConversion("on", 0, 2);
|
||||
}
|
||||
else {
|
||||
mEventName->ToString(eventString);
|
||||
}
|
||||
|
||||
eventString.InsertWithConversion("on", 0, 2);
|
||||
eventChars = eventString.ToNewCString();
|
||||
|
||||
result = mOwner->GetScriptObject(mContext, (void**)&obj);
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "nsIJSEventListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
//nsIDOMMouseListener interface
|
||||
class nsJSEventListener : public nsIDOMEventListener,
|
||||
|
@ -45,9 +47,12 @@ public:
|
|||
//nsIJSEventListener interface
|
||||
NS_IMETHOD GetEventTarget(nsIScriptContext** aContext, nsIScriptObjectOwner** aOwner);
|
||||
|
||||
NS_IMETHOD SetEventName(nsIAtom* aName);
|
||||
|
||||
protected:
|
||||
nsIScriptContext* mContext;
|
||||
nsIScriptObjectOwner* mOwner;
|
||||
nsCOMPtr<nsIAtom> mEventName;
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче