use generated htmldocument binding

This commit is contained in:
Vincent Sanders 2012-10-24 19:00:24 +01:00
parent f487b77f4f
commit b866e3e172
4 changed files with 49 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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
*