Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM XMLStylesheetProcessingInstruction.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "ProcessingInstructionBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "XMLStylesheetProcessingInstructionBinding.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/XMLStylesheetProcessingInstruction.h"
13 : #include "mozilla/dom/XrayExpandoClass.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : namespace XMLStylesheetProcessingInstructionBinding {
19 :
20 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<ProcessingInstructionBinding::NativeType>::value,
21 : "Can't inherit from an interface with a different ownership model.");
22 :
23 : static bool
24 0 : get_sheet(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XMLStylesheetProcessingInstruction* self, JSJitGetterCallArgs args)
25 : {
26 0 : auto result(StrongOrRawPtr<mozilla::StyleSheet>(self->GetSheet()));
27 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
28 0 : if (!result) {
29 0 : args.rval().setNull();
30 0 : return true;
31 : }
32 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
33 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
34 0 : return false;
35 : }
36 0 : return true;
37 : }
38 :
39 : static const JSJitInfo sheet_getterinfo = {
40 : { (JSJitGetterOp)get_sheet },
41 : { prototypes::id::XMLStylesheetProcessingInstruction },
42 : { PrototypeTraits<prototypes::id::XMLStylesheetProcessingInstruction>::Depth },
43 : JSJitInfo::Getter,
44 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
45 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
46 : false, /* isInfallible. False in setters. */
47 : false, /* isMovable. Not relevant for setters. */
48 : false, /* isEliminatable. Not relevant for setters. */
49 : false, /* isAlwaysInSlot. Only relevant for getters. */
50 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
51 : false, /* isTypedMethod. Only relevant for methods. */
52 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
53 : };
54 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
55 : static_assert(0 < 1, "There is no slot for us");
56 :
57 : static bool
58 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
59 : {
60 0 : mozilla::dom::XMLStylesheetProcessingInstruction* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XMLStylesheetProcessingInstruction>(obj);
61 : // We don't want to preserve if we don't have a wrapper, and we
62 : // obviously can't preserve if we're not initialized.
63 0 : if (self && self->GetWrapperPreserveColor()) {
64 0 : PreserveWrapper(self);
65 : }
66 0 : return true;
67 : }
68 :
69 : static void
70 0 : _finalize(js::FreeOp* fop, JSObject* obj)
71 : {
72 0 : mozilla::dom::XMLStylesheetProcessingInstruction* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XMLStylesheetProcessingInstruction>(obj);
73 0 : if (self) {
74 0 : ClearWrapper(self, self, obj);
75 0 : AddForDeferredFinalization<mozilla::dom::XMLStylesheetProcessingInstruction>(self);
76 : }
77 0 : }
78 :
79 : static void
80 0 : _objectMoved(JSObject* obj, const JSObject* old)
81 : {
82 0 : mozilla::dom::XMLStylesheetProcessingInstruction* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XMLStylesheetProcessingInstruction>(obj);
83 0 : if (self) {
84 0 : UpdateWrapper(self, self, obj, old);
85 : }
86 0 : }
87 :
88 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
89 : #if defined(__clang__)
90 : #pragma clang diagnostic push
91 : #pragma clang diagnostic ignored "-Wmissing-braces"
92 : #endif
93 : static const JSPropertySpec sAttributes_specs[] = {
94 : { "sheet", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sheet_getterinfo, nullptr, nullptr },
95 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
96 : };
97 : #if defined(__clang__)
98 : #pragma clang diagnostic pop
99 : #endif
100 :
101 :
102 : // Can't be const because the pref-enabled boolean needs to be writable
103 : static Prefable<const JSPropertySpec> sAttributes[] = {
104 : { nullptr, &sAttributes_specs[0] },
105 : { nullptr, nullptr }
106 : };
107 :
108 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
109 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
110 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
111 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
112 :
113 :
114 : static uint16_t sNativeProperties_sortedPropertyIndices[1];
115 : static PropertyInfo sNativeProperties_propertyInfos[1];
116 :
117 : static const NativePropertiesN<1> sNativeProperties = {
118 : false, 0,
119 : false, 0,
120 : false, 0,
121 : true, 0 /* sAttributes */,
122 : false, 0,
123 : false, 0,
124 : false, 0,
125 : -1,
126 : 1,
127 : sNativeProperties_sortedPropertyIndices,
128 : {
129 : { sAttributes, &sNativeProperties_propertyInfos[0] }
130 : }
131 : };
132 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
133 : "We have a property info count that is oversized");
134 :
135 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
136 : {
137 : "Function",
138 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
139 : &sBoringInterfaceObjectClassClassOps,
140 : JS_NULL_CLASS_SPEC,
141 : JS_NULL_CLASS_EXT,
142 : &sInterfaceObjectClassObjectOps
143 : },
144 : eInterface,
145 : true,
146 : prototypes::id::XMLStylesheetProcessingInstruction,
147 : PrototypeTraits<prototypes::id::XMLStylesheetProcessingInstruction>::Depth,
148 : sNativePropertyHooks,
149 : "function XMLStylesheetProcessingInstruction() {\n [native code]\n}",
150 : ProcessingInstructionBinding::GetConstructorObject
151 : };
152 :
153 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
154 : {
155 : "XMLStylesheetProcessingInstructionPrototype",
156 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
157 : JS_NULL_CLASS_OPS,
158 : JS_NULL_CLASS_SPEC,
159 : JS_NULL_CLASS_EXT,
160 : JS_NULL_OBJECT_OPS
161 : },
162 : eInterfacePrototype,
163 : false,
164 : prototypes::id::XMLStylesheetProcessingInstruction,
165 : PrototypeTraits<prototypes::id::XMLStylesheetProcessingInstruction>::Depth,
166 : sNativePropertyHooks,
167 : "[object XMLStylesheetProcessingInstructionPrototype]",
168 : ProcessingInstructionBinding::GetProtoObject
169 : };
170 :
171 : JSObject*
172 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
173 : {
174 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
175 : }
176 :
177 : static const js::ClassOps sClassOps = {
178 : _addProperty, /* addProperty */
179 : nullptr, /* delProperty */
180 : nullptr, /* getProperty */
181 : nullptr, /* setProperty */
182 : nullptr, /* enumerate */
183 : nullptr, /* newEnumerate */
184 : nullptr, /* resolve */
185 : nullptr, /* mayResolve */
186 : _finalize, /* finalize */
187 : nullptr, /* call */
188 : nullptr, /* hasInstance */
189 : nullptr, /* construct */
190 : nullptr, /* trace */
191 : };
192 :
193 : static const js::ClassExtension sClassExtension = {
194 : nullptr, /* weakmapKeyDelegateOp */
195 : _objectMoved /* objectMovedOp */
196 : };
197 :
198 : static const DOMJSClass sClass = {
199 : { "XMLStylesheetProcessingInstruction",
200 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
201 : &sClassOps,
202 : JS_NULL_CLASS_SPEC,
203 : &sClassExtension,
204 : JS_NULL_OBJECT_OPS
205 : },
206 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::CharacterData, prototypes::id::ProcessingInstruction, prototypes::id::XMLStylesheetProcessingInstruction, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
207 : IsBaseOf<nsISupports, mozilla::dom::XMLStylesheetProcessingInstruction >::value,
208 : sNativePropertyHooks,
209 : FindAssociatedGlobalForNative<mozilla::dom::XMLStylesheetProcessingInstruction>::Get,
210 : GetProtoObjectHandle,
211 : GetCCParticipant<mozilla::dom::XMLStylesheetProcessingInstruction>::Get()
212 : };
213 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
214 : "Must have the right minimal number of reserved slots.");
215 : static_assert(1 >= 1,
216 : "Must have enough reserved slots.");
217 :
218 : const JSClass*
219 0 : GetJSClass()
220 : {
221 0 : return sClass.ToJSClass();
222 : }
223 :
224 : bool
225 0 : Wrap(JSContext* aCx, mozilla::dom::XMLStylesheetProcessingInstruction* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
226 : {
227 : MOZ_ASSERT(static_cast<mozilla::dom::XMLStylesheetProcessingInstruction*>(aObject) ==
228 : reinterpret_cast<mozilla::dom::XMLStylesheetProcessingInstruction*>(aObject),
229 : "Multiple inheritance for mozilla::dom::XMLStylesheetProcessingInstruction is broken.");
230 : MOZ_ASSERT(static_cast<mozilla::dom::ProcessingInstruction*>(aObject) ==
231 : reinterpret_cast<mozilla::dom::ProcessingInstruction*>(aObject),
232 : "Multiple inheritance for mozilla::dom::ProcessingInstruction is broken.");
233 : MOZ_ASSERT(static_cast<nsGenericDOMDataNode*>(aObject) ==
234 : reinterpret_cast<nsGenericDOMDataNode*>(aObject),
235 : "Multiple inheritance for nsGenericDOMDataNode is broken.");
236 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
237 : reinterpret_cast<nsINode*>(aObject),
238 : "Multiple inheritance for nsINode is broken.");
239 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
240 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
241 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
242 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
243 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
244 0 : MOZ_ASSERT(!aCache->GetWrapper(),
245 : "You should probably not be using Wrap() directly; use "
246 : "GetOrCreateDOMReflector instead");
247 :
248 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
249 : "nsISupports must be on our primary inheritance chain");
250 :
251 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
252 0 : if (!global) {
253 0 : return false;
254 : }
255 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
256 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
257 :
258 : // That might have ended up wrapping us already, due to the wonders
259 : // of XBL. Check for that, and bail out as needed.
260 0 : aReflector.set(aCache->GetWrapper());
261 0 : if (aReflector) {
262 : #ifdef DEBUG
263 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
264 : #endif // DEBUG
265 0 : return true;
266 : }
267 :
268 0 : JSAutoCompartment ac(aCx, global);
269 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
270 0 : if (!canonicalProto) {
271 0 : return false;
272 : }
273 0 : JS::Rooted<JSObject*> proto(aCx);
274 0 : if (aGivenProto) {
275 0 : proto = aGivenProto;
276 : // Unfortunately, while aGivenProto was in the compartment of aCx
277 : // coming in, we changed compartments to that of "parent" so may need
278 : // to wrap the proto here.
279 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
280 0 : if (!JS_WrapObject(aCx, &proto)) {
281 0 : return false;
282 : }
283 : }
284 : } else {
285 0 : proto = canonicalProto;
286 : }
287 :
288 0 : BindingJSObjectCreator<mozilla::dom::XMLStylesheetProcessingInstruction> creator(aCx);
289 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
290 0 : if (!aReflector) {
291 0 : return false;
292 : }
293 :
294 0 : aCache->SetWrapper(aReflector);
295 0 : creator.InitializationSucceeded();
296 :
297 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
298 : aCache->GetWrapperPreserveColor() == aReflector);
299 : // If proto != canonicalProto, we have to preserve our wrapper;
300 : // otherwise we won't be able to properly recreate it later, since
301 : // we won't know what proto to use. Note that we don't check
302 : // aGivenProto here, since it's entirely possible (and even
303 : // somewhat common) to have a non-null aGivenProto which is the
304 : // same as canonicalProto.
305 0 : if (proto != canonicalProto) {
306 0 : PreserveWrapper(aObject);
307 : }
308 :
309 0 : return true;
310 : }
311 :
312 : const NativePropertyHooks sNativePropertyHooks[] = { {
313 : nullptr,
314 : nullptr,
315 : nullptr,
316 : { sNativeProperties.Upcast(), nullptr },
317 : prototypes::id::XMLStylesheetProcessingInstruction,
318 : constructors::id::XMLStylesheetProcessingInstruction,
319 : ProcessingInstructionBinding::sNativePropertyHooks,
320 : &DefaultXrayExpandoObjectClass
321 : } };
322 :
323 : void
324 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
325 : {
326 0 : JS::Handle<JSObject*> parentProto(ProcessingInstructionBinding::GetProtoObjectHandle(aCx));
327 0 : if (!parentProto) {
328 0 : return;
329 : }
330 :
331 0 : JS::Handle<JSObject*> constructorProto(ProcessingInstructionBinding::GetConstructorObjectHandle(aCx));
332 0 : if (!constructorProto) {
333 0 : return;
334 : }
335 :
336 : static bool sIdsInited = false;
337 0 : if (!sIdsInited && NS_IsMainThread()) {
338 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
339 0 : return;
340 : }
341 0 : sIdsInited = true;
342 : }
343 :
344 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XMLStylesheetProcessingInstruction);
345 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XMLStylesheetProcessingInstruction);
346 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
347 : &sPrototypeClass.mBase, protoCache,
348 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
349 : interfaceCache,
350 : sNativeProperties.Upcast(),
351 : nullptr,
352 : "XMLStylesheetProcessingInstruction", aDefineOnGlobal,
353 : nullptr,
354 0 : false);
355 : }
356 :
357 : JS::Handle<JSObject*>
358 0 : GetProtoObjectHandle(JSContext* aCx)
359 : {
360 : /* Get the interface prototype object for this class. This will create the
361 : object as needed. */
362 0 : bool aDefineOnGlobal = true;
363 :
364 : /* Make sure our global is sane. Hopefully we can remove this sometime */
365 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
366 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
367 0 : return nullptr;
368 : }
369 :
370 : /* Check to see whether the interface objects are already installed */
371 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
372 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::XMLStylesheetProcessingInstruction)) {
373 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
374 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
375 : }
376 :
377 : /*
378 : * The object might _still_ be null, but that's OK.
379 : *
380 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
381 : * traced by TraceProtoAndIfaceCache() and its contents are never
382 : * changed after they have been set.
383 : *
384 : * Calling address() avoids the read read barrier that does gray
385 : * unmarking, but it's not possible for the object to be gray here.
386 : */
387 :
388 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::XMLStylesheetProcessingInstruction);
389 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
390 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
391 : }
392 :
393 : JS::Handle<JSObject*>
394 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
395 : {
396 : /* Get the interface object for this class. This will create the object as
397 : needed. */
398 :
399 : /* Make sure our global is sane. Hopefully we can remove this sometime */
400 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
401 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
402 0 : return nullptr;
403 : }
404 :
405 : /* Check to see whether the interface objects are already installed */
406 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
407 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::XMLStylesheetProcessingInstruction)) {
408 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
409 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
410 : }
411 :
412 : /*
413 : * The object might _still_ be null, but that's OK.
414 : *
415 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
416 : * traced by TraceProtoAndIfaceCache() and its contents are never
417 : * changed after they have been set.
418 : *
419 : * Calling address() avoids the read read barrier that does gray
420 : * unmarking, but it's not possible for the object to be gray here.
421 : */
422 :
423 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::XMLStylesheetProcessingInstruction);
424 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
425 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
426 : }
427 :
428 : JSObject*
429 0 : GetConstructorObject(JSContext* aCx)
430 : {
431 0 : return GetConstructorObjectHandle(aCx);
432 : }
433 :
434 : } // namespace XMLStylesheetProcessingInstructionBinding
435 :
436 :
437 :
438 : } // namespace dom
439 : } // namespace mozilla
|