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 "JSVisualViewport.h" |
23 | |
24 | #include "EventNames.h" |
25 | #include "JSDOMAttribute.h" |
26 | #include "JSDOMBinding.h" |
27 | #include "JSDOMConstructorNotConstructable.h" |
28 | #include "JSDOMConvertNumbers.h" |
29 | #include "JSDOMExceptionHandling.h" |
30 | #include "JSDOMWrapperCache.h" |
31 | #include "JSEventListener.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 jsVisualViewportConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
46 | bool setJSVisualViewportConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
47 | JSC::EncodedJSValue jsVisualViewportOffsetLeft(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | JSC::EncodedJSValue jsVisualViewportOffsetTop(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
49 | JSC::EncodedJSValue jsVisualViewportPageLeft(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | JSC::EncodedJSValue jsVisualViewportPageTop(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
51 | JSC::EncodedJSValue jsVisualViewportWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
52 | JSC::EncodedJSValue jsVisualViewportHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
53 | JSC::EncodedJSValue jsVisualViewportScale(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | JSC::EncodedJSValue jsVisualViewportOnresize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
55 | bool setJSVisualViewportOnresize(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
56 | JSC::EncodedJSValue jsVisualViewportOnscroll(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
57 | bool setJSVisualViewportOnscroll(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
58 | |
59 | class JSVisualViewportPrototype : public JSC::JSNonFinalObject { |
60 | public: |
61 | using Base = JSC::JSNonFinalObject; |
62 | static JSVisualViewportPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
63 | { |
64 | JSVisualViewportPrototype* ptr = new (NotNull, JSC::allocateCell<JSVisualViewportPrototype>(vm.heap)) JSVisualViewportPrototype(vm, globalObject, structure); |
65 | ptr->finishCreation(vm); |
66 | return ptr; |
67 | } |
68 | |
69 | DECLARE_INFO; |
70 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
71 | { |
72 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
73 | } |
74 | |
75 | private: |
76 | JSVisualViewportPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
77 | : JSC::JSNonFinalObject(vm, structure) |
78 | { |
79 | } |
80 | |
81 | void finishCreation(JSC::VM&); |
82 | }; |
83 | |
84 | using JSVisualViewportConstructor = JSDOMConstructorNotConstructable<JSVisualViewport>; |
85 | |
86 | template<> JSValue JSVisualViewportConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
87 | { |
88 | return JSEventTarget::getConstructor(vm, &globalObject); |
89 | } |
90 | |
91 | template<> void JSVisualViewportConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
92 | { |
93 | putDirect(vm, vm.propertyNames->prototype, JSVisualViewport::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
94 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("VisualViewport"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
95 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
96 | } |
97 | |
98 | template<> const ClassInfo JSVisualViewportConstructor::s_info = { "VisualViewport" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVisualViewportConstructor) }; |
99 | |
100 | /* Hash table for prototype */ |
101 | |
102 | static const HashTableValue JSVisualViewportPrototypeTableValues[] = |
103 | { |
104 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVisualViewportConstructor) } }, |
105 | { "offsetLeft" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportOffsetLeft), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
106 | { "offsetTop" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportOffsetTop), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
107 | { "pageLeft" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportPageLeft), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
108 | { "pageTop" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportPageTop), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
109 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
110 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
111 | { "scale" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportScale), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
112 | { "onresize" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportOnresize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVisualViewportOnresize) } }, |
113 | { "onscroll" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsVisualViewportOnscroll), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSVisualViewportOnscroll) } }, |
114 | }; |
115 | |
116 | const ClassInfo JSVisualViewportPrototype::s_info = { "VisualViewportPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVisualViewportPrototype) }; |
117 | |
118 | void JSVisualViewportPrototype::finishCreation(VM& vm) |
119 | { |
120 | Base::finishCreation(vm); |
121 | reifyStaticProperties(vm, JSVisualViewport::info(), JSVisualViewportPrototypeTableValues, *this); |
122 | } |
123 | |
124 | const ClassInfo JSVisualViewport::s_info = { "VisualViewport" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSVisualViewport) }; |
125 | |
126 | JSVisualViewport::JSVisualViewport(Structure* structure, JSDOMGlobalObject& globalObject, Ref<VisualViewport>&& impl) |
127 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
128 | { |
129 | } |
130 | |
131 | void JSVisualViewport::finishCreation(VM& vm) |
132 | { |
133 | Base::finishCreation(vm); |
134 | ASSERT(inherits(vm, info())); |
135 | |
136 | } |
137 | |
138 | JSObject* JSVisualViewport::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
139 | { |
140 | return JSVisualViewportPrototype::create(vm, &globalObject, JSVisualViewportPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
141 | } |
142 | |
143 | JSObject* JSVisualViewport::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
144 | { |
145 | return getDOMPrototype<JSVisualViewport>(vm, globalObject); |
146 | } |
147 | |
148 | JSValue JSVisualViewport::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
149 | { |
150 | return getDOMConstructor<JSVisualViewportConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
151 | } |
152 | |
153 | template<> inline JSVisualViewport* IDLAttribute<JSVisualViewport>::cast(ExecState& state, EncodedJSValue thisValue) |
154 | { |
155 | return jsDynamicCast<JSVisualViewport*>(state.vm(), JSValue::decode(thisValue)); |
156 | } |
157 | |
158 | EncodedJSValue jsVisualViewportConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
159 | { |
160 | VM& vm = state->vm(); |
161 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
162 | auto* prototype = jsDynamicCast<JSVisualViewportPrototype*>(vm, JSValue::decode(thisValue)); |
163 | if (UNLIKELY(!prototype)) |
164 | return throwVMTypeError(state, throwScope); |
165 | return JSValue::encode(JSVisualViewport::getConstructor(state->vm(), prototype->globalObject())); |
166 | } |
167 | |
168 | bool setJSVisualViewportConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
169 | { |
170 | VM& vm = state->vm(); |
171 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
172 | auto* prototype = jsDynamicCast<JSVisualViewportPrototype*>(vm, JSValue::decode(thisValue)); |
173 | if (UNLIKELY(!prototype)) { |
174 | throwVMTypeError(state, throwScope); |
175 | return false; |
176 | } |
177 | // Shadowing a built-in constructor |
178 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
179 | } |
180 | |
181 | static inline JSValue jsVisualViewportOffsetLeftGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
182 | { |
183 | UNUSED_PARAM(throwScope); |
184 | UNUSED_PARAM(state); |
185 | auto& impl = thisObject.wrapped(); |
186 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.offsetLeft()); |
187 | return result; |
188 | } |
189 | |
190 | EncodedJSValue jsVisualViewportOffsetLeft(ExecState* state, EncodedJSValue thisValue, PropertyName) |
191 | { |
192 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportOffsetLeftGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "offsetLeft" ); |
193 | } |
194 | |
195 | static inline JSValue jsVisualViewportOffsetTopGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
196 | { |
197 | UNUSED_PARAM(throwScope); |
198 | UNUSED_PARAM(state); |
199 | auto& impl = thisObject.wrapped(); |
200 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.offsetTop()); |
201 | return result; |
202 | } |
203 | |
204 | EncodedJSValue jsVisualViewportOffsetTop(ExecState* state, EncodedJSValue thisValue, PropertyName) |
205 | { |
206 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportOffsetTopGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "offsetTop" ); |
207 | } |
208 | |
209 | static inline JSValue jsVisualViewportPageLeftGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
210 | { |
211 | UNUSED_PARAM(throwScope); |
212 | UNUSED_PARAM(state); |
213 | auto& impl = thisObject.wrapped(); |
214 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.pageLeft()); |
215 | return result; |
216 | } |
217 | |
218 | EncodedJSValue jsVisualViewportPageLeft(ExecState* state, EncodedJSValue thisValue, PropertyName) |
219 | { |
220 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportPageLeftGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pageLeft" ); |
221 | } |
222 | |
223 | static inline JSValue jsVisualViewportPageTopGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
224 | { |
225 | UNUSED_PARAM(throwScope); |
226 | UNUSED_PARAM(state); |
227 | auto& impl = thisObject.wrapped(); |
228 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.pageTop()); |
229 | return result; |
230 | } |
231 | |
232 | EncodedJSValue jsVisualViewportPageTop(ExecState* state, EncodedJSValue thisValue, PropertyName) |
233 | { |
234 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportPageTopGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pageTop" ); |
235 | } |
236 | |
237 | static inline JSValue jsVisualViewportWidthGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
238 | { |
239 | UNUSED_PARAM(throwScope); |
240 | UNUSED_PARAM(state); |
241 | auto& impl = thisObject.wrapped(); |
242 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.width()); |
243 | return result; |
244 | } |
245 | |
246 | EncodedJSValue jsVisualViewportWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
247 | { |
248 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
249 | } |
250 | |
251 | static inline JSValue jsVisualViewportHeightGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
252 | { |
253 | UNUSED_PARAM(throwScope); |
254 | UNUSED_PARAM(state); |
255 | auto& impl = thisObject.wrapped(); |
256 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.height()); |
257 | return result; |
258 | } |
259 | |
260 | EncodedJSValue jsVisualViewportHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
261 | { |
262 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
263 | } |
264 | |
265 | static inline JSValue jsVisualViewportScaleGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
266 | { |
267 | UNUSED_PARAM(throwScope); |
268 | UNUSED_PARAM(state); |
269 | auto& impl = thisObject.wrapped(); |
270 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.scale()); |
271 | return result; |
272 | } |
273 | |
274 | EncodedJSValue jsVisualViewportScale(ExecState* state, EncodedJSValue thisValue, PropertyName) |
275 | { |
276 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportScaleGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "scale" ); |
277 | } |
278 | |
279 | static inline JSValue jsVisualViewportOnresizeGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
280 | { |
281 | UNUSED_PARAM(throwScope); |
282 | UNUSED_PARAM(state); |
283 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().resizeEvent, worldForDOMObject(thisObject)); |
284 | } |
285 | |
286 | EncodedJSValue jsVisualViewportOnresize(ExecState* state, EncodedJSValue thisValue, PropertyName) |
287 | { |
288 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportOnresizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onresize" ); |
289 | } |
290 | |
291 | static inline bool setJSVisualViewportOnresizeSetter(ExecState& state, JSVisualViewport& thisObject, JSValue value, ThrowScope& throwScope) |
292 | { |
293 | UNUSED_PARAM(throwScope); |
294 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().resizeEvent, value); |
295 | return true; |
296 | } |
297 | |
298 | bool setJSVisualViewportOnresize(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
299 | { |
300 | return IDLAttribute<JSVisualViewport>::set<setJSVisualViewportOnresizeSetter>(*state, thisValue, encodedValue, "onresize" ); |
301 | } |
302 | |
303 | static inline JSValue jsVisualViewportOnscrollGetter(ExecState& state, JSVisualViewport& thisObject, ThrowScope& throwScope) |
304 | { |
305 | UNUSED_PARAM(throwScope); |
306 | UNUSED_PARAM(state); |
307 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().scrollEvent, worldForDOMObject(thisObject)); |
308 | } |
309 | |
310 | EncodedJSValue jsVisualViewportOnscroll(ExecState* state, EncodedJSValue thisValue, PropertyName) |
311 | { |
312 | return IDLAttribute<JSVisualViewport>::get<jsVisualViewportOnscrollGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onscroll" ); |
313 | } |
314 | |
315 | static inline bool setJSVisualViewportOnscrollSetter(ExecState& state, JSVisualViewport& thisObject, JSValue value, ThrowScope& throwScope) |
316 | { |
317 | UNUSED_PARAM(throwScope); |
318 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().scrollEvent, value); |
319 | return true; |
320 | } |
321 | |
322 | bool setJSVisualViewportOnscroll(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
323 | { |
324 | return IDLAttribute<JSVisualViewport>::set<setJSVisualViewportOnscrollSetter>(*state, thisValue, encodedValue, "onscroll" ); |
325 | } |
326 | |
327 | void JSVisualViewport::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
328 | { |
329 | auto* thisObject = jsCast<JSVisualViewport*>(cell); |
330 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
331 | if (thisObject->scriptExecutionContext()) |
332 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
333 | Base::heapSnapshot(cell, builder); |
334 | } |
335 | |
336 | bool JSVisualViewportOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
337 | { |
338 | auto* jsVisualViewport = jsCast<JSVisualViewport*>(handle.slot()->asCell()); |
339 | if (jsVisualViewport->wrapped().isFiringEventListeners()) { |
340 | if (UNLIKELY(reason)) |
341 | *reason = "EventTarget firing event listeners" ; |
342 | return true; |
343 | } |
344 | Frame* root = WTF::getPtr(jsVisualViewport->wrapped().frame()); |
345 | if (!root) |
346 | return false; |
347 | if (UNLIKELY(reason)) |
348 | *reason = "Reachable from Frame" ; |
349 | return visitor.containsOpaqueRoot(root); |
350 | } |
351 | |
352 | void JSVisualViewportOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
353 | { |
354 | auto* jsVisualViewport = static_cast<JSVisualViewport*>(handle.slot()->asCell()); |
355 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
356 | uncacheWrapper(world, &jsVisualViewport->wrapped(), jsVisualViewport); |
357 | } |
358 | |
359 | #if ENABLE(BINDING_INTEGRITY) |
360 | #if PLATFORM(WIN) |
361 | #pragma warning(disable: 4483) |
362 | extern "C" { extern void (*const __identifier("??_7VisualViewport@WebCore@@6B@" )[])(); } |
363 | #else |
364 | extern "C" { extern void* _ZTVN7WebCore14VisualViewportE[]; } |
365 | #endif |
366 | #endif |
367 | |
368 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<VisualViewport>&& impl) |
369 | { |
370 | |
371 | #if ENABLE(BINDING_INTEGRITY) |
372 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
373 | #if PLATFORM(WIN) |
374 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7VisualViewport@WebCore@@6B@" )); |
375 | #else |
376 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14VisualViewportE[2]); |
377 | #endif |
378 | |
379 | // If this fails VisualViewport does not have a vtable, so you need to add the |
380 | // ImplementationLacksVTable attribute to the interface definition |
381 | static_assert(std::is_polymorphic<VisualViewport>::value, "VisualViewport is not polymorphic" ); |
382 | |
383 | // If you hit this assertion you either have a use after free bug, or |
384 | // VisualViewport has subclasses. If VisualViewport has subclasses that get passed |
385 | // to toJS() we currently require VisualViewport you to opt out of binding hardening |
386 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
387 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
388 | #endif |
389 | return createWrapper<VisualViewport>(globalObject, WTFMove(impl)); |
390 | } |
391 | |
392 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, VisualViewport& impl) |
393 | { |
394 | return wrap(state, globalObject, impl); |
395 | } |
396 | |
397 | VisualViewport* JSVisualViewport::toWrapped(JSC::VM& vm, JSC::JSValue value) |
398 | { |
399 | if (auto* wrapper = jsDynamicCast<JSVisualViewport*>(vm, value)) |
400 | return &wrapper->wrapped(); |
401 | return nullptr; |
402 | } |
403 | |
404 | } |
405 | |