diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2012-07-06 20:00:32 +0100 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2012-07-06 20:00:32 +0100 |
commit | cc93afcfda94ada42b86227b3acd15706ee4ed4f (patch) | |
tree | c8ce27e2affac3887498e90f0676af3c12b0e7ff /javascript/jsapi | |
parent | 9b85ae106b8ce28679ca10d21c07ee9e95001574 (diff) | |
download | netsurf-cc93afcfda94ada42b86227b3acd15706ee4ed4f.tar.gz netsurf-cc93afcfda94ada42b86227b3acd15706ee4ed4f.tar.bz2 |
alter usage of libdom hubbub binding
Diffstat (limited to 'javascript/jsapi')
-rw-r--r-- | javascript/jsapi/document.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c index c73dac721..29ed20c1b 100644 --- a/javascript/jsapi/document.c +++ b/javascript/jsapi/document.c @@ -16,13 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "javascript/jsapi.h" +#include <dom/dom.h> -#include "utils/log.h" -static JSFunctionSpec jsfunctions_document[] = { - JS_FS_END -}; +#include "javascript/jsapi.h" +#include "utils/config.h" +#include "render/html_internal.h" +#include "utils/log.h" static JSClass jsclass_document = { @@ -40,6 +40,39 @@ static JSClass jsclass_document = }; +static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp) +{ + JSString* u16_txt; + char *txt; + unsigned long length; + struct html_content *htmlc; + + htmlc = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL); + if (htmlc == NULL) + return JS_FALSE; + + if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) + return JS_FALSE; + + JSString_to_char(u16_txt, txt, length); + + LOG(("content %p writing %s",htmlc, txt)); + + dom_hubbub_parser_insert_chunk(htmlc->parser_binding, (uint8_t *)txt, length); + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSFunctionSpec jsfunctions_document[] = { + JSAPI_FS(write, 1, 0), + JSAPI_FS_END +}; + + + + JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv) { JSObject *doc; @@ -56,6 +89,8 @@ JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv) if (doc == NULL) { return NULL; } + + LOG(("setting content to %p",doc_priv)); /* private pointer to browsing context */ if (!JS_SetPrivate(cx, doc, doc_priv)) return NULL; |