alter usage of libdom hubbub binding

This commit is contained in:
Vincent Sanders 2012-07-06 20:00:32 +01:00
parent 9b85ae106b
commit cc93afcfda
6 changed files with 656 additions and 626 deletions

View File

@ -133,7 +133,7 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
{
JSContext *cx = (JSContext *)ctx;
//LOG(("%p \"%s\"",cx ,txt));
LOG(("%p \"%s\"",cx ,txt));
if (ctx == NULL) {
return false;

View File

@ -86,8 +86,8 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JS_StrictPropertyStub JS_PropertyStub
#define JSString_to_char(injsstring, outchar, outlen) \
txt = JS_GetStringBytes(u16_txt); \
outlen = strlen(txt)
outchar = JS_GetStringBytes(injsstring); \
outlen = strlen(outchar)
#else /* #if JS_VERSION <= 180 */

View File

@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dom/dom.h>
#include "javascript/jsapi.h"
#include "utils/config.h"
#include "render/html_internal.h"
#include "utils/log.h"
static JSFunctionSpec jsfunctions_document[] = {
JS_FS_END
};
static JSClass jsclass_document =
{
"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;

File diff suppressed because it is too large Load Diff

View File

@ -24,11 +24,11 @@
#include "utils/log.h"
binding_error binding_create_tree(void *arena, const char *charset, void **ctx)
binding_error binding_create_tree(void **ctx, const char *charset, bool enable_script, dom_script script, void *context)
{
dom_hubbub_parser *parser = NULL;
parser = dom_hubbub_parser_create(charset, true, NULL, NULL);
parser = dom_hubbub_parser_create(charset, true, enable_script, NULL, script, context);
if (parser == NULL) {
LOG(("Can't create Hubbub Parser\n"));
return BINDING_NOMEM;

View File

@ -20,6 +20,7 @@
#define _NETSURF_RENDER_PARSER_BINDING_H_
#include <dom/dom.h>
#include <dom/bindings/hubbub/parser.h>
struct box;
struct form;
@ -44,7 +45,7 @@ typedef enum binding_quirks_mode {
BINDING_QUIRKS_MODE_FULL
} binding_quirks_mode;
binding_error binding_create_tree(void *arena, const char *charset, void **ctx);
binding_error binding_create_tree(void **ctx, const char *charset, bool enable_script, dom_script script, void *context);
binding_error binding_destroy_tree(void *ctx);
binding_error binding_parse_chunk(void *ctx, const uint8_t *data, size_t len);