15f62d0b6ae28f6c1bf96b81ef4c7c3a7c8f302c
[WebKit-https.git] / Source / WebKit / WebProcess / InjectedBundle / API / gtk / DOM / WebKitDOMElement.cpp
1 /*
2  *  This file is part of the WebKit open source project.
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Library General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2 of the License, or (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Library General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Library General Public License
15  *  along with this library; see the file COPYING.LIB.  If not, write to
16  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  *  Boston, MA 02110-1301, USA.
18  */
19
20 #include "config.h"
21 #include "WebKitDOMElement.h"
22
23 #include <WebCore/CSSImportRule.h>
24 #include "DOMObjectCache.h"
25 #include <WebCore/DOMRect.h>
26 #include <WebCore/Document.h>
27 #include <WebCore/ExceptionCode.h>
28 #include <WebCore/ExceptionCodeDescription.h>
29 #include "GObjectEventListener.h"
30 #include <WebCore/HTMLNames.h>
31 #include <WebCore/JSMainThreadExecState.h>
32 #include <WebCore/StyledElement.h>
33 #include "WebKitDOMAttrPrivate.h"
34 #include "WebKitDOMCSSStyleDeclarationPrivate.h"
35 #include "WebKitDOMClientRectListPrivate.h"
36 #include "WebKitDOMClientRectPrivate.h"
37 #include "WebKitDOMDOMTokenListPrivate.h"
38 #include "WebKitDOMElementPrivate.h"
39 #include "WebKitDOMEventPrivate.h"
40 #include "WebKitDOMEventTarget.h"
41 #include "WebKitDOMHTMLCollectionPrivate.h"
42 #include "WebKitDOMNamedNodeMapPrivate.h"
43 #include "WebKitDOMNodeListPrivate.h"
44 #include "WebKitDOMNodePrivate.h"
45 #include "WebKitDOMPrivate.h"
46 #include "ConvertToUTF8String.h"
47 #include "WebKitDOMElementUnstable.h"
48 #include <wtf/GetPtr.h>
49 #include <wtf/RefPtr.h>
50
51 namespace WebKit {
52
53 WebKitDOMElement* kit(WebCore::Element* obj)
54 {
55     return WEBKIT_DOM_ELEMENT(kit(static_cast<WebCore::Node*>(obj)));
56 }
57
58 WebCore::Element* core(WebKitDOMElement* request)
59 {
60     return request ? static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
61 }
62
63 WebKitDOMElement* wrapElement(WebCore::Element* coreObject)
64 {
65     ASSERT(coreObject);
66     return WEBKIT_DOM_ELEMENT(g_object_new(WEBKIT_DOM_TYPE_ELEMENT, "core-object", coreObject, nullptr));
67 }
68
69 } // namespace WebKit
70
71 static gboolean webkit_dom_element_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
72 {
73     WebCore::Event* coreEvent = WebKit::core(event);
74     if (!coreEvent)
75         return false;
76     WebCore::Element* coreTarget = static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(target)->coreObject);
77
78     auto result = coreTarget->dispatchEventForBindings(*coreEvent);
79     if (result.hasException()) {
80         WebCore::ExceptionCodeDescription description(result.releaseException().code());
81         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name);
82         return false;
83     }
84     return result.releaseReturnValue();
85 }
86
87 static gboolean webkit_dom_element_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
88 {
89     WebCore::Element* coreTarget = static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(target)->coreObject);
90     return WebKit::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
91 }
92
93 static gboolean webkit_dom_element_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
94 {
95     WebCore::Element* coreTarget = static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(target)->coreObject);
96     return WebKit::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
97 }
98
99 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
100 {
101     iface->dispatch_event = webkit_dom_element_dispatch_event;
102     iface->add_event_listener = webkit_dom_element_add_event_listener;
103     iface->remove_event_listener = webkit_dom_element_remove_event_listener;
104 }
105
106 G_DEFINE_TYPE_WITH_CODE(WebKitDOMElement, webkit_dom_element, WEBKIT_DOM_TYPE_NODE, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkit_dom_event_target_init))
107
108 enum {
109     PROP_0,
110     PROP_TAG_NAME,
111     PROP_ATTRIBUTES,
112     PROP_STYLE,
113     PROP_ID,
114     PROP_NAMESPACE_URI,
115     PROP_PREFIX,
116     PROP_LOCAL_NAME,
117     PROP_OFFSET_LEFT,
118     PROP_OFFSET_TOP,
119     PROP_OFFSET_WIDTH,
120     PROP_OFFSET_HEIGHT,
121     PROP_CLIENT_LEFT,
122     PROP_CLIENT_TOP,
123     PROP_CLIENT_WIDTH,
124     PROP_CLIENT_HEIGHT,
125     PROP_SCROLL_LEFT,
126     PROP_SCROLL_TOP,
127     PROP_SCROLL_WIDTH,
128     PROP_SCROLL_HEIGHT,
129     PROP_OFFSET_PARENT,
130     PROP_INNER_HTML,
131     PROP_OUTER_HTML,
132     PROP_CLASS_NAME,
133     PROP_CLASS_LIST,
134     PROP_WEBKIT_REGION_OVERSET,
135     PROP_PREVIOUS_ELEMENT_SIBLING,
136     PROP_NEXT_ELEMENT_SIBLING,
137     PROP_CHILDREN,
138     PROP_FIRST_ELEMENT_CHILD,
139     PROP_LAST_ELEMENT_CHILD,
140     PROP_CHILD_ELEMENT_COUNT,
141 };
142
143 static void webkit_dom_element_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
144 {
145     WebKitDOMElement* self = WEBKIT_DOM_ELEMENT(object);
146
147     switch (propertyId) {
148     case PROP_ID:
149         webkit_dom_element_set_id(self, g_value_get_string(value));
150         break;
151     case PROP_SCROLL_LEFT:
152         webkit_dom_element_set_scroll_left(self, g_value_get_long(value));
153         break;
154     case PROP_SCROLL_TOP:
155         webkit_dom_element_set_scroll_top(self, g_value_get_long(value));
156         break;
157     case PROP_INNER_HTML:
158         webkit_dom_element_set_inner_html(self, g_value_get_string(value), nullptr);
159         break;
160     case PROP_OUTER_HTML:
161         webkit_dom_element_set_outer_html(self, g_value_get_string(value), nullptr);
162         break;
163     case PROP_CLASS_NAME:
164         webkit_dom_element_set_class_name(self, g_value_get_string(value));
165         break;
166     default:
167         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
168         break;
169     }
170 }
171
172 static void webkit_dom_element_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
173 {
174     WebKitDOMElement* self = WEBKIT_DOM_ELEMENT(object);
175
176     switch (propertyId) {
177     case PROP_TAG_NAME:
178         g_value_take_string(value, webkit_dom_element_get_tag_name(self));
179         break;
180     case PROP_ATTRIBUTES:
181         g_value_set_object(value, webkit_dom_element_get_attributes(self));
182         break;
183     case PROP_STYLE:
184         g_value_set_object(value, webkit_dom_element_get_style(self));
185         break;
186     case PROP_ID:
187         g_value_take_string(value, webkit_dom_element_get_id(self));
188         break;
189     case PROP_NAMESPACE_URI:
190         g_value_take_string(value, webkit_dom_element_get_namespace_uri(self));
191         break;
192     case PROP_PREFIX:
193         g_value_take_string(value, webkit_dom_element_get_prefix(self));
194         break;
195     case PROP_LOCAL_NAME:
196         g_value_take_string(value, webkit_dom_element_get_local_name(self));
197         break;
198     case PROP_OFFSET_LEFT:
199         g_value_set_double(value, webkit_dom_element_get_offset_left(self));
200         break;
201     case PROP_OFFSET_TOP:
202         g_value_set_double(value, webkit_dom_element_get_offset_top(self));
203         break;
204     case PROP_OFFSET_WIDTH:
205         g_value_set_double(value, webkit_dom_element_get_offset_width(self));
206         break;
207     case PROP_OFFSET_HEIGHT:
208         g_value_set_double(value, webkit_dom_element_get_offset_height(self));
209         break;
210     case PROP_CLIENT_LEFT:
211         g_value_set_double(value, webkit_dom_element_get_client_left(self));
212         break;
213     case PROP_CLIENT_TOP:
214         g_value_set_double(value, webkit_dom_element_get_client_top(self));
215         break;
216     case PROP_CLIENT_WIDTH:
217         g_value_set_double(value, webkit_dom_element_get_client_width(self));
218         break;
219     case PROP_CLIENT_HEIGHT:
220         g_value_set_double(value, webkit_dom_element_get_client_height(self));
221         break;
222     case PROP_SCROLL_LEFT:
223         g_value_set_long(value, webkit_dom_element_get_scroll_left(self));
224         break;
225     case PROP_SCROLL_TOP:
226         g_value_set_long(value, webkit_dom_element_get_scroll_top(self));
227         break;
228     case PROP_SCROLL_WIDTH:
229         g_value_set_long(value, webkit_dom_element_get_scroll_width(self));
230         break;
231     case PROP_SCROLL_HEIGHT:
232         g_value_set_long(value, webkit_dom_element_get_scroll_height(self));
233         break;
234     case PROP_OFFSET_PARENT:
235         g_value_set_object(value, webkit_dom_element_get_offset_parent(self));
236         break;
237     case PROP_INNER_HTML:
238         g_value_take_string(value, webkit_dom_element_get_inner_html(self));
239         break;
240     case PROP_OUTER_HTML:
241         g_value_take_string(value, webkit_dom_element_get_outer_html(self));
242         break;
243     case PROP_CLASS_NAME:
244         g_value_take_string(value, webkit_dom_element_get_class_name(self));
245         break;
246     case PROP_CLASS_LIST:
247         g_value_set_object(value, webkit_dom_element_get_class_list(self));
248         break;
249     case PROP_WEBKIT_REGION_OVERSET:
250         g_value_take_string(value, webkit_dom_element_get_webkit_region_overset(self));
251         break;
252     case PROP_PREVIOUS_ELEMENT_SIBLING:
253         g_value_set_object(value, webkit_dom_element_get_previous_element_sibling(self));
254         break;
255     case PROP_NEXT_ELEMENT_SIBLING:
256         g_value_set_object(value, webkit_dom_element_get_next_element_sibling(self));
257         break;
258     case PROP_CHILDREN:
259         g_value_set_object(value, webkit_dom_element_get_children(self));
260         break;
261     case PROP_FIRST_ELEMENT_CHILD:
262         g_value_set_object(value, webkit_dom_element_get_first_element_child(self));
263         break;
264     case PROP_LAST_ELEMENT_CHILD:
265         g_value_set_object(value, webkit_dom_element_get_last_element_child(self));
266         break;
267     case PROP_CHILD_ELEMENT_COUNT:
268         g_value_set_ulong(value, webkit_dom_element_get_child_element_count(self));
269         break;
270     default:
271         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
272         break;
273     }
274 }
275
276 static void webkit_dom_element_class_init(WebKitDOMElementClass* requestClass)
277 {
278     GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
279     gobjectClass->set_property = webkit_dom_element_set_property;
280     gobjectClass->get_property = webkit_dom_element_get_property;
281
282     g_object_class_install_property(
283         gobjectClass,
284         PROP_TAG_NAME,
285         g_param_spec_string(
286             "tag-name",
287             "Element:tag-name",
288             "read-only gchar* Element:tag-name",
289             "",
290             WEBKIT_PARAM_READABLE));
291
292     g_object_class_install_property(
293         gobjectClass,
294         PROP_ATTRIBUTES,
295         g_param_spec_object(
296             "attributes",
297             "Element:attributes",
298             "read-only WebKitDOMNamedNodeMap* Element:attributes",
299             WEBKIT_DOM_TYPE_NAMED_NODE_MAP,
300             WEBKIT_PARAM_READABLE));
301
302     g_object_class_install_property(
303         gobjectClass,
304         PROP_STYLE,
305         g_param_spec_object(
306             "style",
307             "Element:style",
308             "read-only WebKitDOMCSSStyleDeclaration* Element:style",
309             WEBKIT_DOM_TYPE_CSS_STYLE_DECLARATION,
310             WEBKIT_PARAM_READABLE));
311
312     g_object_class_install_property(
313         gobjectClass,
314         PROP_ID,
315         g_param_spec_string(
316             "id",
317             "Element:id",
318             "read-write gchar* Element:id",
319             "",
320             WEBKIT_PARAM_READWRITE));
321
322     g_object_class_install_property(
323         gobjectClass,
324         PROP_NAMESPACE_URI,
325         g_param_spec_string(
326             "namespace-uri",
327             "Element:namespace-uri",
328             "read-only gchar* Element:namespace-uri",
329             "",
330             WEBKIT_PARAM_READABLE));
331
332     g_object_class_install_property(
333         gobjectClass,
334         PROP_PREFIX,
335         g_param_spec_string(
336             "prefix",
337             "Element:prefix",
338             "read-only gchar* Element:prefix",
339             "",
340             WEBKIT_PARAM_READABLE));
341
342     g_object_class_install_property(
343         gobjectClass,
344         PROP_LOCAL_NAME,
345         g_param_spec_string(
346             "local-name",
347             "Element:local-name",
348             "read-only gchar* Element:local-name",
349             "",
350             WEBKIT_PARAM_READABLE));
351
352     g_object_class_install_property(
353         gobjectClass,
354         PROP_OFFSET_LEFT,
355         g_param_spec_double(
356             "offset-left",
357             "Element:offset-left",
358             "read-only gdouble Element:offset-left",
359             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
360             WEBKIT_PARAM_READABLE));
361
362     g_object_class_install_property(
363         gobjectClass,
364         PROP_OFFSET_TOP,
365         g_param_spec_double(
366             "offset-top",
367             "Element:offset-top",
368             "read-only gdouble Element:offset-top",
369             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
370             WEBKIT_PARAM_READABLE));
371
372     g_object_class_install_property(
373         gobjectClass,
374         PROP_OFFSET_WIDTH,
375         g_param_spec_double(
376             "offset-width",
377             "Element:offset-width",
378             "read-only gdouble Element:offset-width",
379             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
380             WEBKIT_PARAM_READABLE));
381
382     g_object_class_install_property(
383         gobjectClass,
384         PROP_OFFSET_HEIGHT,
385         g_param_spec_double(
386             "offset-height",
387             "Element:offset-height",
388             "read-only gdouble Element:offset-height",
389             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
390             WEBKIT_PARAM_READABLE));
391
392     g_object_class_install_property(
393         gobjectClass,
394         PROP_CLIENT_LEFT,
395         g_param_spec_double(
396             "client-left",
397             "Element:client-left",
398             "read-only gdouble Element:client-left",
399             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
400             WEBKIT_PARAM_READABLE));
401
402     g_object_class_install_property(
403         gobjectClass,
404         PROP_CLIENT_TOP,
405         g_param_spec_double(
406             "client-top",
407             "Element:client-top",
408             "read-only gdouble Element:client-top",
409             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
410             WEBKIT_PARAM_READABLE));
411
412     g_object_class_install_property(
413         gobjectClass,
414         PROP_CLIENT_WIDTH,
415         g_param_spec_double(
416             "client-width",
417             "Element:client-width",
418             "read-only gdouble Element:client-width",
419             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
420             WEBKIT_PARAM_READABLE));
421
422     g_object_class_install_property(
423         gobjectClass,
424         PROP_CLIENT_HEIGHT,
425         g_param_spec_double(
426             "client-height",
427             "Element:client-height",
428             "read-only gdouble Element:client-height",
429             -G_MAXDOUBLE, G_MAXDOUBLE, 0,
430             WEBKIT_PARAM_READABLE));
431
432     g_object_class_install_property(
433         gobjectClass,
434         PROP_SCROLL_LEFT,
435         g_param_spec_long(
436             "scroll-left",
437             "Element:scroll-left",
438             "read-write glong Element:scroll-left",
439             G_MINLONG, G_MAXLONG, 0,
440             WEBKIT_PARAM_READWRITE));
441
442     g_object_class_install_property(
443         gobjectClass,
444         PROP_SCROLL_TOP,
445         g_param_spec_long(
446             "scroll-top",
447             "Element:scroll-top",
448             "read-write glong Element:scroll-top",
449             G_MINLONG, G_MAXLONG, 0,
450             WEBKIT_PARAM_READWRITE));
451
452     g_object_class_install_property(
453         gobjectClass,
454         PROP_SCROLL_WIDTH,
455         g_param_spec_long(
456             "scroll-width",
457             "Element:scroll-width",
458             "read-only glong Element:scroll-width",
459             G_MINLONG, G_MAXLONG, 0,
460             WEBKIT_PARAM_READABLE));
461
462     g_object_class_install_property(
463         gobjectClass,
464         PROP_SCROLL_HEIGHT,
465         g_param_spec_long(
466             "scroll-height",
467             "Element:scroll-height",
468             "read-only glong Element:scroll-height",
469             G_MINLONG, G_MAXLONG, 0,
470             WEBKIT_PARAM_READABLE));
471
472     g_object_class_install_property(
473         gobjectClass,
474         PROP_OFFSET_PARENT,
475         g_param_spec_object(
476             "offset-parent",
477             "Element:offset-parent",
478             "read-only WebKitDOMElement* Element:offset-parent",
479             WEBKIT_DOM_TYPE_ELEMENT,
480             WEBKIT_PARAM_READABLE));
481
482     g_object_class_install_property(
483         gobjectClass,
484         PROP_INNER_HTML,
485         g_param_spec_string(
486             "inner-html",
487             "Element:inner-html",
488             "read-write gchar* Element:inner-html",
489             "",
490             WEBKIT_PARAM_READWRITE));
491
492     g_object_class_install_property(
493         gobjectClass,
494         PROP_OUTER_HTML,
495         g_param_spec_string(
496             "outer-html",
497             "Element:outer-html",
498             "read-write gchar* Element:outer-html",
499             "",
500             WEBKIT_PARAM_READWRITE));
501
502     g_object_class_install_property(
503         gobjectClass,
504         PROP_CLASS_NAME,
505         g_param_spec_string(
506             "class-name",
507             "Element:class-name",
508             "read-write gchar* Element:class-name",
509             "",
510             WEBKIT_PARAM_READWRITE));
511
512     g_object_class_install_property(
513         gobjectClass,
514         PROP_CLASS_LIST,
515         g_param_spec_object(
516             "class-list",
517             "Element:class-list",
518             "read-only WebKitDOMDOMTokenList* Element:class-list",
519             WEBKIT_DOM_TYPE_DOM_TOKEN_LIST,
520             WEBKIT_PARAM_READABLE));
521
522     g_object_class_install_property(
523         gobjectClass,
524         PROP_WEBKIT_REGION_OVERSET,
525         g_param_spec_string(
526             "webkit-region-overset",
527             "Element:webkit-region-overset",
528             "read-only gchar* Element:webkit-region-overset",
529             "",
530             WEBKIT_PARAM_READABLE));
531
532     g_object_class_install_property(
533         gobjectClass,
534         PROP_PREVIOUS_ELEMENT_SIBLING,
535         g_param_spec_object(
536             "previous-element-sibling",
537             "Element:previous-element-sibling",
538             "read-only WebKitDOMElement* Element:previous-element-sibling",
539             WEBKIT_DOM_TYPE_ELEMENT,
540             WEBKIT_PARAM_READABLE));
541
542     g_object_class_install_property(
543         gobjectClass,
544         PROP_NEXT_ELEMENT_SIBLING,
545         g_param_spec_object(
546             "next-element-sibling",
547             "Element:next-element-sibling",
548             "read-only WebKitDOMElement* Element:next-element-sibling",
549             WEBKIT_DOM_TYPE_ELEMENT,
550             WEBKIT_PARAM_READABLE));
551
552     g_object_class_install_property(
553         gobjectClass,
554         PROP_CHILDREN,
555         g_param_spec_object(
556             "children",
557             "Element:children",
558             "read-only WebKitDOMHTMLCollection* Element:children",
559             WEBKIT_DOM_TYPE_HTML_COLLECTION,
560             WEBKIT_PARAM_READABLE));
561
562     g_object_class_install_property(
563         gobjectClass,
564         PROP_FIRST_ELEMENT_CHILD,
565         g_param_spec_object(
566             "first-element-child",
567             "Element:first-element-child",
568             "read-only WebKitDOMElement* Element:first-element-child",
569             WEBKIT_DOM_TYPE_ELEMENT,
570             WEBKIT_PARAM_READABLE));
571
572     g_object_class_install_property(
573         gobjectClass,
574         PROP_LAST_ELEMENT_CHILD,
575         g_param_spec_object(
576             "last-element-child",
577             "Element:last-element-child",
578             "read-only WebKitDOMElement* Element:last-element-child",
579             WEBKIT_DOM_TYPE_ELEMENT,
580             WEBKIT_PARAM_READABLE));
581
582     g_object_class_install_property(
583         gobjectClass,
584         PROP_CHILD_ELEMENT_COUNT,
585         g_param_spec_ulong(
586             "child-element-count",
587             "Element:child-element-count",
588             "read-only gulong Element:child-element-count",
589             0, G_MAXULONG, 0,
590             WEBKIT_PARAM_READABLE));
591
592 }
593
594 static void webkit_dom_element_init(WebKitDOMElement* request)
595 {
596     UNUSED_PARAM(request);
597 }
598
599 gchar* webkit_dom_element_get_attribute(WebKitDOMElement* self, const gchar* name)
600 {
601     WebCore::JSMainThreadNullState state;
602     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
603     g_return_val_if_fail(name, 0);
604     WebCore::Element* item = WebKit::core(self);
605     WTF::String convertedName = WTF::String::fromUTF8(name);
606     gchar* result = convertToUTF8String(item->getAttribute(convertedName));
607     return result;
608 }
609
610 void webkit_dom_element_set_attribute(WebKitDOMElement* self, const gchar* name, const gchar* value, GError** error)
611 {
612     WebCore::JSMainThreadNullState state;
613     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
614     g_return_if_fail(name);
615     g_return_if_fail(value);
616     g_return_if_fail(!error || !*error);
617     WebCore::Element* item = WebKit::core(self);
618     WTF::String convertedName = WTF::String::fromUTF8(name);
619     WTF::String convertedValue = WTF::String::fromUTF8(value);
620     auto result = item->setAttribute(convertedName, convertedValue);
621     if (result.hasException()) {
622         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
623         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
624     }
625 }
626
627 void webkit_dom_element_remove_attribute(WebKitDOMElement* self, const gchar* name)
628 {
629     WebCore::JSMainThreadNullState state;
630     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
631     g_return_if_fail(name);
632     WebCore::Element* item = WebKit::core(self);
633     WTF::String convertedName = WTF::String::fromUTF8(name);
634     item->removeAttribute(convertedName);
635 }
636
637 WebKitDOMAttr* webkit_dom_element_get_attribute_node(WebKitDOMElement* self, const gchar* name)
638 {
639     WebCore::JSMainThreadNullState state;
640     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
641     g_return_val_if_fail(name, 0);
642     WebCore::Element* item = WebKit::core(self);
643     WTF::String convertedName = WTF::String::fromUTF8(name);
644     RefPtr<WebCore::Attr> gobjectResult = WTF::getPtr(item->getAttributeNode(convertedName));
645     return WebKit::kit(gobjectResult.get());
646 }
647
648 WebKitDOMAttr* webkit_dom_element_set_attribute_node(WebKitDOMElement* self, WebKitDOMAttr* newAttr, GError** error)
649 {
650     WebCore::JSMainThreadNullState state;
651     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
652     g_return_val_if_fail(WEBKIT_DOM_IS_ATTR(newAttr), 0);
653     g_return_val_if_fail(!error || !*error, 0);
654     WebCore::Element* item = WebKit::core(self);
655     WebCore::Attr* convertedNewAttr = WebKit::core(newAttr);
656     auto result = item->setAttributeNode(*convertedNewAttr);
657     if (result.hasException()) {
658         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
659         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
660         return nullptr;
661     }
662     return WebKit::kit(result.releaseReturnValue().get());
663 }
664
665 WebKitDOMAttr* webkit_dom_element_remove_attribute_node(WebKitDOMElement* self, WebKitDOMAttr* oldAttr, GError** error)
666 {
667     WebCore::JSMainThreadNullState state;
668     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
669     g_return_val_if_fail(WEBKIT_DOM_IS_ATTR(oldAttr), 0);
670     g_return_val_if_fail(!error || !*error, 0);
671     WebCore::Element* item = WebKit::core(self);
672     WebCore::Attr* convertedOldAttr = WebKit::core(oldAttr);
673     auto result = item->removeAttributeNode(*convertedOldAttr);
674     if (result.hasException()) {
675         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
676         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
677         return nullptr;
678     }
679     return WebKit::kit(result.releaseReturnValue().ptr());
680 }
681
682 WebKitDOMHTMLCollection* webkit_dom_element_get_elements_by_tag_name_as_html_collection(WebKitDOMElement* self, const gchar* name)
683 {
684     WebCore::JSMainThreadNullState state;
685     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
686     g_return_val_if_fail(name, 0);
687     WebCore::Element* item = WebKit::core(self);
688     WTF::String convertedName = WTF::String::fromUTF8(name);
689     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByTagName(convertedName));
690     return WebKit::kit(gobjectResult.get());
691 }
692
693 gboolean webkit_dom_element_has_attributes(WebKitDOMElement* self)
694 {
695     WebCore::JSMainThreadNullState state;
696     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
697     WebCore::Element* item = WebKit::core(self);
698     gboolean result = item->hasAttributes();
699     return result;
700 }
701
702 gchar* webkit_dom_element_get_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
703 {
704     WebCore::JSMainThreadNullState state;
705     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
706     g_return_val_if_fail(namespaceURI, 0);
707     g_return_val_if_fail(localName, 0);
708     WebCore::Element* item = WebKit::core(self);
709     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
710     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
711     gchar* result = convertToUTF8String(item->getAttributeNS(convertedNamespaceURI, convertedLocalName));
712     return result;
713 }
714
715 void webkit_dom_element_set_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* qualifiedName, const gchar* value, GError** error)
716 {
717     WebCore::JSMainThreadNullState state;
718     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
719     g_return_if_fail(qualifiedName);
720     g_return_if_fail(value);
721     g_return_if_fail(!error || !*error);
722     WebCore::Element* item = WebKit::core(self);
723     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
724     WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
725     WTF::String convertedValue = WTF::String::fromUTF8(value);
726     auto result = item->setAttributeNS(convertedNamespaceURI, convertedQualifiedName, convertedValue);
727     if (result.hasException()) {
728         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
729         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
730     }
731 }
732
733 void webkit_dom_element_remove_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
734 {
735     WebCore::JSMainThreadNullState state;
736     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
737     g_return_if_fail(namespaceURI);
738     g_return_if_fail(localName);
739     WebCore::Element* item = WebKit::core(self);
740     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
741     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
742     item->removeAttributeNS(convertedNamespaceURI, convertedLocalName);
743 }
744
745 WebKitDOMHTMLCollection* webkit_dom_element_get_elements_by_tag_name_ns_as_html_collection(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
746 {
747     WebCore::JSMainThreadNullState state;
748     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
749     g_return_val_if_fail(namespaceURI, 0);
750     g_return_val_if_fail(localName, 0);
751     WebCore::Element* item = WebKit::core(self);
752     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
753     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
754     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByTagNameNS(convertedNamespaceURI, convertedLocalName));
755     return WebKit::kit(gobjectResult.get());
756 }
757
758 WebKitDOMAttr* webkit_dom_element_get_attribute_node_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
759 {
760     WebCore::JSMainThreadNullState state;
761     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
762     g_return_val_if_fail(namespaceURI, 0);
763     g_return_val_if_fail(localName, 0);
764     WebCore::Element* item = WebKit::core(self);
765     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
766     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
767     RefPtr<WebCore::Attr> gobjectResult = WTF::getPtr(item->getAttributeNodeNS(convertedNamespaceURI, convertedLocalName));
768     return WebKit::kit(gobjectResult.get());
769 }
770
771 WebKitDOMAttr* webkit_dom_element_set_attribute_node_ns(WebKitDOMElement* self, WebKitDOMAttr* newAttr, GError** error)
772 {
773     WebCore::JSMainThreadNullState state;
774     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
775     g_return_val_if_fail(WEBKIT_DOM_IS_ATTR(newAttr), 0);
776     g_return_val_if_fail(!error || !*error, 0);
777     WebCore::Element* item = WebKit::core(self);
778     WebCore::Attr* convertedNewAttr = WebKit::core(newAttr);
779     auto result = item->setAttributeNodeNS(*convertedNewAttr);
780     if (result.hasException()) {
781         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
782         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
783         return nullptr;
784     }
785     return WebKit::kit(result.releaseReturnValue().get());
786 }
787
788 gboolean webkit_dom_element_has_attribute(WebKitDOMElement* self, const gchar* name)
789 {
790     WebCore::JSMainThreadNullState state;
791     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
792     g_return_val_if_fail(name, FALSE);
793     WebCore::Element* item = WebKit::core(self);
794     WTF::String convertedName = WTF::String::fromUTF8(name);
795     gboolean result = item->hasAttribute(convertedName);
796     return result;
797 }
798
799 gboolean webkit_dom_element_has_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
800 {
801     WebCore::JSMainThreadNullState state;
802     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
803     g_return_val_if_fail(namespaceURI, FALSE);
804     g_return_val_if_fail(localName, FALSE);
805     WebCore::Element* item = WebKit::core(self);
806     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
807     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
808     gboolean result = item->hasAttributeNS(convertedNamespaceURI, convertedLocalName);
809     return result;
810 }
811
812 void webkit_dom_element_focus(WebKitDOMElement* self)
813 {
814     WebCore::JSMainThreadNullState state;
815     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
816     WebCore::Element* item = WebKit::core(self);
817     item->focus();
818 }
819
820 void webkit_dom_element_blur(WebKitDOMElement* self)
821 {
822     WebCore::JSMainThreadNullState state;
823     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
824     WebCore::Element* item = WebKit::core(self);
825     item->blur();
826 }
827
828 void webkit_dom_element_scroll_into_view(WebKitDOMElement* self, gboolean alignWithTop)
829 {
830     WebCore::JSMainThreadNullState state;
831     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
832     WebCore::Element* item = WebKit::core(self);
833     item->scrollIntoView(alignWithTop);
834 }
835
836 void webkit_dom_element_scroll_into_view_if_needed(WebKitDOMElement* self, gboolean centerIfNeeded)
837 {
838     WebCore::JSMainThreadNullState state;
839     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
840     WebCore::Element* item = WebKit::core(self);
841     item->scrollIntoViewIfNeeded(centerIfNeeded);
842 }
843
844 void webkit_dom_element_scroll_by_lines(WebKitDOMElement* self, glong lines)
845 {
846     WebCore::JSMainThreadNullState state;
847     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
848     WebCore::Element* item = WebKit::core(self);
849     item->scrollByLines(lines);
850 }
851
852 void webkit_dom_element_scroll_by_pages(WebKitDOMElement* self, glong pages)
853 {
854     WebCore::JSMainThreadNullState state;
855     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
856     WebCore::Element* item = WebKit::core(self);
857     item->scrollByPages(pages);
858 }
859
860 WebKitDOMHTMLCollection* webkit_dom_element_get_elements_by_class_name_as_html_collection(WebKitDOMElement* self, const gchar* name)
861 {
862     WebCore::JSMainThreadNullState state;
863     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
864     g_return_val_if_fail(name, 0);
865     WebCore::Element* item = WebKit::core(self);
866     WTF::String convertedName = WTF::String::fromUTF8(name);
867     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByClassName(convertedName));
868     return WebKit::kit(gobjectResult.get());
869 }
870
871 gboolean webkit_dom_element_matches(WebKitDOMElement* self, const gchar* selectors, GError** error)
872 {
873     WebCore::JSMainThreadNullState state;
874     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
875     g_return_val_if_fail(selectors, FALSE);
876     g_return_val_if_fail(!error || !*error, FALSE);
877     WebCore::Element* item = WebKit::core(self);
878     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
879     auto result = item->matches(convertedSelectors);
880     if (result.hasException()) {
881         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
882         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
883         return false;
884     }
885     return result.releaseReturnValue();
886 }
887
888 WebKitDOMElement* webkit_dom_element_closest(WebKitDOMElement* self, const gchar* selectors, GError** error)
889 {
890     WebCore::JSMainThreadNullState state;
891     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
892     g_return_val_if_fail(selectors, 0);
893     g_return_val_if_fail(!error || !*error, 0);
894     WebCore::Element* item = WebKit::core(self);
895     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
896     auto result = item->closest(convertedSelectors);
897     if (result.hasException()) {
898         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
899         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
900         return nullptr;
901     }
902     return WebKit::kit(result.releaseReturnValue());
903 }
904
905 gboolean webkit_dom_element_webkit_matches_selector(WebKitDOMElement* self, const gchar* selectors, GError** error)
906 {
907     return webkit_dom_element_matches(self, selectors, error);
908 }
909
910 void webkit_dom_element_webkit_request_fullscreen(WebKitDOMElement* self)
911 {
912     WebCore::JSMainThreadNullState state;
913     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
914     WebCore::Element* item = WebKit::core(self);
915     item->webkitRequestFullscreen();
916 }
917
918 WebKitDOMElement* webkit_dom_element_insert_adjacent_element(WebKitDOMElement* self, const gchar* where, WebKitDOMElement* element, GError** error)
919 {
920     WebCore::JSMainThreadNullState state;
921     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
922     g_return_val_if_fail(where, 0);
923     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(element), 0);
924     g_return_val_if_fail(!error || !*error, 0);
925     WebCore::Element* item = WebKit::core(self);
926     WTF::String convertedWhere = WTF::String::fromUTF8(where);
927     WebCore::Element* convertedElement = WebKit::core(element);
928     auto result = item->insertAdjacentElement(convertedWhere, *convertedElement);
929     if (result.hasException()) {
930         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
931         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
932         return nullptr;
933     }
934     return WebKit::kit(result.releaseReturnValue());
935 }
936
937 void webkit_dom_element_insert_adjacent_html(WebKitDOMElement* self, const gchar* where, const gchar* html, GError** error)
938 {
939     WebCore::JSMainThreadNullState state;
940     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
941     g_return_if_fail(where);
942     g_return_if_fail(html);
943     g_return_if_fail(!error || !*error);
944     WebCore::Element* item = WebKit::core(self);
945     WTF::String convertedWhere = WTF::String::fromUTF8(where);
946     WTF::String convertedHtml = WTF::String::fromUTF8(html);
947     auto result = item->insertAdjacentHTML(convertedWhere, convertedHtml);
948     if (result.hasException()) {
949         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
950         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
951     }
952 }
953
954 void webkit_dom_element_insert_adjacent_text(WebKitDOMElement* self, const gchar* where, const gchar* text, GError** error)
955 {
956     WebCore::JSMainThreadNullState state;
957     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
958     g_return_if_fail(where);
959     g_return_if_fail(text);
960     g_return_if_fail(!error || !*error);
961     WebCore::Element* item = WebKit::core(self);
962     WTF::String convertedWhere = WTF::String::fromUTF8(where);
963     WTF::String convertedText = WTF::String::fromUTF8(text);
964     auto result = item->insertAdjacentText(convertedWhere, convertedText);
965     if (result.hasException()) {
966         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
967         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
968     }
969 }
970
971 void webkit_dom_element_request_pointer_lock(WebKitDOMElement* self)
972 {
973 #if ENABLE(POINTER_LOCK)
974     WebCore::JSMainThreadNullState state;
975     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
976     WebCore::Element* item = WebKit::core(self);
977     item->requestPointerLock();
978 #else
979     UNUSED_PARAM(self);
980     WEBKIT_WARN_FEATURE_NOT_PRESENT("Pointer Lock")
981 #endif /* ENABLE(POINTER_LOCK) */
982 }
983
984 void webkit_dom_element_remove(WebKitDOMElement* self, GError** error)
985 {
986     WebCore::JSMainThreadNullState state;
987     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
988     g_return_if_fail(!error || !*error);
989     WebCore::Element* item = WebKit::core(self);
990     auto result = item->remove();
991     if (result.hasException()) {
992         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
993         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
994     }
995 }
996
997 WebKitDOMElement* webkit_dom_element_query_selector(WebKitDOMElement* self, const gchar* selectors, GError** error)
998 {
999     WebCore::JSMainThreadNullState state;
1000     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1001     g_return_val_if_fail(selectors, 0);
1002     g_return_val_if_fail(!error || !*error, 0);
1003     WebCore::Element* item = WebKit::core(self);
1004     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
1005     auto result = item->querySelector(convertedSelectors);
1006     if (result.hasException()) {
1007         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
1008         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
1009         return nullptr;
1010     }
1011     return WebKit::kit(result.releaseReturnValue());
1012 }
1013
1014 WebKitDOMNodeList* webkit_dom_element_query_selector_all(WebKitDOMElement* self, const gchar* selectors, GError** error)
1015 {
1016     WebCore::JSMainThreadNullState state;
1017     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1018     g_return_val_if_fail(selectors, 0);
1019     g_return_val_if_fail(!error || !*error, 0);
1020     WebCore::Element* item = WebKit::core(self);
1021     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
1022     auto result = item->querySelectorAll(convertedSelectors);
1023     if (result.hasException()) {
1024         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
1025         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
1026         return nullptr;
1027     }
1028     return WebKit::kit(result.releaseReturnValue().ptr());
1029 }
1030
1031 gchar* webkit_dom_element_get_tag_name(WebKitDOMElement* self)
1032 {
1033     WebCore::JSMainThreadNullState state;
1034     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1035     WebCore::Element* item = WebKit::core(self);
1036     gchar* result = convertToUTF8String(item->tagName());
1037     return result;
1038 }
1039
1040 WebKitDOMNamedNodeMap* webkit_dom_element_get_attributes(WebKitDOMElement* self)
1041 {
1042     WebCore::JSMainThreadNullState state;
1043     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1044     WebCore::Element* item = WebKit::core(self);
1045     RefPtr<WebCore::NamedNodeMap> gobjectResult = WTF::getPtr(item->attributes());
1046     return WebKit::kit(gobjectResult.get());
1047 }
1048
1049 WebKitDOMCSSStyleDeclaration* webkit_dom_element_get_style(WebKitDOMElement* self)
1050 {
1051     WebCore::JSMainThreadNullState state;
1052     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1053     auto& item = *WebKit::core(self);
1054     if (!is<WebCore::StyledElement>(item))
1055         return nullptr;
1056     return WebKit::kit(&downcast<WebCore::StyledElement>(item).cssomStyle());
1057 }
1058
1059 gchar* webkit_dom_element_get_id(WebKitDOMElement* self)
1060 {
1061     WebCore::JSMainThreadNullState state;
1062     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1063     WebCore::Element* item = WebKit::core(self);
1064     gchar* result = convertToUTF8String(item->getIdAttribute());
1065     return result;
1066 }
1067
1068 void webkit_dom_element_set_id(WebKitDOMElement* self, const gchar* value)
1069 {
1070     WebCore::JSMainThreadNullState state;
1071     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1072     g_return_if_fail(value);
1073     WebCore::Element* item = WebKit::core(self);
1074     WTF::String convertedValue = WTF::String::fromUTF8(value);
1075     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::idAttr, convertedValue);
1076 }
1077
1078 gchar* webkit_dom_element_get_namespace_uri(WebKitDOMElement* self)
1079 {
1080     WebCore::JSMainThreadNullState state;
1081     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1082     WebCore::Element* item = WebKit::core(self);
1083     gchar* result = convertToUTF8String(item->namespaceURI());
1084     return result;
1085 }
1086
1087 gchar* webkit_dom_element_get_prefix(WebKitDOMElement* self)
1088 {
1089     WebCore::JSMainThreadNullState state;
1090     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1091     WebCore::Element* item = WebKit::core(self);
1092     gchar* result = convertToUTF8String(item->prefix());
1093     return result;
1094 }
1095
1096 gchar* webkit_dom_element_get_local_name(WebKitDOMElement* self)
1097 {
1098     WebCore::JSMainThreadNullState state;
1099     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1100     WebCore::Element* item = WebKit::core(self);
1101     gchar* result = convertToUTF8String(item->localName());
1102     return result;
1103 }
1104
1105 gdouble webkit_dom_element_get_offset_left(WebKitDOMElement* self)
1106 {
1107     WebCore::JSMainThreadNullState state;
1108     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1109     WebCore::Element* item = WebKit::core(self);
1110     gdouble result = item->offsetLeft();
1111     return result;
1112 }
1113
1114 gdouble webkit_dom_element_get_offset_top(WebKitDOMElement* self)
1115 {
1116     WebCore::JSMainThreadNullState state;
1117     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1118     WebCore::Element* item = WebKit::core(self);
1119     gdouble result = item->offsetTop();
1120     return result;
1121 }
1122
1123 gdouble webkit_dom_element_get_offset_width(WebKitDOMElement* self)
1124 {
1125     WebCore::JSMainThreadNullState state;
1126     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1127     WebCore::Element* item = WebKit::core(self);
1128     gdouble result = item->offsetWidth();
1129     return result;
1130 }
1131
1132 gdouble webkit_dom_element_get_offset_height(WebKitDOMElement* self)
1133 {
1134     WebCore::JSMainThreadNullState state;
1135     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1136     WebCore::Element* item = WebKit::core(self);
1137     gdouble result = item->offsetHeight();
1138     return result;
1139 }
1140
1141 gdouble webkit_dom_element_get_client_left(WebKitDOMElement* self)
1142 {
1143     WebCore::JSMainThreadNullState state;
1144     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1145     WebCore::Element* item = WebKit::core(self);
1146     gdouble result = item->clientLeft();
1147     return result;
1148 }
1149
1150 gdouble webkit_dom_element_get_client_top(WebKitDOMElement* self)
1151 {
1152     WebCore::JSMainThreadNullState state;
1153     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1154     WebCore::Element* item = WebKit::core(self);
1155     gdouble result = item->clientTop();
1156     return result;
1157 }
1158
1159 gdouble webkit_dom_element_get_client_width(WebKitDOMElement* self)
1160 {
1161     WebCore::JSMainThreadNullState state;
1162     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1163     WebCore::Element* item = WebKit::core(self);
1164     gdouble result = item->clientWidth();
1165     return result;
1166 }
1167
1168 gdouble webkit_dom_element_get_client_height(WebKitDOMElement* self)
1169 {
1170     WebCore::JSMainThreadNullState state;
1171     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1172     WebCore::Element* item = WebKit::core(self);
1173     gdouble result = item->clientHeight();
1174     return result;
1175 }
1176
1177 glong webkit_dom_element_get_scroll_left(WebKitDOMElement* self)
1178 {
1179     WebCore::JSMainThreadNullState state;
1180     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1181     WebCore::Element* item = WebKit::core(self);
1182     glong result = item->scrollLeft();
1183     return result;
1184 }
1185
1186 void webkit_dom_element_set_scroll_left(WebKitDOMElement* self, glong value)
1187 {
1188     WebCore::JSMainThreadNullState state;
1189     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1190     WebCore::Element* item = WebKit::core(self);
1191     item->setScrollLeft(value);
1192 }
1193
1194 glong webkit_dom_element_get_scroll_top(WebKitDOMElement* self)
1195 {
1196     WebCore::JSMainThreadNullState state;
1197     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1198     WebCore::Element* item = WebKit::core(self);
1199     glong result = item->scrollTop();
1200     return result;
1201 }
1202
1203 void webkit_dom_element_set_scroll_top(WebKitDOMElement* self, glong value)
1204 {
1205     WebCore::JSMainThreadNullState state;
1206     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1207     WebCore::Element* item = WebKit::core(self);
1208     item->setScrollTop(value);
1209 }
1210
1211 glong webkit_dom_element_get_scroll_width(WebKitDOMElement* self)
1212 {
1213     WebCore::JSMainThreadNullState state;
1214     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1215     WebCore::Element* item = WebKit::core(self);
1216     glong result = item->scrollWidth();
1217     return result;
1218 }
1219
1220 glong webkit_dom_element_get_scroll_height(WebKitDOMElement* self)
1221 {
1222     WebCore::JSMainThreadNullState state;
1223     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1224     WebCore::Element* item = WebKit::core(self);
1225     glong result = item->scrollHeight();
1226     return result;
1227 }
1228
1229 WebKitDOMClientRect* webkit_dom_element_get_bounding_client_rect(WebKitDOMElement* self)
1230 {
1231     WebCore::JSMainThreadNullState state;
1232     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), nullptr);
1233     WebCore::Element* item = WebKit::core(self);
1234     return WebKit::kit(item->getBoundingClientRect().ptr());
1235 }
1236
1237 WebKitDOMClientRectList* webkit_dom_element_get_client_rects(WebKitDOMElement* self)
1238 {
1239     WebCore::JSMainThreadNullState state;
1240     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), nullptr);
1241     WebCore::Element* item = WebKit::core(self);
1242     return WebKit::kit(item->getClientRects().ptr());
1243 }
1244
1245 WebKitDOMElement* webkit_dom_element_get_offset_parent(WebKitDOMElement* self)
1246 {
1247     WebCore::JSMainThreadNullState state;
1248     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1249     WebCore::Element* item = WebKit::core(self);
1250     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->bindingsOffsetParent());
1251     return WebKit::kit(gobjectResult.get());
1252 }
1253
1254 gchar* webkit_dom_element_get_inner_html(WebKitDOMElement* self)
1255 {
1256     WebCore::JSMainThreadNullState state;
1257     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1258     WebCore::Element* item = WebKit::core(self);
1259     gchar* result = convertToUTF8String(item->innerHTML());
1260     return result;
1261 }
1262
1263 void webkit_dom_element_set_inner_html(WebKitDOMElement* self, const gchar* value, GError** error)
1264 {
1265     WebCore::JSMainThreadNullState state;
1266     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1267     g_return_if_fail(value);
1268     g_return_if_fail(!error || !*error);
1269     WebCore::Element* item = WebKit::core(self);
1270     WTF::String convertedValue = WTF::String::fromUTF8(value);
1271     auto result = item->setInnerHTML(convertedValue);
1272     if (result.hasException()) {
1273         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
1274         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
1275     }
1276 }
1277
1278 gchar* webkit_dom_element_get_outer_html(WebKitDOMElement* self)
1279 {
1280     WebCore::JSMainThreadNullState state;
1281     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1282     WebCore::Element* item = WebKit::core(self);
1283     gchar* result = convertToUTF8String(item->outerHTML());
1284     return result;
1285 }
1286
1287 void webkit_dom_element_set_outer_html(WebKitDOMElement* self, const gchar* value, GError** error)
1288 {
1289     WebCore::JSMainThreadNullState state;
1290     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1291     g_return_if_fail(value);
1292     g_return_if_fail(!error || !*error);
1293     WebCore::Element* item = WebKit::core(self);
1294     WTF::String convertedValue = WTF::String::fromUTF8(value);
1295     auto result = item->setOuterHTML(convertedValue);
1296     if (result.hasException()) {
1297         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
1298         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
1299     }
1300 }
1301
1302 gchar* webkit_dom_element_get_class_name(WebKitDOMElement* self)
1303 {
1304     WebCore::JSMainThreadNullState state;
1305     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1306     WebCore::Element* item = WebKit::core(self);
1307     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::classAttr));
1308     return result;
1309 }
1310
1311 void webkit_dom_element_set_class_name(WebKitDOMElement* self, const gchar* value)
1312 {
1313     WebCore::JSMainThreadNullState state;
1314     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1315     g_return_if_fail(value);
1316     WebCore::Element* item = WebKit::core(self);
1317     WTF::String convertedValue = WTF::String::fromUTF8(value);
1318     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::classAttr, convertedValue);
1319 }
1320
1321 WebKitDOMDOMTokenList* webkit_dom_element_get_class_list(WebKitDOMElement* self)
1322 {
1323     WebCore::JSMainThreadNullState state;
1324     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1325     WebCore::Element* item = WebKit::core(self);
1326     RefPtr<WebCore::DOMTokenList> gobjectResult = WTF::getPtr(item->classList());
1327     return WebKit::kit(gobjectResult.get());
1328 }
1329
1330 gchar* webkit_dom_element_get_webkit_region_overset(WebKitDOMElement* self)
1331 {
1332 #if ENABLE(CSS_REGIONS)
1333     WebCore::JSMainThreadNullState state;
1334     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1335     WebCore::Element* item = WebKit::core(self);
1336     gchar* result = convertToUTF8String(item->webkitRegionOverset());
1337     return result;
1338 #else
1339     UNUSED_PARAM(self);
1340     WEBKIT_WARN_FEATURE_NOT_PRESENT("Css Regions")
1341     return 0;
1342 #endif /* ENABLE(CSS_REGIONS) */
1343 }
1344
1345 WebKitDOMElement* webkit_dom_element_get_previous_element_sibling(WebKitDOMElement* self)
1346 {
1347     WebCore::JSMainThreadNullState state;
1348     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1349     WebCore::Element* item = WebKit::core(self);
1350     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->previousElementSibling());
1351     return WebKit::kit(gobjectResult.get());
1352 }
1353
1354 WebKitDOMElement* webkit_dom_element_get_next_element_sibling(WebKitDOMElement* self)
1355 {
1356     WebCore::JSMainThreadNullState state;
1357     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1358     WebCore::Element* item = WebKit::core(self);
1359     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->nextElementSibling());
1360     return WebKit::kit(gobjectResult.get());
1361 }
1362
1363 WebKitDOMHTMLCollection* webkit_dom_element_get_children(WebKitDOMElement* self)
1364 {
1365     WebCore::JSMainThreadNullState state;
1366     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1367     WebCore::Element* item = WebKit::core(self);
1368     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->children());
1369     return WebKit::kit(gobjectResult.get());
1370 }
1371
1372 WebKitDOMElement* webkit_dom_element_get_first_element_child(WebKitDOMElement* self)
1373 {
1374     WebCore::JSMainThreadNullState state;
1375     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1376     WebCore::Element* item = WebKit::core(self);
1377     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->firstElementChild());
1378     return WebKit::kit(gobjectResult.get());
1379 }
1380
1381 WebKitDOMElement* webkit_dom_element_get_last_element_child(WebKitDOMElement* self)
1382 {
1383     WebCore::JSMainThreadNullState state;
1384     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1385     WebCore::Element* item = WebKit::core(self);
1386     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->lastElementChild());
1387     return WebKit::kit(gobjectResult.get());
1388 }
1389
1390 gulong webkit_dom_element_get_child_element_count(WebKitDOMElement* self)
1391 {
1392     WebCore::JSMainThreadNullState state;
1393     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1394     WebCore::Element* item = WebKit::core(self);
1395     gulong result = item->childElementCount();
1396     return result;
1397 }
1398