LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - ScreenOrientationBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 195 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 19 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM ScreenOrientation.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "ScreenOrientationBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "jsapi.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/Promise.h"
      15             : #include "mozilla/dom/ScreenOrientation.h"
      16             : #include "mozilla/dom/ToJSValue.h"
      17             : #include "mozilla/dom/XrayExpandoClass.h"
      18             : #include "nsContentUtils.h"
      19             : 
      20             : namespace mozilla {
      21             : namespace dom {
      22             : 
      23             : namespace OrientationTypeValues {
      24             : extern const EnumEntry strings[5] = {
      25             :   {"portrait-primary", 16},
      26             :   {"portrait-secondary", 18},
      27             :   {"landscape-primary", 17},
      28             :   {"landscape-secondary", 19},
      29             :   { nullptr, 0 }
      30             : };
      31             : } // namespace OrientationTypeValues
      32             : 
      33             : bool
      34           0 : ToJSValue(JSContext* aCx, OrientationType aArgument, JS::MutableHandle<JS::Value> aValue)
      35             : {
      36           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(OrientationTypeValues::strings));
      37             :   JSString* resultStr =
      38           0 :     JS_NewStringCopyN(aCx, OrientationTypeValues::strings[uint32_t(aArgument)].value,
      39           0 :                       OrientationTypeValues::strings[uint32_t(aArgument)].length);
      40           0 :   if (!resultStr) {
      41           0 :     return false;
      42             :   }
      43           0 :   aValue.setString(resultStr);
      44           0 :   return true;
      45             : }
      46             : 
      47             : 
      48             : namespace OrientationLockTypeValues {
      49             : extern const EnumEntry strings[9] = {
      50             :   {"any", 3},
      51             :   {"natural", 7},
      52             :   {"landscape", 9},
      53             :   {"portrait", 8},
      54             :   {"portrait-primary", 16},
      55             :   {"portrait-secondary", 18},
      56             :   {"landscape-primary", 17},
      57             :   {"landscape-secondary", 19},
      58             :   { nullptr, 0 }
      59             : };
      60             : } // namespace OrientationLockTypeValues
      61             : 
      62             : bool
      63           0 : ToJSValue(JSContext* aCx, OrientationLockType aArgument, JS::MutableHandle<JS::Value> aValue)
      64             : {
      65           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(OrientationLockTypeValues::strings));
      66             :   JSString* resultStr =
      67           0 :     JS_NewStringCopyN(aCx, OrientationLockTypeValues::strings[uint32_t(aArgument)].value,
      68           0 :                       OrientationLockTypeValues::strings[uint32_t(aArgument)].length);
      69           0 :   if (!resultStr) {
      70           0 :     return false;
      71             :   }
      72           0 :   aValue.setString(resultStr);
      73           0 :   return true;
      74             : }
      75             : 
      76             : 
      77             : namespace ScreenOrientationBinding {
      78             : 
      79             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      80             :               "Can't inherit from an interface with a different ownership model.");
      81             : 
      82             : static bool
      83           0 : lock(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, const JSJitMethodCallArgs& args)
      84             : {
      85           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      86           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ScreenOrientation.lock");
      87             :   }
      88           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
      89             :       // Return false from the JSNative in order to trigger
      90             :       // an uncatchable exception.
      91           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
      92           0 :       return false;
      93             :   }
      94             :   OrientationLockType arg0;
      95             :   {
      96             :     int index;
      97           0 :     if (!FindEnumStringIndex<true>(cx, args[0], OrientationLockTypeValues::strings, "OrientationLockType", "Argument 1 of ScreenOrientation.lock", &index)) {
      98           0 :       return false;
      99             :     }
     100           0 :     MOZ_ASSERT(index >= 0);
     101           0 :     arg0 = static_cast<OrientationLockType>(index);
     102             :   }
     103           0 :   binding_detail::FastErrorResult rv;
     104           0 :   auto result(StrongOrRawPtr<Promise>(self->Lock(arg0, rv)));
     105           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     106           0 :     return false;
     107             :   }
     108           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     109           0 :   if (!ToJSValue(cx, result, args.rval())) {
     110           0 :     return false;
     111             :   }
     112           0 :   return true;
     113             : }
     114             : 
     115             : static bool
     116           0 : lock_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, const JSJitMethodCallArgs& args)
     117             : {
     118             :   // Make sure to save the callee before someone maybe messes
     119             :   // with rval().
     120           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     121           0 :   bool ok = lock(cx, obj, self, args);
     122           0 :   if (ok) {
     123           0 :     return true;
     124             :   }
     125           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     126           0 :                                    args.rval());
     127             : }
     128             : 
     129             : static const JSJitInfo lock_methodinfo = {
     130             :   { (JSJitGetterOp)lock_promiseWrapper },
     131             :   { prototypes::id::ScreenOrientation },
     132             :   { PrototypeTraits<prototypes::id::ScreenOrientation>::Depth },
     133             :   JSJitInfo::Method,
     134             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     135             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     136             :   false,  /* isInfallible. False in setters. */
     137             :   false,  /* isMovable.  Not relevant for setters. */
     138             :   false, /* isEliminatable.  Not relevant for setters. */
     139             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     140             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     141             :   false,  /* isTypedMethod.  Only relevant for methods. */
     142             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     143             : };
     144             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     145             : static_assert(0 < 1, "There is no slot for us");
     146             : 
     147             : static bool
     148           0 : unlock(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, const JSJitMethodCallArgs& args)
     149             : {
     150           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     151             :       // Return false from the JSNative in order to trigger
     152             :       // an uncatchable exception.
     153           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     154           0 :       return false;
     155             :   }
     156           0 :   binding_detail::FastErrorResult rv;
     157           0 :   self->Unlock(rv);
     158           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     159           0 :     return false;
     160             :   }
     161           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     162           0 :   args.rval().setUndefined();
     163           0 :   return true;
     164             : }
     165             : 
     166             : static const JSJitInfo unlock_methodinfo = {
     167             :   { (JSJitGetterOp)unlock },
     168             :   { prototypes::id::ScreenOrientation },
     169             :   { PrototypeTraits<prototypes::id::ScreenOrientation>::Depth },
     170             :   JSJitInfo::Method,
     171             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     172             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     173             :   false,  /* isInfallible. False in setters. */
     174             :   false,  /* isMovable.  Not relevant for setters. */
     175             :   false, /* isEliminatable.  Not relevant for setters. */
     176             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     177             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     178             :   false,  /* isTypedMethod.  Only relevant for methods. */
     179             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     180             : };
     181             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     182             : static_assert(0 < 1, "There is no slot for us");
     183             : 
     184             : static bool
     185           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, JSJitGetterCallArgs args)
     186             : {
     187           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     188             :       // Return false from the JSNative in order to trigger
     189             :       // an uncatchable exception.
     190           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     191           0 :       return false;
     192             :   }
     193           0 :   binding_detail::FastErrorResult rv;
     194           0 :   OrientationType result(self->GetType(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv));
     195           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     196           0 :     return false;
     197             :   }
     198           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     199           0 :   if (!ToJSValue(cx, result, args.rval())) {
     200           0 :     return false;
     201             :   }
     202           0 :   return true;
     203             : }
     204             : 
     205             : static const JSJitInfo type_getterinfo = {
     206             :   { (JSJitGetterOp)get_type },
     207             :   { prototypes::id::ScreenOrientation },
     208             :   { PrototypeTraits<prototypes::id::ScreenOrientation>::Depth },
     209             :   JSJitInfo::Getter,
     210             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     211             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     212             :   false,  /* isInfallible. False in setters. */
     213             :   false,  /* isMovable.  Not relevant for setters. */
     214             :   false, /* isEliminatable.  Not relevant for setters. */
     215             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     216             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     217             :   false,  /* isTypedMethod.  Only relevant for methods. */
     218             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     219             : };
     220             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     221             : static_assert(0 < 1, "There is no slot for us");
     222             : 
     223             : static bool
     224           0 : get_angle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, JSJitGetterCallArgs args)
     225             : {
     226           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     227             :       // Return false from the JSNative in order to trigger
     228             :       // an uncatchable exception.
     229           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     230           0 :       return false;
     231             :   }
     232           0 :   binding_detail::FastErrorResult rv;
     233           0 :   uint16_t result(self->GetAngle(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv));
     234           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     235           0 :     return false;
     236             :   }
     237           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     238           0 :   args.rval().setInt32(int32_t(result));
     239           0 :   return true;
     240             : }
     241             : 
     242             : static const JSJitInfo angle_getterinfo = {
     243             :   { (JSJitGetterOp)get_angle },
     244             :   { prototypes::id::ScreenOrientation },
     245             :   { PrototypeTraits<prototypes::id::ScreenOrientation>::Depth },
     246             :   JSJitInfo::Getter,
     247             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     248             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     249             :   false,  /* isInfallible. False in setters. */
     250             :   false,  /* isMovable.  Not relevant for setters. */
     251             :   false, /* isEliminatable.  Not relevant for setters. */
     252             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     253             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     254             :   false,  /* isTypedMethod.  Only relevant for methods. */
     255             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     256             : };
     257             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     258             : static_assert(0 < 1, "There is no slot for us");
     259             : 
     260             : static bool
     261           0 : get_onchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, JSJitGetterCallArgs args)
     262             : {
     263           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     264             :       // Return false from the JSNative in order to trigger
     265             :       // an uncatchable exception.
     266           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     267           0 :       return false;
     268             :   }
     269           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnchange());
     270           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     271           0 :   if (result) {
     272           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     273           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     274           0 :       return false;
     275             :     }
     276           0 :     return true;
     277             :   } else {
     278           0 :     args.rval().setNull();
     279           0 :     return true;
     280             :   }
     281             : }
     282             : 
     283             : static bool
     284           0 : set_onchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScreenOrientation* self, JSJitSetterCallArgs args)
     285             : {
     286           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     287             :       // Return false from the JSNative in order to trigger
     288             :       // an uncatchable exception.
     289           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     290           0 :       return false;
     291             :   }
     292           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     293           0 :   if (args[0].isObject()) {
     294             :     { // scope for tempRoot
     295           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     296           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     297             :     }
     298             :   } else {
     299           0 :     arg0 = nullptr;
     300             :   }
     301           0 :   self->SetOnchange(Constify(arg0));
     302           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     303             : 
     304           0 :   return true;
     305             : }
     306             : 
     307             : static const JSJitInfo onchange_getterinfo = {
     308             :   { (JSJitGetterOp)get_onchange },
     309             :   { prototypes::id::ScreenOrientation },
     310             :   { PrototypeTraits<prototypes::id::ScreenOrientation>::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             : static const JSJitInfo onchange_setterinfo = {
     325             :   { (JSJitGetterOp)set_onchange },
     326             :   { prototypes::id::ScreenOrientation },
     327             :   { PrototypeTraits<prototypes::id::ScreenOrientation>::Depth },
     328             :   JSJitInfo::Setter,
     329             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     330             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     331             :   false,  /* isInfallible. False in setters. */
     332             :   false,  /* isMovable.  Not relevant for setters. */
     333             :   false, /* isEliminatable.  Not relevant for setters. */
     334             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     335             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     336             :   false,  /* isTypedMethod.  Only relevant for methods. */
     337             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     338             : };
     339             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     340             : static_assert(0 < 1, "There is no slot for us");
     341             : 
     342             : static bool
     343           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     344             : {
     345           0 :   mozilla::dom::ScreenOrientation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScreenOrientation>(obj);
     346             :   // We don't want to preserve if we don't have a wrapper, and we
     347             :   // obviously can't preserve if we're not initialized.
     348           0 :   if (self && self->GetWrapperPreserveColor()) {
     349           0 :     PreserveWrapper(self);
     350             :   }
     351           0 :   return true;
     352             : }
     353             : 
     354             : static void
     355           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     356             : {
     357           0 :   mozilla::dom::ScreenOrientation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScreenOrientation>(obj);
     358           0 :   if (self) {
     359           0 :     ClearWrapper(self, self, obj);
     360           0 :     AddForDeferredFinalization<mozilla::dom::ScreenOrientation>(self);
     361             :   }
     362           0 : }
     363             : 
     364             : static void
     365           0 : _objectMoved(JSObject* obj, const JSObject* old)
     366             : {
     367           0 :   mozilla::dom::ScreenOrientation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScreenOrientation>(obj);
     368           0 :   if (self) {
     369           0 :     UpdateWrapper(self, self, obj, old);
     370             :   }
     371           0 : }
     372             : 
     373             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     374             : #if defined(__clang__)
     375             : #pragma clang diagnostic push
     376             : #pragma clang diagnostic ignored "-Wmissing-braces"
     377             : #endif
     378             : static const JSFunctionSpec sMethods_specs[] = {
     379             :   JS_FNSPEC("lock", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&lock_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     380             :   JS_FNSPEC("unlock", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&unlock_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     381             :   JS_FS_END
     382             : };
     383             : #if defined(__clang__)
     384             : #pragma clang diagnostic pop
     385             : #endif
     386             : 
     387             : 
     388             : // Can't be const because the pref-enabled boolean needs to be writable
     389             : static Prefable<const JSFunctionSpec> sMethods[] = {
     390             :   { nullptr, &sMethods_specs[0] },
     391             :   { nullptr, nullptr }
     392             : };
     393             : 
     394             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     395             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     396             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     397             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     398             : 
     399             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     400             : #if defined(__clang__)
     401             : #pragma clang diagnostic push
     402             : #pragma clang diagnostic ignored "-Wmissing-braces"
     403             : #endif
     404             : static const JSPropertySpec sAttributes_specs[] = {
     405             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
     406             :   { "angle", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &angle_getterinfo, nullptr, nullptr },
     407             :   { "onchange", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onchange_getterinfo, GenericBindingSetter, &onchange_setterinfo },
     408             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     409             : };
     410             : #if defined(__clang__)
     411             : #pragma clang diagnostic pop
     412             : #endif
     413             : 
     414             : 
     415             : // Can't be const because the pref-enabled boolean needs to be writable
     416             : static Prefable<const JSPropertySpec> sAttributes[] = {
     417             :   { nullptr, &sAttributes_specs[0] },
     418             :   { nullptr, nullptr }
     419             : };
     420             : 
     421             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     422             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     423             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     424             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     425             : 
     426             : 
     427             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
     428             : static PropertyInfo sNativeProperties_propertyInfos[5];
     429             : 
     430             : static const NativePropertiesN<2> sNativeProperties = {
     431             :   false, 0,
     432             :   false, 0,
     433             :   true,  0 /* sMethods */,
     434             :   true,  1 /* sAttributes */,
     435             :   false, 0,
     436             :   false, 0,
     437             :   false, 0,
     438             :   -1,
     439             :   5,
     440             :   sNativeProperties_sortedPropertyIndices,
     441             :   {
     442             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     443             :     { sAttributes, &sNativeProperties_propertyInfos[2] }
     444             :   }
     445             : };
     446             : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     447             :     "We have a property info count that is oversized");
     448             : 
     449             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     450             :   {
     451             :     "Function",
     452             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     453             :     &sBoringInterfaceObjectClassClassOps,
     454             :     JS_NULL_CLASS_SPEC,
     455             :     JS_NULL_CLASS_EXT,
     456             :     &sInterfaceObjectClassObjectOps
     457             :   },
     458             :   eInterface,
     459             :   true,
     460             :   prototypes::id::ScreenOrientation,
     461             :   PrototypeTraits<prototypes::id::ScreenOrientation>::Depth,
     462             :   sNativePropertyHooks,
     463             :   "function ScreenOrientation() {\n    [native code]\n}",
     464             :   EventTargetBinding::GetConstructorObject
     465             : };
     466             : 
     467             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     468             :   {
     469             :     "ScreenOrientationPrototype",
     470             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     471             :     JS_NULL_CLASS_OPS,
     472             :     JS_NULL_CLASS_SPEC,
     473             :     JS_NULL_CLASS_EXT,
     474             :     JS_NULL_OBJECT_OPS
     475             :   },
     476             :   eInterfacePrototype,
     477             :   false,
     478             :   prototypes::id::ScreenOrientation,
     479             :   PrototypeTraits<prototypes::id::ScreenOrientation>::Depth,
     480             :   sNativePropertyHooks,
     481             :   "[object ScreenOrientationPrototype]",
     482             :   EventTargetBinding::GetProtoObject
     483             : };
     484             : 
     485             : JSObject*
     486           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     487             : {
     488           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     489             : }
     490             : 
     491             : static const js::ClassOps sClassOps = {
     492             :   _addProperty, /* addProperty */
     493             :   nullptr,               /* delProperty */
     494             :   nullptr,               /* getProperty */
     495             :   nullptr,               /* setProperty */
     496             :   nullptr,               /* enumerate */
     497             :   nullptr, /* newEnumerate */
     498             :   nullptr, /* resolve */
     499             :   nullptr, /* mayResolve */
     500             :   _finalize, /* finalize */
     501             :   nullptr, /* call */
     502             :   nullptr,               /* hasInstance */
     503             :   nullptr,               /* construct */
     504             :   nullptr, /* trace */
     505             : };
     506             : 
     507             : static const js::ClassExtension sClassExtension = {
     508             :   nullptr, /* weakmapKeyDelegateOp */
     509             :   _objectMoved /* objectMovedOp */
     510             : };
     511             : 
     512             : static const DOMJSClass sClass = {
     513             :   { "ScreenOrientation",
     514             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     515             :     &sClassOps,
     516             :     JS_NULL_CLASS_SPEC,
     517             :     &sClassExtension,
     518             :     JS_NULL_OBJECT_OPS
     519             :   },
     520             :   { prototypes::id::EventTarget, prototypes::id::ScreenOrientation, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     521             :   IsBaseOf<nsISupports, mozilla::dom::ScreenOrientation >::value,
     522             :   sNativePropertyHooks,
     523             :   FindAssociatedGlobalForNative<mozilla::dom::ScreenOrientation>::Get,
     524             :   GetProtoObjectHandle,
     525             :   GetCCParticipant<mozilla::dom::ScreenOrientation>::Get()
     526             : };
     527             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     528             :               "Must have the right minimal number of reserved slots.");
     529             : static_assert(1 >= 1,
     530             :               "Must have enough reserved slots.");
     531             : 
     532             : const JSClass*
     533           0 : GetJSClass()
     534             : {
     535           0 :   return sClass.ToJSClass();
     536             : }
     537             : 
     538             : bool
     539           0 : Wrap(JSContext* aCx, mozilla::dom::ScreenOrientation* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     540             : {
     541             :   MOZ_ASSERT(static_cast<mozilla::dom::ScreenOrientation*>(aObject) ==
     542             :              reinterpret_cast<mozilla::dom::ScreenOrientation*>(aObject),
     543             :              "Multiple inheritance for mozilla::dom::ScreenOrientation is broken.");
     544             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     545             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     546             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     547           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     548           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     549           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     550             :              "You should probably not be using Wrap() directly; use "
     551             :              "GetOrCreateDOMReflector instead");
     552             : 
     553           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     554             :              "nsISupports must be on our primary inheritance chain");
     555             : 
     556           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     557           0 :   if (!global) {
     558           0 :     return false;
     559             :   }
     560           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     561           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     562             : 
     563             :   // That might have ended up wrapping us already, due to the wonders
     564             :   // of XBL.  Check for that, and bail out as needed.
     565           0 :   aReflector.set(aCache->GetWrapper());
     566           0 :   if (aReflector) {
     567             : #ifdef DEBUG
     568           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     569             : #endif // DEBUG
     570           0 :     return true;
     571             :   }
     572             : 
     573           0 :   JSAutoCompartment ac(aCx, global);
     574           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     575           0 :   if (!canonicalProto) {
     576           0 :     return false;
     577             :   }
     578           0 :   JS::Rooted<JSObject*> proto(aCx);
     579           0 :   if (aGivenProto) {
     580           0 :     proto = aGivenProto;
     581             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     582             :     // coming in, we changed compartments to that of "parent" so may need
     583             :     // to wrap the proto here.
     584           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     585           0 :       if (!JS_WrapObject(aCx, &proto)) {
     586           0 :         return false;
     587             :       }
     588             :     }
     589             :   } else {
     590           0 :     proto = canonicalProto;
     591             :   }
     592             : 
     593           0 :   BindingJSObjectCreator<mozilla::dom::ScreenOrientation> creator(aCx);
     594           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     595           0 :   if (!aReflector) {
     596           0 :     return false;
     597             :   }
     598             : 
     599           0 :   aCache->SetWrapper(aReflector);
     600           0 :   creator.InitializationSucceeded();
     601             : 
     602           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     603             :              aCache->GetWrapperPreserveColor() == aReflector);
     604             :   // If proto != canonicalProto, we have to preserve our wrapper;
     605             :   // otherwise we won't be able to properly recreate it later, since
     606             :   // we won't know what proto to use.  Note that we don't check
     607             :   // aGivenProto here, since it's entirely possible (and even
     608             :   // somewhat common) to have a non-null aGivenProto which is the
     609             :   // same as canonicalProto.
     610           0 :   if (proto != canonicalProto) {
     611           0 :     PreserveWrapper(aObject);
     612             :   }
     613             : 
     614           0 :   return true;
     615             : }
     616             : 
     617             : const NativePropertyHooks sNativePropertyHooks[] = { {
     618             :   nullptr,
     619             :   nullptr,
     620             :   nullptr,
     621             :   { sNativeProperties.Upcast(), nullptr },
     622             :   prototypes::id::ScreenOrientation,
     623             :   constructors::id::ScreenOrientation,
     624             :   EventTargetBinding::sNativePropertyHooks,
     625             :   &DefaultXrayExpandoObjectClass
     626             : } };
     627             : 
     628             : void
     629           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     630             : {
     631           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     632           0 :   if (!parentProto) {
     633           0 :     return;
     634             :   }
     635             : 
     636           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     637           0 :   if (!constructorProto) {
     638           0 :     return;
     639             :   }
     640             : 
     641             :   static bool sIdsInited = false;
     642           0 :   if (!sIdsInited && NS_IsMainThread()) {
     643           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     644           0 :       return;
     645             :     }
     646           0 :     sIdsInited = true;
     647             :   }
     648             : 
     649           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ScreenOrientation);
     650           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ScreenOrientation);
     651           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     652             :                               &sPrototypeClass.mBase, protoCache,
     653             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     654             :                               interfaceCache,
     655             :                               sNativeProperties.Upcast(),
     656             :                               nullptr,
     657             :                               "ScreenOrientation", aDefineOnGlobal,
     658             :                               nullptr,
     659           0 :                               false);
     660             : }
     661             : 
     662             : JS::Handle<JSObject*>
     663           0 : GetProtoObjectHandle(JSContext* aCx)
     664             : {
     665             :   /* Get the interface prototype object for this class.  This will create the
     666             :      object as needed. */
     667           0 :   bool aDefineOnGlobal = true;
     668             : 
     669             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     670           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     671           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     672           0 :     return nullptr;
     673             :   }
     674             : 
     675             :   /* Check to see whether the interface objects are already installed */
     676           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     677           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::ScreenOrientation)) {
     678           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     679           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     680             :   }
     681             : 
     682             :   /*
     683             :    * The object might _still_ be null, but that's OK.
     684             :    *
     685             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     686             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     687             :    * changed after they have been set.
     688             :    *
     689             :    * Calling address() avoids the read read barrier that does gray
     690             :    * unmarking, but it's not possible for the object to be gray here.
     691             :    */
     692             : 
     693           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::ScreenOrientation);
     694           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     695           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     696             : }
     697             : 
     698             : JS::Handle<JSObject*>
     699           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     700             : {
     701             :   /* Get the interface object for this class.  This will create the object as
     702             :      needed. */
     703             : 
     704             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     705           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     706           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     707           0 :     return nullptr;
     708             :   }
     709             : 
     710             :   /* Check to see whether the interface objects are already installed */
     711           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     712           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::ScreenOrientation)) {
     713           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     714           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     715             :   }
     716             : 
     717             :   /*
     718             :    * The object might _still_ be null, but that's OK.
     719             :    *
     720             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     721             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     722             :    * changed after they have been set.
     723             :    *
     724             :    * Calling address() avoids the read read barrier that does gray
     725             :    * unmarking, but it's not possible for the object to be gray here.
     726             :    */
     727             : 
     728           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::ScreenOrientation);
     729           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     730           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     731             : }
     732             : 
     733             : JSObject*
     734           0 : GetConstructorObject(JSContext* aCx)
     735             : {
     736           0 :   return GetConstructorObjectHandle(aCx);
     737             : }
     738             : 
     739             : } // namespace ScreenOrientationBinding
     740             : 
     741             : 
     742             : 
     743             : } // namespace dom
     744             : } // namespace mozilla

Generated by: LCOV version 1.13