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