diff options
Diffstat (limited to 'javascript/jsapi/document.c')
-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; |