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 "JSFontFaceSet.h" |
23 | |
24 | #include "DOMPromiseProxy.h" |
25 | #include "Document.h" |
26 | #include "EventNames.h" |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructor.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertInterface.h" |
32 | #include "JSDOMConvertNumbers.h" |
33 | #include "JSDOMConvertPromise.h" |
34 | #include "JSDOMConvertSequences.h" |
35 | #include "JSDOMConvertStrings.h" |
36 | #include "JSDOMExceptionHandling.h" |
37 | #include "JSDOMGlobalObject.h" |
38 | #include "JSDOMIterator.h" |
39 | #include "JSDOMOperation.h" |
40 | #include "JSDOMOperationReturningPromise.h" |
41 | #include "JSDOMWrapperCache.h" |
42 | #include "JSEventListener.h" |
43 | #include "JSFontFace.h" |
44 | #include "JSFontFaceSet.h" |
45 | #include "ScriptExecutionContext.h" |
46 | #include <JavaScriptCore/BuiltinNames.h> |
47 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
48 | #include <JavaScriptCore/JSArray.h> |
49 | #include <JavaScriptCore/JSCInlines.h> |
50 | #include <JavaScriptCore/JSString.h> |
51 | #include <wtf/GetPtr.h> |
52 | #include <wtf/NeverDestroyed.h> |
53 | #include <wtf/PointerPreparations.h> |
54 | #include <wtf/URL.h> |
55 | |
56 | |
57 | namespace WebCore { |
58 | using namespace JSC; |
59 | |
60 | String convertEnumerationToString(FontFaceSet::LoadStatus enumerationValue) |
61 | { |
62 | static const NeverDestroyed<String> values[] = { |
63 | MAKE_STATIC_STRING_IMPL("loading" ), |
64 | MAKE_STATIC_STRING_IMPL("loaded" ), |
65 | }; |
66 | static_assert(static_cast<size_t>(FontFaceSet::LoadStatus::Loading) == 0, "FontFaceSet::LoadStatus::Loading is not 0 as expected" ); |
67 | static_assert(static_cast<size_t>(FontFaceSet::LoadStatus::Loaded) == 1, "FontFaceSet::LoadStatus::Loaded is not 1 as expected" ); |
68 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
69 | return values[static_cast<size_t>(enumerationValue)]; |
70 | } |
71 | |
72 | template<> JSString* convertEnumerationToJS(ExecState& state, FontFaceSet::LoadStatus enumerationValue) |
73 | { |
74 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
75 | } |
76 | |
77 | template<> Optional<FontFaceSet::LoadStatus> parseEnumeration<FontFaceSet::LoadStatus>(ExecState& state, JSValue value) |
78 | { |
79 | auto stringValue = value.toWTFString(&state); |
80 | if (stringValue == "loading" ) |
81 | return FontFaceSet::LoadStatus::Loading; |
82 | if (stringValue == "loaded" ) |
83 | return FontFaceSet::LoadStatus::Loaded; |
84 | return WTF::nullopt; |
85 | } |
86 | |
87 | template<> const char* expectedEnumerationValues<FontFaceSet::LoadStatus>() |
88 | { |
89 | return "\"loading\", \"loaded\"" ; |
90 | } |
91 | |
92 | // Functions |
93 | |
94 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionHas(JSC::ExecState*); |
95 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionAdd(JSC::ExecState*); |
96 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionDelete(JSC::ExecState*); |
97 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionClear(JSC::ExecState*); |
98 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionLoad(JSC::ExecState*); |
99 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionCheck(JSC::ExecState*); |
100 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionSymbolIterator(JSC::ExecState*); |
101 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionEntries(JSC::ExecState*); |
102 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionKeys(JSC::ExecState*); |
103 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionValues(JSC::ExecState*); |
104 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionForEach(JSC::ExecState*); |
105 | |
106 | // Attributes |
107 | |
108 | JSC::EncodedJSValue jsFontFaceSetConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
109 | bool setJSFontFaceSetConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
110 | JSC::EncodedJSValue jsFontFaceSetSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
111 | JSC::EncodedJSValue jsFontFaceSetOnloading(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
112 | bool setJSFontFaceSetOnloading(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
113 | JSC::EncodedJSValue jsFontFaceSetOnloadingdone(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
114 | bool setJSFontFaceSetOnloadingdone(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
115 | JSC::EncodedJSValue jsFontFaceSetOnloadingerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
116 | bool setJSFontFaceSetOnloadingerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
117 | JSC::EncodedJSValue jsFontFaceSetReady(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
118 | JSC::EncodedJSValue jsFontFaceSetStatus(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
119 | |
120 | class JSFontFaceSetPrototype : public JSC::JSNonFinalObject { |
121 | public: |
122 | using Base = JSC::JSNonFinalObject; |
123 | static JSFontFaceSetPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
124 | { |
125 | JSFontFaceSetPrototype* ptr = new (NotNull, JSC::allocateCell<JSFontFaceSetPrototype>(vm.heap)) JSFontFaceSetPrototype(vm, globalObject, structure); |
126 | ptr->finishCreation(vm); |
127 | return ptr; |
128 | } |
129 | |
130 | DECLARE_INFO; |
131 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
132 | { |
133 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
134 | } |
135 | |
136 | private: |
137 | JSFontFaceSetPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
138 | : JSC::JSNonFinalObject(vm, structure) |
139 | { |
140 | } |
141 | |
142 | void finishCreation(JSC::VM&); |
143 | }; |
144 | |
145 | using JSFontFaceSetConstructor = JSDOMConstructor<JSFontFaceSet>; |
146 | |
147 | template<> EncodedJSValue JSC_HOST_CALL JSFontFaceSetConstructor::construct(ExecState* state) |
148 | { |
149 | VM& vm = state->vm(); |
150 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
151 | UNUSED_PARAM(throwScope); |
152 | auto* castedThis = jsCast<JSFontFaceSetConstructor*>(state->jsCallee()); |
153 | ASSERT(castedThis); |
154 | if (UNLIKELY(state->argumentCount() < 1)) |
155 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
156 | auto* context = castedThis->scriptExecutionContext(); |
157 | if (UNLIKELY(!context)) |
158 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "FontFaceSet" ); |
159 | ASSERT(context->isDocument()); |
160 | auto& document = downcast<Document>(*context); |
161 | auto initialFaces = convert<IDLSequence<IDLInterface<FontFace>>>(*state, state->uncheckedArgument(0)); |
162 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
163 | auto object = FontFaceSet::create(document, WTFMove(initialFaces)); |
164 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FontFaceSet>>(*state, *castedThis->globalObject(), WTFMove(object))); |
165 | } |
166 | |
167 | template<> JSValue JSFontFaceSetConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
168 | { |
169 | return JSEventTarget::getConstructor(vm, &globalObject); |
170 | } |
171 | |
172 | template<> void JSFontFaceSetConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
173 | { |
174 | putDirect(vm, vm.propertyNames->prototype, JSFontFaceSet::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
175 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("FontFaceSet"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
176 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
177 | } |
178 | |
179 | template<> const ClassInfo JSFontFaceSetConstructor::s_info = { "FontFaceSet" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFontFaceSetConstructor) }; |
180 | |
181 | /* Hash table for prototype */ |
182 | |
183 | static const HashTableValue JSFontFaceSetPrototypeTableValues[] = |
184 | { |
185 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetConstructor) } }, |
186 | { "size" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
187 | { "onloading" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetOnloading), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetOnloading) } }, |
188 | { "onloadingdone" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetOnloadingdone), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetOnloadingdone) } }, |
189 | { "onloadingerror" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetOnloadingerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFontFaceSetOnloadingerror) } }, |
190 | { "ready" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetReady), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
191 | { "status" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFontFaceSetStatus), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
192 | { "has" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionHas), (intptr_t) (1) } }, |
193 | { "add" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionAdd), (intptr_t) (1) } }, |
194 | { "delete" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionDelete), (intptr_t) (1) } }, |
195 | { "clear" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionClear), (intptr_t) (0) } }, |
196 | { "load" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionLoad), (intptr_t) (1) } }, |
197 | { "check" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionCheck), (intptr_t) (1) } }, |
198 | { "entries" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionEntries), (intptr_t) (0) } }, |
199 | { "keys" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionKeys), (intptr_t) (0) } }, |
200 | { "values" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionValues), (intptr_t) (0) } }, |
201 | { "forEach" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFontFaceSetPrototypeFunctionForEach), (intptr_t) (1) } }, |
202 | }; |
203 | |
204 | const ClassInfo JSFontFaceSetPrototype::s_info = { "FontFaceSetPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFontFaceSetPrototype) }; |
205 | |
206 | void JSFontFaceSetPrototype::finishCreation(VM& vm) |
207 | { |
208 | Base::finishCreation(vm); |
209 | reifyStaticProperties(vm, JSFontFaceSet::info(), JSFontFaceSetPrototypeTableValues, *this); |
210 | putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
211 | } |
212 | |
213 | const ClassInfo JSFontFaceSet::s_info = { "FontFaceSet" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFontFaceSet) }; |
214 | |
215 | JSFontFaceSet::JSFontFaceSet(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FontFaceSet>&& impl) |
216 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
217 | { |
218 | } |
219 | |
220 | void JSFontFaceSet::finishCreation(VM& vm) |
221 | { |
222 | Base::finishCreation(vm); |
223 | ASSERT(inherits(vm, info())); |
224 | |
225 | } |
226 | |
227 | JSObject* JSFontFaceSet::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
228 | { |
229 | return JSFontFaceSetPrototype::create(vm, &globalObject, JSFontFaceSetPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
230 | } |
231 | |
232 | JSObject* JSFontFaceSet::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
233 | { |
234 | return getDOMPrototype<JSFontFaceSet>(vm, globalObject); |
235 | } |
236 | |
237 | JSValue JSFontFaceSet::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
238 | { |
239 | return getDOMConstructor<JSFontFaceSetConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
240 | } |
241 | |
242 | template<> inline JSFontFaceSet* IDLAttribute<JSFontFaceSet>::cast(ExecState& state, EncodedJSValue thisValue) |
243 | { |
244 | return jsDynamicCast<JSFontFaceSet*>(state.vm(), JSValue::decode(thisValue)); |
245 | } |
246 | |
247 | template<> inline JSFontFaceSet* IDLOperation<JSFontFaceSet>::cast(ExecState& state) |
248 | { |
249 | return jsDynamicCast<JSFontFaceSet*>(state.vm(), state.thisValue()); |
250 | } |
251 | |
252 | EncodedJSValue jsFontFaceSetConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
253 | { |
254 | VM& vm = state->vm(); |
255 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
256 | auto* prototype = jsDynamicCast<JSFontFaceSetPrototype*>(vm, JSValue::decode(thisValue)); |
257 | if (UNLIKELY(!prototype)) |
258 | return throwVMTypeError(state, throwScope); |
259 | return JSValue::encode(JSFontFaceSet::getConstructor(state->vm(), prototype->globalObject())); |
260 | } |
261 | |
262 | bool setJSFontFaceSetConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
263 | { |
264 | VM& vm = state->vm(); |
265 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
266 | auto* prototype = jsDynamicCast<JSFontFaceSetPrototype*>(vm, JSValue::decode(thisValue)); |
267 | if (UNLIKELY(!prototype)) { |
268 | throwVMTypeError(state, throwScope); |
269 | return false; |
270 | } |
271 | // Shadowing a built-in constructor |
272 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
273 | } |
274 | |
275 | static inline JSValue jsFontFaceSetSizeGetter(ExecState& state, JSFontFaceSet& thisObject, ThrowScope& throwScope) |
276 | { |
277 | UNUSED_PARAM(throwScope); |
278 | UNUSED_PARAM(state); |
279 | auto& impl = thisObject.wrapped(); |
280 | JSValue result = toJS<IDLLong>(state, throwScope, impl.size()); |
281 | return result; |
282 | } |
283 | |
284 | EncodedJSValue jsFontFaceSetSize(ExecState* state, EncodedJSValue thisValue, PropertyName) |
285 | { |
286 | return IDLAttribute<JSFontFaceSet>::get<jsFontFaceSetSizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "size" ); |
287 | } |
288 | |
289 | static inline JSValue jsFontFaceSetOnloadingGetter(ExecState& state, JSFontFaceSet& thisObject, ThrowScope& throwScope) |
290 | { |
291 | UNUSED_PARAM(throwScope); |
292 | UNUSED_PARAM(state); |
293 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().loadingEvent, worldForDOMObject(thisObject)); |
294 | } |
295 | |
296 | EncodedJSValue jsFontFaceSetOnloading(ExecState* state, EncodedJSValue thisValue, PropertyName) |
297 | { |
298 | return IDLAttribute<JSFontFaceSet>::get<jsFontFaceSetOnloadingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onloading" ); |
299 | } |
300 | |
301 | static inline bool setJSFontFaceSetOnloadingSetter(ExecState& state, JSFontFaceSet& thisObject, JSValue value, ThrowScope& throwScope) |
302 | { |
303 | UNUSED_PARAM(throwScope); |
304 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().loadingEvent, value); |
305 | return true; |
306 | } |
307 | |
308 | bool setJSFontFaceSetOnloading(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
309 | { |
310 | return IDLAttribute<JSFontFaceSet>::set<setJSFontFaceSetOnloadingSetter>(*state, thisValue, encodedValue, "onloading" ); |
311 | } |
312 | |
313 | static inline JSValue jsFontFaceSetOnloadingdoneGetter(ExecState& state, JSFontFaceSet& thisObject, ThrowScope& throwScope) |
314 | { |
315 | UNUSED_PARAM(throwScope); |
316 | UNUSED_PARAM(state); |
317 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().loadingdoneEvent, worldForDOMObject(thisObject)); |
318 | } |
319 | |
320 | EncodedJSValue jsFontFaceSetOnloadingdone(ExecState* state, EncodedJSValue thisValue, PropertyName) |
321 | { |
322 | return IDLAttribute<JSFontFaceSet>::get<jsFontFaceSetOnloadingdoneGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onloadingdone" ); |
323 | } |
324 | |
325 | static inline bool setJSFontFaceSetOnloadingdoneSetter(ExecState& state, JSFontFaceSet& thisObject, JSValue value, ThrowScope& throwScope) |
326 | { |
327 | UNUSED_PARAM(throwScope); |
328 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().loadingdoneEvent, value); |
329 | return true; |
330 | } |
331 | |
332 | bool setJSFontFaceSetOnloadingdone(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
333 | { |
334 | return IDLAttribute<JSFontFaceSet>::set<setJSFontFaceSetOnloadingdoneSetter>(*state, thisValue, encodedValue, "onloadingdone" ); |
335 | } |
336 | |
337 | static inline JSValue jsFontFaceSetOnloadingerrorGetter(ExecState& state, JSFontFaceSet& thisObject, ThrowScope& throwScope) |
338 | { |
339 | UNUSED_PARAM(throwScope); |
340 | UNUSED_PARAM(state); |
341 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().loadingerrorEvent, worldForDOMObject(thisObject)); |
342 | } |
343 | |
344 | EncodedJSValue jsFontFaceSetOnloadingerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
345 | { |
346 | return IDLAttribute<JSFontFaceSet>::get<jsFontFaceSetOnloadingerrorGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onloadingerror" ); |
347 | } |
348 | |
349 | static inline bool setJSFontFaceSetOnloadingerrorSetter(ExecState& state, JSFontFaceSet& thisObject, JSValue value, ThrowScope& throwScope) |
350 | { |
351 | UNUSED_PARAM(throwScope); |
352 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().loadingerrorEvent, value); |
353 | return true; |
354 | } |
355 | |
356 | bool setJSFontFaceSetOnloadingerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
357 | { |
358 | return IDLAttribute<JSFontFaceSet>::set<setJSFontFaceSetOnloadingerrorSetter>(*state, thisValue, encodedValue, "onloadingerror" ); |
359 | } |
360 | |
361 | static inline JSValue jsFontFaceSetReadyGetter(ExecState& state, JSFontFaceSet& thisObject, ThrowScope& throwScope) |
362 | { |
363 | UNUSED_PARAM(throwScope); |
364 | UNUSED_PARAM(state); |
365 | auto& impl = thisObject.wrapped(); |
366 | JSValue result = toJS<IDLPromise<IDLInterface<FontFaceSet>>>(state, *thisObject.globalObject(), throwScope, impl.ready()); |
367 | return result; |
368 | } |
369 | |
370 | EncodedJSValue jsFontFaceSetReady(ExecState* state, EncodedJSValue thisValue, PropertyName) |
371 | { |
372 | return IDLAttribute<JSFontFaceSet>::get<jsFontFaceSetReadyGetter, CastedThisErrorBehavior::RejectPromise>(*state, thisValue, "ready" ); |
373 | } |
374 | |
375 | static inline JSValue jsFontFaceSetStatusGetter(ExecState& state, JSFontFaceSet& thisObject, ThrowScope& throwScope) |
376 | { |
377 | UNUSED_PARAM(throwScope); |
378 | UNUSED_PARAM(state); |
379 | auto& impl = thisObject.wrapped(); |
380 | JSValue result = toJS<IDLEnumeration<FontFaceSet::LoadStatus>>(state, throwScope, impl.status()); |
381 | return result; |
382 | } |
383 | |
384 | EncodedJSValue jsFontFaceSetStatus(ExecState* state, EncodedJSValue thisValue, PropertyName) |
385 | { |
386 | return IDLAttribute<JSFontFaceSet>::get<jsFontFaceSetStatusGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "status" ); |
387 | } |
388 | |
389 | static inline JSC::EncodedJSValue jsFontFaceSetPrototypeFunctionHasBody(JSC::ExecState* state, typename IDLOperation<JSFontFaceSet>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
390 | { |
391 | UNUSED_PARAM(state); |
392 | UNUSED_PARAM(throwScope); |
393 | auto& impl = castedThis->wrapped(); |
394 | if (UNLIKELY(state->argumentCount() < 1)) |
395 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
396 | auto font = convert<IDLInterface<FontFace>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "font" , "FontFaceSet" , "has" , "FontFace" ); }); |
397 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
398 | return JSValue::encode(toJS<IDLBoolean>(impl.has(*font))); |
399 | } |
400 | |
401 | EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionHas(ExecState* state) |
402 | { |
403 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionHasBody>(*state, "has" ); |
404 | } |
405 | |
406 | static inline JSC::EncodedJSValue jsFontFaceSetPrototypeFunctionAddBody(JSC::ExecState* state, typename IDLOperation<JSFontFaceSet>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
407 | { |
408 | UNUSED_PARAM(state); |
409 | UNUSED_PARAM(throwScope); |
410 | auto& impl = castedThis->wrapped(); |
411 | if (UNLIKELY(state->argumentCount() < 1)) |
412 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
413 | auto font = convert<IDLInterface<FontFace>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "font" , "FontFaceSet" , "add" , "FontFace" ); }); |
414 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
415 | return JSValue::encode(toJS<IDLInterface<FontFaceSet>>(*state, *castedThis->globalObject(), impl.add(*font))); |
416 | } |
417 | |
418 | EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionAdd(ExecState* state) |
419 | { |
420 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionAddBody>(*state, "add" ); |
421 | } |
422 | |
423 | static inline JSC::EncodedJSValue jsFontFaceSetPrototypeFunctionDeleteBody(JSC::ExecState* state, typename IDLOperation<JSFontFaceSet>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
424 | { |
425 | UNUSED_PARAM(state); |
426 | UNUSED_PARAM(throwScope); |
427 | auto& impl = castedThis->wrapped(); |
428 | if (UNLIKELY(state->argumentCount() < 1)) |
429 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
430 | auto font = convert<IDLInterface<FontFace>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "font" , "FontFaceSet" , "delete" , "FontFace" ); }); |
431 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
432 | return JSValue::encode(toJS<IDLBoolean>(impl.remove(*font))); |
433 | } |
434 | |
435 | EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionDelete(ExecState* state) |
436 | { |
437 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionDeleteBody>(*state, "delete" ); |
438 | } |
439 | |
440 | static inline JSC::EncodedJSValue jsFontFaceSetPrototypeFunctionClearBody(JSC::ExecState* state, typename IDLOperation<JSFontFaceSet>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
441 | { |
442 | UNUSED_PARAM(state); |
443 | UNUSED_PARAM(throwScope); |
444 | auto& impl = castedThis->wrapped(); |
445 | impl.clear(); |
446 | return JSValue::encode(jsUndefined()); |
447 | } |
448 | |
449 | EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionClear(ExecState* state) |
450 | { |
451 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionClearBody>(*state, "clear" ); |
452 | } |
453 | |
454 | static inline JSC::EncodedJSValue jsFontFaceSetPrototypeFunctionLoadBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFontFaceSet>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
455 | { |
456 | UNUSED_PARAM(state); |
457 | UNUSED_PARAM(throwScope); |
458 | auto& impl = castedThis->wrapped(); |
459 | if (UNLIKELY(state->argumentCount() < 1)) |
460 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
461 | auto font = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
462 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
463 | auto text = state->argument(1).isUndefined() ? " "_s : convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
464 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
465 | impl.load(WTFMove(font), WTFMove(text), WTFMove(promise)); |
466 | return JSValue::encode(jsUndefined()); |
467 | } |
468 | |
469 | EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionLoad(ExecState* state) |
470 | { |
471 | return IDLOperationReturningPromise<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionLoadBody, PromiseExecutionScope::WindowOnly>(*state, "load" ); |
472 | } |
473 | |
474 | static inline JSC::EncodedJSValue jsFontFaceSetPrototypeFunctionCheckBody(JSC::ExecState* state, typename IDLOperation<JSFontFaceSet>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
475 | { |
476 | UNUSED_PARAM(state); |
477 | UNUSED_PARAM(throwScope); |
478 | auto& impl = castedThis->wrapped(); |
479 | if (UNLIKELY(state->argumentCount() < 1)) |
480 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
481 | auto font = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
482 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
483 | auto text = state->argument(1).isUndefined() ? " "_s : convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
484 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
485 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, impl.check(WTFMove(font), WTFMove(text)))); |
486 | } |
487 | |
488 | EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionCheck(ExecState* state) |
489 | { |
490 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionCheckBody>(*state, "check" ); |
491 | } |
492 | |
493 | struct FontFaceSetIteratorTraits { |
494 | static constexpr JSDOMIteratorType type = JSDOMIteratorType::Set; |
495 | using KeyType = void; |
496 | using ValueType = IDLInterface<FontFace>; |
497 | }; |
498 | |
499 | using FontFaceSetIterator = JSDOMIterator<JSFontFaceSet, FontFaceSetIteratorTraits>; |
500 | using FontFaceSetIteratorPrototype = JSDOMIteratorPrototype<JSFontFaceSet, FontFaceSetIteratorTraits>; |
501 | |
502 | template<> |
503 | const JSC::ClassInfo FontFaceSetIterator::s_info = { "FontFaceSet Iterator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(FontFaceSetIterator) }; |
504 | |
505 | template<> |
506 | const JSC::ClassInfo FontFaceSetIteratorPrototype::s_info = { "FontFaceSet Iterator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(FontFaceSetIteratorPrototype) }; |
507 | |
508 | static inline EncodedJSValue jsFontFaceSetPrototypeFunctionEntriesCaller(ExecState*, JSFontFaceSet* thisObject, JSC::ThrowScope&) |
509 | { |
510 | return JSValue::encode(iteratorCreate<FontFaceSetIterator>(*thisObject, IterationKind::Value)); |
511 | } |
512 | |
513 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionEntries(JSC::ExecState* state) |
514 | { |
515 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionEntriesCaller>(*state, "entries" ); |
516 | } |
517 | |
518 | static inline EncodedJSValue jsFontFaceSetPrototypeFunctionKeysCaller(ExecState*, JSFontFaceSet* thisObject, JSC::ThrowScope&) |
519 | { |
520 | return JSValue::encode(iteratorCreate<FontFaceSetIterator>(*thisObject, IterationKind::Key)); |
521 | } |
522 | |
523 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionKeys(JSC::ExecState* state) |
524 | { |
525 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionKeysCaller>(*state, "keys" ); |
526 | } |
527 | |
528 | static inline EncodedJSValue jsFontFaceSetPrototypeFunctionValuesCaller(ExecState*, JSFontFaceSet* thisObject, JSC::ThrowScope&) |
529 | { |
530 | return JSValue::encode(iteratorCreate<FontFaceSetIterator>(*thisObject, IterationKind::Value)); |
531 | } |
532 | |
533 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionValues(JSC::ExecState* state) |
534 | { |
535 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionValuesCaller>(*state, "values" ); |
536 | } |
537 | |
538 | static inline EncodedJSValue jsFontFaceSetPrototypeFunctionForEachCaller(ExecState* state, JSFontFaceSet* thisObject, JSC::ThrowScope& throwScope) |
539 | { |
540 | return JSValue::encode(iteratorForEach<FontFaceSetIterator>(*state, *thisObject, throwScope)); |
541 | } |
542 | |
543 | JSC::EncodedJSValue JSC_HOST_CALL jsFontFaceSetPrototypeFunctionForEach(JSC::ExecState* state) |
544 | { |
545 | return IDLOperation<JSFontFaceSet>::call<jsFontFaceSetPrototypeFunctionForEachCaller>(*state, "forEach" ); |
546 | } |
547 | |
548 | void JSFontFaceSet::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
549 | { |
550 | auto* thisObject = jsCast<JSFontFaceSet*>(cell); |
551 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
552 | if (thisObject->scriptExecutionContext()) |
553 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
554 | Base::heapSnapshot(cell, builder); |
555 | } |
556 | |
557 | #if ENABLE(BINDING_INTEGRITY) |
558 | #if PLATFORM(WIN) |
559 | #pragma warning(disable: 4483) |
560 | extern "C" { extern void (*const __identifier("??_7FontFaceSet@WebCore@@6B@" )[])(); } |
561 | #else |
562 | extern "C" { extern void* _ZTVN7WebCore11FontFaceSetE[]; } |
563 | #endif |
564 | #endif |
565 | |
566 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FontFaceSet>&& impl) |
567 | { |
568 | |
569 | #if ENABLE(BINDING_INTEGRITY) |
570 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
571 | #if PLATFORM(WIN) |
572 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7FontFaceSet@WebCore@@6B@" )); |
573 | #else |
574 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore11FontFaceSetE[2]); |
575 | #endif |
576 | |
577 | // If this fails FontFaceSet does not have a vtable, so you need to add the |
578 | // ImplementationLacksVTable attribute to the interface definition |
579 | static_assert(std::is_polymorphic<FontFaceSet>::value, "FontFaceSet is not polymorphic" ); |
580 | |
581 | // If you hit this assertion you either have a use after free bug, or |
582 | // FontFaceSet has subclasses. If FontFaceSet has subclasses that get passed |
583 | // to toJS() we currently require FontFaceSet you to opt out of binding hardening |
584 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
585 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
586 | #endif |
587 | return createWrapper<FontFaceSet>(globalObject, WTFMove(impl)); |
588 | } |
589 | |
590 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FontFaceSet& impl) |
591 | { |
592 | return wrap(state, globalObject, impl); |
593 | } |
594 | |
595 | FontFaceSet* JSFontFaceSet::toWrapped(JSC::VM& vm, JSC::JSValue value) |
596 | { |
597 | if (auto* wrapper = jsDynamicCast<JSFontFaceSet*>(vm, value)) |
598 | return &wrapper->wrapped(); |
599 | return nullptr; |
600 | } |
601 | |
602 | } |
603 | |