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