summaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/jsapi/binding.h6
-rw-r--r--javascript/jsapi/bindings/location.bnd53
-rw-r--r--javascript/jsapi/bindings/window.bnd84
3 files changed, 107 insertions, 36 deletions
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 8b32e91db..68ab6d1ed 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -41,6 +41,12 @@ JSObject *jsapi_new_Window(JSContext *cx,
struct browser_window *bw,
html_content *htmlc);
+JSObject *jsapi_InitClass_Location(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Location(JSContext *cx,
+ JSObject *window,
+ JSObject *parent,
+ struct browser_window *bw);
+
JSObject *jsapi_InitClass_Document(JSContext *cx, JSObject *parent);
diff --git a/javascript/jsapi/bindings/location.bnd b/javascript/jsapi/bindings/location.bnd
new file mode 100644
index 000000000..c83fe46e3
--- /dev/null
+++ b/javascript/jsapi/bindings/location.bnd
@@ -0,0 +1,53 @@
+/* Binding to generate Location interface
+ *
+ * Copyright 2012 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
+ */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include "desktop/browser.h"
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+binding location {
+ type js_libdom; /* the binding type */
+
+ interface Location; /* Web IDL interface to generate */
+
+ /* private members:
+ * - stored in private context structure.
+ * - passed as parameters to constructor and stored automatically.
+ * - are *not* considered for property getters/setters.
+ *
+ * internal members:
+ * - value stored in private context structure
+ * - not passed to constructor
+ * - must be instantiated by constructor
+ * - are considered for property getters/setters.
+ */
+ private "struct browser_window *" bw;
+}
+
+operation reload %{
+ browser_window_reload(private->bw, false);
+%}
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index beb2b128e..956932c77 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -18,25 +18,26 @@ preamble %{
%}
-operation confirm %{
- warn_user(message, NULL);
-%}
-
-operation alert %{
- warn_user(message, NULL);
-%}
-
-operation prompt %{
- warn_user(message, NULL);
-%}
-
-getter window %{
- jsret = obj;
-%}
+binding window {
+ type js_libdom; /* the binding type */
+
+ interface Window; /* Web IDL interface to generate */
+
+ /* private are parameters to constructor stored in private
+ * context structure.
+ *
+ * internal are value stored in private context structure but not
+ * passed to constructor but are considered for property
+ * getters/setters.
+ */
+ private "struct browser_window *" bw;
+ private "struct html_content *" htmlc;
+ internal "JSObject *" document;
+ internal "JSObject *" navigator;
+ internal "JSObject *" console;
+ internal "JSObject *" location;
+}
-getter self %{
- jsret = obj;
-%}
api init %{
JSObject *user_proto;
@@ -85,6 +86,11 @@ api init %{
return NULL;
}
+ user_proto = jsapi_InitClass_Location(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
user_proto = jsapi_InitClass_Console(cx, prototype);
if (user_proto == NULL) {
return NULL;
@@ -121,7 +127,11 @@ api new %{
return NULL;
}
- /** @todo forms, history, location */
+ private->location = jsapi_new_Location(cx, NULL, newobject, bw);
+ if (private->location == NULL) {
+ free(private);
+ return NULL;
+ }
private->console = jsapi_new_Console(cx, NULL, newobject);
if (private->console == NULL) {
@@ -129,25 +139,27 @@ api new %{
return NULL;
}
+ /** @todo forms, history */
+
LOG(("Created new window object %p", newobject));
%}
+operation confirm %{
+ warn_user(message, NULL);
+%}
-binding window {
- type js_libdom; /* the binding type */
-
- interface Window; /* Web IDL interface to generate */
-
- /* private are parameters to constructor stored in private
- * context structure.
- *
- * internal are value stored in private context structure but not
- * passed to constructor but are considered for property getters/setters.
- */
- private "struct browser_window *" bw;
- private "struct html_content *" htmlc;
- internal "JSObject *" document;
- internal "JSObject *" navigator;
- internal "JSObject *" console;
+operation alert %{
+ warn_user(message, NULL);
+%}
-}
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+getter window %{
+ jsret = obj;
+%}
+
+getter self %{
+ jsret = obj;
+%}