/work/obj-fuzz/dist/include/mozilla/dom/MutationObserverBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM MutationObserver.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_MutationObserverBinding_h |
4 | | #define mozilla_dom_MutationObserverBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "MutationObserverBinding.h" |
8 | | #include "js/RootingAPI.h" |
9 | | #include "jspubtd.h" |
10 | | #include "mozilla/ErrorResult.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/CallbackFunction.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrototypeList.h" |
15 | | #include "mozilla/dom/ToJSValue.h" |
16 | | #include "nsINode.h" |
17 | | |
18 | | class nsDOMMutationObserver; |
19 | | struct nsDOMMutationObserverAtoms; |
20 | | class nsDOMMutationRecord; |
21 | | struct nsDOMMutationRecordAtoms; |
22 | | class nsINode; |
23 | | |
24 | | namespace mozilla { |
25 | | namespace dom { |
26 | | |
27 | | class MutationCallback; |
28 | | struct MutationObserverInitAtoms; |
29 | | struct MutationObservingInfoAtoms; |
30 | | struct NativePropertyHooks; |
31 | | class ProtoAndIfaceCache; |
32 | | |
33 | | } // namespace dom |
34 | | } // namespace mozilla |
35 | | |
36 | | namespace mozilla { |
37 | | namespace dom { |
38 | | |
39 | | struct MutationObserverInit : public DictionaryBase |
40 | | { |
41 | | MOZ_INIT_OUTSIDE_CTOR bool mAnimations; |
42 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<nsString>> mAttributeFilter; |
43 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mAttributeOldValue; |
44 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mAttributes; |
45 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mCharacterData; |
46 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mCharacterDataOldValue; |
47 | | MOZ_INIT_OUTSIDE_CTOR bool mChildList; |
48 | | MOZ_INIT_OUTSIDE_CTOR bool mNativeAnonymousChildList; |
49 | | MOZ_INIT_OUTSIDE_CTOR bool mSubtree; |
50 | | |
51 | | MutationObserverInit(); |
52 | | |
53 | | explicit inline MutationObserverInit(const FastDictionaryInitializer& ) |
54 | 0 | { |
55 | 0 | // Do nothing here; this is used by our "Fast" subclass |
56 | 0 | } |
57 | | |
58 | | explicit inline MutationObserverInit(const MutationObserverInit& aOther) |
59 | 0 | { |
60 | 0 | *this = aOther; |
61 | 0 | } |
62 | | |
63 | | bool |
64 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
65 | | |
66 | | bool |
67 | | Init(const nsAString& aJSON); |
68 | | |
69 | | bool |
70 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
71 | | |
72 | | bool |
73 | | ToJSON(nsAString& aJSON) const; |
74 | | |
75 | | void |
76 | | TraceDictionary(JSTracer* trc); |
77 | | |
78 | | MutationObserverInit& |
79 | | operator=(const MutationObserverInit& aOther); |
80 | | |
81 | | private: |
82 | | static bool |
83 | | InitIds(JSContext* cx, MutationObserverInitAtoms* atomsCache); |
84 | | }; |
85 | | |
86 | | namespace binding_detail { |
87 | | struct FastMutationObserverInit : public MutationObserverInit |
88 | | { |
89 | | inline FastMutationObserverInit() |
90 | | : MutationObserverInit(FastDictionaryInitializer()) |
91 | 0 | { |
92 | 0 | // Doesn't matter what int we pass to the parent constructor |
93 | 0 | } |
94 | | }; |
95 | | } // namespace binding_detail |
96 | | |
97 | | |
98 | | struct MutationObservingInfo : public MutationObserverInit |
99 | | { |
100 | | MOZ_INIT_OUTSIDE_CTOR RefPtr<nsINode> mObservedNode; |
101 | | |
102 | | MutationObservingInfo(); |
103 | | |
104 | | explicit inline MutationObservingInfo(const FastDictionaryInitializer& ) |
105 | | : MutationObserverInit(FastDictionaryInitializer()) |
106 | 0 | { |
107 | 0 | // Do nothing here; this is used by our "Fast" subclass |
108 | 0 | } |
109 | | |
110 | | explicit inline MutationObservingInfo(const MutationObservingInfo& aOther) |
111 | 0 | { |
112 | 0 | *this = aOther; |
113 | 0 | } |
114 | | |
115 | | bool |
116 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
117 | | |
118 | | bool |
119 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
120 | | |
121 | | void |
122 | | TraceDictionary(JSTracer* trc); |
123 | | |
124 | | inline void |
125 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
126 | 0 | { |
127 | 0 | ImplCycleCollectionTraverse(aCallback, mObservedNode, "mObservedNode", aFlags); |
128 | 0 | } |
129 | | |
130 | | inline void |
131 | | UnlinkForCC() |
132 | 0 | { |
133 | 0 | ImplCycleCollectionUnlink(mObservedNode); |
134 | 0 | } |
135 | | |
136 | | MutationObservingInfo& |
137 | | operator=(const MutationObservingInfo& aOther); |
138 | | |
139 | | private: |
140 | | static bool |
141 | | InitIds(JSContext* cx, MutationObservingInfoAtoms* atomsCache); |
142 | | }; |
143 | | |
144 | | namespace binding_detail { |
145 | | struct FastMutationObservingInfo : public MutationObservingInfo |
146 | | { |
147 | | inline FastMutationObservingInfo() |
148 | | : MutationObservingInfo(FastDictionaryInitializer()) |
149 | 0 | { |
150 | 0 | // Doesn't matter what int we pass to the parent constructor |
151 | 0 | } |
152 | | }; |
153 | | } // namespace binding_detail |
154 | | |
155 | | |
156 | | class MutationCallback : public CallbackFunction |
157 | | { |
158 | | public: |
159 | | explicit inline MutationCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
160 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
161 | 0 | { |
162 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
163 | 0 | } |
164 | | |
165 | | explicit inline MutationCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
166 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
167 | 0 | { |
168 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
169 | 0 | } |
170 | | |
171 | | explicit inline MutationCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
172 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
173 | 0 | { |
174 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
175 | 0 | } |
176 | | |
177 | | explicit inline MutationCallback(CallbackFunction* aOther) |
178 | | : CallbackFunction(aOther) |
179 | 0 | { |
180 | 0 | } |
181 | | |
182 | | template <typename T> |
183 | | inline void |
184 | | Call(const T& thisVal, const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
185 | 0 | { |
186 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
187 | 0 | if (!aExecutionReason) { |
188 | 0 | aExecutionReason = "MutationCallback"; |
189 | 0 | } |
190 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
191 | 0 | if (!s.GetContext()) { |
192 | 0 | MOZ_ASSERT(aRv.Failed()); |
193 | 0 | return; |
194 | 0 | } |
195 | 0 | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
196 | 0 | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
197 | 0 | aRv.Throw(NS_ERROR_FAILURE); |
198 | 0 | return; |
199 | 0 | } |
200 | 0 | return Call(s.GetContext(), thisValJS, mutations, observer, aRv); |
201 | 0 | } |
202 | | |
203 | | inline void |
204 | | Call(const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
205 | 0 | { |
206 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
207 | 0 | if (!aExecutionReason) { |
208 | 0 | aExecutionReason = "MutationCallback"; |
209 | 0 | } |
210 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
211 | 0 | if (!s.GetContext()) { |
212 | 0 | MOZ_ASSERT(aRv.Failed()); |
213 | 0 | return; |
214 | 0 | } |
215 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, mutations, observer, aRv); |
216 | 0 | } |
217 | | |
218 | | template <typename T> |
219 | | inline void |
220 | | Call(const T& thisVal, const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, const char* aExecutionReason = nullptr) |
221 | 0 | { |
222 | 0 | return Call(thisVal, mutations, observer, IgnoreErrors(), aExecutionReason); |
223 | 0 | } |
224 | | |
225 | | inline void |
226 | | Call(const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, const char* aExecutionReason = nullptr) |
227 | 0 | { |
228 | 0 | return Call(mutations, observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
229 | 0 | } |
230 | | |
231 | | inline bool |
232 | | operator==(const MutationCallback& aOther) const |
233 | 0 | { |
234 | 0 | return CallbackFunction::operator==(aOther); |
235 | 0 | } |
236 | | |
237 | | private: |
238 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const Sequence<OwningNonNull<nsDOMMutationRecord>>& mutations, nsDOMMutationObserver& observer, ErrorResult& aRv); |
239 | | }; |
240 | | |
241 | | |
242 | | namespace binding_detail { |
243 | | class FastMutationCallback : public MutationCallback |
244 | | { |
245 | | public: |
246 | | explicit inline FastMutationCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
247 | | : MutationCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
248 | 0 | { |
249 | 0 | } |
250 | | |
251 | | inline void |
252 | | Trace(JSTracer* aTracer) |
253 | 0 | { |
254 | 0 | MutationCallback::Trace(aTracer); |
255 | 0 | } |
256 | | |
257 | | inline void |
258 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
259 | 0 | { |
260 | 0 | MutationCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
261 | 0 | } |
262 | | }; |
263 | | } // namespace binding_detail |
264 | | |
265 | | |
266 | | namespace MutationObserver_Binding { |
267 | | |
268 | | typedef nsDOMMutationObserver NativeType; |
269 | | |
270 | | const JSClass* |
271 | | GetJSClass(); |
272 | | |
273 | | bool |
274 | | Wrap(JSContext* aCx, nsDOMMutationObserver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
275 | | |
276 | | template <class T> |
277 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
278 | 0 | { |
279 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
280 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
281 | 0 | } |
282 | | |
283 | | // We declare this as an array so that retrieving a pointer to this |
284 | | // binding's property hooks only requires compile/link-time resolvable |
285 | | // address arithmetic. Declaring it as a pointer instead would require |
286 | | // doing a run-time load to fetch a pointer to this binding's property |
287 | | // hooks. And then structures which embedded a pointer to this structure |
288 | | // would require a run-time load for proper initialization, which would |
289 | | // then induce static constructors. Lots of static constructors. |
290 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
291 | | |
292 | | void |
293 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
294 | | |
295 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
296 | 0 | { |
297 | 0 | /* Get the interface prototype object for this class. This will create the |
298 | 0 | object as needed. */ |
299 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::MutationObserver, |
300 | 0 | &CreateInterfaceObjects, |
301 | 0 | /* aDefineOnGlobal = */ true); |
302 | 0 |
|
303 | 0 | } |
304 | | |
305 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
306 | 0 | { |
307 | 0 | /* Get the interface object for this class. This will create the object as |
308 | 0 | needed. */ |
309 | 0 |
|
310 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::MutationObserver, |
311 | 0 | &CreateInterfaceObjects, |
312 | 0 | aDefineOnGlobal); |
313 | 0 | } |
314 | | |
315 | | JSObject* |
316 | | GetConstructorObject(JSContext* aCx); |
317 | | |
318 | | } // namespace MutationObserver_Binding |
319 | | |
320 | | |
321 | | |
322 | | namespace MutationRecord_Binding { |
323 | | |
324 | | typedef nsDOMMutationRecord NativeType; |
325 | | |
326 | | const JSClass* |
327 | | GetJSClass(); |
328 | | |
329 | | bool |
330 | | Wrap(JSContext* aCx, nsDOMMutationRecord* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
331 | | |
332 | | template <class T> |
333 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
334 | 0 | { |
335 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
336 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
337 | 0 | } |
338 | | |
339 | | // We declare this as an array so that retrieving a pointer to this |
340 | | // binding's property hooks only requires compile/link-time resolvable |
341 | | // address arithmetic. Declaring it as a pointer instead would require |
342 | | // doing a run-time load to fetch a pointer to this binding's property |
343 | | // hooks. And then structures which embedded a pointer to this structure |
344 | | // would require a run-time load for proper initialization, which would |
345 | | // then induce static constructors. Lots of static constructors. |
346 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
347 | | |
348 | | void |
349 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
350 | | |
351 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
352 | 0 | { |
353 | 0 | /* Get the interface prototype object for this class. This will create the |
354 | 0 | object as needed. */ |
355 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::MutationRecord, |
356 | 0 | &CreateInterfaceObjects, |
357 | 0 | /* aDefineOnGlobal = */ true); |
358 | 0 |
|
359 | 0 | } |
360 | | |
361 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
362 | 0 | { |
363 | 0 | /* Get the interface object for this class. This will create the object as |
364 | 0 | needed. */ |
365 | 0 |
|
366 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::MutationRecord, |
367 | 0 | &CreateInterfaceObjects, |
368 | 0 | aDefineOnGlobal); |
369 | 0 | } |
370 | | |
371 | | JSObject* |
372 | | GetConstructorObject(JSContext* aCx); |
373 | | |
374 | | } // namespace MutationRecord_Binding |
375 | | |
376 | | |
377 | | |
378 | | } // namespace dom |
379 | | } // namespace mozilla |
380 | | |
381 | | #endif // mozilla_dom_MutationObserverBinding_h |