Adding originalTarget to Event object. r=joki

This commit is contained in:
hyatt%netscape.com 2000-09-07 01:07:29 +00:00
Родитель 824ee3933d
Коммит f542d90ef4
12 изменённых файлов: 75 добавлений и 69 удалений

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

@ -47,6 +47,7 @@ public:
NS_IMETHOD DuplicatePrivateData() = 0; NS_IMETHOD DuplicatePrivateData() = 0;
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) = 0; NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aTarget) = 0; NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD SetOriginalTarget(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0; NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0;
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0; NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0;
NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aRealTarget) = 0; NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aRealTarget) = 0;

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

@ -83,6 +83,7 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsAR
} }
mTarget = nsnull; mTarget = nsnull;
mCurrentTarget = nsnull; mCurrentTarget = nsnull;
mOriginalTarget = nsnull;
mText = nsnull; mText = nsnull;
mTextRange = nsnull; mTextRange = nsnull;
@ -119,6 +120,7 @@ nsDOMEvent::~nsDOMEvent() {
NS_IF_RELEASE(mPresContext); NS_IF_RELEASE(mPresContext);
NS_IF_RELEASE(mTarget); NS_IF_RELEASE(mTarget);
NS_IF_RELEASE(mCurrentTarget); NS_IF_RELEASE(mCurrentTarget);
NS_IF_RELEASE(mOriginalTarget);
NS_IF_RELEASE(mTextRange); NS_IF_RELEASE(mTextRange);
if (mEventIsInternal) { if (mEventIsInternal) {
@ -207,6 +209,14 @@ nsDOMEvent::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDOMEvent::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)
{
*aOriginalTarget = mOriginalTarget;
NS_IF_ADDREF(*aOriginalTarget);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase) nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
{ {
@ -1022,6 +1032,16 @@ NS_METHOD nsDOMEvent::SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget)
return NS_OK; return NS_OK;
} }
NS_METHOD nsDOMEvent::SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget)
{
if (mOriginalTarget != aOriginalTarget) {
NS_IF_RELEASE(mOriginalTarget);
NS_IF_ADDREF(aOriginalTarget);
mOriginalTarget = aOriginalTarget;
}
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped) nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped)
{ {

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

@ -99,6 +99,7 @@ public:
NS_IMETHOD GetType(nsAWritableString& aType); NS_IMETHOD GetType(nsAWritableString& aType);
NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget); NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget);
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget); NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget);
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget);
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); NS_IMETHOD GetEventPhase(PRUint16* aEventPhase);
NS_IMETHOD GetBubbles(PRBool* aBubbles); NS_IMETHOD GetBubbles(PRBool* aBubbles);
NS_IMETHOD GetCancelable(PRBool* aCancelable); NS_IMETHOD GetCancelable(PRBool* aCancelable);
@ -147,6 +148,7 @@ public:
NS_IMETHOD DuplicatePrivateData(); NS_IMETHOD DuplicatePrivateData();
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget); NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget);
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget); NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget);
NS_IMETHOD SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget);
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped); NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped);
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent); NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent);
NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aTarget); NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aTarget);
@ -173,6 +175,7 @@ protected:
nsIPresContext* mPresContext; nsIPresContext* mPresContext;
nsIDOMEventTarget* mTarget; nsIDOMEventTarget* mTarget;
nsIDOMEventTarget* mCurrentTarget; nsIDOMEventTarget* mCurrentTarget;
nsIDOMEventTarget* mOriginalTarget;
nsString* mText; nsString* mText;
nsIPrivateTextRangeList* mTextRange; nsIPrivateTextRangeList* mTextRange;
const char* GetEventName(PRUint32 aEventType); const char* GetEventName(PRUint32 aEventType);

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

