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 "JSHTMLCanvasElement.h" |
23 | |
24 | #include "CallTracer.h" |
25 | #include "CustomElementReactionQueue.h" |
26 | #include "JSBlobCallback.h" |
27 | #include "JSCanvasRenderingContext2D.h" |
28 | #include "JSDOMAttribute.h" |
29 | #include "JSDOMBinding.h" |
30 | #include "JSDOMConstructorNotConstructable.h" |
31 | #include "JSDOMConvertAny.h" |
32 | #include "JSDOMConvertCallbacks.h" |
33 | #include "JSDOMConvertInterface.h" |
34 | #include "JSDOMConvertNullable.h" |
35 | #include "JSDOMConvertNumbers.h" |
36 | #include "JSDOMConvertStrings.h" |
37 | #include "JSDOMConvertUnion.h" |
38 | #include "JSDOMConvertVariadic.h" |
39 | #include "JSDOMExceptionHandling.h" |
40 | #include "JSDOMGlobalObject.h" |
41 | #include "JSDOMOperation.h" |
42 | #include "JSDOMWrapperCache.h" |
43 | #include "JSImageBitmapRenderingContext.h" |
44 | #include "JSWebGLRenderingContext.h" |
45 | #include "ScriptExecutionContext.h" |
46 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
47 | #include <JavaScriptCore/JSCInlines.h> |
48 | #include <wtf/GetPtr.h> |
49 | #include <wtf/PointerPreparations.h> |
50 | #include <wtf/URL.h> |
51 | #include <wtf/Variant.h> |
52 | |
53 | #if ENABLE(MEDIA_STREAM) |
54 | #include "JSMediaStream.h" |
55 | #endif |
56 | |
57 | |
58 | namespace WebCore { |
59 | using namespace JSC; |
60 | |
61 | // Functions |
62 | |
63 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionGetContext(JSC::ExecState*); |
64 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionToDataURL(JSC::ExecState*); |
65 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionToBlob(JSC::ExecState*); |
66 | #if ENABLE(MEDIA_STREAM) |
67 | JSC::EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionCaptureStream(JSC::ExecState*); |
68 | #endif |
69 | |
70 | // Attributes |
71 | |
72 | JSC::EncodedJSValue jsHTMLCanvasElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
73 | bool setJSHTMLCanvasElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
74 | JSC::EncodedJSValue jsHTMLCanvasElementWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
75 | bool setJSHTMLCanvasElementWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
76 | JSC::EncodedJSValue jsHTMLCanvasElementHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
77 | bool setJSHTMLCanvasElementHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
78 | |
79 | class JSHTMLCanvasElementPrototype : public JSC::JSNonFinalObject { |
80 | public: |
81 | using Base = JSC::JSNonFinalObject; |
82 | static JSHTMLCanvasElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
83 | { |
84 | JSHTMLCanvasElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLCanvasElementPrototype>(vm.heap)) JSHTMLCanvasElementPrototype(vm, globalObject, structure); |
85 | ptr->finishCreation(vm); |
86 | return ptr; |
87 | } |
88 | |
89 | DECLARE_INFO; |
90 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
91 | { |
92 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
93 | } |
94 | |
95 | private: |
96 | JSHTMLCanvasElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
97 | : JSC::JSNonFinalObject(vm, structure) |
98 | { |
99 | } |
100 | |
101 | void finishCreation(JSC::VM&); |
102 | }; |
103 | |
104 | using JSHTMLCanvasElementConstructor = JSDOMConstructorNotConstructable<JSHTMLCanvasElement>; |
105 | |
106 | template<> JSValue JSHTMLCanvasElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
107 | { |
108 | return JSHTMLElement::getConstructor(vm, &globalObject); |
109 | } |
110 | |
111 | template<> void JSHTMLCanvasElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
112 | { |
113 | putDirect(vm, vm.propertyNames->prototype, JSHTMLCanvasElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
114 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLCanvasElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
115 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
116 | } |
117 | |
118 | template<> const ClassInfo JSHTMLCanvasElementConstructor::s_info = { "HTMLCanvasElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLCanvasElementConstructor) }; |
119 | |
120 | /* Hash table for prototype */ |
121 | |
122 | static const HashTableValue JSHTMLCanvasElementPrototypeTableValues[] = |
123 | { |
124 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCanvasElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLCanvasElementConstructor) } }, |
125 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCanvasElementWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLCanvasElementWidth) } }, |
126 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCanvasElementHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLCanvasElementHeight) } }, |
127 | { "getContext" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLCanvasElementPrototypeFunctionGetContext), (intptr_t) (1) } }, |
128 | { "toDataURL" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLCanvasElementPrototypeFunctionToDataURL), (intptr_t) (0) } }, |
129 | { "toBlob" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLCanvasElementPrototypeFunctionToBlob), (intptr_t) (1) } }, |
130 | #if ENABLE(MEDIA_STREAM) |
131 | { "captureStream" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLCanvasElementPrototypeFunctionCaptureStream), (intptr_t) (0) } }, |
132 | #else |
133 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
134 | #endif |
135 | }; |
136 | |
137 | const ClassInfo JSHTMLCanvasElementPrototype::s_info = { "HTMLCanvasElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLCanvasElementPrototype) }; |
138 | |
139 | void JSHTMLCanvasElementPrototype::finishCreation(VM& vm) |
140 | { |
141 | Base::finishCreation(vm); |
142 | reifyStaticProperties(vm, JSHTMLCanvasElement::info(), JSHTMLCanvasElementPrototypeTableValues, *this); |
143 | } |
144 | |
145 | const ClassInfo JSHTMLCanvasElement::s_info = { "HTMLCanvasElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLCanvasElement) }; |
146 | |
147 | JSHTMLCanvasElement::JSHTMLCanvasElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLCanvasElement>&& impl) |
148 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
149 | { |
150 | } |
151 | |
152 | void JSHTMLCanvasElement::finishCreation(VM& vm) |
153 | { |
154 | Base::finishCreation(vm); |
155 | ASSERT(inherits(vm, info())); |
156 | |
157 | } |
158 | |
159 | JSObject* JSHTMLCanvasElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
160 | { |
161 | return JSHTMLCanvasElementPrototype::create(vm, &globalObject, JSHTMLCanvasElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
162 | } |
163 | |
164 | JSObject* JSHTMLCanvasElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
165 | { |
166 | return getDOMPrototype<JSHTMLCanvasElement>(vm, globalObject); |
167 | } |
168 | |
169 | JSValue JSHTMLCanvasElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
170 | { |
171 | return getDOMConstructor<JSHTMLCanvasElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
172 | } |
173 | |
174 | template<> inline JSHTMLCanvasElement* IDLAttribute<JSHTMLCanvasElement>::cast(ExecState& state, EncodedJSValue thisValue) |
175 | { |
176 | return jsDynamicCast<JSHTMLCanvasElement*>(state.vm(), JSValue::decode(thisValue)); |
177 | } |
178 | |
179 | template<> inline JSHTMLCanvasElement* IDLOperation<JSHTMLCanvasElement>::cast(ExecState& state) |
180 | { |
181 | return jsDynamicCast<JSHTMLCanvasElement*>(state.vm(), state.thisValue()); |
182 | } |
183 | |
184 | EncodedJSValue jsHTMLCanvasElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
185 | { |
186 | VM& vm = state->vm(); |
187 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
188 | auto* prototype = jsDynamicCast<JSHTMLCanvasElementPrototype*>(vm, JSValue::decode(thisValue)); |
189 | if (UNLIKELY(!prototype)) |
190 | return throwVMTypeError(state, throwScope); |
191 | return JSValue::encode(JSHTMLCanvasElement::getConstructor(state->vm(), prototype->globalObject())); |
192 | } |
193 | |
194 | bool setJSHTMLCanvasElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
195 | { |
196 | VM& vm = state->vm(); |
197 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
198 | auto* prototype = jsDynamicCast<JSHTMLCanvasElementPrototype*>(vm, JSValue::decode(thisValue)); |
199 | if (UNLIKELY(!prototype)) { |
200 | throwVMTypeError(state, throwScope); |
201 | return false; |
202 | } |
203 | // Shadowing a built-in constructor |
204 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
205 | } |
206 | |
207 | static inline JSValue jsHTMLCanvasElementWidthGetter(ExecState& state, JSHTMLCanvasElement& thisObject, ThrowScope& throwScope) |
208 | { |
209 | UNUSED_PARAM(throwScope); |
210 | UNUSED_PARAM(state); |
211 | auto& impl = thisObject.wrapped(); |
212 | if (UNLIKELY(impl.callTracingActive())) |
213 | CallTracer::recordCanvasAction(impl, "width"_s ); |
214 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.width()); |
215 | return result; |
216 | } |
217 | |
218 | EncodedJSValue jsHTMLCanvasElementWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
219 | { |
220 | return IDLAttribute<JSHTMLCanvasElement>::get<jsHTMLCanvasElementWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
221 | } |
222 | |
223 | static inline bool setJSHTMLCanvasElementWidthSetter(ExecState& state, JSHTMLCanvasElement& thisObject, JSValue value, ThrowScope& throwScope) |
224 | { |
225 | UNUSED_PARAM(throwScope); |
226 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
227 | auto& impl = thisObject.wrapped(); |
228 | auto nativeValue = convert<IDLUnsignedLong>(state, value); |
229 | RETURN_IF_EXCEPTION(throwScope, false); |
230 | if (UNLIKELY(impl.callTracingActive())) { |
231 | Vector<RecordCanvasActionVariant> callTracerParameters; |
232 | callTracerParameters.append(nativeValue); |
233 | CallTracer::recordCanvasAction(impl, "width"_s , WTFMove(callTracerParameters)); |
234 | } |
235 | AttributeSetter::call(state, throwScope, [&] { |
236 | return impl.setWidth(WTFMove(nativeValue)); |
237 | }); |
238 | return true; |
239 | } |
240 | |
241 | bool setJSHTMLCanvasElementWidth(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
242 | { |
243 | return IDLAttribute<JSHTMLCanvasElement>::set<setJSHTMLCanvasElementWidthSetter>(*state, thisValue, encodedValue, "width" ); |
244 | } |
245 | |
246 | static inline JSValue jsHTMLCanvasElementHeightGetter(ExecState& state, JSHTMLCanvasElement& thisObject, ThrowScope& throwScope) |
247 | { |
248 | UNUSED_PARAM(throwScope); |
249 | UNUSED_PARAM(state); |
250 | auto& impl = thisObject.wrapped(); |
251 | if (UNLIKELY(impl.callTracingActive())) |
252 | CallTracer::recordCanvasAction(impl, "height"_s ); |
253 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.height()); |
254 | return result; |
255 | } |
256 | |
257 | EncodedJSValue jsHTMLCanvasElementHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
258 | { |
259 | return IDLAttribute<JSHTMLCanvasElement>::get<jsHTMLCanvasElementHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
260 | } |
261 | |
262 | static inline bool setJSHTMLCanvasElementHeightSetter(ExecState& state, JSHTMLCanvasElement& thisObject, JSValue value, ThrowScope& throwScope) |
263 | { |
264 | UNUSED_PARAM(throwScope); |
265 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
266 | auto& impl = thisObject.wrapped(); |
267 | auto nativeValue = convert<IDLUnsignedLong>(state, value); |
268 | RETURN_IF_EXCEPTION(throwScope, false); |
269 | if (UNLIKELY(impl.callTracingActive())) { |
270 | Vector<RecordCanvasActionVariant> callTracerParameters; |
271 | callTracerParameters.append(nativeValue); |
272 | CallTracer::recordCanvasAction(impl, "height"_s , WTFMove(callTracerParameters)); |
273 | } |
274 | AttributeSetter::call(state, throwScope, [&] { |
275 | return impl.setHeight(WTFMove(nativeValue)); |
276 | }); |
277 | return true; |
278 | } |
279 | |
280 | bool setJSHTMLCanvasElementHeight(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
281 | { |
282 | return IDLAttribute<JSHTMLCanvasElement>::set<setJSHTMLCanvasElementHeightSetter>(*state, thisValue, encodedValue, "height" ); |
283 | } |
284 | |
285 | static inline JSC::EncodedJSValue jsHTMLCanvasElementPrototypeFunctionGetContextBody(JSC::ExecState* state, typename IDLOperation<JSHTMLCanvasElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
286 | { |
287 | UNUSED_PARAM(state); |
288 | UNUSED_PARAM(throwScope); |
289 | auto& impl = castedThis->wrapped(); |
290 | if (UNLIKELY(state->argumentCount() < 1)) |
291 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
292 | auto contextId = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
293 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
294 | auto arguments = convertVariadicArguments<IDLAny>(*state, 1); |
295 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
296 | return JSValue::encode(toJS<IDLNullable<IDLUnion<IDLInterface<WebGLRenderingContext>, IDLInterface<ImageBitmapRenderingContext>, IDLInterface<CanvasRenderingContext2D>>>>(*state, *castedThis->globalObject(), throwScope, impl.getContext(*state, WTFMove(contextId), WTFMove(arguments)))); |
297 | } |
298 | |
299 | EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionGetContext(ExecState* state) |
300 | { |
301 | return IDLOperation<JSHTMLCanvasElement>::call<jsHTMLCanvasElementPrototypeFunctionGetContextBody>(*state, "getContext" ); |
302 | } |
303 | |
304 | static inline JSC::EncodedJSValue jsHTMLCanvasElementPrototypeFunctionToDataURLBody(JSC::ExecState* state, typename IDLOperation<JSHTMLCanvasElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
305 | { |
306 | UNUSED_PARAM(state); |
307 | UNUSED_PARAM(throwScope); |
308 | auto& impl = castedThis->wrapped(); |
309 | auto type = state->argument(0).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
310 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
311 | auto quality = convert<IDLAny>(*state, state->argument(1)); |
312 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
313 | return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.toDataURL(WTFMove(type), WTFMove(quality)))); |
314 | } |
315 | |
316 | EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionToDataURL(ExecState* state) |
317 | { |
318 | return IDLOperation<JSHTMLCanvasElement>::call<jsHTMLCanvasElementPrototypeFunctionToDataURLBody>(*state, "toDataURL" ); |
319 | } |
320 | |
321 | static inline JSC::EncodedJSValue jsHTMLCanvasElementPrototypeFunctionToBlobBody(JSC::ExecState* state, typename IDLOperation<JSHTMLCanvasElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
322 | { |
323 | UNUSED_PARAM(state); |
324 | UNUSED_PARAM(throwScope); |
325 | auto& impl = castedThis->wrapped(); |
326 | if (UNLIKELY(state->argumentCount() < 1)) |
327 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
328 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
329 | if (UNLIKELY(!context)) |
330 | return JSValue::encode(jsUndefined()); |
331 | auto callback = convert<IDLCallbackFunction<JSBlobCallback>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback" , "HTMLCanvasElement" , "toBlob" ); }); |
332 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
333 | auto type = state->argument(1).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
334 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
335 | auto quality = convert<IDLAny>(*state, state->argument(2)); |
336 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
337 | propagateException(*state, throwScope, impl.toBlob(*context, callback.releaseNonNull(), WTFMove(type), WTFMove(quality))); |
338 | return JSValue::encode(jsUndefined()); |
339 | } |
340 | |
341 | EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionToBlob(ExecState* state) |
342 | { |
343 | return IDLOperation<JSHTMLCanvasElement>::call<jsHTMLCanvasElementPrototypeFunctionToBlobBody>(*state, "toBlob" ); |
344 | } |
345 | |
346 | #if ENABLE(MEDIA_STREAM) |
347 | static inline JSC::EncodedJSValue jsHTMLCanvasElementPrototypeFunctionCaptureStreamBody(JSC::ExecState* state, typename IDLOperation<JSHTMLCanvasElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
348 | { |
349 | UNUSED_PARAM(state); |
350 | UNUSED_PARAM(throwScope); |
351 | auto& impl = castedThis->wrapped(); |
352 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
353 | if (UNLIKELY(!context)) |
354 | return JSValue::encode(jsUndefined()); |
355 | auto frameRequestRate = state->argument(0).isUndefined() ? Optional<Converter<IDLDouble>::ReturnType>() : Optional<Converter<IDLDouble>::ReturnType>(convert<IDLDouble>(*state, state->uncheckedArgument(0))); |
356 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
357 | return JSValue::encode(toJSNewlyCreated<IDLInterface<MediaStream>>(*state, *castedThis->globalObject(), throwScope, impl.captureStream(*context, WTFMove(frameRequestRate)))); |
358 | } |
359 | |
360 | EncodedJSValue JSC_HOST_CALL jsHTMLCanvasElementPrototypeFunctionCaptureStream(ExecState* state) |
361 | { |
362 | return IDLOperation<JSHTMLCanvasElement>::call<jsHTMLCanvasElementPrototypeFunctionCaptureStreamBody>(*state, "captureStream" ); |
363 | } |
364 | |
365 | #endif |
366 | |
367 | void JSHTMLCanvasElement::visitChildren(JSCell* cell, SlotVisitor& visitor) |
368 | { |
369 | auto* thisObject = jsCast<JSHTMLCanvasElement*>(cell); |
370 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
371 | Base::visitChildren(thisObject, visitor); |
372 | visitor.reportExtraMemoryVisited(thisObject->wrapped().memoryCost()); |
373 | #if ENABLE(RESOURCE_USAGE) |
374 | visitor.reportExternalMemoryVisited(thisObject->wrapped().externalMemoryCost()); |
375 | #endif |
376 | } |
377 | |
378 | size_t JSHTMLCanvasElement::estimatedSize(JSCell* cell, VM& vm) |
379 | { |
380 | auto* thisObject = jsCast<JSHTMLCanvasElement*>(cell); |
381 | return Base::estimatedSize(thisObject, vm) + thisObject->wrapped().memoryCost(); |
382 | } |
383 | |
384 | void JSHTMLCanvasElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
385 | { |
386 | auto* thisObject = jsCast<JSHTMLCanvasElement*>(cell); |
387 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
388 | if (thisObject->scriptExecutionContext()) |
389 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
390 | Base::heapSnapshot(cell, builder); |
391 | } |
392 | |
393 | HTMLCanvasElement* JSHTMLCanvasElement::toWrapped(JSC::VM& vm, JSC::JSValue value) |
394 | { |
395 | if (auto* wrapper = jsDynamicCast<JSHTMLCanvasElement*>(vm, value)) |
396 | return &wrapper->wrapped(); |
397 | return nullptr; |
398 | } |
399 | |
400 | } |
401 | |