Drop ExceptionCodeDescription class
[WebKit-https.git] / Source / WebKit / WebProcess / InjectedBundle / API / gtk / DOM / WebKitDOMDocument.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 "WebKitDOMDocument.h"
22
23 #include "ConvertToUTF8String.h"
24 #include "DOMObjectCache.h"
25 #include "GObjectEventListener.h"
26 #include "WebKitDOMAttrPrivate.h"
27 #include "WebKitDOMCDATASectionPrivate.h"
28 #include "WebKitDOMCSSStyleDeclarationPrivate.h"
29 #include "WebKitDOMCommentPrivate.h"
30 #include "WebKitDOMDOMImplementationPrivate.h"
31 #include "WebKitDOMDOMWindowPrivate.h"
32 #include "WebKitDOMDocumentFragmentPrivate.h"
33 #include "WebKitDOMDocumentPrivate.h"
34 #include "WebKitDOMDocumentTypePrivate.h"
35 #include "WebKitDOMDocumentUnstable.h"
36 #include "WebKitDOMElementPrivate.h"
37 #include "WebKitDOMEventPrivate.h"
38 #include "WebKitDOMEventTarget.h"
39 #include "WebKitDOMHTMLCollectionPrivate.h"
40 #include "WebKitDOMHTMLElementPrivate.h"
41 #include "WebKitDOMHTMLHeadElementPrivate.h"
42 #include "WebKitDOMHTMLScriptElementPrivate.h"
43 #include "WebKitDOMNodeFilterPrivate.h"
44 #include "WebKitDOMNodeIteratorPrivate.h"
45 #include "WebKitDOMNodeListPrivate.h"
46 #include "WebKitDOMNodePrivate.h"
47 #include "WebKitDOMPrivate.h"
48 #include "WebKitDOMProcessingInstructionPrivate.h"
49 #include "WebKitDOMRangePrivate.h"
50 #include "WebKitDOMStyleSheetListPrivate.h"
51 #include "WebKitDOMTextPrivate.h"
52 #include "WebKitDOMTreeWalkerPrivate.h"
53 #include "WebKitDOMXPathExpressionPrivate.h"
54 #include "WebKitDOMXPathNSResolverPrivate.h"
55 #include "WebKitDOMXPathResultPrivate.h"
56 #include <WebCore/CSSImportRule.h>
57 #include <WebCore/DOMException.h>
58 #include <WebCore/Document.h>
59 #include <WebCore/JSMainThreadExecState.h>
60 #include <wtf/GetPtr.h>
61 #include <wtf/RefPtr.h>
62
63 namespace WebKit {
64
65 WebKitDOMDocument* kit(WebCore::Document* obj)
66 {
67     return WEBKIT_DOM_DOCUMENT(kit(static_cast<WebCore::Node*>(obj)));
68 }
69
70 WebCore::Document* core(WebKitDOMDocument* request)
71 {
72     return request ? static_cast<WebCore::Document*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
73 }
74
75 WebKitDOMDocument* wrapDocument(WebCore::Document* coreObject)
76 {
77     ASSERT(coreObject);
78     return WEBKIT_DOM_DOCUMENT(g_object_new(WEBKIT_DOM_TYPE_DOCUMENT, "core-object", coreObject, nullptr));
79 }
80
81 } // namespace WebKit
82
83 static gboolean webkit_dom_document_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
84 {
85     WebCore::Event* coreEvent = WebKit::core(event);
86     if (!coreEvent)
87         return false;
88     WebCore::Document* coreTarget = static_cast<WebCore::Document*>(WEBKIT_DOM_OBJECT(target)->coreObject);
89
90     auto result = coreTarget->dispatchEventForBindings(*coreEvent);
91     if (result.hasException()) {
92         auto description = WebCore::DOMException::description(result.releaseException().code());
93         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
94         return false;
95     }
96     return result.releaseReturnValue();
97 }
98
99 static gboolean webkit_dom_document_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
100 {
101     WebCore::Document* coreTarget = static_cast<WebCore::Document*>(WEBKIT_DOM_OBJECT(target)->coreObject);
102     return WebKit::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
103 }
104
105 static gboolean webkit_dom_document_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
106 {
107     WebCore::Document* coreTarget = static_cast<WebCore::Document*>(WEBKIT_DOM_OBJECT(target)->coreObject);
108     return WebKit::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
109 }
110
111 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
112 {
113     iface->dispatch_event = webkit_dom_document_dispatch_event;
114     iface->add_event_listener = webkit_dom_document_add_event_listener;
115     iface->remove_event_listener = webkit_dom_document_remove_event_listener;
116 }
117
118 G_DEFINE_TYPE_WITH_CODE(WebKitDOMDocument, webkit_dom_document, WEBKIT_DOM_TYPE_NODE, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkit_dom_event_target_init))
119
120 enum {
121     PROP_0,
122     PROP_DOCTYPE,
123     PROP_IMPLEMENTATION,
124     PROP_DOCUMENT_ELEMENT,
125     PROP_INPUT_ENCODING,
126     PROP_XML_ENCODING,
127     PROP_XML_VERSION,
128     PROP_XML_STANDALONE,
129     PROP_DOCUMENT_URI,
130     PROP_DEFAULT_VIEW,
131     PROP_STYLE_SHEETS,
132     PROP_CONTENT_TYPE,
133     PROP_TITLE,
134     PROP_DIR,
135     PROP_DESIGN_MODE,
136     PROP_REFERRER,
137     PROP_DOMAIN,
138     PROP_URL,
139     PROP_COOKIE,
140     PROP_BODY,
141     PROP_HEAD,
142     PROP_IMAGES,
143     PROP_APPLETS,
144     PROP_LINKS,
145     PROP_FORMS,
146     PROP_ANCHORS,
147     PROP_EMBEDS,
148     PROP_PLUGINS,
149     PROP_SCRIPTS,
150     PROP_LAST_MODIFIED,
151     PROP_CHARSET,
152     PROP_READY_STATE,
153     PROP_CHARACTER_SET,
154     PROP_PREFERRED_STYLESHEET_SET,
155     PROP_SELECTED_STYLESHEET_SET,
156     PROP_ACTIVE_ELEMENT,
157     PROP_COMPAT_MODE,
158     PROP_WEBKIT_IS_FULL_SCREEN,
159     PROP_WEBKIT_FULL_SCREEN_KEYBOARD_INPUT_ALLOWED,
160     PROP_WEBKIT_CURRENT_FULL_SCREEN_ELEMENT,
161     PROP_WEBKIT_FULLSCREEN_ENABLED,
162     PROP_WEBKIT_FULLSCREEN_ELEMENT,
163     PROP_POINTER_LOCK_ELEMENT,
164     PROP_VISIBILITY_STATE,
165     PROP_HIDDEN,
166     PROP_CURRENT_SCRIPT,
167     PROP_ORIGIN,
168     PROP_SCROLLING_ELEMENT,
169     PROP_CHILDREN,
170     PROP_FIRST_ELEMENT_CHILD,
171     PROP_LAST_ELEMENT_CHILD,
172     PROP_CHILD_ELEMENT_COUNT,
173 };
174
175 static void webkit_dom_document_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
176 {
177     WebKitDOMDocument* self = WEBKIT_DOM_DOCUMENT(object);
178
179     switch (propertyId) {
180     case PROP_XML_VERSION:
181         webkit_dom_document_set_xml_version(self, g_value_get_string(value), nullptr);
182         break;
183     case PROP_XML_STANDALONE:
184         webkit_dom_document_set_xml_standalone(self, g_value_get_boolean(value), nullptr);
185         break;
186     case PROP_DOCUMENT_URI:
187         webkit_dom_document_set_document_uri(self, g_value_get_string(value));
188         break;
189     case PROP_TITLE:
190         webkit_dom_document_set_title(self, g_value_get_string(value));
191         break;
192     case PROP_DIR:
193         webkit_dom_document_set_dir(self, g_value_get_string(value));
194         break;
195     case PROP_DESIGN_MODE:
196         webkit_dom_document_set_design_mode(self, g_value_get_string(value));
197         break;
198     case PROP_COOKIE:
199         webkit_dom_document_set_cookie(self, g_value_get_string(value), nullptr);
200         break;
201     case PROP_CHARSET:
202         webkit_dom_document_set_charset(self, g_value_get_string(value));
203         break;
204     case PROP_SELECTED_STYLESHEET_SET:
205         webkit_dom_document_set_selected_stylesheet_set(self, g_value_get_string(value));
206         break;
207     default:
208         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
209         break;
210     }
211 }
212
213 static void webkit_dom_document_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
214 {
215     WebKitDOMDocument* self = WEBKIT_DOM_DOCUMENT(object);
216
217     switch (propertyId) {
218     case PROP_DOCTYPE:
219         g_value_set_object(value, webkit_dom_document_get_doctype(self));
220         break;
221     case PROP_IMPLEMENTATION:
222         g_value_set_object(value, webkit_dom_document_get_implementation(self));
223         break;
224     case PROP_DOCUMENT_ELEMENT:
225         g_value_set_object(value, webkit_dom_document_get_document_element(self));
226         break;
227     case PROP_INPUT_ENCODING:
228         g_value_take_string(value, webkit_dom_document_get_input_encoding(self));
229         break;
230     case PROP_XML_ENCODING:
231         g_value_take_string(value, webkit_dom_document_get_xml_encoding(self));
232         break;
233     case PROP_XML_VERSION:
234         g_value_take_string(value, webkit_dom_document_get_xml_version(self));
235         break;
236     case PROP_XML_STANDALONE:
237         g_value_set_boolean(value, webkit_dom_document_get_xml_standalone(self));
238         break;
239     case PROP_DOCUMENT_URI:
240         g_value_take_string(value, webkit_dom_document_get_document_uri(self));
241         break;
242     case PROP_DEFAULT_VIEW:
243         g_value_set_object(value, webkit_dom_document_get_default_view(self));
244         break;
245     case PROP_STYLE_SHEETS:
246         g_value_set_object(value, webkit_dom_document_get_style_sheets(self));
247         break;
248     case PROP_CONTENT_TYPE:
249         g_value_take_string(value, webkit_dom_document_get_content_type(self));
250         break;
251     case PROP_TITLE:
252         g_value_take_string(value, webkit_dom_document_get_title(self));
253         break;
254     case PROP_DIR:
255         g_value_take_string(value, webkit_dom_document_get_dir(self));
256         break;
257     case PROP_DESIGN_MODE:
258         g_value_take_string(value, webkit_dom_document_get_design_mode(self));
259         break;
260     case PROP_REFERRER:
261         g_value_take_string(value, webkit_dom_document_get_referrer(self));
262         break;
263     case PROP_DOMAIN:
264         g_value_take_string(value, webkit_dom_document_get_domain(self));
265         break;
266     case PROP_URL:
267         g_value_take_string(value, webkit_dom_document_get_url(self));
268         break;
269     case PROP_COOKIE:
270         g_value_take_string(value, webkit_dom_document_get_cookie(self, nullptr));
271         break;
272     case PROP_BODY:
273         g_value_set_object(value, webkit_dom_document_get_body(self));
274         break;
275     case PROP_HEAD:
276         g_value_set_object(value, webkit_dom_document_get_head(self));
277         break;
278     case PROP_IMAGES:
279         g_value_set_object(value, webkit_dom_document_get_images(self));
280         break;
281     case PROP_APPLETS:
282         g_value_set_object(value, webkit_dom_document_get_applets(self));
283         break;
284     case PROP_LINKS:
285         g_value_set_object(value, webkit_dom_document_get_links(self));
286         break;
287     case PROP_FORMS:
288         g_value_set_object(value, webkit_dom_document_get_forms(self));
289         break;
290     case PROP_ANCHORS:
291         g_value_set_object(value, webkit_dom_document_get_anchors(self));
292         break;
293     case PROP_EMBEDS:
294         g_value_set_object(value, webkit_dom_document_get_embeds(self));
295         break;
296     case PROP_PLUGINS:
297         g_value_set_object(value, webkit_dom_document_get_plugins(self));
298         break;
299     case PROP_SCRIPTS:
300         g_value_set_object(value, webkit_dom_document_get_scripts(self));
301         break;
302     case PROP_LAST_MODIFIED:
303         g_value_take_string(value, webkit_dom_document_get_last_modified(self));
304         break;
305     case PROP_CHARSET:
306         g_value_take_string(value, webkit_dom_document_get_charset(self));
307         break;
308     case PROP_READY_STATE:
309         g_value_take_string(value, webkit_dom_document_get_ready_state(self));
310         break;
311     case PROP_CHARACTER_SET:
312         g_value_take_string(value, webkit_dom_document_get_character_set(self));
313         break;
314     case PROP_PREFERRED_STYLESHEET_SET:
315         g_value_take_string(value, webkit_dom_document_get_preferred_stylesheet_set(self));
316         break;
317     case PROP_SELECTED_STYLESHEET_SET:
318         g_value_take_string(value, webkit_dom_document_get_selected_stylesheet_set(self));
319         break;
320     case PROP_ACTIVE_ELEMENT:
321         g_value_set_object(value, webkit_dom_document_get_active_element(self));
322         break;
323     case PROP_COMPAT_MODE:
324         g_value_take_string(value, webkit_dom_document_get_compat_mode(self));
325         break;
326     case PROP_WEBKIT_IS_FULL_SCREEN:
327         g_value_set_boolean(value, webkit_dom_document_get_webkit_is_fullscreen(self));
328         break;
329     case PROP_WEBKIT_FULL_SCREEN_KEYBOARD_INPUT_ALLOWED:
330         g_value_set_boolean(value, webkit_dom_document_get_webkit_fullscreen_keyboard_input_allowed(self));
331         break;
332     case PROP_WEBKIT_CURRENT_FULL_SCREEN_ELEMENT:
333         g_value_set_object(value, webkit_dom_document_get_webkit_current_fullscreen_element(self));
334         break;
335     case PROP_WEBKIT_FULLSCREEN_ENABLED:
336         g_value_set_boolean(value, webkit_dom_document_get_webkit_fullscreen_enabled(self));
337         break;
338     case PROP_WEBKIT_FULLSCREEN_ELEMENT:
339         g_value_set_object(value, webkit_dom_document_get_webkit_fullscreen_element(self));
340         break;
341     case PROP_POINTER_LOCK_ELEMENT:
342         g_value_set_object(value, webkit_dom_document_get_pointer_lock_element(self));
343         break;
344     case PROP_VISIBILITY_STATE:
345         g_value_take_string(value, webkit_dom_document_get_visibility_state(self));
346         break;
347     case PROP_HIDDEN:
348         g_value_set_boolean(value, webkit_dom_document_get_hidden(self));
349         break;
350     case PROP_CURRENT_SCRIPT:
351         g_value_set_object(value, webkit_dom_document_get_current_script(self));
352         break;
353     case PROP_ORIGIN:
354         g_value_take_string(value, webkit_dom_document_get_origin(self));
355         break;
356     case PROP_SCROLLING_ELEMENT:
357         g_value_set_object(value, webkit_dom_document_get_scrolling_element(self));
358         break;
359     case PROP_CHILDREN:
360         g_value_set_object(value, webkit_dom_document_get_children(self));
361         break;
362     case PROP_FIRST_ELEMENT_CHILD:
363         g_value_set_object(value, webkit_dom_document_get_first_element_child(self));
364         break;
365     case PROP_LAST_ELEMENT_CHILD:
366         g_value_set_object(value, webkit_dom_document_get_last_element_child(self));
367         break;
368     case PROP_CHILD_ELEMENT_COUNT:
369         g_value_set_ulong(value, webkit_dom_document_get_child_element_count(self));
370         break;
371     default:
372         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
373         break;
374     }
375 }
376
377 static void webkit_dom_document_class_init(WebKitDOMDocumentClass* requestClass)
378 {
379     GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
380     gobjectClass->set_property = webkit_dom_document_set_property;
381     gobjectClass->get_property = webkit_dom_document_get_property;
382
383     g_object_class_install_property(
384         gobjectClass,
385         PROP_DOCTYPE,
386         g_param_spec_object(
387             "doctype",
388             "Document:doctype",
389             "read-only WebKitDOMDocumentType* Document:doctype",
390             WEBKIT_DOM_TYPE_DOCUMENT_TYPE,
391             WEBKIT_PARAM_READABLE));
392
393     g_object_class_install_property(
394         gobjectClass,
395         PROP_IMPLEMENTATION,
396         g_param_spec_object(
397             "implementation",
398             "Document:implementation",
399             "read-only WebKitDOMDOMImplementation* Document:implementation",
400             WEBKIT_DOM_TYPE_DOM_IMPLEMENTATION,
401             WEBKIT_PARAM_READABLE));
402
403     g_object_class_install_property(
404         gobjectClass,
405         PROP_DOCUMENT_ELEMENT,
406         g_param_spec_object(
407             "document-element",
408             "Document:document-element",
409             "read-only WebKitDOMElement* Document:document-element",
410             WEBKIT_DOM_TYPE_ELEMENT,
411             WEBKIT_PARAM_READABLE));
412
413     g_object_class_install_property(
414         gobjectClass,
415         PROP_INPUT_ENCODING,
416         g_param_spec_string(
417             "input-encoding",
418             "Document:input-encoding",
419             "read-only gchar* Document:input-encoding",
420             "",
421             WEBKIT_PARAM_READABLE));
422
423     g_object_class_install_property(
424         gobjectClass,
425         PROP_XML_ENCODING,
426         g_param_spec_string(
427             "xml-encoding",
428             "Document:xml-encoding",
429             "read-only gchar* Document:xml-encoding",
430             "",
431             WEBKIT_PARAM_READABLE));
432
433     g_object_class_install_property(
434         gobjectClass,
435         PROP_XML_VERSION,
436         g_param_spec_string(
437             "xml-version",
438             "Document:xml-version",
439             "read-write gchar* Document:xml-version",
440             "",
441             WEBKIT_PARAM_READWRITE));
442
443     g_object_class_install_property(
444         gobjectClass,
445         PROP_XML_STANDALONE,
446         g_param_spec_boolean(
447             "xml-standalone",
448             "Document:xml-standalone",
449             "read-write gboolean Document:xml-standalone",
450             FALSE,
451             WEBKIT_PARAM_READWRITE));
452
453     g_object_class_install_property(
454         gobjectClass,
455         PROP_DOCUMENT_URI,
456         g_param_spec_string(
457             "document-uri",
458             "Document:document-uri",
459             "read-write gchar* Document:document-uri",
460             "",
461             WEBKIT_PARAM_READWRITE));
462
463     g_object_class_install_property(
464         gobjectClass,
465         PROP_DEFAULT_VIEW,
466         g_param_spec_object(
467             "default-view",
468             "Document:default-view",
469             "read-only WebKitDOMDOMWindow* Document:default-view",
470             WEBKIT_DOM_TYPE_DOM_WINDOW,
471             WEBKIT_PARAM_READABLE));
472
473     g_object_class_install_property(
474         gobjectClass,
475         PROP_STYLE_SHEETS,
476         g_param_spec_object(
477             "style-sheets",
478             "Document:style-sheets",
479             "read-only WebKitDOMStyleSheetList* Document:style-sheets",
480             WEBKIT_DOM_TYPE_STYLE_SHEET_LIST,
481             WEBKIT_PARAM_READABLE));
482
483     g_object_class_install_property(
484         gobjectClass,
485         PROP_CONTENT_TYPE,
486         g_param_spec_string(
487             "content-type",
488             "Document:content-type",
489             "read-only gchar* Document:content-type",
490             "",
491             WEBKIT_PARAM_READABLE));
492
493     g_object_class_install_property(
494         gobjectClass,
495         PROP_TITLE,
496         g_param_spec_string(
497             "title",
498             "Document:title",
499             "read-write gchar* Document:title",
500             "",
501             WEBKIT_PARAM_READWRITE));
502
503     g_object_class_install_property(
504         gobjectClass,
505         PROP_DIR,
506         g_param_spec_string(
507             "dir",
508             "Document:dir",
509             "read-write gchar* Document:dir",
510             "",
511             WEBKIT_PARAM_READWRITE));
512
513     g_object_class_install_property(
514         gobjectClass,
515         PROP_DESIGN_MODE,
516         g_param_spec_string(
517             "design-mode",
518             "Document:design-mode",
519             "read-write gchar* Document:design-mode",
520             "",
521             WEBKIT_PARAM_READWRITE));
522
523     g_object_class_install_property(
524         gobjectClass,
525         PROP_REFERRER,
526         g_param_spec_string(
527             "referrer",
528             "Document:referrer",
529             "read-only gchar* Document:referrer",
530             "",
531             WEBKIT_PARAM_READABLE));
532
533     g_object_class_install_property(
534         gobjectClass,
535         PROP_DOMAIN,
536         g_param_spec_string(
537             "domain",
538             "Document:domain",
539             "read-only gchar* Document:domain",
540             "",
541             WEBKIT_PARAM_READABLE));
542
543     g_object_class_install_property(
544         gobjectClass,
545         PROP_URL,
546         g_param_spec_string(
547             "url",
548             "Document:url",
549             "read-only gchar* Document:url",
550             "",
551             WEBKIT_PARAM_READABLE));
552
553     g_object_class_install_property(
554         gobjectClass,
555         PROP_COOKIE,
556         g_param_spec_string(
557             "cookie",
558             "Document:cookie",
559             "read-write gchar* Document:cookie",
560             "",
561             WEBKIT_PARAM_READWRITE));
562
563     g_object_class_install_property(
564         gobjectClass,
565         PROP_BODY,
566         g_param_spec_object(
567             "body",
568             "Document:body",
569             "read-only WebKitDOMHTMLElement* Document:body",
570             WEBKIT_DOM_TYPE_HTML_ELEMENT,
571             WEBKIT_PARAM_READABLE));
572
573     g_object_class_install_property(
574         gobjectClass,
575         PROP_HEAD,
576         g_param_spec_object(
577             "head",
578             "Document:head",
579             "read-only WebKitDOMHTMLHeadElement* Document:head",
580             WEBKIT_DOM_TYPE_HTML_HEAD_ELEMENT,
581             WEBKIT_PARAM_READABLE));
582
583     g_object_class_install_property(
584         gobjectClass,
585         PROP_IMAGES,
586         g_param_spec_object(
587             "images",
588             "Document:images",
589             "read-only WebKitDOMHTMLCollection* Document:images",
590             WEBKIT_DOM_TYPE_HTML_COLLECTION,
591             WEBKIT_PARAM_READABLE));
592
593     g_object_class_install_property(
594         gobjectClass,
595         PROP_APPLETS,
596         g_param_spec_object(
597             "applets",
598             "Document:applets",
599             "read-only WebKitDOMHTMLCollection* Document:applets",
600             WEBKIT_DOM_TYPE_HTML_COLLECTION,
601             WEBKIT_PARAM_READABLE));
602
603     g_object_class_install_property(
604         gobjectClass,
605         PROP_LINKS,
606         g_param_spec_object(
607             "links",
608             "Document:links",
609             "read-only WebKitDOMHTMLCollection* Document:links",
610             WEBKIT_DOM_TYPE_HTML_COLLECTION,
611             WEBKIT_PARAM_READABLE));
612
613     g_object_class_install_property(
614         gobjectClass,
615         PROP_FORMS,
616         g_param_spec_object(
617             "forms",
618             "Document:forms",
619             "read-only WebKitDOMHTMLCollection* Document:forms",
620             WEBKIT_DOM_TYPE_HTML_COLLECTION,
621             WEBKIT_PARAM_READABLE));
622
623     g_object_class_install_property(
624         gobjectClass,
625         PROP_ANCHORS,
626         g_param_spec_object(
627             "anchors",
628             "Document:anchors",
629             "read-only WebKitDOMHTMLCollection* Document:anchors",
630             WEBKIT_DOM_TYPE_HTML_COLLECTION,
631             WEBKIT_PARAM_READABLE));
632
633     g_object_class_install_property(
634         gobjectClass,
635         PROP_EMBEDS,
636         g_param_spec_object(
637             "embeds",
638             "Document:embeds",
639             "read-only WebKitDOMHTMLCollection* Document:embeds",
640             WEBKIT_DOM_TYPE_HTML_COLLECTION,
641             WEBKIT_PARAM_READABLE));
642
643     g_object_class_install_property(
644         gobjectClass,
645         PROP_PLUGINS,
646         g_param_spec_object(
647             "plugins",
648             "Document:plugins",
649             "read-only WebKitDOMHTMLCollection* Document:plugins",
650             WEBKIT_DOM_TYPE_HTML_COLLECTION,
651             WEBKIT_PARAM_READABLE));
652
653     g_object_class_install_property(
654         gobjectClass,
655         PROP_SCRIPTS,
656         g_param_spec_object(
657             "scripts",
658             "Document:scripts",
659             "read-only WebKitDOMHTMLCollection* Document:scripts",
660             WEBKIT_DOM_TYPE_HTML_COLLECTION,
661             WEBKIT_PARAM_READABLE));
662
663     g_object_class_install_property(
664         gobjectClass,
665         PROP_LAST_MODIFIED,
666         g_param_spec_string(
667             "last-modified",
668             "Document:last-modified",
669             "read-only gchar* Document:last-modified",
670             "",
671             WEBKIT_PARAM_READABLE));
672
673     g_object_class_install_property(
674         gobjectClass,
675         PROP_CHARSET,
676         g_param_spec_string(
677             "charset",
678             "Document:charset",
679             "read-write gchar* Document:charset",
680             "",
681             WEBKIT_PARAM_READWRITE));
682
683     g_object_class_install_property(
684         gobjectClass,
685         PROP_READY_STATE,
686         g_param_spec_string(
687             "ready-state",
688             "Document:ready-state",
689             "read-only gchar* Document:ready-state",
690             "",
691             WEBKIT_PARAM_READABLE));
692
693     g_object_class_install_property(
694         gobjectClass,
695         PROP_CHARACTER_SET,
696         g_param_spec_string(
697             "character-set",
698             "Document:character-set",
699             "read-only gchar* Document:character-set",
700             "",
701             WEBKIT_PARAM_READABLE));
702
703     g_object_class_install_property(
704         gobjectClass,
705         PROP_PREFERRED_STYLESHEET_SET,
706         g_param_spec_string(
707             "preferred-stylesheet-set",
708             "Document:preferred-stylesheet-set",
709             "read-only gchar* Document:preferred-stylesheet-set",
710             "",
711             WEBKIT_PARAM_READABLE));
712
713     g_object_class_install_property(
714         gobjectClass,
715         PROP_SELECTED_STYLESHEET_SET,
716         g_param_spec_string(
717             "selected-stylesheet-set",
718             "Document:selected-stylesheet-set",
719             "read-write gchar* Document:selected-stylesheet-set",
720             "",
721             WEBKIT_PARAM_READWRITE));
722
723     g_object_class_install_property(
724         gobjectClass,
725         PROP_ACTIVE_ELEMENT,
726         g_param_spec_object(
727             "active-element",
728             "Document:active-element",
729             "read-only WebKitDOMElement* Document:active-element",
730             WEBKIT_DOM_TYPE_ELEMENT,
731             WEBKIT_PARAM_READABLE));
732
733     g_object_class_install_property(
734         gobjectClass,
735         PROP_COMPAT_MODE,
736         g_param_spec_string(
737             "compat-mode",
738             "Document:compat-mode",
739             "read-only gchar* Document:compat-mode",
740             "",
741             WEBKIT_PARAM_READABLE));
742
743     g_object_class_install_property(
744         gobjectClass,
745         PROP_WEBKIT_IS_FULL_SCREEN,
746         g_param_spec_boolean(
747             "webkit-is-full-screen",
748             "Document:webkit-is-full-screen",
749             "read-only gboolean Document:webkit-is-full-screen",
750             FALSE,
751             WEBKIT_PARAM_READABLE));
752
753     g_object_class_install_property(
754         gobjectClass,
755         PROP_WEBKIT_FULL_SCREEN_KEYBOARD_INPUT_ALLOWED,
756         g_param_spec_boolean(
757             "webkit-full-screen-keyboard-input-allowed",
758             "Document:webkit-full-screen-keyboard-input-allowed",
759             "read-only gboolean Document:webkit-full-screen-keyboard-input-allowed",
760             FALSE,
761             WEBKIT_PARAM_READABLE));
762
763     g_object_class_install_property(
764         gobjectClass,
765         PROP_WEBKIT_CURRENT_FULL_SCREEN_ELEMENT,
766         g_param_spec_object(
767             "webkit-current-full-screen-element",
768             "Document:webkit-current-full-screen-element",
769             "read-only WebKitDOMElement* Document:webkit-current-full-screen-element",
770             WEBKIT_DOM_TYPE_ELEMENT,
771             WEBKIT_PARAM_READABLE));
772
773     g_object_class_install_property(
774         gobjectClass,
775         PROP_WEBKIT_FULLSCREEN_ENABLED,
776         g_param_spec_boolean(
777             "webkit-fullscreen-enabled",
778             "Document:webkit-fullscreen-enabled",
779             "read-only gboolean Document:webkit-fullscreen-enabled",
780             FALSE,
781             WEBKIT_PARAM_READABLE));
782
783     g_object_class_install_property(
784         gobjectClass,
785         PROP_WEBKIT_FULLSCREEN_ELEMENT,
786         g_param_spec_object(
787             "webkit-fullscreen-element",
788             "Document:webkit-fullscreen-element",
789             "read-only WebKitDOMElement* Document:webkit-fullscreen-element",
790             WEBKIT_DOM_TYPE_ELEMENT,
791             WEBKIT_PARAM_READABLE));
792
793     g_object_class_install_property(
794         gobjectClass,
795         PROP_POINTER_LOCK_ELEMENT,
796         g_param_spec_object(
797             "pointer-lock-element",
798             "Document:pointer-lock-element",
799             "read-only WebKitDOMElement* Document:pointer-lock-element",
800             WEBKIT_DOM_TYPE_ELEMENT,
801             WEBKIT_PARAM_READABLE));
802
803     g_object_class_install_property(
804         gobjectClass,
805         PROP_VISIBILITY_STATE,
806         g_param_spec_string(
807             "visibility-state",
808             "Document:visibility-state",
809             "read-only gchar* Document:visibility-state",
810             "",
811             WEBKIT_PARAM_READABLE));
812
813     g_object_class_install_property(
814         gobjectClass,
815         PROP_HIDDEN,
816         g_param_spec_boolean(
817             "hidden",
818             "Document:hidden",
819             "read-only gboolean Document:hidden",
820             FALSE,
821             WEBKIT_PARAM_READABLE));
822
823     g_object_class_install_property(
824         gobjectClass,
825         PROP_CURRENT_SCRIPT,
826         g_param_spec_object(
827             "current-script",
828             "Document:current-script",
829             "read-only WebKitDOMHTMLScriptElement* Document:current-script",
830             WEBKIT_DOM_TYPE_HTML_SCRIPT_ELEMENT,
831             WEBKIT_PARAM_READABLE));
832
833     g_object_class_install_property(
834         gobjectClass,
835         PROP_ORIGIN,
836         g_param_spec_string(
837             "origin",
838             "Document:origin",
839             "read-only gchar* Document:origin",
840             "",
841             WEBKIT_PARAM_READABLE));
842
843     g_object_class_install_property(
844         gobjectClass,
845         PROP_SCROLLING_ELEMENT,
846         g_param_spec_object(
847             "scrolling-element",
848             "Document:scrolling-element",
849             "read-only WebKitDOMElement* Document:scrolling-element",
850             WEBKIT_DOM_TYPE_ELEMENT,
851             WEBKIT_PARAM_READABLE));
852
853     g_object_class_install_property(
854         gobjectClass,
855         PROP_CHILDREN,
856         g_param_spec_object(
857             "children",
858             "Document:children",
859             "read-only WebKitDOMHTMLCollection* Document:children",
860             WEBKIT_DOM_TYPE_HTML_COLLECTION,
861             WEBKIT_PARAM_READABLE));
862
863     g_object_class_install_property(
864         gobjectClass,
865         PROP_FIRST_ELEMENT_CHILD,
866         g_param_spec_object(
867             "first-element-child",
868             "Document:first-element-child",
869             "read-only WebKitDOMElement* Document:first-element-child",
870             WEBKIT_DOM_TYPE_ELEMENT,
871             WEBKIT_PARAM_READABLE));
872
873     g_object_class_install_property(
874         gobjectClass,
875         PROP_LAST_ELEMENT_CHILD,
876         g_param_spec_object(
877             "last-element-child",
878             "Document:last-element-child",
879             "read-only WebKitDOMElement* Document:last-element-child",
880             WEBKIT_DOM_TYPE_ELEMENT,
881             WEBKIT_PARAM_READABLE));
882
883     g_object_class_install_property(
884         gobjectClass,
885         PROP_CHILD_ELEMENT_COUNT,
886         g_param_spec_ulong(
887             "child-element-count",
888             "Document:child-element-count",
889             "read-only gulong Document:child-element-count",
890             0, G_MAXULONG, 0,
891             WEBKIT_PARAM_READABLE));
892
893 }
894
895 static void webkit_dom_document_init(WebKitDOMDocument* request)
896 {
897     UNUSED_PARAM(request);
898 }
899
900 WebKitDOMElement* webkit_dom_document_create_element(WebKitDOMDocument* self, const gchar* tagName, GError** error)
901 {
902     WebCore::JSMainThreadNullState state;
903     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
904     g_return_val_if_fail(tagName, 0);
905     g_return_val_if_fail(!error || !*error, 0);
906     WebCore::Document* item = WebKit::core(self);
907     WTF::String convertedTagName = WTF::String::fromUTF8(tagName);
908     auto result = item->createElementForBindings(convertedTagName);
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().ptr());
915 }
916
917 WebKitDOMDocumentFragment* webkit_dom_document_create_document_fragment(WebKitDOMDocument* self)
918 {
919     WebCore::JSMainThreadNullState state;
920     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
921     WebCore::Document* item = WebKit::core(self);
922     RefPtr<WebCore::DocumentFragment> gobjectResult = WTF::getPtr(item->createDocumentFragment());
923     return WebKit::kit(gobjectResult.get());
924 }
925
926 WebKitDOMText* webkit_dom_document_create_text_node(WebKitDOMDocument* self, const gchar* data)
927 {
928     WebCore::JSMainThreadNullState state;
929     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
930     g_return_val_if_fail(data, 0);
931     WebCore::Document* item = WebKit::core(self);
932     WTF::String convertedData = WTF::String::fromUTF8(data);
933     RefPtr<WebCore::Text> gobjectResult = WTF::getPtr(item->createTextNode(convertedData));
934     return WebKit::kit(gobjectResult.get());
935 }
936
937 WebKitDOMComment* webkit_dom_document_create_comment(WebKitDOMDocument* self, const gchar* data)
938 {
939     WebCore::JSMainThreadNullState state;
940     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
941     g_return_val_if_fail(data, 0);
942     WebCore::Document* item = WebKit::core(self);
943     WTF::String convertedData = WTF::String::fromUTF8(data);
944     RefPtr<WebCore::Comment> gobjectResult = WTF::getPtr(item->createComment(convertedData));
945     return WebKit::kit(gobjectResult.get());
946 }
947
948 WebKitDOMCDATASection* webkit_dom_document_create_cdata_section(WebKitDOMDocument* self, const gchar* data, GError** error)
949 {
950     WebCore::JSMainThreadNullState state;
951     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
952     g_return_val_if_fail(data, 0);
953     g_return_val_if_fail(!error || !*error, 0);
954     WebCore::Document* item = WebKit::core(self);
955     WTF::String convertedData = WTF::String::fromUTF8(data);
956     auto result = item->createCDATASection(convertedData);
957     if (result.hasException()) {
958         auto description = WebCore::DOMException::description(result.releaseException().code());
959         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
960         return nullptr;
961     }
962     return WebKit::kit(result.releaseReturnValue().ptr());
963 }
964
965 WebKitDOMProcessingInstruction* webkit_dom_document_create_processing_instruction(WebKitDOMDocument* self, const gchar* target, const gchar* data, GError** error)
966 {
967     WebCore::JSMainThreadNullState state;
968     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
969     g_return_val_if_fail(target, 0);
970     g_return_val_if_fail(data, 0);
971     g_return_val_if_fail(!error || !*error, 0);
972     WebCore::Document* item = WebKit::core(self);
973     WTF::String convertedTarget = WTF::String::fromUTF8(target);
974     WTF::String convertedData = WTF::String::fromUTF8(data);
975     auto result = item->createProcessingInstruction(convertedTarget, convertedData);
976     if (result.hasException()) {
977         auto description = WebCore::DOMException::description(result.releaseException().code());
978         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
979         return nullptr;
980     }
981     return WebKit::kit(result.releaseReturnValue().ptr());
982 }
983
984 WebKitDOMAttr* webkit_dom_document_create_attribute(WebKitDOMDocument* self, const gchar* name, GError** error)
985 {
986     WebCore::JSMainThreadNullState state;
987     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
988     g_return_val_if_fail(name, 0);
989     g_return_val_if_fail(!error || !*error, 0);
990     WebCore::Document* item = WebKit::core(self);
991     WTF::String convertedName = WTF::String::fromUTF8(name);
992     auto result = item->createAttribute(convertedName);
993     if (result.hasException()) {
994         auto description = WebCore::DOMException::description(result.releaseException().code());
995         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
996         return nullptr;
997     }
998     return WebKit::kit(result.releaseReturnValue().ptr());
999 }
1000
1001 WebKitDOMHTMLCollection* webkit_dom_document_get_elements_by_tag_name_as_html_collection(WebKitDOMDocument* self, const gchar* tagname)
1002 {
1003     WebCore::JSMainThreadNullState state;
1004     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1005     g_return_val_if_fail(tagname, 0);
1006     WebCore::Document* item = WebKit::core(self);
1007     WTF::String convertedTagname = WTF::String::fromUTF8(tagname);
1008     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByTagName(convertedTagname));
1009     return WebKit::kit(gobjectResult.get());
1010 }
1011
1012 WebKitDOMNode* webkit_dom_document_import_node(WebKitDOMDocument* self, WebKitDOMNode* importedNode, gboolean deep, GError** error)
1013 {
1014     WebCore::JSMainThreadNullState state;
1015     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1016     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(importedNode), 0);
1017     g_return_val_if_fail(!error || !*error, 0);
1018     WebCore::Document* item = WebKit::core(self);
1019     WebCore::Node* convertedImportedNode = WebKit::core(importedNode);
1020     auto result = item->importNode(*convertedImportedNode, deep);
1021     if (result.hasException()) {
1022         auto description = WebCore::DOMException::description(result.releaseException().code());
1023         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1024         return nullptr;
1025     }
1026     return WebKit::kit(result.releaseReturnValue().ptr());
1027 }
1028
1029 WebKitDOMElement* webkit_dom_document_create_element_ns(WebKitDOMDocument* self, const gchar* namespaceURI, const gchar* qualifiedName, GError** error)
1030 {
1031     WebCore::JSMainThreadNullState state;
1032     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1033     g_return_val_if_fail(qualifiedName, 0);
1034     g_return_val_if_fail(!error || !*error, 0);
1035     WebCore::Document* item = WebKit::core(self);
1036     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
1037     WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
1038     auto result = item->createElementNS(convertedNamespaceURI, convertedQualifiedName);
1039     if (result.hasException()) {
1040         auto description = WebCore::DOMException::description(result.releaseException().code());
1041         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1042         return nullptr;
1043     }
1044     return WebKit::kit(result.releaseReturnValue().ptr());
1045 }
1046
1047 WebKitDOMAttr* webkit_dom_document_create_attribute_ns(WebKitDOMDocument* self, const gchar* namespaceURI, const gchar* qualifiedName, GError** error)
1048 {
1049     WebCore::JSMainThreadNullState state;
1050     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1051     g_return_val_if_fail(qualifiedName, 0);
1052     g_return_val_if_fail(!error || !*error, 0);
1053     WebCore::Document* item = WebKit::core(self);
1054     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
1055     WTF::String convertedQualifiedName = WTF::String::fromUTF8(qualifiedName);
1056     auto result = item->createAttributeNS(convertedNamespaceURI, convertedQualifiedName);
1057     if (result.hasException()) {
1058         auto description = WebCore::DOMException::description(result.releaseException().code());
1059         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1060         return nullptr;
1061     }
1062     return WebKit::kit(result.releaseReturnValue().ptr());
1063 }
1064
1065 WebKitDOMHTMLCollection* webkit_dom_document_get_elements_by_tag_name_ns_as_html_collection(WebKitDOMDocument* self, const gchar* namespaceURI, const gchar* localName)
1066 {
1067     WebCore::JSMainThreadNullState state;
1068     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1069     g_return_val_if_fail(namespaceURI, 0);
1070     g_return_val_if_fail(localName, 0);
1071     WebCore::Document* item = WebKit::core(self);
1072     WTF::String convertedNamespaceURI = WTF::String::fromUTF8(namespaceURI);
1073     WTF::String convertedLocalName = WTF::String::fromUTF8(localName);
1074     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByTagNameNS(convertedNamespaceURI, convertedLocalName));
1075     return WebKit::kit(gobjectResult.get());
1076 }
1077
1078 WebKitDOMNode* webkit_dom_document_adopt_node(WebKitDOMDocument* self, WebKitDOMNode* source, GError** error)
1079 {
1080     WebCore::JSMainThreadNullState state;
1081     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1082     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(source), 0);
1083     g_return_val_if_fail(!error || !*error, 0);
1084     WebCore::Document* item = WebKit::core(self);
1085     WebCore::Node* convertedSource = WebKit::core(source);
1086     auto result = item->adoptNode(*convertedSource);
1087     if (result.hasException()) {
1088         auto description = WebCore::DOMException::description(result.releaseException().code());
1089         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1090         return nullptr;
1091     }
1092     return WebKit::kit(result.releaseReturnValue().ptr());
1093 }
1094
1095 WebKitDOMEvent* webkit_dom_document_create_event(WebKitDOMDocument* self, const gchar* eventType, GError** error)
1096 {
1097     WebCore::JSMainThreadNullState state;
1098     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1099     g_return_val_if_fail(eventType, 0);
1100     g_return_val_if_fail(!error || !*error, 0);
1101     WebCore::Document* item = WebKit::core(self);
1102     WTF::String convertedEventType = WTF::String::fromUTF8(eventType);
1103     auto result = item->createEvent(convertedEventType);
1104     if (result.hasException()) {
1105         auto description = WebCore::DOMException::description(result.releaseException().code());
1106         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1107         return nullptr;
1108     }
1109     return WebKit::kit(result.releaseReturnValue().ptr());
1110 }
1111
1112 WebKitDOMRange* webkit_dom_document_create_range(WebKitDOMDocument* self)
1113 {
1114     WebCore::JSMainThreadNullState state;
1115     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1116     WebCore::Document* item = WebKit::core(self);
1117     RefPtr<WebCore::Range> gobjectResult = WTF::getPtr(item->createRange());
1118     return WebKit::kit(gobjectResult.get());
1119 }
1120
1121 WebKitDOMNodeIterator* webkit_dom_document_create_node_iterator(WebKitDOMDocument* self, WebKitDOMNode* root, gulong whatToShow, WebKitDOMNodeFilter* filter, gboolean expandEntityReferences, GError** error)
1122 {
1123     WebCore::JSMainThreadNullState state;
1124     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1125     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(root), 0);
1126     g_return_val_if_fail(!filter || WEBKIT_DOM_IS_NODE_FILTER(filter), 0);
1127     UNUSED_PARAM(error);
1128     WebCore::Document* item = WebKit::core(self);
1129     WebCore::Node* convertedRoot = WebKit::core(root);
1130     RefPtr<WebCore::NodeFilter> convertedFilter = WebKit::core(filter);
1131     RefPtr<WebCore::NodeIterator> gobjectResult = WTF::getPtr(item->createNodeIterator(*convertedRoot, whatToShow, WTF::getPtr(convertedFilter), expandEntityReferences));
1132     return WebKit::kit(gobjectResult.get());
1133 }
1134
1135 WebKitDOMTreeWalker* webkit_dom_document_create_tree_walker(WebKitDOMDocument* self, WebKitDOMNode* root, gulong whatToShow, WebKitDOMNodeFilter* filter, gboolean expandEntityReferences, GError** error)
1136 {
1137     WebCore::JSMainThreadNullState state;
1138     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1139     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(root), 0);
1140     g_return_val_if_fail(!filter || WEBKIT_DOM_IS_NODE_FILTER(filter), 0);
1141     UNUSED_PARAM(error);
1142     WebCore::Document* item = WebKit::core(self);
1143     WebCore::Node* convertedRoot = WebKit::core(root);
1144     RefPtr<WebCore::NodeFilter> convertedFilter = WebKit::core(filter);
1145     RefPtr<WebCore::TreeWalker> gobjectResult = WTF::getPtr(item->createTreeWalker(*convertedRoot, whatToShow, WTF::getPtr(convertedFilter), expandEntityReferences));
1146     return WebKit::kit(gobjectResult.get());
1147 }
1148
1149 WebKitDOMCSSStyleDeclaration* webkit_dom_document_get_override_style(WebKitDOMDocument* self, WebKitDOMElement* element, const gchar* pseudoElement)
1150 {
1151     WebCore::JSMainThreadNullState state;
1152     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1153     g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(element), 0);
1154     WebCore::Document* item = WebKit::core(self);
1155     WebCore::Element* convertedElement = WebKit::core(element);
1156     WTF::String convertedPseudoElement = WTF::String::fromUTF8(pseudoElement);
1157     RefPtr<WebCore::CSSStyleDeclaration> gobjectResult = WTF::getPtr(item->getOverrideStyle(convertedElement, convertedPseudoElement));
1158     return WebKit::kit(gobjectResult.get());
1159 }
1160
1161 WebKitDOMXPathExpression* webkit_dom_document_create_expression(WebKitDOMDocument* self, const gchar* expression, WebKitDOMXPathNSResolver* resolver, GError** error)
1162 {
1163     WebCore::JSMainThreadNullState state;
1164     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1165     g_return_val_if_fail(expression, 0);
1166     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver), 0);
1167     g_return_val_if_fail(!error || !*error, 0);
1168     WebCore::Document* item = WebKit::core(self);
1169     WTF::String convertedExpression = WTF::String::fromUTF8(expression);
1170     RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
1171     auto result = item->createExpression(convertedExpression, WTFMove(convertedResolver));
1172     if (result.hasException()) {
1173         auto description = WebCore::DOMException::description(result.releaseException().code());
1174         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1175         return nullptr;
1176     }
1177     return WebKit::kit(result.releaseReturnValue().ptr());
1178 }
1179
1180 WebKitDOMXPathNSResolver* webkit_dom_document_create_ns_resolver(WebKitDOMDocument* self, WebKitDOMNode* nodeResolver)
1181 {
1182     WebCore::JSMainThreadNullState state;
1183     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1184     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(nodeResolver), 0);
1185     WebCore::Document* item = WebKit::core(self);
1186     WebCore::Node* convertedNodeResolver = WebKit::core(nodeResolver);
1187     RefPtr<WebCore::XPathNSResolver> gobjectResult = WTF::getPtr(item->createNSResolver(convertedNodeResolver));
1188     return WebKit::kit(gobjectResult.get());
1189 }
1190
1191 WebKitDOMXPathResult* webkit_dom_document_evaluate(WebKitDOMDocument* self, const gchar* expression, WebKitDOMNode* contextNode, WebKitDOMXPathNSResolver* resolver, gushort type, WebKitDOMXPathResult* inResult, GError** error)
1192 {
1193     WebCore::JSMainThreadNullState state;
1194     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1195     g_return_val_if_fail(expression, 0);
1196     g_return_val_if_fail(WEBKIT_DOM_IS_NODE(contextNode), 0);
1197     g_return_val_if_fail(!resolver || WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver), 0);
1198     g_return_val_if_fail(!inResult || WEBKIT_DOM_IS_XPATH_RESULT(inResult), 0);
1199     g_return_val_if_fail(!error || !*error, 0);
1200     WebCore::Document* item = WebKit::core(self);
1201     WTF::String convertedExpression = WTF::String::fromUTF8(expression);
1202     WebCore::Node* convertedContextNode = WebKit::core(contextNode);
1203     RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
1204     WebCore::XPathResult* convertedInResult = WebKit::core(inResult);
1205     auto result = item->evaluate(convertedExpression, convertedContextNode, WTFMove(convertedResolver), type, convertedInResult);
1206     if (result.hasException()) {
1207         auto description = WebCore::DOMException::description(result.releaseException().code());
1208         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1209         return nullptr;
1210     }
1211     return WebKit::kit(result.releaseReturnValue().ptr());
1212 }
1213
1214 gboolean webkit_dom_document_exec_command(WebKitDOMDocument* self, const gchar* command, gboolean userInterface, const gchar* value)
1215 {
1216     WebCore::JSMainThreadNullState state;
1217     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1218     g_return_val_if_fail(command, FALSE);
1219     g_return_val_if_fail(value, FALSE);
1220     WebCore::Document* item = WebKit::core(self);
1221     WTF::String convertedCommand = WTF::String::fromUTF8(command);
1222     WTF::String convertedValue = WTF::String::fromUTF8(value);
1223     gboolean result = item->execCommand(convertedCommand, userInterface, convertedValue);
1224     return result;
1225 }
1226
1227 gboolean webkit_dom_document_query_command_enabled(WebKitDOMDocument* self, const gchar* command)
1228 {
1229     WebCore::JSMainThreadNullState state;
1230     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1231     g_return_val_if_fail(command, FALSE);
1232     WebCore::Document* item = WebKit::core(self);
1233     WTF::String convertedCommand = WTF::String::fromUTF8(command);
1234     gboolean result = item->queryCommandEnabled(convertedCommand);
1235     return result;
1236 }
1237
1238 gboolean webkit_dom_document_query_command_indeterm(WebKitDOMDocument* self, const gchar* command)
1239 {
1240     WebCore::JSMainThreadNullState state;
1241     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1242     g_return_val_if_fail(command, FALSE);
1243     WebCore::Document* item = WebKit::core(self);
1244     WTF::String convertedCommand = WTF::String::fromUTF8(command);
1245     gboolean result = item->queryCommandIndeterm(convertedCommand);
1246     return result;
1247 }
1248
1249 gboolean webkit_dom_document_query_command_state(WebKitDOMDocument* self, const gchar* command)
1250 {
1251     WebCore::JSMainThreadNullState state;
1252     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1253     g_return_val_if_fail(command, FALSE);
1254     WebCore::Document* item = WebKit::core(self);
1255     WTF::String convertedCommand = WTF::String::fromUTF8(command);
1256     gboolean result = item->queryCommandState(convertedCommand);
1257     return result;
1258 }
1259
1260 gboolean webkit_dom_document_query_command_supported(WebKitDOMDocument* self, const gchar* command)
1261 {
1262     WebCore::JSMainThreadNullState state;
1263     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1264     g_return_val_if_fail(command, FALSE);
1265     WebCore::Document* item = WebKit::core(self);
1266     WTF::String convertedCommand = WTF::String::fromUTF8(command);
1267     gboolean result = item->queryCommandSupported(convertedCommand);
1268     return result;
1269 }
1270
1271 gchar* webkit_dom_document_query_command_value(WebKitDOMDocument* self, const gchar* command)
1272 {
1273     WebCore::JSMainThreadNullState state;
1274     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1275     g_return_val_if_fail(command, 0);
1276     WebCore::Document* item = WebKit::core(self);
1277     WTF::String convertedCommand = WTF::String::fromUTF8(command);
1278     gchar* result = convertToUTF8String(item->queryCommandValue(convertedCommand));
1279     return result;
1280 }
1281
1282 WebKitDOMNodeList* webkit_dom_document_get_elements_by_name(WebKitDOMDocument* self, const gchar* elementName)
1283 {
1284     WebCore::JSMainThreadNullState state;
1285     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1286     g_return_val_if_fail(elementName, 0);
1287     WebCore::Document* item = WebKit::core(self);
1288     WTF::String convertedElementName = WTF::String::fromUTF8(elementName);
1289     RefPtr<WebCore::NodeList> gobjectResult = WTF::getPtr(item->getElementsByName(convertedElementName));
1290     return WebKit::kit(gobjectResult.get());
1291 }
1292
1293 WebKitDOMElement* webkit_dom_document_element_from_point(WebKitDOMDocument* self, glong x, glong y)
1294 {
1295     WebCore::JSMainThreadNullState state;
1296     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1297     WebCore::Document* item = WebKit::core(self);
1298     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->elementFromPoint(x, y));
1299     return WebKit::kit(gobjectResult.get());
1300 }
1301
1302 WebKitDOMRange* webkit_dom_document_caret_range_from_point(WebKitDOMDocument* self, glong x, glong y)
1303 {
1304     WebCore::JSMainThreadNullState state;
1305     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1306     WebCore::Document* item = WebKit::core(self);
1307     RefPtr<WebCore::Range> gobjectResult = WTF::getPtr(item->caretRangeFromPoint(x, y));
1308     return WebKit::kit(gobjectResult.get());
1309 }
1310
1311 WebKitDOMCSSStyleDeclaration* webkit_dom_document_create_css_style_declaration(WebKitDOMDocument* self)
1312 {
1313     WebCore::JSMainThreadNullState state;
1314     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1315     WebCore::Document* item = WebKit::core(self);
1316     RefPtr<WebCore::CSSStyleDeclaration> gobjectResult = WTF::getPtr(item->createCSSStyleDeclaration());
1317     return WebKit::kit(gobjectResult.get());
1318 }
1319
1320 WebKitDOMHTMLCollection* webkit_dom_document_get_elements_by_class_name_as_html_collection(WebKitDOMDocument* self, const gchar* classNames)
1321 {
1322     WebCore::JSMainThreadNullState state;
1323     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1324     g_return_val_if_fail(classNames, 0);
1325     WebCore::Document* item = WebKit::core(self);
1326     WTF::String convertedClassNames = WTF::String::fromUTF8(classNames);
1327     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->getElementsByClassName(convertedClassNames));
1328     return WebKit::kit(gobjectResult.get());
1329 }
1330
1331 gboolean webkit_dom_document_has_focus(WebKitDOMDocument* self)
1332 {
1333     WebCore::JSMainThreadNullState state;
1334     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1335     WebCore::Document* item = WebKit::core(self);
1336     gboolean result = item->hasFocus();
1337     return result;
1338 }
1339
1340 void webkit_dom_document_webkit_cancel_fullscreen(WebKitDOMDocument* self)
1341 {
1342     WebCore::JSMainThreadNullState state;
1343     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1344     WebCore::Document* item = WebKit::core(self);
1345     item->webkitCancelFullScreen();
1346 }
1347
1348 void webkit_dom_document_webkit_exit_fullscreen(WebKitDOMDocument* self)
1349 {
1350     WebCore::JSMainThreadNullState state;
1351     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1352     WebCore::Document* item = WebKit::core(self);
1353     item->webkitExitFullscreen();
1354 }
1355
1356 void webkit_dom_document_exit_pointer_lock(WebKitDOMDocument* self)
1357 {
1358 #if ENABLE(POINTER_LOCK)
1359     WebCore::JSMainThreadNullState state;
1360     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1361     WebCore::Document* item = WebKit::core(self);
1362     item->exitPointerLock();
1363 #else
1364     UNUSED_PARAM(self);
1365     WEBKIT_WARN_FEATURE_NOT_PRESENT("Pointer Lock")
1366 #endif /* ENABLE(POINTER_LOCK) */
1367 }
1368
1369 WebKitDOMElement* webkit_dom_document_get_element_by_id(WebKitDOMDocument* self, const gchar* elementId)
1370 {
1371     WebCore::JSMainThreadNullState state;
1372     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1373     g_return_val_if_fail(elementId, 0);
1374     WebCore::Document* item = WebKit::core(self);
1375     WTF::String convertedElementId = WTF::String::fromUTF8(elementId);
1376     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->getElementById(convertedElementId));
1377     return WebKit::kit(gobjectResult.get());
1378 }
1379
1380 WebKitDOMElement* webkit_dom_document_query_selector(WebKitDOMDocument* self, const gchar* selectors, GError** error)
1381 {
1382     WebCore::JSMainThreadNullState state;
1383     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1384     g_return_val_if_fail(selectors, 0);
1385     g_return_val_if_fail(!error || !*error, 0);
1386     WebCore::Document* item = WebKit::core(self);
1387     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
1388     auto result = item->querySelector(convertedSelectors);
1389     if (result.hasException()) {
1390         auto description = WebCore::DOMException::description(result.releaseException().code());
1391         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1392         return nullptr;
1393     }
1394     return WebKit::kit(result.releaseReturnValue());
1395 }
1396
1397 WebKitDOMNodeList* webkit_dom_document_query_selector_all(WebKitDOMDocument* self, const gchar* selectors, GError** error)
1398 {
1399     WebCore::JSMainThreadNullState state;
1400     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1401     g_return_val_if_fail(selectors, 0);
1402     g_return_val_if_fail(!error || !*error, 0);
1403     WebCore::Document* item = WebKit::core(self);
1404     WTF::String convertedSelectors = WTF::String::fromUTF8(selectors);
1405     auto result = item->querySelectorAll(convertedSelectors);
1406     if (result.hasException()) {
1407         auto description = WebCore::DOMException::description(result.releaseException().code());
1408         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1409         return nullptr;
1410     }
1411     return WebKit::kit(result.releaseReturnValue().ptr());
1412 }
1413
1414 WebKitDOMDocumentType* webkit_dom_document_get_doctype(WebKitDOMDocument* self)
1415 {
1416     WebCore::JSMainThreadNullState state;
1417     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1418     WebCore::Document* item = WebKit::core(self);
1419     RefPtr<WebCore::DocumentType> gobjectResult = WTF::getPtr(item->doctype());
1420     return WebKit::kit(gobjectResult.get());
1421 }
1422
1423 WebKitDOMDOMImplementation* webkit_dom_document_get_implementation(WebKitDOMDocument* self)
1424 {
1425     WebCore::JSMainThreadNullState state;
1426     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1427     WebCore::Document* item = WebKit::core(self);
1428     RefPtr<WebCore::DOMImplementation> gobjectResult = WTF::getPtr(item->implementation());
1429     return WebKit::kit(gobjectResult.get());
1430 }
1431
1432 WebKitDOMElement* webkit_dom_document_get_document_element(WebKitDOMDocument* self)
1433 {
1434     WebCore::JSMainThreadNullState state;
1435     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1436     WebCore::Document* item = WebKit::core(self);
1437     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->documentElement());
1438     return WebKit::kit(gobjectResult.get());
1439 }
1440
1441 gchar* webkit_dom_document_get_input_encoding(WebKitDOMDocument* self)
1442 {
1443     WebCore::JSMainThreadNullState state;
1444     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1445     WebCore::Document* item = WebKit::core(self);
1446     gchar* result = convertToUTF8String(item->characterSetWithUTF8Fallback());
1447     return result;
1448 }
1449
1450 gchar* webkit_dom_document_get_xml_encoding(WebKitDOMDocument* self)
1451 {
1452     WebCore::JSMainThreadNullState state;
1453     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1454     WebCore::Document* item = WebKit::core(self);
1455     gchar* result = convertToUTF8String(item->xmlEncoding());
1456     return result;
1457 }
1458
1459 gchar* webkit_dom_document_get_xml_version(WebKitDOMDocument* self)
1460 {
1461     WebCore::JSMainThreadNullState state;
1462     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1463     WebCore::Document* item = WebKit::core(self);
1464     gchar* result = convertToUTF8String(item->xmlVersion());
1465     return result;
1466 }
1467
1468 void webkit_dom_document_set_xml_version(WebKitDOMDocument* self, const gchar* value, GError** error)
1469 {
1470     WebCore::JSMainThreadNullState state;
1471     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1472     g_return_if_fail(value);
1473     g_return_if_fail(!error || !*error);
1474     WebCore::Document* item = WebKit::core(self);
1475     WTF::String convertedValue = WTF::String::fromUTF8(value);
1476     auto result = item->setXMLVersion(convertedValue);
1477     if (result.hasException()) {
1478         auto description = WebCore::DOMException::description(result.releaseException().code());
1479         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1480     }
1481 }
1482
1483 gboolean webkit_dom_document_get_xml_standalone(WebKitDOMDocument* self)
1484 {
1485     WebCore::JSMainThreadNullState state;
1486     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1487     WebCore::Document* item = WebKit::core(self);
1488     gboolean result = item->xmlStandalone();
1489     return result;
1490 }
1491
1492 void webkit_dom_document_set_xml_standalone(WebKitDOMDocument* self, gboolean value, GError** error)
1493 {
1494     WebCore::JSMainThreadNullState state;
1495     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1496     g_return_if_fail(!error || !*error);
1497     WebKit::core(self)->setXMLStandalone(value);
1498 }
1499
1500 gchar* webkit_dom_document_get_document_uri(WebKitDOMDocument* self)
1501 {
1502     WebCore::JSMainThreadNullState state;
1503     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1504     WebCore::Document* item = WebKit::core(self);
1505     gchar* result = convertToUTF8String(item->documentURI());
1506     return result;
1507 }
1508
1509 void webkit_dom_document_set_document_uri(WebKitDOMDocument* self, const gchar* value)
1510 {
1511     WebCore::JSMainThreadNullState state;
1512     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1513     g_return_if_fail(value);
1514     WebCore::Document* item = WebKit::core(self);
1515     WTF::String convertedValue = WTF::String::fromUTF8(value);
1516     item->setDocumentURI(convertedValue);
1517 }
1518
1519 WebKitDOMDOMWindow* webkit_dom_document_get_default_view(WebKitDOMDocument* self)
1520 {
1521     WebCore::JSMainThreadNullState state;
1522     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1523     WebCore::Document* item = WebKit::core(self);
1524     RefPtr<WebCore::DOMWindow> gobjectResult = WTF::getPtr(item->defaultView());
1525     return WebKit::kit(gobjectResult.get());
1526 }
1527
1528 WebKitDOMStyleSheetList* webkit_dom_document_get_style_sheets(WebKitDOMDocument* self)
1529 {
1530     WebCore::JSMainThreadNullState state;
1531     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1532     WebCore::Document* item = WebKit::core(self);
1533     RefPtr<WebCore::StyleSheetList> gobjectResult = WTF::getPtr(item->styleSheets());
1534     return WebKit::kit(gobjectResult.get());
1535 }
1536
1537 gchar* webkit_dom_document_get_content_type(WebKitDOMDocument* self)
1538 {
1539     WebCore::JSMainThreadNullState state;
1540     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1541     WebCore::Document* item = WebKit::core(self);
1542     gchar* result = convertToUTF8String(item->contentType());
1543     return result;
1544 }
1545
1546 gchar* webkit_dom_document_get_title(WebKitDOMDocument* self)
1547 {
1548     WebCore::JSMainThreadNullState state;
1549     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1550     WebCore::Document* item = WebKit::core(self);
1551     gchar* result = convertToUTF8String(item->title());
1552     return result;
1553 }
1554
1555 void webkit_dom_document_set_title(WebKitDOMDocument* self, const gchar* value)
1556 {
1557     WebCore::JSMainThreadNullState state;
1558     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1559     g_return_if_fail(value);
1560     WebCore::Document* item = WebKit::core(self);
1561     WTF::String convertedValue = WTF::String::fromUTF8(value);
1562     item->setTitle(convertedValue);
1563 }
1564
1565 gchar* webkit_dom_document_get_dir(WebKitDOMDocument* self)
1566 {
1567     WebCore::JSMainThreadNullState state;
1568     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1569     WebCore::Document* item = WebKit::core(self);
1570     gchar* result = convertToUTF8String(item->dir());
1571     return result;
1572 }
1573
1574 void webkit_dom_document_set_dir(WebKitDOMDocument* self, const gchar* value)
1575 {
1576     WebCore::JSMainThreadNullState state;
1577     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1578     g_return_if_fail(value);
1579     WebCore::Document* item = WebKit::core(self);
1580     WTF::String convertedValue = WTF::String::fromUTF8(value);
1581     item->setDir(convertedValue);
1582 }
1583
1584 gchar* webkit_dom_document_get_design_mode(WebKitDOMDocument* self)
1585 {
1586     WebCore::JSMainThreadNullState state;
1587     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1588     WebCore::Document* item = WebKit::core(self);
1589     gchar* result = convertToUTF8String(item->designMode());
1590     return result;
1591 }
1592
1593 void webkit_dom_document_set_design_mode(WebKitDOMDocument* self, const gchar* value)
1594 {
1595     WebCore::JSMainThreadNullState state;
1596     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1597     g_return_if_fail(value);
1598     WebCore::Document* item = WebKit::core(self);
1599     WTF::String convertedValue = WTF::String::fromUTF8(value);
1600     item->setDesignMode(convertedValue);
1601 }
1602
1603 gchar* webkit_dom_document_get_referrer(WebKitDOMDocument* self)
1604 {
1605     WebCore::JSMainThreadNullState state;
1606     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1607     WebCore::Document* item = WebKit::core(self);
1608     gchar* result = convertToUTF8String(item->referrer());
1609     return result;
1610 }
1611
1612 gchar* webkit_dom_document_get_domain(WebKitDOMDocument* self)
1613 {
1614     WebCore::JSMainThreadNullState state;
1615     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1616     WebCore::Document* item = WebKit::core(self);
1617     gchar* result = convertToUTF8String(item->domain());
1618     return result;
1619 }
1620
1621 gchar* webkit_dom_document_get_url(WebKitDOMDocument* self)
1622 {
1623     WebCore::JSMainThreadNullState state;
1624     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1625     WebCore::Document* item = WebKit::core(self);
1626     gchar* result = convertToUTF8String(item->urlForBindings());
1627     return result;
1628 }
1629
1630 gchar* webkit_dom_document_get_cookie(WebKitDOMDocument* self, GError** error)
1631 {
1632     WebCore::JSMainThreadNullState state;
1633     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1634     g_return_val_if_fail(!error || !*error, 0);
1635     WebCore::Document* item = WebKit::core(self);
1636     auto result = item->cookie();
1637     if (result.hasException())
1638         return nullptr;
1639     return convertToUTF8String(result.releaseReturnValue());
1640 }
1641
1642 void webkit_dom_document_set_cookie(WebKitDOMDocument* self, const gchar* value, GError** error)
1643 {
1644     WebCore::JSMainThreadNullState state;
1645     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1646     g_return_if_fail(value);
1647     g_return_if_fail(!error || !*error);
1648     WebCore::Document* item = WebKit::core(self);
1649     WTF::String convertedValue = WTF::String::fromUTF8(value);
1650     auto result = item->setCookie(convertedValue);
1651     if (result.hasException()) {
1652         auto description = WebCore::DOMException::description(result.releaseException().code());
1653         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1654     }
1655 }
1656
1657 WebKitDOMHTMLElement* webkit_dom_document_get_body(WebKitDOMDocument* self)
1658 {
1659     WebCore::JSMainThreadNullState state;
1660     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1661     WebCore::Document* item = WebKit::core(self);
1662     RefPtr<WebCore::HTMLElement> gobjectResult = WTF::getPtr(item->bodyOrFrameset());
1663     return WebKit::kit(gobjectResult.get());
1664 }
1665
1666 void webkit_dom_document_set_body(WebKitDOMDocument* self, WebKitDOMHTMLElement* value, GError** error)
1667 {
1668     WebCore::JSMainThreadNullState state;
1669     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1670     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(value));
1671     g_return_if_fail(!error || !*error);
1672     WebCore::Document* item = WebKit::core(self);
1673     WebCore::HTMLElement* convertedValue = WebKit::core(value);
1674     auto result = item->setBodyOrFrameset(convertedValue);
1675     if (result.hasException()) {
1676         auto description = WebCore::DOMException::description(result.releaseException().code());
1677         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
1678     }
1679 }
1680
1681 WebKitDOMHTMLHeadElement* webkit_dom_document_get_head(WebKitDOMDocument* self)
1682 {
1683     WebCore::JSMainThreadNullState state;
1684     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1685     WebCore::Document* item = WebKit::core(self);
1686     RefPtr<WebCore::HTMLHeadElement> gobjectResult = WTF::getPtr(item->head());
1687     return WebKit::kit(gobjectResult.get());
1688 }
1689
1690 WebKitDOMHTMLCollection* webkit_dom_document_get_images(WebKitDOMDocument* self)
1691 {
1692     WebCore::JSMainThreadNullState state;
1693     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1694     WebCore::Document* item = WebKit::core(self);
1695     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->images());
1696     return WebKit::kit(gobjectResult.get());
1697 }
1698
1699 WebKitDOMHTMLCollection* webkit_dom_document_get_applets(WebKitDOMDocument* self)
1700 {
1701     WebCore::JSMainThreadNullState state;
1702     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1703     WebCore::Document* item = WebKit::core(self);
1704     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->applets());
1705     return WebKit::kit(gobjectResult.get());
1706 }
1707
1708 WebKitDOMHTMLCollection* webkit_dom_document_get_links(WebKitDOMDocument* self)
1709 {
1710     WebCore::JSMainThreadNullState state;
1711     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1712     WebCore::Document* item = WebKit::core(self);
1713     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->links());
1714     return WebKit::kit(gobjectResult.get());
1715 }
1716
1717 WebKitDOMHTMLCollection* webkit_dom_document_get_forms(WebKitDOMDocument* self)
1718 {
1719     WebCore::JSMainThreadNullState state;
1720     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1721     WebCore::Document* item = WebKit::core(self);
1722     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->forms());
1723     return WebKit::kit(gobjectResult.get());
1724 }
1725
1726 WebKitDOMHTMLCollection* webkit_dom_document_get_anchors(WebKitDOMDocument* self)
1727 {
1728     WebCore::JSMainThreadNullState state;
1729     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1730     WebCore::Document* item = WebKit::core(self);
1731     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->anchors());
1732     return WebKit::kit(gobjectResult.get());
1733 }
1734
1735 WebKitDOMHTMLCollection* webkit_dom_document_get_embeds(WebKitDOMDocument* self)
1736 {
1737     WebCore::JSMainThreadNullState state;
1738     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1739     WebCore::Document* item = WebKit::core(self);
1740     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->embeds());
1741     return WebKit::kit(gobjectResult.get());
1742 }
1743
1744 WebKitDOMHTMLCollection* webkit_dom_document_get_plugins(WebKitDOMDocument* self)
1745 {
1746     WebCore::JSMainThreadNullState state;
1747     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1748     WebCore::Document* item = WebKit::core(self);
1749     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->plugins());
1750     return WebKit::kit(gobjectResult.get());
1751 }
1752
1753 WebKitDOMHTMLCollection* webkit_dom_document_get_scripts(WebKitDOMDocument* self)
1754 {
1755     WebCore::JSMainThreadNullState state;
1756     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1757     WebCore::Document* item = WebKit::core(self);
1758     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->scripts());
1759     return WebKit::kit(gobjectResult.get());
1760 }
1761
1762 gchar* webkit_dom_document_get_last_modified(WebKitDOMDocument* self)
1763 {
1764     WebCore::JSMainThreadNullState state;
1765     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1766     WebCore::Document* item = WebKit::core(self);
1767     gchar* result = convertToUTF8String(item->lastModified());
1768     return result;
1769 }
1770
1771 gchar* webkit_dom_document_get_charset(WebKitDOMDocument* self)
1772 {
1773     WebCore::JSMainThreadNullState state;
1774     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1775     WebCore::Document* item = WebKit::core(self);
1776     gchar* result = convertToUTF8String(item->charset());
1777     return result;
1778 }
1779
1780 void webkit_dom_document_set_charset(WebKitDOMDocument* self, const gchar* value)
1781 {
1782     WebCore::JSMainThreadNullState state;
1783     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1784     g_return_if_fail(value);
1785     WebCore::Document* item = WebKit::core(self);
1786     WTF::String convertedValue = WTF::String::fromUTF8(value);
1787     item->setCharset(convertedValue);
1788 }
1789
1790 gchar* webkit_dom_document_get_ready_state(WebKitDOMDocument* self)
1791 {
1792     WebCore::JSMainThreadNullState state;
1793     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1794
1795     auto readyState = WebKit::core(self)->readyState();
1796     switch (readyState) {
1797     case WebCore::Document::Loading:
1798         return convertToUTF8String(ASCIILiteral("loading"));
1799     case WebCore::Document::Interactive:
1800         return convertToUTF8String(ASCIILiteral("interactive"));
1801     case WebCore::Document::Complete:
1802         return convertToUTF8String(ASCIILiteral("complete"));
1803     }
1804     return 0;
1805 }
1806
1807 gchar* webkit_dom_document_get_character_set(WebKitDOMDocument* self)
1808 {
1809     WebCore::JSMainThreadNullState state;
1810     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1811     WebCore::Document* item = WebKit::core(self);
1812     gchar* result = convertToUTF8String(item->characterSetWithUTF8Fallback());
1813     return result;
1814 }
1815
1816 gchar* webkit_dom_document_get_preferred_stylesheet_set(WebKitDOMDocument* self)
1817 {
1818     WebCore::JSMainThreadNullState state;
1819     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1820     WebCore::Document* item = WebKit::core(self);
1821     gchar* result = convertToUTF8String(item->preferredStylesheetSet());
1822     return result;
1823 }
1824
1825 gchar* webkit_dom_document_get_selected_stylesheet_set(WebKitDOMDocument* self)
1826 {
1827     WebCore::JSMainThreadNullState state;
1828     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1829     WebCore::Document* item = WebKit::core(self);
1830     gchar* result = convertToUTF8String(item->selectedStylesheetSet());
1831     return result;
1832 }
1833
1834 void webkit_dom_document_set_selected_stylesheet_set(WebKitDOMDocument* self, const gchar* value)
1835 {
1836     WebCore::JSMainThreadNullState state;
1837     g_return_if_fail(WEBKIT_DOM_IS_DOCUMENT(self));
1838     g_return_if_fail(value);
1839     WebCore::Document* item = WebKit::core(self);
1840     WTF::String convertedValue = WTF::String::fromUTF8(value);
1841     item->setSelectedStylesheetSet(convertedValue);
1842 }
1843
1844 WebKitDOMElement* webkit_dom_document_get_active_element(WebKitDOMDocument* self)
1845 {
1846     WebCore::JSMainThreadNullState state;
1847     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1848     WebCore::Document* item = WebKit::core(self);
1849     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->activeElement());
1850     return WebKit::kit(gobjectResult.get());
1851 }
1852
1853 gchar* webkit_dom_document_get_compat_mode(WebKitDOMDocument* self)
1854 {
1855     WebCore::JSMainThreadNullState state;
1856     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1857     WebCore::Document* item = WebKit::core(self);
1858     gchar* result = convertToUTF8String(item->compatMode());
1859     return result;
1860 }
1861
1862 gboolean webkit_dom_document_get_webkit_is_fullscreen(WebKitDOMDocument* self)
1863 {
1864     WebCore::JSMainThreadNullState state;
1865     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1866     WebCore::Document* item = WebKit::core(self);
1867     gboolean result = item->webkitIsFullScreen();
1868     return result;
1869 }
1870
1871 gboolean webkit_dom_document_get_webkit_fullscreen_keyboard_input_allowed(WebKitDOMDocument* self)
1872 {
1873     WebCore::JSMainThreadNullState state;
1874     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1875     WebCore::Document* item = WebKit::core(self);
1876     gboolean result = item->webkitFullScreenKeyboardInputAllowed();
1877     return result;
1878 }
1879
1880 WebKitDOMElement* webkit_dom_document_get_webkit_current_fullscreen_element(WebKitDOMDocument* self)
1881 {
1882     WebCore::JSMainThreadNullState state;
1883     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1884     WebCore::Document* item = WebKit::core(self);
1885     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->webkitCurrentFullScreenElement());
1886     return WebKit::kit(gobjectResult.get());
1887 }
1888
1889 gboolean webkit_dom_document_get_webkit_fullscreen_enabled(WebKitDOMDocument* self)
1890 {
1891     WebCore::JSMainThreadNullState state;
1892     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1893     WebCore::Document* item = WebKit::core(self);
1894     gboolean result = item->webkitFullscreenEnabled();
1895     return result;
1896 }
1897
1898 WebKitDOMElement* webkit_dom_document_get_webkit_fullscreen_element(WebKitDOMDocument* self)
1899 {
1900     WebCore::JSMainThreadNullState state;
1901     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1902     WebCore::Document* item = WebKit::core(self);
1903     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->webkitFullscreenElement());
1904     return WebKit::kit(gobjectResult.get());
1905 }
1906
1907 WebKitDOMElement* webkit_dom_document_get_pointer_lock_element(WebKitDOMDocument* self)
1908 {
1909 #if ENABLE(POINTER_LOCK)
1910     WebCore::JSMainThreadNullState state;
1911     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1912     WebCore::Document* item = WebKit::core(self);
1913     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->pointerLockElement());
1914     return WebKit::kit(gobjectResult.get());
1915 #else
1916     UNUSED_PARAM(self);
1917     WEBKIT_WARN_FEATURE_NOT_PRESENT("Pointer Lock")
1918     return 0;
1919 #endif /* ENABLE(POINTER_LOCK) */
1920 }
1921
1922 gchar* webkit_dom_document_get_visibility_state(WebKitDOMDocument* self)
1923 {
1924     WebCore::JSMainThreadNullState state;
1925     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1926     WebCore::Document* item = WebKit::core(self);
1927     switch (item->visibilityState()) {
1928     case WebCore::Document::VisibilityState::Hidden:
1929         return convertToUTF8String("hidden");
1930     case WebCore::Document::VisibilityState::Visible:
1931         return convertToUTF8String("visible");
1932     case WebCore::Document::VisibilityState::Prerender:
1933         return convertToUTF8String("prerender");
1934     }
1935     ASSERT_NOT_REACHED();
1936     return nullptr;
1937 }
1938
1939 gboolean webkit_dom_document_get_hidden(WebKitDOMDocument* self)
1940 {
1941     WebCore::JSMainThreadNullState state;
1942     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), FALSE);
1943     WebCore::Document* item = WebKit::core(self);
1944     gboolean result = item->hidden();
1945     return result;
1946 }
1947
1948 WebKitDOMHTMLScriptElement* webkit_dom_document_get_current_script(WebKitDOMDocument* self)
1949 {
1950     WebCore::JSMainThreadNullState state;
1951     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1952     WebCore::Document* item = WebKit::core(self);
1953     RefPtr<WebCore::HTMLScriptElement> gobjectResult = WTF::getPtr(item->currentScript());
1954     return WebKit::kit(gobjectResult.get());
1955 }
1956
1957 gchar* webkit_dom_document_get_origin(WebKitDOMDocument* self)
1958 {
1959     WebCore::JSMainThreadNullState state;
1960     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1961     WebCore::Document* item = WebKit::core(self);
1962     gchar* result = convertToUTF8String(item->origin());
1963     return result;
1964 }
1965
1966 WebKitDOMElement* webkit_dom_document_get_scrolling_element(WebKitDOMDocument* self)
1967 {
1968     WebCore::JSMainThreadNullState state;
1969     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1970     WebCore::Document* item = WebKit::core(self);
1971     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->scrollingElement());
1972     return WebKit::kit(gobjectResult.get());
1973 }
1974
1975 WebKitDOMHTMLCollection* webkit_dom_document_get_children(WebKitDOMDocument* self)
1976 {
1977     WebCore::JSMainThreadNullState state;
1978     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1979     WebCore::Document* item = WebKit::core(self);
1980     RefPtr<WebCore::HTMLCollection> gobjectResult = WTF::getPtr(item->children());
1981     return WebKit::kit(gobjectResult.get());
1982 }
1983
1984 WebKitDOMElement* webkit_dom_document_get_first_element_child(WebKitDOMDocument* self)
1985 {
1986     WebCore::JSMainThreadNullState state;
1987     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1988     WebCore::Document* item = WebKit::core(self);
1989     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->firstElementChild());
1990     return WebKit::kit(gobjectResult.get());
1991 }
1992
1993 WebKitDOMElement* webkit_dom_document_get_last_element_child(WebKitDOMDocument* self)
1994 {
1995     WebCore::JSMainThreadNullState state;
1996     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
1997     WebCore::Document* item = WebKit::core(self);
1998     RefPtr<WebCore::Element> gobjectResult = WTF::getPtr(item->lastElementChild());
1999     return WebKit::kit(gobjectResult.get());
2000 }
2001
2002 gulong webkit_dom_document_get_child_element_count(WebKitDOMDocument* self)
2003 {
2004     WebCore::JSMainThreadNullState state;
2005     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
2006     WebCore::Document* item = WebKit::core(self);
2007     gulong result = item->childElementCount();
2008     return result;
2009 }
2010