mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[spidermonkey] event.preventDefault
This commit is contained in:
parent
0da45fcfd0
commit
3ccb7e664b
@ -289,7 +289,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
event_obj = spidermonkey_InitClass(ctx, global, NULL,
|
event_obj = spidermonkey_InitClass(ctx, global, NULL,
|
||||||
&event_class, event_constructor, 0,
|
&event_class, event_constructor, 0,
|
||||||
event_props,
|
event_props,
|
||||||
NULL,
|
event_funcs,
|
||||||
NULL, NULL, "Event");
|
NULL, NULL, "Event");
|
||||||
|
|
||||||
if (!event_obj) {
|
if (!event_obj) {
|
||||||
|
@ -72,6 +72,8 @@ static bool event_get_property_composed(JSContext *ctx, unsigned int argc, JS::V
|
|||||||
static bool event_get_property_defaultPrevented(JSContext *ctx, unsigned int argc, JS::Value *vp);
|
static bool event_get_property_defaultPrevented(JSContext *ctx, unsigned int argc, JS::Value *vp);
|
||||||
static bool event_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp);
|
static bool event_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp);
|
||||||
|
|
||||||
|
static bool event_preventDefault(JSContext *ctx, unsigned int argc, JS::Value *vp);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_finalize(JS::GCContext *op, JSObject *event_obj)
|
event_finalize(JS::GCContext *op, JSObject *event_obj)
|
||||||
{
|
{
|
||||||
@ -150,6 +152,11 @@ JSPropertySpec event_props[] = {
|
|||||||
JS_PS_END
|
JS_PS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const spidermonkeyFunctionSpec event_funcs[] = {
|
||||||
|
{ "preventDefault", event_preventDefault, 0 },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
event_get_property_bubbles(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
event_get_property_bubbles(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||||
{
|
{
|
||||||
@ -254,6 +261,35 @@ event_get_property_defaultPrevented(JSContext *ctx, unsigned int argc, JS::Value
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
event_preventDefault(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||||
|
{
|
||||||
|
#ifdef ECMASCRIPT_DEBUG
|
||||||
|
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||||
|
#endif
|
||||||
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
|
JS::Realm *comp = js::GetContextRealm(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
#ifdef ECMASCRIPT_DEBUG
|
||||||
|
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
struct eljs_event *event = JS::GetMaybePtrFromReservedSlot<struct eljs_event>(hobj, 0);
|
||||||
|
|
||||||
|
if (!event) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (event->cancelable) {
|
||||||
|
event->defaultPrevented = 1;
|
||||||
|
}
|
||||||
|
args.rval().setUndefined();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
event_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
event_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
extern JSClass event_class;
|
extern JSClass event_class;
|
||||||
extern JSPropertySpec event_props[];
|
extern JSPropertySpec event_props[];
|
||||||
|
extern const spidermonkeyFunctionSpec event_funcs[];
|
||||||
bool event_constructor(JSContext* ctx, unsigned argc, JS::Value* vp);
|
bool event_constructor(JSContext* ctx, unsigned argc, JS::Value* vp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user