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 "JSTreeWalker.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertCallbacks.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertNullable.h" |
30 | #include "JSDOMConvertNumbers.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMGlobalObject.h" |
33 | #include "JSDOMOperation.h" |
34 | #include "JSDOMWrapperCache.h" |
35 | #include "JSNode.h" |
36 | #include "JSNodeFilter.h" |
37 | #include "ScriptExecutionContext.h" |
38 | #include <JavaScriptCore/FunctionPrototype.h> |
39 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
40 | #include <JavaScriptCore/JSCInlines.h> |
41 | #include <wtf/GetPtr.h> |
42 | #include <wtf/PointerPreparations.h> |
43 | #include <wtf/URL.h> |
44 | |
45 | |
46 | namespace WebCore { |
47 | using namespace JSC; |
48 | |
49 | // Functions |
50 | |
51 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionParentNode(JSC::ExecState*); |
52 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionFirstChild(JSC::ExecState*); |
53 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionLastChild(JSC::ExecState*); |
54 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionPreviousSibling(JSC::ExecState*); |
55 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionNextSibling(JSC::ExecState*); |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionPreviousNode(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionNextNode(JSC::ExecState*); |
58 | |
59 | // Attributes |
60 | |
61 | JSC::EncodedJSValue jsTreeWalkerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
62 | bool setJSTreeWalkerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
63 | JSC::EncodedJSValue jsTreeWalkerRoot(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
64 | JSC::EncodedJSValue jsTreeWalkerWhatToShow(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
65 | JSC::EncodedJSValue jsTreeWalkerFilter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
66 | JSC::EncodedJSValue jsTreeWalkerCurrentNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
67 | bool setJSTreeWalkerCurrentNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
68 | |
69 | class JSTreeWalkerPrototype : public JSC::JSNonFinalObject { |
70 | public: |
71 | using Base = JSC::JSNonFinalObject; |
72 | static JSTreeWalkerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
73 | { |
74 | JSTreeWalkerPrototype* ptr = new (NotNull, JSC::allocateCell<JSTreeWalkerPrototype>(vm.heap)) JSTreeWalkerPrototype(vm, globalObject, structure); |
75 | ptr->finishCreation(vm); |
76 | return ptr; |
77 | } |
78 | |
79 | DECLARE_INFO; |
80 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
81 | { |
82 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
83 | } |
84 | |
85 | private: |
86 | JSTreeWalkerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
87 | : JSC::JSNonFinalObject(vm, structure) |
88 | { |
89 | } |
90 | |
91 | void finishCreation(JSC::VM&); |
92 | }; |
93 | |
94 | using JSTreeWalkerConstructor = JSDOMConstructorNotConstructable<JSTreeWalker>; |
95 | |
96 | template<> JSValue JSTreeWalkerConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
97 | { |
98 | UNUSED_PARAM(vm); |
99 | return globalObject.functionPrototype(); |
100 | } |
101 | |
102 | template<> void JSTreeWalkerConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
103 | { |
104 | putDirect(vm, vm.propertyNames->prototype, JSTreeWalker::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
105 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TreeWalker"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
106 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
107 | } |
108 | |
109 | template<> const ClassInfo JSTreeWalkerConstructor::s_info = { "TreeWalker" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTreeWalkerConstructor) }; |
110 | |
111 | /* Hash table for prototype */ |
112 | |
113 | static const HashTableValue JSTreeWalkerPrototypeTableValues[] = |
114 | { |
115 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTreeWalkerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTreeWalkerConstructor) } }, |
116 | { "root" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTreeWalkerRoot), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
117 | { "whatToShow" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTreeWalkerWhatToShow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
118 | { "filter" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTreeWalkerFilter), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
119 | { "currentNode" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTreeWalkerCurrentNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTreeWalkerCurrentNode) } }, |
120 | { "parentNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionParentNode), (intptr_t) (0) } }, |
121 | { "firstChild" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionFirstChild), (intptr_t) (0) } }, |
122 | { "lastChild" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionLastChild), (intptr_t) (0) } }, |
123 | { "previousSibling" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionPreviousSibling), (intptr_t) (0) } }, |
124 | { "nextSibling" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionNextSibling), (intptr_t) (0) } }, |
125 | { "previousNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionPreviousNode), (intptr_t) (0) } }, |
126 | { "nextNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTreeWalkerPrototypeFunctionNextNode), (intptr_t) (0) } }, |
127 | }; |
128 | |
129 | const ClassInfo JSTreeWalkerPrototype::s_info = { "TreeWalkerPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTreeWalkerPrototype) }; |
130 | |
131 | void JSTreeWalkerPrototype::finishCreation(VM& vm) |
132 | { |
133 | Base::finishCreation(vm); |
134 | reifyStaticProperties(vm, JSTreeWalker::info(), JSTreeWalkerPrototypeTableValues, *this); |
135 | } |
136 | |
137 | const ClassInfo JSTreeWalker::s_info = { "TreeWalker" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTreeWalker) }; |
138 | |
139 | JSTreeWalker::JSTreeWalker(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TreeWalker>&& impl) |
140 | : JSDOMWrapper<TreeWalker>(structure, globalObject, WTFMove(impl)) |
141 | { |
142 | } |
143 | |
144 | void JSTreeWalker::finishCreation(VM& vm) |
145 | { |
146 | Base::finishCreation(vm); |
147 | ASSERT(inherits(vm, info())); |
148 | |
149 | } |
150 | |
151 | JSObject* JSTreeWalker::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
152 | { |
153 | return JSTreeWalkerPrototype::create(vm, &globalObject, JSTreeWalkerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
154 | } |
155 | |
156 | JSObject* JSTreeWalker::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
157 | { |
158 | return getDOMPrototype<JSTreeWalker>(vm, globalObject); |
159 | } |
160 | |
161 | JSValue JSTreeWalker::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
162 | { |
163 | return getDOMConstructor<JSTreeWalkerConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
164 | } |
165 | |
166 | void JSTreeWalker::destroy(JSC::JSCell* cell) |
167 | { |
168 | JSTreeWalker* thisObject = static_cast<JSTreeWalker*>(cell); |
169 | thisObject->JSTreeWalker::~JSTreeWalker(); |
170 | } |
171 | |
172 | template<> inline JSTreeWalker* IDLAttribute<JSTreeWalker>::cast(ExecState& state, EncodedJSValue thisValue) |
173 | { |
174 | return jsDynamicCast<JSTreeWalker*>(state.vm(), JSValue::decode(thisValue)); |
175 | } |
176 | |
177 | template<> inline JSTreeWalker* IDLOperation<JSTreeWalker>::cast(ExecState& state) |
178 | { |
179 | return jsDynamicCast<JSTreeWalker*>(state.vm(), state.thisValue()); |
180 | } |
181 | |
182 | EncodedJSValue jsTreeWalkerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
183 | { |
184 | VM& vm = state->vm(); |
185 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
186 | auto* prototype = jsDynamicCast<JSTreeWalkerPrototype*>(vm, JSValue::decode(thisValue)); |
187 | if (UNLIKELY(!prototype)) |
188 | return throwVMTypeError(state, throwScope); |
189 | return JSValue::encode(JSTreeWalker::getConstructor(state->vm(), prototype->globalObject())); |
190 | } |
191 | |
192 | bool setJSTreeWalkerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
193 | { |
194 | VM& vm = state->vm(); |
195 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
196 | auto* prototype = jsDynamicCast<JSTreeWalkerPrototype*>(vm, JSValue::decode(thisValue)); |
197 | if (UNLIKELY(!prototype)) { |
198 | throwVMTypeError(state, throwScope); |
199 | return false; |
200 | } |
201 | // Shadowing a built-in constructor |
202 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
203 | } |
204 | |
205 | static inline JSValue jsTreeWalkerRootGetter(ExecState& state, JSTreeWalker& thisObject, ThrowScope& throwScope) |
206 | { |
207 | UNUSED_PARAM(throwScope); |
208 | UNUSED_PARAM(state); |
209 | auto& impl = thisObject.wrapped(); |
210 | JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.root()); |
211 | return result; |
212 | } |
213 | |
214 | EncodedJSValue jsTreeWalkerRoot(ExecState* state, EncodedJSValue thisValue, PropertyName) |
215 | { |
216 | return IDLAttribute<JSTreeWalker>::get<jsTreeWalkerRootGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "root" ); |
217 | } |
218 | |
219 | static inline JSValue jsTreeWalkerWhatToShowGetter(ExecState& state, JSTreeWalker& thisObject, ThrowScope& throwScope) |
220 | { |
221 | UNUSED_PARAM(throwScope); |
222 | UNUSED_PARAM(state); |
223 | auto& impl = thisObject.wrapped(); |
224 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.whatToShow()); |
225 | return result; |
226 | } |
227 | |
228 | EncodedJSValue jsTreeWalkerWhatToShow(ExecState* state, EncodedJSValue thisValue, PropertyName) |
229 | { |
230 | return IDLAttribute<JSTreeWalker>::get<jsTreeWalkerWhatToShowGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "whatToShow" ); |
231 | } |
232 | |
233 | static inline JSValue jsTreeWalkerFilterGetter(ExecState& state, JSTreeWalker& thisObject, ThrowScope& throwScope) |
234 | { |
235 | UNUSED_PARAM(throwScope); |
236 | UNUSED_PARAM(state); |
237 | auto& impl = thisObject.wrapped(); |
238 | JSValue result = toJS<IDLNullable<IDLCallbackInterface<JSNodeFilter>>>(state, *thisObject.globalObject(), throwScope, impl.filter()); |
239 | return result; |
240 | } |
241 | |
242 | EncodedJSValue jsTreeWalkerFilter(ExecState* state, EncodedJSValue thisValue, PropertyName) |
243 | { |
244 | return IDLAttribute<JSTreeWalker>::get<jsTreeWalkerFilterGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "filter" ); |
245 | } |
246 | |
247 | static inline JSValue jsTreeWalkerCurrentNodeGetter(ExecState& state, JSTreeWalker& thisObject, ThrowScope& throwScope) |
248 | { |
249 | UNUSED_PARAM(throwScope); |
250 | UNUSED_PARAM(state); |
251 | auto& impl = thisObject.wrapped(); |
252 | JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.currentNode()); |
253 | return result; |
254 | } |
255 | |
256 | EncodedJSValue jsTreeWalkerCurrentNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
257 | { |
258 | return IDLAttribute<JSTreeWalker>::get<jsTreeWalkerCurrentNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "currentNode" ); |
259 | } |
260 | |
261 | static inline bool setJSTreeWalkerCurrentNodeSetter(ExecState& state, JSTreeWalker& thisObject, JSValue value, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | auto& impl = thisObject.wrapped(); |
265 | auto nativeValue = convert<IDLInterface<Node>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TreeWalker" , "currentNode" , "Node" ); }); |
266 | RETURN_IF_EXCEPTION(throwScope, false); |
267 | AttributeSetter::call(state, throwScope, [&] { |
268 | return impl.setCurrentNode(*nativeValue); |
269 | }); |
270 | return true; |
271 | } |
272 | |
273 | bool setJSTreeWalkerCurrentNode(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
274 | { |
275 | return IDLAttribute<JSTreeWalker>::set<setJSTreeWalkerCurrentNodeSetter>(*state, thisValue, encodedValue, "currentNode" ); |
276 | } |
277 | |
278 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionParentNodeBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
279 | { |
280 | UNUSED_PARAM(state); |
281 | UNUSED_PARAM(throwScope); |
282 | auto& impl = castedThis->wrapped(); |
283 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.parentNode())); |
284 | } |
285 | |
286 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionParentNode(ExecState* state) |
287 | { |
288 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionParentNodeBody>(*state, "parentNode" ); |
289 | } |
290 | |
291 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionFirstChildBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
292 | { |
293 | UNUSED_PARAM(state); |
294 | UNUSED_PARAM(throwScope); |
295 | auto& impl = castedThis->wrapped(); |
296 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.firstChild())); |
297 | } |
298 | |
299 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionFirstChild(ExecState* state) |
300 | { |
301 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionFirstChildBody>(*state, "firstChild" ); |
302 | } |
303 | |
304 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionLastChildBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
305 | { |
306 | UNUSED_PARAM(state); |
307 | UNUSED_PARAM(throwScope); |
308 | auto& impl = castedThis->wrapped(); |
309 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.lastChild())); |
310 | } |
311 | |
312 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionLastChild(ExecState* state) |
313 | { |
314 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionLastChildBody>(*state, "lastChild" ); |
315 | } |
316 | |
317 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionPreviousSiblingBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
318 | { |
319 | UNUSED_PARAM(state); |
320 | UNUSED_PARAM(throwScope); |
321 | auto& impl = castedThis->wrapped(); |
322 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.previousSibling())); |
323 | } |
324 | |
325 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionPreviousSibling(ExecState* state) |
326 | { |
327 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionPreviousSiblingBody>(*state, "previousSibling" ); |
328 | } |
329 | |
330 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionNextSiblingBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
331 | { |
332 | UNUSED_PARAM(state); |
333 | UNUSED_PARAM(throwScope); |
334 | auto& impl = castedThis->wrapped(); |
335 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.nextSibling())); |
336 | } |
337 | |
338 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionNextSibling(ExecState* state) |
339 | { |
340 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionNextSiblingBody>(*state, "nextSibling" ); |
341 | } |
342 | |
343 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionPreviousNodeBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
344 | { |
345 | UNUSED_PARAM(state); |
346 | UNUSED_PARAM(throwScope); |
347 | auto& impl = castedThis->wrapped(); |
348 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.previousNode())); |
349 | } |
350 | |
351 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionPreviousNode(ExecState* state) |
352 | { |
353 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionPreviousNodeBody>(*state, "previousNode" ); |
354 | } |
355 | |
356 | static inline JSC::EncodedJSValue jsTreeWalkerPrototypeFunctionNextNodeBody(JSC::ExecState* state, typename IDLOperation<JSTreeWalker>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
357 | { |
358 | UNUSED_PARAM(state); |
359 | UNUSED_PARAM(throwScope); |
360 | auto& impl = castedThis->wrapped(); |
361 | return JSValue::encode(toJS<IDLNullable<IDLInterface<Node>>>(*state, *castedThis->globalObject(), throwScope, impl.nextNode())); |
362 | } |
363 | |
364 | EncodedJSValue JSC_HOST_CALL jsTreeWalkerPrototypeFunctionNextNode(ExecState* state) |
365 | { |
366 | return IDLOperation<JSTreeWalker>::call<jsTreeWalkerPrototypeFunctionNextNodeBody>(*state, "nextNode" ); |
367 | } |
368 | |
369 | void JSTreeWalker::visitChildren(JSCell* cell, SlotVisitor& visitor) |
370 | { |
371 | auto* thisObject = jsCast<JSTreeWalker*>(cell); |
372 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
373 | Base::visitChildren(thisObject, visitor); |
374 | thisObject->visitAdditionalChildren(visitor); |
375 | } |
376 | |
377 | void JSTreeWalker::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
378 | { |
379 | auto* thisObject = jsCast<JSTreeWalker*>(cell); |
380 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
381 | Base::visitOutputConstraints(thisObject, visitor); |
382 | thisObject->visitAdditionalChildren(visitor); |
383 | } |
384 | |
385 | void JSTreeWalker::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
386 | { |
387 | auto* thisObject = jsCast<JSTreeWalker*>(cell); |
388 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
389 | if (thisObject->scriptExecutionContext()) |
390 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
391 | Base::heapSnapshot(cell, builder); |
392 | } |
393 | |
394 | bool JSTreeWalkerOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
395 | { |
396 | UNUSED_PARAM(handle); |
397 | UNUSED_PARAM(visitor); |
398 | UNUSED_PARAM(reason); |
399 | return false; |
400 | } |
401 | |
402 | void JSTreeWalkerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
403 | { |
404 | auto* jsTreeWalker = static_cast<JSTreeWalker*>(handle.slot()->asCell()); |
405 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
406 | uncacheWrapper(world, &jsTreeWalker->wrapped(), jsTreeWalker); |
407 | } |
408 | |
409 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TreeWalker>&& impl) |
410 | { |
411 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
412 | // attribute. You should remove that attribute. If the class has subclasses |
413 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
414 | // attribute to TreeWalker. |
415 | static_assert(!std::is_polymorphic<TreeWalker>::value, "TreeWalker is polymorphic but the IDL claims it is not" ); |
416 | return createWrapper<TreeWalker>(globalObject, WTFMove(impl)); |
417 | } |
418 | |
419 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TreeWalker& impl) |
420 | { |
421 | return wrap(state, globalObject, impl); |
422 | } |
423 | |
424 | TreeWalker* JSTreeWalker::toWrapped(JSC::VM& vm, JSC::JSValue value) |
425 | { |
426 | if (auto* wrapper = jsDynamicCast<JSTreeWalker*>(vm, value)) |
427 | return &wrapper->wrapped(); |
428 | return nullptr; |
429 | } |
430 | |
431 | } |
432 | |