summaryrefslogtreecommitdiff
path: root/javascript/duktape/Window.bnd
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-06-07 16:01:04 +0100
committerVincent Sanders <vince@kyllikki.org>2016-06-07 16:01:04 +0100
commit042fcb82b83d19bf08afd3367235ac71a60b3850 (patch)
tree47fe3c15f160b3fac7b0e8ab4f47b495901e0557 /javascript/duktape/Window.bnd
parent9754539e2275e33af34b5de9d343b85e8122d871 (diff)
downloadnetsurf-042fcb82b83d19bf08afd3367235ac71a60b3850.tar.gz
netsurf-042fcb82b83d19bf08afd3367235ac71a60b3850.tar.bz2
Move javascript content handler as appropriate for updated source format
Diffstat (limited to 'javascript/duktape/Window.bnd')
-rw-r--r--javascript/duktape/Window.bnd146
1 files changed, 0 insertions, 146 deletions
diff --git a/javascript/duktape/Window.bnd b/javascript/duktape/Window.bnd
deleted file mode 100644
index 489587899..000000000
--- a/javascript/duktape/Window.bnd
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Window binding for browser using duktape and libdom
- *
- * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * Released under the terms of the MIT License,
- * http://www.opensource.org/licenses/mit-license
- */
-
-class Window {
- private struct browser_window * win;
- private struct html_content * htmlc;
- prologue %{
-#include "utils/nsurl.h"
-#include "netsurf/browser_window.h"
-#include "content/hlcache.h"
-#include "render/html.h"
-#include "render/html_internal.h"
-%};
-};
-
-init Window(struct browser_window *win, struct html_content *htmlc)
-%{
- /* element window */
- priv->win = win;
- priv->htmlc = htmlc;
- LOG("win=%p htmlc=%p", priv->win, priv->htmlc);
-
- LOG("URL is %s", nsurl_access(browser_window_get_url(priv->win)));
-%}
-
-prototype Window()
-%{
-#define EXPOSE(v) \
- duk_get_global_string(ctx, #v); \
- duk_put_prop_string(ctx, 0, #v)
- /* steal undefined */
- EXPOSE(undefined);
- EXPOSE(eval);
- EXPOSE(Object);
- EXPOSE(parseInt);
- EXPOSE(parseFloat);
- EXPOSE(Array);
- EXPOSE(Date);
- EXPOSE(RegExp);
- EXPOSE(Math);
- EXPOSE(Function);
- EXPOSE(Proxy);
- EXPOSE(String);
-#undef EXPOSE
-%}
-
-getter Window::document()
-%{
- JS_LOG("priv=%p", priv);
- dom_document *doc = priv->htmlc->document;
- dukky_push_node(ctx, (struct dom_node *)doc);
- return 1;
-%}
-
-getter Window::window()
-%{
- duk_push_this(ctx);
- return 1;
-%}
-
-getter Window::console()
-%{
- duk_push_this(ctx);
- duk_get_prop_string(ctx, -1, MAGIC(Console));
- if (duk_is_undefined(ctx, -1)) {
- duk_pop(ctx);
- if (dukky_create_object(ctx, PROTO_NAME(CONSOLE), 0) != DUK_EXEC_SUCCESS) {
- duk_error(ctx, DUK_ERR_ERROR, "Unable to create console object");
- return 0;
- }
- duk_dup(ctx, -1);
- duk_put_prop_string(ctx, -3, MAGIC(Console));
- }
- return 1;
-%}
-
-getter Window::location()
-%{
- duk_push_this(ctx);
- duk_get_prop_string(ctx, -1, MAGIC(Location));
- if (duk_is_undefined(ctx, -1)) {
- duk_pop(ctx);
-
- duk_push_pointer(ctx, llcache_handle_get_url(priv->htmlc->base.llcache));
-
- if (dukky_create_object(ctx, PROTO_NAME(LOCATION), 1) != DUK_EXEC_SUCCESS) {
- duk_error(ctx, DUK_ERR_ERROR, "Unable to create location object");
- return 0;
- }
- duk_dup(ctx, -1);
- duk_put_prop_string(ctx, -3, MAGIC(Location));
- }
- return 1;
-%}
-
-getter Window::navigator()
-%{
- duk_push_this(ctx);
- duk_get_prop_string(ctx, -1, MAGIC(Navigator));
- if (duk_is_undefined(ctx, -1)) {
- duk_pop(ctx);
-
- if (dukky_create_object(ctx,
- PROTO_NAME(NAVIGATOR),
- 0) != DUK_EXEC_SUCCESS) {
- duk_error(ctx,
- DUK_ERR_ERROR,
- "Unable to create navigator object");
- return 0;
- }
- duk_dup(ctx, -1);
- duk_put_prop_string(ctx, -3, MAGIC(Navigator));
- }
- return 1;
-%}
-
-getter Window::name()
-%{
- const char *name;
- browser_window_get_name(priv->win, &name);
- duk_push_string(ctx, name);
- return 1;
-%}
-
-setter Window::name()
-%{
- const char *name;
- name = duk_to_string(ctx, -1);
- browser_window_set_name(priv->win, name);
- return 0;
-%}
-
-method Window::alert()
-%{
- duk_size_t msg_len;
- const char *msg = duk_safe_to_lstring(ctx, 0, &msg_len);
- LOG("JS ALERT: %*s", (int)msg_len, msg);
- return 0;
-%}