summaryrefslogtreecommitdiff
path: root/javascript/duktape/Window.bnd
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-08-09 12:26:41 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-08-09 12:26:41 +0100
commitaadb8200899ae7b2dd75bc743b08dcd9cecd27db (patch)
tree98a22ed5498d541c336eed7cb6d7fcfadc31d0db /javascript/duktape/Window.bnd
parent37b118d966598301fc57a6d7cb63312013069934 (diff)
downloadnetsurf-aadb8200899ae7b2dd75bc743b08dcd9cecd27db.tar.gz
netsurf-aadb8200899ae7b2dd75bc743b08dcd9cecd27db.tar.bz2
Add duktape bindings
Diffstat (limited to 'javascript/duktape/Window.bnd')
-rw-r--r--javascript/duktape/Window.bnd52
1 files changed, 52 insertions, 0 deletions
diff --git a/javascript/duktape/Window.bnd b/javascript/duktape/Window.bnd
new file mode 100644
index 000000000..2223ae88d
--- /dev/null
+++ b/javascript/duktape/Window.bnd
@@ -0,0 +1,52 @@
+/* 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 "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)));
+%}
+
+prototype Window()
+%{
+ /* steal undefined */
+ duk_get_global_string(ctx, "undefined");
+ duk_put_prop_string(ctx, 0, "undefined");
+%}
+
+getter Window::document()
+%{
+ LOG("priv=%p", priv);
+ dom_document *doc = priv->htmlc->document;
+ dukky_push_node(ctx, (struct dom_node *)doc);
+ return 1;
+%}
+
+
+getter Window::document()
+%{
+ duk_dup(ctx, 0);
+ return 1;
+%}