summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-08-02 23:03:13 +0100
committerVincent Sanders <vince@kyllikki.org>2015-08-02 23:03:13 +0100
commitbbd5a2f71e0de963dfb7a5ee3442d656efc56996 (patch)
tree47cf243a38552b946c2bfac04fa7b0ff65e26428
parentba214995f8d259790a9eab683a227403b2d3608d (diff)
downloadnetsurf-bbd5a2f71e0de963dfb7a5ee3442d656efc56996.tar.gz
netsurf-bbd5a2f71e0de963dfb7a5ee3442d656efc56996.tar.bz2
add window binding
-rw-r--r--javascript/duktape/Window.bnd57
-rw-r--r--javascript/duktape/netsurf.bnd1
2 files changed, 58 insertions, 0 deletions
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 <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)));
+
+ /* 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 */