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 "JSDocumentTimeline.h" |
23 | |
24 | #include "Document.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructor.h" |
27 | #include "JSDOMConvertDictionary.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMExceptionHandling.h" |
30 | #include "JSDOMWrapperCache.h" |
31 | #include "JSDocumentTimelineOptions.h" |
32 | #include "ScriptExecutionContext.h" |
33 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
34 | #include <JavaScriptCore/JSCInlines.h> |
35 | #include <wtf/GetPtr.h> |
36 | #include <wtf/PointerPreparations.h> |
37 | #include <wtf/URL.h> |
38 | |
39 | |
40 | namespace WebCore { |
41 | using namespace JSC; |
42 | |
43 | // Attributes |
44 | |
45 | JSC::EncodedJSValue jsDocumentTimelineConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
46 | bool setJSDocumentTimelineConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
47 | |
48 | class JSDocumentTimelinePrototype : public JSC::JSNonFinalObject { |
49 | public: |
50 | using Base = JSC::JSNonFinalObject; |
51 | static JSDocumentTimelinePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
52 | { |
53 | JSDocumentTimelinePrototype* ptr = new (NotNull, JSC::allocateCell<JSDocumentTimelinePrototype>(vm.heap)) JSDocumentTimelinePrototype(vm, globalObject, structure); |
54 | ptr->finishCreation(vm); |
55 | return ptr; |
56 | } |
57 | |
58 | DECLARE_INFO; |
59 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
60 | { |
61 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
62 | } |
63 | |
64 | private: |
65 | JSDocumentTimelinePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
66 | : JSC::JSNonFinalObject(vm, structure) |
67 | { |
68 | } |
69 | |
70 | void finishCreation(JSC::VM&); |
71 | }; |
72 | |
73 | using JSDocumentTimelineConstructor = JSDOMConstructor<JSDocumentTimeline>; |
74 | |
75 | template<> EncodedJSValue JSC_HOST_CALL JSDocumentTimelineConstructor::construct(ExecState* state) |
76 | { |
77 | VM& vm = state->vm(); |
78 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
79 | UNUSED_PARAM(throwScope); |
80 | auto* castedThis = jsCast<JSDocumentTimelineConstructor*>(state->jsCallee()); |
81 | ASSERT(castedThis); |
82 | auto* context = castedThis->scriptExecutionContext(); |
83 | if (UNLIKELY(!context)) |
84 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "DocumentTimeline" ); |
85 | ASSERT(context->isDocument()); |
86 | auto& document = downcast<Document>(*context); |
87 | auto options = convert<IDLDictionary<DocumentTimelineOptions>>(*state, state->argument(0)); |
88 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
89 | auto object = DocumentTimeline::create(document, WTFMove(options)); |
90 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DocumentTimeline>>(*state, *castedThis->globalObject(), WTFMove(object))); |
91 | } |
92 | |
93 | template<> JSValue JSDocumentTimelineConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
94 | { |
95 | return JSAnimationTimeline::getConstructor(vm, &globalObject); |
96 | } |
97 | |
98 | template<> void JSDocumentTimelineConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
99 | { |
100 | putDirect(vm, vm.propertyNames->prototype, JSDocumentTimeline::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
101 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DocumentTimeline"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
102 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
103 | } |
104 | |
105 | template<> const ClassInfo JSDocumentTimelineConstructor::s_info = { "DocumentTimeline" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDocumentTimelineConstructor) }; |
106 | |
107 | /* Hash table for prototype */ |
108 | |
109 | static const HashTableValue JSDocumentTimelinePrototypeTableValues[] = |
110 | { |
111 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTimelineConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDocumentTimelineConstructor) } }, |
112 | }; |
113 | |
114 | const ClassInfo JSDocumentTimelinePrototype::s_info = { "DocumentTimelinePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDocumentTimelinePrototype) }; |
115 | |
116 | void JSDocumentTimelinePrototype::finishCreation(VM& vm) |
117 | { |
118 | Base::finishCreation(vm); |
119 | reifyStaticProperties(vm, JSDocumentTimeline::info(), JSDocumentTimelinePrototypeTableValues, *this); |
120 | } |
121 | |
122 | const ClassInfo JSDocumentTimeline::s_info = { "DocumentTimeline" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDocumentTimeline) }; |
123 | |
124 | JSDocumentTimeline::JSDocumentTimeline(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DocumentTimeline>&& impl) |
125 | : JSAnimationTimeline(structure, globalObject, WTFMove(impl)) |
126 | { |
127 | } |
128 | |
129 | void JSDocumentTimeline::finishCreation(VM& vm) |
130 | { |
131 | Base::finishCreation(vm); |
132 | ASSERT(inherits(vm, info())); |
133 | |
134 | } |
135 | |
136 | JSObject* JSDocumentTimeline::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
137 | { |
138 | return JSDocumentTimelinePrototype::create(vm, &globalObject, JSDocumentTimelinePrototype::createStructure(vm, &globalObject, JSAnimationTimeline::prototype(vm, globalObject))); |
139 | } |
140 | |
141 | JSObject* JSDocumentTimeline::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
142 | { |
143 | return getDOMPrototype<JSDocumentTimeline>(vm, globalObject); |
144 | } |
145 | |
146 | JSValue JSDocumentTimeline::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
147 | { |
148 | return getDOMConstructor<JSDocumentTimelineConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
149 | } |
150 | |
151 | EncodedJSValue jsDocumentTimelineConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
152 | { |
153 | VM& vm = state->vm(); |
154 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
155 | auto* prototype = jsDynamicCast<JSDocumentTimelinePrototype*>(vm, JSValue::decode(thisValue)); |
156 | if (UNLIKELY(!prototype)) |
157 | return throwVMTypeError(state, throwScope); |
158 | return JSValue::encode(JSDocumentTimeline::getConstructor(state->vm(), prototype->globalObject())); |
159 | } |
160 | |
161 | bool setJSDocumentTimelineConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
162 | { |
163 | VM& vm = state->vm(); |
164 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
165 | auto* prototype = jsDynamicCast<JSDocumentTimelinePrototype*>(vm, JSValue::decode(thisValue)); |
166 | if (UNLIKELY(!prototype)) { |
167 | throwVMTypeError(state, throwScope); |
168 | return false; |
169 | } |
170 | // Shadowing a built-in constructor |
171 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
172 | } |
173 | |
174 | void JSDocumentTimeline::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
175 | { |
176 | auto* thisObject = jsCast<JSDocumentTimeline*>(cell); |
177 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
178 | if (thisObject->scriptExecutionContext()) |
179 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
180 | Base::heapSnapshot(cell, builder); |
181 | } |
182 | |
183 | #if ENABLE(BINDING_INTEGRITY) |
184 | #if PLATFORM(WIN) |
185 | #pragma warning(disable: 4483) |
186 | extern "C" { extern void (*const __identifier("??_7DocumentTimeline@WebCore@@6B@" )[])(); } |
187 | #else |
188 | extern "C" { extern void* _ZTVN7WebCore16DocumentTimelineE[]; } |
189 | #endif |
190 | #endif |
191 | |
192 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DocumentTimeline>&& impl) |
193 | { |
194 | |
195 | #if ENABLE(BINDING_INTEGRITY) |
196 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
197 | #if PLATFORM(WIN) |
198 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7DocumentTimeline@WebCore@@6B@" )); |
199 | #else |
200 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore16DocumentTimelineE[2]); |
201 | #endif |
202 | |
203 | // If this fails DocumentTimeline does not have a vtable, so you need to add the |
204 | // ImplementationLacksVTable attribute to the interface definition |
205 | static_assert(std::is_polymorphic<DocumentTimeline>::value, "DocumentTimeline is not polymorphic" ); |
206 | |
207 | // If you hit this assertion you either have a use after free bug, or |
208 | // DocumentTimeline has subclasses. If DocumentTimeline has subclasses that get passed |
209 | // to toJS() we currently require DocumentTimeline you to opt out of binding hardening |
210 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
211 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
212 | #endif |
213 | return createWrapper<DocumentTimeline>(globalObject, WTFMove(impl)); |
214 | } |
215 | |
216 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DocumentTimeline& impl) |
217 | { |
218 | return wrap(state, globalObject, impl); |
219 | } |
220 | |
221 | |
222 | } |
223 | |