/work/obj-fuzz/dist/include/mozilla/dom/WebExtensionContentScriptBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM WebExtensionContentScript.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_WebExtensionContentScriptBinding_h |
4 | | #define mozilla_dom_WebExtensionContentScriptBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "WebExtensionContentScriptBinding.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/FakeString.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrototypeList.h" |
15 | | #include "mozilla/dom/UnionMember.h" |
16 | | |
17 | | namespace mozilla { |
18 | | |
19 | | namespace dom { |
20 | | |
21 | | class MatchGlobOrString; |
22 | | class MatchPatternSetOrStringSequence; |
23 | | struct MozDocumentMatcherInitAtoms; |
24 | | struct NativePropertyHooks; |
25 | | class OwningMatchGlobOrString; |
26 | | class OwningMatchPatternSetOrStringSequence; |
27 | | class ProtoAndIfaceCache; |
28 | | struct WebExtensionContentScriptInitAtoms; |
29 | | |
30 | | } // namespace dom |
31 | | |
32 | | namespace extensions { |
33 | | |
34 | | class MatchGlob; |
35 | | class MatchPatternSet; |
36 | | class MozDocumentMatcher; |
37 | | struct MozDocumentMatcherAtoms; |
38 | | class WebExtensionContentScript; |
39 | | struct WebExtensionContentScriptAtoms; |
40 | | |
41 | | } // namespace extensions |
42 | | |
43 | | } // namespace mozilla |
44 | | |
45 | | namespace mozilla { |
46 | | namespace dom { |
47 | | |
48 | | enum class ContentScriptRunAt : uint8_t { |
49 | | Document_start, |
50 | | Document_end, |
51 | | Document_idle, |
52 | | EndGuard_ |
53 | | }; |
54 | | |
55 | | namespace ContentScriptRunAtValues { |
56 | | extern const EnumEntry strings[4]; |
57 | | } // namespace ContentScriptRunAtValues |
58 | | |
59 | | bool |
60 | | ToJSValue(JSContext* aCx, ContentScriptRunAt aArgument, JS::MutableHandle<JS::Value> aValue); |
61 | | |
62 | | |
63 | | void |
64 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningMatchGlobOrString& aUnion, const char* aName, uint32_t aFlags = 0); |
65 | | |
66 | | |
67 | | void |
68 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningMatchPatternSetOrStringSequence& aUnion, const char* aName, uint32_t aFlags = 0); |
69 | | |
70 | | |
71 | | void |
72 | | ImplCycleCollectionUnlink(OwningMatchGlobOrString& aUnion); |
73 | | |
74 | | |
75 | | void |
76 | | ImplCycleCollectionUnlink(OwningMatchPatternSetOrStringSequence& aUnion); |
77 | | |
78 | | |
79 | | class MatchGlobOrString |
80 | | { |
81 | | friend class MatchGlobOrStringArgument; |
82 | | enum Type |
83 | | { |
84 | | eUninitialized, |
85 | | eMatchGlob, |
86 | | eString |
87 | | }; |
88 | | |
89 | | union Value |
90 | | { |
91 | | UnionMember<NonNull<mozilla::extensions::MatchGlob> > mMatchGlob; |
92 | | UnionMember<binding_detail::FakeString > mString; |
93 | | |
94 | | }; |
95 | | |
96 | | Type mType; |
97 | | Value mValue; |
98 | | |
99 | | MatchGlobOrString(const MatchGlobOrString&) = delete; |
100 | | MatchGlobOrString& operator=(const MatchGlobOrString&) = delete; |
101 | | public: |
102 | | explicit inline MatchGlobOrString() |
103 | | : mType(eUninitialized) |
104 | 0 | { |
105 | 0 | } |
106 | | |
107 | | inline ~MatchGlobOrString() |
108 | 0 | { |
109 | 0 | Uninit(); |
110 | 0 | } |
111 | | |
112 | | inline NonNull<mozilla::extensions::MatchGlob>& |
113 | | RawSetAsMatchGlob() |
114 | 0 | { |
115 | 0 | if (mType == eMatchGlob) { |
116 | 0 | return mValue.mMatchGlob.Value(); |
117 | 0 | } |
118 | 0 | MOZ_ASSERT(mType == eUninitialized); |
119 | 0 | mType = eMatchGlob; |
120 | 0 | return mValue.mMatchGlob.SetValue(); |
121 | 0 | } |
122 | | |
123 | | inline NonNull<mozilla::extensions::MatchGlob>& |
124 | | SetAsMatchGlob() |
125 | 0 | { |
126 | 0 | if (mType == eMatchGlob) { |
127 | 0 | return mValue.mMatchGlob.Value(); |
128 | 0 | } |
129 | 0 | Uninit(); |
130 | 0 | mType = eMatchGlob; |
131 | 0 | return mValue.mMatchGlob.SetValue(); |
132 | 0 | } |
133 | | |
134 | | inline bool |
135 | | IsMatchGlob() const |
136 | 0 | { |
137 | 0 | return mType == eMatchGlob; |
138 | 0 | } |
139 | | |
140 | | inline NonNull<mozilla::extensions::MatchGlob>& |
141 | | GetAsMatchGlob() |
142 | 0 | { |
143 | 0 | MOZ_ASSERT(IsMatchGlob(), "Wrong type!"); |
144 | 0 | return mValue.mMatchGlob.Value(); |
145 | 0 | } |
146 | | |
147 | | inline mozilla::extensions::MatchGlob& |
148 | | GetAsMatchGlob() const |
149 | 0 | { |
150 | 0 | MOZ_ASSERT(IsMatchGlob(), "Wrong type!"); |
151 | 0 | return mValue.mMatchGlob.Value(); |
152 | 0 | } |
153 | | |
154 | | inline binding_detail::FakeString& |
155 | | RawSetAsString() |
156 | 0 | { |
157 | 0 | if (mType == eString) { |
158 | 0 | return mValue.mString.Value(); |
159 | 0 | } |
160 | 0 | MOZ_ASSERT(mType == eUninitialized); |
161 | 0 | mType = eString; |
162 | 0 | return mValue.mString.SetValue(); |
163 | 0 | } |
164 | | |
165 | | inline binding_detail::FakeString& |
166 | | SetAsString() |
167 | 0 | { |
168 | 0 | if (mType == eString) { |
169 | 0 | return mValue.mString.Value(); |
170 | 0 | } |
171 | 0 | Uninit(); |
172 | 0 | mType = eString; |
173 | 0 | return mValue.mString.SetValue(); |
174 | 0 | } |
175 | | |
176 | | inline bool |
177 | | IsString() const |
178 | 0 | { |
179 | 0 | return mType == eString; |
180 | 0 | } |
181 | | |
182 | | inline binding_detail::FakeString& |
183 | | GetAsString() |
184 | 0 | { |
185 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
186 | 0 | return mValue.mString.Value(); |
187 | 0 | } |
188 | | |
189 | | inline const nsAString& |
190 | | GetAsString() const |
191 | 0 | { |
192 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
193 | 0 | return mValue.mString.Value(); |
194 | 0 | } |
195 | | |
196 | | inline void |
197 | | Uninit() |
198 | 0 | { |
199 | 0 | switch (mType) { |
200 | 0 | case eUninitialized: { |
201 | 0 | break; |
202 | 0 | } |
203 | 0 | case eMatchGlob: { |
204 | 0 | DestroyMatchGlob(); |
205 | 0 | break; |
206 | 0 | } |
207 | 0 | case eString: { |
208 | 0 | DestroyString(); |
209 | 0 | break; |
210 | 0 | } |
211 | 0 | } |
212 | 0 | } |
213 | | |
214 | | bool |
215 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
216 | | |
217 | | private: |
218 | | inline void |
219 | | DestroyMatchGlob() |
220 | 0 | { |
221 | 0 | MOZ_ASSERT(IsMatchGlob(), "Wrong type!"); |
222 | 0 | mValue.mMatchGlob.Destroy(); |
223 | 0 | mType = eUninitialized; |
224 | 0 | } |
225 | | |
226 | | inline void |
227 | | DestroyString() |
228 | 0 | { |
229 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
230 | 0 | mValue.mString.Destroy(); |
231 | 0 | mType = eUninitialized; |
232 | 0 | } |
233 | | }; |
234 | | |
235 | | |
236 | | class OwningMatchGlobOrString : public AllOwningUnionBase |
237 | | { |
238 | | friend void ImplCycleCollectionUnlink(OwningMatchGlobOrString& aUnion); |
239 | | enum Type |
240 | | { |
241 | | eUninitialized, |
242 | | eMatchGlob, |
243 | | eString |
244 | | }; |
245 | | |
246 | | union Value |
247 | | { |
248 | | UnionMember<OwningNonNull<mozilla::extensions::MatchGlob> > mMatchGlob; |
249 | | UnionMember<nsString > mString; |
250 | | |
251 | | }; |
252 | | |
253 | | Type mType; |
254 | | Value mValue; |
255 | | |
256 | | public: |
257 | | explicit inline OwningMatchGlobOrString() |
258 | | : mType(eUninitialized) |
259 | 0 | { |
260 | 0 | } |
261 | | |
262 | | explicit inline OwningMatchGlobOrString(const OwningMatchGlobOrString& aOther) |
263 | | : mType(eUninitialized) |
264 | 0 | { |
265 | 0 | *this = aOther; |
266 | 0 | } |
267 | | |
268 | | inline ~OwningMatchGlobOrString() |
269 | 0 | { |
270 | 0 | Uninit(); |
271 | 0 | } |
272 | | |
273 | | OwningNonNull<mozilla::extensions::MatchGlob>& |
274 | | RawSetAsMatchGlob(); |
275 | | |
276 | | OwningNonNull<mozilla::extensions::MatchGlob>& |
277 | | SetAsMatchGlob(); |
278 | | |
279 | | bool |
280 | | TrySetToMatchGlob(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
281 | | |
282 | | inline bool |
283 | | IsMatchGlob() const |
284 | 0 | { |
285 | 0 | return mType == eMatchGlob; |
286 | 0 | } |
287 | | |
288 | | inline OwningNonNull<mozilla::extensions::MatchGlob>& |
289 | | GetAsMatchGlob() |
290 | 0 | { |
291 | 0 | MOZ_ASSERT(IsMatchGlob(), "Wrong type!"); |
292 | 0 | return mValue.mMatchGlob.Value(); |
293 | 0 | } |
294 | | |
295 | | inline OwningNonNull<mozilla::extensions::MatchGlob> const & |
296 | | GetAsMatchGlob() const |
297 | 0 | { |
298 | 0 | MOZ_ASSERT(IsMatchGlob(), "Wrong type!"); |
299 | 0 | return mValue.mMatchGlob.Value(); |
300 | 0 | } |
301 | | |
302 | | nsString& |
303 | | RawSetAsString(); |
304 | | |
305 | | nsString& |
306 | | SetAsString(); |
307 | | |
308 | | bool |
309 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
310 | | |
311 | | inline void |
312 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
313 | 0 | { |
314 | 0 | RawSetAsString().Assign(aData, aLength); |
315 | 0 | } |
316 | | |
317 | | inline bool |
318 | | IsString() const |
319 | 0 | { |
320 | 0 | return mType == eString; |
321 | 0 | } |
322 | | |
323 | | inline nsString& |
324 | | GetAsString() |
325 | 0 | { |
326 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
327 | 0 | return mValue.mString.Value(); |
328 | 0 | } |
329 | | |
330 | | inline nsString const & |
331 | | GetAsString() const |
332 | 0 | { |
333 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
334 | 0 | return mValue.mString.Value(); |
335 | 0 | } |
336 | | |
337 | | void |
338 | | Uninit(); |
339 | | |
340 | | bool |
341 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
342 | | |
343 | | void |
344 | | TraceUnion(JSTracer* trc); |
345 | | |
346 | | OwningMatchGlobOrString& |
347 | | operator=(const OwningMatchGlobOrString& aOther); |
348 | | |
349 | | private: |
350 | | void |
351 | | DestroyMatchGlob(); |
352 | | |
353 | | void |
354 | | DestroyString(); |
355 | | }; |
356 | | |
357 | | |
358 | | class MatchPatternSetOrStringSequence |
359 | | { |
360 | | friend class MatchPatternSetOrStringSequenceArgument; |
361 | | enum Type |
362 | | { |
363 | | eUninitialized, |
364 | | eMatchPatternSet, |
365 | | eStringSequence |
366 | | }; |
367 | | |
368 | | union Value |
369 | | { |
370 | | UnionMember<NonNull<mozilla::extensions::MatchPatternSet> > mMatchPatternSet; |
371 | | UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence; |
372 | | |
373 | | }; |
374 | | |
375 | | Type mType; |
376 | | Value mValue; |
377 | | |
378 | | MatchPatternSetOrStringSequence(const MatchPatternSetOrStringSequence&) = delete; |
379 | | MatchPatternSetOrStringSequence& operator=(const MatchPatternSetOrStringSequence&) = delete; |
380 | | public: |
381 | | explicit inline MatchPatternSetOrStringSequence() |
382 | | : mType(eUninitialized) |
383 | 0 | { |
384 | 0 | } |
385 | | |
386 | | inline ~MatchPatternSetOrStringSequence() |
387 | 0 | { |
388 | 0 | Uninit(); |
389 | 0 | } |
390 | | |
391 | | inline NonNull<mozilla::extensions::MatchPatternSet>& |
392 | | RawSetAsMatchPatternSet() |
393 | 0 | { |
394 | 0 | if (mType == eMatchPatternSet) { |
395 | 0 | return mValue.mMatchPatternSet.Value(); |
396 | 0 | } |
397 | 0 | MOZ_ASSERT(mType == eUninitialized); |
398 | 0 | mType = eMatchPatternSet; |
399 | 0 | return mValue.mMatchPatternSet.SetValue(); |
400 | 0 | } |
401 | | |
402 | | inline NonNull<mozilla::extensions::MatchPatternSet>& |
403 | | SetAsMatchPatternSet() |
404 | 0 | { |
405 | 0 | if (mType == eMatchPatternSet) { |
406 | 0 | return mValue.mMatchPatternSet.Value(); |
407 | 0 | } |
408 | 0 | Uninit(); |
409 | 0 | mType = eMatchPatternSet; |
410 | 0 | return mValue.mMatchPatternSet.SetValue(); |
411 | 0 | } |
412 | | |
413 | | inline bool |
414 | | IsMatchPatternSet() const |
415 | 0 | { |
416 | 0 | return mType == eMatchPatternSet; |
417 | 0 | } |
418 | | |
419 | | inline NonNull<mozilla::extensions::MatchPatternSet>& |
420 | | GetAsMatchPatternSet() |
421 | 0 | { |
422 | 0 | MOZ_ASSERT(IsMatchPatternSet(), "Wrong type!"); |
423 | 0 | return mValue.mMatchPatternSet.Value(); |
424 | 0 | } |
425 | | |
426 | | inline mozilla::extensions::MatchPatternSet& |
427 | | GetAsMatchPatternSet() const |
428 | 0 | { |
429 | 0 | MOZ_ASSERT(IsMatchPatternSet(), "Wrong type!"); |
430 | 0 | return mValue.mMatchPatternSet.Value(); |
431 | 0 | } |
432 | | |
433 | | inline binding_detail::AutoSequence<nsString>& |
434 | | RawSetAsStringSequence() |
435 | 0 | { |
436 | 0 | if (mType == eStringSequence) { |
437 | 0 | return mValue.mStringSequence.Value(); |
438 | 0 | } |
439 | 0 | MOZ_ASSERT(mType == eUninitialized); |
440 | 0 | mType = eStringSequence; |
441 | 0 | return mValue.mStringSequence.SetValue(); |
442 | 0 | } |
443 | | |
444 | | inline binding_detail::AutoSequence<nsString>& |
445 | | SetAsStringSequence() |
446 | 0 | { |
447 | 0 | if (mType == eStringSequence) { |
448 | 0 | return mValue.mStringSequence.Value(); |
449 | 0 | } |
450 | 0 | Uninit(); |
451 | 0 | mType = eStringSequence; |
452 | 0 | return mValue.mStringSequence.SetValue(); |
453 | 0 | } |
454 | | |
455 | | inline bool |
456 | | IsStringSequence() const |
457 | 0 | { |
458 | 0 | return mType == eStringSequence; |
459 | 0 | } |
460 | | |
461 | | inline binding_detail::AutoSequence<nsString>& |
462 | | GetAsStringSequence() |
463 | 0 | { |
464 | 0 | MOZ_ASSERT(IsStringSequence(), "Wrong type!"); |
465 | 0 | return mValue.mStringSequence.Value(); |
466 | 0 | } |
467 | | |
468 | | inline const Sequence<nsString>& |
469 | | GetAsStringSequence() const |
470 | 0 | { |
471 | 0 | MOZ_ASSERT(IsStringSequence(), "Wrong type!"); |
472 | 0 | return mValue.mStringSequence.Value(); |
473 | 0 | } |
474 | | |
475 | | inline void |
476 | | Uninit() |
477 | 0 | { |
478 | 0 | switch (mType) { |
479 | 0 | case eUninitialized: { |
480 | 0 | break; |
481 | 0 | } |
482 | 0 | case eMatchPatternSet: { |
483 | 0 | DestroyMatchPatternSet(); |
484 | 0 | break; |
485 | 0 | } |
486 | 0 | case eStringSequence: { |
487 | 0 | DestroyStringSequence(); |
488 | 0 | break; |
489 | 0 | } |
490 | 0 | } |
491 | 0 | } |
492 | | |
493 | | bool |
494 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
495 | | |
496 | | private: |
497 | | inline void |
498 | | DestroyMatchPatternSet() |
499 | 0 | { |
500 | 0 | MOZ_ASSERT(IsMatchPatternSet(), "Wrong type!"); |
501 | 0 | mValue.mMatchPatternSet.Destroy(); |
502 | 0 | mType = eUninitialized; |
503 | 0 | } |
504 | | |
505 | | inline void |
506 | | DestroyStringSequence() |
507 | 0 | { |
508 | 0 | MOZ_ASSERT(IsStringSequence(), "Wrong type!"); |
509 | 0 | mValue.mStringSequence.Destroy(); |
510 | 0 | mType = eUninitialized; |
511 | 0 | } |
512 | | }; |
513 | | |
514 | | |
515 | | class OwningMatchPatternSetOrStringSequence : public AllOwningUnionBase |
516 | | { |
517 | | friend void ImplCycleCollectionUnlink(OwningMatchPatternSetOrStringSequence& aUnion); |
518 | | enum Type |
519 | | { |
520 | | eUninitialized, |
521 | | eMatchPatternSet, |
522 | | eStringSequence |
523 | | }; |
524 | | |
525 | | union Value |
526 | | { |
527 | | UnionMember<OwningNonNull<mozilla::extensions::MatchPatternSet> > mMatchPatternSet; |
528 | | UnionMember<Sequence<nsString> > mStringSequence; |
529 | | |
530 | | }; |
531 | | |
532 | | Type mType; |
533 | | Value mValue; |
534 | | |
535 | | public: |
536 | | explicit inline OwningMatchPatternSetOrStringSequence() |
537 | | : mType(eUninitialized) |
538 | 0 | { |
539 | 0 | } |
540 | | |
541 | | explicit inline OwningMatchPatternSetOrStringSequence(const OwningMatchPatternSetOrStringSequence& aOther) |
542 | | : mType(eUninitialized) |
543 | 0 | { |
544 | 0 | *this = aOther; |
545 | 0 | } |
546 | | |
547 | | inline ~OwningMatchPatternSetOrStringSequence() |
548 | 0 | { |
549 | 0 | Uninit(); |
550 | 0 | } |
551 | | |
552 | | OwningNonNull<mozilla::extensions::MatchPatternSet>& |
553 | | RawSetAsMatchPatternSet(); |
554 | | |
555 | | OwningNonNull<mozilla::extensions::MatchPatternSet>& |
556 | | SetAsMatchPatternSet(); |
557 | | |
558 | | bool |
559 | | TrySetToMatchPatternSet(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
560 | | |
561 | | inline bool |
562 | | IsMatchPatternSet() const |
563 | 0 | { |
564 | 0 | return mType == eMatchPatternSet; |
565 | 0 | } |
566 | | |
567 | | inline OwningNonNull<mozilla::extensions::MatchPatternSet>& |
568 | | GetAsMatchPatternSet() |
569 | 0 | { |
570 | 0 | MOZ_ASSERT(IsMatchPatternSet(), "Wrong type!"); |
571 | 0 | return mValue.mMatchPatternSet.Value(); |
572 | 0 | } |
573 | | |
574 | | inline OwningNonNull<mozilla::extensions::MatchPatternSet> const & |
575 | | GetAsMatchPatternSet() const |
576 | 0 | { |
577 | 0 | MOZ_ASSERT(IsMatchPatternSet(), "Wrong type!"); |
578 | 0 | return mValue.mMatchPatternSet.Value(); |
579 | 0 | } |
580 | | |
581 | | Sequence<nsString>& |
582 | | RawSetAsStringSequence(); |
583 | | |
584 | | Sequence<nsString>& |
585 | | SetAsStringSequence(); |
586 | | |
587 | | bool |
588 | | TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
589 | | |
590 | | inline bool |
591 | | IsStringSequence() const |
592 | 0 | { |
593 | 0 | return mType == eStringSequence; |
594 | 0 | } |
595 | | |
596 | | inline Sequence<nsString>& |
597 | | GetAsStringSequence() |
598 | 0 | { |
599 | 0 | MOZ_ASSERT(IsStringSequence(), "Wrong type!"); |
600 | 0 | return mValue.mStringSequence.Value(); |
601 | 0 | } |
602 | | |
603 | | inline Sequence<nsString> const & |
604 | | GetAsStringSequence() const |
605 | 0 | { |
606 | 0 | MOZ_ASSERT(IsStringSequence(), "Wrong type!"); |
607 | 0 | return mValue.mStringSequence.Value(); |
608 | 0 | } |
609 | | |
610 | | void |
611 | | Uninit(); |
612 | | |
613 | | bool |
614 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
615 | | |
616 | | void |
617 | | TraceUnion(JSTracer* trc); |
618 | | |
619 | | OwningMatchPatternSetOrStringSequence& |
620 | | operator=(const OwningMatchPatternSetOrStringSequence& aOther); |
621 | | |
622 | | private: |
623 | | void |
624 | | DestroyMatchPatternSet(); |
625 | | |
626 | | void |
627 | | DestroyStringSequence(); |
628 | | }; |
629 | | |
630 | | |
631 | | struct MozDocumentMatcherInit : public DictionaryBase |
632 | | { |
633 | | MOZ_INIT_OUTSIDE_CTOR bool mAllFrames; |
634 | | MOZ_INIT_OUTSIDE_CTOR Nullable<Sequence<OwningMatchGlobOrString>> mExcludeGlobs; |
635 | | MOZ_INIT_OUTSIDE_CTOR Nullable<OwningMatchPatternSetOrStringSequence > mExcludeMatches; |
636 | | MOZ_INIT_OUTSIDE_CTOR Nullable<uint64_t> mFrameID; |
637 | | MOZ_INIT_OUTSIDE_CTOR bool mHasActiveTabPermission; |
638 | | MOZ_INIT_OUTSIDE_CTOR Nullable<Sequence<OwningMatchGlobOrString>> mIncludeGlobs; |
639 | | MOZ_INIT_OUTSIDE_CTOR bool mMatchAboutBlank; |
640 | | MOZ_INIT_OUTSIDE_CTOR OwningMatchPatternSetOrStringSequence mMatches; |
641 | | |
642 | | MozDocumentMatcherInit(); |
643 | | |
644 | | explicit inline MozDocumentMatcherInit(const FastDictionaryInitializer& ) |
645 | 0 | { |
646 | 0 | // Do nothing here; this is used by our "Fast" subclass |
647 | 0 | } |
648 | | |
649 | | explicit inline MozDocumentMatcherInit(const MozDocumentMatcherInit& aOther) |
650 | 0 | { |
651 | 0 | *this = aOther; |
652 | 0 | } |
653 | | |
654 | | bool |
655 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
656 | | |
657 | | bool |
658 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
659 | | |
660 | | void |
661 | | TraceDictionary(JSTracer* trc); |
662 | | |
663 | | inline void |
664 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
665 | 0 | { |
666 | 0 | ImplCycleCollectionTraverse(aCallback, mExcludeGlobs, "mExcludeGlobs", aFlags); |
667 | 0 | ImplCycleCollectionTraverse(aCallback, mExcludeMatches, "mExcludeMatches", aFlags); |
668 | 0 | ImplCycleCollectionTraverse(aCallback, mIncludeGlobs, "mIncludeGlobs", aFlags); |
669 | 0 | ImplCycleCollectionTraverse(aCallback, mMatches, "mMatches", aFlags); |
670 | 0 | } |
671 | | |
672 | | inline void |
673 | | UnlinkForCC() |
674 | 0 | { |
675 | 0 | ImplCycleCollectionUnlink(mExcludeGlobs); |
676 | 0 | ImplCycleCollectionUnlink(mExcludeMatches); |
677 | 0 | ImplCycleCollectionUnlink(mIncludeGlobs); |
678 | 0 | ImplCycleCollectionUnlink(mMatches); |
679 | 0 | } |
680 | | |
681 | | MozDocumentMatcherInit& |
682 | | operator=(const MozDocumentMatcherInit& aOther); |
683 | | |
684 | | private: |
685 | | static bool |
686 | | InitIds(JSContext* cx, MozDocumentMatcherInitAtoms* atomsCache); |
687 | | }; |
688 | | |
689 | | namespace binding_detail { |
690 | | struct FastMozDocumentMatcherInit : public MozDocumentMatcherInit |
691 | | { |
692 | | inline FastMozDocumentMatcherInit() |
693 | | : MozDocumentMatcherInit(FastDictionaryInitializer()) |
694 | 0 | { |
695 | 0 | // Doesn't matter what int we pass to the parent constructor |
696 | 0 | } |
697 | | }; |
698 | | } // namespace binding_detail |
699 | | |
700 | | |
701 | | struct WebExtensionContentScriptInit : public MozDocumentMatcherInit |
702 | | { |
703 | | MOZ_INIT_OUTSIDE_CTOR Sequence<nsString> mCssPaths; |
704 | | MOZ_INIT_OUTSIDE_CTOR Sequence<nsString> mJsPaths; |
705 | | MOZ_INIT_OUTSIDE_CTOR ContentScriptRunAt mRunAt; |
706 | | |
707 | | WebExtensionContentScriptInit(); |
708 | | |
709 | | explicit inline WebExtensionContentScriptInit(const FastDictionaryInitializer& ) |
710 | | : MozDocumentMatcherInit(FastDictionaryInitializer()) |
711 | 0 | { |
712 | 0 | // Do nothing here; this is used by our "Fast" subclass |
713 | 0 | } |
714 | | |
715 | | explicit inline WebExtensionContentScriptInit(const WebExtensionContentScriptInit& aOther) |
716 | 0 | { |
717 | 0 | *this = aOther; |
718 | 0 | } |
719 | | |
720 | | bool |
721 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
722 | | |
723 | | bool |
724 | | Init(const nsAString& aJSON); |
725 | | |
726 | | bool |
727 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
728 | | |
729 | | bool |
730 | | ToJSON(nsAString& aJSON) const; |
731 | | |
732 | | void |
733 | | TraceDictionary(JSTracer* trc); |
734 | | |
735 | | inline void |
736 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
737 | 0 | { |
738 | 0 | MozDocumentMatcherInit::TraverseForCC(aCallback, aFlags); |
739 | 0 | } |
740 | | |
741 | | inline void |
742 | | UnlinkForCC() |
743 | 0 | { |
744 | 0 | MozDocumentMatcherInit::UnlinkForCC(); |
745 | 0 | } |
746 | | |
747 | | WebExtensionContentScriptInit& |
748 | | operator=(const WebExtensionContentScriptInit& aOther); |
749 | | |
750 | | private: |
751 | | static bool |
752 | | InitIds(JSContext* cx, WebExtensionContentScriptInitAtoms* atomsCache); |
753 | | }; |
754 | | |
755 | | namespace binding_detail { |
756 | | struct FastWebExtensionContentScriptInit : public WebExtensionContentScriptInit |
757 | | { |
758 | | inline FastWebExtensionContentScriptInit() |
759 | | : WebExtensionContentScriptInit(FastDictionaryInitializer()) |
760 | 0 | { |
761 | 0 | // Doesn't matter what int we pass to the parent constructor |
762 | 0 | } |
763 | | }; |
764 | | } // namespace binding_detail |
765 | | |
766 | | |
767 | | namespace MozDocumentMatcher_Binding { |
768 | | |
769 | | typedef mozilla::extensions::MozDocumentMatcher NativeType; |
770 | | |
771 | | bool |
772 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
773 | | |
774 | | const JSClass* |
775 | | GetJSClass(); |
776 | | |
777 | | bool |
778 | | Wrap(JSContext* aCx, mozilla::extensions::MozDocumentMatcher* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
779 | | |
780 | | template <class T> |
781 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
782 | 0 | { |
783 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
784 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
785 | 0 | } |
786 | | |
787 | | void |
788 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
789 | | |
790 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
791 | 0 | { |
792 | 0 | /* Get the interface prototype object for this class. This will create the |
793 | 0 | object as needed. */ |
794 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::MozDocumentMatcher, |
795 | 0 | &CreateInterfaceObjects, |
796 | 0 | /* aDefineOnGlobal = */ true); |
797 | 0 |
|
798 | 0 | } |
799 | | |
800 | | JSObject* |
801 | | GetProtoObject(JSContext* aCx); |
802 | | |
803 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
804 | 0 | { |
805 | 0 | /* Get the interface object for this class. This will create the object as |
806 | 0 | needed. */ |
807 | 0 |
|
808 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::MozDocumentMatcher, |
809 | 0 | &CreateInterfaceObjects, |
810 | 0 | aDefineOnGlobal); |
811 | 0 | } |
812 | | |
813 | | JSObject* |
814 | | GetConstructorObject(JSContext* aCx); |
815 | | |
816 | | } // namespace MozDocumentMatcher_Binding |
817 | | |
818 | | |
819 | | |
820 | | namespace WebExtensionContentScript_Binding { |
821 | | |
822 | | typedef mozilla::extensions::WebExtensionContentScript NativeType; |
823 | | |
824 | | bool |
825 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
826 | | |
827 | | const JSClass* |
828 | | GetJSClass(); |
829 | | |
830 | | bool |
831 | | Wrap(JSContext* aCx, mozilla::extensions::WebExtensionContentScript* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
832 | | |
833 | | template <class T> |
834 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
835 | 0 | { |
836 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
837 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
838 | 0 | } |
839 | | |
840 | | void |
841 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
842 | | |
843 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
844 | 0 | { |
845 | 0 | /* Get the interface prototype object for this class. This will create the |
846 | 0 | object as needed. */ |
847 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::WebExtensionContentScript, |
848 | 0 | &CreateInterfaceObjects, |
849 | 0 | /* aDefineOnGlobal = */ true); |
850 | 0 |
|
851 | 0 | } |
852 | | |
853 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
854 | 0 | { |
855 | 0 | /* Get the interface object for this class. This will create the object as |
856 | 0 | needed. */ |
857 | 0 |
|
858 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::WebExtensionContentScript, |
859 | 0 | &CreateInterfaceObjects, |
860 | 0 | aDefineOnGlobal); |
861 | 0 | } |
862 | | |
863 | | JSObject* |
864 | | GetConstructorObject(JSContext* aCx); |
865 | | |
866 | | } // namespace WebExtensionContentScript_Binding |
867 | | |
868 | | |
869 | | |
870 | | } // namespace dom |
871 | | } // namespace mozilla |
872 | | |
873 | | #endif // mozilla_dom_WebExtensionContentScriptBinding_h |