Drop ExceptionCodeDescription class
[WebKit-https.git] / Source / WebKit / WebProcess / InjectedBundle / API / gtk / DOM / WebKitDOMHTMLInputElement.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 "WebKitDOMHTMLInputElement.h"
22
23 #include <WebCore/CSSImportRule.h>
24 #include "DOMObjectCache.h"
25 #include <WebCore/DOMException.h>
26 #include <WebCore/Document.h>
27 #include "GObjectEventListener.h"
28 #include <WebCore/HTMLNames.h>
29 #include <WebCore/JSMainThreadExecState.h>
30 #include "WebKitDOMEventPrivate.h"
31 #include "WebKitDOMEventTarget.h"
32 #include "WebKitDOMFileListPrivate.h"
33 #include "WebKitDOMHTMLElementPrivate.h"
34 #include "WebKitDOMHTMLFormElementPrivate.h"
35 #include "WebKitDOMHTMLInputElementPrivate.h"
36 #include "WebKitDOMNodeListPrivate.h"
37 #include "WebKitDOMNodePrivate.h"
38 #include "WebKitDOMPrivate.h"
39 #include "ConvertToUTF8String.h"
40 #include <wtf/GetPtr.h>
41 #include <wtf/RefPtr.h>
42
43 namespace WebKit {
44
45 WebKitDOMHTMLInputElement* kit(WebCore::HTMLInputElement* obj)
46 {
47     return WEBKIT_DOM_HTML_INPUT_ELEMENT(kit(static_cast<WebCore::Node*>(obj)));
48 }
49
50 WebCore::HTMLInputElement* core(WebKitDOMHTMLInputElement* request)
51 {
52     return request ? static_cast<WebCore::HTMLInputElement*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
53 }
54
55 WebKitDOMHTMLInputElement* wrapHTMLInputElement(WebCore::HTMLInputElement* coreObject)
56 {
57     ASSERT(coreObject);
58     return WEBKIT_DOM_HTML_INPUT_ELEMENT(g_object_new(WEBKIT_DOM_TYPE_HTML_INPUT_ELEMENT, "core-object", coreObject, nullptr));
59 }
60
61 } // namespace WebKit
62
63 static gboolean webkit_dom_html_input_element_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
64 {
65     WebCore::Event* coreEvent = WebKit::core(event);
66     if (!coreEvent)
67         return false;
68     WebCore::HTMLInputElement* coreTarget = static_cast<WebCore::HTMLInputElement*>(WEBKIT_DOM_OBJECT(target)->coreObject);
69
70     auto result = coreTarget->dispatchEventForBindings(*coreEvent);
71     if (result.hasException()) {
72         auto description = WebCore::DOMException::description(result.releaseException().code());
73         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
74         return false;
75     }
76     return result.releaseReturnValue();
77 }
78
79 static gboolean webkit_dom_html_input_element_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
80 {
81     WebCore::HTMLInputElement* coreTarget = static_cast<WebCore::HTMLInputElement*>(WEBKIT_DOM_OBJECT(target)->coreObject);
82     return WebKit::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
83 }
84
85 static gboolean webkit_dom_html_input_element_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
86 {
87     WebCore::HTMLInputElement* coreTarget = static_cast<WebCore::HTMLInputElement*>(WEBKIT_DOM_OBJECT(target)->coreObject);
88     return WebKit::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
89 }
90
91 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
92 {
93     iface->dispatch_event = webkit_dom_html_input_element_dispatch_event;
94     iface->add_event_listener = webkit_dom_html_input_element_add_event_listener;
95     iface->remove_event_listener = webkit_dom_html_input_element_remove_event_listener;
96 }
97
98 G_DEFINE_TYPE_WITH_CODE(WebKitDOMHTMLInputElement, webkit_dom_html_input_element, WEBKIT_DOM_TYPE_HTML_ELEMENT, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkit_dom_event_target_init))
99
100 enum {
101     PROP_0,
102     PROP_ACCEPT,
103     PROP_ALT,
104     PROP_AUTOFOCUS,
105     PROP_DEFAULT_CHECKED,
106     PROP_CHECKED,
107     PROP_DISABLED,
108     PROP_FORM,
109     PROP_FILES,
110     PROP_HEIGHT,
111     PROP_INDETERMINATE,
112     PROP_MAX_LENGTH,
113     PROP_MULTIPLE,
114     PROP_NAME,
115     PROP_READ_ONLY,
116     PROP_SIZE,
117     PROP_SRC,
118     PROP_TYPE,
119     PROP_DEFAULT_VALUE,
120     PROP_VALUE,
121     PROP_WIDTH,
122     PROP_WILL_VALIDATE,
123     PROP_ALIGN,
124     PROP_USE_MAP,
125     PROP_CAPTURE,
126 };
127
128 static void webkit_dom_html_input_element_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
129 {
130     WebKitDOMHTMLInputElement* self = WEBKIT_DOM_HTML_INPUT_ELEMENT(object);
131
132     switch (propertyId) {
133     case PROP_ACCEPT:
134         webkit_dom_html_input_element_set_accept(self, g_value_get_string(value));
135         break;
136     case PROP_ALT:
137         webkit_dom_html_input_element_set_alt(self, g_value_get_string(value));
138         break;
139     case PROP_AUTOFOCUS:
140         webkit_dom_html_input_element_set_autofocus(self, g_value_get_boolean(value));
141         break;
142     case PROP_DEFAULT_CHECKED:
143         webkit_dom_html_input_element_set_default_checked(self, g_value_get_boolean(value));
144         break;
145     case PROP_CHECKED:
146         webkit_dom_html_input_element_set_checked(self, g_value_get_boolean(value));
147         break;
148     case PROP_DISABLED:
149         webkit_dom_html_input_element_set_disabled(self, g_value_get_boolean(value));
150         break;
151     case PROP_HEIGHT:
152         webkit_dom_html_input_element_set_height(self, g_value_get_ulong(value));
153         break;
154     case PROP_INDETERMINATE:
155         webkit_dom_html_input_element_set_indeterminate(self, g_value_get_boolean(value));
156         break;
157     case PROP_MAX_LENGTH:
158         webkit_dom_html_input_element_set_max_length(self, g_value_get_long(value), nullptr);
159         break;
160     case PROP_MULTIPLE:
161         webkit_dom_html_input_element_set_multiple(self, g_value_get_boolean(value));
162         break;
163     case PROP_NAME:
164         webkit_dom_html_input_element_set_name(self, g_value_get_string(value));
165         break;
166     case PROP_READ_ONLY:
167         webkit_dom_html_input_element_set_read_only(self, g_value_get_boolean(value));
168         break;
169     case PROP_SIZE:
170         webkit_dom_html_input_element_set_size(self, g_value_get_ulong(value), nullptr);
171         break;
172     case PROP_SRC:
173         webkit_dom_html_input_element_set_src(self, g_value_get_string(value));
174         break;
175     case PROP_TYPE:
176         webkit_dom_html_input_element_set_input_type(self, g_value_get_string(value));
177         break;
178     case PROP_DEFAULT_VALUE:
179         webkit_dom_html_input_element_set_default_value(self, g_value_get_string(value));
180         break;
181     case PROP_VALUE:
182         webkit_dom_html_input_element_set_value(self, g_value_get_string(value));
183         break;
184     case PROP_WIDTH:
185         webkit_dom_html_input_element_set_width(self, g_value_get_ulong(value));
186         break;
187     case PROP_ALIGN:
188         webkit_dom_html_input_element_set_align(self, g_value_get_string(value));
189         break;
190     case PROP_USE_MAP:
191         webkit_dom_html_input_element_set_use_map(self, g_value_get_string(value));
192         break;
193     case PROP_CAPTURE:
194         webkit_dom_html_input_element_set_capture_type(self, g_value_get_string(value));
195         break;
196     default:
197         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
198         break;
199     }
200 }
201
202 static void webkit_dom_html_input_element_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
203 {
204     WebKitDOMHTMLInputElement* self = WEBKIT_DOM_HTML_INPUT_ELEMENT(object);
205
206     switch (propertyId) {
207     case PROP_ACCEPT:
208         g_value_take_string(value, webkit_dom_html_input_element_get_accept(self));
209         break;
210     case PROP_ALT:
211         g_value_take_string(value, webkit_dom_html_input_element_get_alt(self));
212         break;
213     case PROP_AUTOFOCUS:
214         g_value_set_boolean(value, webkit_dom_html_input_element_get_autofocus(self));
215         break;
216     case PROP_DEFAULT_CHECKED:
217         g_value_set_boolean(value, webkit_dom_html_input_element_get_default_checked(self));
218         break;
219     case PROP_CHECKED:
220         g_value_set_boolean(value, webkit_dom_html_input_element_get_checked(self));
221         break;
222     case PROP_DISABLED:
223         g_value_set_boolean(value, webkit_dom_html_input_element_get_disabled(self));
224         break;
225     case PROP_FORM:
226         g_value_set_object(value, webkit_dom_html_input_element_get_form(self));
227         break;
228     case PROP_FILES:
229         g_value_set_object(value, webkit_dom_html_input_element_get_files(self));
230         break;
231     case PROP_HEIGHT:
232         g_value_set_ulong(value, webkit_dom_html_input_element_get_height(self));
233         break;
234     case PROP_INDETERMINATE:
235         g_value_set_boolean(value, webkit_dom_html_input_element_get_indeterminate(self));
236         break;
237     case PROP_MAX_LENGTH:
238         g_value_set_long(value, webkit_dom_html_input_element_get_max_length(self));
239         break;
240     case PROP_MULTIPLE:
241         g_value_set_boolean(value, webkit_dom_html_input_element_get_multiple(self));
242         break;
243     case PROP_NAME:
244         g_value_take_string(value, webkit_dom_html_input_element_get_name(self));
245         break;
246     case PROP_READ_ONLY:
247         g_value_set_boolean(value, webkit_dom_html_input_element_get_read_only(self));
248         break;
249     case PROP_SIZE:
250         g_value_set_ulong(value, webkit_dom_html_input_element_get_size(self));
251         break;
252     case PROP_SRC:
253         g_value_take_string(value, webkit_dom_html_input_element_get_src(self));
254         break;
255     case PROP_TYPE:
256         g_value_take_string(value, webkit_dom_html_input_element_get_input_type(self));
257         break;
258     case PROP_DEFAULT_VALUE:
259         g_value_take_string(value, webkit_dom_html_input_element_get_default_value(self));
260         break;
261     case PROP_VALUE:
262         g_value_take_string(value, webkit_dom_html_input_element_get_value(self));
263         break;
264     case PROP_WIDTH:
265         g_value_set_ulong(value, webkit_dom_html_input_element_get_width(self));
266         break;
267     case PROP_WILL_VALIDATE:
268         g_value_set_boolean(value, webkit_dom_html_input_element_get_will_validate(self));
269         break;
270     case PROP_ALIGN:
271         g_value_take_string(value, webkit_dom_html_input_element_get_align(self));
272         break;
273     case PROP_USE_MAP:
274         g_value_take_string(value, webkit_dom_html_input_element_get_use_map(self));
275         break;
276     case PROP_CAPTURE:
277         g_value_take_string(value, webkit_dom_html_input_element_get_capture_type(self));
278         break;
279     default:
280         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
281         break;
282     }
283 }
284
285 static void webkit_dom_html_input_element_class_init(WebKitDOMHTMLInputElementClass* requestClass)
286 {
287     GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
288     gobjectClass->set_property = webkit_dom_html_input_element_set_property;
289     gobjectClass->get_property = webkit_dom_html_input_element_get_property;
290
291     g_object_class_install_property(
292         gobjectClass,
293         PROP_ACCEPT,
294         g_param_spec_string(
295             "accept",
296             "HTMLInputElement:accept",
297             "read-write gchar* HTMLInputElement:accept",
298             "",
299             WEBKIT_PARAM_READWRITE));
300
301     g_object_class_install_property(
302         gobjectClass,
303         PROP_ALT,
304         g_param_spec_string(
305             "alt",
306             "HTMLInputElement:alt",
307             "read-write gchar* HTMLInputElement:alt",
308             "",
309             WEBKIT_PARAM_READWRITE));
310
311     g_object_class_install_property(
312         gobjectClass,
313         PROP_AUTOFOCUS,
314         g_param_spec_boolean(
315             "autofocus",
316             "HTMLInputElement:autofocus",
317             "read-write gboolean HTMLInputElement:autofocus",
318             FALSE,
319             WEBKIT_PARAM_READWRITE));
320
321     g_object_class_install_property(
322         gobjectClass,
323         PROP_DEFAULT_CHECKED,
324         g_param_spec_boolean(
325             "default-checked",
326             "HTMLInputElement:default-checked",
327             "read-write gboolean HTMLInputElement:default-checked",
328             FALSE,
329             WEBKIT_PARAM_READWRITE));
330
331     g_object_class_install_property(
332         gobjectClass,
333         PROP_CHECKED,
334         g_param_spec_boolean(
335             "checked",
336             "HTMLInputElement:checked",
337             "read-write gboolean HTMLInputElement:checked",
338             FALSE,
339             WEBKIT_PARAM_READWRITE));
340
341     g_object_class_install_property(
342         gobjectClass,
343         PROP_DISABLED,
344         g_param_spec_boolean(
345             "disabled",
346             "HTMLInputElement:disabled",
347             "read-write gboolean HTMLInputElement:disabled",
348             FALSE,
349             WEBKIT_PARAM_READWRITE));
350
351     g_object_class_install_property(
352         gobjectClass,
353         PROP_FORM,
354         g_param_spec_object(
355             "form",
356             "HTMLInputElement:form",
357             "read-only WebKitDOMHTMLFormElement* HTMLInputElement:form",
358             WEBKIT_DOM_TYPE_HTML_FORM_ELEMENT,
359             WEBKIT_PARAM_READABLE));
360
361     g_object_class_install_property(
362         gobjectClass,
363         PROP_FILES,
364         g_param_spec_object(
365             "files",
366             "HTMLInputElement:files",
367             "read-only WebKitDOMFileList* HTMLInputElement:files",
368             WEBKIT_DOM_TYPE_FILE_LIST,
369             WEBKIT_PARAM_READABLE));
370
371     g_object_class_install_property(
372         gobjectClass,
373         PROP_HEIGHT,
374         g_param_spec_ulong(
375             "height",
376             "HTMLInputElement:height",
377             "read-write gulong HTMLInputElement:height",
378             0, G_MAXULONG, 0,
379             WEBKIT_PARAM_READWRITE));
380
381     g_object_class_install_property(
382         gobjectClass,
383         PROP_INDETERMINATE,
384         g_param_spec_boolean(
385             "indeterminate",
386             "HTMLInputElement:indeterminate",
387             "read-write gboolean HTMLInputElement:indeterminate",
388             FALSE,
389             WEBKIT_PARAM_READWRITE));
390
391     g_object_class_install_property(
392         gobjectClass,
393         PROP_MAX_LENGTH,
394         g_param_spec_long(
395             "max-length",
396             "HTMLInputElement:max-length",
397             "read-write glong HTMLInputElement:max-length",
398             G_MINLONG, G_MAXLONG, 0,
399             WEBKIT_PARAM_READWRITE));
400
401     g_object_class_install_property(
402         gobjectClass,
403         PROP_MULTIPLE,
404         g_param_spec_boolean(
405             "multiple",
406             "HTMLInputElement:multiple",
407             "read-write gboolean HTMLInputElement:multiple",
408             FALSE,
409             WEBKIT_PARAM_READWRITE));
410
411     g_object_class_install_property(
412         gobjectClass,
413         PROP_NAME,
414         g_param_spec_string(
415             "name",
416             "HTMLInputElement:name",
417             "read-write gchar* HTMLInputElement:name",
418             "",
419             WEBKIT_PARAM_READWRITE));
420
421     g_object_class_install_property(
422         gobjectClass,
423         PROP_READ_ONLY,
424         g_param_spec_boolean(
425             "read-only",
426             "HTMLInputElement:read-only",
427             "read-write gboolean HTMLInputElement:read-only",
428             FALSE,
429             WEBKIT_PARAM_READWRITE));
430
431     g_object_class_install_property(
432         gobjectClass,
433         PROP_SIZE,
434         g_param_spec_ulong(
435             "size",
436             "HTMLInputElement:size",
437             "read-write gulong HTMLInputElement:size",
438             0, G_MAXULONG, 0,
439             WEBKIT_PARAM_READWRITE));
440
441     g_object_class_install_property(
442         gobjectClass,
443         PROP_SRC,
444         g_param_spec_string(
445             "src",
446             "HTMLInputElement:src",
447             "read-write gchar* HTMLInputElement:src",
448             "",
449             WEBKIT_PARAM_READWRITE));
450
451     g_object_class_install_property(
452         gobjectClass,
453         PROP_TYPE,
454         g_param_spec_string(
455             "type",
456             "HTMLInputElement:type",
457             "read-write gchar* HTMLInputElement:type",
458             "",
459             WEBKIT_PARAM_READWRITE));
460
461     g_object_class_install_property(
462         gobjectClass,
463         PROP_DEFAULT_VALUE,
464         g_param_spec_string(
465             "default-value",
466             "HTMLInputElement:default-value",
467             "read-write gchar* HTMLInputElement:default-value",
468             "",
469             WEBKIT_PARAM_READWRITE));
470
471     g_object_class_install_property(
472         gobjectClass,
473         PROP_VALUE,
474         g_param_spec_string(
475             "value",
476             "HTMLInputElement:value",
477             "read-write gchar* HTMLInputElement:value",
478             "",
479             WEBKIT_PARAM_READWRITE));
480
481     g_object_class_install_property(
482         gobjectClass,
483         PROP_WIDTH,
484         g_param_spec_ulong(
485             "width",
486             "HTMLInputElement:width",
487             "read-write gulong HTMLInputElement:width",
488             0, G_MAXULONG, 0,
489             WEBKIT_PARAM_READWRITE));
490
491     g_object_class_install_property(
492         gobjectClass,
493         PROP_WILL_VALIDATE,
494         g_param_spec_boolean(
495             "will-validate",
496             "HTMLInputElement:will-validate",
497             "read-only gboolean HTMLInputElement:will-validate",
498             FALSE,
499             WEBKIT_PARAM_READABLE));
500
501     g_object_class_install_property(
502         gobjectClass,
503         PROP_ALIGN,
504         g_param_spec_string(
505             "align",
506             "HTMLInputElement:align",
507             "read-write gchar* HTMLInputElement:align",
508             "",
509             WEBKIT_PARAM_READWRITE));
510
511     g_object_class_install_property(
512         gobjectClass,
513         PROP_USE_MAP,
514         g_param_spec_string(
515             "use-map",
516             "HTMLInputElement:use-map",
517             "read-write gchar* HTMLInputElement:use-map",
518             "",
519             WEBKIT_PARAM_READWRITE));
520
521     g_object_class_install_property(
522         gobjectClass,
523         PROP_CAPTURE,
524         g_param_spec_string(
525             "capture",
526             "HTMLInputElement:capture",
527             "read-write gchar* HTMLInputElement:capture",
528             "",
529             WEBKIT_PARAM_READWRITE));
530
531 }
532
533 static void webkit_dom_html_input_element_init(WebKitDOMHTMLInputElement* request)
534 {
535     UNUSED_PARAM(request);
536 }
537
538 void webkit_dom_html_input_element_select(WebKitDOMHTMLInputElement* self)
539 {
540     WebCore::JSMainThreadNullState state;
541     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
542     WebCore::HTMLInputElement* item = WebKit::core(self);
543     item->select();
544 }
545
546 gchar* webkit_dom_html_input_element_get_accept(WebKitDOMHTMLInputElement* self)
547 {
548     WebCore::JSMainThreadNullState state;
549     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
550     WebCore::HTMLInputElement* item = WebKit::core(self);
551     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::acceptAttr));
552     return result;
553 }
554
555 void webkit_dom_html_input_element_set_accept(WebKitDOMHTMLInputElement* self, const gchar* value)
556 {
557     WebCore::JSMainThreadNullState state;
558     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
559     g_return_if_fail(value);
560     WebCore::HTMLInputElement* item = WebKit::core(self);
561     WTF::String convertedValue = WTF::String::fromUTF8(value);
562     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::acceptAttr, convertedValue);
563 }
564
565 gchar* webkit_dom_html_input_element_get_alt(WebKitDOMHTMLInputElement* self)
566 {
567     WebCore::JSMainThreadNullState state;
568     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
569     WebCore::HTMLInputElement* item = WebKit::core(self);
570     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::altAttr));
571     return result;
572 }
573
574 void webkit_dom_html_input_element_set_alt(WebKitDOMHTMLInputElement* self, const gchar* value)
575 {
576     WebCore::JSMainThreadNullState state;
577     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
578     g_return_if_fail(value);
579     WebCore::HTMLInputElement* item = WebKit::core(self);
580     WTF::String convertedValue = WTF::String::fromUTF8(value);
581     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::altAttr, convertedValue);
582 }
583
584 gboolean webkit_dom_html_input_element_get_autofocus(WebKitDOMHTMLInputElement* self)
585 {
586     WebCore::JSMainThreadNullState state;
587     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
588     WebCore::HTMLInputElement* item = WebKit::core(self);
589     gboolean result = item->hasAttributeWithoutSynchronization(WebCore::HTMLNames::autofocusAttr);
590     return result;
591 }
592
593 void webkit_dom_html_input_element_set_autofocus(WebKitDOMHTMLInputElement* self, gboolean value)
594 {
595     WebCore::JSMainThreadNullState state;
596     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
597     WebCore::HTMLInputElement* item = WebKit::core(self);
598     item->setBooleanAttribute(WebCore::HTMLNames::autofocusAttr, value);
599 }
600
601 gboolean webkit_dom_html_input_element_get_default_checked(WebKitDOMHTMLInputElement* self)
602 {
603     WebCore::JSMainThreadNullState state;
604     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
605     WebCore::HTMLInputElement* item = WebKit::core(self);
606     gboolean result = item->hasAttributeWithoutSynchronization(WebCore::HTMLNames::checkedAttr);
607     return result;
608 }
609
610 void webkit_dom_html_input_element_set_default_checked(WebKitDOMHTMLInputElement* self, gboolean value)
611 {
612     WebCore::JSMainThreadNullState state;
613     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
614     WebCore::HTMLInputElement* item = WebKit::core(self);
615     item->setBooleanAttribute(WebCore::HTMLNames::checkedAttr, value);
616 }
617
618 gboolean webkit_dom_html_input_element_get_checked(WebKitDOMHTMLInputElement* self)
619 {
620     WebCore::JSMainThreadNullState state;
621     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
622     WebCore::HTMLInputElement* item = WebKit::core(self);
623     gboolean result = item->checked();
624     return result;
625 }
626
627 void webkit_dom_html_input_element_set_checked(WebKitDOMHTMLInputElement* self, gboolean value)
628 {
629     WebCore::JSMainThreadNullState state;
630     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
631     WebCore::HTMLInputElement* item = WebKit::core(self);
632     item->setChecked(value);
633 }
634
635 gboolean webkit_dom_html_input_element_get_disabled(WebKitDOMHTMLInputElement* self)
636 {
637     WebCore::JSMainThreadNullState state;
638     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
639     WebCore::HTMLInputElement* item = WebKit::core(self);
640     gboolean result = item->hasAttributeWithoutSynchronization(WebCore::HTMLNames::disabledAttr);
641     return result;
642 }
643
644 void webkit_dom_html_input_element_set_disabled(WebKitDOMHTMLInputElement* self, gboolean value)
645 {
646     WebCore::JSMainThreadNullState state;
647     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
648     WebCore::HTMLInputElement* item = WebKit::core(self);
649     item->setBooleanAttribute(WebCore::HTMLNames::disabledAttr, value);
650 }
651
652 WebKitDOMHTMLFormElement* webkit_dom_html_input_element_get_form(WebKitDOMHTMLInputElement* self)
653 {
654     WebCore::JSMainThreadNullState state;
655     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
656     WebCore::HTMLInputElement* item = WebKit::core(self);
657     RefPtr<WebCore::HTMLFormElement> gobjectResult = WTF::getPtr(item->form());
658     return WebKit::kit(gobjectResult.get());
659 }
660
661 WebKitDOMFileList* webkit_dom_html_input_element_get_files(WebKitDOMHTMLInputElement* self)
662 {
663     WebCore::JSMainThreadNullState state;
664     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
665     WebCore::HTMLInputElement* item = WebKit::core(self);
666     RefPtr<WebCore::FileList> gobjectResult = WTF::getPtr(item->files());
667     return WebKit::kit(gobjectResult.get());
668 }
669
670 void webkit_dom_html_input_element_set_files(WebKitDOMHTMLInputElement* self, WebKitDOMFileList* value)
671 {
672     WebCore::JSMainThreadNullState state;
673     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
674     g_return_if_fail(WEBKIT_DOM_IS_FILE_LIST(value));
675     WebCore::HTMLInputElement* item = WebKit::core(self);
676     WebCore::FileList* convertedValue = WebKit::core(value);
677     item->setFiles(convertedValue);
678 }
679
680 gulong webkit_dom_html_input_element_get_height(WebKitDOMHTMLInputElement* self)
681 {
682     WebCore::JSMainThreadNullState state;
683     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
684     WebCore::HTMLInputElement* item = WebKit::core(self);
685     gulong result = item->height();
686     return result;
687 }
688
689 void webkit_dom_html_input_element_set_height(WebKitDOMHTMLInputElement* self, gulong value)
690 {
691     WebCore::JSMainThreadNullState state;
692     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
693     WebCore::HTMLInputElement* item = WebKit::core(self);
694     item->setHeight(value);
695 }
696
697 gboolean webkit_dom_html_input_element_get_indeterminate(WebKitDOMHTMLInputElement* self)
698 {
699     WebCore::JSMainThreadNullState state;
700     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
701     WebCore::HTMLInputElement* item = WebKit::core(self);
702     gboolean result = item->indeterminate();
703     return result;
704 }
705
706 void webkit_dom_html_input_element_set_indeterminate(WebKitDOMHTMLInputElement* self, gboolean value)
707 {
708     WebCore::JSMainThreadNullState state;
709     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
710     WebCore::HTMLInputElement* item = WebKit::core(self);
711     item->setIndeterminate(value);
712 }
713
714 glong webkit_dom_html_input_element_get_max_length(WebKitDOMHTMLInputElement* self)
715 {
716     WebCore::JSMainThreadNullState state;
717     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
718     WebCore::HTMLInputElement* item = WebKit::core(self);
719     glong result = item->maxLength();
720     return result;
721 }
722
723 void webkit_dom_html_input_element_set_max_length(WebKitDOMHTMLInputElement* self, glong value, GError** error)
724 {
725     WebCore::JSMainThreadNullState state;
726     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
727     g_return_if_fail(!error || !*error);
728     WebCore::HTMLInputElement* item = WebKit::core(self);
729     auto result = item->setMaxLength(value);
730     if (result.hasException()) {
731         auto description = WebCore::DOMException::description(result.releaseException().code());
732         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
733     }
734 }
735
736 gboolean webkit_dom_html_input_element_get_multiple(WebKitDOMHTMLInputElement* self)
737 {
738     WebCore::JSMainThreadNullState state;
739     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
740     WebCore::HTMLInputElement* item = WebKit::core(self);
741     gboolean result = item->hasAttributeWithoutSynchronization(WebCore::HTMLNames::multipleAttr);
742     return result;
743 }
744
745 void webkit_dom_html_input_element_set_multiple(WebKitDOMHTMLInputElement* self, gboolean value)
746 {
747     WebCore::JSMainThreadNullState state;
748     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
749     WebCore::HTMLInputElement* item = WebKit::core(self);
750     item->setBooleanAttribute(WebCore::HTMLNames::multipleAttr, value);
751 }
752
753 gchar* webkit_dom_html_input_element_get_name(WebKitDOMHTMLInputElement* self)
754 {
755     WebCore::JSMainThreadNullState state;
756     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
757     WebCore::HTMLInputElement* item = WebKit::core(self);
758     gchar* result = convertToUTF8String(item->getNameAttribute());
759     return result;
760 }
761
762 void webkit_dom_html_input_element_set_name(WebKitDOMHTMLInputElement* self, const gchar* value)
763 {
764     WebCore::JSMainThreadNullState state;
765     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
766     g_return_if_fail(value);
767     WebCore::HTMLInputElement* item = WebKit::core(self);
768     WTF::String convertedValue = WTF::String::fromUTF8(value);
769     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, convertedValue);
770 }
771
772 gboolean webkit_dom_html_input_element_get_read_only(WebKitDOMHTMLInputElement* self)
773 {
774     WebCore::JSMainThreadNullState state;
775     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
776     WebCore::HTMLInputElement* item = WebKit::core(self);
777     gboolean result = item->hasAttributeWithoutSynchronization(WebCore::HTMLNames::readonlyAttr);
778     return result;
779 }
780
781 void webkit_dom_html_input_element_set_read_only(WebKitDOMHTMLInputElement* self, gboolean value)
782 {
783     WebCore::JSMainThreadNullState state;
784     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
785     WebCore::HTMLInputElement* item = WebKit::core(self);
786     item->setBooleanAttribute(WebCore::HTMLNames::readonlyAttr, value);
787 }
788
789 gulong webkit_dom_html_input_element_get_size(WebKitDOMHTMLInputElement* self)
790 {
791     WebCore::JSMainThreadNullState state;
792     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
793     WebCore::HTMLInputElement* item = WebKit::core(self);
794     gulong result = item->size();
795     return result;
796 }
797
798 void webkit_dom_html_input_element_set_size(WebKitDOMHTMLInputElement* self, gulong value, GError** error)
799 {
800     WebCore::JSMainThreadNullState state;
801     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
802     g_return_if_fail(!error || !*error);
803     WebCore::HTMLInputElement* item = WebKit::core(self);
804     auto result = item->setSize(value);
805     if (result.hasException()) {
806         auto description = WebCore::DOMException::description(result.releaseException().code());
807         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);
808     }
809 }
810
811 gchar* webkit_dom_html_input_element_get_src(WebKitDOMHTMLInputElement* self)
812 {
813     WebCore::JSMainThreadNullState state;
814     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
815     WebCore::HTMLInputElement* item = WebKit::core(self);
816     gchar* result = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::srcAttr));
817     return result;
818 }
819
820 void webkit_dom_html_input_element_set_src(WebKitDOMHTMLInputElement* self, const gchar* value)
821 {
822     WebCore::JSMainThreadNullState state;
823     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
824     g_return_if_fail(value);
825     WebCore::HTMLInputElement* item = WebKit::core(self);
826     WTF::String convertedValue = WTF::String::fromUTF8(value);
827     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::srcAttr, convertedValue);
828 }
829
830 gchar* webkit_dom_html_input_element_get_input_type(WebKitDOMHTMLInputElement* self)
831 {
832     WebCore::JSMainThreadNullState state;
833     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
834     WebCore::HTMLInputElement* item = WebKit::core(self);
835     gchar* result = convertToUTF8String(item->type());
836     return result;
837 }
838
839 void webkit_dom_html_input_element_set_input_type(WebKitDOMHTMLInputElement* self, const gchar* value)
840 {
841     WebCore::JSMainThreadNullState state;
842     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
843     g_return_if_fail(value);
844     WebCore::HTMLInputElement* item = WebKit::core(self);
845     WTF::String convertedValue = WTF::String::fromUTF8(value);
846     item->setType(convertedValue);
847 }
848
849 gchar* webkit_dom_html_input_element_get_default_value(WebKitDOMHTMLInputElement* self)
850 {
851     WebCore::JSMainThreadNullState state;
852     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
853     WebCore::HTMLInputElement* item = WebKit::core(self);
854     gchar* result = convertToUTF8String(item->defaultValue());
855     return result;
856 }
857
858 void webkit_dom_html_input_element_set_default_value(WebKitDOMHTMLInputElement* self, const gchar* value)
859 {
860     WebCore::JSMainThreadNullState state;
861     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
862     g_return_if_fail(value);
863     WebCore::HTMLInputElement* item = WebKit::core(self);
864     WTF::String convertedValue = WTF::String::fromUTF8(value);
865     item->setDefaultValue(convertedValue);
866 }
867
868 gchar* webkit_dom_html_input_element_get_value(WebKitDOMHTMLInputElement* self)
869 {
870     WebCore::JSMainThreadNullState state;
871     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
872     WebCore::HTMLInputElement* item = WebKit::core(self);
873     gchar* result = convertToUTF8String(item->value());
874     return result;
875 }
876
877 void webkit_dom_html_input_element_set_value(WebKitDOMHTMLInputElement* self, const gchar* value)
878 {
879     WebCore::JSMainThreadNullState state;
880     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
881     g_return_if_fail(value);
882     WebCore::HTMLInputElement* item = WebKit::core(self);
883     WTF::String convertedValue = WTF::String::fromUTF8(value);
884     item->setValue(convertedValue);
885 }
886
887 gulong webkit_dom_html_input_element_get_width(WebKitDOMHTMLInputElement* self)
888 {
889     WebCore::JSMainThreadNullState state;
890     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
891     WebCore::HTMLInputElement* item = WebKit::core(self);
892     gulong result = item->width();
893     return result;
894 }
895
896 void webkit_dom_html_input_element_set_width(WebKitDOMHTMLInputElement* self, gulong value)
897 {
898     WebCore::JSMainThreadNullState state;
899     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
900     WebCore::HTMLInputElement* item = WebKit::core(self);
901     item->setWidth(value);
902 }
903
904 gboolean webkit_dom_html_input_element_get_will_validate(WebKitDOMHTMLInputElement* self)
905 {
906     WebCore::JSMainThreadNullState state;
907     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
908     WebCore::HTMLInputElement* item = WebKit::core(self);
909     gboolean result = item->willValidate();
910     return result;
911 }
912
913 gchar* webkit_dom_html_input_element_get_align(WebKitDOMHTMLInputElement* self)
914 {
915     WebCore::JSMainThreadNullState state;
916     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
917     WebCore::HTMLInputElement* item = WebKit::core(self);
918     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::alignAttr));
919     return result;
920 }
921
922 void webkit_dom_html_input_element_set_align(WebKitDOMHTMLInputElement* self, const gchar* value)
923 {
924     WebCore::JSMainThreadNullState state;
925     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
926     g_return_if_fail(value);
927     WebCore::HTMLInputElement* item = WebKit::core(self);
928     WTF::String convertedValue = WTF::String::fromUTF8(value);
929     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::alignAttr, convertedValue);
930 }
931
932 gchar* webkit_dom_html_input_element_get_use_map(WebKitDOMHTMLInputElement* self)
933 {
934     WebCore::JSMainThreadNullState state;
935     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
936     WebCore::HTMLInputElement* item = WebKit::core(self);
937     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::usemapAttr));
938     return result;
939 }
940
941 void webkit_dom_html_input_element_set_use_map(WebKitDOMHTMLInputElement* self, const gchar* value)
942 {
943     WebCore::JSMainThreadNullState state;
944     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
945     g_return_if_fail(value);
946     WebCore::HTMLInputElement* item = WebKit::core(self);
947     WTF::String convertedValue = WTF::String::fromUTF8(value);
948     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::usemapAttr, convertedValue);
949 }
950
951 gchar* webkit_dom_html_input_element_get_capture_type(WebKitDOMHTMLInputElement* self)
952 {
953 #if ENABLE(MEDIA_CAPTURE)
954     WebCore::JSMainThreadNullState state;
955     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), 0);
956     WebCore::HTMLInputElement* item = WebKit::core(self);
957     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::captureAttr));
958     return result;
959 #else
960     UNUSED_PARAM(self);
961     WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Capture")
962     return 0;
963 #endif /* ENABLE(MEDIA_CAPTURE) */
964 }
965
966 void webkit_dom_html_input_element_set_capture_type(WebKitDOMHTMLInputElement* self, const gchar* value)
967 {
968 #if ENABLE(MEDIA_CAPTURE)
969     WebCore::JSMainThreadNullState state;
970     g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
971     g_return_if_fail(value);
972     WebCore::HTMLInputElement* item = WebKit::core(self);
973     WTF::String convertedValue = WTF::String::fromUTF8(value);
974     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::captureAttr, convertedValue);
975 #else
976     UNUSED_PARAM(self);
977     UNUSED_PARAM(value);
978     WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Capture")
979 #endif /* ENABLE(MEDIA_CAPTURE) */
980 }
981
982 gboolean webkit_dom_html_input_element_is_edited(WebKitDOMHTMLInputElement* input)
983 {
984     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(input), FALSE);
985
986     return WebKit::core(input)->lastChangeWasUserEdit();
987 }
988
989 gboolean webkit_dom_html_input_element_get_auto_filled(WebKitDOMHTMLInputElement* self)
990 {
991   g_return_val_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self), FALSE);
992
993   return WebKit::core(self)->isAutoFilled();
994 }
995
996 void webkit_dom_html_input_element_set_auto_filled(WebKitDOMHTMLInputElement* self, gboolean value)
997 {
998   g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
999
1000   WebKit::core(self)->setAutoFilled(value);
1001 }
1002
1003 void webkit_dom_html_input_element_set_editing_value(WebKitDOMHTMLInputElement* self, const gchar* value)
1004 {
1005   g_return_if_fail(WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(self));
1006   g_return_if_fail(value);
1007
1008   WebKit::core(self)->setEditingValue(WTF::String::fromUTF8(value));
1009 }