summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amiga/Makefile.target6
-rw-r--r--javascript/jsapi/document.c35
-rw-r--r--render/html.c24
3 files changed, 48 insertions, 17 deletions
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index fb0259c59..f2d23bbc0 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -52,16 +52,16 @@ else
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include
CFLAGS += $(shell $(PKG_CONFIG) --cflags libxml-2.0 libcurl libcares openssl)
- CFLAGS += $(shell $(PKG_CONFIG) --cflags tre libhubbub libcss)
+ CFLAGS += $(shell $(PKG_CONFIG) --cflags tre libdom libcss)
LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libcares openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs tre libhubbub libcss)
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs tre libdom libcss)
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
ifeq ($(SUBTARGET),os3)
LDFLAGS += -liconv
else
- LDFLAGS += -lauto
+ LDFLAGS += -lauto -lpbl
endif
EXETARGET := NetSurf
diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
index c54d2f6a5..49144c4a9 100644
--- a/javascript/jsapi/document.c
+++ b/javascript/jsapi/document.c
@@ -115,7 +115,40 @@ static JSClass jsclass_document =
static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
+ JSString* u16_txt;
+ char *txt;
+ unsigned long txtlen;
+ struct html_content *htmlc;
+ dom_string *idstr;
+ dom_element *idelement;
+
+ htmlc = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL);
+ if (htmlc == NULL)
+ return JS_FALSE;
+
+ if (htmlc->document == NULL) {
+ /* no document available, this is obviously a problem
+ * for finding elements
+ */
+ JSAPI_SET_RVAL(cx, vp, JSVAL_NULL);
+
+ return JS_TRUE;
+ }
+
+ if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt))
+ return JS_FALSE;
+
+ JSString_to_char(u16_txt, txt, txtlen);
+
+ dom_string_create((unsigned char*)txt, txtlen, &idstr);
+
+ dom_document_get_element_by_id(htmlc->document, idstr, &idelement);
+
+ if (idelement==NULL) {
+ JSAPI_SET_RVAL(cx, vp, JSVAL_NULL);
+ } else {
+ /* create element object and return it*/
+ }
return JS_TRUE;
}
diff --git a/render/html.c b/render/html.c
index 069f290ef..8526ca001 100644
--- a/render/html.c
+++ b/render/html.c
@@ -334,7 +334,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
/* Create the parser binding */
c->parser = dom_hubbub_parser_create(c->encoding,
true,
- nsoption_bool(enable_javascript),
+ nsoption_bool(enable_javascript),
+ &c->document,
NULL,
html_process_script,
c);
@@ -347,6 +348,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->parser = dom_hubbub_parser_create(c->encoding,
true,
nsoption_bool(enable_javascript),
+ &c->document,
NULL,
html_process_script,
c);
@@ -449,6 +451,7 @@ html_process_encoding_change(struct content *c,
html->parser = dom_hubbub_parser_create(html->encoding,
true,
nsoption_bool(enable_javascript),
+ &html->document,
NULL,
html_process_script,
html);
@@ -468,6 +471,8 @@ html_process_encoding_change(struct content *c,
html->parser = dom_hubbub_parser_create(html->encoding,
true,
nsoption_bool(enable_javascript),
+ &html->document,
+
NULL,
html_process_script,
html);
@@ -1966,7 +1971,8 @@ html_begin_conversion(html_content *htmlc)
union content_msg_data msg_data;
/** @todo Improve processing of errors */
- msg_data.error = messages_get("NoMemory");
+ LOG(("Parsing failed"));
+ msg_data.error = messages_get("ParsingFail");
content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
return false;
@@ -1975,23 +1981,15 @@ html_begin_conversion(html_content *htmlc)
/* complete script execution */
html_scripts_exec(htmlc);
- htmlc->document = dom_hubbub_parser_get_document(htmlc->parser);
-
- if (htmlc->document == NULL) {
- LOG(("Parsing failed"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
- return false;
- }
-
+ /* quirks mode */
exc = dom_document_get_quirks_mode(htmlc->document, &htmlc->quirks);
if (exc != DOM_NO_ERR) {
LOG(("error retrieving quirks"));
+ /** @todo should this be fatal to the conversion? */
}
-
LOG(("quirks set to %d", htmlc->quirks));
-
+ /* get encoding */
if (htmlc->encoding == NULL) {
const char *encoding;
encoding = dom_hubbub_parser_get_encoding(htmlc->parser,