/work/obj-fuzz/dist/include/mozilla/dom/IntersectionObserverBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM IntersectionObserver.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_IntersectionObserverBinding_h |
4 | | #define mozilla_dom_IntersectionObserverBinding_h |
5 | | |
6 | | #include "DOMRectBinding.h" |
7 | | #include "GeckoProfiler.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/Element.h" |
14 | | #include "mozilla/dom/FakeString.h" |
15 | | #include "mozilla/dom/Nullable.h" |
16 | | #include "mozilla/dom/PrototypeList.h" |
17 | | #include "mozilla/dom/ToJSValue.h" |
18 | | #include "mozilla/dom/UnionMember.h" |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | |
23 | | class DOMIntersectionObserver; |
24 | | struct DOMIntersectionObserverAtoms; |
25 | | class DOMIntersectionObserverEntry; |
26 | | struct DOMIntersectionObserverEntryAtoms; |
27 | | struct DOMRectInit; |
28 | | class DoubleOrDoubleSequence; |
29 | | class Element; |
30 | | class IntersectionCallback; |
31 | | struct IntersectionObserverEntryInitAtoms; |
32 | | struct IntersectionObserverInitAtoms; |
33 | | struct NativePropertyHooks; |
34 | | class OwningDoubleOrDoubleSequence; |
35 | | class ProtoAndIfaceCache; |
36 | | |
37 | | } // namespace dom |
38 | | } // namespace mozilla |
39 | | |
40 | | namespace mozilla { |
41 | | namespace dom { |
42 | | |
43 | | class DoubleOrDoubleSequence |
44 | | { |
45 | | friend class DoubleOrDoubleSequenceArgument; |
46 | | enum Type |
47 | | { |
48 | | eUninitialized, |
49 | | eDouble, |
50 | | eDoubleSequence |
51 | | }; |
52 | | |
53 | | union Value |
54 | | { |
55 | | UnionMember<double > mDouble; |
56 | | UnionMember<binding_detail::AutoSequence<double> > mDoubleSequence; |
57 | | |
58 | | }; |
59 | | |
60 | | Type mType; |
61 | | Value mValue; |
62 | | |
63 | | DoubleOrDoubleSequence(const DoubleOrDoubleSequence&) = delete; |
64 | | DoubleOrDoubleSequence& operator=(const DoubleOrDoubleSequence&) = delete; |
65 | | public: |
66 | | explicit inline DoubleOrDoubleSequence() |
67 | | : mType(eUninitialized) |
68 | 0 | { |
69 | 0 | } |
70 | | |
71 | | inline ~DoubleOrDoubleSequence() |
72 | 0 | { |
73 | 0 | Uninit(); |
74 | 0 | } |
75 | | |
76 | | inline double& |
77 | | RawSetAsDouble() |
78 | 0 | { |
79 | 0 | if (mType == eDouble) { |
80 | 0 | return mValue.mDouble.Value(); |
81 | 0 | } |
82 | 0 | MOZ_ASSERT(mType == eUninitialized); |
83 | 0 | mType = eDouble; |
84 | 0 | return mValue.mDouble.SetValue(); |
85 | 0 | } |
86 | | |
87 | | inline double& |
88 | | SetAsDouble() |
89 | 0 | { |
90 | 0 | if (mType == eDouble) { |
91 | 0 | return mValue.mDouble.Value(); |
92 | 0 | } |
93 | 0 | Uninit(); |
94 | 0 | mType = eDouble; |
95 | 0 | return mValue.mDouble.SetValue(); |
96 | 0 | } |
97 | | |
98 | | inline bool |
99 | | IsDouble() const |
100 | 0 | { |
101 | 0 | return mType == eDouble; |
102 | 0 | } |
103 | | |
104 | | inline double& |
105 | | GetAsDouble() |
106 | 0 | { |
107 | 0 | MOZ_ASSERT(IsDouble(), "Wrong type!"); |
108 | 0 | return mValue.mDouble.Value(); |
109 | 0 | } |
110 | | |
111 | | inline double |
112 | | GetAsDouble() const |
113 | 0 | { |
114 | 0 | MOZ_ASSERT(IsDouble(), "Wrong type!"); |
115 | 0 | return mValue.mDouble.Value(); |
116 | 0 | } |
117 | | |
118 | | inline binding_detail::AutoSequence<double>& |
119 | | RawSetAsDoubleSequence() |
120 | 0 | { |
121 | 0 | if (mType == eDoubleSequence) { |
122 | 0 | return mValue.mDoubleSequence.Value(); |
123 | 0 | } |
124 | 0 | MOZ_ASSERT(mType == eUninitialized); |
125 | 0 | mType = eDoubleSequence; |
126 | 0 | return mValue.mDoubleSequence.SetValue(); |
127 | 0 | } |
128 | | |
129 | | inline binding_detail::AutoSequence<double>& |
130 | | SetAsDoubleSequence() |
131 | 0 | { |
132 | 0 | if (mType == eDoubleSequence) { |
133 | 0 | return mValue.mDoubleSequence.Value(); |
134 | 0 | } |
135 | 0 | Uninit(); |
136 | 0 | mType = eDoubleSequence; |
137 | 0 | return mValue.mDoubleSequence.SetValue(); |
138 | 0 | } |
139 | | |
140 | | inline bool |
141 | | IsDoubleSequence() const |
142 | 0 | { |
143 | 0 | return mType == eDoubleSequence; |
144 | 0 | } |
145 | | |
146 | | inline binding_detail::AutoSequence<double>& |
147 | | GetAsDoubleSequence() |
148 | 0 | { |
149 | 0 | MOZ_ASSERT(IsDoubleSequence(), "Wrong type!"); |
150 | 0 | return mValue.mDoubleSequence.Value(); |
151 | 0 | } |
152 | | |
153 | | inline const Sequence<double>& |
154 | | GetAsDoubleSequence() const |
155 | 0 | { |
156 | 0 | MOZ_ASSERT(IsDoubleSequence(), "Wrong type!"); |
157 | 0 | return mValue.mDoubleSequence.Value(); |
158 | 0 | } |
159 | | |
160 | | inline void |
161 | | Uninit() |
162 | 0 | { |
163 | 0 | switch (mType) { |
164 | 0 | case eUninitialized: { |
165 | 0 | break; |
166 | 0 | } |
167 | 0 | case eDouble: { |
168 | 0 | DestroyDouble(); |
169 | 0 | break; |
170 | 0 | } |
171 | 0 | case eDoubleSequence: { |
172 | 0 | DestroyDoubleSequence(); |
173 | 0 | break; |
174 | 0 | } |
175 | 0 | } |
176 | 0 | } |
177 | | |
178 | | bool |
179 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
180 | | |
181 | | private: |
182 | | inline void |
183 | | DestroyDouble() |
184 | 0 | { |
185 | 0 | MOZ_ASSERT(IsDouble(), "Wrong type!"); |
186 | 0 | mValue.mDouble.Destroy(); |
187 | 0 | mType = eUninitialized; |
188 | 0 | } |
189 | | |
190 | | inline void |
191 | | DestroyDoubleSequence() |
192 | 0 | { |
193 | 0 | MOZ_ASSERT(IsDoubleSequence(), "Wrong type!"); |
194 | 0 | mValue.mDoubleSequence.Destroy(); |
195 | 0 | mType = eUninitialized; |
196 | 0 | } |
197 | | }; |
198 | | |
199 | | |
200 | | class OwningDoubleOrDoubleSequence : public AllOwningUnionBase |
201 | | { |
202 | | friend void ImplCycleCollectionUnlink(OwningDoubleOrDoubleSequence& aUnion); |
203 | | enum Type |
204 | | { |
205 | | eUninitialized, |
206 | | eDouble, |
207 | | eDoubleSequence |
208 | | }; |
209 | | |
210 | | union Value |
211 | | { |
212 | | UnionMember<double > mDouble; |
213 | | UnionMember<Sequence<double> > mDoubleSequence; |
214 | | |
215 | | }; |
216 | | |
217 | | Type mType; |
218 | | Value mValue; |
219 | | |
220 | | public: |
221 | | explicit inline OwningDoubleOrDoubleSequence() |
222 | | : mType(eUninitialized) |
223 | 0 | { |
224 | 0 | } |
225 | | |
226 | | explicit inline OwningDoubleOrDoubleSequence(const OwningDoubleOrDoubleSequence& aOther) |
227 | | : mType(eUninitialized) |
228 | 0 | { |
229 | 0 | *this = aOther; |
230 | 0 | } |
231 | | |
232 | | inline ~OwningDoubleOrDoubleSequence() |
233 | 0 | { |
234 | 0 | Uninit(); |
235 | 0 | } |
236 | | |
237 | | double& |
238 | | RawSetAsDouble(); |
239 | | |
240 | | double& |
241 | | SetAsDouble(); |
242 | | |
243 | | bool |
244 | | TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
245 | | |
246 | | inline bool |
247 | | IsDouble() const |
248 | 0 | { |
249 | 0 | return mType == eDouble; |
250 | 0 | } |
251 | | |
252 | | inline double& |
253 | | GetAsDouble() |
254 | 0 | { |
255 | 0 | MOZ_ASSERT(IsDouble(), "Wrong type!"); |
256 | 0 | return mValue.mDouble.Value(); |
257 | 0 | } |
258 | | |
259 | | inline double const & |
260 | | GetAsDouble() const |
261 | 0 | { |
262 | 0 | MOZ_ASSERT(IsDouble(), "Wrong type!"); |
263 | 0 | return mValue.mDouble.Value(); |
264 | 0 | } |
265 | | |
266 | | Sequence<double>& |
267 | | RawSetAsDoubleSequence(); |
268 | | |
269 | | Sequence<double>& |
270 | | SetAsDoubleSequence(); |
271 | | |
272 | | bool |
273 | | TrySetToDoubleSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
274 | | |
275 | | inline bool |
276 | | IsDoubleSequence() const |
277 | 0 | { |
278 | 0 | return mType == eDoubleSequence; |
279 | 0 | } |
280 | | |
281 | | inline Sequence<double>& |
282 | | GetAsDoubleSequence() |
283 | 0 | { |
284 | 0 | MOZ_ASSERT(IsDoubleSequence(), "Wrong type!"); |
285 | 0 | return mValue.mDoubleSequence.Value(); |
286 | 0 | } |
287 | | |
288 | | inline Sequence<double> const & |
289 | | GetAsDoubleSequence() const |
290 | 0 | { |
291 | 0 | MOZ_ASSERT(IsDoubleSequence(), "Wrong type!"); |
292 | 0 | return mValue.mDoubleSequence.Value(); |
293 | 0 | } |
294 | | |
295 | | void |
296 | | Uninit(); |
297 | | |
298 | | bool |
299 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
300 | | |
301 | | void |
302 | | TraceUnion(JSTracer* trc); |
303 | | |
304 | | OwningDoubleOrDoubleSequence& |
305 | | operator=(const OwningDoubleOrDoubleSequence& aOther); |
306 | | |
307 | | private: |
308 | | void |
309 | | DestroyDouble(); |
310 | | |
311 | | void |
312 | | DestroyDoubleSequence(); |
313 | | }; |
314 | | |
315 | | |
316 | | struct IntersectionObserverEntryInit : public DictionaryBase |
317 | | { |
318 | | MOZ_INIT_OUTSIDE_CTOR DOMRectInit mBoundingClientRect; |
319 | | MOZ_INIT_OUTSIDE_CTOR DOMRectInit mIntersectionRect; |
320 | | MOZ_INIT_OUTSIDE_CTOR DOMRectInit mRootBounds; |
321 | | MOZ_INIT_OUTSIDE_CTOR OwningNonNull<mozilla::dom::Element> mTarget; |
322 | | MOZ_INIT_OUTSIDE_CTOR double mTime; |
323 | | |
324 | | IntersectionObserverEntryInit(); |
325 | | |
326 | | explicit inline IntersectionObserverEntryInit(const FastDictionaryInitializer& ) |
327 | | : mBoundingClientRect(FastDictionaryInitializer()), |
328 | | mIntersectionRect(FastDictionaryInitializer()), |
329 | | mRootBounds(FastDictionaryInitializer()) |
330 | 0 | { |
331 | 0 | // Do nothing here; this is used by our "Fast" subclass |
332 | 0 | } |
333 | | |
334 | | explicit inline IntersectionObserverEntryInit(const IntersectionObserverEntryInit& aOther) |
335 | | : mBoundingClientRect(FastDictionaryInitializer()), |
336 | | mIntersectionRect(FastDictionaryInitializer()), |
337 | | mRootBounds(FastDictionaryInitializer()) |
338 | 0 | { |
339 | 0 | *this = aOther; |
340 | 0 | } |
341 | | |
342 | | bool |
343 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
344 | | |
345 | | bool |
346 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
347 | | |
348 | | void |
349 | | TraceDictionary(JSTracer* trc); |
350 | | |
351 | | inline void |
352 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
353 | 0 | { |
354 | 0 | ImplCycleCollectionTraverse(aCallback, mTarget, "mTarget", aFlags); |
355 | 0 | } |
356 | | |
357 | | inline void |
358 | | UnlinkForCC() |
359 | 0 | { |
360 | 0 | ImplCycleCollectionUnlink(mTarget); |
361 | 0 | } |
362 | | |
363 | | IntersectionObserverEntryInit& |
364 | | operator=(const IntersectionObserverEntryInit& aOther); |
365 | | |
366 | | private: |
367 | | static bool |
368 | | InitIds(JSContext* cx, IntersectionObserverEntryInitAtoms* atomsCache); |
369 | | }; |
370 | | |
371 | | namespace binding_detail { |
372 | | struct FastIntersectionObserverEntryInit : public IntersectionObserverEntryInit |
373 | | { |
374 | | inline FastIntersectionObserverEntryInit() |
375 | | : IntersectionObserverEntryInit(FastDictionaryInitializer()) |
376 | 0 | { |
377 | 0 | // Doesn't matter what int we pass to the parent constructor |
378 | 0 | } |
379 | | }; |
380 | | } // namespace binding_detail |
381 | | |
382 | | |
383 | | struct IntersectionObserverInit : public DictionaryBase |
384 | | { |
385 | | MOZ_INIT_OUTSIDE_CTOR RefPtr<mozilla::dom::Element> mRoot; |
386 | | MOZ_INIT_OUTSIDE_CTOR nsString mRootMargin; |
387 | | MOZ_INIT_OUTSIDE_CTOR OwningDoubleOrDoubleSequence mThreshold; |
388 | | |
389 | | IntersectionObserverInit(); |
390 | | |
391 | | explicit inline IntersectionObserverInit(const FastDictionaryInitializer& ) |
392 | 0 | { |
393 | 0 | // Do nothing here; this is used by our "Fast" subclass |
394 | 0 | } |
395 | | |
396 | | explicit inline IntersectionObserverInit(const IntersectionObserverInit& aOther) |
397 | 0 | { |
398 | 0 | *this = aOther; |
399 | 0 | } |
400 | | |
401 | | bool |
402 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
403 | | |
404 | | bool |
405 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
406 | | |
407 | | void |
408 | | TraceDictionary(JSTracer* trc); |
409 | | |
410 | | inline void |
411 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
412 | 0 | { |
413 | 0 | ImplCycleCollectionTraverse(aCallback, mRoot, "mRoot", aFlags); |
414 | 0 | } |
415 | | |
416 | | inline void |
417 | | UnlinkForCC() |
418 | 0 | { |
419 | 0 | ImplCycleCollectionUnlink(mRoot); |
420 | 0 | } |
421 | | |
422 | | IntersectionObserverInit& |
423 | | operator=(const IntersectionObserverInit& aOther); |
424 | | |
425 | | private: |
426 | | static bool |
427 | | InitIds(JSContext* cx, IntersectionObserverInitAtoms* atomsCache); |
428 | | }; |
429 | | |
430 | | namespace binding_detail { |
431 | | struct FastIntersectionObserverInit : public IntersectionObserverInit |
432 | | { |
433 | | inline FastIntersectionObserverInit() |
434 | | : IntersectionObserverInit(FastDictionaryInitializer()) |
435 | 0 | { |
436 | 0 | // Doesn't matter what int we pass to the parent constructor |
437 | 0 | } |
438 | | }; |
439 | | } // namespace binding_detail |
440 | | |
441 | | |
442 | | class IntersectionCallback : public CallbackFunction |
443 | | { |
444 | | public: |
445 | | explicit inline IntersectionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
446 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
447 | 0 | { |
448 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
449 | 0 | } |
450 | | |
451 | | explicit inline IntersectionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
452 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
453 | 0 | { |
454 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
455 | 0 | } |
456 | | |
457 | | explicit inline IntersectionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
458 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
459 | 0 | { |
460 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
461 | 0 | } |
462 | | |
463 | | explicit inline IntersectionCallback(CallbackFunction* aOther) |
464 | | : CallbackFunction(aOther) |
465 | 0 | { |
466 | 0 | } |
467 | | |
468 | | template <typename T> |
469 | | inline void |
470 | | Call(const T& thisVal, const Sequence<OwningNonNull<DOMIntersectionObserverEntry>>& entries, DOMIntersectionObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
471 | 0 | { |
472 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
473 | 0 | if (!aExecutionReason) { |
474 | 0 | aExecutionReason = "IntersectionCallback"; |
475 | 0 | } |
476 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
477 | 0 | if (!s.GetContext()) { |
478 | 0 | MOZ_ASSERT(aRv.Failed()); |
479 | 0 | return; |
480 | 0 | } |
481 | 0 | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
482 | 0 | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
483 | 0 | aRv.Throw(NS_ERROR_FAILURE); |
484 | 0 | return; |
485 | 0 | } |
486 | 0 | return Call(s.GetContext(), thisValJS, entries, observer, aRv); |
487 | 0 | } |
488 | | |
489 | | inline void |
490 | | Call(const Sequence<OwningNonNull<DOMIntersectionObserverEntry>>& entries, DOMIntersectionObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
491 | 0 | { |
492 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
493 | 0 | if (!aExecutionReason) { |
494 | 0 | aExecutionReason = "IntersectionCallback"; |
495 | 0 | } |
496 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
497 | 0 | if (!s.GetContext()) { |
498 | 0 | MOZ_ASSERT(aRv.Failed()); |
499 | 0 | return; |
500 | 0 | } |
501 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, entries, observer, aRv); |
502 | 0 | } |
503 | | |
504 | | template <typename T> |
505 | | inline void |
506 | | Call(const T& thisVal, const Sequence<OwningNonNull<DOMIntersectionObserverEntry>>& entries, DOMIntersectionObserver& observer, const char* aExecutionReason = nullptr) |
507 | 0 | { |
508 | 0 | return Call(thisVal, entries, observer, IgnoreErrors(), aExecutionReason); |
509 | 0 | } |
510 | | |
511 | | inline void |
512 | | Call(const Sequence<OwningNonNull<DOMIntersectionObserverEntry>>& entries, DOMIntersectionObserver& observer, const char* aExecutionReason = nullptr) |
513 | 0 | { |
514 | 0 | return Call(entries, observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
515 | 0 | } |
516 | | |
517 | | inline bool |
518 | | operator==(const IntersectionCallback& aOther) const |
519 | 0 | { |
520 | 0 | return CallbackFunction::operator==(aOther); |
521 | 0 | } |
522 | | |
523 | | private: |
524 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const Sequence<OwningNonNull<DOMIntersectionObserverEntry>>& entries, DOMIntersectionObserver& observer, ErrorResult& aRv); |
525 | | }; |
526 | | |
527 | | |
528 | | namespace binding_detail { |
529 | | class FastIntersectionCallback : public IntersectionCallback |
530 | | { |
531 | | public: |
532 | | explicit inline FastIntersectionCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
533 | | : IntersectionCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
534 | 0 | { |
535 | 0 | } |
536 | | |
537 | | inline void |
538 | | Trace(JSTracer* aTracer) |
539 | 0 | { |
540 | 0 | IntersectionCallback::Trace(aTracer); |
541 | 0 | } |
542 | | |
543 | | inline void |
544 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
545 | 0 | { |
546 | 0 | IntersectionCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
547 | 0 | } |
548 | | }; |
549 | | } // namespace binding_detail |
550 | | |
551 | | |
552 | | namespace IntersectionObserver_Binding { |
553 | | |
554 | | typedef mozilla::dom::DOMIntersectionObserver NativeType; |
555 | | |
556 | | bool |
557 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
558 | | |
559 | | const JSClass* |
560 | | GetJSClass(); |
561 | | |
562 | | bool |
563 | | Wrap(JSContext* aCx, mozilla::dom::DOMIntersectionObserver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
564 | | |
565 | | template <class T> |
566 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
567 | 0 | { |
568 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
569 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
570 | 0 | } |
571 | | |
572 | | // We declare this as an array so that retrieving a pointer to this |
573 | | // binding's property hooks only requires compile/link-time resolvable |
574 | | // address arithmetic. Declaring it as a pointer instead would require |
575 | | // doing a run-time load to fetch a pointer to this binding's property |
576 | | // hooks. And then structures which embedded a pointer to this structure |
577 | | // would require a run-time load for proper initialization, which would |
578 | | // then induce static constructors. Lots of static constructors. |
579 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
580 | | |
581 | | void |
582 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
583 | | |
584 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
585 | 0 | { |
586 | 0 | /* Get the interface prototype object for this class. This will create the |
587 | 0 | object as needed. */ |
588 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::IntersectionObserver, |
589 | 0 | &CreateInterfaceObjects, |
590 | 0 | /* aDefineOnGlobal = */ true); |
591 | 0 |
|
592 | 0 | } |
593 | | |
594 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
595 | 0 | { |
596 | 0 | /* Get the interface object for this class. This will create the object as |
597 | 0 | needed. */ |
598 | 0 |
|
599 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::IntersectionObserver, |
600 | 0 | &CreateInterfaceObjects, |
601 | 0 | aDefineOnGlobal); |
602 | 0 | } |
603 | | |
604 | | JSObject* |
605 | | GetConstructorObject(JSContext* aCx); |
606 | | |
607 | | } // namespace IntersectionObserver_Binding |
608 | | |
609 | | |
610 | | |
611 | | namespace IntersectionObserverEntry_Binding { |
612 | | |
613 | | typedef mozilla::dom::DOMIntersectionObserverEntry NativeType; |
614 | | |
615 | | bool |
616 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
617 | | |
618 | | const JSClass* |
619 | | GetJSClass(); |
620 | | |
621 | | bool |
622 | | Wrap(JSContext* aCx, mozilla::dom::DOMIntersectionObserverEntry* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
623 | | |
624 | | template <class T> |
625 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
626 | 0 | { |
627 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
628 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
629 | 0 | } |
630 | | |
631 | | // We declare this as an array so that retrieving a pointer to this |
632 | | // binding's property hooks only requires compile/link-time resolvable |
633 | | // address arithmetic. Declaring it as a pointer instead would require |
634 | | // doing a run-time load to fetch a pointer to this binding's property |
635 | | // hooks. And then structures which embedded a pointer to this structure |
636 | | // would require a run-time load for proper initialization, which would |
637 | | // then induce static constructors. Lots of static constructors. |
638 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
639 | | |
640 | | void |
641 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
642 | | |
643 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
644 | 0 | { |
645 | 0 | /* Get the interface prototype object for this class. This will create the |
646 | 0 | object as needed. */ |
647 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::IntersectionObserverEntry, |
648 | 0 | &CreateInterfaceObjects, |
649 | 0 | /* aDefineOnGlobal = */ true); |
650 | 0 |
|
651 | 0 | } |
652 | | |
653 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
654 | 0 | { |
655 | 0 | /* Get the interface object for this class. This will create the object as |
656 | 0 | needed. */ |
657 | 0 |
|
658 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::IntersectionObserverEntry, |
659 | 0 | &CreateInterfaceObjects, |
660 | 0 | aDefineOnGlobal); |
661 | 0 | } |
662 | | |
663 | | JSObject* |
664 | | GetConstructorObject(JSContext* aCx); |
665 | | |
666 | | } // namespace IntersectionObserverEntry_Binding |
667 | | |
668 | | |
669 | | |
670 | | } // namespace dom |
671 | | } // namespace mozilla |
672 | | |
673 | | #endif // mozilla_dom_IntersectionObserverBinding_h |