зеркало из https://github.com/mozilla/pjs.git
Adding more backwards compat DOM support (event.which, pageX, and pageY)
This commit is contained in:
Родитель
fa92211c9b
Коммит
76afffebc9
|
@ -306,6 +306,50 @@ NS_METHOD nsDOMEvent::SetLayerY(PRInt32 aLayerY)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
||||
{
|
||||
return GetClientX(aPageX);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetPageX(PRInt32 aPageX)
|
||||
{
|
||||
return SetClientX(aPageX);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetPageY(PRInt32* aPageY)
|
||||
{
|
||||
return GetClientY(aPageY);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetPageY(PRInt32 aPageY)
|
||||
{
|
||||
return SetClientY(aPageY);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
|
||||
{
|
||||
switch (mEvent->eventStructType) {
|
||||
case NS_KEY_EVENT:
|
||||
return GetKeyCode(aWhich);
|
||||
break;
|
||||
case NS_MOUSE_EVENT:
|
||||
return GetButton(aWhich);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetWhich(PRUint32 aWhich)
|
||||
{
|
||||
switch (mEvent->eventStructType) {
|
||||
case NS_KEY_EVENT:
|
||||
return SetKeyCode(aWhich);
|
||||
break;
|
||||
case NS_MOUSE_EVENT:
|
||||
return SetButton(aWhich);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::DuplicatePrivateData()
|
||||
{
|
||||
//XXX Write me!
|
||||
|
|
|
@ -117,6 +117,15 @@ public:
|
|||
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY);
|
||||
|
||||
NS_IMETHOD GetPageX(PRInt32* aClientX);
|
||||
NS_IMETHOD SetPageX(PRInt32 aClientX);
|
||||
|
||||
NS_IMETHOD GetPageY(PRInt32* aClientY);
|
||||
NS_IMETHOD SetPageY(PRInt32 aClientY);
|
||||
|
||||
NS_IMETHOD GetWhich(PRUint32* aKeyCode);
|
||||
NS_IMETHOD SetWhich(PRUint32 aKeyCode);
|
||||
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc);
|
||||
|
||||
// nsIPrivateDOMEvent interface
|
||||
|
|
|
@ -75,6 +75,15 @@ public:
|
|||
NS_IMETHOD GetLayerY(PRInt32* aLayerY)=0;
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY)=0;
|
||||
|
||||
NS_IMETHOD GetPageX(PRInt32* aPageX)=0;
|
||||
NS_IMETHOD SetPageX(PRInt32 aPageX)=0;
|
||||
|
||||
NS_IMETHOD GetPageY(PRInt32* aPageY)=0;
|
||||
NS_IMETHOD SetPageY(PRInt32 aPageY)=0;
|
||||
|
||||
NS_IMETHOD GetWhich(PRUint32* aWhich)=0;
|
||||
NS_IMETHOD SetWhich(PRUint32 aWhich)=0;
|
||||
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc)=0;
|
||||
};
|
||||
|
||||
|
@ -84,6 +93,12 @@ public:
|
|||
NS_IMETHOD SetLayerX(PRInt32 aLayerX); \
|
||||
NS_IMETHOD GetLayerY(PRInt32* aLayerY); \
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY); \
|
||||
NS_IMETHOD GetPageX(PRInt32* aPageX); \
|
||||
NS_IMETHOD SetPageX(PRInt32 aPageX); \
|
||||
NS_IMETHOD GetPageY(PRInt32* aPageY); \
|
||||
NS_IMETHOD SetPageY(PRInt32 aPageY); \
|
||||
NS_IMETHOD GetWhich(PRUint32* aWhich); \
|
||||
NS_IMETHOD SetWhich(PRUint32 aWhich); \
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc); \
|
||||
|
||||
|
||||
|
@ -93,6 +108,12 @@ public:
|
|||
NS_IMETHOD SetLayerX(PRInt32 aLayerX) { return _to##SetLayerX(aLayerX); } \
|
||||
NS_IMETHOD GetLayerY(PRInt32* aLayerY) { return _to##GetLayerY(aLayerY); } \
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY) { return _to##SetLayerY(aLayerY); } \
|
||||
NS_IMETHOD GetPageX(PRInt32* aPageX) { return _to##GetPageX(aPageX); } \
|
||||
NS_IMETHOD SetPageX(PRInt32 aPageX) { return _to##SetPageX(aPageX); } \
|
||||
NS_IMETHOD GetPageY(PRInt32* aPageY) { return _to##GetPageY(aPageY); } \
|
||||
NS_IMETHOD SetPageY(PRInt32 aPageY) { return _to##SetPageY(aPageY); } \
|
||||
NS_IMETHOD GetWhich(PRUint32* aWhich) { return _to##GetWhich(aWhich); } \
|
||||
NS_IMETHOD SetWhich(PRUint32 aWhich) { return _to##SetWhich(aWhich); } \
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc) { return _to##GetRc(aRc); } \
|
||||
|
||||
|
||||
|
|
|
@ -183,8 +183,11 @@
|
|||
const int EVENT_SHIFT_MASK = 0x00000004;
|
||||
const int EVENT_META_MASK = 0x00000008;
|
||||
|
||||
attribute int layerX;
|
||||
attribute int layerY;
|
||||
attribute int layerX;
|
||||
attribute int layerY;
|
||||
attribute int pageX;
|
||||
attribute int pageY;
|
||||
attribute unsigned long which;
|
||||
|
||||
readonly attribute RenderingContext rc;
|
||||
};
|
||||
|
|
|
@ -64,7 +64,10 @@ enum Event_slots {
|
|||
EVENT_BUTTON = -14,
|
||||
NSEVENT_LAYERX = -15,
|
||||
NSEVENT_LAYERY = -16,
|
||||
NSEVENT_RC = -17
|
||||
NSEVENT_PAGEX = -17,
|
||||
NSEVENT_PAGEY = -18,
|
||||
NSEVENT_WHICH = -19,
|
||||
NSEVENT_RC = -20
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -295,6 +298,66 @@ GetEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NSEVENT_PAGEX:
|
||||
{
|
||||
PRInt32 prop;
|
||||
nsIDOMNSEvent* b;
|
||||
if (NS_OK == a->QueryInterface(kINSEventIID, (void **)&b)) {
|
||||
if(NS_OK == b->GetPageX(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(b);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Object must be of type NSEvent");
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NSEVENT_PAGEY:
|
||||
{
|
||||
PRInt32 prop;
|
||||
nsIDOMNSEvent* b;
|
||||
if (NS_OK == a->QueryInterface(kINSEventIID, (void **)&b)) {
|
||||
if(NS_OK == b->GetPageY(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(b);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Object must be of type NSEvent");
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NSEVENT_WHICH:
|
||||
{
|
||||
PRUint32 prop;
|
||||
nsIDOMNSEvent* b;
|
||||
if (NS_OK == a->QueryInterface(kINSEventIID, (void **)&b)) {
|
||||
if(NS_OK == b->GetWhich(&prop)) {
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(b);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Object must be of type NSEvent");
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NSEVENT_RC:
|
||||
{
|
||||
nsIDOMRenderingContext* prop;
|
||||
|
@ -652,6 +715,81 @@ SetEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
break;
|
||||
}
|
||||
case NSEVENT_PAGEX:
|
||||
{
|
||||
PRInt32 prop;
|
||||
int32 temp;
|
||||
if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
|
||||
prop = (PRInt32)temp;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsIDOMNSEvent *b;
|
||||
if (NS_OK == a->QueryInterface(kINSEventIID, (void **)&b)) {
|
||||
b->SetPageX(prop);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
|
||||
JS_ReportError(cx, "Object must be of type NSEvent");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NSEVENT_PAGEY:
|
||||
{
|
||||
PRInt32 prop;
|
||||
int32 temp;
|
||||
if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
|
||||
prop = (PRInt32)temp;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsIDOMNSEvent *b;
|
||||
if (NS_OK == a->QueryInterface(kINSEventIID, (void **)&b)) {
|
||||
b->SetPageY(prop);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
|
||||
JS_ReportError(cx, "Object must be of type NSEvent");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NSEVENT_WHICH:
|
||||
{
|
||||
PRUint32 prop;
|
||||
int32 temp;
|
||||
if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
|
||||
prop = (PRUint32)temp;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsIDOMNSEvent *b;
|
||||
if (NS_OK == a->QueryInterface(kINSEventIID, (void **)&b)) {
|
||||
b->SetWhich(prop);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
|
||||
JS_ReportError(cx, "Object must be of type NSEvent");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
nsIJSScriptObject *object;
|
||||
|
@ -778,6 +916,9 @@ static JSPropertySpec EventProperties[] =
|
|||
{"button", EVENT_BUTTON, JSPROP_ENUMERATE},
|
||||
{"layerX", NSEVENT_LAYERX, JSPROP_ENUMERATE},
|
||||
{"layerY", NSEVENT_LAYERY, JSPROP_ENUMERATE},
|
||||
{"pageX", NSEVENT_PAGEX, JSPROP_ENUMERATE},
|
||||
{"pageY", NSEVENT_PAGEY, JSPROP_ENUMERATE},
|
||||
{"which", NSEVENT_WHICH, JSPROP_ENUMERATE},
|
||||
{"rc", NSEVENT_RC, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
|
|
@ -306,6 +306,50 @@ NS_METHOD nsDOMEvent::SetLayerY(PRInt32 aLayerY)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
||||
{
|
||||
return GetClientX(aPageX);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetPageX(PRInt32 aPageX)
|
||||
{
|
||||
return SetClientX(aPageX);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetPageY(PRInt32* aPageY)
|
||||
{
|
||||
return GetClientY(aPageY);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetPageY(PRInt32 aPageY)
|
||||
{
|
||||
return SetClientY(aPageY);
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::GetWhich(PRUint32* aWhich)
|
||||
{
|
||||
switch (mEvent->eventStructType) {
|
||||
case NS_KEY_EVENT:
|
||||
return GetKeyCode(aWhich);
|
||||
break;
|
||||
case NS_MOUSE_EVENT:
|
||||
return GetButton(aWhich);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::SetWhich(PRUint32 aWhich)
|
||||
{
|
||||
switch (mEvent->eventStructType) {
|
||||
case NS_KEY_EVENT:
|
||||
return SetKeyCode(aWhich);
|
||||
break;
|
||||
case NS_MOUSE_EVENT:
|
||||
return SetButton(aWhich);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD nsDOMEvent::DuplicatePrivateData()
|
||||
{
|
||||
//XXX Write me!
|
||||
|
|
|
@ -117,6 +117,15 @@ public:
|
|||
NS_IMETHOD GetLayerY(PRInt32* aLayerY);
|
||||
NS_IMETHOD SetLayerY(PRInt32 aLayerY);
|
||||
|
||||
NS_IMETHOD GetPageX(PRInt32* aClientX);
|
||||
NS_IMETHOD SetPageX(PRInt32 aClientX);
|
||||
|
||||
NS_IMETHOD GetPageY(PRInt32* aClientY);
|
||||
NS_IMETHOD SetPageY(PRInt32 aClientY);
|
||||
|
||||
NS_IMETHOD GetWhich(PRUint32* aKeyCode);
|
||||
NS_IMETHOD SetWhich(PRUint32 aKeyCode);
|
||||
|
||||
NS_IMETHOD GetRc(nsIDOMRenderingContext** aRc);
|
||||
|
||||
// nsIPrivateDOMEvent interface
|
||||
|
|
Загрузка…
Ссылка в новой задаче