summaryrefslogtreecommitdiff
path: root/javascript/jsapi/htmldocument.bnd
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/jsapi/htmldocument.bnd')
-rw-r--r--javascript/jsapi/htmldocument.bnd83
1 files changed, 81 insertions, 2 deletions
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 7574512dd..b642cabe6 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -12,6 +12,8 @@ preamble %{
#include "utils/config.h"
#include "utils/log.h"
+#include "utils/corestrings.h"
+#include "utils/domutils.h"
#include "content/urldb.h"
@@ -23,13 +25,13 @@ preamble %{
binding document {
type js_libdom; /* the binding type */
+ interface Document; /* Web IDL interface to generate */
+
/* parameters to constructor value stored in private
* context structure.
*/
private "dom_document *" node;
private "struct html_content *" htmlc;
-
- interface Document; /* Web IDL interface to generate */
}
api finalise %{
@@ -49,6 +51,61 @@ getter cookie %{
}
%}
+getter documentElement %{
+ dom_exception exc;
+ dom_element *element;
+
+ /* document (html) element */
+ exc = dom_document_get_document_element(private->node, (void *)&element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (element != NULL) {
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ }
+%}
+
+getter head %{
+ dom_node *element;
+ dom_node *head;
+ dom_exception exc;
+
+ /* document (html) element */
+ exc = dom_document_get_document_element(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (element != NULL) {
+ head = find_first_named_dom_element(element, corestring_lwc_head) ;
+ if (head != NULL) {
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, (dom_element *)head, private->htmlc);
+ }
+ dom_node_unref(element);
+ }
+%}
+
+getter body %{
+ dom_node *element;
+ dom_node *body;
+ dom_exception exc;
+
+ /* document (html) element */
+ exc = dom_document_get_document_element(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (element != NULL) {
+ body = find_first_named_dom_element(element, corestring_lwc_body) ;
+ if (body != NULL) {
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, (dom_element *)body, private->htmlc);
+ }
+ dom_node_unref(element);
+ }
+%}
+
operation getElementById %{
dom_string *elementId_dom;
dom_element *element;
@@ -112,3 +169,25 @@ operation write %{
dom_hubbub_parser_insert_chunk(private->htmlc->parser, (uint8_t *)text, text_len);
}
%}
+
+/* in dom Document */
+operation createTextNode %{
+ dom_string *data_dom;
+ dom_element *element;
+ dom_exception exc;
+ dom_text *text;
+
+ exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ exc = dom_document_create_text_node(private->node, data_dom, &text);
+ dom_string_unref(data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ jsret = jsapi_new_Text(cx, NULL, NULL, text);
+
+%}