@ -84,6 +84,8 @@ public:
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)=0; NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)=0;
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)=0;
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase)=0; NS_IMETHOD GetEventPhase(PRUint16* aEventPhase)=0;
NS_IMETHOD GetBubbles(PRBool* aBubbles)=0; NS_IMETHOD GetBubbles(PRBool* aBubbles)=0;
@ -108,6 +110,7 @@ public:
NS_IMETHOD GetType(nsAWritableString& aType); \ NS_IMETHOD GetType(nsAWritableString& aType); \
NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget); \ NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget); \
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget); \ NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget); \
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget); \
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); \ NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); \
NS_IMETHOD GetBubbles(PRBool* aBubbles); \ NS_IMETHOD GetBubbles(PRBool* aBubbles); \
NS_IMETHOD GetCancelable(PRBool* aCancelable); \ NS_IMETHOD GetCancelable(PRBool* aCancelable); \
@ -124,6 +127,7 @@ public:
NS_IMETHOD GetType(nsAWritableString& aType) { return _to GetType(aType); } \ NS_IMETHOD GetType(nsAWritableString& aType) { return _to GetType(aType); } \
NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget) { return _to GetTarget(aTarget); } \ NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget) { return _to GetTarget(aTarget); } \
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget) { return _to GetCurrentTarget(aCurrentTarget); } \ NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget) { return _to GetCurrentTarget(aCurrentTarget); } \
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget) { return _to GetOriginalTarget(aOriginalTarget); } \
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase) { return _to GetEventPhase(aEventPhase); } \ NS_IMETHOD GetEventPhase(PRUint16* aEventPhase) { return _to GetEventPhase(aEventPhase); } \
NS_IMETHOD GetBubbles(PRBool* aBubbles) { return _to GetBubbles(aBubbles); } \ NS_IMETHOD GetBubbles(PRBool* aBubbles) { return _to GetBubbles(aBubbles); } \
NS_IMETHOD GetCancelable(PRBool* aCancelable) { return _to GetCancelable(aCancelable); } \ NS_IMETHOD GetCancelable(PRBool* aCancelable) { return _to GetCancelable(aCancelable); } \

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

@ -1,64 +0,0 @@
interface Event {
/* IID: { 0xa66b7b80, 0xff46, 0xbd97, \
{ 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0x8a, 0xdd, 0x32 } } */
const unsigned short CAPTURING_PHASE = 1;
const unsigned short AT_TARGET = 2;
const unsigned short BUBBLING_PHASE = 3;
const int MOUSEDOWN = 0x00000001;
const int MOUSEUP = 0x00000002;
const int MOUSEOVER = 0x00000004;
const int MOUSEOUT = 0x00000008;
const int MOUSEMOVE = 0x00000010;
const int MOUSEDRAG = 0x00000020;
const int CLICK = 0x00000040;
const int DBLCLICK = 0x00000080;
const int KEYDOWN = 0x00000100;
const int KEYUP = 0x00000200;
const int KEYPRESS = 0x00000400;
const int DRAGDROP = 0x00000800;
const int FOCUS = 0x00001000;
const int BLUR = 0x00002000;
const int SELECT = 0x00004000;
const int CHANGE = 0x00008000;
const int RESET = 0x00010000;
const int SUBMIT = 0x00020000;
const int SCROLL = 0x00040000;
const int LOAD = 0x00080000;
const int UNLOAD = 0x00100000;
const int XFER_DONE = 0x00200000;
const int ABORT = 0x00400000;
const int ERROR = 0x00800000;
const int LOCATE = 0x01000000;
const int MOVE = 0x02000000;
const int RESIZE = 0x04000000;
const int FORWARD = 0x08000000;
const int HELP = 0x10000000;
const int BACK = 0x20000000;
const int TEXT = 0x40000000;
const int ALT_MASK = 0x00000001;
const int CONTROL_MASK = 0x00000002;
const int SHIFT_MASK = 0x00000004;
const int META_MASK = 0x00000008;
readonly attribute wstring type;
readonly attribute EventTarget target;
readonly attribute EventTarget currentTarget;
readonly attribute unsigned short eventPhase;
readonly attribute boolean bubbles;
readonly attribute boolean cancelable;
readonly attribute unsigned longlong timeStamp;
void stopPropagation();
void preventBubble();
void preventCapture();
void preventDefault();
void initEvent(in wstring eventTypeArg,
in boolean canBubbleArg,
in boolean cancelableArg);
};

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

