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