Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/f5891097cc955e05946f114a7e28b36f61faddf1
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/f5891097cc955e05946f114a7e28b36f61faddf1
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/f5891097cc955e05946f114a7e28b36f61faddf1

The branch, master has been updated
       via  f5891097cc955e05946f114a7e28b36f61faddf1 (commit)
       via  9a0f7028a340f0678ce27d6a91f50faf96800187 (commit)
      from  3e2123d9ec06ad7102ed32847755358ef43a84c2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commitdiff/f5891097cc955e05946f114a7e28b36f61faddf1
commit f5891097cc955e05946f114a7e28b36f61faddf1
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    Inital work on supporting getelementbyid

diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
index c54d2f6..49144c4 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;
 }


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commitdiff/9a0f7028a340f0678ce27d6a91f50faf96800187
commit 9a0f7028a340f0678ce27d6a91f50faf96800187
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    Libdom now returns the document object at creation time

diff --git a/render/html.c b/render/html.c
index 069f290..8526ca0 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,


-----------------------------------------------------------------------

Summary of changes:
 javascript/jsapi/document.c |   35 ++++++++++++++++++++++++++++++++++-
 render/html.c               |   24 +++++++++++-------------
 2 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
index c54d2f6..49144c4 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 069f290..8526ca0 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,


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to