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 "WebKitDOMDOMSelection.h" |
22 | |
23 | #include <WebCore/CSSImportRule.h> |
24 | #include "DOMObjectCache.h" |
25 | #include <WebCore/DOMException.h> |
26 | #include <WebCore/Document.h> |
27 | #include <WebCore/JSExecState.h> |
28 | #include "WebKitDOMDOMSelectionPrivate.h" |
29 | #include "WebKitDOMNodePrivate.h" |
30 | #include "WebKitDOMPrivate.h" |
31 | #include "WebKitDOMRangePrivate.h" |
32 | #include "ConvertToUTF8String.h" |
33 | #include <wtf/GetPtr.h> |
34 | #include <wtf/RefPtr.h> |
35 | |
36 | #define WEBKIT_DOM_DOM_SELECTION_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_DOM_TYPE_DOM_SELECTION, WebKitDOMDOMSelectionPrivate) |
37 | |
38 | typedef struct _WebKitDOMDOMSelectionPrivate { |
39 | RefPtr<WebCore::DOMSelection> coreObject; |
40 | } WebKitDOMDOMSelectionPrivate; |
41 | |
42 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
43 | |
44 | namespace WebKit { |
45 | |
46 | WebKitDOMDOMSelection* kit(WebCore::DOMSelection* obj) |
47 | { |
48 | if (!obj) |
49 | return 0; |
50 | |
51 | if (gpointer ret = DOMObjectCache::get(obj)) |
52 | return WEBKIT_DOM_DOM_SELECTION(ret); |
53 | |
54 | return wrapDOMSelection(obj); |
55 | } |
56 | |
57 | WebCore::DOMSelection* core(WebKitDOMDOMSelection* request) |
58 | { |
59 | return request ? static_cast<WebCore::DOMSelection*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0; |
60 | } |
61 | |
62 | WebKitDOMDOMSelection* wrapDOMSelection(WebCore::DOMSelection* coreObject) |
63 | { |
64 | ASSERT(coreObject); |
65 | return WEBKIT_DOM_DOM_SELECTION(g_object_new(WEBKIT_DOM_TYPE_DOM_SELECTION, "core-object" , coreObject, nullptr)); |
66 | } |
67 | |
68 | } // namespace WebKit |
69 | |
70 | G_DEFINE_TYPE(WebKitDOMDOMSelection, webkit_dom_dom_selection, WEBKIT_DOM_TYPE_OBJECT) |
71 | |
72 | enum { |
73 | DOM_DOM_SELECTION_PROP_0, |
74 | DOM_DOM_SELECTION_PROP_ANCHOR_NODE, |
75 | DOM_DOM_SELECTION_PROP_ANCHOR_OFFSET, |
76 | DOM_DOM_SELECTION_PROP_FOCUS_NODE, |
77 | DOM_DOM_SELECTION_PROP_FOCUS_OFFSET, |
78 | DOM_DOM_SELECTION_PROP_IS_COLLAPSED, |
79 | DOM_DOM_SELECTION_PROP_RANGE_COUNT, |
80 | DOM_DOM_SELECTION_PROP_TYPE, |
81 | DOM_DOM_SELECTION_PROP_BASE_NODE, |
82 | DOM_DOM_SELECTION_PROP_BASE_OFFSET, |
83 | DOM_DOM_SELECTION_PROP_EXTENT_NODE, |
84 | DOM_DOM_SELECTION_PROP_EXTENT_OFFSET, |
85 | }; |
86 | |
87 | static void webkit_dom_dom_selection_finalize(GObject* object) |
88 | { |
89 | WebKitDOMDOMSelectionPrivate* priv = WEBKIT_DOM_DOM_SELECTION_GET_PRIVATE(object); |
90 | |
91 | WebKit::DOMObjectCache::forget(priv->coreObject.get()); |
92 | |
93 | priv->~WebKitDOMDOMSelectionPrivate(); |
94 | G_OBJECT_CLASS(webkit_dom_dom_selection_parent_class)->finalize(object); |
95 | } |
96 | |
97 | static void webkit_dom_dom_selection_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) |
98 | { |
99 | WebKitDOMDOMSelection* self = WEBKIT_DOM_DOM_SELECTION(object); |
100 | |
101 | switch (propertyId) { |
102 | case DOM_DOM_SELECTION_PROP_ANCHOR_NODE: |
103 | g_value_set_object(value, webkit_dom_dom_selection_get_anchor_node(self)); |
104 | break; |
105 | case DOM_DOM_SELECTION_PROP_ANCHOR_OFFSET: |
106 | g_value_set_ulong(value, webkit_dom_dom_selection_get_anchor_offset(self)); |
107 | break; |
108 | case DOM_DOM_SELECTION_PROP_FOCUS_NODE: |
109 | g_value_set_object(value, webkit_dom_dom_selection_get_focus_node(self)); |
110 | break; |
111 | case DOM_DOM_SELECTION_PROP_FOCUS_OFFSET: |
112 | g_value_set_ulong(value, webkit_dom_dom_selection_get_focus_offset(self)); |
113 | break; |
114 | case DOM_DOM_SELECTION_PROP_IS_COLLAPSED: |
115 | g_value_set_boolean(value, webkit_dom_dom_selection_get_is_collapsed(self)); |
116 | break; |
117 | case DOM_DOM_SELECTION_PROP_RANGE_COUNT: |
118 | g_value_set_ulong(value, webkit_dom_dom_selection_get_range_count(self)); |
119 | break; |
120 | case DOM_DOM_SELECTION_PROP_TYPE: |
121 | g_value_take_string(value, webkit_dom_dom_selection_get_selection_type(self)); |
122 | break; |
123 | case DOM_DOM_SELECTION_PROP_BASE_NODE: |
124 | g_value_set_object(value, webkit_dom_dom_selection_get_base_node(self)); |
125 | break; |
126 | case DOM_DOM_SELECTION_PROP_BASE_OFFSET: |
127 | g_value_set_ulong(value, webkit_dom_dom_selection_get_base_offset(self)); |
128 | break; |
129 | case DOM_DOM_SELECTION_PROP_EXTENT_NODE: |
130 | g_value_set_object(value, webkit_dom_dom_selection_get_extent_node(self)); |
131 | break; |
132 | case DOM_DOM_SELECTION_PROP_EXTENT_OFFSET: |
133 | g_value_set_ulong(value, webkit_dom_dom_selection_get_extent_offset(self)); |
134 | break; |
135 | default: |
136 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); |
137 | break; |
138 | } |
139 | } |
140 | |
141 | static GObject* webkit_dom_dom_selection_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties) |
142 | { |
143 | GObject* object = G_OBJECT_CLASS(webkit_dom_dom_selection_parent_class)->constructor(type, constructPropertiesCount, constructProperties); |
144 | |
145 | WebKitDOMDOMSelectionPrivate* priv = WEBKIT_DOM_DOM_SELECTION_GET_PRIVATE(object); |
146 | priv->coreObject = static_cast<WebCore::DOMSelection*>(WEBKIT_DOM_OBJECT(object)->coreObject); |
147 | WebKit::DOMObjectCache::put(priv->coreObject.get(), object); |
148 | |
149 | return object; |
150 | } |
151 | |
152 | static void webkit_dom_dom_selection_class_init(WebKitDOMDOMSelectionClass* requestClass) |
153 | { |
154 | GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); |
155 | g_type_class_add_private(gobjectClass, sizeof(WebKitDOMDOMSelectionPrivate)); |
156 | gobjectClass->constructor = webkit_dom_dom_selection_constructor; |
157 | gobjectClass->finalize = webkit_dom_dom_selection_finalize; |
158 | gobjectClass->get_property = webkit_dom_dom_selection_get_property; |
159 | |
160 | g_object_class_install_property( |
161 | gobjectClass, |
162 | DOM_DOM_SELECTION_PROP_ANCHOR_NODE, |
163 | g_param_spec_object( |
164 | "anchor-node" , |
165 | "DOMSelection:anchor-node" , |
166 | "read-only WebKitDOMNode* DOMSelection:anchor-node" , |
167 | WEBKIT_DOM_TYPE_NODE, |
168 | WEBKIT_PARAM_READABLE)); |
169 | |
170 | g_object_class_install_property( |
171 | gobjectClass, |
172 | DOM_DOM_SELECTION_PROP_ANCHOR_OFFSET, |
173 | g_param_spec_ulong( |
174 | "anchor-offset" , |
175 | "DOMSelection:anchor-offset" , |
176 | "read-only gulong DOMSelection:anchor-offset" , |
177 | 0, G_MAXULONG, 0, |
178 | WEBKIT_PARAM_READABLE)); |
179 | |
180 | g_object_class_install_property( |
181 | gobjectClass, |
182 | DOM_DOM_SELECTION_PROP_FOCUS_NODE, |
183 | g_param_spec_object( |
184 | "focus-node" , |
185 | "DOMSelection:focus-node" , |
186 | "read-only WebKitDOMNode* DOMSelection:focus-node" , |
187 | WEBKIT_DOM_TYPE_NODE, |
188 | WEBKIT_PARAM_READABLE)); |
189 | |
190 | g_object_class_install_property( |
191 | gobjectClass, |
192 | DOM_DOM_SELECTION_PROP_FOCUS_OFFSET, |
193 | g_param_spec_ulong( |
194 | "focus-offset" , |
195 | "DOMSelection:focus-offset" , |
196 | "read-only gulong DOMSelection:focus-offset" , |
197 | 0, G_MAXULONG, 0, |
198 | WEBKIT_PARAM_READABLE)); |
199 | |
200 | g_object_class_install_property( |
201 | gobjectClass, |
202 | DOM_DOM_SELECTION_PROP_IS_COLLAPSED, |
203 | g_param_spec_boolean( |
204 | "is-collapsed" , |
205 | "DOMSelection:is-collapsed" , |
206 | "read-only gboolean DOMSelection:is-collapsed" , |
207 | FALSE, |
208 | WEBKIT_PARAM_READABLE)); |
209 | |
210 | g_object_class_install_property( |
211 | gobjectClass, |
212 | DOM_DOM_SELECTION_PROP_RANGE_COUNT, |
213 | g_param_spec_ulong( |
214 | "range-count" , |
215 | "DOMSelection:range-count" , |
216 | "read-only gulong DOMSelection:range-count" , |
217 | 0, G_MAXULONG, 0, |
218 | WEBKIT_PARAM_READABLE)); |
219 | |
220 | g_object_class_install_property( |
221 | gobjectClass, |
222 | DOM_DOM_SELECTION_PROP_TYPE, |
223 | g_param_spec_string( |
224 | "type" , |
225 | "DOMSelection:type" , |
226 | "read-only gchar* DOMSelection:type" , |
227 | "" , |
228 | WEBKIT_PARAM_READABLE)); |
229 | |
230 | g_object_class_install_property( |
231 | gobjectClass, |
232 | DOM_DOM_SELECTION_PROP_BASE_NODE, |
233 | g_param_spec_object( |
234 | "base-node" , |
235 | "DOMSelection:base-node" , |
236 | "read-only WebKitDOMNode* DOMSelection:base-node" , |
237 | WEBKIT_DOM_TYPE_NODE, |
238 | WEBKIT_PARAM_READABLE)); |
239 | |
240 | g_object_class_install_property( |
241 | gobjectClass, |
242 | DOM_DOM_SELECTION_PROP_BASE_OFFSET, |
243 | g_param_spec_ulong( |
244 | "base-offset" , |
245 | "DOMSelection:base-offset" , |
246 | "read-only gulong DOMSelection:base-offset" , |
247 | 0, G_MAXULONG, 0, |
248 | WEBKIT_PARAM_READABLE)); |
249 | |
250 | g_object_class_install_property( |
251 | gobjectClass, |
252 | DOM_DOM_SELECTION_PROP_EXTENT_NODE, |
253 | g_param_spec_object( |
254 | "extent-node" , |
255 | "DOMSelection:extent-node" , |
256 | "read-only WebKitDOMNode* DOMSelection:extent-node" , |
257 | WEBKIT_DOM_TYPE_NODE, |
258 | WEBKIT_PARAM_READABLE)); |
259 | |
260 | g_object_class_install_property( |
261 | gobjectClass, |
262 | DOM_DOM_SELECTION_PROP_EXTENT_OFFSET, |
263 | g_param_spec_ulong( |
264 | "extent-offset" , |
265 | "DOMSelection:extent-offset" , |
266 | "read-only gulong DOMSelection:extent-offset" , |
267 | 0, G_MAXULONG, 0, |
268 | WEBKIT_PARAM_READABLE)); |
269 | |
270 | } |
271 | |
272 | static void webkit_dom_dom_selection_init(WebKitDOMDOMSelection* request) |
273 | { |
274 | WebKitDOMDOMSelectionPrivate* priv = WEBKIT_DOM_DOM_SELECTION_GET_PRIVATE(request); |
275 | new (priv) WebKitDOMDOMSelectionPrivate(); |
276 | } |
277 | |
278 | void webkit_dom_dom_selection_collapse(WebKitDOMDOMSelection* self, WebKitDOMNode* node, gulong offset) |
279 | { |
280 | WebCore::JSMainThreadNullState state; |
281 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
282 | g_return_if_fail(WEBKIT_DOM_IS_NODE(node)); |
283 | WebCore::DOMSelection* item = WebKit::core(self); |
284 | WebCore::Node* convertedNode = WebKit::core(node); |
285 | item->collapse(convertedNode, offset); |
286 | } |
287 | |
288 | void webkit_dom_dom_selection_collapse_to_end(WebKitDOMDOMSelection* self, GError** error) |
289 | { |
290 | WebCore::JSMainThreadNullState state; |
291 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
292 | g_return_if_fail(!error || !*error); |
293 | WebCore::DOMSelection* item = WebKit::core(self); |
294 | auto result = item->collapseToEnd(); |
295 | if (result.hasException()) { |
296 | auto description = WebCore::DOMException::description(result.releaseException().code()); |
297 | g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM" ), description.legacyCode, description.name); |
298 | } |
299 | } |
300 | |
301 | void webkit_dom_dom_selection_collapse_to_start(WebKitDOMDOMSelection* self, GError** error) |
302 | { |
303 | WebCore::JSMainThreadNullState state; |
304 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
305 | g_return_if_fail(!error || !*error); |
306 | WebCore::DOMSelection* item = WebKit::core(self); |
307 | auto result = item->collapseToStart(); |
308 | if (result.hasException()) { |
309 | auto description = WebCore::DOMException::description(result.releaseException().code()); |
310 | g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM" ), description.legacyCode, description.name); |
311 | } |
312 | } |
313 | |
314 | void webkit_dom_dom_selection_delete_from_document(WebKitDOMDOMSelection* self) |
315 | { |
316 | WebCore::JSMainThreadNullState state; |
317 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
318 | WebCore::DOMSelection* item = WebKit::core(self); |
319 | item->deleteFromDocument(); |
320 | } |
321 | |
322 | gboolean webkit_dom_dom_selection_contains_node(WebKitDOMDOMSelection* self, WebKitDOMNode* node, gboolean allowPartial) |
323 | { |
324 | WebCore::JSMainThreadNullState state; |
325 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), FALSE); |
326 | g_return_val_if_fail(WEBKIT_DOM_IS_NODE(node), FALSE); |
327 | WebCore::DOMSelection* item = WebKit::core(self); |
328 | WebCore::Node* convertedNode = WebKit::core(node); |
329 | gboolean result = item->containsNode(*convertedNode, allowPartial); |
330 | return result; |
331 | } |
332 | |
333 | void webkit_dom_dom_selection_select_all_children(WebKitDOMDOMSelection* self, WebKitDOMNode* node) |
334 | { |
335 | WebCore::JSMainThreadNullState state; |
336 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
337 | g_return_if_fail(WEBKIT_DOM_IS_NODE(node)); |
338 | WebCore::DOMSelection* item = WebKit::core(self); |
339 | WebCore::Node* convertedNode = WebKit::core(node); |
340 | item->selectAllChildren(*convertedNode); |
341 | } |
342 | |
343 | void webkit_dom_dom_selection_extend(WebKitDOMDOMSelection* self, WebKitDOMNode* node, gulong offset, GError** error) |
344 | { |
345 | WebCore::JSMainThreadNullState state; |
346 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
347 | g_return_if_fail(WEBKIT_DOM_IS_NODE(node)); |
348 | g_return_if_fail(!error || !*error); |
349 | WebCore::DOMSelection* item = WebKit::core(self); |
350 | WebCore::Node* convertedNode = WebKit::core(node); |
351 | auto result = item->extend(*convertedNode, offset); |
352 | if (result.hasException()) { |
353 | auto description = WebCore::DOMException::description(result.releaseException().code()); |
354 | g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM" ), description.legacyCode, description.name); |
355 | } |
356 | } |
357 | |
358 | WebKitDOMRange* webkit_dom_dom_selection_get_range_at(WebKitDOMDOMSelection* self, gulong index, GError** error) |
359 | { |
360 | WebCore::JSMainThreadNullState state; |
361 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
362 | g_return_val_if_fail(!error || !*error, 0); |
363 | WebCore::DOMSelection* item = WebKit::core(self); |
364 | auto result = item->getRangeAt(index); |
365 | if (result.hasException()) { |
366 | auto description = WebCore::DOMException::description(result.releaseException().code()); |
367 | g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM" ), description.legacyCode, description.name); |
368 | return nullptr; |
369 | } |
370 | return WebKit::kit(result.releaseReturnValue().ptr()); |
371 | } |
372 | |
373 | void webkit_dom_dom_selection_remove_all_ranges(WebKitDOMDOMSelection* self) |
374 | { |
375 | WebCore::JSMainThreadNullState state; |
376 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
377 | WebCore::DOMSelection* item = WebKit::core(self); |
378 | item->removeAllRanges(); |
379 | } |
380 | |
381 | void webkit_dom_dom_selection_add_range(WebKitDOMDOMSelection* self, WebKitDOMRange* range) |
382 | { |
383 | WebCore::JSMainThreadNullState state; |
384 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
385 | g_return_if_fail(WEBKIT_DOM_IS_RANGE(range)); |
386 | WebCore::DOMSelection* item = WebKit::core(self); |
387 | WebCore::Range* convertedRange = WebKit::core(range); |
388 | item->addRange(*convertedRange); |
389 | } |
390 | |
391 | void webkit_dom_dom_selection_set_base_and_extent(WebKitDOMDOMSelection* self, WebKitDOMNode* baseNode, gulong baseOffset, WebKitDOMNode* extentNode, gulong extentOffset) |
392 | { |
393 | WebCore::JSMainThreadNullState state; |
394 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
395 | g_return_if_fail(WEBKIT_DOM_IS_NODE(baseNode)); |
396 | g_return_if_fail(WEBKIT_DOM_IS_NODE(extentNode)); |
397 | WebCore::DOMSelection* item = WebKit::core(self); |
398 | WebCore::Node* convertedBaseNode = WebKit::core(baseNode); |
399 | WebCore::Node* convertedExtentNode = WebKit::core(extentNode); |
400 | item->setBaseAndExtent(convertedBaseNode, baseOffset, convertedExtentNode, extentOffset); |
401 | } |
402 | |
403 | void webkit_dom_dom_selection_set_position(WebKitDOMDOMSelection* self, WebKitDOMNode* node, gulong offset) |
404 | { |
405 | WebCore::JSMainThreadNullState state; |
406 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
407 | g_return_if_fail(WEBKIT_DOM_IS_NODE(node)); |
408 | WebCore::DOMSelection* item = WebKit::core(self); |
409 | WebCore::Node* convertedNode = WebKit::core(node); |
410 | item->setPosition(convertedNode, offset); |
411 | } |
412 | |
413 | void webkit_dom_dom_selection_empty(WebKitDOMDOMSelection* self) |
414 | { |
415 | WebCore::JSMainThreadNullState state; |
416 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
417 | WebCore::DOMSelection* item = WebKit::core(self); |
418 | item->empty(); |
419 | } |
420 | |
421 | void webkit_dom_dom_selection_modify(WebKitDOMDOMSelection* self, const gchar* alter, const gchar* direction, const gchar* granularity) |
422 | { |
423 | WebCore::JSMainThreadNullState state; |
424 | g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self)); |
425 | g_return_if_fail(alter); |
426 | g_return_if_fail(direction); |
427 | g_return_if_fail(granularity); |
428 | WebCore::DOMSelection* item = WebKit::core(self); |
429 | WTF::String convertedAlter = WTF::String::fromUTF8(alter); |
430 | WTF::String convertedDirection = WTF::String::fromUTF8(direction); |
431 | WTF::String convertedGranularity = WTF::String::fromUTF8(granularity); |
432 | item->modify(convertedAlter, convertedDirection, convertedGranularity); |
433 | } |
434 | |
435 | WebKitDOMNode* webkit_dom_dom_selection_get_anchor_node(WebKitDOMDOMSelection* self) |
436 | { |
437 | WebCore::JSMainThreadNullState state; |
438 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
439 | WebCore::DOMSelection* item = WebKit::core(self); |
440 | RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->anchorNode()); |
441 | return WebKit::kit(gobjectResult.get()); |
442 | } |
443 | |
444 | gulong webkit_dom_dom_selection_get_anchor_offset(WebKitDOMDOMSelection* self) |
445 | { |
446 | WebCore::JSMainThreadNullState state; |
447 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
448 | WebCore::DOMSelection* item = WebKit::core(self); |
449 | gulong result = item->anchorOffset(); |
450 | return result; |
451 | } |
452 | |
453 | WebKitDOMNode* webkit_dom_dom_selection_get_focus_node(WebKitDOMDOMSelection* self) |
454 | { |
455 | WebCore::JSMainThreadNullState state; |
456 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
457 | WebCore::DOMSelection* item = WebKit::core(self); |
458 | RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->focusNode()); |
459 | return WebKit::kit(gobjectResult.get()); |
460 | } |
461 | |
462 | gulong webkit_dom_dom_selection_get_focus_offset(WebKitDOMDOMSelection* self) |
463 | { |
464 | WebCore::JSMainThreadNullState state; |
465 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
466 | WebCore::DOMSelection* item = WebKit::core(self); |
467 | gulong result = item->focusOffset(); |
468 | return result; |
469 | } |
470 | |
471 | gboolean webkit_dom_dom_selection_get_is_collapsed(WebKitDOMDOMSelection* self) |
472 | { |
473 | WebCore::JSMainThreadNullState state; |
474 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), FALSE); |
475 | WebCore::DOMSelection* item = WebKit::core(self); |
476 | gboolean result = item->isCollapsed(); |
477 | return result; |
478 | } |
479 | |
480 | gulong webkit_dom_dom_selection_get_range_count(WebKitDOMDOMSelection* self) |
481 | { |
482 | WebCore::JSMainThreadNullState state; |
483 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
484 | WebCore::DOMSelection* item = WebKit::core(self); |
485 | gulong result = item->rangeCount(); |
486 | return result; |
487 | } |
488 | |
489 | gchar* webkit_dom_dom_selection_get_selection_type(WebKitDOMDOMSelection* self) |
490 | { |
491 | WebCore::JSMainThreadNullState state; |
492 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
493 | WebCore::DOMSelection* item = WebKit::core(self); |
494 | gchar* result = convertToUTF8String(item->type()); |
495 | return result; |
496 | } |
497 | |
498 | WebKitDOMNode* webkit_dom_dom_selection_get_base_node(WebKitDOMDOMSelection* self) |
499 | { |
500 | WebCore::JSMainThreadNullState state; |
501 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
502 | WebCore::DOMSelection* item = WebKit::core(self); |
503 | RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->baseNode()); |
504 | return WebKit::kit(gobjectResult.get()); |
505 | } |
506 | |
507 | gulong webkit_dom_dom_selection_get_base_offset(WebKitDOMDOMSelection* self) |
508 | { |
509 | WebCore::JSMainThreadNullState state; |
510 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
511 | WebCore::DOMSelection* item = WebKit::core(self); |
512 | gulong result = item->baseOffset(); |
513 | return result; |
514 | } |
515 | |
516 | WebKitDOMNode* webkit_dom_dom_selection_get_extent_node(WebKitDOMDOMSelection* self) |
517 | { |
518 | WebCore::JSMainThreadNullState state; |
519 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
520 | WebCore::DOMSelection* item = WebKit::core(self); |
521 | RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->extentNode()); |
522 | return WebKit::kit(gobjectResult.get()); |
523 | } |
524 | |
525 | gulong webkit_dom_dom_selection_get_extent_offset(WebKitDOMDOMSelection* self) |
526 | { |
527 | WebCore::JSMainThreadNullState state; |
528 | g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0); |
529 | WebCore::DOMSelection* item = WebKit::core(self); |
530 | gulong result = item->extentOffset(); |
531 | return result; |
532 | } |
533 | |
534 | G_GNUC_END_IGNORE_DEPRECATIONS; |
535 | |