Remove ENABLE_CSS_REGIONS
[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/DOMException.h>
26 #include <WebCore/DOMRect.h>
27 #include <WebCore/Document.h>
28 #include "GObjectEventListener.h"
29 #include <WebCore/HTMLNames.h>
30 #include <WebCore/JSMainThreadExecState.h>
31 #include <WebCore/StyledElement.h>
32 #include "WebKitDOMAttrPrivate.h"
33 #include "WebKitDOMCSSStyleDeclarationPrivate.h"
34 #include "WebKitDOMClientRectListPrivate.h"
35 #include "WebKitDOMClientRectPrivate.h"
36 #include "WebKitDOMDOMTokenListPrivate.h"
37 #include "WebKitDOMElementPrivate.h"
38 #include "WebKitDOMEventPrivate.h"
39 #include "WebKitDOMEventTarget.h"
40 #include "WebKitDOMHTMLCollectionPrivate.h"
41 #include "WebKitDOMNamedNodeMapPrivate.h"
42 #include "WebKitDOMNodeListPrivate.h"
43 #include "WebKitDOMNodePrivate.h"
44 #include "WebKitDOMPrivate.h"
45 #include "ConvertToUTF8String.h"
46 #include "WebKitDOMElementUnstable.h"
47 #include <wtf/GetPtr.h>
48 #include <wtf/RefPtr.h>
49
50 namespace WebKit {
51
52 WebKitDOMElement* kit(WebCore::Element* obj)
53 {
54     return WEBKIT_DOM_ELEMENT(kit(static_cast<WebCore::Node*>(obj)));
55 }
56
57 WebCore::Element* core(WebKitDOMElement* request)
58 {
59     return request ? static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
60 }
61
62 WebKitDOMElement* wrapElement(WebCore::Element* coreObject)
63 {
64     ASSERT(coreObject);
65     return WEBKIT_DOM_ELEMENT(g_object_new(WEBKIT_DOM_TYPE_ELEMENT, "core-object", coreObject, nullptr));
66 }
67
68 } // namespace WebKit
69
70 static gboolean webkit_dom_element_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
71 {
72     WebCore::Event* coreEvent = WebKit::core(event);
73     if (!coreEvent)
74         return false;
75     WebCore::Element* coreTarget = static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(target)->coreObject);
76
77     auto result = coreTarget->dispatchEventForBindings(*coreEvent);
78     if (result.hasException()) {
79         auto description = WebCore::DOMException::description(result.releaseException().code());
80         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
81         return false;
82     }
83     return result.releaseReturnValue();
84 }
85
86 static gboolean webkit_dom_element_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
87 {
88     WebCore::Element* coreTarget = static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(target)->coreObject);
89     return WebKit::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
90 }
91
92 static gboolean webkit_dom_element_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
93 {
94     WebCore::Element* coreTarget = static_cast<WebCore::Element*>(WEBKIT_DOM_OBJECT(target)->coreObject);
95     return WebKit::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
96 }
97
98 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
99 {
100     iface->dispatch_event = webkit_dom_element_dispatch_event;
101     iface->add_event_listener = webkit_dom_element_add_event_listener;
102     iface->remove_event_listener = webkit_dom_element_remove_event_listener;
103 }
104
105 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))
106
107 enum {
108     PROP_0,
109     PROP_TAG_NAME,
110     PROP_ATTRIBUTES,
111     PROP_STYLE,
112     PROP_ID,
113     PROP_NAMESPACE_URI,
114     PROP_PREFIX,
115     PROP_LOCAL_NAME,
116     PROP_OFFSET_LEFT,
117     PROP_OFFSET_TOP,
118     PROP_OFFSET_WIDTH,
119     PROP_OFFSET_HEIGHT,
120     PROP_CLIENT_LEFT,
121     PROP_CLIENT_TOP,
122     PROP_CLIENT_WIDTH,
123     PROP_CLIENT_HEIGHT,
124     PROP_SCROLL_LEFT,
125     PROP_SCROLL_TOP,
126     PROP_SCROLL_WIDTH,
127     PROP_SCROLL_HEIGHT,
128     PROP_OFFSET_PARENT,
129     PROP_INNER_HTML,
130     PROP_OUTER_HTML,
131     PROP_CLASS_NAME,
132     PROP_CLASS_LIST,
133     PROP_WEBKIT_REGION_OVERSET,
134     PROP_PREVIOUS_ELEMENT_SIBLING,
135     PROP_NEXT_ELEMENT_SIBLING,
136     PROP_CHILDREN,
137     PROP_FIRST_ELEMENT_CHILD,
138     PROP_LAST_ELEMENT_CHILD,
139     PROP_CHILD_ELEMENT_COUNT,
140 };
141
142 static void webkit_dom_element_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
143 {
144     WebKitDOMElement* self = WEBKIT_DOM_ELEMENT(object);
145
146     switch (propertyId) {
147     case PROP_ID:
148         webkit_dom_element_set_id(self, g_value_get_string(value));
149         break;
150     case PROP_SCROLL_LEFT:
151         webkit_dom_element_set_scroll_left(self, g_value_get_long(value));
152         break;
153     case PROP_SCROLL_TOP:
154         webkit_dom_element_set_scroll_top(self, g_value_get_long(value));
155         break;
156     case PROP_INNER_HTML:
157         webkit_dom_element_set_inner_html(self, g_value_get_string(value), nullptr);
158         break;
159     case PROP_OUTER_HTML:
160         webkit_dom_element_set_outer_html(self, g_value_get_string(value), nullptr);
161         break;
162     case PROP_CLASS_NAME:
163         webkit_dom_element_set_class_name(self, g_value_get_string(value));
164         break;
165     default:
166         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
167         break;
168     }
169 }
170
171 static void webkit_dom_element_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
172 {
173     WebKitDOMElement* self = WEBKIT_DOM_ELEMENT(object);
174
175     switch (propertyId) {
176     case PROP_TAG_NAME:
177         g_value_take_string(value, webkit_dom_element_get_tag_name(self));
178         break;
179     case PROP_ATTRIBUTES:
180         g_value_set_object(value, webkit_dom_element_get_attributes(self));
181         break;
182     case PROP_STYLE:
183         g_value_set_object(value, webkit_dom_element_get_style(self));
184         break;
185     case PROP_ID:
186         g_value_take_string(value, webkit_dom_element_get_id(self));
187         break;
188     case PROP_NAMESPACE_URI:
189         g_value_take_string(value, webkit_dom_element_get_namespace_uri(self));
190         break;
191     case PROP_PREFIX:
192         g_value_take_string(value, webkit_dom_element_get_prefix(self));
193         break;
194     case PROP_LOCAL_NAME:
195         g_value_take_string(value, webkit_dom_element_get_local_name(self));
196         break;
197     case PROP_OFFSET_LEFT:
198         g_value_set_double(value, webkit_dom_element_get_offset_left(self));
199         break;
200     case PROP_OFFSET_TOP:
201         g_value_set_double(value, webkit_dom_element_get_offset_top(self));
202         break;
203     case PROP_OFFSET_WIDTH:
204         g_value_set_double(value, webkit_dom_element_get_offset_width(self));
205         break;
206     case PROP_OFFSET_HEIGHT:
207         g_value_set_double(value, webkit_dom_element_get_offset_height(self));
208         break;
209     case PROP_CLIENT_LEFT:
210         g_value_set_double(value, webkit_dom_element_get_client_left(self));
211         break;
212     case PROP_CLIENT_TOP:
213         g_value_set_double(value, webkit_dom_element_get_client_top(self));
214         break;
215     case PROP_CLIENT_WIDTH:
216         g_value_set_double(value, webkit_dom_element_get_client_width(self));
217         break;
218     case PROP_CLIENT_HEIGHT:
219         g_value_set_double(value, webkit_dom_element_get_client_height(self));
220         break;
221     case PROP_SCROLL_LEFT:
222         g_value_set_long(value, webkit_dom_element_get_scroll_left(self));
223         break;
224     case PROP_SCROLL_TOP:
225         g_value_set_long(value, webkit_dom_element_get_scroll_top(self));
226         break;
227     case PROP_SCROLL_WIDTH:
228         g_value_set_long(value, webkit_dom_element_get_scroll_width(self));
229         break;
230     case PROP_SCROLL_HEIGHT:
231         g_value_set_long(value, webkit_dom_element_get_scroll_height(self));
232         break;
233     case PROP_OFFSET_PARENT:
234         g_value_set_object(value, webkit_dom_element_get_offset_parent(self));
235         break;
236     case PROP_INNER_HTML:
237         g_value_take_string(value, webkit_dom_element_get_inner_html(self));
238         break;
239     case PROP_OUTER_HTML:
240         g_value_take_string(value, webkit_dom_element_get_outer_html(self));
241         break;
242     case PROP_CLASS_NAME:
243         g_value_take_string(value, webkit_dom_element_get_class_name(self));
244         break;
245     case PROP_CLASS_LIST:
246         g_value_set_object(value, webkit_dom_element_get_class_list(self));
247         break;
248     case PROP_WEBKIT_REGION_OVERSET:
249         g_warning("%s: CSS Regions support has been removed, the webkit-region-overset property no longer works.", __func__);
250         g_value_set_static_string(value, nullptr);
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     /**
523      * WebKitDOMElement:webkit-region-overset:
524      *
525      * This property is always %NULL.
526      *
527      * Deprecated: 2.20
528      */
529     g_object_class_install_property(
530         gobjectClass,
531         PROP_WEBKIT_REGION_OVERSET,
532         g_param_spec_string(
533             "webkit-region-overset",
534             "Element:webkit-region-overset",
535             "read-only gchar* Element:webkit-region-overset",
536             "",
537             WEBKIT_PARAM_READABLE));
538
539     g_object_class_install_property(
540         gobjectClass,
541         PROP_PREVIOUS_ELEMENT_SIBLING,
542         g_param_spec_object(
543             "previous-element-sibling",
544             "Element:previous-element-sibling",
545             "read-only WebKitDOMElement* Element:previous-element-sibling",
546             WEBKIT_DOM_TYPE_ELEMENT,
547             WEBKIT_PARAM_READABLE));
548
549     g_object_class_install_property(
550         gobjectClass,
551         PROP_NEXT_ELEMENT_SIBLING,
552         g_param_spec_object(
553             "next-element-sibling",
554             "Element:next-element-sibling",
555             "read-only WebKitDOMElement* Element:next-element-sibling",
556             WEBKIT_DOM_TYPE_ELEMENT,
557             WEBKIT_PARAM_READABLE));
558
559     g_object_class_install_property(
560         gobjectClass,
561         PROP_CHILDREN,
562         g_param_spec_object(
563             "children",
564             "Element:children",
565             "read-only WebKitDOMHTMLCollection* Element:children",
566             WEBKIT_DOM_TYPE_HTML_COLLECTION,
567             WEBKIT_PARAM_READABLE));
568
569     g_object_class_install_property(
570         gobjectClass,
571         PROP_FIRST_ELEMENT_CHILD,
572         g_param_spec_object(
573             "first-element-child",
574             "Element:first-element-child",
575             "read-only WebKitDOMElement* Element:first-element-child",
576             WEBKIT_DOM_TYPE_ELEMENT,
577             WEBKIT_PARAM_READABLE));
578
579     g_object_class_install_property(
580         gobjectClass,
581         PROP_LAST_ELEMENT_CHILD,
582         g_param_spec_object(
583             "last-element-child",
584             "Element:last-element-child",
585             "read-only WebKitDOMElement* Element:last-element-child",
586             WEBKIT_DOM_TYPE_ELEMENT,
587             WEBKIT_PARAM_READABLE));
588
589     g_object_class_install_property(
590         gobjectClass,
591         PROP_CHILD_ELEMENT_COUNT,
592         g_param_spec_ulong(
593             "child-element-count",
594             "Element:child-element-count",
595             "read-only gulong Element:child-element-count",
596             0, G_MAXULONG, 0,
597             WEBKIT_PARAM_READABLE));
598
599 }
600
601 static void webkit_dom_element_init(WebKitDOMElement* request)
602 {
603     UNUSED_PARAM(request);
604 }
605
606 gchar* webkit_dom_element_get_attribute(WebKitDOMElement* self, const gchar* name)
607 {
608     WebCore::JSMainThreadNullState state;
609     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
610     g_return_val_if_fail(name, 0);
611     WebCore::Element* item = WebKit::core(self);
612     WTF::String convertedName = WTF::String::fromUTF8(name);
613     gchar* result = convertToUTF8String(item->getAttribute(convertedName));
614     return result;
615 }
616
617 void webkit_dom_element_set_attribute(WebKitDOMElement* self, const gchar* name, const gchar* value, GError** error)
618 {
619     WebCore::JSMainThreadNullState state;
620     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
621     g_return_if_fail(name);
622     g_return_if_fail(value);
623     g_return_if_fail(!error || !*error);
624     WebCore::Element* item = WebKit::core(self);
625     WTF::String convertedName = WTF::String::fromUTF8(name);
626     WTF::String convertedValue = WTF::String::fromUTF8(value);
627     auto result = item->setAttribute(convertedName, convertedValue);
628     if (result.hasException()) {
629         auto description = WebCore::DOMException::description(result.releaseException().code());
630         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
631     }
632 }
633
634 void webkit_dom_element_remove_attribute(WebKitDOMElement* self, const gchar* name)
635 {
636     WebCore::JSMainThreadNullState state;
637     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
638     g_return_if_fail(name);
639     WebCore::Element* item = WebKit::core(self);
640     WTF::String convertedName = WTF::String::fromUTF8(name);
641     item->removeAttribute(convertedName);
642 }
643
644 WebKitDOMAttr* webkit_dom_element_get_attribute_node(WebKitDOMElement* self, const gchar* name)
645 {
646     WebCore::JSMainThreadNullState state;
647     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
648     g_return_val_if_fail(name, 0);
649     WebCore::Element* item = WebKit::core(self);
650     WTF::String convertedName = WTF::String::fromUTF8(name);
651     RefPtr<WebCore::Attr> gobjectResult = WTF::getPtr(item->getAttributeNode(convertedName));
652     return WebKit::kit(gobjectResult.get());
653 }
654
655 WebKitDOMAttr* webkit_dom_element_set_attribute_node(WebKitDOMElement* self, WebKitDOMAttr* newAttr, GError** error)
656 {
657     WebCore::JSMainThreadNullState state;
658     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
659     g_return_val_if_fail(WEBKIT_DOM_IS_ATTR(newAttr), 0);
660     g_return_val_if_fail(!error || !*error, 0);
661     WebCore::Element* item = WebKit::core(self);
662     WebCore::Attr* convertedNewAttr = WebKit::core(newAttr);
663     auto result = item->setAttributeNode(*convertedNewAttr);
664     if (result.hasException()) {
665         auto description = WebCore::DOMException::description(result.releaseException().code());
666         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
667         return nullptr;
668     }
669     return WebKit::kit(result.releaseReturnValue().get());
670 }
671
672 WebKitDOMAttr* webkit_dom_element_remove_attribute_node(WebKitDOMElement* self, WebKitDOMAttr* oldAttr, GError** error)
673 {
674     WebCore::JSMainThreadNullState state;
675     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
676     g_return_val_if_fail(WEBKIT_DOM_IS_ATTR(oldAttr), 0);
677     g_return_val_if_fail(!error || !*error, 0);
678     WebCore::Element* item = WebKit::core(self);
679     WebCore::Attr* convertedOldAttr = WebKit::core(oldAttr);
680     auto result = item->removeAttributeNode(*convertedOldAttr);
681     if (result.hasException()) {
682         auto description = WebCore::DOMException::description(result.releaseException().code());
683         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
684         return nullptr;
685     }
686     return WebKit::kit(result.releaseReturnValue().ptr());
687 }
688
689 WebKitDOMHTMLCollection* webkit_dom_element_get_elements_by_tag_name_as_html_collection(WebKitDOMElement* self, const gchar* name)
690 {
691     WebCore::JSMainThreadNullState state;
692     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
693     g_return_val_if_fail(name, 0);
694     WebCore::Element* item = WebKit::core(self);
695     WTF::String convertedName = WTF::String::fromUTF8(name);
696     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByTagName(convertedName));
697     return WebKit::kit(gobjectResult.get());
698 }
699
700 gboolean webkit_dom_element_has_attributes(WebKitDOMElement* self)
701 {
702     WebCore::JSMainThreadNullState state;
703     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
704     WebCore::Element* item = WebKit::core(self);
705     gboolean result = item->hasAttributes();
706     return result;
707 }
708
709 gchar* webkit_dom_element_get_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
710 {
711     WebCore::JSMainThreadNullState state;
712     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
713     g_return_val_if_fail(namespaceURI, 0);
714     g_return_val_if_fail(localName, 0);
715     WebCore::Element* item = WebKit::core(self);
716     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
717     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
718     gchar* result = convertToUTF8String(item->getAttributeNS(convertedNamespaceURI, convertedLocalName));
719     return result;
720 }
721
722 void webkit_dom_element_set_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* qualifiedName, const gchar* value, GError** error)
723 {
724     WebCore::JSMainThreadNullState state;
725     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
726     g_return_if_fail(qualifiedName);
727     g_return_if_fail(value);
728     g_return_if_fail(!error || !*error);
729     WebCore::Element* item = WebKit::core(self);
730     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
731     WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
732     WTF::String convertedValue = WTF::String::fromUTF8(value);
733     auto result = item->setAttributeNS(convertedNamespaceURI, convertedQualifiedName, convertedValue);
734     if (result.hasException()) {
735         auto description = WebCore::DOMException::description(result.releaseException().code());
736         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
737     }
738 }
739
740 void webkit_dom_element_remove_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
741 {
742     WebCore::JSMainThreadNullState state;
743     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
744     g_return_if_fail(namespaceURI);
745     g_return_if_fail(localName);
746     WebCore::Element* item = WebKit::core(self);
747     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
748     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
749     item->removeAttributeNS(convertedNamespaceURI, convertedLocalName);
750 }
751
752 WebKitDOMHTMLCollection* webkit_dom_element_get_elements_by_tag_name_ns_as_html_collection(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
753 {
754     WebCore::JSMainThreadNullState state;
755     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
756     g_return_val_if_fail(namespaceURI, 0);
757     g_return_val_if_fail(localName, 0);
758     WebCore::Element* item = WebKit::core(self);
759     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
760     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
761     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByTagNameNS(convertedNamespaceURI, convertedLocalName));
762     return WebKit::kit(gobjectResult.get());
763 }
764
765 WebKitDOMAttr* webkit_dom_element_get_attribute_node_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
766 {
767     WebCore::JSMainThreadNullState state;
768     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
769     g_return_val_if_fail(namespaceURI, 0);
770     g_return_val_if_fail(localName, 0);
771     WebCore::Element* item = WebKit::core(self);
772     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
773     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
774     RefPtr<WebCore::Attr> gobjectResult = WTF::getPtr(item->getAttributeNodeNS(convertedNamespaceURI, convertedLocalName));
775     return WebKit::kit(gobjectResult.get());
776 }
777
778 WebKitDOMAttr* webkit_dom_element_set_attribute_node_ns(WebKitDOMElement* self, WebKitDOMAttr* newAttr, GError** error)
779 {
780     WebCore::JSMainThreadNullState state;
781     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
782     g_return_val_if_fail(WEBKIT_DOM_IS_ATTR(newAttr), 0);
783     g_return_val_if_fail(!error || !*error, 0);
784     WebCore::Element* item = WebKit::core(self);
785     WebCore::Attr* convertedNewAttr = WebKit::core(newAttr);
786     auto result = item->setAttributeNodeNS(*convertedNewAttr);
787     if (result.hasException()) {
788         auto description = WebCore::DOMException::description(result.releaseException().code());
789         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
790         return nullptr;
791     }
792     return WebKit::kit(result.releaseReturnValue().get());
793 }
794
795 gboolean webkit_dom_element_has_attribute(WebKitDOMElement* self, const gchar* name)
796 {
797     WebCore::JSMainThreadNullState state;
798     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
799     g_return_val_if_fail(name, FALSE);
800     WebCore::Element* item = WebKit::core(self);
801     WTF::String convertedName = WTF::String::fromUTF8(name);
802     gboolean result = item->hasAttribute(convertedName);
803     return result;
804 }
805
806 gboolean webkit_dom_element_has_attribute_ns(WebKitDOMElement* self, const gchar* namespaceURI, const gchar* localName)
807 {
808     WebCore::JSMainThreadNullState state;
809     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
810     g_return_val_if_fail(namespaceURI, FALSE);
811     g_return_val_if_fail(localName, FALSE);
812     WebCore::Element* item = WebKit::core(self);
813     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
814     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
815     gboolean result = item->hasAttributeNS(convertedNamespaceURI, convertedLocalName);
816     return result;
817 }
818
819 void webkit_dom_element_focus(WebKitDOMElement* self)
820 {
821     WebCore::JSMainThreadNullState state;
822     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
823     WebCore::Element* item = WebKit::core(self);
824     item->focus();
825 }
826
827 void webkit_dom_element_blur(WebKitDOMElement* self)
828 {
829     WebCore::JSMainThreadNullState state;
830     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
831     WebCore::Element* item = WebKit::core(self);
832     item->blur();
833 }
834
835 void webkit_dom_element_scroll_into_view(WebKitDOMElement* self, gboolean alignWithTop)
836 {
837     WebCore::JSMainThreadNullState state;
838     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
839     WebCore::Element* item = WebKit::core(self);
840     item->scrollIntoView(alignWithTop);
841 }
842
843 void webkit_dom_element_scroll_into_view_if_needed(WebKitDOMElement* self, gboolean centerIfNeeded)
844 {
845     WebCore::JSMainThreadNullState state;
846     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
847     WebCore::Element* item = WebKit::core(self);
848     item->scrollIntoViewIfNeeded(centerIfNeeded);
849 }
850
851 void webkit_dom_element_scroll_by_lines(WebKitDOMElement* self, glong lines)
852 {
853     WebCore::JSMainThreadNullState state;
854     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
855     WebCore::Element* item = WebKit::core(self);
856     item->scrollByLines(lines);
857 }
858
859 void webkit_dom_element_scroll_by_pages(WebKitDOMElement* self, glong pages)
860 {
861     WebCore::JSMainThreadNullState state;
862     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
863     WebCore::Element* item = WebKit::core(self);
864     item->scrollByPages(pages);
865 }
866
867 WebKitDOMHTMLCollection* webkit_dom_element_get_elements_by_class_name_as_html_collection(WebKitDOMElement* self, const gchar* name)
868 {
869     WebCore::JSMainThreadNullState state;
870     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
871     g_return_val_if_fail(name, 0);
872     WebCore::Element* item = WebKit::core(self);
873     WTF::String convertedName = WTF::String::fromUTF8(name);
874     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByClassName(convertedName));
875     return WebKit::kit(gobjectResult.get());
876 }
877
878 gboolean webkit_dom_element_matches(WebKitDOMElement* self, const gchar* selectors, GError** error)
879 {
880     WebCore::JSMainThreadNullState state;
881     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), FALSE);
882     g_return_val_if_fail(selectors, FALSE);
883     g_return_val_if_fail(!error || !*error, FALSE);
884     WebCore::Element* item = WebKit::core(self);
885     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
886     auto result = item->matches(convertedSelectors);
887     if (result.hasException()) {
888         auto description = WebCore::DOMException::description(result.releaseException().code());
889         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
890         return false;
891     }
892     return result.releaseReturnValue();
893 }
894
895 WebKitDOMElement* webkit_dom_element_closest(WebKitDOMElement* self, const gchar* selectors, GError** error)
896 {
897     WebCore::JSMainThreadNullState state;
898     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
899     g_return_val_if_fail(selectors, 0);
900     g_return_val_if_fail(!error || !*error, 0);
901     WebCore::Element* item = WebKit::core(self);
902     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
903     auto result = item->closest(convertedSelectors);
904     if (result.hasException()) {
905         auto description = WebCore::DOMException::description(result.releaseException().code());
906         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
907         return nullptr;
908     }
909     return WebKit::kit(result.releaseReturnValue());
910 }
911
912 gboolean webkit_dom_element_webkit_matches_selector(WebKitDOMElement* self, const gchar* selectors, GError** error)
913 {
914     return webkit_dom_element_matches(self, selectors, error);
915 }
916
917 void webkit_dom_element_webkit_request_fullscreen(WebKitDOMElement* self)
918 {
919     WebCore::JSMainThreadNullState state;
920     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
921     WebCore::Element* item = WebKit::core(self);
922     item->webkitRequestFullscreen();
923 }
924
925 WebKitDOMElement* webkit_dom_element_insert_adjacent_element(WebKitDOMElement* self, const gchar* where, WebKitDOMElement* element, GError** error)
926 {
927     WebCore::JSMainThreadNullState state;
928     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
929     g_return_val_if_fail(where, 0);
930     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(element), 0);
931     g_return_val_if_fail(!error || !*error, 0);
932     WebCore::Element* item = WebKit::core(self);
933     WTF::String convertedWhere = WTF::String::fromUTF8(where);
934     WebCore::Element* convertedElement = WebKit::core(element);
935     auto result = item->insertAdjacentElement(convertedWhere, *convertedElement);
936     if (result.hasException()) {
937         auto description = WebCore::DOMException::description(result.releaseException().code());
938         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
939         return nullptr;
940     }
941     return WebKit::kit(result.releaseReturnValue());
942 }
943
944 void webkit_dom_element_insert_adjacent_html(WebKitDOMElement* self, const gchar* where, const gchar* html, GError** error)
945 {
946     WebCore::JSMainThreadNullState state;
947     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
948     g_return_if_fail(where);
949     g_return_if_fail(html);
950     g_return_if_fail(!error || !*error);
951     WebCore::Element* item = WebKit::core(self);
952     WTF::String convertedWhere = WTF::String::fromUTF8(where);
953     WTF::String convertedHtml = WTF::String::fromUTF8(html);
954     auto result = item->insertAdjacentHTML(convertedWhere, convertedHtml);
955     if (result.hasException()) {
956         auto description = WebCore::DOMException::description(result.releaseException().code());
957         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
958     }
959 }
960
961 void webkit_dom_element_insert_adjacent_text(WebKitDOMElement* self, const gchar* where, const gchar* text, GError** error)
962 {
963     WebCore::JSMainThreadNullState state;
964     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
965     g_return_if_fail(where);
966     g_return_if_fail(text);
967     g_return_if_fail(!error || !*error);
968     WebCore::Element* item = WebKit::core(self);
969     WTF::String convertedWhere = WTF::String::fromUTF8(where);
970     WTF::String convertedText = WTF::String::fromUTF8(text);
971     auto result = item->insertAdjacentText(convertedWhere, convertedText);
972     if (result.hasException()) {
973         auto description = WebCore::DOMException::description(result.releaseException().code());
974         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
975     }
976 }
977
978 void webkit_dom_element_request_pointer_lock(WebKitDOMElement* self)
979 {
980 #if ENABLE(POINTER_LOCK)
981     WebCore::JSMainThreadNullState state;
982     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
983     WebCore::Element* item = WebKit::core(self);
984     item->requestPointerLock();
985 #else
986     UNUSED_PARAM(self);
987     WEBKIT_WARN_FEATURE_NOT_PRESENT("Pointer Lock")
988 #endif /* ENABLE(POINTER_LOCK) */
989 }
990
991 void webkit_dom_element_remove(WebKitDOMElement* self, GError** error)
992 {
993     WebCore::JSMainThreadNullState state;
994     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
995     g_return_if_fail(!error || !*error);
996     WebCore::Element* item = WebKit::core(self);
997     auto result = item->remove();
998     if (result.hasException()) {
999         auto description = WebCore::DOMException::description(result.releaseException().code());
1000         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1001     }
1002 }
1003
1004 WebKitDOMElement* webkit_dom_element_query_selector(WebKitDOMElement* self, const gchar* selectors, GError** error)
1005 {
1006     WebCore::JSMainThreadNullState state;
1007     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1008     g_return_val_if_fail(selectors, 0);
1009     g_return_val_if_fail(!error || !*error, 0);
1010     WebCore::Element* item = WebKit::core(self);
1011     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
1012     auto result = item->querySelector(convertedSelectors);
1013     if (result.hasException()) {
1014         auto description = WebCore::DOMException::description(result.releaseException().code());
1015         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1016         return nullptr;
1017     }
1018     return WebKit::kit(result.releaseReturnValue());
1019 }
1020
1021 WebKitDOMNodeList* webkit_dom_element_query_selector_all(WebKitDOMElement* self, const gchar* selectors, GError** error)
1022 {
1023     WebCore::JSMainThreadNullState state;
1024     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1025     g_return_val_if_fail(selectors, 0);
1026     g_return_val_if_fail(!error || !*error, 0);
1027     WebCore::Element* item = WebKit::core(self);
1028     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
1029     auto result = item->querySelectorAll(convertedSelectors);
1030     if (result.hasException()) {
1031         auto description = WebCore::DOMException::description(result.releaseException().code());
1032         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1033         return nullptr;
1034     }
1035     return WebKit::kit(result.releaseReturnValue().ptr());
1036 }
1037
1038 gchar* webkit_dom_element_get_tag_name(WebKitDOMElement* self)
1039 {
1040     WebCore::JSMainThreadNullState state;
1041     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1042     WebCore::Element* item = WebKit::core(self);
1043     gchar* result = convertToUTF8String(item->tagName());
1044     return result;
1045 }
1046
1047 WebKitDOMNamedNodeMap* webkit_dom_element_get_attributes(WebKitDOMElement* self)
1048 {
1049     WebCore::JSMainThreadNullState state;
1050     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1051     WebCore::Element* item = WebKit::core(self);
1052     RefPtr<WebCore::NamedNodeMap> gobjectResult = WTF::getPtr(item->attributes());
1053     return WebKit::kit(gobjectResult.get());
1054 }
1055
1056 WebKitDOMCSSStyleDeclaration* webkit_dom_element_get_style(WebKitDOMElement* self)
1057 {
1058     WebCore::JSMainThreadNullState state;
1059     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1060     auto& item = *WebKit::core(self);
1061     if (!is<WebCore::StyledElement>(item))
1062         return nullptr;
1063     return WebKit::kit(&downcast<WebCore::StyledElement>(item).cssomStyle());
1064 }
1065
1066 gchar* webkit_dom_element_get_id(WebKitDOMElement* self)
1067 {
1068     WebCore::JSMainThreadNullState state;
1069     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1070     WebCore::Element* item = WebKit::core(self);
1071     gchar* result = convertToUTF8String(item->getIdAttribute());
1072     return result;
1073 }
1074
1075 void webkit_dom_element_set_id(WebKitDOMElement* self, const gchar* value)
1076 {
1077     WebCore::JSMainThreadNullState state;
1078     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1079     g_return_if_fail(value);
1080     WebCore::Element* item = WebKit::core(self);
1081     WTF::String convertedValue = WTF::String::fromUTF8(value);
1082     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::idAttr, convertedValue);
1083 }
1084
1085 gchar* webkit_dom_element_get_namespace_uri(WebKitDOMElement* self)
1086 {
1087     WebCore::JSMainThreadNullState state;
1088     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1089     WebCore::Element* item = WebKit::core(self);
1090     gchar* result = convertToUTF8String(item->namespaceURI());
1091     return result;
1092 }
1093
1094 gchar* webkit_dom_element_get_prefix(WebKitDOMElement* self)
1095 {
1096     WebCore::JSMainThreadNullState state;
1097     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1098     WebCore::Element* item = WebKit::core(self);
1099     gchar* result = convertToUTF8String(item->prefix());
1100     return result;
1101 }
1102
1103 gchar* webkit_dom_element_get_local_name(WebKitDOMElement* self)
1104 {
1105     WebCore::JSMainThreadNullState state;
1106     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1107     WebCore::Element* item = WebKit::core(self);
1108     gchar* result = convertToUTF8String(item->localName());
1109     return result;
1110 }
1111
1112 gdouble webkit_dom_element_get_offset_left(WebKitDOMElement* self)
1113 {
1114     WebCore::JSMainThreadNullState state;
1115     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1116     WebCore::Element* item = WebKit::core(self);
1117     gdouble result = item->offsetLeft();
1118     return result;
1119 }
1120
1121 gdouble webkit_dom_element_get_offset_top(WebKitDOMElement* self)
1122 {
1123     WebCore::JSMainThreadNullState state;
1124     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1125     WebCore::Element* item = WebKit::core(self);
1126     gdouble result = item->offsetTop();
1127     return result;
1128 }
1129
1130 gdouble webkit_dom_element_get_offset_width(WebKitDOMElement* self)
1131 {
1132     WebCore::JSMainThreadNullState state;
1133     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1134     WebCore::Element* item = WebKit::core(self);
1135     gdouble result = item->offsetWidth();
1136     return result;
1137 }
1138
1139 gdouble webkit_dom_element_get_offset_height(WebKitDOMElement* self)
1140 {
1141     WebCore::JSMainThreadNullState state;
1142     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1143     WebCore::Element* item = WebKit::core(self);
1144     gdouble result = item->offsetHeight();
1145     return result;
1146 }
1147
1148 gdouble webkit_dom_element_get_client_left(WebKitDOMElement* self)
1149 {
1150     WebCore::JSMainThreadNullState state;
1151     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1152     WebCore::Element* item = WebKit::core(self);
1153     gdouble result = item->clientLeft();
1154     return result;
1155 }
1156
1157 gdouble webkit_dom_element_get_client_top(WebKitDOMElement* self)
1158 {
1159     WebCore::JSMainThreadNullState state;
1160     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1161     WebCore::Element* item = WebKit::core(self);
1162     gdouble result = item->clientTop();
1163     return result;
1164 }
1165
1166 gdouble webkit_dom_element_get_client_width(WebKitDOMElement* self)
1167 {
1168     WebCore::JSMainThreadNullState state;
1169     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1170     WebCore::Element* item = WebKit::core(self);
1171     gdouble result = item->clientWidth();
1172     return result;
1173 }
1174
1175 gdouble webkit_dom_element_get_client_height(WebKitDOMElement* self)
1176 {
1177     WebCore::JSMainThreadNullState state;
1178     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1179     WebCore::Element* item = WebKit::core(self);
1180     gdouble result = item->clientHeight();
1181     return result;
1182 }
1183
1184 glong webkit_dom_element_get_scroll_left(WebKitDOMElement* self)
1185 {
1186     WebCore::JSMainThreadNullState state;
1187     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1188     WebCore::Element* item = WebKit::core(self);
1189     glong result = item->scrollLeft();
1190     return result;
1191 }
1192
1193 void webkit_dom_element_set_scroll_left(WebKitDOMElement* self, glong value)
1194 {
1195     WebCore::JSMainThreadNullState state;
1196     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1197     WebCore::Element* item = WebKit::core(self);
1198     item->setScrollLeft(value);
1199 }
1200
1201 glong webkit_dom_element_get_scroll_top(WebKitDOMElement* self)
1202 {
1203     WebCore::JSMainThreadNullState state;
1204     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1205     WebCore::Element* item = WebKit::core(self);
1206     glong result = item->scrollTop();
1207     return result;
1208 }
1209
1210 void webkit_dom_element_set_scroll_top(WebKitDOMElement* self, glong value)
1211 {
1212     WebCore::JSMainThreadNullState state;
1213     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1214     WebCore::Element* item = WebKit::core(self);
1215     item->setScrollTop(value);
1216 }
1217
1218 glong webkit_dom_element_get_scroll_width(WebKitDOMElement* self)
1219 {
1220     WebCore::JSMainThreadNullState state;
1221     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1222     WebCore::Element* item = WebKit::core(self);
1223     glong result = item->scrollWidth();
1224     return result;
1225 }
1226
1227 glong webkit_dom_element_get_scroll_height(WebKitDOMElement* self)
1228 {
1229     WebCore::JSMainThreadNullState state;
1230     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1231     WebCore::Element* item = WebKit::core(self);
1232     glong result = item->scrollHeight();
1233     return result;
1234 }
1235
1236 WebKitDOMClientRect* webkit_dom_element_get_bounding_client_rect(WebKitDOMElement* self)
1237 {
1238     WebCore::JSMainThreadNullState state;
1239     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), nullptr);
1240     WebCore::Element* item = WebKit::core(self);
1241     return WebKit::kit(item->getBoundingClientRect().ptr());
1242 }
1243
1244 WebKitDOMClientRectList* webkit_dom_element_get_client_rects(WebKitDOMElement* self)
1245 {
1246     WebCore::JSMainThreadNullState state;
1247     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), nullptr);
1248     WebCore::Element* item = WebKit::core(self);
1249     return WebKit::kit(item->getClientRects().ptr());
1250 }
1251
1252 WebKitDOMElement* webkit_dom_element_get_offset_parent(WebKitDOMElement* self)
1253 {
1254     WebCore::JSMainThreadNullState state;
1255     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1256     WebCore::Element* item = WebKit::core(self);
1257     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->bindingsOffsetParent());
1258     return WebKit::kit(gobjectResult.get());
1259 }
1260
1261 gchar* webkit_dom_element_get_inner_html(WebKitDOMElement* self)
1262 {
1263     WebCore::JSMainThreadNullState state;
1264     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1265     WebCore::Element* item = WebKit::core(self);
1266     gchar* result = convertToUTF8String(item->innerHTML());
1267     return result;
1268 }
1269
1270 void webkit_dom_element_set_inner_html(WebKitDOMElement* self, const gchar* value, GError** error)
1271 {
1272     WebCore::JSMainThreadNullState state;
1273     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1274     g_return_if_fail(value);
1275     g_return_if_fail(!error || !*error);
1276     WebCore::Element* item = WebKit::core(self);
1277     WTF::String convertedValue = WTF::String::fromUTF8(value);
1278     auto result = item->setInnerHTML(convertedValue);
1279     if (result.hasException()) {
1280         auto description = WebCore::DOMException::description(result.releaseException().code());
1281         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1282     }
1283 }
1284
1285 gchar* webkit_dom_element_get_outer_html(WebKitDOMElement* self)
1286 {
1287     WebCore::JSMainThreadNullState state;
1288     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1289     WebCore::Element* item = WebKit::core(self);
1290     gchar* result = convertToUTF8String(item->outerHTML());
1291     return result;
1292 }
1293
1294 void webkit_dom_element_set_outer_html(WebKitDOMElement* self, const gchar* value, GError** error)
1295 {
1296     WebCore::JSMainThreadNullState state;
1297     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1298     g_return_if_fail(value);
1299     g_return_if_fail(!error || !*error);
1300     WebCore::Element* item = WebKit::core(self);
1301     WTF::String convertedValue = WTF::String::fromUTF8(value);
1302     auto result = item->setOuterHTML(convertedValue);
1303     if (result.hasException()) {
1304         auto description = WebCore::DOMException::description(result.releaseException().code());
1305         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1306     }
1307 }
1308
1309 gchar* webkit_dom_element_get_class_name(WebKitDOMElement* self)
1310 {
1311     WebCore::JSMainThreadNullState state;
1312     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1313     WebCore::Element* item = WebKit::core(self);
1314     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::classAttr));
1315     return result;
1316 }
1317
1318 void webkit_dom_element_set_class_name(WebKitDOMElement* self, const gchar* value)
1319 {
1320     WebCore::JSMainThreadNullState state;
1321     g_return_if_fail(WEBKIT_DOM_IS_ELEMENT(self));
1322     g_return_if_fail(value);
1323     WebCore::Element* item = WebKit::core(self);
1324     WTF::String convertedValue = WTF::String::fromUTF8(value);
1325     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::classAttr, convertedValue);
1326 }
1327
1328 WebKitDOMDOMTokenList* webkit_dom_element_get_class_list(WebKitDOMElement* self)
1329 {
1330     WebCore::JSMainThreadNullState state;
1331     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1332     WebCore::Element* item = WebKit::core(self);
1333     RefPtr<WebCore::DOMTokenList> gobjectResult = WTF::getPtr(item->classList());
1334     return WebKit::kit(gobjectResult.get());
1335 }
1336
1337 WebKitDOMElement* webkit_dom_element_get_previous_element_sibling(WebKitDOMElement* self)
1338 {
1339     WebCore::JSMainThreadNullState state;
1340     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1341     WebCore::Element* item = WebKit::core(self);
1342     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->previousElementSibling());
1343     return WebKit::kit(gobjectResult.get());
1344 }
1345
1346 WebKitDOMElement* webkit_dom_element_get_next_element_sibling(WebKitDOMElement* self)
1347 {
1348     WebCore::JSMainThreadNullState state;
1349     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1350     WebCore::Element* item = WebKit::core(self);
1351     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->nextElementSibling());
1352     return WebKit::kit(gobjectResult.get());
1353 }
1354
1355 WebKitDOMHTMLCollection* webkit_dom_element_get_children(WebKitDOMElement* self)
1356 {
1357     WebCore::JSMainThreadNullState state;
1358     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1359     WebCore::Element* item = WebKit::core(self);
1360     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->children());
1361     return WebKit::kit(gobjectResult.get());
1362 }
1363
1364 WebKitDOMElement* webkit_dom_element_get_first_element_child(WebKitDOMElement* self)
1365 {
1366     WebCore::JSMainThreadNullState state;
1367     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1368     WebCore::Element* item = WebKit::core(self);
1369     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->firstElementChild());
1370     return WebKit::kit(gobjectResult.get());
1371 }
1372
1373 WebKitDOMElement* webkit_dom_element_get_last_element_child(WebKitDOMElement* self)
1374 {
1375     WebCore::JSMainThreadNullState state;
1376     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1377     WebCore::Element* item = WebKit::core(self);
1378     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->lastElementChild());
1379     return WebKit::kit(gobjectResult.get());
1380 }
1381
1382 gulong webkit_dom_element_get_child_element_count(WebKitDOMElement* self)
1383 {
1384     WebCore::JSMainThreadNullState state;
1385     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(self), 0);
1386     WebCore::Element* item = WebKit::core(self);
1387     gulong result = item->childElementCount();
1388     return result;
1389 }
1390