/work/obj-fuzz/dom/bindings/HTMLFontElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM HTMLFontElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "HTMLElementBinding.h" |
4 | | #include "HTMLFontElementBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/CustomElementRegistry.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/DocGroup.h" |
11 | | #include "mozilla/dom/HTMLFontElement.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/XrayExpandoClass.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
19 | | using namespace mozilla::dom::binding_detail; |
20 | | |
21 | | |
22 | | namespace HTMLFontElement_Binding { |
23 | | |
24 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value, |
25 | | "Can't inherit from an interface with a different ownership model."); |
26 | | |
27 | | MOZ_CAN_RUN_SCRIPT static bool |
28 | | get_color(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFontElement* self, JSJitGetterCallArgs args) |
29 | 0 | { |
30 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLFontElement.color", DOM, cx); |
31 | 0 |
|
32 | 0 | DOMString result; |
33 | 0 | self->GetColor(result); |
34 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
35 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
36 | 0 | return false; |
37 | 0 | } |
38 | 0 | return true; |
39 | 0 | } |
40 | | |
41 | | MOZ_CAN_RUN_SCRIPT static bool |
42 | | set_color(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFontElement* self, JSJitSetterCallArgs args) |
43 | 0 | { |
44 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLFontElement.color", DOM, cx); |
45 | 0 |
|
46 | 0 | binding_detail::FakeString arg0; |
47 | 0 | if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) { |
48 | 0 | return false; |
49 | 0 | } |
50 | 0 | Maybe<AutoCEReaction> ceReaction; |
51 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
52 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
53 | 0 | if (docGroup) { |
54 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
55 | 0 | } |
56 | 0 | } |
57 | 0 | FastErrorResult rv; |
58 | 0 | self->SetColor(NonNullHelper(Constify(arg0)), rv); |
59 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
60 | 0 | return false; |
61 | 0 | } |
62 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
63 | 0 |
|
64 | 0 | return true; |
65 | 0 | } |
66 | | |
67 | | static const JSJitInfo color_getterinfo = { |
68 | | { (JSJitGetterOp)get_color }, |
69 | | { prototypes::id::HTMLFontElement }, |
70 | | { PrototypeTraits<prototypes::id::HTMLFontElement>::Depth }, |
71 | | JSJitInfo::Getter, |
72 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
73 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
74 | | false, /* isInfallible. False in setters. */ |
75 | | false, /* isMovable. Not relevant for setters. */ |
76 | | false, /* isEliminatable. Not relevant for setters. */ |
77 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
78 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
79 | | false, /* isTypedMethod. Only relevant for methods. */ |
80 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
81 | | }; |
82 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
83 | | static_assert(0 < 1, "There is no slot for us"); |
84 | | static const JSJitInfo color_setterinfo = { |
85 | | { (JSJitGetterOp)set_color }, |
86 | | { prototypes::id::HTMLFontElement }, |
87 | | { PrototypeTraits<prototypes::id::HTMLFontElement>::Depth }, |
88 | | JSJitInfo::Setter, |
89 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
90 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
91 | | false, /* isInfallible. False in setters. */ |
92 | | false, /* isMovable. Not relevant for setters. */ |
93 | | false, /* isEliminatable. Not relevant for setters. */ |
94 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
95 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
96 | | false, /* isTypedMethod. Only relevant for methods. */ |
97 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
98 | | }; |
99 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
100 | | static_assert(0 < 1, "There is no slot for us"); |
101 | | |
102 | | MOZ_CAN_RUN_SCRIPT static bool |
103 | | get_face(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFontElement* self, JSJitGetterCallArgs args) |
104 | 0 | { |
105 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLFontElement.face", DOM, cx); |
106 | 0 |
|
107 | 0 | DOMString result; |
108 | 0 | self->GetFace(result); |
109 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
110 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
111 | 0 | return false; |
112 | 0 | } |
113 | 0 | return true; |
114 | 0 | } |
115 | | |
116 | | MOZ_CAN_RUN_SCRIPT static bool |
117 | | set_face(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFontElement* self, JSJitSetterCallArgs args) |
118 | 0 | { |
119 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLFontElement.face", DOM, cx); |
120 | 0 |
|
121 | 0 | binding_detail::FakeString arg0; |
122 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
123 | 0 | return false; |
124 | 0 | } |
125 | 0 | Maybe<AutoCEReaction> ceReaction; |
126 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
127 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
128 | 0 | if (docGroup) { |
129 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
130 | 0 | } |
131 | 0 | } |
132 | 0 | FastErrorResult rv; |
133 | 0 | self->SetFace(NonNullHelper(Constify(arg0)), rv); |
134 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
135 | 0 | return false; |
136 | 0 | } |
137 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
138 | 0 |
|
139 | 0 | return true; |
140 | 0 | } |
141 | | |
142 | | static const JSJitInfo face_getterinfo = { |
143 | | { (JSJitGetterOp)get_face }, |
144 | | { prototypes::id::HTMLFontElement }, |
145 | | { PrototypeTraits<prototypes::id::HTMLFontElement>::Depth }, |
146 | | JSJitInfo::Getter, |
147 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
148 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
149 | | false, /* isInfallible. False in setters. */ |
150 | | false, /* isMovable. Not relevant for setters. */ |
151 | | false, /* isEliminatable. Not relevant for setters. */ |
152 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
153 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
154 | | false, /* isTypedMethod. Only relevant for methods. */ |
155 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
156 | | }; |
157 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
158 | | static_assert(0 < 1, "There is no slot for us"); |
159 | | static const JSJitInfo face_setterinfo = { |
160 | | { (JSJitGetterOp)set_face }, |
161 | | { prototypes::id::HTMLFontElement }, |
162 | | { PrototypeTraits<prototypes::id::HTMLFontElement>::Depth }, |
163 | | JSJitInfo::Setter, |
164 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
165 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
166 | | false, /* isInfallible. False in setters. */ |
167 | | false, /* isMovable. Not relevant for setters. */ |
168 | | false, /* isEliminatable. Not relevant for setters. */ |
169 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
170 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
171 | | false, /* isTypedMethod. Only relevant for methods. */ |
172 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
173 | | }; |
174 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
175 | | static_assert(0 < 1, "There is no slot for us"); |
176 | | |
177 | | MOZ_CAN_RUN_SCRIPT static bool |
178 | | get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFontElement* self, JSJitGetterCallArgs args) |
179 | 0 | { |
180 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLFontElement.size", DOM, cx); |
181 | 0 |
|
182 | 0 | DOMString result; |
183 | 0 | self->GetSize(result); |
184 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
185 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
186 | 0 | return false; |
187 | 0 | } |
188 | 0 | return true; |
189 | 0 | } |
190 | | |
191 | | MOZ_CAN_RUN_SCRIPT static bool |
192 | | set_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFontElement* self, JSJitSetterCallArgs args) |
193 | 0 | { |
194 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLFontElement.size", DOM, cx); |
195 | 0 |
|
196 | 0 | binding_detail::FakeString arg0; |
197 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
198 | 0 | return false; |
199 | 0 | } |
200 | 0 | Maybe<AutoCEReaction> ceReaction; |
201 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
202 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
203 | 0 | if (docGroup) { |
204 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
205 | 0 | } |
206 | 0 | } |
207 | 0 | FastErrorResult rv; |
208 | 0 | self->SetSize(NonNullHelper(Constify(arg0)), rv); |
209 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
210 | 0 | return false; |
211 | 0 | } |
212 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
213 | 0 |
|
214 | 0 | return true; |
215 | 0 | } |
216 | | |
217 | | static const JSJitInfo size_getterinfo = { |
218 | | { (JSJitGetterOp)get_size }, |
219 | | { prototypes::id::HTMLFontElement }, |
220 | | { PrototypeTraits<prototypes::id::HTMLFontElement>::Depth }, |
221 | | JSJitInfo::Getter, |
222 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
223 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
224 | | false, /* isInfallible. False in setters. */ |
225 | | false, /* isMovable. Not relevant for setters. */ |
226 | | false, /* isEliminatable. Not relevant for setters. */ |
227 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
228 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
229 | | false, /* isTypedMethod. Only relevant for methods. */ |
230 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
231 | | }; |
232 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
233 | | static_assert(0 < 1, "There is no slot for us"); |
234 | | static const JSJitInfo size_setterinfo = { |
235 | | { (JSJitGetterOp)set_size }, |
236 | | { prototypes::id::HTMLFontElement }, |
237 | | { PrototypeTraits<prototypes::id::HTMLFontElement>::Depth }, |
238 | | JSJitInfo::Setter, |
239 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
240 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
241 | | false, /* isInfallible. False in setters. */ |
242 | | false, /* isMovable. Not relevant for setters. */ |
243 | | false, /* isEliminatable. Not relevant for setters. */ |
244 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
245 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
246 | | false, /* isTypedMethod. Only relevant for methods. */ |
247 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
248 | | }; |
249 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
250 | | static_assert(0 < 1, "There is no slot for us"); |
251 | | |
252 | | static bool |
253 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
254 | 0 | { |
255 | 0 | mozilla::dom::HTMLFontElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLFontElement>(obj); |
256 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
257 | 0 | // obviously can't preserve if we're not initialized. |
258 | 0 | if (self && self->GetWrapperPreserveColor()) { |
259 | 0 | PreserveWrapper(self); |
260 | 0 | } |
261 | 0 | return true; |
262 | 0 | } |
263 | | |
264 | | static void |
265 | | _finalize(js::FreeOp* fop, JSObject* obj) |
266 | 0 | { |
267 | 0 | mozilla::dom::HTMLFontElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLFontElement>(obj); |
268 | 0 | if (self) { |
269 | 0 | ClearWrapper(self, self, obj); |
270 | 0 | AddForDeferredFinalization<mozilla::dom::HTMLFontElement>(self); |
271 | 0 | } |
272 | 0 | } |
273 | | |
274 | | static size_t |
275 | | _objectMoved(JSObject* obj, JSObject* old) |
276 | 0 | { |
277 | 0 | mozilla::dom::HTMLFontElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLFontElement>(obj); |
278 | 0 | if (self) { |
279 | 0 | UpdateWrapper(self, self, obj, old); |
280 | 0 | } |
281 | 0 |
|
282 | 0 | return 0; |
283 | 0 | } |
284 | | |
285 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
286 | | #if defined(__clang__) |
287 | | #pragma clang diagnostic push |
288 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
289 | | #endif |
290 | | static const JSPropertySpec sAttributes_specs[] = { |
291 | | { "color", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &color_getterinfo, GenericSetter<NormalThisPolicy>, &color_setterinfo }, |
292 | | { "face", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &face_getterinfo, GenericSetter<NormalThisPolicy>, &face_setterinfo }, |
293 | | { "size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, GenericSetter<NormalThisPolicy>, &size_setterinfo }, |
294 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
295 | | }; |
296 | | #if defined(__clang__) |
297 | | #pragma clang diagnostic pop |
298 | | #endif |
299 | | |
300 | | |
301 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
302 | | { nullptr, &sAttributes_specs[0] }, |
303 | | { nullptr, nullptr } |
304 | | }; |
305 | | |
306 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
307 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
308 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
309 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
310 | | |
311 | | |
312 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
313 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
314 | | |
315 | | static const NativePropertiesN<1> sNativeProperties = { |
316 | | false, 0, |
317 | | false, 0, |
318 | | false, 0, |
319 | | true, 0 /* sAttributes */, |
320 | | false, 0, |
321 | | false, 0, |
322 | | false, 0, |
323 | | -1, |
324 | | 3, |
325 | | sNativeProperties_sortedPropertyIndices, |
326 | | { |
327 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
328 | | } |
329 | | }; |
330 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
331 | | "We have a property info count that is oversized"); |
332 | | |
333 | | static bool |
334 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
335 | 0 | { |
336 | 0 | AUTO_PROFILER_LABEL_FAST("HTMLFontElement constructor", DOM, cx); |
337 | 0 |
|
338 | 0 | return HTMLConstructor(cx, argc, vp, |
339 | 0 | constructors::id::HTMLFontElement, |
340 | 0 | prototypes::id::HTMLFontElement, |
341 | 0 | CreateInterfaceObjects); |
342 | 0 | } |
343 | | |
344 | | static const js::ClassOps sInterfaceObjectClassOps = { |
345 | | nullptr, /* addProperty */ |
346 | | nullptr, /* delProperty */ |
347 | | nullptr, /* enumerate */ |
348 | | nullptr, /* newEnumerate */ |
349 | | nullptr, /* resolve */ |
350 | | nullptr, /* mayResolve */ |
351 | | nullptr, /* finalize */ |
352 | | _constructor, /* call */ |
353 | | nullptr, /* hasInstance */ |
354 | | _constructor, /* construct */ |
355 | | nullptr, /* trace */ |
356 | | }; |
357 | | |
358 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
359 | | { |
360 | | "Function", |
361 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
362 | | &sInterfaceObjectClassOps, |
363 | | JS_NULL_CLASS_SPEC, |
364 | | JS_NULL_CLASS_EXT, |
365 | | &sInterfaceObjectClassObjectOps |
366 | | }, |
367 | | eInterface, |
368 | | true, |
369 | | prototypes::id::HTMLFontElement, |
370 | | PrototypeTraits<prototypes::id::HTMLFontElement>::Depth, |
371 | | sNativePropertyHooks, |
372 | | "function HTMLFontElement() {\n [native code]\n}", |
373 | | HTMLElement_Binding::GetConstructorObject |
374 | | }; |
375 | | |
376 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
377 | | { |
378 | | "HTMLFontElementPrototype", |
379 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
380 | | JS_NULL_CLASS_OPS, |
381 | | JS_NULL_CLASS_SPEC, |
382 | | JS_NULL_CLASS_EXT, |
383 | | JS_NULL_OBJECT_OPS |
384 | | }, |
385 | | eInterfacePrototype, |
386 | | false, |
387 | | prototypes::id::HTMLFontElement, |
388 | | PrototypeTraits<prototypes::id::HTMLFontElement>::Depth, |
389 | | sNativePropertyHooks, |
390 | | "[object HTMLFontElementPrototype]", |
391 | | HTMLElement_Binding::GetProtoObject |
392 | | }; |
393 | | |
394 | | static const js::ClassOps sClassOps = { |
395 | | _addProperty, /* addProperty */ |
396 | | nullptr, /* delProperty */ |
397 | | nullptr, /* enumerate */ |
398 | | nullptr, /* newEnumerate */ |
399 | | nullptr, /* resolve */ |
400 | | nullptr, /* mayResolve */ |
401 | | _finalize, /* finalize */ |
402 | | nullptr, /* call */ |
403 | | nullptr, /* hasInstance */ |
404 | | nullptr, /* construct */ |
405 | | nullptr, /* trace */ |
406 | | }; |
407 | | |
408 | | static const js::ClassExtension sClassExtension = { |
409 | | nullptr, /* weakmapKeyDelegateOp */ |
410 | | _objectMoved /* objectMovedOp */ |
411 | | }; |
412 | | |
413 | | static const DOMJSClass sClass = { |
414 | | { "HTMLFontElement", |
415 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
416 | | &sClassOps, |
417 | | JS_NULL_CLASS_SPEC, |
418 | | &sClassExtension, |
419 | | JS_NULL_OBJECT_OPS |
420 | | }, |
421 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLFontElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
422 | | IsBaseOf<nsISupports, mozilla::dom::HTMLFontElement >::value, |
423 | | sNativePropertyHooks, |
424 | | FindAssociatedGlobalForNative<mozilla::dom::HTMLFontElement>::Get, |
425 | | GetProtoObjectHandle, |
426 | | GetCCParticipant<mozilla::dom::HTMLFontElement>::Get() |
427 | | }; |
428 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
429 | | "Must have the right minimal number of reserved slots."); |
430 | | static_assert(1 >= 1, |
431 | | "Must have enough reserved slots."); |
432 | | |
433 | | const JSClass* |
434 | | GetJSClass() |
435 | 0 | { |
436 | 0 | return sClass.ToJSClass(); |
437 | 0 | } |
438 | | |
439 | | bool |
440 | | Wrap(JSContext* aCx, mozilla::dom::HTMLFontElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
441 | 0 | { |
442 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLFontElement>::value, |
443 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
444 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::HTMLFontElement*>(aObject) == |
445 | 0 | reinterpret_cast<mozilla::dom::HTMLFontElement*>(aObject), |
446 | 0 | "Multiple inheritance for mozilla::dom::HTMLFontElement is broken."); |
447 | 0 | MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) == |
448 | 0 | reinterpret_cast<nsGenericHTMLElement*>(aObject), |
449 | 0 | "Multiple inheritance for nsGenericHTMLElement is broken."); |
450 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
451 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
452 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
453 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
454 | 0 | reinterpret_cast<nsINode*>(aObject), |
455 | 0 | "Multiple inheritance for nsINode is broken."); |
456 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
457 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
458 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
459 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
460 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
461 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
462 | 0 | "You should probably not be using Wrap() directly; use " |
463 | 0 | "GetOrCreateDOMReflector instead"); |
464 | 0 |
|
465 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
466 | 0 | "nsISupports must be on our primary inheritance chain"); |
467 | 0 |
|
468 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
469 | 0 | if (!global) { |
470 | 0 | return false; |
471 | 0 | } |
472 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
473 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
474 | 0 |
|
475 | 0 | // That might have ended up wrapping us already, due to the wonders |
476 | 0 | // of XBL. Check for that, and bail out as needed. |
477 | 0 | aReflector.set(aCache->GetWrapper()); |
478 | 0 | if (aReflector) { |
479 | | #ifdef DEBUG |
480 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
481 | | #endif // DEBUG |
482 | | return true; |
483 | 0 | } |
484 | 0 |
|
485 | 0 | JSAutoRealm ar(aCx, global); |
486 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
487 | 0 | if (!canonicalProto) { |
488 | 0 | return false; |
489 | 0 | } |
490 | 0 | JS::Rooted<JSObject*> proto(aCx); |
491 | 0 | if (aGivenProto) { |
492 | 0 | proto = aGivenProto; |
493 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
494 | 0 | // coming in, we changed compartments to that of "parent" so may need |
495 | 0 | // to wrap the proto here. |
496 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
497 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
498 | 0 | return false; |
499 | 0 | } |
500 | 0 | } |
501 | 0 | } else { |
502 | 0 | proto = canonicalProto; |
503 | 0 | } |
504 | 0 |
|
505 | 0 | BindingJSObjectCreator<mozilla::dom::HTMLFontElement> creator(aCx); |
506 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
507 | 0 | if (!aReflector) { |
508 | 0 | return false; |
509 | 0 | } |
510 | 0 | |
511 | 0 | aCache->SetWrapper(aReflector); |
512 | 0 | creator.InitializationSucceeded(); |
513 | 0 |
|
514 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
515 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
516 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
517 | 0 | // otherwise we won't be able to properly recreate it later, since |
518 | 0 | // we won't know what proto to use. Note that we don't check |
519 | 0 | // aGivenProto here, since it's entirely possible (and even |
520 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
521 | 0 | // same as canonicalProto. |
522 | 0 | if (proto != canonicalProto) { |
523 | 0 | PreserveWrapper(aObject); |
524 | 0 | } |
525 | 0 |
|
526 | 0 | return true; |
527 | 0 | } |
528 | | |
529 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
530 | | nullptr, |
531 | | nullptr, |
532 | | nullptr, |
533 | | { sNativeProperties.Upcast(), nullptr }, |
534 | | prototypes::id::HTMLFontElement, |
535 | | constructors::id::HTMLFontElement, |
536 | | HTMLElement_Binding::sNativePropertyHooks, |
537 | | &DefaultXrayExpandoObjectClass |
538 | | } }; |
539 | | |
540 | | void |
541 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
542 | 0 | { |
543 | 0 | JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx)); |
544 | 0 | if (!parentProto) { |
545 | 0 | return; |
546 | 0 | } |
547 | 0 | |
548 | 0 | JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx)); |
549 | 0 | if (!constructorProto) { |
550 | 0 | return; |
551 | 0 | } |
552 | 0 | |
553 | 0 | static bool sIdsInited = false; |
554 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
555 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
556 | 0 | return; |
557 | 0 | } |
558 | 0 | sIdsInited = true; |
559 | 0 | } |
560 | 0 |
|
561 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLFontElement); |
562 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLFontElement); |
563 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
564 | 0 | &sPrototypeClass.mBase, protoCache, |
565 | 0 | nullptr, |
566 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
567 | 0 | interfaceCache, |
568 | 0 | sNativeProperties.Upcast(), |
569 | 0 | nullptr, |
570 | 0 | "HTMLFontElement", aDefineOnGlobal, |
571 | 0 | nullptr, |
572 | 0 | false); |
573 | 0 | } |
574 | | |
575 | | JSObject* |
576 | | GetConstructorObject(JSContext* aCx) |
577 | 0 | { |
578 | 0 | return GetConstructorObjectHandle(aCx); |
579 | 0 | } |
580 | | |
581 | | } // namespace HTMLFontElement_Binding |
582 | | |
583 | | |
584 | | |
585 | | } // namespace dom |
586 | | } // namespace mozilla |