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