2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #include "JSDOMSelection.h"
24 #include "DOMSelection.h"
25 #include "ExceptionCode.h"
26 #include "JSDOMBinding.h"
32 #include <runtime/Error.h>
33 #include <runtime/JSString.h>
34 #include <wtf/GetPtr.h>
40 ASSERT_CLASS_FITS_IN_CELL(JSDOMSelection);
44 #define THUNK_GENERATOR(generator) , generator
46 #define THUNK_GENERATOR(generator)
49 #define INTRINSIC(intrinsic) , intrinsic
51 #define INTRINSIC(intrinsic)
54 static const HashTableValue JSDOMSelectionTableValues[] =
56 { "anchorNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionAnchorNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
57 { "anchorOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionAnchorOffset), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
58 { "focusNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionFocusNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
59 { "focusOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionFocusOffset), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
60 { "isCollapsed", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionIsCollapsed), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
61 { "rangeCount", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionRangeCount), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
62 { "baseNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionBaseNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
63 { "baseOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionBaseOffset), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
64 { "extentNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionExtentNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
65 { "extentOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionExtentOffset), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
66 { "type", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionType), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
67 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
70 #undef THUNK_GENERATOR
71 static const HashTable JSDOMSelectionTable = { 34, 31, JSDOMSelectionTableValues, 0 };
72 /* Hash table for prototype */
74 #define THUNK_GENERATOR(generator) , generator
76 #define THUNK_GENERATOR(generator)
79 #define INTRINSIC(intrinsic) , intrinsic
81 #define INTRINSIC(intrinsic)
84 static const HashTableValue JSDOMSelectionPrototypeTableValues[] =
86 { "collapse", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionCollapse), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
87 { "collapseToEnd", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionCollapseToEnd), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
88 { "collapseToStart", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionCollapseToStart), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
89 { "deleteFromDocument", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionDeleteFromDocument), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
90 { "containsNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionContainsNode), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
91 { "selectAllChildren", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionSelectAllChildren), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
92 { "extend", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionExtend), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
93 { "getRangeAt", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionGetRangeAt), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
94 { "removeAllRanges", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionRemoveAllRanges), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
95 { "addRange", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionAddRange), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
96 { "toString", DontDelete | DontEnum | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionToString), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
97 { "modify", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionModify), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
98 { "setBaseAndExtent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionSetBaseAndExtent), (intptr_t)4 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
99 { "setPosition", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionSetPosition), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
100 { "empty", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionEmpty), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
101 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
104 #undef THUNK_GENERATOR
105 static const HashTable JSDOMSelectionPrototypeTable = { 34, 31, JSDOMSelectionPrototypeTableValues, 0 };
106 const ClassInfo JSDOMSelectionPrototype::s_info = { "DOMSelectionPrototype", &JSC::JSNonFinalObject::s_info, &JSDOMSelectionPrototypeTable, 0, CREATE_METHOD_TABLE(JSDOMSelectionPrototype) };
108 JSObject* JSDOMSelectionPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
110 return getDOMPrototype<JSDOMSelection>(exec, globalObject);
113 bool JSDOMSelectionPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
115 JSDOMSelectionPrototype* thisObject = jsCast<JSDOMSelectionPrototype*>(cell);
116 return getStaticFunctionSlot<JSObject>(exec, &JSDOMSelectionPrototypeTable, thisObject, propertyName, slot);
119 bool JSDOMSelectionPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
121 JSDOMSelectionPrototype* thisObject = jsCast<JSDOMSelectionPrototype*>(object);
122 return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMSelectionPrototypeTable, thisObject, propertyName, descriptor);
125 const ClassInfo JSDOMSelection::s_info = { "DOMSelection", &JSDOMWrapper::s_info, &JSDOMSelectionTable, 0 , CREATE_METHOD_TABLE(JSDOMSelection) };
127 JSDOMSelection::JSDOMSelection(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMSelection> impl)
128 : JSDOMWrapper(structure, globalObject)
129 , m_impl(impl.leakRef())
133 void JSDOMSelection::finishCreation(JSGlobalData& globalData)
135 Base::finishCreation(globalData);
136 ASSERT(inherits(&s_info));
139 JSObject* JSDOMSelection::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
141 return JSDOMSelectionPrototype::create(exec->globalData(), globalObject, JSDOMSelectionPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
144 bool JSDOMSelection::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
146 JSDOMSelection* thisObject = jsCast<JSDOMSelection*>(cell);
147 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
148 return getStaticValueSlot<JSDOMSelection, Base>(exec, &JSDOMSelectionTable, thisObject, propertyName, slot);
151 bool JSDOMSelection::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
153 JSDOMSelection* thisObject = jsCast<JSDOMSelection*>(object);
154 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
155 return getStaticValueDescriptor<JSDOMSelection, Base>(exec, &JSDOMSelectionTable, thisObject, propertyName, descriptor);
158 JSValue jsDOMSelectionAnchorNode(ExecState* exec, JSValue slotBase, const Identifier&)
160 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
162 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
163 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->anchorNode()));
168 JSValue jsDOMSelectionAnchorOffset(ExecState* exec, JSValue slotBase, const Identifier&)
170 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
172 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
173 JSValue result = jsNumber(imp->anchorOffset());
178 JSValue jsDOMSelectionFocusNode(ExecState* exec, JSValue slotBase, const Identifier&)
180 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
182 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
183 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->focusNode()));
188 JSValue jsDOMSelectionFocusOffset(ExecState* exec, JSValue slotBase, const Identifier&)
190 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
192 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
193 JSValue result = jsNumber(imp->focusOffset());
198 JSValue jsDOMSelectionIsCollapsed(ExecState* exec, JSValue slotBase, const Identifier&)
200 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
202 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
203 JSValue result = jsBoolean(imp->isCollapsed());
208 JSValue jsDOMSelectionRangeCount(ExecState* exec, JSValue slotBase, const Identifier&)
210 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
212 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
213 JSValue result = jsNumber(imp->rangeCount());
218 JSValue jsDOMSelectionBaseNode(ExecState* exec, JSValue slotBase, const Identifier&)
220 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
222 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
223 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->baseNode()));
228 JSValue jsDOMSelectionBaseOffset(ExecState* exec, JSValue slotBase, const Identifier&)
230 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
232 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
233 JSValue result = jsNumber(imp->baseOffset());
238 JSValue jsDOMSelectionExtentNode(ExecState* exec, JSValue slotBase, const Identifier&)
240 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
242 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
243 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->extentNode()));
248 JSValue jsDOMSelectionExtentOffset(ExecState* exec, JSValue slotBase, const Identifier&)
250 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
252 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
253 JSValue result = jsNumber(imp->extentOffset());
258 JSValue jsDOMSelectionType(ExecState* exec, JSValue slotBase, const Identifier&)
260 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase));
262 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
263 JSValue result = jsString(exec, imp->type());
268 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapse(ExecState* exec)
270 JSValue thisValue = exec->hostThisValue();
271 if (!thisValue.inherits(&JSDOMSelection::s_info))
272 return throwVMTypeError(exec);
273 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
274 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
275 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
276 ExceptionCode ec = 0;
277 Node* node(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
278 if (exec->hadException())
279 return JSValue::encode(jsUndefined());
280 int index(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toInt32(exec));
281 if (exec->hadException())
282 return JSValue::encode(jsUndefined());
283 imp->collapse(node, index, ec);
284 setDOMException(exec, ec);
285 return JSValue::encode(jsUndefined());
288 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToEnd(ExecState* exec)
290 JSValue thisValue = exec->hostThisValue();
291 if (!thisValue.inherits(&JSDOMSelection::s_info))
292 return throwVMTypeError(exec);
293 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
294 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
295 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
296 ExceptionCode ec = 0;
297 imp->collapseToEnd(ec);
298 setDOMException(exec, ec);
299 return JSValue::encode(jsUndefined());
302 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToStart(ExecState* exec)
304 JSValue thisValue = exec->hostThisValue();
305 if (!thisValue.inherits(&JSDOMSelection::s_info))
306 return throwVMTypeError(exec);
307 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
308 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
309 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
310 ExceptionCode ec = 0;
311 imp->collapseToStart(ec);
312 setDOMException(exec, ec);
313 return JSValue::encode(jsUndefined());
316 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionDeleteFromDocument(ExecState* exec)
318 JSValue thisValue = exec->hostThisValue();
319 if (!thisValue.inherits(&JSDOMSelection::s_info))
320 return throwVMTypeError(exec);
321 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
322 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
323 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
324 imp->deleteFromDocument();
325 return JSValue::encode(jsUndefined());
328 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionContainsNode(ExecState* exec)
330 JSValue thisValue = exec->hostThisValue();
331 if (!thisValue.inherits(&JSDOMSelection::s_info))
332 return throwVMTypeError(exec);
333 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
334 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
335 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
336 Node* node(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
337 if (exec->hadException())
338 return JSValue::encode(jsUndefined());
339 bool allowPartial(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toBoolean(exec));
340 if (exec->hadException())
341 return JSValue::encode(jsUndefined());
343 JSC::JSValue result = jsBoolean(imp->containsNode(node, allowPartial));
344 return JSValue::encode(result);
347 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSelectAllChildren(ExecState* exec)
349 JSValue thisValue = exec->hostThisValue();
350 if (!thisValue.inherits(&JSDOMSelection::s_info))
351 return throwVMTypeError(exec);
352 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
353 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
354 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
355 ExceptionCode ec = 0;
356 Node* node(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
357 if (exec->hadException())
358 return JSValue::encode(jsUndefined());
359 imp->selectAllChildren(node, ec);
360 setDOMException(exec, ec);
361 return JSValue::encode(jsUndefined());
364 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionExtend(ExecState* exec)
366 JSValue thisValue = exec->hostThisValue();
367 if (!thisValue.inherits(&JSDOMSelection::s_info))
368 return throwVMTypeError(exec);
369 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
370 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
371 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
372 ExceptionCode ec = 0;
373 Node* node(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
374 if (exec->hadException())
375 return JSValue::encode(jsUndefined());
376 int offset(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toInt32(exec));
377 if (exec->hadException())
378 return JSValue::encode(jsUndefined());
379 imp->extend(node, offset, ec);
380 setDOMException(exec, ec);
381 return JSValue::encode(jsUndefined());
384 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionGetRangeAt(ExecState* exec)
386 JSValue thisValue = exec->hostThisValue();
387 if (!thisValue.inherits(&JSDOMSelection::s_info))
388 return throwVMTypeError(exec);
389 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
390 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
391 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
392 ExceptionCode ec = 0;
393 int index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toInt32(exec));
394 if (exec->hadException())
395 return JSValue::encode(jsUndefined());
397 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getRangeAt(index, ec)));
398 setDOMException(exec, ec);
399 return JSValue::encode(result);
402 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionRemoveAllRanges(ExecState* exec)
404 JSValue thisValue = exec->hostThisValue();
405 if (!thisValue.inherits(&JSDOMSelection::s_info))
406 return throwVMTypeError(exec);
407 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
408 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
409 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
410 imp->removeAllRanges();
411 return JSValue::encode(jsUndefined());
414 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionAddRange(ExecState* exec)
416 JSValue thisValue = exec->hostThisValue();
417 if (!thisValue.inherits(&JSDOMSelection::s_info))
418 return throwVMTypeError(exec);
419 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
420 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
421 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
422 Range* range(toRange(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
423 if (exec->hadException())
424 return JSValue::encode(jsUndefined());
425 imp->addRange(range);
426 return JSValue::encode(jsUndefined());
429 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionToString(ExecState* exec)
431 JSValue thisValue = exec->hostThisValue();
432 if (!thisValue.inherits(&JSDOMSelection::s_info))
433 return throwVMTypeError(exec);
434 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
435 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
436 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
438 JSC::JSValue result = jsString(exec, imp->toString());
439 return JSValue::encode(result);
442 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionModify(ExecState* exec)
444 JSValue thisValue = exec->hostThisValue();
445 if (!thisValue.inherits(&JSDOMSelection::s_info))
446 return throwVMTypeError(exec);
447 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
448 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
449 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
450 const String& alter(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
451 if (exec->hadException())
452 return JSValue::encode(jsUndefined());
453 const String& direction(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toString(exec)));
454 if (exec->hadException())
455 return JSValue::encode(jsUndefined());
456 const String& granularity(ustringToString(MAYBE_MISSING_PARAMETER(exec, 2, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 2, MissingIsUndefined).toString(exec)));
457 if (exec->hadException())
458 return JSValue::encode(jsUndefined());
459 imp->modify(alter, direction, granularity);
460 return JSValue::encode(jsUndefined());
463 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetBaseAndExtent(ExecState* exec)
465 JSValue thisValue = exec->hostThisValue();
466 if (!thisValue.inherits(&JSDOMSelection::s_info))
467 return throwVMTypeError(exec);
468 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
469 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
470 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
471 ExceptionCode ec = 0;
472 Node* baseNode(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
473 if (exec->hadException())
474 return JSValue::encode(jsUndefined());
475 int baseOffset(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toInt32(exec));
476 if (exec->hadException())
477 return JSValue::encode(jsUndefined());
478 Node* extentNode(toNode(MAYBE_MISSING_PARAMETER(exec, 2, MissingIsUndefined)));
479 if (exec->hadException())
480 return JSValue::encode(jsUndefined());
481 int extentOffset(MAYBE_MISSING_PARAMETER(exec, 3, MissingIsUndefined).toInt32(exec));
482 if (exec->hadException())
483 return JSValue::encode(jsUndefined());
484 imp->setBaseAndExtent(baseNode, baseOffset, extentNode, extentOffset, ec);
485 setDOMException(exec, ec);
486 return JSValue::encode(jsUndefined());
489 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetPosition(ExecState* exec)
491 JSValue thisValue = exec->hostThisValue();
492 if (!thisValue.inherits(&JSDOMSelection::s_info))
493 return throwVMTypeError(exec);
494 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
495 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
496 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
497 ExceptionCode ec = 0;
498 Node* node(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
499 if (exec->hadException())
500 return JSValue::encode(jsUndefined());
501 int offset(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toInt32(exec));
502 if (exec->hadException())
503 return JSValue::encode(jsUndefined());
504 imp->setPosition(node, offset, ec);
505 setDOMException(exec, ec);
506 return JSValue::encode(jsUndefined());
509 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionEmpty(ExecState* exec)
511 JSValue thisValue = exec->hostThisValue();
512 if (!thisValue.inherits(&JSDOMSelection::s_info))
513 return throwVMTypeError(exec);
514 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue));
515 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDOMSelection::s_info);
516 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl());
518 return JSValue::encode(jsUndefined());
521 static inline bool isObservable(JSDOMSelection* jsDOMSelection)
523 if (jsDOMSelection->hasCustomProperties())
528 bool JSDOMSelectionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
530 JSDOMSelection* jsDOMSelection = static_cast<JSDOMSelection*>(handle.get().asCell());
531 if (!isObservable(jsDOMSelection))
533 Frame* root = jsDOMSelection->impl()->frame();
536 return visitor.containsOpaqueRoot(root);
539 void JSDOMSelectionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
541 JSDOMSelection* jsDOMSelection = static_cast<JSDOMSelection*>(handle.get().asCell());
542 DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
543 uncacheWrapper(world, jsDOMSelection->impl(), jsDOMSelection);
544 jsDOMSelection->releaseImpl();
547 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMSelection* impl)
549 return wrap<JSDOMSelection>(exec, globalObject, impl);
552 DOMSelection* toDOMSelection(JSC::JSValue value)
554 return value.inherits(&JSDOMSelection::s_info) ? static_cast<JSDOMSelection*>(asObject(value))->impl() : 0;