1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* DOM bindings entries */
webidlfile "dom.idl";
operation getElementById %{
dom_string *elementId_dom;
dom_element *element;
dom_exception exc;
exc = dom_string_create((unsigned char*)elementId, elementId_len, &elementId_dom);
if (exc != DOM_NO_ERR) {
return JS_FALSE;
}
exc = dom_document_get_element_by_id(private->node, elementId_dom, &element);
if (exc != DOM_NO_ERR) {
return JS_FALSE;
}
if (element != NULL) {
jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
}
%}
/* Dom 4 says this should return a htmlcollection, libdom currently
* returns DOM 3 spec of a nodelist
*/
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;
}
LOG(("here"));
exc = dom_document_get_elements_by_tag_name(private->node, localName_dom, /*&collection*/&nodelist);
if (exc != DOM_NO_ERR) {
return JS_FALSE;
}
LOG(("nodelist %p", nodelist));
if (/*collection*/nodelist != NULL) {
/* jsret = jsapi_new_HTMLCollection(cx,
NULL,
NULL,
collection,
private->htmlc);*/
jsret = jsapi_new_NodeList(cx,
NULL,
NULL,
nodelist,
private->htmlc);
}
%}
getter textContent %{
dom_exception exc;
dom_string *content;
exc = dom_node_get_text_content(private->node, &content);
if ((exc == DOM_NO_ERR) && (content != NULL)) {
jsret = JS_NewStringCopyN(cx, dom_string_data(content), dom_string_length(content));
}
%}
|