From 7b62bb5ff89b08820f56df666c8d9616c8c57489 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 16 Jan 2013 13:42:16 +0000 Subject: implement document.compatmode --- javascript/jsapi/htmldocument.bnd | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'javascript/jsapi/htmldocument.bnd') diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index 8d5c69eb5..c948e2dbb 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -52,6 +52,9 @@ binding document { /** location instantiated on first use */ property unshared location; + /* compatability mode instantiated on first use */ + property unshared compatMode; + /* events through a single interface */ property unshared type EventHandler; } @@ -66,7 +69,7 @@ api finalise %{ getter location %{ - if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx,vp))) { + if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx, vp))) { /* already created - return it */ return JS_TRUE; } @@ -95,6 +98,32 @@ getter documentURI %{ jsret = JSVAL_TO_STRING(jsstr); %} + +getter compatMode %{ + /* Returns the string "CSS1Compat" if document is in no-quirks + * mode or limited-quirks mode, and "BackCompat", if document + * is in quirks mode. + */ + if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx, vp))) { + /* already created, just use it */ + return JS_TRUE; + } + if (private->htmlc->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) { + jsret = JS_NewStringCopyN(cx, "BackCompat", SLEN("BackCompat")); + } else { + jsret = JS_NewStringCopyN(cx, "CSS1Compat", SLEN("CSS1Compat")); + } + +%} + +/* +getter characterSet %{ +%} + +getter contentType %{ +%} +*/ + getter cookie %{ char *cookie_str; cookie_str = urldb_get_cookie(llcache_handle_get_url(private->htmlc->base.llcache), false); -- cgit v1.2.3 From fab7b04de689fdbb03e4cf604b1524a80bb4a174 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 23 Jan 2013 14:11:41 +0000 Subject: implement Element::getElementsByTagName --- javascript/jsapi/htmldocument.bnd | 1 + javascript/jsapi/htmlelement.bnd | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'javascript/jsapi/htmldocument.bnd') diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index c948e2dbb..ec7a18039 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -219,6 +219,7 @@ operation getElementById %{ * Dom 4 says this should return a htmlcollection, libdom currently * returns DOM 3 spec of a nodelist */ +/* HTMLCollection Document::getElementsByTagName(DOMString localName); */ operation getElementsByTagName %{ dom_string *localName_dom; /* dom_html_collection *collection;*/ diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index f0032fa1a..5af2d5b25 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -174,6 +174,44 @@ operation setAttribute %{ } %} +/* + * + * Dom 4 says this should return a htmlcollection, libdom currently + * returns DOM 3 spec of a nodelist + */ +/* HTMLCollection Element::getElementsByTagName(DOMString localName); */ +operation getElementsByTagName %{ + dom_string *localName_dom; + /* dom_html_collection *collection;*/ + dom_nodelist *nodelist; + dom_exception exc; + + exc = dom_string_create((uint8_t *)localName, localName_len, &localName_dom); + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } + + exc = dom_element_get_elements_by_tag_name(private->node, localName_dom, /*&collection*/&nodelist); + dom_string_unref(localName_dom); + if (exc != DOM_NO_ERR) { + return JS_FALSE; + } + + if (/*collection*/nodelist != NULL) { + /*jsret = jsapi_new_HTMLCollection(cx, + NULL, + NULL, + collection, + private->htmlc);*/ + jsret = jsapi_new_NodeList(cx, + NULL, + NULL, + nodelist, + private->htmlc); + } + +%} + /* * DOM 3 has these as the element traversal extension * -- cgit v1.2.3 From db7d3acdc3b7256728bf5dcfce8ef04a8d32b65b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 23 Jan 2013 15:49:46 +0000 Subject: add and use debug logging macro --- javascript/jsapi.h | 5 +++++ javascript/jsapi/htmldocument.bnd | 18 +++++++++--------- javascript/jsapi/htmlelement.bnd | 1 + javascript/jsapi/nodelist.bnd | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) (limited to 'javascript/jsapi/htmldocument.bnd') diff --git a/javascript/jsapi.h b/javascript/jsapi.h index b308ca531..e38188ab4 100644 --- a/javascript/jsapi.h +++ b/javascript/jsapi.h @@ -376,5 +376,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx, #endif #define JSLOG(args...) LOG((args)) +#ifdef ENABLE_VERBOSE_JS_DEBUG +#define JSDBG(args...) LOG((args)) +#else +#define JSDBG(args...) +#endif #endif diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index ec7a18039..4aacccf4e 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -173,7 +173,7 @@ getter body %{ dom_node *body; dom_exception exc; - JSLOG("Getting your body"); + JSDBG("Getting your body"); /* document (html) element */ exc = dom_document_get_document_element(private->node, &element); @@ -189,7 +189,7 @@ getter body %{ dom_node_unref(element); } - JSLOG("returning jsobject %p",jsret); + JSDBG("returning jsobject %p",jsret); %} @@ -266,7 +266,7 @@ operation createTextNode %{ if (data != NULL) { - JSLOG("Creating text node for string \"%s\"", data); + JSDBG("Creating text node for string \"%s\"", data); exc = dom_string_create((unsigned char*)data, data_len, &data_dom); if (exc != DOM_NO_ERR) { return JS_FALSE; @@ -281,7 +281,7 @@ operation createTextNode %{ jsret = jsapi_new_Text(cx, NULL, NULL, text, private->htmlc); } - JSLOG("returning jsobject %p",jsret); + JSDBG("returning jsobject %p",jsret); %} @@ -293,7 +293,7 @@ operation createComment %{ if (data != NULL) { - JSLOG("Creating string \"%s\"", data); + JSDBG("Creating string \"%s\"", data); exc = dom_string_create((unsigned char*)data, data_len, &data_dom); @@ -301,7 +301,7 @@ operation createComment %{ return JS_FALSE; } - JSLOG("Creating comment object for dom string \"%s\"", + JSDBG("Creating comment object for dom string \"%s\"", dom_string_data(data_dom)); exc = dom_document_create_comment(private->node, data_dom, @@ -314,7 +314,7 @@ operation createComment %{ jsret = jsapi_new_Comment(cx, NULL, NULL, comment, private->htmlc); } - JSLOG("returning jsobject %p", jsret); + JSDBG("returning jsobject %p", jsret); %} @@ -325,7 +325,7 @@ operation createElement %{ dom_element *element; if (localName != NULL) { - JSLOG("Creating text node for string \"%s\"", localName); + JSDBG("Creating text node for string \"%s\"", localName); exc = dom_string_create((unsigned char*)localName, localName_len, &localName_dom); if (exc != DOM_NO_ERR) { return JS_FALSE; @@ -340,7 +340,7 @@ operation createElement %{ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc); } - JSLOG("returning jsobject %p",jsret); + JSDBG("returning jsobject %p",jsret); %} diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index fd3a9caf8..56c98258b 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -29,6 +29,7 @@ preamble %{ #include "htmlelement.h" #include "text.h" #include "location.h" +#include "nodelist.h" %} diff --git a/javascript/jsapi/nodelist.bnd b/javascript/jsapi/nodelist.bnd index d7adafd93..379809659 100644 --- a/javascript/jsapi/nodelist.bnd +++ b/javascript/jsapi/nodelist.bnd @@ -56,7 +56,7 @@ api getproperty %{ JSAPI_PROP_IDVAL(cx, &queryprop); if (JSVAL_IS_INT(queryprop)) { idx = JSVAL_TO_INT(queryprop); - LOG(("Index was %d", idx)); + JSDBG("Index was %d", idx); err = dom_nodelist_item(private->nodelist, idx, &domnode); @@ -67,7 +67,7 @@ api getproperty %{ if (domnode != NULL) { jsret = jsapi_new_HTMLElement(cx, NULL, NULL, (dom_element *)domnode, private->htmlc); - JSLOG("return object:%p", jsret); + JSDBG("return object:%p", jsret); JSAPI_PROP_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsret)); } -- cgit v1.2.3