@ -294,7 +294,8 @@ enum nsDOMProp {
NS_DOM_PROP_EVENT_CANCELABLE, NS_DOM_PROP_EVENT_CANCELABLE,
NS_DOM_PROP_EVENT_CURRENTTARGET, NS_DOM_PROP_EVENT_CURRENTTARGET,
NS_DOM_PROP_EVENT_EVENTPHASE, NS_DOM_PROP_EVENT_EVENTPHASE,
NS_DOM_PROP_EVENT_INITEVENT, NS_DOM_PROP_EVENT_INITEVENT,
NS_DOM_PROP_EVENT_ORIGINALTARGET,
NS_DOM_PROP_EVENT_PREVENTBUBBLE, NS_DOM_PROP_EVENT_PREVENTBUBBLE,
NS_DOM_PROP_EVENT_PREVENTCAPTURE, NS_DOM_PROP_EVENT_PREVENTCAPTURE,
NS_DOM_PROP_EVENT_PREVENTDEFAULT, NS_DOM_PROP_EVENT_PREVENTDEFAULT,

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

@ -293,6 +293,7 @@
"event.currenttarget", \ "event.currenttarget", \
"event.eventphase", \ "event.eventphase", \
"event.initevent", \ "event.initevent", \
"event.originaltarget", \
"event.preventbubble", \ "event.preventbubble", \
"event.preventcapture", \ "event.preventcapture", \
"event.preventdefault", \ "event.preventdefault", \

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

@ -20,6 +20,7 @@
* Contributor(s): * Contributor(s):
* Travis Bogard <travis@netscape.com> * Travis Bogard <travis@netscape.com>
* Brendan Eich <brendan@mozilla.org> * Brendan Eich <brendan@mozilla.org>
* David Hyatt (hyatt@netscape.com)
*/ */
// Local Includes // Local Includes

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

@ -51,10 +51,11 @@ enum Event_slots {
EVENT_TYPE = -1, EVENT_TYPE = -1,
EVENT_TARGET = -2, EVENT_TARGET = -2,
EVENT_CURRENTTARGET = -3, EVENT_CURRENTTARGET = -3,
EVENT_EVENTPHASE = -4, EVENT_ORIGINALTARGET = -4,
EVENT_BUBBLES = -5, EVENT_EVENTPHASE = -5,
EVENT_CANCELABLE = -6, EVENT_BUBBLES = -6,
EVENT_TIMESTAMP = -7 EVENT_CANCELABLE = -7,
EVENT_TIMESTAMP = -8
}; };
/***********************************************************************/ /***********************************************************************/
@ -115,6 +116,19 @@ GetEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
} }
break; break;
} }
case EVENT_ORIGINALTARGET:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_EVENT_ORIGINALTARGET, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsIDOMEventTarget* prop;
rv = a->GetOriginalTarget(&prop);
if (NS_SUCCEEDED(rv)) {
// get the js object
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
}
}
break;
}
case EVENT_EVENTPHASE: case EVENT_EVENTPHASE:
{ {
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_EVENT_EVENTPHASE, PR_FALSE); rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_EVENT_EVENTPHASE, PR_FALSE);
@ -464,6 +478,7 @@ static JSPropertySpec EventProperties[] =
{"type", EVENT_TYPE, JSPROP_ENUMERATE | JSPROP_READONLY}, {"type", EVENT_TYPE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"target", EVENT_TARGET, JSPROP_ENUMERATE | JSPROP_READONLY}, {"target", EVENT_TARGET, JSPROP_ENUMERATE | JSPROP_READONLY},
{"currentTarget", EVENT_CURRENTTARGET, JSPROP_ENUMERATE | JSPROP_READONLY}, {"currentTarget", EVENT_CURRENTTARGET, JSPROP_ENUMERATE | JSPROP_READONLY},
{"originalTarget", EVENT_ORIGINALTARGET, JSPROP_ENUMERATE | JSPROP_READONLY},
{"eventPhase", EVENT_EVENTPHASE, JSPROP_ENUMERATE | JSPROP_READONLY}, {"eventPhase", EVENT_EVENTPHASE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"bubbles", EVENT_BUBBLES, JSPROP_ENUMERATE | JSPROP_READONLY}, {"bubbles", EVENT_BUBBLES, JSPROP_ENUMERATE | JSPROP_READONLY},
{"cancelable", EVENT_CANCELABLE, JSPROP_ENUMERATE | JSPROP_READONLY}, {"cancelable", EVENT_CANCELABLE, JSPROP_ENUMERATE | JSPROP_READONLY},

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

