summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.sources12
-rw-r--r--Makefile.sources.javascript40
-rw-r--r--javascript/jsapi.c5
-rw-r--r--javascript/jsapi.h2
4 files changed, 49 insertions, 10 deletions
diff --git a/Makefile.sources b/Makefile.sources
index 0c2356c0b..32db5e666 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -29,13 +29,8 @@ S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \
scrollbar.c sslcert.c textarea.c thumbnail.c tree.c \
tree_url_node.c version.c
-# Javascript sources
-ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = window.c navigator.c console.c htmldocument.c htmlelement.c
-S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
-else
-S_JAVASCRIPT += none.c
-endif
+# Javascript source
+include Makefile.sources.javascript
# S_COMMON are sources common to all builds
S_COMMON := $(addprefix content/,$(S_CONTENT)) \
@@ -45,7 +40,8 @@ S_COMMON := $(addprefix content/,$(S_CONTENT)) \
$(addprefix utils/,$(S_UTILS)) \
$(addprefix utils/http/,$(S_HTTP)) \
$(addprefix desktop/,$(S_DESKTOP)) \
- $(addprefix javascript/,$(S_JAVASCRIPT))
+ $(addprefix javascript/,$(S_JAVASCRIPT)) \
+ $(S_JSAPI_BINDING)
# S_IMAGE are sources related to image management
S_IMAGE_YES := image.c image_cache.c
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
new file mode 100644
index 000000000..48cd1cff4
--- /dev/null
+++ b/Makefile.sources.javascript
@@ -0,0 +1,40 @@
+#
+# NetSurf javascript source file inclusion
+#
+# Included by Makefile.sources
+#
+
+# ----------------------------------------------------------------------------
+# JSAPI binding
+# ----------------------------------------------------------------------------
+
+S_JSAPI_BINDING:=
+
+JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
+
+# 1: input file
+# 2: output file
+# 3: binding name
+define convert_jsapi_binding
+
+S_JSAPI_BINDING += $(2)
+
+$(2): $(1)
+ $(Q)nsgenbind -I javascript/jsapi/WebIDL/ -o $(2) $(1)
+
+endef
+
+# Javascript sources
+ifeq ($(NETSURF_USE_JS),YES)
+
+S_JSAPI = window.c navigator.c console.c htmlelement.c
+#htmldocument.c
+
+S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
+
+$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi)))
+
+
+else
+S_JAVASCRIPT += none.c
+endif
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index fa8726b42..f7ac3eda1 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -98,6 +98,7 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
JSObject *document_obj;
JSObject *navigator_obj;
JSObject *console_obj;
+ struct html_content *htmlc = doc_priv;
if (cx == NULL)
goto js_newcompartment_fail;
@@ -108,7 +109,7 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
goto js_newcompartment_fail;
/* attach the subclasses off the window global */
- document_obj = jsapi_new_document(cx, window_obj, doc_priv);
+ document_obj = jsapi_new_Document(cx, window_obj, htmlc->document, htmlc);
if (document_obj == NULL)
goto js_newcompartment_fail;
@@ -126,6 +127,8 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
js_newcompartment_fail:
+ LOG(("New compartment creation failed"));
+
return NULL;
}
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index c4c1ed099..91d9184b4 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -165,7 +165,7 @@ JSObject *jsapi_new_window(JSContext *cx, JSObject *parent, void *win_priv);
* @param doc_priv The private context to set on the object
* @return new javascript object or NULL on error
*/
-JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc);
+JSObject *jsapi_new_Document(JSContext *cx, JSObject *parent, dom_document *node, struct html_content *htmlc);
/** Create a new javascript console object
*