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