2012-11-02 01:13:14 +04:00
|
|
|
/* DOM bindings entries */
|
2012-10-23 21:39:34 +04:00
|
|
|
|
|
|
|
webidlfile "dom.idl";
|
|
|
|
|
2012-11-07 22:52:30 +04:00
|
|
|
/* interface Node members */
|
|
|
|
|
2012-11-04 01:37:06 +04:00
|
|
|
|
2012-11-02 01:13:14 +04:00
|
|
|
getter textContent %{
|
2012-11-09 14:52:32 +04:00
|
|
|
dom_exception exc;
|
|
|
|
dom_string *content;
|
2012-10-23 21:39:34 +04:00
|
|
|
|
2012-11-09 14:52:32 +04:00
|
|
|
exc = dom_node_get_text_content(private->node, &content);
|
|
|
|
if (exc != DOM_NO_ERR) {
|
2012-11-04 15:18:37 +04:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (content != NULL) {
|
2012-11-09 14:52:32 +04:00
|
|
|
jsret = JS_NewStringCopyN(cx, dom_string_data(content), dom_string_length(content));
|
2012-11-04 15:18:37 +04:00
|
|
|
dom_string_unref(content);
|
|
|
|
|
2012-11-09 14:52:32 +04:00
|
|
|
}
|
2012-10-23 21:39:34 +04:00
|
|
|
%}
|
2012-11-04 01:37:06 +04:00
|
|
|
|
|
|
|
|
2012-11-07 22:52:30 +04:00
|
|
|
operation appendChild %{
|
2012-11-08 21:22:29 +04:00
|
|
|
struct dom_node *result = NULL;
|
2012-11-09 14:52:32 +04:00
|
|
|
dom_exception exc;
|
2012-11-08 21:22:29 +04:00
|
|
|
|
|
|
|
struct jsclass_private *node_private;
|
|
|
|
dom_node_type node_type;
|
|
|
|
|
|
|
|
JSLOG("appending %p", node);
|
|
|
|
|
|
|
|
/* CAUTION this expects all Node objects private pointers to
|
|
|
|
* have private->node in the same place
|
|
|
|
*/
|
2012-11-09 14:52:32 +04:00
|
|
|
/* text */
|
2012-11-08 21:22:29 +04:00
|
|
|
node_private = JS_GetInstancePrivate(cx, node, &JSClass_Text, NULL);
|
2012-11-09 14:52:32 +04:00
|
|
|
if (node_private == NULL) {
|
|
|
|
/* element */
|
|
|
|
node_private = JS_GetInstancePrivate(cx, node, &JSClass_HTMLElement, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node_private == NULL) {
|
|
|
|
/* type error? */
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* append the found element */
|
|
|
|
exc = dom_node_append_child(private->node, node_private->node, &result);
|
|
|
|
if (exc != DOM_NO_ERR) {
|
|
|
|
return JS_FALSE;
|
2012-11-08 21:22:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result != NULL) {
|
|
|
|
exc = dom_node_get_node_type(result, &node_type);
|
|
|
|
if (exc != DOM_NO_ERR) {
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
switch (node_type) {
|
|
|
|
case DOM_ELEMENT_NODE:
|
2012-11-08 21:30:43 +04:00
|
|
|
jsret = jsapi_new_HTMLElement(cx, NULL, NULL, (dom_element *)result, private->htmlc);
|
2012-11-08 21:22:29 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DOM_TEXT_NODE:
|
2012-11-08 21:30:43 +04:00
|
|
|
jsret = jsapi_new_Text(cx, NULL, NULL, (dom_text *)result, private->htmlc);
|
2012-11-08 21:22:29 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
JSLOG("Unsupported result node type %d", node_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
JSLOG("No result");
|
|
|
|
}
|
2012-11-07 22:52:30 +04:00
|
|
|
%}
|