Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SVGGraphicsElement.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "DOMSVGStringList.h"
5 : #include "SVGElementBinding.h"
6 : #include "SVGGraphicsElementBinding.h"
7 : #include "WrapperFactory.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/PrimitiveConversions.h"
14 : #include "mozilla/dom/SVGAnimatedTransformList.h"
15 : #include "mozilla/dom/SVGGraphicsElement.h"
16 : #include "mozilla/dom/SVGIRect.h"
17 : #include "mozilla/dom/SVGMatrix.h"
18 : #include "mozilla/dom/ScriptSettings.h"
19 : #include "mozilla/dom/SimpleGlobalObject.h"
20 : #include "mozilla/dom/XrayExpandoClass.h"
21 : #include "nsSVGElement.h"
22 :
23 : namespace mozilla {
24 : namespace dom {
25 :
26 :
27 0 : SVGBoundingBoxOptions::SVGBoundingBoxOptions()
28 : {
29 : // Safe to pass a null context if we pass a null value
30 0 : Init(nullptr, JS::NullHandleValue);
31 0 : }
32 :
33 :
34 :
35 : bool
36 0 : SVGBoundingBoxOptions::InitIds(JSContext* cx, SVGBoundingBoxOptionsAtoms* atomsCache)
37 : {
38 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
39 :
40 : // Initialize these in reverse order so that any failure leaves the first one
41 : // uninitialized.
42 0 : if (!atomsCache->stroke_id.init(cx, "stroke") ||
43 0 : !atomsCache->markers_id.init(cx, "markers") ||
44 0 : !atomsCache->fill_id.init(cx, "fill") ||
45 0 : !atomsCache->clipped_id.init(cx, "clipped")) {
46 0 : return false;
47 : }
48 0 : return true;
49 : }
50 :
51 : bool
52 0 : SVGBoundingBoxOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
53 : {
54 : // Passing a null JSContext is OK only if we're initing from null,
55 : // Since in that case we will not have to do any property gets
56 : // Also evaluate isNullOrUndefined in order to avoid false-positive
57 : // checkers by static analysis tools
58 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
59 0 : SVGBoundingBoxOptionsAtoms* atomsCache = nullptr;
60 0 : if (cx) {
61 0 : atomsCache = GetAtomCache<SVGBoundingBoxOptionsAtoms>(cx);
62 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
63 0 : return false;
64 : }
65 : }
66 :
67 0 : if (!IsConvertibleToDictionary(val)) {
68 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
69 : }
70 :
71 0 : bool isNull = val.isNullOrUndefined();
72 : // We only need these if !isNull, in which case we have |cx|.
73 0 : Maybe<JS::Rooted<JSObject *> > object;
74 0 : Maybe<JS::Rooted<JS::Value> > temp;
75 0 : if (!isNull) {
76 0 : MOZ_ASSERT(cx);
77 0 : object.emplace(cx, &val.toObject());
78 0 : temp.emplace(cx);
79 : }
80 0 : if (!isNull) {
81 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->clipped_id, temp.ptr())) {
82 0 : return false;
83 : }
84 : }
85 0 : if (!isNull && !temp->isUndefined()) {
86 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mClipped)) {
87 0 : return false;
88 : }
89 : } else {
90 0 : mClipped = false;
91 : }
92 0 : mIsAnyMemberPresent = true;
93 :
94 0 : if (!isNull) {
95 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->fill_id, temp.ptr())) {
96 0 : return false;
97 : }
98 : }
99 0 : if (!isNull && !temp->isUndefined()) {
100 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFill)) {
101 0 : return false;
102 : }
103 : } else {
104 0 : mFill = true;
105 : }
106 0 : mIsAnyMemberPresent = true;
107 :
108 0 : if (!isNull) {
109 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->markers_id, temp.ptr())) {
110 0 : return false;
111 : }
112 : }
113 0 : if (!isNull && !temp->isUndefined()) {
114 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMarkers)) {
115 0 : return false;
116 : }
117 : } else {
118 0 : mMarkers = false;
119 : }
120 0 : mIsAnyMemberPresent = true;
121 :
122 0 : if (!isNull) {
123 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->stroke_id, temp.ptr())) {
124 0 : return false;
125 : }
126 : }
127 0 : if (!isNull && !temp->isUndefined()) {
128 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mStroke)) {
129 0 : return false;
130 : }
131 : } else {
132 0 : mStroke = false;
133 : }
134 0 : mIsAnyMemberPresent = true;
135 0 : return true;
136 : }
137 :
138 : bool
139 0 : SVGBoundingBoxOptions::Init(const nsAString& aJSON)
140 : {
141 0 : AutoJSAPI jsapi;
142 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
143 0 : if (!cleanGlobal) {
144 0 : return false;
145 : }
146 0 : if (!jsapi.Init(cleanGlobal)) {
147 0 : return false;
148 : }
149 0 : JSContext* cx = jsapi.cx();
150 0 : JS::Rooted<JS::Value> json(cx);
151 0 : bool ok = ParseJSON(cx, aJSON, &json);
152 0 : NS_ENSURE_TRUE(ok, false);
153 0 : return Init(cx, json);
154 : }
155 :
156 : bool
157 0 : SVGBoundingBoxOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
158 : {
159 0 : SVGBoundingBoxOptionsAtoms* atomsCache = GetAtomCache<SVGBoundingBoxOptionsAtoms>(cx);
160 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
161 0 : return false;
162 : }
163 :
164 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
165 0 : if (!obj) {
166 0 : return false;
167 : }
168 0 : rval.set(JS::ObjectValue(*obj));
169 :
170 : do {
171 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
172 0 : JS::Rooted<JS::Value> temp(cx);
173 0 : bool const & currentValue = mClipped;
174 0 : temp.setBoolean(currentValue);
175 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->clipped_id, temp, JSPROP_ENUMERATE)) {
176 0 : return false;
177 : }
178 0 : break;
179 : } while(0);
180 :
181 : do {
182 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
183 0 : JS::Rooted<JS::Value> temp(cx);
184 0 : bool const & currentValue = mFill;
185 0 : temp.setBoolean(currentValue);
186 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->fill_id, temp, JSPROP_ENUMERATE)) {
187 0 : return false;
188 : }
189 0 : break;
190 : } while(0);
191 :
192 : do {
193 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
194 0 : JS::Rooted<JS::Value> temp(cx);
195 0 : bool const & currentValue = mMarkers;
196 0 : temp.setBoolean(currentValue);
197 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->markers_id, temp, JSPROP_ENUMERATE)) {
198 0 : return false;
199 : }
200 0 : break;
201 : } while(0);
202 :
203 : do {
204 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
205 0 : JS::Rooted<JS::Value> temp(cx);
206 0 : bool const & currentValue = mStroke;
207 0 : temp.setBoolean(currentValue);
208 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->stroke_id, temp, JSPROP_ENUMERATE)) {
209 0 : return false;
210 : }
211 0 : break;
212 : } while(0);
213 :
214 0 : return true;
215 : }
216 :
217 : bool
218 0 : SVGBoundingBoxOptions::ToJSON(nsAString& aJSON) const
219 : {
220 0 : AutoJSAPI jsapi;
221 0 : jsapi.Init();
222 0 : JSContext *cx = jsapi.cx();
223 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
224 : // because we'll only be creating objects, in ways that have no
225 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
226 : // which likewise guarantees no side-effects for the sorts of
227 : // things we will pass it.
228 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
229 0 : JS::Rooted<JS::Value> val(cx);
230 0 : if (!ToObjectInternal(cx, &val)) {
231 0 : return false;
232 : }
233 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
234 0 : return StringifyToJSON(cx, obj, aJSON);
235 : }
236 :
237 : void
238 0 : SVGBoundingBoxOptions::TraceDictionary(JSTracer* trc)
239 : {
240 0 : }
241 :
242 : SVGBoundingBoxOptions&
243 0 : SVGBoundingBoxOptions::operator=(const SVGBoundingBoxOptions& aOther)
244 : {
245 0 : mClipped = aOther.mClipped;
246 0 : mFill = aOther.mFill;
247 0 : mMarkers = aOther.mMarkers;
248 0 : mStroke = aOther.mStroke;
249 0 : return *this;
250 : }
251 :
252 : namespace binding_detail {
253 : } // namespace binding_detail
254 :
255 :
256 : namespace SVGGraphicsElementBinding {
257 :
258 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<SVGElementBinding::NativeType>::value,
259 : "Can't inherit from an interface with a different ownership model.");
260 :
261 : static bool
262 0 : get_transform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
263 : {
264 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedTransformList>(self->Transform()));
265 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
266 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
267 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
268 0 : return false;
269 : }
270 0 : return true;
271 : }
272 :
273 : static const JSJitInfo transform_getterinfo = {
274 : { (JSJitGetterOp)get_transform },
275 : { prototypes::id::SVGGraphicsElement },
276 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
277 : JSJitInfo::Getter,
278 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
279 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
280 : false, /* isInfallible. False in setters. */
281 : false, /* isMovable. Not relevant for setters. */
282 : false, /* isEliminatable. Not relevant for setters. */
283 : false, /* isAlwaysInSlot. Only relevant for getters. */
284 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
285 : false, /* isTypedMethod. Only relevant for methods. */
286 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
287 : };
288 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
289 : static_assert(0 < 1, "There is no slot for us");
290 :
291 : static bool
292 0 : get_nearestViewportElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
293 : {
294 0 : auto result(StrongOrRawPtr<nsSVGElement>(self->GetNearestViewportElement()));
295 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
296 0 : if (!result) {
297 0 : args.rval().setNull();
298 0 : return true;
299 : }
300 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
301 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
302 0 : return false;
303 : }
304 0 : return true;
305 : }
306 :
307 : static const JSJitInfo nearestViewportElement_getterinfo = {
308 : { (JSJitGetterOp)get_nearestViewportElement },
309 : { prototypes::id::SVGGraphicsElement },
310 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
311 : JSJitInfo::Getter,
312 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
313 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
314 : false, /* isInfallible. False in setters. */
315 : false, /* isMovable. Not relevant for setters. */
316 : false, /* isEliminatable. Not relevant for setters. */
317 : false, /* isAlwaysInSlot. Only relevant for getters. */
318 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
319 : false, /* isTypedMethod. Only relevant for methods. */
320 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
321 : };
322 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
323 : static_assert(0 < 1, "There is no slot for us");
324 :
325 : static bool
326 0 : get_farthestViewportElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
327 : {
328 0 : auto result(StrongOrRawPtr<nsSVGElement>(self->GetFarthestViewportElement()));
329 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
330 0 : if (!result) {
331 0 : args.rval().setNull();
332 0 : return true;
333 : }
334 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
335 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
336 0 : return false;
337 : }
338 0 : return true;
339 : }
340 :
341 : static const JSJitInfo farthestViewportElement_getterinfo = {
342 : { (JSJitGetterOp)get_farthestViewportElement },
343 : { prototypes::id::SVGGraphicsElement },
344 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
345 : JSJitInfo::Getter,
346 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
347 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
348 : false, /* isInfallible. False in setters. */
349 : false, /* isMovable. Not relevant for setters. */
350 : false, /* isEliminatable. Not relevant for setters. */
351 : false, /* isAlwaysInSlot. Only relevant for getters. */
352 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
353 : false, /* isTypedMethod. Only relevant for methods. */
354 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
355 : };
356 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
357 : static_assert(0 < 1, "There is no slot for us");
358 :
359 : static bool
360 0 : getBBox(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
361 : {
362 0 : binding_detail::FastSVGBoundingBoxOptions arg0;
363 0 : if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of SVGGraphicsElement.getBBox", false)) {
364 0 : return false;
365 : }
366 0 : binding_detail::FastErrorResult rv;
367 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGIRect>(self->GetBBox(Constify(arg0), rv)));
368 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
369 0 : return false;
370 : }
371 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
372 : static_assert(!IsPointer<decltype(result)>::value,
373 : "NewObject implies that we need to keep the object alive with a strong reference.");
374 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
375 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
376 0 : return false;
377 : }
378 0 : return true;
379 : }
380 :
381 : static const JSJitInfo getBBox_methodinfo = {
382 : { (JSJitGetterOp)getBBox },
383 : { prototypes::id::SVGGraphicsElement },
384 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
385 : JSJitInfo::Method,
386 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
387 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
388 : false, /* isInfallible. False in setters. */
389 : false, /* isMovable. Not relevant for setters. */
390 : false, /* isEliminatable. Not relevant for setters. */
391 : false, /* isAlwaysInSlot. Only relevant for getters. */
392 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
393 : false, /* isTypedMethod. Only relevant for methods. */
394 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
395 : };
396 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
397 : static_assert(0 < 1, "There is no slot for us");
398 :
399 : static bool
400 0 : getCTM(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
401 : {
402 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetCTM()));
403 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
404 0 : if (!result) {
405 0 : args.rval().setNull();
406 0 : return true;
407 : }
408 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
409 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
410 0 : return false;
411 : }
412 0 : return true;
413 : }
414 :
415 : static const JSJitInfo getCTM_methodinfo = {
416 : { (JSJitGetterOp)getCTM },
417 : { prototypes::id::SVGGraphicsElement },
418 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
419 : JSJitInfo::Method,
420 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
421 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
422 : false, /* isInfallible. False in setters. */
423 : false, /* isMovable. Not relevant for setters. */
424 : false, /* isEliminatable. Not relevant for setters. */
425 : false, /* isAlwaysInSlot. Only relevant for getters. */
426 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
427 : false, /* isTypedMethod. Only relevant for methods. */
428 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
429 : };
430 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
431 : static_assert(0 < 1, "There is no slot for us");
432 :
433 : static bool
434 0 : getScreenCTM(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
435 : {
436 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetScreenCTM()));
437 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
438 0 : if (!result) {
439 0 : args.rval().setNull();
440 0 : return true;
441 : }
442 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
443 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
444 0 : return false;
445 : }
446 0 : return true;
447 : }
448 :
449 : static const JSJitInfo getScreenCTM_methodinfo = {
450 : { (JSJitGetterOp)getScreenCTM },
451 : { prototypes::id::SVGGraphicsElement },
452 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
453 : JSJitInfo::Method,
454 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
455 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
456 : false, /* isInfallible. False in setters. */
457 : false, /* isMovable. Not relevant for setters. */
458 : false, /* isEliminatable. Not relevant for setters. */
459 : false, /* isAlwaysInSlot. Only relevant for getters. */
460 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
461 : false, /* isTypedMethod. Only relevant for methods. */
462 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
463 : };
464 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
465 : static_assert(0 < 1, "There is no slot for us");
466 :
467 : static bool
468 0 : getTransformToElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
469 : {
470 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
471 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGGraphicsElement.getTransformToElement");
472 : }
473 0 : NonNull<mozilla::dom::SVGGraphicsElement> arg0;
474 0 : if (args[0].isObject()) {
475 : {
476 0 : nsresult rv = UnwrapObject<prototypes::id::SVGGraphicsElement, mozilla::dom::SVGGraphicsElement>(args[0], arg0);
477 0 : if (NS_FAILED(rv)) {
478 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGGraphicsElement.getTransformToElement", "SVGGraphicsElement");
479 0 : return false;
480 : }
481 : }
482 : } else {
483 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGGraphicsElement.getTransformToElement");
484 0 : return false;
485 : }
486 0 : binding_detail::FastErrorResult rv;
487 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetTransformToElement(NonNullHelper(arg0), rv)));
488 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
489 0 : return false;
490 : }
491 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
492 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
493 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
494 0 : return false;
495 : }
496 0 : return true;
497 : }
498 :
499 : static const JSJitInfo getTransformToElement_methodinfo = {
500 : { (JSJitGetterOp)getTransformToElement },
501 : { prototypes::id::SVGGraphicsElement },
502 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
503 : JSJitInfo::Method,
504 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
505 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
506 : false, /* isInfallible. False in setters. */
507 : false, /* isMovable. Not relevant for setters. */
508 : false, /* isEliminatable. Not relevant for setters. */
509 : false, /* isAlwaysInSlot. Only relevant for getters. */
510 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
511 : false, /* isTypedMethod. Only relevant for methods. */
512 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
513 : };
514 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
515 : static_assert(0 < 1, "There is no slot for us");
516 :
517 : static bool
518 0 : get_requiredFeatures(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
519 : {
520 0 : auto result(StrongOrRawPtr<mozilla::DOMSVGStringList>(self->RequiredFeatures()));
521 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
522 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
523 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
524 0 : return false;
525 : }
526 0 : return true;
527 : }
528 :
529 : static const JSJitInfo requiredFeatures_getterinfo = {
530 : { (JSJitGetterOp)get_requiredFeatures },
531 : { prototypes::id::SVGGraphicsElement },
532 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
533 : JSJitInfo::Getter,
534 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
535 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
536 : false, /* isInfallible. False in setters. */
537 : false, /* isMovable. Not relevant for setters. */
538 : false, /* isEliminatable. Not relevant for setters. */
539 : false, /* isAlwaysInSlot. Only relevant for getters. */
540 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
541 : false, /* isTypedMethod. Only relevant for methods. */
542 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
543 : };
544 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
545 : static_assert(0 < 1, "There is no slot for us");
546 :
547 : static bool
548 0 : get_requiredExtensions(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
549 : {
550 0 : auto result(StrongOrRawPtr<mozilla::DOMSVGStringList>(self->RequiredExtensions()));
551 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
552 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
553 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
554 0 : return false;
555 : }
556 0 : return true;
557 : }
558 :
559 : static const JSJitInfo requiredExtensions_getterinfo = {
560 : { (JSJitGetterOp)get_requiredExtensions },
561 : { prototypes::id::SVGGraphicsElement },
562 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
563 : JSJitInfo::Getter,
564 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
565 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
566 : false, /* isInfallible. False in setters. */
567 : false, /* isMovable. Not relevant for setters. */
568 : false, /* isEliminatable. Not relevant for setters. */
569 : false, /* isAlwaysInSlot. Only relevant for getters. */
570 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
571 : false, /* isTypedMethod. Only relevant for methods. */
572 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
573 : };
574 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
575 : static_assert(0 < 1, "There is no slot for us");
576 :
577 : static bool
578 0 : get_systemLanguage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
579 : {
580 0 : auto result(StrongOrRawPtr<mozilla::DOMSVGStringList>(self->SystemLanguage()));
581 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
582 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
583 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
584 0 : return false;
585 : }
586 0 : return true;
587 : }
588 :
589 : static const JSJitInfo systemLanguage_getterinfo = {
590 : { (JSJitGetterOp)get_systemLanguage },
591 : { prototypes::id::SVGGraphicsElement },
592 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
593 : JSJitInfo::Getter,
594 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
595 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
596 : false, /* isInfallible. False in setters. */
597 : false, /* isMovable. Not relevant for setters. */
598 : false, /* isEliminatable. Not relevant for setters. */
599 : false, /* isAlwaysInSlot. Only relevant for getters. */
600 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
601 : false, /* isTypedMethod. Only relevant for methods. */
602 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
603 : };
604 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
605 : static_assert(0 < 1, "There is no slot for us");
606 :
607 : static bool
608 0 : hasExtension(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
609 : {
610 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
611 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGGraphicsElement.hasExtension");
612 : }
613 0 : binding_detail::FakeString arg0;
614 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
615 0 : return false;
616 : }
617 0 : bool result(self->HasExtension(NonNullHelper(Constify(arg0))));
618 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
619 0 : args.rval().setBoolean(result);
620 0 : return true;
621 : }
622 :
623 : static const JSJitInfo hasExtension_methodinfo = {
624 : { (JSJitGetterOp)hasExtension },
625 : { prototypes::id::SVGGraphicsElement },
626 : { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
627 : JSJitInfo::Method,
628 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
629 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
630 : false, /* isInfallible. False in setters. */
631 : false, /* isMovable. Not relevant for setters. */
632 : false, /* isEliminatable. Not relevant for setters. */
633 : false, /* isAlwaysInSlot. Only relevant for getters. */
634 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
635 : false, /* isTypedMethod. Only relevant for methods. */
636 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
637 : };
638 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
639 : static_assert(0 < 1, "There is no slot for us");
640 :
641 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
642 : #if defined(__clang__)
643 : #pragma clang diagnostic push
644 : #pragma clang diagnostic ignored "-Wmissing-braces"
645 : #endif
646 : static const JSFunctionSpec sMethods_specs[] = {
647 : JS_FNSPEC("getBBox", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getBBox_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
648 : JS_FNSPEC("getCTM", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getCTM_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
649 : JS_FNSPEC("getScreenCTM", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getScreenCTM_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
650 : JS_FNSPEC("getTransformToElement", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getTransformToElement_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
651 : JS_FNSPEC("hasExtension", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&hasExtension_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
652 : JS_FS_END
653 : };
654 : #if defined(__clang__)
655 : #pragma clang diagnostic pop
656 : #endif
657 :
658 :
659 : // Can't be const because the pref-enabled boolean needs to be writable
660 : static Prefable<const JSFunctionSpec> sMethods[] = {
661 : { nullptr, &sMethods_specs[0] },
662 : { nullptr, nullptr }
663 : };
664 :
665 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
666 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
667 : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
668 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
669 :
670 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
671 : #if defined(__clang__)
672 : #pragma clang diagnostic push
673 : #pragma clang diagnostic ignored "-Wmissing-braces"
674 : #endif
675 : static const JSPropertySpec sAttributes_specs[] = {
676 : { "transform", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &transform_getterinfo, nullptr, nullptr },
677 : { "nearestViewportElement", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &nearestViewportElement_getterinfo, nullptr, nullptr },
678 : { "farthestViewportElement", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &farthestViewportElement_getterinfo, nullptr, nullptr },
679 : { "requiredFeatures", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &requiredFeatures_getterinfo, nullptr, nullptr },
680 : { "requiredExtensions", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &requiredExtensions_getterinfo, nullptr, nullptr },
681 : { "systemLanguage", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &systemLanguage_getterinfo, nullptr, nullptr },
682 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
683 : };
684 : #if defined(__clang__)
685 : #pragma clang diagnostic pop
686 : #endif
687 :
688 :
689 : // Can't be const because the pref-enabled boolean needs to be writable
690 : static Prefable<const JSPropertySpec> sAttributes[] = {
691 : { nullptr, &sAttributes_specs[0] },
692 : { nullptr, nullptr }
693 : };
694 :
695 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
696 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
697 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
698 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
699 :
700 :
701 : static uint16_t sNativeProperties_sortedPropertyIndices[11];
702 : static PropertyInfo sNativeProperties_propertyInfos[11];
703 :
704 : static const NativePropertiesN<2> sNativeProperties = {
705 : false, 0,
706 : false, 0,
707 : true, 0 /* sMethods */,
708 : true, 1 /* sAttributes */,
709 : false, 0,
710 : false, 0,
711 : false, 0,
712 : -1,
713 : 11,
714 : sNativeProperties_sortedPropertyIndices,
715 : {
716 : { sMethods, &sNativeProperties_propertyInfos[0] },
717 : { sAttributes, &sNativeProperties_propertyInfos[5] }
718 : }
719 : };
720 : static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
721 : "We have a property info count that is oversized");
722 :
723 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
724 : {
725 : "Function",
726 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
727 : &sBoringInterfaceObjectClassClassOps,
728 : JS_NULL_CLASS_SPEC,
729 : JS_NULL_CLASS_EXT,
730 : &sInterfaceObjectClassObjectOps
731 : },
732 : eInterface,
733 : true,
734 : prototypes::id::SVGGraphicsElement,
735 : PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth,
736 : sNativePropertyHooks,
737 : "function SVGGraphicsElement() {\n [native code]\n}",
738 : SVGElementBinding::GetConstructorObject
739 : };
740 :
741 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
742 : {
743 : "SVGGraphicsElementPrototype",
744 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
745 : JS_NULL_CLASS_OPS,
746 : JS_NULL_CLASS_SPEC,
747 : JS_NULL_CLASS_EXT,
748 : JS_NULL_OBJECT_OPS
749 : },
750 : eInterfacePrototype,
751 : false,
752 : prototypes::id::SVGGraphicsElement,
753 : PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth,
754 : sNativePropertyHooks,
755 : "[object SVGGraphicsElementPrototype]",
756 : SVGElementBinding::GetProtoObject
757 : };
758 :
759 : JSObject*
760 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
761 : {
762 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
763 : }
764 :
765 : const NativePropertyHooks sNativePropertyHooks[] = { {
766 : nullptr,
767 : nullptr,
768 : nullptr,
769 : { sNativeProperties.Upcast(), nullptr },
770 : prototypes::id::SVGGraphicsElement,
771 : constructors::id::SVGGraphicsElement,
772 : SVGElementBinding::sNativePropertyHooks,
773 : &DefaultXrayExpandoObjectClass
774 : } };
775 :
776 : void
777 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
778 : {
779 0 : JS::Handle<JSObject*> parentProto(SVGElementBinding::GetProtoObjectHandle(aCx));
780 0 : if (!parentProto) {
781 0 : return;
782 : }
783 :
784 0 : JS::Handle<JSObject*> constructorProto(SVGElementBinding::GetConstructorObjectHandle(aCx));
785 0 : if (!constructorProto) {
786 0 : return;
787 : }
788 :
789 : static bool sIdsInited = false;
790 0 : if (!sIdsInited && NS_IsMainThread()) {
791 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
792 0 : return;
793 : }
794 0 : sIdsInited = true;
795 : }
796 :
797 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGGraphicsElement);
798 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGGraphicsElement);
799 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
800 : &sPrototypeClass.mBase, protoCache,
801 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
802 : interfaceCache,
803 : sNativeProperties.Upcast(),
804 : nullptr,
805 : "SVGGraphicsElement", aDefineOnGlobal,
806 : nullptr,
807 0 : false);
808 : }
809 :
810 : JS::Handle<JSObject*>
811 0 : GetProtoObjectHandle(JSContext* aCx)
812 : {
813 : /* Get the interface prototype object for this class. This will create the
814 : object as needed. */
815 0 : bool aDefineOnGlobal = true;
816 :
817 : /* Make sure our global is sane. Hopefully we can remove this sometime */
818 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
819 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
820 0 : return nullptr;
821 : }
822 :
823 : /* Check to see whether the interface objects are already installed */
824 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
825 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SVGGraphicsElement)) {
826 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
827 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
828 : }
829 :
830 : /*
831 : * The object might _still_ be null, but that's OK.
832 : *
833 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
834 : * traced by TraceProtoAndIfaceCache() and its contents are never
835 : * changed after they have been set.
836 : *
837 : * Calling address() avoids the read read barrier that does gray
838 : * unmarking, but it's not possible for the object to be gray here.
839 : */
840 :
841 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SVGGraphicsElement);
842 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
843 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
844 : }
845 :
846 : JSObject*
847 0 : GetProtoObject(JSContext* aCx)
848 : {
849 0 : return GetProtoObjectHandle(aCx);
850 : }
851 :
852 : JS::Handle<JSObject*>
853 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
854 : {
855 : /* Get the interface object for this class. This will create the object as
856 : needed. */
857 :
858 : /* Make sure our global is sane. Hopefully we can remove this sometime */
859 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
860 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
861 0 : return nullptr;
862 : }
863 :
864 : /* Check to see whether the interface objects are already installed */
865 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
866 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SVGGraphicsElement)) {
867 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
868 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
869 : }
870 :
871 : /*
872 : * The object might _still_ be null, but that's OK.
873 : *
874 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
875 : * traced by TraceProtoAndIfaceCache() and its contents are never
876 : * changed after they have been set.
877 : *
878 : * Calling address() avoids the read read barrier that does gray
879 : * unmarking, but it's not possible for the object to be gray here.
880 : */
881 :
882 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SVGGraphicsElement);
883 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
884 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
885 : }
886 :
887 : JSObject*
888 0 : GetConstructorObject(JSContext* aCx)
889 : {
890 0 : return GetConstructorObjectHandle(aCx);
891 : }
892 :
893 : } // namespace SVGGraphicsElementBinding
894 :
895 :
896 :
897 : } // namespace dom
898 : } // namespace mozilla
|