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