|
1 /* |
|
2 This file is part of the WebKit open source project. |
|
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
|
4 |
|
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. |
|
9 |
|
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. |
|
14 |
|
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. |
|
19 */ |
|
20 |
|
21 #include "config.h" |
|
22 #include "JSDOMSelection.h" |
|
23 |
|
24 #include "DOMSelection.h" |
|
25 #include "JSNode.h" |
|
26 #include "JSRange.h" |
|
27 #include "KURL.h" |
|
28 #include "Node.h" |
|
29 #include "Range.h" |
|
30 #include <runtime/Error.h> |
|
31 #include <runtime/JSNumberCell.h> |
|
32 #include <runtime/JSString.h> |
|
33 #include <wtf/GetPtr.h> |
|
34 |
|
35 using namespace JSC; |
|
36 |
|
37 namespace WebCore { |
|
38 |
|
39 ASSERT_CLASS_FITS_IN_CELL(JSDOMSelection); |
|
40 |
|
41 /* Hash table */ |
|
42 #if ENABLE(JIT) |
|
43 #define THUNK_GENERATOR(generator) , generator |
|
44 #else |
|
45 #define THUNK_GENERATOR(generator) |
|
46 #endif |
|
47 |
|
48 static const HashTableValue JSDOMSelectionTableValues[12] = |
|
49 { |
|
50 { "anchorNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionAnchorNode), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
51 { "anchorOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionAnchorOffset), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
52 { "focusNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionFocusNode), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
53 { "focusOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionFocusOffset), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
54 { "isCollapsed", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionIsCollapsed), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
55 { "rangeCount", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionRangeCount), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
56 { "baseNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionBaseNode), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
57 { "baseOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionBaseOffset), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
58 { "extentNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionExtentNode), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
59 { "extentOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionExtentOffset), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
60 { "type", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionType), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
61 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
62 }; |
|
63 |
|
64 #undef THUNK_GENERATOR |
|
65 static JSC_CONST_HASHTABLE HashTable JSDOMSelectionTable = { 34, 31, JSDOMSelectionTableValues, 0 }; |
|
66 /* Hash table for prototype */ |
|
67 #if ENABLE(JIT) |
|
68 #define THUNK_GENERATOR(generator) , generator |
|
69 #else |
|
70 #define THUNK_GENERATOR(generator) |
|
71 #endif |
|
72 |
|
73 static const HashTableValue JSDOMSelectionPrototypeTableValues[16] = |
|
74 { |
|
75 { "collapse", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionCollapse), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
76 { "collapseToEnd", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionCollapseToEnd), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
77 { "collapseToStart", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionCollapseToStart), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
78 { "deleteFromDocument", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionDeleteFromDocument), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
79 { "containsNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionContainsNode), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
80 { "selectAllChildren", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionSelectAllChildren), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
81 { "extend", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionExtend), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
82 { "getRangeAt", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionGetRangeAt), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
83 { "removeAllRanges", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionRemoveAllRanges), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
84 { "addRange", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionAddRange), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
85 { "toString", DontDelete | DontEnum | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionToString), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
86 { "modify", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionModify), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
87 { "setBaseAndExtent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionSetBaseAndExtent), (intptr_t)4 THUNK_GENERATOR(0) }, |
|
88 { "setPosition", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionSetPosition), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
89 { "empty", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMSelectionPrototypeFunctionEmpty), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
90 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
91 }; |
|
92 |
|
93 #undef THUNK_GENERATOR |
|
94 static JSC_CONST_HASHTABLE HashTable JSDOMSelectionPrototypeTable = { 34, 31, JSDOMSelectionPrototypeTableValues, 0 }; |
|
95 const ClassInfo JSDOMSelectionPrototype::s_info = { "DOMSelectionPrototype", 0, &JSDOMSelectionPrototypeTable, 0 }; |
|
96 |
|
97 JSObject* JSDOMSelectionPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
98 { |
|
99 return getDOMPrototype<JSDOMSelection>(exec, globalObject); |
|
100 } |
|
101 |
|
102 bool JSDOMSelectionPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
103 { |
|
104 return getStaticFunctionSlot<JSObject>(exec, &JSDOMSelectionPrototypeTable, this, propertyName, slot); |
|
105 } |
|
106 |
|
107 bool JSDOMSelectionPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
108 { |
|
109 return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMSelectionPrototypeTable, this, propertyName, descriptor); |
|
110 } |
|
111 |
|
112 const ClassInfo JSDOMSelection::s_info = { "DOMSelection", 0, &JSDOMSelectionTable, 0 }; |
|
113 |
|
114 JSDOMSelection::JSDOMSelection(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMSelection> impl) |
|
115 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
116 , m_impl(impl) |
|
117 { |
|
118 } |
|
119 |
|
120 JSDOMSelection::~JSDOMSelection() |
|
121 { |
|
122 forgetDOMObject(this, impl()); |
|
123 } |
|
124 |
|
125 JSObject* JSDOMSelection::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
126 { |
|
127 return new (exec) JSDOMSelectionPrototype(globalObject, JSDOMSelectionPrototype::createStructure(globalObject->objectPrototype())); |
|
128 } |
|
129 |
|
130 bool JSDOMSelection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
131 { |
|
132 return getStaticValueSlot<JSDOMSelection, Base>(exec, &JSDOMSelectionTable, this, propertyName, slot); |
|
133 } |
|
134 |
|
135 bool JSDOMSelection::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
136 { |
|
137 return getStaticValueDescriptor<JSDOMSelection, Base>(exec, &JSDOMSelectionTable, this, propertyName, descriptor); |
|
138 } |
|
139 |
|
140 JSValue jsDOMSelectionAnchorNode(ExecState* exec, JSValue slotBase, const Identifier&) |
|
141 { |
|
142 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
143 UNUSED_PARAM(exec); |
|
144 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
145 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->anchorNode())); |
|
146 return result; |
|
147 } |
|
148 |
|
149 JSValue jsDOMSelectionAnchorOffset(ExecState* exec, JSValue slotBase, const Identifier&) |
|
150 { |
|
151 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
152 UNUSED_PARAM(exec); |
|
153 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
154 JSValue result = jsNumber(exec, imp->anchorOffset()); |
|
155 return result; |
|
156 } |
|
157 |
|
158 JSValue jsDOMSelectionFocusNode(ExecState* exec, JSValue slotBase, const Identifier&) |
|
159 { |
|
160 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
161 UNUSED_PARAM(exec); |
|
162 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
163 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->focusNode())); |
|
164 return result; |
|
165 } |
|
166 |
|
167 JSValue jsDOMSelectionFocusOffset(ExecState* exec, JSValue slotBase, const Identifier&) |
|
168 { |
|
169 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
170 UNUSED_PARAM(exec); |
|
171 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
172 JSValue result = jsNumber(exec, imp->focusOffset()); |
|
173 return result; |
|
174 } |
|
175 |
|
176 JSValue jsDOMSelectionIsCollapsed(ExecState* exec, JSValue slotBase, const Identifier&) |
|
177 { |
|
178 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
179 UNUSED_PARAM(exec); |
|
180 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
181 JSValue result = jsBoolean(imp->isCollapsed()); |
|
182 return result; |
|
183 } |
|
184 |
|
185 JSValue jsDOMSelectionRangeCount(ExecState* exec, JSValue slotBase, const Identifier&) |
|
186 { |
|
187 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
188 UNUSED_PARAM(exec); |
|
189 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
190 JSValue result = jsNumber(exec, imp->rangeCount()); |
|
191 return result; |
|
192 } |
|
193 |
|
194 JSValue jsDOMSelectionBaseNode(ExecState* exec, JSValue slotBase, const Identifier&) |
|
195 { |
|
196 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
197 UNUSED_PARAM(exec); |
|
198 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
199 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->baseNode())); |
|
200 return result; |
|
201 } |
|
202 |
|
203 JSValue jsDOMSelectionBaseOffset(ExecState* exec, JSValue slotBase, const Identifier&) |
|
204 { |
|
205 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
206 UNUSED_PARAM(exec); |
|
207 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
208 JSValue result = jsNumber(exec, imp->baseOffset()); |
|
209 return result; |
|
210 } |
|
211 |
|
212 JSValue jsDOMSelectionExtentNode(ExecState* exec, JSValue slotBase, const Identifier&) |
|
213 { |
|
214 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
215 UNUSED_PARAM(exec); |
|
216 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
217 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->extentNode())); |
|
218 return result; |
|
219 } |
|
220 |
|
221 JSValue jsDOMSelectionExtentOffset(ExecState* exec, JSValue slotBase, const Identifier&) |
|
222 { |
|
223 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
224 UNUSED_PARAM(exec); |
|
225 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
226 JSValue result = jsNumber(exec, imp->extentOffset()); |
|
227 return result; |
|
228 } |
|
229 |
|
230 JSValue jsDOMSelectionType(ExecState* exec, JSValue slotBase, const Identifier&) |
|
231 { |
|
232 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(slotBase)); |
|
233 UNUSED_PARAM(exec); |
|
234 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
235 JSValue result = jsString(exec, imp->type()); |
|
236 return result; |
|
237 } |
|
238 |
|
239 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapse(ExecState* exec) |
|
240 { |
|
241 JSValue thisValue = exec->hostThisValue(); |
|
242 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
243 return throwVMTypeError(exec); |
|
244 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
245 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
246 ExceptionCode ec = 0; |
|
247 Node* node = toNode(exec->argument(0)); |
|
248 int index = exec->argument(1).toInt32(exec); |
|
249 |
|
250 imp->collapse(node, index, ec); |
|
251 setDOMException(exec, ec); |
|
252 return JSValue::encode(jsUndefined()); |
|
253 } |
|
254 |
|
255 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToEnd(ExecState* exec) |
|
256 { |
|
257 JSValue thisValue = exec->hostThisValue(); |
|
258 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
259 return throwVMTypeError(exec); |
|
260 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
261 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
262 |
|
263 imp->collapseToEnd(); |
|
264 return JSValue::encode(jsUndefined()); |
|
265 } |
|
266 |
|
267 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToStart(ExecState* exec) |
|
268 { |
|
269 JSValue thisValue = exec->hostThisValue(); |
|
270 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
271 return throwVMTypeError(exec); |
|
272 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
273 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
274 |
|
275 imp->collapseToStart(); |
|
276 return JSValue::encode(jsUndefined()); |
|
277 } |
|
278 |
|
279 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionDeleteFromDocument(ExecState* exec) |
|
280 { |
|
281 JSValue thisValue = exec->hostThisValue(); |
|
282 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
283 return throwVMTypeError(exec); |
|
284 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
285 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
286 |
|
287 imp->deleteFromDocument(); |
|
288 return JSValue::encode(jsUndefined()); |
|
289 } |
|
290 |
|
291 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionContainsNode(ExecState* exec) |
|
292 { |
|
293 JSValue thisValue = exec->hostThisValue(); |
|
294 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
295 return throwVMTypeError(exec); |
|
296 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
297 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
298 Node* node = toNode(exec->argument(0)); |
|
299 bool allowPartial = exec->argument(1).toBoolean(exec); |
|
300 |
|
301 |
|
302 JSC::JSValue result = jsBoolean(imp->containsNode(node, allowPartial)); |
|
303 return JSValue::encode(result); |
|
304 } |
|
305 |
|
306 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSelectAllChildren(ExecState* exec) |
|
307 { |
|
308 JSValue thisValue = exec->hostThisValue(); |
|
309 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
310 return throwVMTypeError(exec); |
|
311 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
312 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
313 ExceptionCode ec = 0; |
|
314 Node* node = toNode(exec->argument(0)); |
|
315 |
|
316 imp->selectAllChildren(node, ec); |
|
317 setDOMException(exec, ec); |
|
318 return JSValue::encode(jsUndefined()); |
|
319 } |
|
320 |
|
321 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionExtend(ExecState* exec) |
|
322 { |
|
323 JSValue thisValue = exec->hostThisValue(); |
|
324 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
325 return throwVMTypeError(exec); |
|
326 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
327 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
328 ExceptionCode ec = 0; |
|
329 Node* node = toNode(exec->argument(0)); |
|
330 int offset = exec->argument(1).toInt32(exec); |
|
331 |
|
332 imp->extend(node, offset, ec); |
|
333 setDOMException(exec, ec); |
|
334 return JSValue::encode(jsUndefined()); |
|
335 } |
|
336 |
|
337 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionGetRangeAt(ExecState* exec) |
|
338 { |
|
339 JSValue thisValue = exec->hostThisValue(); |
|
340 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
341 return throwVMTypeError(exec); |
|
342 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
343 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
344 ExceptionCode ec = 0; |
|
345 int index = exec->argument(0).toInt32(exec); |
|
346 |
|
347 |
|
348 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getRangeAt(index, ec))); |
|
349 setDOMException(exec, ec); |
|
350 return JSValue::encode(result); |
|
351 } |
|
352 |
|
353 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionRemoveAllRanges(ExecState* exec) |
|
354 { |
|
355 JSValue thisValue = exec->hostThisValue(); |
|
356 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
357 return throwVMTypeError(exec); |
|
358 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
359 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
360 |
|
361 imp->removeAllRanges(); |
|
362 return JSValue::encode(jsUndefined()); |
|
363 } |
|
364 |
|
365 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionAddRange(ExecState* exec) |
|
366 { |
|
367 JSValue thisValue = exec->hostThisValue(); |
|
368 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
369 return throwVMTypeError(exec); |
|
370 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
371 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
372 Range* range = toRange(exec->argument(0)); |
|
373 |
|
374 imp->addRange(range); |
|
375 return JSValue::encode(jsUndefined()); |
|
376 } |
|
377 |
|
378 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionToString(ExecState* exec) |
|
379 { |
|
380 JSValue thisValue = exec->hostThisValue(); |
|
381 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
382 return throwVMTypeError(exec); |
|
383 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
384 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
385 |
|
386 |
|
387 JSC::JSValue result = jsString(exec, imp->toString()); |
|
388 return JSValue::encode(result); |
|
389 } |
|
390 |
|
391 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionModify(ExecState* exec) |
|
392 { |
|
393 JSValue thisValue = exec->hostThisValue(); |
|
394 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
395 return throwVMTypeError(exec); |
|
396 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
397 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
398 const String& alter = ustringToString(exec->argument(0).toString(exec)); |
|
399 const String& direction = ustringToString(exec->argument(1).toString(exec)); |
|
400 const String& granularity = ustringToString(exec->argument(2).toString(exec)); |
|
401 |
|
402 imp->modify(alter, direction, granularity); |
|
403 return JSValue::encode(jsUndefined()); |
|
404 } |
|
405 |
|
406 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetBaseAndExtent(ExecState* exec) |
|
407 { |
|
408 JSValue thisValue = exec->hostThisValue(); |
|
409 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
410 return throwVMTypeError(exec); |
|
411 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
412 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
413 ExceptionCode ec = 0; |
|
414 Node* baseNode = toNode(exec->argument(0)); |
|
415 int baseOffset = exec->argument(1).toInt32(exec); |
|
416 Node* extentNode = toNode(exec->argument(2)); |
|
417 int extentOffset = exec->argument(3).toInt32(exec); |
|
418 |
|
419 imp->setBaseAndExtent(baseNode, baseOffset, extentNode, extentOffset, ec); |
|
420 setDOMException(exec, ec); |
|
421 return JSValue::encode(jsUndefined()); |
|
422 } |
|
423 |
|
424 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetPosition(ExecState* exec) |
|
425 { |
|
426 JSValue thisValue = exec->hostThisValue(); |
|
427 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
428 return throwVMTypeError(exec); |
|
429 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
430 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
431 ExceptionCode ec = 0; |
|
432 Node* node = toNode(exec->argument(0)); |
|
433 int offset = exec->argument(1).toInt32(exec); |
|
434 |
|
435 imp->setPosition(node, offset, ec); |
|
436 setDOMException(exec, ec); |
|
437 return JSValue::encode(jsUndefined()); |
|
438 } |
|
439 |
|
440 EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionEmpty(ExecState* exec) |
|
441 { |
|
442 JSValue thisValue = exec->hostThisValue(); |
|
443 if (!thisValue.inherits(&JSDOMSelection::s_info)) |
|
444 return throwVMTypeError(exec); |
|
445 JSDOMSelection* castedThis = static_cast<JSDOMSelection*>(asObject(thisValue)); |
|
446 DOMSelection* imp = static_cast<DOMSelection*>(castedThis->impl()); |
|
447 |
|
448 imp->empty(); |
|
449 return JSValue::encode(jsUndefined()); |
|
450 } |
|
451 |
|
452 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMSelection* object) |
|
453 { |
|
454 return getDOMObjectWrapper<JSDOMSelection>(exec, globalObject, object); |
|
455 } |
|
456 DOMSelection* toDOMSelection(JSC::JSValue value) |
|
457 { |
|
458 return value.inherits(&JSDOMSelection::s_info) ? static_cast<JSDOMSelection*>(asObject(value))->impl() : 0; |
|
459 } |
|
460 |
|
461 } |