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