@ -47,6 +47,7 @@ public:
NS_IMETHOD DuplicatePrivateData() = 0; NS_IMETHOD DuplicatePrivateData() = 0;
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) = 0; NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aTarget) = 0; NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD SetOriginalTarget(nsIDOMEventTarget* aTarget) = 0;
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0; NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0;
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0; NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0;
NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aRealTarget) = 0; NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aRealTarget) = 0;

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

@ -83,6 +83,7 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsAR
} }
mTarget = nsnull; mTarget = nsnull;
mCurrentTarget = nsnull; mCurrentTarget = nsnull;
mOriginalTarget = nsnull;
mText = nsnull; mText = nsnull;
mTextRange = nsnull; mTextRange = nsnull;
@ -119,6 +120,7 @@ nsDOMEvent::~nsDOMEvent() {
NS_IF_RELEASE(mPresContext); NS_IF_RELEASE(mPresContext);
NS_IF_RELEASE(mTarget); NS_IF_RELEASE(mTarget);
NS_IF_RELEASE(mCurrentTarget); NS_IF_RELEASE(mCurrentTarget);
NS_IF_RELEASE(mOriginalTarget);
NS_IF_RELEASE(mTextRange); NS_IF_RELEASE(mTextRange);
if (mEventIsInternal) { if (mEventIsInternal) {
@ -207,6 +209,14 @@ nsDOMEvent::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDOMEvent::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget)
{
*aOriginalTarget = mOriginalTarget;
NS_IF_ADDREF(*aOriginalTarget);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMEvent::GetEventPhase(PRUint16* aEventPhase) nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
{ {
@ -1022,6 +1032,16 @@ NS_METHOD nsDOMEvent::SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget)
return NS_OK; return NS_OK;
} }
NS_METHOD nsDOMEvent::SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget)
{
if (mOriginalTarget != aOriginalTarget) {
NS_IF_RELEASE(mOriginalTarget);
NS_IF_ADDREF(aOriginalTarget);
mOriginalTarget = aOriginalTarget;
}
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped) nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped)
{ {

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

@ -99,6 +99,7 @@ public:
NS_IMETHOD GetType(nsAWritableString& aType); NS_IMETHOD GetType(nsAWritableString& aType);
NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget); NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget);
NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget); NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget);
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget);
NS_IMETHOD GetEventPhase(PRUint16* aEventPhase); NS_IMETHOD GetEventPhase(PRUint16* aEventPhase);
NS_IMETHOD GetBubbles(PRBool* aBubbles); NS_IMETHOD GetBubbles(PRBool* aBubbles);
NS_IMETHOD GetCancelable(PRBool* aCancelable); NS_IMETHOD GetCancelable(PRBool* aCancelable);
@ -147,6 +148,7 @@ public:
NS_IMETHOD DuplicatePrivateData(); NS_IMETHOD DuplicatePrivateData();
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget); NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget);
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget); NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget);
NS_IMETHOD SetOriginalTarget(nsIDOMEventTarget* aOriginalTarget);
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped); NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped);
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent); NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent);
NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aTarget); NS_IMETHOD GetRealTarget(nsIDOMEventTarget** aTarget);
@ -173,6 +175,7 @@ protected:
nsIPresContext* mPresContext; nsIPresContext* mPresContext;
nsIDOMEventTarget* mTarget; nsIDOMEventTarget* mTarget;
nsIDOMEventTarget* mCurrentTarget; nsIDOMEventTarget* mCurrentTarget;
nsIDOMEventTarget* mOriginalTarget;
nsString* mText; nsString* mText;
nsIPrivateTextRangeList* mTextRange; nsIPrivateTextRangeList* mTextRange;
const char* GetEventName(PRUint32 aEventType); const char* GetEventName(PRUint32 aEventType);