mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-02 08:57:19 -04:00
[spidermonkey] el_message - separate struct
This commit is contained in:
parent
df27a1ab4c
commit
e1c099270f
@ -68,7 +68,11 @@ struct el_window {
|
|||||||
JS::RootedObject thisval;
|
JS::RootedObject thisval;
|
||||||
LIST_OF(struct listener) listeners;
|
LIST_OF(struct listener) listeners;
|
||||||
JS::RootedValue onmessage;
|
JS::RootedValue onmessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct el_message {
|
||||||
JS::RootedObject messageObject;
|
JS::RootedObject messageObject;
|
||||||
|
struct el_window *elwin;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -187,9 +191,16 @@ const spidermonkeyFunctionSpec window_funcs[] = {
|
|||||||
static void
|
static void
|
||||||
onmessage_run(void *data)
|
onmessage_run(void *data)
|
||||||
{
|
{
|
||||||
struct el_window *elwin = (struct el_window *)data;
|
struct el_message *mess = (struct el_message *)data;
|
||||||
|
|
||||||
|
if (mess) {
|
||||||
|
struct el_window *elwin = mess->elwin;
|
||||||
|
|
||||||
|
if (!elwin) {
|
||||||
|
mem_free(mess);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (elwin) {
|
|
||||||
struct ecmascript_interpreter *interpreter = elwin->interpreter;
|
struct ecmascript_interpreter *interpreter = elwin->interpreter;
|
||||||
JSContext *ctx = (JSContext *)interpreter->backend_data;
|
JSContext *ctx = (JSContext *)interpreter->backend_data;
|
||||||
JS::Realm *comp = JS::EnterRealm(ctx, (JSObject *)interpreter->ac);
|
JS::Realm *comp = JS::EnterRealm(ctx, (JSObject *)interpreter->ac);
|
||||||
@ -200,7 +211,7 @@ onmessage_run(void *data)
|
|||||||
if (!argv.resize(1)) {
|
if (!argv.resize(1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
argv[0].setObject(*(elwin->messageObject));
|
argv[0].setObject(*(mess->messageObject));
|
||||||
|
|
||||||
struct listener *l;
|
struct listener *l;
|
||||||
|
|
||||||
@ -213,6 +224,7 @@ onmessage_run(void *data)
|
|||||||
JS_CallFunctionValue(ctx, elwin->thisval, elwin->onmessage, argv, &r_val);
|
JS_CallFunctionValue(ctx, elwin->thisval, elwin->onmessage, argv, &r_val);
|
||||||
done_heartbeat(interpreter->heartbeat);
|
done_heartbeat(interpreter->heartbeat);
|
||||||
JS::LeaveRealm(ctx, comp);
|
JS::LeaveRealm(ctx, comp);
|
||||||
|
mem_free(mess);
|
||||||
check_for_rerender(interpreter, "window_onmessage");
|
check_for_rerender(interpreter, "window_onmessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,9 +377,14 @@ window_postMessage(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
|||||||
args.rval().setUndefined();
|
args.rval().setUndefined();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
struct el_message *mess = (struct el_message *)mem_calloc(1, sizeof(*mess));
|
||||||
|
if (!mess) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
JS::RootedObject messageObject(ctx, val);
|
JS::RootedObject messageObject(ctx, val);
|
||||||
elwin->messageObject = messageObject;
|
mess->messageObject = messageObject;
|
||||||
register_bottom_half(onmessage_run, elwin);
|
mess->elwin = elwin;
|
||||||
|
register_bottom_half(onmessage_run, mess);
|
||||||
args.rval().setUndefined();
|
args.rval().setUndefined();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user