8d18830701b16dc34851ac8969a41f85944bb447
[WebKit-https.git] / Source / WebKit / WebProcess / InjectedBundle / API / gtk / DOM / WebKitDOMHTMLElement.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 "WebKitDOMHTMLElement.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 "WebKitDOMHTMLElementPrivate.h"
34 #include "WebKitDOMNodePrivate.h"
35 #include "WebKitDOMPrivate.h"
36 #include "ConvertToUTF8String.h"
37 #include "WebKitDOMHTMLElementUnstable.h"
38 #include <wtf/GetPtr.h>
39 #include <wtf/RefPtr.h>
40
41 namespace WebKit {
42
43 WebKitDOMHTMLElement* kit(WebCore::HTMLElement* obj)
44 {
45     return WEBKIT_DOM_HTML_ELEMENT(kit(static_cast<WebCore::Node*>(obj)));
46 }
47
48 WebCore::HTMLElement* core(WebKitDOMHTMLElement* request)
49 {
50     return request ? static_cast<WebCore::HTMLElement*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
51 }
52
53 WebKitDOMHTMLElement* wrapHTMLElement(WebCore::HTMLElement* coreObject)
54 {
55     ASSERT(coreObject);
56     return WEBKIT_DOM_HTML_ELEMENT(g_object_new(WEBKIT_DOM_TYPE_HTML_ELEMENT, "core-object", coreObject, nullptr));
57 }
58
59 } // namespace WebKit
60
61 static gboolean webkit_dom_html_element_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error)
62 {
63     WebCore::Event* coreEvent = WebKit::core(event);
64     if (!coreEvent)
65         return false;
66     WebCore::HTMLElement* coreTarget = static_cast<WebCore::HTMLElement*>(WEBKIT_DOM_OBJECT(target)->coreObject);
67
68     auto result = coreTarget->dispatchEventForBindings(*coreEvent);
69     if (result.hasException()) {
70         WebCore::ExceptionCodeDescription description(result.releaseException().code());
71         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name);
72         return false;
73     }
74     return result.releaseReturnValue();
75 }
76
77 static gboolean webkit_dom_html_element_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
78 {
79     WebCore::HTMLElement* coreTarget = static_cast<WebCore::HTMLElement*>(WEBKIT_DOM_OBJECT(target)->coreObject);
80     return WebKit::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
81 }
82
83 static gboolean webkit_dom_html_element_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture)
84 {
85     WebCore::HTMLElement* coreTarget = static_cast<WebCore::HTMLElement*>(WEBKIT_DOM_OBJECT(target)->coreObject);
86     return WebKit::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture);
87 }
88
89 static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface)
90 {
91     iface->dispatch_event = webkit_dom_html_element_dispatch_event;
92     iface->add_event_listener = webkit_dom_html_element_add_event_listener;
93     iface->remove_event_listener = webkit_dom_html_element_remove_event_listener;
94 }
95
96 G_DEFINE_TYPE_WITH_CODE(WebKitDOMHTMLElement, webkit_dom_html_element, WEBKIT_DOM_TYPE_ELEMENT, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkit_dom_event_target_init))
97
98 enum {
99     PROP_0,
100     PROP_TITLE,
101     PROP_LANG,
102     PROP_TRANSLATE,
103     PROP_DIR,
104     PROP_TAB_INDEX,
105     PROP_DRAGGABLE,
106     PROP_WEBKITDROPZONE,
107     PROP_HIDDEN,
108     PROP_ACCESS_KEY,
109     PROP_INNER_TEXT,
110     PROP_OUTER_TEXT,
111     PROP_CONTENT_EDITABLE,
112     PROP_IS_CONTENT_EDITABLE,
113     PROP_SPELLCHECK,
114 };
115
116 static void webkit_dom_html_element_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec)
117 {
118     WebKitDOMHTMLElement* self = WEBKIT_DOM_HTML_ELEMENT(object);
119
120     switch (propertyId) {
121     case PROP_TITLE:
122         webkit_dom_html_element_set_title(self, g_value_get_string(value));
123         break;
124     case PROP_LANG:
125         webkit_dom_html_element_set_lang(self, g_value_get_string(value));
126         break;
127     case PROP_TRANSLATE:
128         webkit_dom_html_element_set_translate(self, g_value_get_boolean(value));
129         break;
130     case PROP_DIR:
131         webkit_dom_html_element_set_dir(self, g_value_get_string(value));
132         break;
133     case PROP_TAB_INDEX:
134         webkit_dom_html_element_set_tab_index(self, g_value_get_long(value));
135         break;
136     case PROP_DRAGGABLE:
137         webkit_dom_html_element_set_draggable(self, g_value_get_boolean(value));
138         break;
139     case PROP_WEBKITDROPZONE:
140         webkit_dom_html_element_set_webkitdropzone(self, g_value_get_string(value));
141         break;
142     case PROP_HIDDEN:
143         webkit_dom_html_element_set_hidden(self, g_value_get_boolean(value));
144         break;
145     case PROP_ACCESS_KEY:
146         webkit_dom_html_element_set_access_key(self, g_value_get_string(value));
147         break;
148     case PROP_INNER_TEXT:
149         webkit_dom_html_element_set_inner_text(self, g_value_get_string(value), nullptr);
150         break;
151     case PROP_OUTER_TEXT:
152         webkit_dom_html_element_set_outer_text(self, g_value_get_string(value), nullptr);
153         break;
154     case PROP_CONTENT_EDITABLE:
155         webkit_dom_html_element_set_content_editable(self, g_value_get_string(value), nullptr);
156         break;
157     case PROP_SPELLCHECK:
158         webkit_dom_html_element_set_spellcheck(self, g_value_get_boolean(value));
159         break;
160     default:
161         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
162         break;
163     }
164 }
165
166 static void webkit_dom_html_element_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
167 {
168     WebKitDOMHTMLElement* self = WEBKIT_DOM_HTML_ELEMENT(object);
169
170     switch (propertyId) {
171     case PROP_TITLE:
172         g_value_take_string(value, webkit_dom_html_element_get_title(self));
173         break;
174     case PROP_LANG:
175         g_value_take_string(value, webkit_dom_html_element_get_lang(self));
176         break;
177     case PROP_TRANSLATE:
178         g_value_set_boolean(value, webkit_dom_html_element_get_translate(self));
179         break;
180     case PROP_DIR:
181         g_value_take_string(value, webkit_dom_html_element_get_dir(self));
182         break;
183     case PROP_TAB_INDEX:
184         g_value_set_long(value, webkit_dom_html_element_get_tab_index(self));
185         break;
186     case PROP_DRAGGABLE:
187         g_value_set_boolean(value, webkit_dom_html_element_get_draggable(self));
188         break;
189     case PROP_WEBKITDROPZONE:
190         g_value_take_string(value, webkit_dom_html_element_get_webkitdropzone(self));
191         break;
192     case PROP_HIDDEN:
193         g_value_set_boolean(value, webkit_dom_html_element_get_hidden(self));
194         break;
195     case PROP_ACCESS_KEY:
196         g_value_take_string(value, webkit_dom_html_element_get_access_key(self));
197         break;
198     case PROP_INNER_TEXT:
199         g_value_take_string(value, webkit_dom_html_element_get_inner_text(self));
200         break;
201     case PROP_OUTER_TEXT:
202         g_value_take_string(value, webkit_dom_html_element_get_outer_text(self));
203         break;
204     case PROP_CONTENT_EDITABLE:
205         g_value_take_string(value, webkit_dom_html_element_get_content_editable(self));
206         break;
207     case PROP_IS_CONTENT_EDITABLE:
208         g_value_set_boolean(value, webkit_dom_html_element_get_is_content_editable(self));
209         break;
210     case PROP_SPELLCHECK:
211         g_value_set_boolean(value, webkit_dom_html_element_get_spellcheck(self));
212         break;
213     default:
214         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
215         break;
216     }
217 }
218
219 static void webkit_dom_html_element_class_init(WebKitDOMHTMLElementClass* requestClass)
220 {
221     GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
222     gobjectClass->set_property = webkit_dom_html_element_set_property;
223     gobjectClass->get_property = webkit_dom_html_element_get_property;
224
225     g_object_class_install_property(
226         gobjectClass,
227         PROP_TITLE,
228         g_param_spec_string(
229             "title",
230             "HTMLElement:title",
231             "read-write gchar* HTMLElement:title",
232             "",
233             WEBKIT_PARAM_READWRITE));
234
235     g_object_class_install_property(
236         gobjectClass,
237         PROP_LANG,
238         g_param_spec_string(
239             "lang",
240             "HTMLElement:lang",
241             "read-write gchar* HTMLElement:lang",
242             "",
243             WEBKIT_PARAM_READWRITE));
244
245     g_object_class_install_property(
246         gobjectClass,
247         PROP_TRANSLATE,
248         g_param_spec_boolean(
249             "translate",
250             "HTMLElement:translate",
251             "read-write gboolean HTMLElement:translate",
252             FALSE,
253             WEBKIT_PARAM_READWRITE));
254
255     g_object_class_install_property(
256         gobjectClass,
257         PROP_DIR,
258         g_param_spec_string(
259             "dir",
260             "HTMLElement:dir",
261             "read-write gchar* HTMLElement:dir",
262             "",
263             WEBKIT_PARAM_READWRITE));
264
265     g_object_class_install_property(
266         gobjectClass,
267         PROP_TAB_INDEX,
268         g_param_spec_long(
269             "tab-index",
270             "HTMLElement:tab-index",
271             "read-write glong HTMLElement:tab-index",
272             G_MINLONG, G_MAXLONG, 0,
273             WEBKIT_PARAM_READWRITE));
274
275     g_object_class_install_property(
276         gobjectClass,
277         PROP_DRAGGABLE,
278         g_param_spec_boolean(
279             "draggable",
280             "HTMLElement:draggable",
281             "read-write gboolean HTMLElement:draggable",
282             FALSE,
283             WEBKIT_PARAM_READWRITE));
284
285     g_object_class_install_property(
286         gobjectClass,
287         PROP_WEBKITDROPZONE,
288         g_param_spec_string(
289             "webkitdropzone",
290             "HTMLElement:webkitdropzone",
291             "read-write gchar* HTMLElement:webkitdropzone",
292             "",
293             WEBKIT_PARAM_READWRITE));
294
295     g_object_class_install_property(
296         gobjectClass,
297         PROP_HIDDEN,
298         g_param_spec_boolean(
299             "hidden",
300             "HTMLElement:hidden",
301             "read-write gboolean HTMLElement:hidden",
302             FALSE,
303             WEBKIT_PARAM_READWRITE));
304
305     g_object_class_install_property(
306         gobjectClass,
307         PROP_ACCESS_KEY,
308         g_param_spec_string(
309             "access-key",
310             "HTMLElement:access-key",
311             "read-write gchar* HTMLElement:access-key",
312             "",
313             WEBKIT_PARAM_READWRITE));
314
315     g_object_class_install_property(
316         gobjectClass,
317         PROP_INNER_TEXT,
318         g_param_spec_string(
319             "inner-text",
320             "HTMLElement:inner-text",
321             "read-write gchar* HTMLElement:inner-text",
322             "",
323             WEBKIT_PARAM_READWRITE));
324
325     g_object_class_install_property(
326         gobjectClass,
327         PROP_OUTER_TEXT,
328         g_param_spec_string(
329             "outer-text",
330             "HTMLElement:outer-text",
331             "read-write gchar* HTMLElement:outer-text",
332             "",
333             WEBKIT_PARAM_READWRITE));
334
335     g_object_class_install_property(
336         gobjectClass,
337         PROP_CONTENT_EDITABLE,
338         g_param_spec_string(
339             "content-editable",
340             "HTMLElement:content-editable",
341             "read-write gchar* HTMLElement:content-editable",
342             "",
343             WEBKIT_PARAM_READWRITE));
344
345     g_object_class_install_property(
346         gobjectClass,
347         PROP_IS_CONTENT_EDITABLE,
348         g_param_spec_boolean(
349             "is-content-editable",
350             "HTMLElement:is-content-editable",
351             "read-only gboolean HTMLElement:is-content-editable",
352             FALSE,
353             WEBKIT_PARAM_READABLE));
354
355     g_object_class_install_property(
356         gobjectClass,
357         PROP_SPELLCHECK,
358         g_param_spec_boolean(
359             "spellcheck",
360             "HTMLElement:spellcheck",
361             "read-write gboolean HTMLElement:spellcheck",
362             FALSE,
363             WEBKIT_PARAM_READWRITE));
364
365 }
366
367 static void webkit_dom_html_element_init(WebKitDOMHTMLElement* request)
368 {
369     UNUSED_PARAM(request);
370 }
371
372 void webkit_dom_html_element_click(WebKitDOMHTMLElement* self)
373 {
374     WebCore::JSMainThreadNullState state;
375     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
376     WebCore::HTMLElement* item = WebKit::core(self);
377     item->click();
378 }
379
380 gchar* webkit_dom_html_element_get_title(WebKitDOMHTMLElement* self)
381 {
382     WebCore::JSMainThreadNullState state;
383     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
384     WebCore::HTMLElement* item = WebKit::core(self);
385     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::titleAttr));
386     return result;
387 }
388
389 void webkit_dom_html_element_set_title(WebKitDOMHTMLElement* self, const gchar* value)
390 {
391     WebCore::JSMainThreadNullState state;
392     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
393     g_return_if_fail(value);
394     WebCore::HTMLElement* item = WebKit::core(self);
395     WTF::String convertedValue = WTF::String::fromUTF8(value);
396     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::titleAttr, convertedValue);
397 }
398
399 gchar* webkit_dom_html_element_get_lang(WebKitDOMHTMLElement* self)
400 {
401     WebCore::JSMainThreadNullState state;
402     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
403     WebCore::HTMLElement* item = WebKit::core(self);
404     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::langAttr));
405     return result;
406 }
407
408 void webkit_dom_html_element_set_lang(WebKitDOMHTMLElement* self, const gchar* value)
409 {
410     WebCore::JSMainThreadNullState state;
411     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
412     g_return_if_fail(value);
413     WebCore::HTMLElement* item = WebKit::core(self);
414     WTF::String convertedValue = WTF::String::fromUTF8(value);
415     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::langAttr, convertedValue);
416 }
417
418 gboolean webkit_dom_html_element_get_translate(WebKitDOMHTMLElement* self)
419 {
420     WebCore::JSMainThreadNullState state;
421     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), FALSE);
422     WebCore::HTMLElement* item = WebKit::core(self);
423     gboolean result = item->translate();
424     return result;
425 }
426
427 void webkit_dom_html_element_set_translate(WebKitDOMHTMLElement* self, gboolean value)
428 {
429     WebCore::JSMainThreadNullState state;
430     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
431     WebCore::HTMLElement* item = WebKit::core(self);
432     item->setTranslate(value);
433 }
434
435 gchar* webkit_dom_html_element_get_dir(WebKitDOMHTMLElement* self)
436 {
437     WebCore::JSMainThreadNullState state;
438     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
439     WebCore::HTMLElement* item = WebKit::core(self);
440     gchar* result = convertToUTF8String(item->dir());
441     return result;
442 }
443
444 void webkit_dom_html_element_set_dir(WebKitDOMHTMLElement* self, const gchar* value)
445 {
446     WebCore::JSMainThreadNullState state;
447     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
448     g_return_if_fail(value);
449     WebCore::HTMLElement* item = WebKit::core(self);
450     WTF::String convertedValue = WTF::String::fromUTF8(value);
451     item->setDir(convertedValue);
452 }
453
454 glong webkit_dom_html_element_get_tab_index(WebKitDOMHTMLElement* self)
455 {
456     WebCore::JSMainThreadNullState state;
457     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
458     WebCore::HTMLElement* item = WebKit::core(self);
459     glong result = item->tabIndex();
460     return result;
461 }
462
463 void webkit_dom_html_element_set_tab_index(WebKitDOMHTMLElement* self, glong value)
464 {
465     WebCore::JSMainThreadNullState state;
466     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
467     WebCore::HTMLElement* item = WebKit::core(self);
468     item->setTabIndex(value);
469 }
470
471 gboolean webkit_dom_html_element_get_draggable(WebKitDOMHTMLElement* self)
472 {
473     WebCore::JSMainThreadNullState state;
474     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), FALSE);
475     WebCore::HTMLElement* item = WebKit::core(self);
476     gboolean result = item->draggable();
477     return result;
478 }
479
480 void webkit_dom_html_element_set_draggable(WebKitDOMHTMLElement* self, gboolean value)
481 {
482     WebCore::JSMainThreadNullState state;
483     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
484     WebCore::HTMLElement* item = WebKit::core(self);
485     item->setDraggable(value);
486 }
487
488 gchar* webkit_dom_html_element_get_webkitdropzone(WebKitDOMHTMLElement* self)
489 {
490     WebCore::JSMainThreadNullState state;
491     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
492     WebCore::HTMLElement* item = WebKit::core(self);
493     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::webkitdropzoneAttr));
494     return result;
495 }
496
497 void webkit_dom_html_element_set_webkitdropzone(WebKitDOMHTMLElement* self, const gchar* value)
498 {
499     WebCore::JSMainThreadNullState state;
500     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
501     g_return_if_fail(value);
502     WebCore::HTMLElement* item = WebKit::core(self);
503     WTF::String convertedValue = WTF::String::fromUTF8(value);
504     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::webkitdropzoneAttr, convertedValue);
505 }
506
507 gboolean webkit_dom_html_element_get_hidden(WebKitDOMHTMLElement* self)
508 {
509     WebCore::JSMainThreadNullState state;
510     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), FALSE);
511     WebCore::HTMLElement* item = WebKit::core(self);
512     gboolean result = item->hasAttributeWithoutSynchronization(WebCore::HTMLNames::hiddenAttr);
513     return result;
514 }
515
516 void webkit_dom_html_element_set_hidden(WebKitDOMHTMLElement* self, gboolean value)
517 {
518     WebCore::JSMainThreadNullState state;
519     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
520     WebCore::HTMLElement* item = WebKit::core(self);
521     item->setBooleanAttribute(WebCore::HTMLNames::hiddenAttr, value);
522 }
523
524 gchar* webkit_dom_html_element_get_access_key(WebKitDOMHTMLElement* self)
525 {
526     WebCore::JSMainThreadNullState state;
527     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
528     WebCore::HTMLElement* item = WebKit::core(self);
529     gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::accesskeyAttr));
530     return result;
531 }
532
533 void webkit_dom_html_element_set_access_key(WebKitDOMHTMLElement* self, const gchar* value)
534 {
535     WebCore::JSMainThreadNullState state;
536     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
537     g_return_if_fail(value);
538     WebCore::HTMLElement* item = WebKit::core(self);
539     WTF::String convertedValue = WTF::String::fromUTF8(value);
540     item->setAttributeWithoutSynchronization(WebCore::HTMLNames::accesskeyAttr, convertedValue);
541 }
542
543 gchar* webkit_dom_html_element_get_inner_text(WebKitDOMHTMLElement* self)
544 {
545     WebCore::JSMainThreadNullState state;
546     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
547     WebCore::HTMLElement* item = WebKit::core(self);
548     gchar* result = convertToUTF8String(item->innerText());
549     return result;
550 }
551
552 void webkit_dom_html_element_set_inner_text(WebKitDOMHTMLElement* self, const gchar* value, GError** error)
553 {
554     WebCore::JSMainThreadNullState state;
555     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
556     g_return_if_fail(value);
557     g_return_if_fail(!error || !*error);
558     WebCore::HTMLElement* item = WebKit::core(self);
559     WTF::String convertedValue = WTF::String::fromUTF8(value);
560     auto result = item->setInnerText(convertedValue);
561     if (result.hasException()) {
562         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
563         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
564     }
565 }
566
567 gchar* webkit_dom_html_element_get_outer_text(WebKitDOMHTMLElement* self)
568 {
569     WebCore::JSMainThreadNullState state;
570     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
571     WebCore::HTMLElement* item = WebKit::core(self);
572     gchar* result = convertToUTF8String(item->outerText());
573     return result;
574 }
575
576 void webkit_dom_html_element_set_outer_text(WebKitDOMHTMLElement* self, const gchar* value, GError** error)
577 {
578     WebCore::JSMainThreadNullState state;
579     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
580     g_return_if_fail(value);
581     g_return_if_fail(!error || !*error);
582     WebCore::HTMLElement* item = WebKit::core(self);
583     WTF::String convertedValue = WTF::String::fromUTF8(value);
584     auto result = item->setOuterText(convertedValue);
585     if (result.hasException()) {
586         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
587         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
588     }
589 }
590
591 gchar* webkit_dom_html_element_get_content_editable(WebKitDOMHTMLElement* self)
592 {
593     WebCore::JSMainThreadNullState state;
594     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), 0);
595     WebCore::HTMLElement* item = WebKit::core(self);
596     gchar* result = convertToUTF8String(item->contentEditable());
597     return result;
598 }
599
600 void webkit_dom_html_element_set_content_editable(WebKitDOMHTMLElement* self, const gchar* value, GError** error)
601 {
602     WebCore::JSMainThreadNullState state;
603     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
604     g_return_if_fail(value);
605     g_return_if_fail(!error || !*error);
606     WebCore::HTMLElement* item = WebKit::core(self);
607     WTF::String convertedValue = WTF::String::fromUTF8(value);
608     auto result = item->setContentEditable(convertedValue);
609     if (result.hasException()) {
610         WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
611         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
612     }
613 }
614
615 gboolean webkit_dom_html_element_get_is_content_editable(WebKitDOMHTMLElement* self)
616 {
617     WebCore::JSMainThreadNullState state;
618     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), FALSE);
619     WebCore::HTMLElement* item = WebKit::core(self);
620     gboolean result = item->isContentEditable();
621     return result;
622 }
623
624 gboolean webkit_dom_html_element_get_spellcheck(WebKitDOMHTMLElement* self)
625 {
626     WebCore::JSMainThreadNullState state;
627     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self), FALSE);
628     WebCore::HTMLElement* item = WebKit::core(self);
629     gboolean result = item->spellcheck();
630     return result;
631 }
632
633 void webkit_dom_html_element_set_spellcheck(WebKitDOMHTMLElement* self, gboolean value)
634 {
635     WebCore::JSMainThreadNullState state;
636     g_return_if_fail(WEBKIT_DOM_IS_HTML_ELEMENT(self));
637     WebCore::HTMLElement* item = WebKit::core(self);
638     item->setSpellcheck(value);
639 }
640