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