1 module libwasm.bindings.Node; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.Document; 7 import libwasm.bindings.Element; 8 import libwasm.bindings.EventTarget; 9 import libwasm.bindings.L10nUtils; 10 import libwasm.bindings.NodeList; 11 12 @safe: 13 nothrow: 14 15 struct GetRootNodeOptions { 16 nothrow: 17 JsHandle handle; 18 alias handle this; 19 this(Handle h) { 20 this.handle = JsHandle(h); 21 } 22 static auto create() { 23 return GetRootNodeOptions(libwasm_add__object()); 24 } 25 void composed()(bool composed) { 26 Object_Call_bool__void(this.handle, "composed", composed); 27 } 28 bool composed()() { 29 return Object_Getter__bool(this.handle, "composed"); 30 } 31 } 32 struct Node { 33 nothrow: 34 libwasm.bindings.EventTarget.EventTarget _parent; 35 alias _parent this; 36 this(Handle h) { 37 _parent = .EventTarget(h); 38 } 39 enum ushort ELEMENT_NODE = 1; 40 enum ushort ATTRIBUTE_NODE = 2; 41 enum ushort TEXT_NODE = 3; 42 enum ushort CDATA_SECTION_NODE = 4; 43 enum ushort ENTITY_REFERENCE_NODE = 5; 44 enum ushort ENTITY_NODE = 6; 45 enum ushort PROCESSING_INSTRUCTION_NODE = 7; 46 enum ushort COMMENT_NODE = 8; 47 enum ushort DOCUMENT_NODE = 9; 48 enum ushort DOCUMENT_TYPE_NODE = 10; 49 enum ushort DOCUMENT_FRAGMENT_NODE = 11; 50 enum ushort NOTATION_NODE = 12; 51 ushort nodeType()() { 52 return Object_Getter__ushort(this._parent, "nodeType"); 53 } 54 string nodeName()() { 55 return Object_Getter__string(this._parent, "nodeName"); 56 } 57 Optional!(string) baseURI()() { 58 return Object_Getter__OptionalString(this._parent, "baseURI"); 59 } 60 bool isConnected()() { 61 return Object_Getter__bool(this._parent, "isConnected"); 62 } 63 auto ownerDocument()() { 64 return recastOpt!(Document)(Object_Getter__OptionalHandle(this._parent, "ownerDocument")); 65 } 66 auto getRootNode()(scope ref GetRootNodeOptions options) { 67 return Node(Object_Call_Handle__Handle(this._parent, "getRootNode", options.handle)); 68 } 69 auto getRootNode()() { 70 return Node(Object_Getter__Handle(this._parent, "getRootNode")); 71 } 72 auto parentNode()() { 73 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "parentNode")); 74 } 75 auto parentElement()() { 76 return recastOpt!(Element)(Object_Getter__OptionalHandle(this._parent, "parentElement")); 77 } 78 bool hasChildNodes()() { 79 return Object_Getter__bool(this._parent, "hasChildNodes"); 80 } 81 auto childNodes()() { 82 return NodeList(Object_Getter__Handle(this._parent, "childNodes")); 83 } 84 auto firstChild()() { 85 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "firstChild")); 86 } 87 auto lastChild()() { 88 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "lastChild")); 89 } 90 auto previousSibling()() { 91 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "previousSibling")); 92 } 93 auto nextSibling()() { 94 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "nextSibling")); 95 } 96 void nodeValue(T0)(scope auto ref Optional!(T0) nodeValue) if (isTOrPointer!(T0, string)) { 97 Serialize_Object_VarArgCall!void(this._parent, "nodeValue", "Optional!(string)", tuple(!nodeValue.empty, nodeValue.front)); 98 } 99 Optional!(string) nodeValue()() { 100 return Object_Getter__OptionalString(this._parent, "nodeValue"); 101 } 102 void textContent(T0)(scope auto ref Optional!(T0) textContent) if (isTOrPointer!(T0, string)) { 103 Serialize_Object_VarArgCall!void(this._parent, "textContent", "Optional!(string)", tuple(!textContent.empty, textContent.front)); 104 } 105 Optional!(string) textContent()() { 106 return Object_Getter__OptionalString(this._parent, "textContent"); 107 } 108 auto insertBefore(T1)(scope ref Node node, scope auto ref Optional!(T1) child) if (isTOrPointer!(T1, Node)) { 109 return Node(Serialize_Object_VarArgCall!Handle(this._parent, "insertBefore", "Handle;Optional!Handle", tuple(cast(Handle)node._parent, !child.empty, cast(Handle)child.front._parent))); 110 } 111 auto appendChild()(scope ref Node node) { 112 return Node(Object_Call_Handle__Handle(this._parent, "appendChild", node._parent)); 113 } 114 auto replaceChild()(scope ref Node node, scope ref Node child) { 115 return Node(Serialize_Object_VarArgCall!Handle(this._parent, "replaceChild", "Handle;Handle", tuple(cast(Handle)node._parent, cast(Handle)child._parent))); 116 } 117 auto removeChild()(scope ref Node child) { 118 return Node(Object_Call_Handle__Handle(this._parent, "removeChild", child._parent)); 119 } 120 void normalize()() { 121 Object_Call__void(this._parent, "normalize"); 122 } 123 auto cloneNode()(bool deep /* = false */) { 124 return Node(Object_Call_bool__Handle(this._parent, "cloneNode", deep)); 125 } 126 auto cloneNode()() { 127 return Node(Object_Getter__Handle(this._parent, "cloneNode")); 128 } 129 bool isSameNode(T0)(scope auto ref Optional!(T0) node) if (isTOrPointer!(T0, Node)) { 130 return Serialize_Object_VarArgCall!bool(this._parent, "isSameNode", "Optional!Handle", tuple(!node.empty, cast(Handle)node.front._parent)); 131 } 132 bool isEqualNode(T0)(scope auto ref Optional!(T0) node) if (isTOrPointer!(T0, Node)) { 133 return Serialize_Object_VarArgCall!bool(this._parent, "isEqualNode", "Optional!Handle", tuple(!node.empty, cast(Handle)node.front._parent)); 134 } 135 enum ushort DOCUMENT_POSITION_DISCONNECTED = 0x01; 136 enum ushort DOCUMENT_POSITION_PRECEDING = 0x02; 137 enum ushort DOCUMENT_POSITION_FOLLOWING = 0x04; 138 enum ushort DOCUMENT_POSITION_CONTAINS = 0x08; 139 enum ushort DOCUMENT_POSITION_CONTAINED_BY = 0x10; 140 enum ushort DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; 141 ushort compareDocumentPosition()(scope ref Node other) { 142 return Serialize_Object_VarArgCall!ushort(this._parent, "compareDocumentPosition", "Handle", tuple(cast(Handle)other._parent)); 143 } 144 bool contains(T0)(scope auto ref Optional!(T0) other) if (isTOrPointer!(T0, Node)) { 145 return Serialize_Object_VarArgCall!bool(this._parent, "contains", "Optional!Handle", tuple(!other.empty, cast(Handle)other.front._parent)); 146 } 147 Optional!(string) lookupPrefix(T0)(scope auto ref Optional!(T0) namespace) if (isTOrPointer!(T0, string)) { 148 return Serialize_Object_VarArgCall!(Optional!string)(this._parent, "lookupPrefix", "Optional!(string)", tuple(!namespace.empty, namespace.front)); 149 } 150 Optional!(string) lookupNamespaceURI(T0)(scope auto ref Optional!(T0) prefix) if (isTOrPointer!(T0, string)) { 151 return Serialize_Object_VarArgCall!(Optional!string)(this._parent, "lookupNamespaceURI", "Optional!(string)", tuple(!prefix.empty, prefix.front)); 152 } 153 bool isDefaultNamespace(T0)(scope auto ref Optional!(T0) namespace) if (isTOrPointer!(T0, string)) { 154 return Serialize_Object_VarArgCall!bool(this._parent, "isDefaultNamespace", "Optional!(string)", tuple(!namespace.empty, namespace.front)); 155 } 156 auto nodePrincipal()() { 157 return Principal(Object_Getter__Handle(this._parent, "nodePrincipal")); 158 } 159 auto baseURIObject()() { 160 return recastOpt!(URI)(Object_Getter__OptionalHandle(this._parent, "baseURIObject")); 161 } 162 string generateXPath()() { 163 return Object_Getter__string(this._parent, "generateXPath"); 164 } 165 auto flattenedTreeParentNode()() { 166 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "flattenedTreeParentNode")); 167 } 168 auto parentFlexElement()() { 169 return recastOpt!(Element)(Object_Getter__OptionalHandle(this._parent, "parentFlexElement")); 170 } 171 auto localize()(L10nCallback l10nCallback) { 172 return JsPromise!(void)(Node_localize(this._parent, l10nCallback)); 173 } 174 } 175 176 177 extern (C) Handle Node_localize(Handle, L10nCallback);