/work/obj-fuzz/dist/include/mozilla/dom/CustomElementRegistryBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM CustomElementRegistry.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_CustomElementRegistryBinding_h |
4 | | #define mozilla_dom_CustomElementRegistryBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "js/RootingAPI.h" |
8 | | #include "jspubtd.h" |
9 | | #include "mozilla/ErrorResult.h" |
10 | | #include "mozilla/dom/BindingDeclarations.h" |
11 | | #include "mozilla/dom/CallbackFunction.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "mozilla/dom/PrototypeList.h" |
14 | | #include "mozilla/dom/ToJSValue.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | class CustomElementCreationCallback; |
20 | | class CustomElementRegistry; |
21 | | struct CustomElementRegistryAtoms; |
22 | | struct ElementDefinitionOptionsAtoms; |
23 | | struct NativePropertyHooks; |
24 | | class ProtoAndIfaceCache; |
25 | | |
26 | | } // namespace dom |
27 | | } // namespace mozilla |
28 | | |
29 | | namespace mozilla { |
30 | | namespace dom { |
31 | | |
32 | | struct ElementDefinitionOptions : public DictionaryBase |
33 | | { |
34 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mExtends; |
35 | | |
36 | | ElementDefinitionOptions(); |
37 | | |
38 | | explicit inline ElementDefinitionOptions(const FastDictionaryInitializer& ) |
39 | 0 | { |
40 | 0 | // Do nothing here; this is used by our "Fast" subclass |
41 | 0 | } |
42 | | |
43 | | explicit inline ElementDefinitionOptions(const ElementDefinitionOptions& aOther) |
44 | 0 | { |
45 | 0 | *this = aOther; |
46 | 0 | } |
47 | | |
48 | | bool |
49 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
50 | | |
51 | | bool |
52 | | Init(const nsAString& aJSON); |
53 | | |
54 | | bool |
55 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
56 | | |
57 | | bool |
58 | | ToJSON(nsAString& aJSON) const; |
59 | | |
60 | | void |
61 | | TraceDictionary(JSTracer* trc); |
62 | | |
63 | | ElementDefinitionOptions& |
64 | | operator=(const ElementDefinitionOptions& aOther); |
65 | | |
66 | | private: |
67 | | static bool |
68 | | InitIds(JSContext* cx, ElementDefinitionOptionsAtoms* atomsCache); |
69 | | }; |
70 | | |
71 | | namespace binding_detail { |
72 | | struct FastElementDefinitionOptions : public ElementDefinitionOptions |
73 | | { |
74 | | inline FastElementDefinitionOptions() |
75 | | : ElementDefinitionOptions(FastDictionaryInitializer()) |
76 | 0 | { |
77 | 0 | // Doesn't matter what int we pass to the parent constructor |
78 | 0 | } |
79 | | }; |
80 | | } // namespace binding_detail |
81 | | |
82 | | |
83 | | class CustomElementCreationCallback : public CallbackFunction |
84 | | { |
85 | | public: |
86 | | explicit inline CustomElementCreationCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
87 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
88 | 0 | { |
89 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
90 | 0 | } |
91 | | |
92 | | explicit inline CustomElementCreationCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
93 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
94 | 0 | { |
95 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
96 | 0 | } |
97 | | |
98 | | explicit inline CustomElementCreationCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
99 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
100 | 0 | { |
101 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
102 | 0 | } |
103 | | |
104 | | explicit inline CustomElementCreationCallback(CallbackFunction* aOther) |
105 | | : CallbackFunction(aOther) |
106 | 0 | { |
107 | 0 | } |
108 | | |
109 | | template <typename T> |
110 | | inline void |
111 | | Call(const T& thisVal, const nsAString& name, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
112 | | { |
113 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
114 | | if (!aExecutionReason) { |
115 | | aExecutionReason = "CustomElementCreationCallback"; |
116 | | } |
117 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
118 | | if (!s.GetContext()) { |
119 | | MOZ_ASSERT(aRv.Failed()); |
120 | | return; |
121 | | } |
122 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
123 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
124 | | aRv.Throw(NS_ERROR_FAILURE); |
125 | | return; |
126 | | } |
127 | | return Call(s.GetContext(), thisValJS, name, aRv); |
128 | | } |
129 | | |
130 | | inline void |
131 | | Call(const nsAString& name, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
132 | 0 | { |
133 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
134 | 0 | if (!aExecutionReason) { |
135 | 0 | aExecutionReason = "CustomElementCreationCallback"; |
136 | 0 | } |
137 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
138 | 0 | if (!s.GetContext()) { |
139 | 0 | MOZ_ASSERT(aRv.Failed()); |
140 | 0 | return; |
141 | 0 | } |
142 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, name, aRv); |
143 | 0 | } |
144 | | |
145 | | template <typename T> |
146 | | inline void |
147 | | Call(const T& thisVal, const nsAString& name, const char* aExecutionReason = nullptr) |
148 | | { |
149 | | return Call(thisVal, name, IgnoreErrors(), aExecutionReason); |
150 | | } |
151 | | |
152 | | inline void |
153 | | Call(const nsAString& name, const char* aExecutionReason = nullptr) |
154 | 0 | { |
155 | 0 | return Call(name, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
156 | 0 | } |
157 | | |
158 | | inline bool |
159 | | operator==(const CustomElementCreationCallback& aOther) const |
160 | 0 | { |
161 | 0 | return CallbackFunction::operator==(aOther); |
162 | 0 | } |
163 | | |
164 | | private: |
165 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& name, ErrorResult& aRv); |
166 | | }; |
167 | | |
168 | | |
169 | | namespace binding_detail { |
170 | | class FastCustomElementCreationCallback : public CustomElementCreationCallback |
171 | | { |
172 | | public: |
173 | | explicit inline FastCustomElementCreationCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
174 | | : CustomElementCreationCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
175 | 0 | { |
176 | 0 | } |
177 | | |
178 | | inline void |
179 | | Trace(JSTracer* aTracer) |
180 | 0 | { |
181 | 0 | CustomElementCreationCallback::Trace(aTracer); |
182 | 0 | } |
183 | | |
184 | | inline void |
185 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
186 | 0 | { |
187 | 0 | CustomElementCreationCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
188 | 0 | } |
189 | | }; |
190 | | } // namespace binding_detail |
191 | | |
192 | | |
193 | | namespace CustomElementRegistry_Binding { |
194 | | |
195 | | typedef mozilla::dom::CustomElementRegistry NativeType; |
196 | | |
197 | | bool |
198 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
199 | | |
200 | | const JSClass* |
201 | | GetJSClass(); |
202 | | |
203 | | bool |
204 | | Wrap(JSContext* aCx, mozilla::dom::CustomElementRegistry* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
205 | | |
206 | | template <class T> |
207 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
208 | 0 | { |
209 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
210 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
211 | 0 | } |
212 | | |
213 | | // We declare this as an array so that retrieving a pointer to this |
214 | | // binding's property hooks only requires compile/link-time resolvable |
215 | | // address arithmetic. Declaring it as a pointer instead would require |
216 | | // doing a run-time load to fetch a pointer to this binding's property |
217 | | // hooks. And then structures which embedded a pointer to this structure |
218 | | // would require a run-time load for proper initialization, which would |
219 | | // then induce static constructors. Lots of static constructors. |
220 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
221 | | |
222 | | void |
223 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
224 | | |
225 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
226 | 0 | { |
227 | 0 | /* Get the interface prototype object for this class. This will create the |
228 | 0 | object as needed. */ |
229 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::CustomElementRegistry, |
230 | 0 | &CreateInterfaceObjects, |
231 | 0 | /* aDefineOnGlobal = */ true); |
232 | 0 |
|
233 | 0 | } |
234 | | |
235 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
236 | 0 | { |
237 | 0 | /* Get the interface object for this class. This will create the object as |
238 | 0 | needed. */ |
239 | 0 |
|
240 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::CustomElementRegistry, |
241 | 0 | &CreateInterfaceObjects, |
242 | 0 | aDefineOnGlobal); |
243 | 0 | } |
244 | | |
245 | | JSObject* |
246 | | GetConstructorObject(JSContext* aCx); |
247 | | |
248 | | } // namespace CustomElementRegistry_Binding |
249 | | |
250 | | |
251 | | |
252 | | } // namespace dom |
253 | | } // namespace mozilla |
254 | | |
255 | | #endif // mozilla_dom_CustomElementRegistryBinding_h |