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 "JSMutationRecord.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNullable.h"
29#include "JSDOMConvertStrings.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMGlobalObject.h"
32#include "JSDOMWrapperCache.h"
33#include "JSNode.h"
34#include "JSNodeList.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/FunctionPrototype.h>
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43
44namespace WebCore {
45using namespace JSC;
46
47// Attributes
48
49JSC::EncodedJSValue jsMutationRecordConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSMutationRecordConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsMutationRecordType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsMutationRecordTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53JSC::EncodedJSValue jsMutationRecordAddedNodes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54JSC::EncodedJSValue jsMutationRecordRemovedNodes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55JSC::EncodedJSValue jsMutationRecordPreviousSibling(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56JSC::EncodedJSValue jsMutationRecordNextSibling(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57JSC::EncodedJSValue jsMutationRecordAttributeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58JSC::EncodedJSValue jsMutationRecordAttributeNamespace(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59JSC::EncodedJSValue jsMutationRecordOldValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60
61class JSMutationRecordPrototype : public JSC::JSNonFinalObject {
62public:
63 using Base = JSC::JSNonFinalObject;
64 static JSMutationRecordPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
65 {
66 JSMutationRecordPrototype* ptr = new (NotNull, JSC::allocateCell<JSMutationRecordPrototype>(vm.heap)) JSMutationRecordPrototype(vm, globalObject, structure);
67 ptr->finishCreation(vm);
68 return ptr;
69 }
70
71 DECLARE_INFO;
72 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
73 {
74 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
75 }
76
77private:
78 JSMutationRecordPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
79 : JSC::JSNonFinalObject(vm, structure)
80 {
81 }
82
83 void finishCreation(JSC::VM&);
84};
85
86using JSMutationRecordConstructor = JSDOMConstructorNotConstructable<JSMutationRecord>;
87
88template<> JSValue JSMutationRecordConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
89{
90 UNUSED_PARAM(vm);
91 return globalObject.functionPrototype();
92}
93
94template<> void JSMutationRecordConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
95{
96 putDirect(vm, vm.propertyNames->prototype, JSMutationRecord::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MutationRecord"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
99}
100
101template<> const ClassInfo JSMutationRecordConstructor::s_info = { "MutationRecord", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMutationRecordConstructor) };
102
103/* Hash table for prototype */
104
105static const HashTableValue JSMutationRecordPrototypeTableValues[] =
106{
107 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMutationRecordConstructor) } },
108 { "type", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
109 { "target", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
110 { "addedNodes", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordAddedNodes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
111 { "removedNodes", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordRemovedNodes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
112 { "previousSibling", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordPreviousSibling), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
113 { "nextSibling", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordNextSibling), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
114 { "attributeName", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordAttributeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
115 { "attributeNamespace", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordAttributeNamespace), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
116 { "oldValue", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationRecordOldValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
117};
118
119const ClassInfo JSMutationRecordPrototype::s_info = { "MutationRecordPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMutationRecordPrototype) };
120
121void JSMutationRecordPrototype::finishCreation(VM& vm)
122{
123 Base::finishCreation(vm);
124 reifyStaticProperties(vm, JSMutationRecord::info(), JSMutationRecordPrototypeTableValues, *this);
125}
126
127const ClassInfo JSMutationRecord::s_info = { "MutationRecord", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMutationRecord) };
128
129JSMutationRecord::JSMutationRecord(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MutationRecord>&& impl)
130 : JSDOMWrapper<MutationRecord>(structure, globalObject, WTFMove(impl))
131{
132}
133
134void JSMutationRecord::finishCreation(VM& vm)
135{
136 Base::finishCreation(vm);
137 ASSERT(inherits(vm, info()));
138
139}
140
141JSObject* JSMutationRecord::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
142{
143 return JSMutationRecordPrototype::create(vm, &globalObject, JSMutationRecordPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
144}
145
146JSObject* JSMutationRecord::prototype(VM& vm, JSDOMGlobalObject& globalObject)
147{
148 return getDOMPrototype<JSMutationRecord>(vm, globalObject);
149}
150
151JSValue JSMutationRecord::getConstructor(VM& vm, const JSGlobalObject* globalObject)
152{
153 return getDOMConstructor<JSMutationRecordConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
154}
155
156void JSMutationRecord::destroy(JSC::JSCell* cell)
157{
158 JSMutationRecord* thisObject = static_cast<JSMutationRecord*>(cell);
159 thisObject->JSMutationRecord::~JSMutationRecord();
160}
161
162template<> inline JSMutationRecord* IDLAttribute<JSMutationRecord>::cast(ExecState& state, EncodedJSValue thisValue)
163{
164 return jsDynamicCast<JSMutationRecord*>(state.vm(), JSValue::decode(thisValue));
165}
166
167EncodedJSValue jsMutationRecordConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
168{
169 VM& vm = state->vm();
170 auto throwScope = DECLARE_THROW_SCOPE(vm);
171 auto* prototype = jsDynamicCast<JSMutationRecordPrototype*>(vm, JSValue::decode(thisValue));
172 if (UNLIKELY(!prototype))
173 return throwVMTypeError(state, throwScope);
174 return JSValue::encode(JSMutationRecord::getConstructor(state->vm(), prototype->globalObject()));
175}
176
177bool setJSMutationRecordConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
178{
179 VM& vm = state->vm();
180 auto throwScope = DECLARE_THROW_SCOPE(vm);
181 auto* prototype = jsDynamicCast<JSMutationRecordPrototype*>(vm, JSValue::decode(thisValue));
182 if (UNLIKELY(!prototype)) {
183 throwVMTypeError(state, throwScope);
184 return false;
185 }
186 // Shadowing a built-in constructor
187 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
188}
189
190static inline JSValue jsMutationRecordTypeGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
191{
192 UNUSED_PARAM(throwScope);
193 UNUSED_PARAM(state);
194 auto& impl = thisObject.wrapped();
195 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type());
196 return result;
197}
198
199EncodedJSValue jsMutationRecordType(ExecState* state, EncodedJSValue thisValue, PropertyName)
200{
201 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type");
202}
203
204static inline JSValue jsMutationRecordTargetGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
205{
206 UNUSED_PARAM(throwScope);
207 UNUSED_PARAM(state);
208 auto& impl = thisObject.wrapped();
209 JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.target());
210 return result;
211}
212
213EncodedJSValue jsMutationRecordTarget(ExecState* state, EncodedJSValue thisValue, PropertyName)
214{
215 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordTargetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "target");
216}
217
218static inline JSValue jsMutationRecordAddedNodesGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
219{
220 UNUSED_PARAM(throwScope);
221 UNUSED_PARAM(state);
222 auto& impl = thisObject.wrapped();
223 JSValue result = toJS<IDLInterface<NodeList>>(state, *thisObject.globalObject(), throwScope, impl.addedNodes());
224 return result;
225}
226
227EncodedJSValue jsMutationRecordAddedNodes(ExecState* state, EncodedJSValue thisValue, PropertyName)
228{
229 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordAddedNodesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "addedNodes");
230}
231
232static inline JSValue jsMutationRecordRemovedNodesGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
233{
234 UNUSED_PARAM(throwScope);
235 UNUSED_PARAM(state);
236 auto& impl = thisObject.wrapped();
237 JSValue result = toJS<IDLInterface<NodeList>>(state, *thisObject.globalObject(), throwScope, impl.removedNodes());
238 return result;
239}
240
241EncodedJSValue jsMutationRecordRemovedNodes(ExecState* state, EncodedJSValue thisValue, PropertyName)
242{
243 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordRemovedNodesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "removedNodes");
244}
245
246static inline JSValue jsMutationRecordPreviousSiblingGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
247{
248 UNUSED_PARAM(throwScope);
249 UNUSED_PARAM(state);
250 auto& impl = thisObject.wrapped();
251 JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.previousSibling());
252 return result;
253}
254
255EncodedJSValue jsMutationRecordPreviousSibling(ExecState* state, EncodedJSValue thisValue, PropertyName)
256{
257 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordPreviousSiblingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "previousSibling");
258}
259
260static inline JSValue jsMutationRecordNextSiblingGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
261{
262 UNUSED_PARAM(throwScope);
263 UNUSED_PARAM(state);
264 auto& impl = thisObject.wrapped();
265 JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.nextSibling());
266 return result;
267}
268
269EncodedJSValue jsMutationRecordNextSibling(ExecState* state, EncodedJSValue thisValue, PropertyName)
270{
271 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordNextSiblingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "nextSibling");
272}
273
274static inline JSValue jsMutationRecordAttributeNameGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
275{
276 UNUSED_PARAM(throwScope);
277 UNUSED_PARAM(state);
278 auto& impl = thisObject.wrapped();
279 JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.attributeName());
280 return result;
281}
282
283EncodedJSValue jsMutationRecordAttributeName(ExecState* state, EncodedJSValue thisValue, PropertyName)
284{
285 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordAttributeNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attributeName");
286}
287
288static inline JSValue jsMutationRecordAttributeNamespaceGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
289{
290 UNUSED_PARAM(throwScope);
291 UNUSED_PARAM(state);
292 auto& impl = thisObject.wrapped();
293 JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.attributeNamespace());
294 return result;
295}
296
297EncodedJSValue jsMutationRecordAttributeNamespace(ExecState* state, EncodedJSValue thisValue, PropertyName)
298{
299 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordAttributeNamespaceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attributeNamespace");
300}
301
302static inline JSValue jsMutationRecordOldValueGetter(ExecState& state, JSMutationRecord& thisObject, ThrowScope& throwScope)
303{
304 UNUSED_PARAM(throwScope);
305 UNUSED_PARAM(state);
306 auto& impl = thisObject.wrapped();
307 JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.oldValue());
308 return result;
309}
310
311EncodedJSValue jsMutationRecordOldValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
312{
313 return IDLAttribute<JSMutationRecord>::get<jsMutationRecordOldValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "oldValue");
314}
315
316void JSMutationRecord::visitChildren(JSCell* cell, SlotVisitor& visitor)
317{
318 auto* thisObject = jsCast<JSMutationRecord*>(cell);
319 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
320 Base::visitChildren(thisObject, visitor);
321 thisObject->visitAdditionalChildren(visitor);
322}
323
324void JSMutationRecord::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor)
325{
326 auto* thisObject = jsCast<JSMutationRecord*>(cell);
327 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
328 Base::visitOutputConstraints(thisObject, visitor);
329 thisObject->visitAdditionalChildren(visitor);
330}
331
332void JSMutationRecord::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
333{
334 auto* thisObject = jsCast<JSMutationRecord*>(cell);
335 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
336 if (thisObject->scriptExecutionContext())
337 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
338 Base::heapSnapshot(cell, builder);
339}
340
341bool JSMutationRecordOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
342{
343 UNUSED_PARAM(handle);
344 UNUSED_PARAM(visitor);
345 UNUSED_PARAM(reason);
346 return false;
347}
348
349void JSMutationRecordOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
350{
351 auto* jsMutationRecord = static_cast<JSMutationRecord*>(handle.slot()->asCell());
352 auto& world = *static_cast<DOMWrapperWorld*>(context);
353 uncacheWrapper(world, &jsMutationRecord->wrapped(), jsMutationRecord);
354}
355
356JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MutationRecord>&& impl)
357{
358 return createWrapper<MutationRecord>(globalObject, WTFMove(impl));
359}
360
361JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MutationRecord& impl)
362{
363 return wrap(state, globalObject, impl);
364}
365
366MutationRecord* JSMutationRecord::toWrapped(JSC::VM& vm, JSC::JSValue value)
367{
368 if (auto* wrapper = jsDynamicCast<JSMutationRecord*>(vm, value))
369 return &wrapper->wrapped();
370 return nullptr;
371}
372
373}
374