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 "WebKitDOMHTMLTableColElement.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 "WebKitDOMHTMLTableColElementPrivate.h" |
33 | #include "WebKitDOMNodePrivate.h" |
34 | #include "WebKitDOMPrivate.h" |
35 | #include "ConvertToUTF8String.h" |
36 | #include <wtf/GetPtr.h> |
37 | #include <wtf/RefPtr.h> |
38 | |
39 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
40 | |
41 | namespace WebKit { |
42 | |
43 | WebKitDOMHTMLTableColElement* kit(WebCore::HTMLTableColElement* obj) |
44 | { |
45 | return WEBKIT_DOM_HTML_TABLE_COL_ELEMENT(kit(static_cast<WebCore::Node*>(obj))); |
46 | } |
47 | |
48 | WebCore::HTMLTableColElement* core(WebKitDOMHTMLTableColElement* request) |
49 | { |
50 | return request ? static_cast<WebCore::HTMLTableColElement*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0; |
51 | } |
52 | |
53 | WebKitDOMHTMLTableColElement* wrapHTMLTableColElement(WebCore::HTMLTableColElement* coreObject) |
54 | { |
55 | ASSERT(coreObject); |
56 | return WEBKIT_DOM_HTML_TABLE_COL_ELEMENT(g_object_new(WEBKIT_DOM_TYPE_HTML_TABLE_COL_ELEMENT, "core-object" , coreObject, nullptr)); |
57 | } |
58 | |
59 | } // namespace WebKit |
60 | |
61 | static gboolean webkit_dom_html_table_col_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::HTMLTableColElement* coreTarget = static_cast<WebCore::HTMLTableColElement*>(WEBKIT_DOM_OBJECT(target)->coreObject); |
67 | |
68 | auto result = coreTarget->dispatchEventForBindings(*coreEvent); |
69 | if (result.hasException()) { |
70 | auto description = WebCore::DOMException::description(result.releaseException().code()); |
71 | g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM" ), description.legacyCode, description.name); |
72 | return false; |
73 | } |
74 | return result.releaseReturnValue(); |
75 | } |
76 | |
77 | static gboolean webkit_dom_html_table_col_element_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture) |
78 | { |
79 | WebCore::HTMLTableColElement* coreTarget = static_cast<WebCore::HTMLTableColElement*>(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_table_col_element_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GClosure* handler, gboolean useCapture) |
84 | { |
85 | WebCore::HTMLTableColElement* coreTarget = static_cast<WebCore::HTMLTableColElement*>(WEBKIT_DOM_OBJECT(target)->coreObject); |
86 | return WebKit::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, useCapture); |
87 | } |
88 | |
89 | static void webkit_dom_html_table_col_element_dom_event_target_init(WebKitDOMEventTargetIface* iface) |
90 | { |
91 | iface->dispatch_event = webkit_dom_html_table_col_element_dispatch_event; |
92 | iface->add_event_listener = webkit_dom_html_table_col_element_add_event_listener; |
93 | iface->remove_event_listener = webkit_dom_html_table_col_element_remove_event_listener; |
94 | } |
95 | |
96 | G_DEFINE_TYPE_WITH_CODE(WebKitDOMHTMLTableColElement, webkit_dom_html_table_col_element, WEBKIT_DOM_TYPE_HTML_ELEMENT, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_EVENT_TARGET, webkit_dom_html_table_col_element_dom_event_target_init)) |
97 | |
98 | enum { |
99 | DOM_HTML_TABLE_COL_ELEMENT_PROP_0, |
100 | DOM_HTML_TABLE_COL_ELEMENT_PROP_ALIGN, |
101 | DOM_HTML_TABLE_COL_ELEMENT_PROP_CH, |
102 | DOM_HTML_TABLE_COL_ELEMENT_PROP_CH_OFF, |
103 | DOM_HTML_TABLE_COL_ELEMENT_PROP_SPAN, |
104 | DOM_HTML_TABLE_COL_ELEMENT_PROP_V_ALIGN, |
105 | DOM_HTML_TABLE_COL_ELEMENT_PROP_WIDTH, |
106 | }; |
107 | |
108 | static void webkit_dom_html_table_col_element_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) |
109 | { |
110 | WebKitDOMHTMLTableColElement* self = WEBKIT_DOM_HTML_TABLE_COL_ELEMENT(object); |
111 | |
112 | switch (propertyId) { |
113 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_ALIGN: |
114 | webkit_dom_html_table_col_element_set_align(self, g_value_get_string(value)); |
115 | break; |
116 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_CH: |
117 | webkit_dom_html_table_col_element_set_ch(self, g_value_get_string(value)); |
118 | break; |
119 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_CH_OFF: |
120 | webkit_dom_html_table_col_element_set_ch_off(self, g_value_get_string(value)); |
121 | break; |
122 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_SPAN: |
123 | webkit_dom_html_table_col_element_set_span(self, g_value_get_long(value)); |
124 | break; |
125 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_V_ALIGN: |
126 | webkit_dom_html_table_col_element_set_v_align(self, g_value_get_string(value)); |
127 | break; |
128 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_WIDTH: |
129 | webkit_dom_html_table_col_element_set_width(self, g_value_get_string(value)); |
130 | break; |
131 | default: |
132 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); |
133 | break; |
134 | } |
135 | } |
136 | |
137 | static void webkit_dom_html_table_col_element_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) |
138 | { |
139 | WebKitDOMHTMLTableColElement* self = WEBKIT_DOM_HTML_TABLE_COL_ELEMENT(object); |
140 | |
141 | switch (propertyId) { |
142 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_ALIGN: |
143 | g_value_take_string(value, webkit_dom_html_table_col_element_get_align(self)); |
144 | break; |
145 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_CH: |
146 | g_value_take_string(value, webkit_dom_html_table_col_element_get_ch(self)); |
147 | break; |
148 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_CH_OFF: |
149 | g_value_take_string(value, webkit_dom_html_table_col_element_get_ch_off(self)); |
150 | break; |
151 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_SPAN: |
152 | g_value_set_long(value, webkit_dom_html_table_col_element_get_span(self)); |
153 | break; |
154 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_V_ALIGN: |
155 | g_value_take_string(value, webkit_dom_html_table_col_element_get_v_align(self)); |
156 | break; |
157 | case DOM_HTML_TABLE_COL_ELEMENT_PROP_WIDTH: |
158 | g_value_take_string(value, webkit_dom_html_table_col_element_get_width(self)); |
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_table_col_element_class_init(WebKitDOMHTMLTableColElementClass* requestClass) |
167 | { |
168 | GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); |
169 | gobjectClass->set_property = webkit_dom_html_table_col_element_set_property; |
170 | gobjectClass->get_property = webkit_dom_html_table_col_element_get_property; |
171 | |
172 | g_object_class_install_property( |
173 | gobjectClass, |
174 | DOM_HTML_TABLE_COL_ELEMENT_PROP_ALIGN, |
175 | g_param_spec_string( |
176 | "align" , |
177 | "HTMLTableColElement:align" , |
178 | "read-write gchar* HTMLTableColElement:align" , |
179 | "" , |
180 | WEBKIT_PARAM_READWRITE)); |
181 | |
182 | g_object_class_install_property( |
183 | gobjectClass, |
184 | DOM_HTML_TABLE_COL_ELEMENT_PROP_CH, |
185 | g_param_spec_string( |
186 | "ch" , |
187 | "HTMLTableColElement:ch" , |
188 | "read-write gchar* HTMLTableColElement:ch" , |
189 | "" , |
190 | WEBKIT_PARAM_READWRITE)); |
191 | |
192 | g_object_class_install_property( |
193 | gobjectClass, |
194 | DOM_HTML_TABLE_COL_ELEMENT_PROP_CH_OFF, |
195 | g_param_spec_string( |
196 | "ch-off" , |
197 | "HTMLTableColElement:ch-off" , |
198 | "read-write gchar* HTMLTableColElement:ch-off" , |
199 | "" , |
200 | WEBKIT_PARAM_READWRITE)); |
201 | |
202 | g_object_class_install_property( |
203 | gobjectClass, |
204 | DOM_HTML_TABLE_COL_ELEMENT_PROP_SPAN, |
205 | g_param_spec_long( |
206 | "span" , |
207 | "HTMLTableColElement:span" , |
208 | "read-write glong HTMLTableColElement:span" , |
209 | G_MINLONG, G_MAXLONG, 0, |
210 | WEBKIT_PARAM_READWRITE)); |
211 | |
212 | g_object_class_install_property( |
213 | gobjectClass, |
214 | DOM_HTML_TABLE_COL_ELEMENT_PROP_V_ALIGN, |
215 | g_param_spec_string( |
216 | "v-align" , |
217 | "HTMLTableColElement:v-align" , |
218 | "read-write gchar* HTMLTableColElement:v-align" , |
219 | "" , |
220 | WEBKIT_PARAM_READWRITE)); |
221 | |
222 | g_object_class_install_property( |
223 | gobjectClass, |
224 | DOM_HTML_TABLE_COL_ELEMENT_PROP_WIDTH, |
225 | g_param_spec_string( |
226 | "width" , |
227 | "HTMLTableColElement:width" , |
228 | "read-write gchar* HTMLTableColElement:width" , |
229 | "" , |
230 | WEBKIT_PARAM_READWRITE)); |
231 | |
232 | } |
233 | |
234 | static void webkit_dom_html_table_col_element_init(WebKitDOMHTMLTableColElement* request) |
235 | { |
236 | UNUSED_PARAM(request); |
237 | } |
238 | |
239 | gchar* webkit_dom_html_table_col_element_get_align(WebKitDOMHTMLTableColElement* self) |
240 | { |
241 | WebCore::JSMainThreadNullState state; |
242 | g_return_val_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self), 0); |
243 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
244 | gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::alignAttr)); |
245 | return result; |
246 | } |
247 | |
248 | void webkit_dom_html_table_col_element_set_align(WebKitDOMHTMLTableColElement* self, const gchar* value) |
249 | { |
250 | WebCore::JSMainThreadNullState state; |
251 | g_return_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self)); |
252 | g_return_if_fail(value); |
253 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
254 | WTF::String convertedValue = WTF::String::fromUTF8(value); |
255 | item->setAttributeWithoutSynchronization(WebCore::HTMLNames::alignAttr, convertedValue); |
256 | } |
257 | |
258 | gchar* webkit_dom_html_table_col_element_get_ch(WebKitDOMHTMLTableColElement* self) |
259 | { |
260 | WebCore::JSMainThreadNullState state; |
261 | g_return_val_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self), 0); |
262 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
263 | gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::charAttr)); |
264 | return result; |
265 | } |
266 | |
267 | void webkit_dom_html_table_col_element_set_ch(WebKitDOMHTMLTableColElement* self, const gchar* value) |
268 | { |
269 | WebCore::JSMainThreadNullState state; |
270 | g_return_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self)); |
271 | g_return_if_fail(value); |
272 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
273 | WTF::String convertedValue = WTF::String::fromUTF8(value); |
274 | item->setAttributeWithoutSynchronization(WebCore::HTMLNames::charAttr, convertedValue); |
275 | } |
276 | |
277 | gchar* webkit_dom_html_table_col_element_get_ch_off(WebKitDOMHTMLTableColElement* self) |
278 | { |
279 | WebCore::JSMainThreadNullState state; |
280 | g_return_val_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self), 0); |
281 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
282 | gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::charoffAttr)); |
283 | return result; |
284 | } |
285 | |
286 | void webkit_dom_html_table_col_element_set_ch_off(WebKitDOMHTMLTableColElement* self, const gchar* value) |
287 | { |
288 | WebCore::JSMainThreadNullState state; |
289 | g_return_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self)); |
290 | g_return_if_fail(value); |
291 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
292 | WTF::String convertedValue = WTF::String::fromUTF8(value); |
293 | item->setAttributeWithoutSynchronization(WebCore::HTMLNames::charoffAttr, convertedValue); |
294 | } |
295 | |
296 | glong webkit_dom_html_table_col_element_get_span(WebKitDOMHTMLTableColElement* self) |
297 | { |
298 | WebCore::JSMainThreadNullState state; |
299 | g_return_val_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self), 0); |
300 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
301 | glong result = item->span(); |
302 | return result; |
303 | } |
304 | |
305 | void webkit_dom_html_table_col_element_set_span(WebKitDOMHTMLTableColElement* self, glong value) |
306 | { |
307 | WebCore::JSMainThreadNullState state; |
308 | g_return_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self)); |
309 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
310 | item->setSpan(value); |
311 | } |
312 | |
313 | gchar* webkit_dom_html_table_col_element_get_v_align(WebKitDOMHTMLTableColElement* self) |
314 | { |
315 | WebCore::JSMainThreadNullState state; |
316 | g_return_val_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self), 0); |
317 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
318 | gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::valignAttr)); |
319 | return result; |
320 | } |
321 | |
322 | void webkit_dom_html_table_col_element_set_v_align(WebKitDOMHTMLTableColElement* self, const gchar* value) |
323 | { |
324 | WebCore::JSMainThreadNullState state; |
325 | g_return_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self)); |
326 | g_return_if_fail(value); |
327 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
328 | WTF::String convertedValue = WTF::String::fromUTF8(value); |
329 | item->setAttributeWithoutSynchronization(WebCore::HTMLNames::valignAttr, convertedValue); |
330 | } |
331 | |
332 | gchar* webkit_dom_html_table_col_element_get_width(WebKitDOMHTMLTableColElement* self) |
333 | { |
334 | WebCore::JSMainThreadNullState state; |
335 | g_return_val_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self), 0); |
336 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
337 | gchar* result = convertToUTF8String(item->attributeWithoutSynchronization(WebCore::HTMLNames::widthAttr)); |
338 | return result; |
339 | } |
340 | |
341 | void webkit_dom_html_table_col_element_set_width(WebKitDOMHTMLTableColElement* self, const gchar* value) |
342 | { |
343 | WebCore::JSMainThreadNullState state; |
344 | g_return_if_fail(WEBKIT_DOM_IS_HTML_TABLE_COL_ELEMENT(self)); |
345 | g_return_if_fail(value); |
346 | WebCore::HTMLTableColElement* item = WebKit::core(self); |
347 | WTF::String convertedValue = WTF::String::fromUTF8(value); |
348 | item->setAttributeWithoutSynchronization(WebCore::HTMLNames::widthAttr, convertedValue); |
349 | } |
350 | |
351 | G_GNUC_END_IGNORE_DEPRECATIONS; |
352 | |