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