1 module webkit2webextension.DOMNode;
2 
3 private import glib.ErrorG;
4 private import glib.GException;
5 private import glib.Str;
6 private import gobject.ObjectG;
7 private import javascriptcore.Value;
8 private import webkit2webextension.DOMDocument;
9 private import webkit2webextension.DOMElement;
10 private import webkit2webextension.DOMEventTargetIF;
11 private import webkit2webextension.DOMEventTargetT;
12 private import webkit2webextension.DOMNodeList;
13 private import webkit2webextension.DOMObject;
14 private import webkit2webextension.c.functions;
15 public  import webkit2webextension.c.types;
16 
17 
18 /** */
19 public class DOMNode : DOMObject, DOMEventTargetIF
20 {
21 	/** the main Gtk struct */
22 	protected WebKitDOMNode* webKitDOMNode;
23 
24 	/** Get the main Gtk struct */
25 	public WebKitDOMNode* getDOMNodeStruct(bool transferOwnership = false)
26 	{
27 		if (transferOwnership)
28 			ownedRef = false;
29 		return webKitDOMNode;
30 	}
31 
32 	/** the main Gtk struct as a void* */
33 	protected override void* getStruct()
34 	{
35 		return cast(void*)webKitDOMNode;
36 	}
37 
38 	/**
39 	 * Sets our main struct and passes it to the parent class.
40 	 */
41 	public this (WebKitDOMNode* webKitDOMNode, bool ownedRef = false)
42 	{
43 		this.webKitDOMNode = webKitDOMNode;
44 		super(cast(WebKitDOMObject*)webKitDOMNode, ownedRef);
45 	}
46 
47 	// add the DOMEventTarget capabilities
48 	mixin DOMEventTargetT!(WebKitDOMNode);
49 
50 
51 	/** */
52 	public static GType getType()
53 	{
54 		return webkit_dom_node_get_type();
55 	}
56 
57 	/**
58 	 * Get the #WebKitDOMNode for the DOM node referenced by @value.
59 	 *
60 	 * Params:
61 	 *     value = a #JSCValue
62 	 *
63 	 * Returns: a #WebKitDOMNode, or %NULL if @value doesn't reference a DOM node.
64 	 *
65 	 * Since: 2.22
66 	 */
67 	public static DOMNode forJsValue(Value value)
68 	{
69 		auto __p = webkit_dom_node_for_js_value((value is null) ? null : value.getValueStruct());
70 
71 		if(__p is null)
72 		{
73 			return null;
74 		}
75 
76 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
77 	}
78 
79 	/**
80 	 *
81 	 *
82 	 * Deprecated: Use JavaScriptCore API instead
83 	 *
84 	 * Params:
85 	 *     newChild = A #WebKitDOMNode
86 	 *
87 	 * Returns: A #WebKitDOMNode
88 	 *
89 	 * Throws: GException on failure.
90 	 */
91 	public DOMNode appendChild(DOMNode newChild)
92 	{
93 		GError* err = null;
94 
95 		auto __p = webkit_dom_node_append_child(webKitDOMNode, (newChild is null) ? null : newChild.getDOMNodeStruct(), &err);
96 
97 		if (err !is null)
98 		{
99 			throw new GException( new ErrorG(err) );
100 		}
101 
102 		if(__p is null)
103 		{
104 			return null;
105 		}
106 
107 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
108 	}
109 
110 	/**
111 	 *
112 	 *
113 	 * Deprecated: Use webkit_dom_node_clone_node_with_error() instead.
114 	 *
115 	 * Params:
116 	 *     deep = A #gboolean
117 	 *
118 	 * Returns: A #WebKitDOMNode
119 	 *
120 	 * Throws: GException on failure.
121 	 */
122 	/*public DOMNode cloneNode(bool deep)
123 	{
124 		GError* err = null;
125 
126 		auto __p = webkit_dom_node_clone_node(webKitDOMNode, deep, &err);
127 
128 		if (err !is null)
129 		{
130 			throw new GException( new ErrorG(err) );
131 		}
132 
133 		if(__p is null)
134 		{
135 			return null;
136 		}
137 
138 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
139 	}*/
140 
141 	/**
142 	 *
143 	 *
144 	 * Deprecated: Use JavaScriptCore API instead
145 	 *
146 	 * Params:
147 	 *     deep = A #gboolean
148 	 *
149 	 * Returns: A #WebKitDOMNode
150 	 *
151 	 * Since: 2.14
152 	 *
153 	 * Throws: GException on failure.
154 	 */
155 	public DOMNode cloneNodeWithError(bool deep)
156 	{
157 		GError* err = null;
158 
159 		auto __p = webkit_dom_node_clone_node_with_error(webKitDOMNode, deep, &err);
160 
161 		if (err !is null)
162 		{
163 			throw new GException( new ErrorG(err) );
164 		}
165 
166 		if(__p is null)
167 		{
168 			return null;
169 		}
170 
171 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
172 	}
173 
174 	/**
175 	 *
176 	 *
177 	 * Deprecated: Use JavaScriptCore API instead
178 	 *
179 	 * Params:
180 	 *     other = A #WebKitDOMNode
181 	 *
182 	 * Returns: A #gushort
183 	 */
184 	public ushort compareDocumentPosition(DOMNode other)
185 	{
186 		return webkit_dom_node_compare_document_position(webKitDOMNode, (other is null) ? null : other.getDOMNodeStruct());
187 	}
188 
189 	/**
190 	 *
191 	 *
192 	 * Deprecated: Use JavaScriptCore API instead
193 	 *
194 	 * Params:
195 	 *     other = A #WebKitDOMNode
196 	 *
197 	 * Returns: A #gboolean
198 	 */
199 	public bool contains(DOMNode other)
200 	{
201 		return webkit_dom_node_contains(webKitDOMNode, (other is null) ? null : other.getDOMNodeStruct()) != 0;
202 	}
203 
204 	/**
205 	 *
206 	 *
207 	 * Deprecated: Use JavaScriptCore API instead
208 	 *
209 	 * Returns: A #gchar
210 	 */
211 	public string getBaseUri()
212 	{
213 		auto retStr = webkit_dom_node_get_base_uri(webKitDOMNode);
214 
215 		scope(exit) Str.freeString(retStr);
216 		return Str.toString(retStr);
217 	}
218 
219 	/**
220 	 *
221 	 *
222 	 * Deprecated: Use JavaScriptCore API instead
223 	 *
224 	 * Returns: A #WebKitDOMNodeList
225 	 */
226 	public DOMNodeList getChildNodes()
227 	{
228 		auto __p = webkit_dom_node_get_child_nodes(webKitDOMNode);
229 
230 		if(__p is null)
231 		{
232 			return null;
233 		}
234 
235 		return ObjectG.getDObject!(DOMNodeList)(cast(WebKitDOMNodeList*) __p, true);
236 	}
237 
238 	/**
239 	 *
240 	 *
241 	 * Deprecated: Use JavaScriptCore API instead
242 	 *
243 	 * Returns: A #WebKitDOMNode
244 	 */
245 	public DOMNode getFirstChild()
246 	{
247 		auto __p = webkit_dom_node_get_first_child(webKitDOMNode);
248 
249 		if(__p is null)
250 		{
251 			return null;
252 		}
253 
254 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
255 	}
256 
257 	/**
258 	 *
259 	 *
260 	 * Deprecated: Use JavaScriptCore API instead
261 	 *
262 	 * Returns: A #WebKitDOMNode
263 	 */
264 	public DOMNode getLastChild()
265 	{
266 		auto __p = webkit_dom_node_get_last_child(webKitDOMNode);
267 
268 		if(__p is null)
269 		{
270 			return null;
271 		}
272 
273 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
274 	}
275 
276 	/**
277 	 *
278 	 *
279 	 * Deprecated: Use webkit_dom_attr_get_local_name() or webkit_dom_element_get_local_name() instead.
280 	 *
281 	 * Returns: A #gchar
282 	 */
283 	public string getLocalName()
284 	{
285 		auto retStr = webkit_dom_node_get_local_name(webKitDOMNode);
286 
287 		scope(exit) Str.freeString(retStr);
288 		return Str.toString(retStr);
289 	}
290 
291 	/**
292 	 *
293 	 *
294 	 * Deprecated: Use webkit_dom_attr_get_namespace_uri() or webkit_dom_element_get_namespace_uri() instead.
295 	 *
296 	 * Returns: A #gchar
297 	 */
298 	public string getNamespaceUri()
299 	{
300 		auto retStr = webkit_dom_node_get_namespace_uri(webKitDOMNode);
301 
302 		scope(exit) Str.freeString(retStr);
303 		return Str.toString(retStr);
304 	}
305 
306 	/**
307 	 *
308 	 *
309 	 * Deprecated: Use JavaScriptCore API instead
310 	 *
311 	 * Returns: A #WebKitDOMNode
312 	 */
313 	public DOMNode getNextSibling()
314 	{
315 		auto __p = webkit_dom_node_get_next_sibling(webKitDOMNode);
316 
317 		if(__p is null)
318 		{
319 			return null;
320 		}
321 
322 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
323 	}
324 
325 	/**
326 	 *
327 	 *
328 	 * Deprecated: Use JavaScriptCore API instead
329 	 *
330 	 * Returns: A #gchar
331 	 */
332 	public string getNodeName()
333 	{
334 		auto retStr = webkit_dom_node_get_node_name(webKitDOMNode);
335 
336 		scope(exit) Str.freeString(retStr);
337 		return Str.toString(retStr);
338 	}
339 
340 	/**
341 	 *
342 	 *
343 	 * Deprecated: Use JavaScriptCore API instead
344 	 *
345 	 * Returns: A #gushort
346 	 */
347 	public ushort getNodeType()
348 	{
349 		return webkit_dom_node_get_node_type(webKitDOMNode);
350 	}
351 
352 	/**
353 	 *
354 	 *
355 	 * Deprecated: Use JavaScriptCore API instead
356 	 *
357 	 * Returns: A #gchar
358 	 */
359 	public string getNodeValue()
360 	{
361 		auto retStr = webkit_dom_node_get_node_value(webKitDOMNode);
362 
363 		scope(exit) Str.freeString(retStr);
364 		return Str.toString(retStr);
365 	}
366 
367 	/**
368 	 *
369 	 *
370 	 * Deprecated: Use JavaScriptCore API instead
371 	 *
372 	 * Returns: A #WebKitDOMDocument
373 	 */
374 	public DOMDocument getOwnerDocument()
375 	{
376 		auto __p = webkit_dom_node_get_owner_document(webKitDOMNode);
377 
378 		if(__p is null)
379 		{
380 			return null;
381 		}
382 
383 		return ObjectG.getDObject!(DOMDocument)(cast(WebKitDOMDocument*) __p);
384 	}
385 
386 	/**
387 	 *
388 	 *
389 	 * Deprecated: Use JavaScriptCore API instead
390 	 *
391 	 * Returns: A #WebKitDOMElement
392 	 */
393 	public DOMElement getParentElement()
394 	{
395 		auto __p = webkit_dom_node_get_parent_element(webKitDOMNode);
396 
397 		if(__p is null)
398 		{
399 			return null;
400 		}
401 
402 		return ObjectG.getDObject!(DOMElement)(cast(WebKitDOMElement*) __p);
403 	}
404 
405 	/**
406 	 *
407 	 *
408 	 * Deprecated: Use JavaScriptCore API instead
409 	 *
410 	 * Returns: A #WebKitDOMNode
411 	 */
412 	public DOMNode getParentNode()
413 	{
414 		auto __p = webkit_dom_node_get_parent_node(webKitDOMNode);
415 
416 		if(__p is null)
417 		{
418 			return null;
419 		}
420 
421 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
422 	}
423 
424 	/**
425 	 *
426 	 *
427 	 * Deprecated: Use webkit_dom_attr_get_prefix() or webkit_dom_element_get_prefix() instead.
428 	 *
429 	 * Returns: A #gchar
430 	 */
431 	public string getPrefix()
432 	{
433 		auto retStr = webkit_dom_node_get_prefix(webKitDOMNode);
434 
435 		scope(exit) Str.freeString(retStr);
436 		return Str.toString(retStr);
437 	}
438 
439 	/**
440 	 *
441 	 *
442 	 * Deprecated: Use JavaScriptCore API instead
443 	 *
444 	 * Returns: A #WebKitDOMNode
445 	 */
446 	public DOMNode getPreviousSibling()
447 	{
448 		auto __p = webkit_dom_node_get_previous_sibling(webKitDOMNode);
449 
450 		if(__p is null)
451 		{
452 			return null;
453 		}
454 
455 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
456 	}
457 
458 	/**
459 	 *
460 	 *
461 	 * Deprecated: Use JavaScriptCore API instead
462 	 *
463 	 * Returns: A #gchar
464 	 */
465 	public string getTextContent()
466 	{
467 		auto retStr = webkit_dom_node_get_text_content(webKitDOMNode);
468 
469 		scope(exit) Str.freeString(retStr);
470 		return Str.toString(retStr);
471 	}
472 
473 	/**
474 	 *
475 	 *
476 	 * Deprecated: Use JavaScriptCore API instead
477 	 *
478 	 * Returns: A #gboolean
479 	 */
480 	public bool hasChildNodes()
481 	{
482 		return webkit_dom_node_has_child_nodes(webKitDOMNode) != 0;
483 	}
484 
485 	/**
486 	 *
487 	 *
488 	 * Deprecated: Use JavaScriptCore API instead
489 	 *
490 	 * Params:
491 	 *     newChild = A #WebKitDOMNode
492 	 *     refChild = A #WebKitDOMNode
493 	 *
494 	 * Returns: A #WebKitDOMNode
495 	 *
496 	 * Throws: GException on failure.
497 	 */
498 	public DOMNode insertBefore(DOMNode newChild, DOMNode refChild)
499 	{
500 		GError* err = null;
501 
502 		auto __p = webkit_dom_node_insert_before(webKitDOMNode, (newChild is null) ? null : newChild.getDOMNodeStruct(), (refChild is null) ? null : refChild.getDOMNodeStruct(), &err);
503 
504 		if (err !is null)
505 		{
506 			throw new GException( new ErrorG(err) );
507 		}
508 
509 		if(__p is null)
510 		{
511 			return null;
512 		}
513 
514 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
515 	}
516 
517 	/**
518 	 *
519 	 *
520 	 * Deprecated: Use JavaScriptCore API instead
521 	 *
522 	 * Params:
523 	 *     namespaceURI = A #gchar
524 	 *
525 	 * Returns: A #gboolean
526 	 */
527 	public bool isDefaultNamespace(string namespaceURI)
528 	{
529 		return webkit_dom_node_is_default_namespace(webKitDOMNode, Str.toStringz(namespaceURI)) != 0;
530 	}
531 
532 	/**
533 	 *
534 	 *
535 	 * Deprecated: Use JavaScriptCore API instead
536 	 *
537 	 * Params:
538 	 *     other = A #WebKitDOMNode
539 	 *
540 	 * Returns: A #gboolean
541 	 */
542 	public bool isEqualNode(DOMNode other)
543 	{
544 		return webkit_dom_node_is_equal_node(webKitDOMNode, (other is null) ? null : other.getDOMNodeStruct()) != 0;
545 	}
546 
547 	/**
548 	 *
549 	 *
550 	 * Deprecated: Use JavaScriptCore API instead
551 	 *
552 	 * Params:
553 	 *     other = A #WebKitDOMNode
554 	 *
555 	 * Returns: A #gboolean
556 	 */
557 	public bool isSameNode(DOMNode other)
558 	{
559 		return webkit_dom_node_is_same_node(webKitDOMNode, (other is null) ? null : other.getDOMNodeStruct()) != 0;
560 	}
561 
562 	/**
563 	 *
564 	 *
565 	 * Deprecated: Use JavaScriptCore API instead
566 	 *
567 	 * Params:
568 	 *     feature = A #gchar
569 	 *     version_ = A #gchar
570 	 *
571 	 * Returns: A #gboolean
572 	 */
573 	public bool isSupported(string feature, string version_)
574 	{
575 		return webkit_dom_node_is_supported(webKitDOMNode, Str.toStringz(feature), Str.toStringz(version_)) != 0;
576 	}
577 
578 	/**
579 	 *
580 	 *
581 	 * Deprecated: Use JavaScriptCore API instead
582 	 *
583 	 * Params:
584 	 *     prefix = A #gchar
585 	 *
586 	 * Returns: A #gchar
587 	 */
588 	public string lookupNamespaceUri(string prefix)
589 	{
590 		auto retStr = webkit_dom_node_lookup_namespace_uri(webKitDOMNode, Str.toStringz(prefix));
591 
592 		scope(exit) Str.freeString(retStr);
593 		return Str.toString(retStr);
594 	}
595 
596 	/**
597 	 *
598 	 *
599 	 * Deprecated: Use JavaScriptCore API instead
600 	 *
601 	 * Params:
602 	 *     namespaceURI = A #gchar
603 	 *
604 	 * Returns: A #gchar
605 	 */
606 	public string lookupPrefix(string namespaceURI)
607 	{
608 		auto retStr = webkit_dom_node_lookup_prefix(webKitDOMNode, Str.toStringz(namespaceURI));
609 
610 		scope(exit) Str.freeString(retStr);
611 		return Str.toString(retStr);
612 	}
613 
614 	/**
615 	 *
616 	 *
617 	 * Deprecated: Use JavaScriptCore API instead
618 	 */
619 	public void normalize()
620 	{
621 		webkit_dom_node_normalize(webKitDOMNode);
622 	}
623 
624 	/**
625 	 *
626 	 *
627 	 * Deprecated: Use JavaScriptCore API instead
628 	 *
629 	 * Params:
630 	 *     oldChild = A #WebKitDOMNode
631 	 *
632 	 * Returns: A #WebKitDOMNode
633 	 *
634 	 * Throws: GException on failure.
635 	 */
636 	public DOMNode removeChild(DOMNode oldChild)
637 	{
638 		GError* err = null;
639 
640 		auto __p = webkit_dom_node_remove_child(webKitDOMNode, (oldChild is null) ? null : oldChild.getDOMNodeStruct(), &err);
641 
642 		if (err !is null)
643 		{
644 			throw new GException( new ErrorG(err) );
645 		}
646 
647 		if(__p is null)
648 		{
649 			return null;
650 		}
651 
652 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
653 	}
654 
655 	/**
656 	 *
657 	 *
658 	 * Deprecated: Use JavaScriptCore API instead
659 	 *
660 	 * Params:
661 	 *     newChild = A #WebKitDOMNode
662 	 *     oldChild = A #WebKitDOMNode
663 	 *
664 	 * Returns: A #WebKitDOMNode
665 	 *
666 	 * Throws: GException on failure.
667 	 */
668 	public DOMNode replaceChild(DOMNode newChild, DOMNode oldChild)
669 	{
670 		GError* err = null;
671 
672 		auto __p = webkit_dom_node_replace_child(webKitDOMNode, (newChild is null) ? null : newChild.getDOMNodeStruct(), (oldChild is null) ? null : oldChild.getDOMNodeStruct(), &err);
673 
674 		if (err !is null)
675 		{
676 			throw new GException( new ErrorG(err) );
677 		}
678 
679 		if(__p is null)
680 		{
681 			return null;
682 		}
683 
684 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
685 	}
686 
687 	/**
688 	 *
689 	 *
690 	 * Deprecated: Use JavaScriptCore API instead
691 	 *
692 	 * Params:
693 	 *     value = A #gchar
694 	 *
695 	 * Throws: GException on failure.
696 	 */
697 	public void setNodeValue(string value)
698 	{
699 		GError* err = null;
700 
701 		webkit_dom_node_set_node_value(webKitDOMNode, Str.toStringz(value), &err);
702 
703 		if (err !is null)
704 		{
705 			throw new GException( new ErrorG(err) );
706 		}
707 	}
708 
709 	/** */
710 	public void setPrefix(string value)
711 	{
712 		GError* err = null;
713 
714 		webkit_dom_node_set_prefix(webKitDOMNode, Str.toStringz(value), &err);
715 
716 		if (err !is null)
717 		{
718 			throw new GException( new ErrorG(err) );
719 		}
720 	}
721 
722 	/**
723 	 *
724 	 *
725 	 * Deprecated: Use JavaScriptCore API instead
726 	 *
727 	 * Params:
728 	 *     value = A #gchar
729 	 *
730 	 * Throws: GException on failure.
731 	 */
732 	public void setTextContent(string value)
733 	{
734 		GError* err = null;
735 
736 		webkit_dom_node_set_text_content(webKitDOMNode, Str.toStringz(value), &err);
737 
738 		if (err !is null)
739 		{
740 			throw new GException( new ErrorG(err) );
741 		}
742 	}
743 }