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