mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-16 22:43:58 +03:00
Event: Implement initEvent() and getter isTrusted
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
177a047752
commit
2739a47d83
@ -148,3 +148,40 @@ getter Event::defaultPrevented ()
|
||||
return 1;
|
||||
%}
|
||||
|
||||
getter Event::isTrusted ()
|
||||
%{
|
||||
dom_exception exc;
|
||||
bool ret;
|
||||
|
||||
exc = dom_event_get_is_trusted(priv->evt, &ret);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
|
||||
duk_push_boolean(ctx, ret);
|
||||
return 1;
|
||||
%}
|
||||
|
||||
|
||||
method Event::initEvent ()
|
||||
%{
|
||||
dom_exception exc;
|
||||
bool bubbles;
|
||||
bool cancellable;
|
||||
|
||||
duk_size_t text_len;
|
||||
const char *text = duk_safe_to_lstring(ctx, 0, &text_len);
|
||||
dom_string *text_str;
|
||||
|
||||
exc = dom_string_create((const uint8_t*)text, text_len, &text_str);
|
||||
if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */
|
||||
|
||||
bubbles = duk_get_boolean(ctx, 1);
|
||||
cancellable = duk_get_boolean(ctx, 2);
|
||||
|
||||
exc = dom_event_init(priv->evt, text_str, bubbles, cancellable);
|
||||
if (exc != DOM_NO_ERR) {
|
||||
dom_string_unref(text_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
%}
|
||||
|
@ -426,8 +426,6 @@ getter ErrorEvent::error(any);\n
|
||||
getter ErrorEvent::filename(string);\n
|
||||
getter ErrorEvent::lineno(unsigned long);\n
|
||||
getter ErrorEvent::message(string);\n
|
||||
method Event::initEvent();\n
|
||||
getter Event::isTrusted(boolean);\n
|
||||
method EventListener::handleEvent();\n
|
||||
method EventSource::close();\n
|
||||
getter EventSource::onerror(user);\n
|
||||
|
Loading…
x
Reference in New Issue
Block a user