Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM CSSValue.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "CSSValueBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/dom/BindingUtils.h"
7 : #include "mozilla/dom/CSSValue.h"
8 : #include "mozilla/dom/DOMJSClass.h"
9 : #include "mozilla/dom/NonRefcountedDOMObject.h"
10 : #include "mozilla/dom/PrimitiveConversions.h"
11 : #include "mozilla/dom/XrayExpandoClass.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : namespace CSSValueBinding {
17 :
18 : static bool
19 0 : get_cssText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSValue* self, JSJitGetterCallArgs args)
20 : {
21 0 : binding_detail::FastErrorResult rv;
22 0 : DOMString result;
23 0 : self->GetCssText(result, rv);
24 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
25 0 : return false;
26 : }
27 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
28 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
29 0 : return false;
30 : }
31 0 : return true;
32 : }
33 :
34 : static bool
35 0 : set_cssText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSValue* self, JSJitSetterCallArgs args)
36 : {
37 0 : binding_detail::FakeString arg0;
38 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
39 0 : return false;
40 : }
41 0 : binding_detail::FastErrorResult rv;
42 0 : self->SetCssText(NonNullHelper(Constify(arg0)), rv);
43 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
44 0 : return false;
45 : }
46 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
47 :
48 0 : return true;
49 : }
50 :
51 : static const JSJitInfo cssText_getterinfo = {
52 : { (JSJitGetterOp)get_cssText },
53 : { prototypes::id::CSSValue },
54 : { PrototypeTraits<prototypes::id::CSSValue>::Depth },
55 : JSJitInfo::Getter,
56 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
57 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
58 : false, /* isInfallible. False in setters. */
59 : false, /* isMovable. Not relevant for setters. */
60 : false, /* isEliminatable. Not relevant for setters. */
61 : false, /* isAlwaysInSlot. Only relevant for getters. */
62 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
63 : false, /* isTypedMethod. Only relevant for methods. */
64 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
65 : };
66 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
67 : static_assert(0 < 1, "There is no slot for us");
68 : static const JSJitInfo cssText_setterinfo = {
69 : { (JSJitGetterOp)set_cssText },
70 : { prototypes::id::CSSValue },
71 : { PrototypeTraits<prototypes::id::CSSValue>::Depth },
72 : JSJitInfo::Setter,
73 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
74 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
75 : false, /* isInfallible. False in setters. */
76 : false, /* isMovable. Not relevant for setters. */
77 : false, /* isEliminatable. Not relevant for setters. */
78 : false, /* isAlwaysInSlot. Only relevant for getters. */
79 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
80 : false, /* isTypedMethod. Only relevant for methods. */
81 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
82 : };
83 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
84 : static_assert(0 < 1, "There is no slot for us");
85 :
86 : static bool
87 0 : get_cssValueType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CSSValue* self, JSJitGetterCallArgs args)
88 : {
89 0 : uint16_t result(self->CssValueType());
90 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
91 0 : args.rval().setInt32(int32_t(result));
92 0 : return true;
93 : }
94 :
95 : static const JSJitInfo cssValueType_getterinfo = {
96 : { (JSJitGetterOp)get_cssValueType },
97 : { prototypes::id::CSSValue },
98 : { PrototypeTraits<prototypes::id::CSSValue>::Depth },
99 : JSJitInfo::Getter,
100 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
101 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
102 : true, /* isInfallible. False in setters. */
103 : false, /* isMovable. Not relevant for setters. */
104 : false, /* isEliminatable. Not relevant for setters. */
105 : false, /* isAlwaysInSlot. Only relevant for getters. */
106 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
107 : false, /* isTypedMethod. Only relevant for methods. */
108 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
109 : };
110 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
111 : static_assert(0 < 1, "There is no slot for us");
112 :
113 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
114 : #if defined(__clang__)
115 : #pragma clang diagnostic push
116 : #pragma clang diagnostic ignored "-Wmissing-braces"
117 : #endif
118 : static const JSPropertySpec sAttributes_specs[] = {
119 : { "cssText", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &cssText_getterinfo, GenericBindingSetter, &cssText_setterinfo },
120 : { "cssValueType", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &cssValueType_getterinfo, nullptr, nullptr },
121 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
122 : };
123 : #if defined(__clang__)
124 : #pragma clang diagnostic pop
125 : #endif
126 :
127 :
128 : // Can't be const because the pref-enabled boolean needs to be writable
129 : static Prefable<const JSPropertySpec> sAttributes[] = {
130 : { nullptr, &sAttributes_specs[0] },
131 : { nullptr, nullptr }
132 : };
133 :
134 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
135 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
136 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
137 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
138 :
139 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
140 : #if defined(__clang__)
141 : #pragma clang diagnostic push
142 : #pragma clang diagnostic ignored "-Wmissing-braces"
143 : #endif
144 : static const ConstantSpec sConstants_specs[] = {
145 : { "CSS_INHERIT", JS::Int32Value(0) },
146 : { "CSS_PRIMITIVE_VALUE", JS::Int32Value(1) },
147 : { "CSS_VALUE_LIST", JS::Int32Value(2) },
148 : { "CSS_CUSTOM", JS::Int32Value(3) },
149 : { 0, JS::UndefinedValue() }
150 : };
151 : #if defined(__clang__)
152 : #pragma clang diagnostic pop
153 : #endif
154 :
155 :
156 : // Can't be const because the pref-enabled boolean needs to be writable
157 : static Prefable<const ConstantSpec> sConstants[] = {
158 : { nullptr, &sConstants_specs[0] },
159 : { nullptr, nullptr }
160 : };
161 :
162 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
163 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
164 : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
165 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
166 :
167 :
168 : static uint16_t sNativeProperties_sortedPropertyIndices[6];
169 : static PropertyInfo sNativeProperties_propertyInfos[6];
170 :
171 : static const NativePropertiesN<2> sNativeProperties = {
172 : false, 0,
173 : false, 0,
174 : false, 0,
175 : true, 0 /* sAttributes */,
176 : false, 0,
177 : false, 0,
178 : true, 1 /* sConstants */,
179 : -1,
180 : 6,
181 : sNativeProperties_sortedPropertyIndices,
182 : {
183 : { sAttributes, &sNativeProperties_propertyInfos[0] },
184 : { sConstants, &sNativeProperties_propertyInfos[2] }
185 : }
186 : };
187 : static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
188 : "We have a property info count that is oversized");
189 :
190 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
191 : {
192 : "Function",
193 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
194 : &sBoringInterfaceObjectClassClassOps,
195 : JS_NULL_CLASS_SPEC,
196 : JS_NULL_CLASS_EXT,
197 : &sInterfaceObjectClassObjectOps
198 : },
199 : eInterface,
200 : true,
201 : prototypes::id::CSSValue,
202 : PrototypeTraits<prototypes::id::CSSValue>::Depth,
203 : sNativePropertyHooks,
204 : "function CSSValue() {\n [native code]\n}",
205 : JS::GetRealmFunctionPrototype
206 : };
207 :
208 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
209 : {
210 : "CSSValuePrototype",
211 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
212 : JS_NULL_CLASS_OPS,
213 : JS_NULL_CLASS_SPEC,
214 : JS_NULL_CLASS_EXT,
215 : JS_NULL_OBJECT_OPS
216 : },
217 : eInterfacePrototype,
218 : false,
219 : prototypes::id::CSSValue,
220 : PrototypeTraits<prototypes::id::CSSValue>::Depth,
221 : sNativePropertyHooks,
222 : "[object CSSValuePrototype]",
223 : JS::GetRealmObjectPrototype
224 : };
225 :
226 : JSObject*
227 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
228 : {
229 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
230 : }
231 :
232 : const NativePropertyHooks sNativePropertyHooks[] = { {
233 : nullptr,
234 : nullptr,
235 : nullptr,
236 : { sNativeProperties.Upcast(), nullptr },
237 : prototypes::id::CSSValue,
238 : constructors::id::CSSValue,
239 : nullptr,
240 : &DefaultXrayExpandoObjectClass
241 : } };
242 :
243 : void
244 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
245 : {
246 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
247 0 : if (!parentProto) {
248 0 : return;
249 : }
250 :
251 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
252 0 : if (!constructorProto) {
253 0 : return;
254 : }
255 :
256 : static bool sIdsInited = false;
257 0 : if (!sIdsInited && NS_IsMainThread()) {
258 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
259 0 : return;
260 : }
261 0 : sIdsInited = true;
262 : }
263 :
264 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSValue);
265 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSValue);
266 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
267 : &sPrototypeClass.mBase, protoCache,
268 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
269 : interfaceCache,
270 : sNativeProperties.Upcast(),
271 : nullptr,
272 : "CSSValue", aDefineOnGlobal,
273 : nullptr,
274 0 : false);
275 : }
276 :
277 : JS::Handle<JSObject*>
278 0 : GetProtoObjectHandle(JSContext* aCx)
279 : {
280 : /* Get the interface prototype object for this class. This will create the
281 : object as needed. */
282 0 : bool aDefineOnGlobal = true;
283 :
284 : /* Make sure our global is sane. Hopefully we can remove this sometime */
285 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
286 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
287 0 : return nullptr;
288 : }
289 :
290 : /* Check to see whether the interface objects are already installed */
291 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
292 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CSSValue)) {
293 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
294 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
295 : }
296 :
297 : /*
298 : * The object might _still_ be null, but that's OK.
299 : *
300 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
301 : * traced by TraceProtoAndIfaceCache() and its contents are never
302 : * changed after they have been set.
303 : *
304 : * Calling address() avoids the read read barrier that does gray
305 : * unmarking, but it's not possible for the object to be gray here.
306 : */
307 :
308 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CSSValue);
309 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
310 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
311 : }
312 :
313 : JSObject*
314 0 : GetProtoObject(JSContext* aCx)
315 : {
316 0 : return GetProtoObjectHandle(aCx);
317 : }
318 :
319 : JS::Handle<JSObject*>
320 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
321 : {
322 : /* Get the interface object for this class. This will create the object as
323 : needed. */
324 :
325 : /* Make sure our global is sane. Hopefully we can remove this sometime */
326 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
327 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
328 0 : return nullptr;
329 : }
330 :
331 : /* Check to see whether the interface objects are already installed */
332 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
333 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CSSValue)) {
334 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
335 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
336 : }
337 :
338 : /*
339 : * The object might _still_ be null, but that's OK.
340 : *
341 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
342 : * traced by TraceProtoAndIfaceCache() and its contents are never
343 : * changed after they have been set.
344 : *
345 : * Calling address() avoids the read read barrier that does gray
346 : * unmarking, but it's not possible for the object to be gray here.
347 : */
348 :
349 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CSSValue);
350 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
351 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
352 : }
353 :
354 : JSObject*
355 0 : GetConstructorObject(JSContext* aCx)
356 : {
357 0 : return GetConstructorObjectHandle(aCx);
358 : }
359 :
360 : } // namespace CSSValueBinding
361 :
362 :
363 :
364 : } // namespace dom
365 : } // namespace mozilla
|