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