|
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 "JSRange.h" |
|
23 |
|
24 #include "ClientRect.h" |
|
25 #include "ClientRectList.h" |
|
26 #include "DocumentFragment.h" |
|
27 #include "JSClientRect.h" |
|
28 #include "JSClientRectList.h" |
|
29 #include "JSDocumentFragment.h" |
|
30 #include "JSNode.h" |
|
31 #include "JSRange.h" |
|
32 #include "KURL.h" |
|
33 #include "Node.h" |
|
34 #include "Range.h" |
|
35 #include <runtime/Error.h> |
|
36 #include <runtime/JSNumberCell.h> |
|
37 #include <runtime/JSString.h> |
|
38 #include <wtf/GetPtr.h> |
|
39 |
|
40 using namespace JSC; |
|
41 |
|
42 namespace WebCore { |
|
43 |
|
44 ASSERT_CLASS_FITS_IN_CELL(JSRange); |
|
45 |
|
46 /* Hash table */ |
|
47 #if ENABLE(JIT) |
|
48 #define THUNK_GENERATOR(generator) , generator |
|
49 #else |
|
50 #define THUNK_GENERATOR(generator) |
|
51 #endif |
|
52 |
|
53 static const HashTableValue JSRangeTableValues[8] = |
|
54 { |
|
55 { "startContainer", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeStartContainer), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
56 { "startOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeStartOffset), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
57 { "endContainer", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEndContainer), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
58 { "endOffset", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEndOffset), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
59 { "collapsed", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeCollapsed), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
60 { "commonAncestorContainer", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeCommonAncestorContainer), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
61 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
62 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
63 }; |
|
64 |
|
65 #undef THUNK_GENERATOR |
|
66 static JSC_CONST_HASHTABLE HashTable JSRangeTable = { 18, 15, JSRangeTableValues, 0 }; |
|
67 /* Hash table for constructor */ |
|
68 #if ENABLE(JIT) |
|
69 #define THUNK_GENERATOR(generator) , generator |
|
70 #else |
|
71 #define THUNK_GENERATOR(generator) |
|
72 #endif |
|
73 |
|
74 static const HashTableValue JSRangeConstructorTableValues[9] = |
|
75 { |
|
76 { "START_TO_START", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeSTART_TO_START), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
77 { "START_TO_END", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeSTART_TO_END), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
78 { "END_TO_END", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEND_TO_END), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
79 { "END_TO_START", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEND_TO_START), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
80 { "NODE_BEFORE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_BEFORE), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
81 { "NODE_AFTER", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_AFTER), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
82 { "NODE_BEFORE_AND_AFTER", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_BEFORE_AND_AFTER), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
83 { "NODE_INSIDE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_INSIDE), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
84 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
85 }; |
|
86 |
|
87 #undef THUNK_GENERATOR |
|
88 static JSC_CONST_HASHTABLE HashTable JSRangeConstructorTable = { 18, 15, JSRangeConstructorTableValues, 0 }; |
|
89 |
|
90 COMPILE_ASSERT(0 == Range::START_TO_START, RangeEnumSTART_TO_STARTIsWrongUseDontCheckEnums); |
|
91 COMPILE_ASSERT(1 == Range::START_TO_END, RangeEnumSTART_TO_ENDIsWrongUseDontCheckEnums); |
|
92 COMPILE_ASSERT(2 == Range::END_TO_END, RangeEnumEND_TO_ENDIsWrongUseDontCheckEnums); |
|
93 COMPILE_ASSERT(3 == Range::END_TO_START, RangeEnumEND_TO_STARTIsWrongUseDontCheckEnums); |
|
94 COMPILE_ASSERT(0 == Range::NODE_BEFORE, RangeEnumNODE_BEFOREIsWrongUseDontCheckEnums); |
|
95 COMPILE_ASSERT(1 == Range::NODE_AFTER, RangeEnumNODE_AFTERIsWrongUseDontCheckEnums); |
|
96 COMPILE_ASSERT(2 == Range::NODE_BEFORE_AND_AFTER, RangeEnumNODE_BEFORE_AND_AFTERIsWrongUseDontCheckEnums); |
|
97 COMPILE_ASSERT(3 == Range::NODE_INSIDE, RangeEnumNODE_INSIDEIsWrongUseDontCheckEnums); |
|
98 |
|
99 class JSRangeConstructor : public DOMConstructorObject { |
|
100 public: |
|
101 JSRangeConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
102 |
|
103 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
104 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
105 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
106 static const JSC::ClassInfo s_info; |
|
107 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
108 { |
|
109 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
110 } |
|
111 protected: |
|
112 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
113 }; |
|
114 |
|
115 const ClassInfo JSRangeConstructor::s_info = { "RangeConstructor", 0, &JSRangeConstructorTable, 0 }; |
|
116 |
|
117 JSRangeConstructor::JSRangeConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
118 : DOMConstructorObject(JSRangeConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
119 { |
|
120 putDirect(exec->propertyNames().prototype, JSRangePrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
121 } |
|
122 |
|
123 bool JSRangeConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
124 { |
|
125 return getStaticValueSlot<JSRangeConstructor, DOMObject>(exec, &JSRangeConstructorTable, this, propertyName, slot); |
|
126 } |
|
127 |
|
128 bool JSRangeConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
129 { |
|
130 return getStaticValueDescriptor<JSRangeConstructor, DOMObject>(exec, &JSRangeConstructorTable, this, propertyName, descriptor); |
|
131 } |
|
132 |
|
133 /* Hash table for prototype */ |
|
134 #if ENABLE(JIT) |
|
135 #define THUNK_GENERATOR(generator) , generator |
|
136 #else |
|
137 #define THUNK_GENERATOR(generator) |
|
138 #endif |
|
139 |
|
140 static const HashTableValue JSRangePrototypeTableValues[35] = |
|
141 { |
|
142 { "START_TO_START", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeSTART_TO_START), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
143 { "START_TO_END", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeSTART_TO_END), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
144 { "END_TO_END", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEND_TO_END), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
145 { "END_TO_START", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEND_TO_START), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
146 { "NODE_BEFORE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_BEFORE), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
147 { "NODE_AFTER", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_AFTER), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
148 { "NODE_BEFORE_AND_AFTER", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_BEFORE_AND_AFTER), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
149 { "NODE_INSIDE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeNODE_INSIDE), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
150 { "setStart", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSetStart), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
151 { "setEnd", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSetEnd), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
152 { "setStartBefore", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSetStartBefore), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
153 { "setStartAfter", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSetStartAfter), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
154 { "setEndBefore", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSetEndBefore), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
155 { "setEndAfter", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSetEndAfter), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
156 { "collapse", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionCollapse), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
157 { "selectNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSelectNode), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
158 { "selectNodeContents", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSelectNodeContents), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
159 { "compareBoundaryPoints", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionCompareBoundaryPoints), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
160 { "deleteContents", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionDeleteContents), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
161 { "extractContents", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionExtractContents), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
162 { "cloneContents", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionCloneContents), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
163 { "insertNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionInsertNode), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
164 { "surroundContents", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionSurroundContents), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
165 { "cloneRange", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionCloneRange), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
166 { "toString", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionToString), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
167 { "detach", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionDetach), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
168 { "getClientRects", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionGetClientRects), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
169 { "getBoundingClientRect", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionGetBoundingClientRect), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
170 { "createContextualFragment", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionCreateContextualFragment), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
171 { "intersectsNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionIntersectsNode), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
172 { "compareNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionCompareNode), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
173 { "comparePoint", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionComparePoint), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
174 { "isPointInRange", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionIsPointInRange), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
175 { "expand", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsRangePrototypeFunctionExpand), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
176 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
177 }; |
|
178 |
|
179 #undef THUNK_GENERATOR |
|
180 static JSC_CONST_HASHTABLE HashTable JSRangePrototypeTable = { 132, 127, JSRangePrototypeTableValues, 0 }; |
|
181 const ClassInfo JSRangePrototype::s_info = { "RangePrototype", 0, &JSRangePrototypeTable, 0 }; |
|
182 |
|
183 JSObject* JSRangePrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
184 { |
|
185 return getDOMPrototype<JSRange>(exec, globalObject); |
|
186 } |
|
187 |
|
188 bool JSRangePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
189 { |
|
190 return getStaticPropertySlot<JSRangePrototype, JSObject>(exec, &JSRangePrototypeTable, this, propertyName, slot); |
|
191 } |
|
192 |
|
193 bool JSRangePrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
194 { |
|
195 return getStaticPropertyDescriptor<JSRangePrototype, JSObject>(exec, &JSRangePrototypeTable, this, propertyName, descriptor); |
|
196 } |
|
197 |
|
198 const ClassInfo JSRange::s_info = { "Range", 0, &JSRangeTable, 0 }; |
|
199 |
|
200 JSRange::JSRange(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<Range> impl) |
|
201 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
202 , m_impl(impl) |
|
203 { |
|
204 } |
|
205 |
|
206 JSRange::~JSRange() |
|
207 { |
|
208 forgetDOMObject(this, impl()); |
|
209 } |
|
210 |
|
211 JSObject* JSRange::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
212 { |
|
213 return new (exec) JSRangePrototype(globalObject, JSRangePrototype::createStructure(globalObject->objectPrototype())); |
|
214 } |
|
215 |
|
216 bool JSRange::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
217 { |
|
218 return getStaticValueSlot<JSRange, Base>(exec, &JSRangeTable, this, propertyName, slot); |
|
219 } |
|
220 |
|
221 bool JSRange::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
222 { |
|
223 return getStaticValueDescriptor<JSRange, Base>(exec, &JSRangeTable, this, propertyName, descriptor); |
|
224 } |
|
225 |
|
226 JSValue jsRangeStartContainer(ExecState* exec, JSValue slotBase, const Identifier&) |
|
227 { |
|
228 JSRange* castedThis = static_cast<JSRange*>(asObject(slotBase)); |
|
229 ExceptionCode ec = 0; |
|
230 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
231 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->startContainer(ec))); |
|
232 setDOMException(exec, ec); |
|
233 return result; |
|
234 } |
|
235 |
|
236 JSValue jsRangeStartOffset(ExecState* exec, JSValue slotBase, const Identifier&) |
|
237 { |
|
238 JSRange* castedThis = static_cast<JSRange*>(asObject(slotBase)); |
|
239 ExceptionCode ec = 0; |
|
240 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
241 JSC::JSValue result = jsNumber(exec, imp->startOffset(ec)); |
|
242 setDOMException(exec, ec); |
|
243 return result; |
|
244 } |
|
245 |
|
246 JSValue jsRangeEndContainer(ExecState* exec, JSValue slotBase, const Identifier&) |
|
247 { |
|
248 JSRange* castedThis = static_cast<JSRange*>(asObject(slotBase)); |
|
249 ExceptionCode ec = 0; |
|
250 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
251 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->endContainer(ec))); |
|
252 setDOMException(exec, ec); |
|
253 return result; |
|
254 } |
|
255 |
|
256 JSValue jsRangeEndOffset(ExecState* exec, JSValue slotBase, const Identifier&) |
|
257 { |
|
258 JSRange* castedThis = static_cast<JSRange*>(asObject(slotBase)); |
|
259 ExceptionCode ec = 0; |
|
260 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
261 JSC::JSValue result = jsNumber(exec, imp->endOffset(ec)); |
|
262 setDOMException(exec, ec); |
|
263 return result; |
|
264 } |
|
265 |
|
266 JSValue jsRangeCollapsed(ExecState* exec, JSValue slotBase, const Identifier&) |
|
267 { |
|
268 JSRange* castedThis = static_cast<JSRange*>(asObject(slotBase)); |
|
269 ExceptionCode ec = 0; |
|
270 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
271 JSC::JSValue result = jsBoolean(imp->collapsed(ec)); |
|
272 setDOMException(exec, ec); |
|
273 return result; |
|
274 } |
|
275 |
|
276 JSValue jsRangeCommonAncestorContainer(ExecState* exec, JSValue slotBase, const Identifier&) |
|
277 { |
|
278 JSRange* castedThis = static_cast<JSRange*>(asObject(slotBase)); |
|
279 ExceptionCode ec = 0; |
|
280 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
281 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->commonAncestorContainer(ec))); |
|
282 setDOMException(exec, ec); |
|
283 return result; |
|
284 } |
|
285 |
|
286 JSValue jsRangeConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
287 { |
|
288 JSRange* domObject = static_cast<JSRange*>(asObject(slotBase)); |
|
289 return JSRange::getConstructor(exec, domObject->globalObject()); |
|
290 } |
|
291 JSValue JSRange::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
292 { |
|
293 return getDOMConstructor<JSRangeConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
294 } |
|
295 |
|
296 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStart(ExecState* exec) |
|
297 { |
|
298 JSValue thisValue = exec->hostThisValue(); |
|
299 if (!thisValue.inherits(&JSRange::s_info)) |
|
300 return throwVMTypeError(exec); |
|
301 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
302 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
303 ExceptionCode ec = 0; |
|
304 Node* refNode = toNode(exec->argument(0)); |
|
305 int offset = exec->argument(1).toInt32(exec); |
|
306 |
|
307 imp->setStart(refNode, offset, ec); |
|
308 setDOMException(exec, ec); |
|
309 return JSValue::encode(jsUndefined()); |
|
310 } |
|
311 |
|
312 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEnd(ExecState* exec) |
|
313 { |
|
314 JSValue thisValue = exec->hostThisValue(); |
|
315 if (!thisValue.inherits(&JSRange::s_info)) |
|
316 return throwVMTypeError(exec); |
|
317 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
318 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
319 ExceptionCode ec = 0; |
|
320 Node* refNode = toNode(exec->argument(0)); |
|
321 int offset = exec->argument(1).toInt32(exec); |
|
322 |
|
323 imp->setEnd(refNode, offset, ec); |
|
324 setDOMException(exec, ec); |
|
325 return JSValue::encode(jsUndefined()); |
|
326 } |
|
327 |
|
328 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStartBefore(ExecState* exec) |
|
329 { |
|
330 JSValue thisValue = exec->hostThisValue(); |
|
331 if (!thisValue.inherits(&JSRange::s_info)) |
|
332 return throwVMTypeError(exec); |
|
333 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
334 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
335 ExceptionCode ec = 0; |
|
336 Node* refNode = toNode(exec->argument(0)); |
|
337 |
|
338 imp->setStartBefore(refNode, ec); |
|
339 setDOMException(exec, ec); |
|
340 return JSValue::encode(jsUndefined()); |
|
341 } |
|
342 |
|
343 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStartAfter(ExecState* exec) |
|
344 { |
|
345 JSValue thisValue = exec->hostThisValue(); |
|
346 if (!thisValue.inherits(&JSRange::s_info)) |
|
347 return throwVMTypeError(exec); |
|
348 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
349 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
350 ExceptionCode ec = 0; |
|
351 Node* refNode = toNode(exec->argument(0)); |
|
352 |
|
353 imp->setStartAfter(refNode, ec); |
|
354 setDOMException(exec, ec); |
|
355 return JSValue::encode(jsUndefined()); |
|
356 } |
|
357 |
|
358 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEndBefore(ExecState* exec) |
|
359 { |
|
360 JSValue thisValue = exec->hostThisValue(); |
|
361 if (!thisValue.inherits(&JSRange::s_info)) |
|
362 return throwVMTypeError(exec); |
|
363 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
364 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
365 ExceptionCode ec = 0; |
|
366 Node* refNode = toNode(exec->argument(0)); |
|
367 |
|
368 imp->setEndBefore(refNode, ec); |
|
369 setDOMException(exec, ec); |
|
370 return JSValue::encode(jsUndefined()); |
|
371 } |
|
372 |
|
373 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEndAfter(ExecState* exec) |
|
374 { |
|
375 JSValue thisValue = exec->hostThisValue(); |
|
376 if (!thisValue.inherits(&JSRange::s_info)) |
|
377 return throwVMTypeError(exec); |
|
378 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
379 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
380 ExceptionCode ec = 0; |
|
381 Node* refNode = toNode(exec->argument(0)); |
|
382 |
|
383 imp->setEndAfter(refNode, ec); |
|
384 setDOMException(exec, ec); |
|
385 return JSValue::encode(jsUndefined()); |
|
386 } |
|
387 |
|
388 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCollapse(ExecState* exec) |
|
389 { |
|
390 JSValue thisValue = exec->hostThisValue(); |
|
391 if (!thisValue.inherits(&JSRange::s_info)) |
|
392 return throwVMTypeError(exec); |
|
393 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
394 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
395 ExceptionCode ec = 0; |
|
396 bool toStart = exec->argument(0).toBoolean(exec); |
|
397 |
|
398 imp->collapse(toStart, ec); |
|
399 setDOMException(exec, ec); |
|
400 return JSValue::encode(jsUndefined()); |
|
401 } |
|
402 |
|
403 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSelectNode(ExecState* exec) |
|
404 { |
|
405 JSValue thisValue = exec->hostThisValue(); |
|
406 if (!thisValue.inherits(&JSRange::s_info)) |
|
407 return throwVMTypeError(exec); |
|
408 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
409 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
410 ExceptionCode ec = 0; |
|
411 Node* refNode = toNode(exec->argument(0)); |
|
412 |
|
413 imp->selectNode(refNode, ec); |
|
414 setDOMException(exec, ec); |
|
415 return JSValue::encode(jsUndefined()); |
|
416 } |
|
417 |
|
418 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSelectNodeContents(ExecState* exec) |
|
419 { |
|
420 JSValue thisValue = exec->hostThisValue(); |
|
421 if (!thisValue.inherits(&JSRange::s_info)) |
|
422 return throwVMTypeError(exec); |
|
423 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
424 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
425 ExceptionCode ec = 0; |
|
426 Node* refNode = toNode(exec->argument(0)); |
|
427 |
|
428 imp->selectNodeContents(refNode, ec); |
|
429 setDOMException(exec, ec); |
|
430 return JSValue::encode(jsUndefined()); |
|
431 } |
|
432 |
|
433 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareBoundaryPoints(ExecState* exec) |
|
434 { |
|
435 JSValue thisValue = exec->hostThisValue(); |
|
436 if (!thisValue.inherits(&JSRange::s_info)) |
|
437 return throwVMTypeError(exec); |
|
438 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
439 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
440 ExceptionCode ec = 0; |
|
441 Range::CompareHow how = static_cast<Range::CompareHow>(exec->argument(0).toInt32(exec)); |
|
442 Range* sourceRange = toRange(exec->argument(1)); |
|
443 |
|
444 |
|
445 JSC::JSValue result = jsNumber(exec, imp->compareBoundaryPoints(how, sourceRange, ec)); |
|
446 setDOMException(exec, ec); |
|
447 return JSValue::encode(result); |
|
448 } |
|
449 |
|
450 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionDeleteContents(ExecState* exec) |
|
451 { |
|
452 JSValue thisValue = exec->hostThisValue(); |
|
453 if (!thisValue.inherits(&JSRange::s_info)) |
|
454 return throwVMTypeError(exec); |
|
455 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
456 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
457 ExceptionCode ec = 0; |
|
458 |
|
459 imp->deleteContents(ec); |
|
460 setDOMException(exec, ec); |
|
461 return JSValue::encode(jsUndefined()); |
|
462 } |
|
463 |
|
464 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionExtractContents(ExecState* exec) |
|
465 { |
|
466 JSValue thisValue = exec->hostThisValue(); |
|
467 if (!thisValue.inherits(&JSRange::s_info)) |
|
468 return throwVMTypeError(exec); |
|
469 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
470 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
471 ExceptionCode ec = 0; |
|
472 |
|
473 |
|
474 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->extractContents(ec))); |
|
475 setDOMException(exec, ec); |
|
476 return JSValue::encode(result); |
|
477 } |
|
478 |
|
479 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneContents(ExecState* exec) |
|
480 { |
|
481 JSValue thisValue = exec->hostThisValue(); |
|
482 if (!thisValue.inherits(&JSRange::s_info)) |
|
483 return throwVMTypeError(exec); |
|
484 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
485 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
486 ExceptionCode ec = 0; |
|
487 |
|
488 |
|
489 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->cloneContents(ec))); |
|
490 setDOMException(exec, ec); |
|
491 return JSValue::encode(result); |
|
492 } |
|
493 |
|
494 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionInsertNode(ExecState* exec) |
|
495 { |
|
496 JSValue thisValue = exec->hostThisValue(); |
|
497 if (!thisValue.inherits(&JSRange::s_info)) |
|
498 return throwVMTypeError(exec); |
|
499 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
500 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
501 ExceptionCode ec = 0; |
|
502 Node* newNode = toNode(exec->argument(0)); |
|
503 |
|
504 imp->insertNode(newNode, ec); |
|
505 setDOMException(exec, ec); |
|
506 return JSValue::encode(jsUndefined()); |
|
507 } |
|
508 |
|
509 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSurroundContents(ExecState* exec) |
|
510 { |
|
511 JSValue thisValue = exec->hostThisValue(); |
|
512 if (!thisValue.inherits(&JSRange::s_info)) |
|
513 return throwVMTypeError(exec); |
|
514 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
515 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
516 ExceptionCode ec = 0; |
|
517 Node* newParent = toNode(exec->argument(0)); |
|
518 |
|
519 imp->surroundContents(newParent, ec); |
|
520 setDOMException(exec, ec); |
|
521 return JSValue::encode(jsUndefined()); |
|
522 } |
|
523 |
|
524 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneRange(ExecState* exec) |
|
525 { |
|
526 JSValue thisValue = exec->hostThisValue(); |
|
527 if (!thisValue.inherits(&JSRange::s_info)) |
|
528 return throwVMTypeError(exec); |
|
529 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
530 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
531 ExceptionCode ec = 0; |
|
532 |
|
533 |
|
534 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->cloneRange(ec))); |
|
535 setDOMException(exec, ec); |
|
536 return JSValue::encode(result); |
|
537 } |
|
538 |
|
539 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionToString(ExecState* exec) |
|
540 { |
|
541 JSValue thisValue = exec->hostThisValue(); |
|
542 if (!thisValue.inherits(&JSRange::s_info)) |
|
543 return throwVMTypeError(exec); |
|
544 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
545 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
546 ExceptionCode ec = 0; |
|
547 |
|
548 |
|
549 JSC::JSValue result = jsString(exec, imp->toString(ec)); |
|
550 setDOMException(exec, ec); |
|
551 return JSValue::encode(result); |
|
552 } |
|
553 |
|
554 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionDetach(ExecState* exec) |
|
555 { |
|
556 JSValue thisValue = exec->hostThisValue(); |
|
557 if (!thisValue.inherits(&JSRange::s_info)) |
|
558 return throwVMTypeError(exec); |
|
559 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
560 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
561 ExceptionCode ec = 0; |
|
562 |
|
563 imp->detach(ec); |
|
564 setDOMException(exec, ec); |
|
565 return JSValue::encode(jsUndefined()); |
|
566 } |
|
567 |
|
568 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionGetClientRects(ExecState* exec) |
|
569 { |
|
570 JSValue thisValue = exec->hostThisValue(); |
|
571 if (!thisValue.inherits(&JSRange::s_info)) |
|
572 return throwVMTypeError(exec); |
|
573 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
574 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
575 |
|
576 |
|
577 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getClientRects())); |
|
578 return JSValue::encode(result); |
|
579 } |
|
580 |
|
581 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionGetBoundingClientRect(ExecState* exec) |
|
582 { |
|
583 JSValue thisValue = exec->hostThisValue(); |
|
584 if (!thisValue.inherits(&JSRange::s_info)) |
|
585 return throwVMTypeError(exec); |
|
586 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
587 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
588 |
|
589 |
|
590 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->getBoundingClientRect())); |
|
591 return JSValue::encode(result); |
|
592 } |
|
593 |
|
594 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCreateContextualFragment(ExecState* exec) |
|
595 { |
|
596 JSValue thisValue = exec->hostThisValue(); |
|
597 if (!thisValue.inherits(&JSRange::s_info)) |
|
598 return throwVMTypeError(exec); |
|
599 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
600 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
601 ExceptionCode ec = 0; |
|
602 const String& html = ustringToString(exec->argument(0).toString(exec)); |
|
603 |
|
604 |
|
605 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createContextualFragment(html, ec))); |
|
606 setDOMException(exec, ec); |
|
607 return JSValue::encode(result); |
|
608 } |
|
609 |
|
610 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionIntersectsNode(ExecState* exec) |
|
611 { |
|
612 JSValue thisValue = exec->hostThisValue(); |
|
613 if (!thisValue.inherits(&JSRange::s_info)) |
|
614 return throwVMTypeError(exec); |
|
615 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
616 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
617 ExceptionCode ec = 0; |
|
618 Node* refNode = toNode(exec->argument(0)); |
|
619 |
|
620 |
|
621 JSC::JSValue result = jsBoolean(imp->intersectsNode(refNode, ec)); |
|
622 setDOMException(exec, ec); |
|
623 return JSValue::encode(result); |
|
624 } |
|
625 |
|
626 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareNode(ExecState* exec) |
|
627 { |
|
628 JSValue thisValue = exec->hostThisValue(); |
|
629 if (!thisValue.inherits(&JSRange::s_info)) |
|
630 return throwVMTypeError(exec); |
|
631 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
632 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
633 ExceptionCode ec = 0; |
|
634 Node* refNode = toNode(exec->argument(0)); |
|
635 |
|
636 |
|
637 JSC::JSValue result = jsNumber(exec, imp->compareNode(refNode, ec)); |
|
638 setDOMException(exec, ec); |
|
639 return JSValue::encode(result); |
|
640 } |
|
641 |
|
642 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionComparePoint(ExecState* exec) |
|
643 { |
|
644 JSValue thisValue = exec->hostThisValue(); |
|
645 if (!thisValue.inherits(&JSRange::s_info)) |
|
646 return throwVMTypeError(exec); |
|
647 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
648 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
649 ExceptionCode ec = 0; |
|
650 Node* refNode = toNode(exec->argument(0)); |
|
651 int offset = exec->argument(1).toInt32(exec); |
|
652 |
|
653 |
|
654 JSC::JSValue result = jsNumber(exec, imp->comparePoint(refNode, offset, ec)); |
|
655 setDOMException(exec, ec); |
|
656 return JSValue::encode(result); |
|
657 } |
|
658 |
|
659 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionIsPointInRange(ExecState* exec) |
|
660 { |
|
661 JSValue thisValue = exec->hostThisValue(); |
|
662 if (!thisValue.inherits(&JSRange::s_info)) |
|
663 return throwVMTypeError(exec); |
|
664 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
665 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
666 ExceptionCode ec = 0; |
|
667 Node* refNode = toNode(exec->argument(0)); |
|
668 int offset = exec->argument(1).toInt32(exec); |
|
669 |
|
670 |
|
671 JSC::JSValue result = jsBoolean(imp->isPointInRange(refNode, offset, ec)); |
|
672 setDOMException(exec, ec); |
|
673 return JSValue::encode(result); |
|
674 } |
|
675 |
|
676 EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionExpand(ExecState* exec) |
|
677 { |
|
678 JSValue thisValue = exec->hostThisValue(); |
|
679 if (!thisValue.inherits(&JSRange::s_info)) |
|
680 return throwVMTypeError(exec); |
|
681 JSRange* castedThis = static_cast<JSRange*>(asObject(thisValue)); |
|
682 Range* imp = static_cast<Range*>(castedThis->impl()); |
|
683 ExceptionCode ec = 0; |
|
684 const String& unit = ustringToString(exec->argument(0).toString(exec)); |
|
685 |
|
686 imp->expand(unit, ec); |
|
687 setDOMException(exec, ec); |
|
688 return JSValue::encode(jsUndefined()); |
|
689 } |
|
690 |
|
691 // Constant getters |
|
692 |
|
693 JSValue jsRangeSTART_TO_START(ExecState* exec, JSValue, const Identifier&) |
|
694 { |
|
695 return jsNumber(exec, static_cast<int>(0)); |
|
696 } |
|
697 |
|
698 JSValue jsRangeSTART_TO_END(ExecState* exec, JSValue, const Identifier&) |
|
699 { |
|
700 return jsNumber(exec, static_cast<int>(1)); |
|
701 } |
|
702 |
|
703 JSValue jsRangeEND_TO_END(ExecState* exec, JSValue, const Identifier&) |
|
704 { |
|
705 return jsNumber(exec, static_cast<int>(2)); |
|
706 } |
|
707 |
|
708 JSValue jsRangeEND_TO_START(ExecState* exec, JSValue, const Identifier&) |
|
709 { |
|
710 return jsNumber(exec, static_cast<int>(3)); |
|
711 } |
|
712 |
|
713 JSValue jsRangeNODE_BEFORE(ExecState* exec, JSValue, const Identifier&) |
|
714 { |
|
715 return jsNumber(exec, static_cast<int>(0)); |
|
716 } |
|
717 |
|
718 JSValue jsRangeNODE_AFTER(ExecState* exec, JSValue, const Identifier&) |
|
719 { |
|
720 return jsNumber(exec, static_cast<int>(1)); |
|
721 } |
|
722 |
|
723 JSValue jsRangeNODE_BEFORE_AND_AFTER(ExecState* exec, JSValue, const Identifier&) |
|
724 { |
|
725 return jsNumber(exec, static_cast<int>(2)); |
|
726 } |
|
727 |
|
728 JSValue jsRangeNODE_INSIDE(ExecState* exec, JSValue, const Identifier&) |
|
729 { |
|
730 return jsNumber(exec, static_cast<int>(3)); |
|
731 } |
|
732 |
|
733 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Range* object) |
|
734 { |
|
735 return getDOMObjectWrapper<JSRange>(exec, globalObject, object); |
|
736 } |
|
737 Range* toRange(JSC::JSValue value) |
|
738 { |
|
739 return value.inherits(&JSRange::s_info) ? static_cast<JSRange*>(asObject(value))->impl() : 0; |
|
740 } |
|
741 |
|
742 } |