From bbd5a2f71e0de963dfb7a5ee3442d656efc56996 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 2 Aug 2015 23:03:13 +0100 Subject: add window binding --- javascript/duktape/Window.bnd | 57 ++++++++++++++++++++++++++++++++++++++++++ javascript/duktape/netsurf.bnd | 1 + 2 files changed, 58 insertions(+) create mode 100644 javascript/duktape/Window.bnd diff --git a/javascript/duktape/Window.bnd b/javascript/duktape/Window.bnd new file mode 100644 index 000000000..2835f4bea --- /dev/null +++ b/javascript/duktape/Window.bnd @@ -0,0 +1,57 @@ +/* Window binding for browser using duktape and libdom + * + * Copyright 2015 Vincent Sanders + * + * 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 "desktop/browser.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))); + + /* populate window.window */ + duk_dup(ctx, 0); + duk_put_prop_string(ctx, 0, "window"); +%} + + + +getter Window::document() +%{ + LOG("priv=%p", priv); + dom_document *doc = priv->htmlc->document; + dukky_push_node(ctx, (struct dom_node *)doc); + return 1; +%} + +setter Window::document() +%{ + LOG("BWUAhAHAHAHAHA FUCK OFF"); +%} + +/* prototype needs: +#define STEAL_THING(X) \ + duk_get_global_string(ctx, #X); \ + duk_put_prop_string(ctx, 0, #X) + +STEAL_THING(undefined); + */ diff --git a/javascript/duktape/netsurf.bnd b/javascript/duktape/netsurf.bnd index d50275fe1..63e2eeea5 100644 --- a/javascript/duktape/netsurf.bnd +++ b/javascript/duktape/netsurf.bnd @@ -50,6 +50,7 @@ struct dom_html_br_element; } +#include "Window.bnd" #include "Node.bnd" /* specialisations of html_element */ -- cgit v1.2.3