/work/obj-fuzz/dom/bindings/CSSBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM CSS.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "CSSBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/CSS.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 binding_detail {}; // Just to make sure it's known as a namespace |
17 | | using namespace mozilla::dom::binding_detail; |
18 | | |
19 | | |
20 | | namespace CSS_Binding { |
21 | | |
22 | | static bool |
23 | | supports(JSContext* cx, unsigned argc, JS::Value* vp) |
24 | 0 | { |
25 | 0 | AUTO_PROFILER_LABEL_FAST("CSS.supports", DOM, cx); |
26 | 0 |
|
27 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
28 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
29 | 0 |
|
30 | 0 | unsigned argcount = std::min(args.length(), 2u); |
31 | 0 | switch (argcount) { |
32 | 0 | case 1: { |
33 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
34 | 0 | if (global.Failed()) { |
35 | 0 | return false; |
36 | 0 | } |
37 | 0 | |
38 | 0 | binding_detail::FakeString arg0; |
39 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
40 | 0 | return false; |
41 | 0 | } |
42 | 0 | FastErrorResult rv; |
43 | 0 | bool result(mozilla::dom::CSS::Supports(global, NonNullHelper(Constify(arg0)), rv)); |
44 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
48 | 0 | args.rval().setBoolean(result); |
49 | 0 | return true; |
50 | 0 | break; |
51 | 0 | } |
52 | 0 | case 2: { |
53 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
54 | 0 | if (global.Failed()) { |
55 | 0 | return false; |
56 | 0 | } |
57 | 0 | |
58 | 0 | binding_detail::FakeString arg0; |
59 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
60 | 0 | return false; |
61 | 0 | } |
62 | 0 | binding_detail::FakeString arg1; |
63 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
64 | 0 | return false; |
65 | 0 | } |
66 | 0 | FastErrorResult rv; |
67 | 0 | bool result(mozilla::dom::CSS::Supports(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)); |
68 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
69 | 0 | return false; |
70 | 0 | } |
71 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
72 | 0 | args.rval().setBoolean(result); |
73 | 0 | return true; |
74 | 0 | break; |
75 | 0 | } |
76 | 0 | default: { |
77 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CSS.supports"); |
78 | 0 | break; |
79 | 0 | } |
80 | 0 | } |
81 | 0 | MOZ_CRASH("We have an always-returning default case"); |
82 | 0 | return false; |
83 | 0 | } |
84 | | |
85 | | static bool |
86 | | escape(JSContext* cx, unsigned argc, JS::Value* vp) |
87 | 0 | { |
88 | 0 | AUTO_PROFILER_LABEL_FAST("CSS.escape", DOM, cx); |
89 | 0 |
|
90 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
91 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
92 | 0 |
|
93 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
94 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CSS.escape"); |
95 | 0 | } |
96 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
97 | 0 | if (global.Failed()) { |
98 | 0 | return false; |
99 | 0 | } |
100 | 0 | |
101 | 0 | binding_detail::FakeString arg0; |
102 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
103 | 0 | return false; |
104 | 0 | } |
105 | 0 | DOMString result; |
106 | 0 | mozilla::dom::CSS::Escape(global, NonNullHelper(Constify(arg0)), result); |
107 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
108 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
109 | 0 | return false; |
110 | 0 | } |
111 | 0 | return true; |
112 | 0 | } |
113 | | |
114 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
115 | | #if defined(__clang__) |
116 | | #pragma clang diagnostic push |
117 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
118 | | #endif |
119 | | static const JSFunctionSpec sStaticMethods_specs[] = { |
120 | | JS_FNSPEC("supports", supports, nullptr, 1, JSPROP_ENUMERATE, nullptr), |
121 | | JS_FNSPEC("escape", escape, nullptr, 1, JSPROP_ENUMERATE, nullptr), |
122 | | JS_FS_END |
123 | | }; |
124 | | #if defined(__clang__) |
125 | | #pragma clang diagnostic pop |
126 | | #endif |
127 | | |
128 | | |
129 | | static const Prefable<const JSFunctionSpec> sStaticMethods[] = { |
130 | | { nullptr, &sStaticMethods_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 | | |
140 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
141 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
142 | | |
143 | | static const NativePropertiesN<1> sNativeProperties = { |
144 | | true, 0 /* sStaticMethods */, |
145 | | false, 0, |
146 | | false, 0, |
147 | | false, 0, |
148 | | false, 0, |
149 | | false, 0, |
150 | | false, 0, |
151 | | -1, |
152 | | 2, |
153 | | sNativeProperties_sortedPropertyIndices, |
154 | | { |
155 | | { sStaticMethods, &sNativeProperties_propertyInfos[0] } |
156 | | } |
157 | | }; |
158 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
159 | | "We have a property info count that is oversized"); |
160 | | |
161 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
162 | | { |
163 | | "Object", |
164 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
165 | | JS_NULL_CLASS_OPS, |
166 | | JS_NULL_CLASS_SPEC, |
167 | | JS_NULL_CLASS_EXT, |
168 | | JS_NULL_OBJECT_OPS |
169 | | }, |
170 | | eInterface, |
171 | | false, |
172 | | prototypes::id::_ID_Count, |
173 | | 0, |
174 | | sNativePropertyHooks, |
175 | | "[object Object]", |
176 | | JS::GetRealmObjectPrototype |
177 | | }; |
178 | | |
179 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
180 | | nullptr, |
181 | | nullptr, |
182 | | nullptr, |
183 | | { sNativeProperties.Upcast(), nullptr }, |
184 | | prototypes::id::_ID_Count, |
185 | | constructors::id::CSS, |
186 | | nullptr, |
187 | | &DefaultXrayExpandoObjectClass |
188 | | } }; |
189 | | |
190 | | void |
191 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
192 | 0 | { |
193 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
194 | 0 | if (!constructorProto) { |
195 | 0 | return; |
196 | 0 | } |
197 | 0 | |
198 | 0 | static bool sIdsInited = false; |
199 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
200 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
201 | 0 | return; |
202 | 0 | } |
203 | 0 | sIdsInited = true; |
204 | 0 | } |
205 | 0 |
|
206 | 0 | JS::Heap<JSObject*>* protoCache = nullptr; |
207 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSS); |
208 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, nullptr, |
209 | 0 | nullptr, protoCache, |
210 | 0 | nullptr, |
211 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
212 | 0 | interfaceCache, |
213 | 0 | sNativeProperties.Upcast(), |
214 | 0 | nullptr, |
215 | 0 | "CSS", aDefineOnGlobal, |
216 | 0 | nullptr, |
217 | 0 | false); |
218 | 0 | } |
219 | | |
220 | | JSObject* |
221 | | GetConstructorObject(JSContext* aCx) |
222 | 0 | { |
223 | 0 | return GetConstructorObjectHandle(aCx); |
224 | 0 | } |
225 | | |
226 | | } // namespace CSS_Binding |
227 | | |
228 | | |
229 | | |
230 | | } // namespace dom |
231 | | } // namespace mozilla |