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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM ScrollViewChangeEvent.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "EventBinding.h"
       5             : #include "ScrollViewChangeEventBinding.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/PrimitiveConversions.h"
      13             : #include "mozilla/dom/ScriptSettings.h"
      14             : #include "mozilla/dom/ScrollViewChangeEvent.h"
      15             : #include "mozilla/dom/SimpleGlobalObject.h"
      16             : #include "mozilla/dom/XrayExpandoClass.h"
      17             : #include "nsContentUtils.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace ScrollStateValues {
      23             : extern const EnumEntry strings[3] = {
      24             :   {"started", 7},
      25             :   {"stopped", 7},
      26             :   { nullptr, 0 }
      27             : };
      28             : } // namespace ScrollStateValues
      29             : 
      30             : bool
      31           0 : ToJSValue(JSContext* aCx, ScrollState aArgument, JS::MutableHandle<JS::Value> aValue)
      32             : {
      33           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ScrollStateValues::strings));
      34             :   JSString* resultStr =
      35           0 :     JS_NewStringCopyN(aCx, ScrollStateValues::strings[uint32_t(aArgument)].value,
      36           0 :                       ScrollStateValues::strings[uint32_t(aArgument)].length);
      37           0 :   if (!resultStr) {
      38           0 :     return false;
      39             :   }
      40           0 :   aValue.setString(resultStr);
      41           0 :   return true;
      42             : }
      43             : 
      44             : 
      45             : 
      46           0 : ScrollViewChangeEventInit::ScrollViewChangeEventInit()
      47           0 :   : EventInit(FastDictionaryInitializer())
      48             : {
      49             :   // Safe to pass a null context if we pass a null value
      50           0 :   Init(nullptr, JS::NullHandleValue);
      51           0 : }
      52             : 
      53             : 
      54             : 
      55             : bool
      56           0 : ScrollViewChangeEventInit::InitIds(JSContext* cx, ScrollViewChangeEventInitAtoms* atomsCache)
      57             : {
      58           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      59             : 
      60             :   // Initialize these in reverse order so that any failure leaves the first one
      61             :   // uninitialized.
      62           0 :   if (!atomsCache->state_id.init(cx, "state")) {
      63           0 :     return false;
      64             :   }
      65           0 :   return true;
      66             : }
      67             : 
      68             : bool
      69           0 : ScrollViewChangeEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      70             : {
      71             :   // Passing a null JSContext is OK only if we're initing from null,
      72             :   // Since in that case we will not have to do any property gets
      73             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      74             :   // checkers by static analysis tools
      75           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      76           0 :   ScrollViewChangeEventInitAtoms* atomsCache = nullptr;
      77           0 :   if (cx) {
      78           0 :     atomsCache = GetAtomCache<ScrollViewChangeEventInitAtoms>(cx);
      79           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      80           0 :       return false;
      81             :     }
      82             :   }
      83             : 
      84             :   // Per spec, we init the parent's members first
      85           0 :   if (!EventInit::Init(cx, val)) {
      86           0 :     return false;
      87             :   }
      88             : 
      89           0 :   bool isNull = val.isNullOrUndefined();
      90             :   // We only need these if !isNull, in which case we have |cx|.
      91           0 :   Maybe<JS::Rooted<JSObject *> > object;
      92           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      93           0 :   if (!isNull) {
      94           0 :     MOZ_ASSERT(cx);
      95           0 :     object.emplace(cx, &val.toObject());
      96           0 :     temp.emplace(cx);
      97             :   }
      98           0 :   if (!isNull) {
      99           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->state_id, temp.ptr())) {
     100           0 :       return false;
     101             :     }
     102             :   }
     103           0 :   if (!isNull && !temp->isUndefined()) {
     104             :     {
     105             :       int index;
     106           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), ScrollStateValues::strings, "ScrollState", "'state' member of ScrollViewChangeEventInit", &index)) {
     107           0 :         return false;
     108             :       }
     109           0 :       MOZ_ASSERT(index >= 0);
     110           0 :       mState = static_cast<ScrollState>(index);
     111             :     }
     112             :   } else {
     113           0 :     mState = ScrollState::Started;
     114             :   }
     115           0 :   mIsAnyMemberPresent = true;
     116           0 :   return true;
     117             : }
     118             : 
     119             : bool
     120           0 : ScrollViewChangeEventInit::Init(const nsAString& aJSON)
     121             : {
     122           0 :   AutoJSAPI jsapi;
     123           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     124           0 :   if (!cleanGlobal) {
     125           0 :     return false;
     126             :   }
     127           0 :   if (!jsapi.Init(cleanGlobal)) {
     128           0 :     return false;
     129             :   }
     130           0 :   JSContext* cx = jsapi.cx();
     131           0 :   JS::Rooted<JS::Value> json(cx);
     132           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     133           0 :   NS_ENSURE_TRUE(ok, false);
     134           0 :   return Init(cx, json);
     135             : }
     136             : 
     137             : bool
     138           0 : ScrollViewChangeEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     139             : {
     140           0 :   ScrollViewChangeEventInitAtoms* atomsCache = GetAtomCache<ScrollViewChangeEventInitAtoms>(cx);
     141           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     142           0 :     return false;
     143             :   }
     144             : 
     145             :   // Per spec, we define the parent's members first
     146           0 :   if (!EventInit::ToObjectInternal(cx, rval)) {
     147           0 :     return false;
     148             :   }
     149           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     150             : 
     151             :   do {
     152             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     153           0 :     JS::Rooted<JS::Value> temp(cx);
     154           0 :     ScrollState const & currentValue = mState;
     155           0 :     if (!ToJSValue(cx, currentValue, &temp)) {
     156           0 :       return false;
     157             :     }
     158           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->state_id, temp, JSPROP_ENUMERATE)) {
     159           0 :       return false;
     160             :     }
     161           0 :     break;
     162             :   } while(0);
     163             : 
     164           0 :   return true;
     165             : }
     166             : 
     167             : bool
     168           0 : ScrollViewChangeEventInit::ToJSON(nsAString& aJSON) const
     169             : {
     170           0 :   AutoJSAPI jsapi;
     171           0 :   jsapi.Init();
     172           0 :   JSContext *cx = jsapi.cx();
     173             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     174             :   // because we'll only be creating objects, in ways that have no
     175             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     176             :   // which likewise guarantees no side-effects for the sorts of
     177             :   // things we will pass it.
     178           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     179           0 :   JS::Rooted<JS::Value> val(cx);
     180           0 :   if (!ToObjectInternal(cx, &val)) {
     181           0 :     return false;
     182             :   }
     183           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     184           0 :   return StringifyToJSON(cx, obj, aJSON);
     185             : }
     186             : 
     187             : void
     188           0 : ScrollViewChangeEventInit::TraceDictionary(JSTracer* trc)
     189             : {
     190           0 :   EventInit::TraceDictionary(trc);
     191           0 : }
     192             : 
     193             : ScrollViewChangeEventInit&
     194           0 : ScrollViewChangeEventInit::operator=(const ScrollViewChangeEventInit& aOther)
     195             : {
     196           0 :   EventInit::operator=(aOther);
     197           0 :   mState = aOther.mState;
     198           0 :   return *this;
     199             : }
     200             : 
     201             : namespace binding_detail {
     202             : } // namespace binding_detail
     203             : 
     204             : 
     205             : namespace ScrollViewChangeEventBinding {
     206             : 
     207             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventBinding::NativeType>::value,
     208             :               "Can't inherit from an interface with a different ownership model.");
     209             : 
     210             : static bool
     211           0 : get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScrollViewChangeEvent* self, JSJitGetterCallArgs args)
     212             : {
     213           0 :   ScrollState result(self->State());
     214           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     215           0 :   if (!ToJSValue(cx, result, args.rval())) {
     216           0 :     return false;
     217             :   }
     218           0 :   return true;
     219             : }
     220             : 
     221             : static const JSJitInfo state_getterinfo = {
     222             :   { (JSJitGetterOp)get_state },
     223             :   { prototypes::id::ScrollViewChangeEvent },
     224             :   { PrototypeTraits<prototypes::id::ScrollViewChangeEvent>::Depth },
     225             :   JSJitInfo::Getter,
     226             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     227             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     228             :   false,  /* isInfallible. False in setters. */
     229             :   false,  /* isMovable.  Not relevant for setters. */
     230             :   false, /* isEliminatable.  Not relevant for setters. */
     231             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     232             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     233             :   false,  /* isTypedMethod.  Only relevant for methods. */
     234             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     235             : };
     236             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     237             : static_assert(0 < 1, "There is no slot for us");
     238             : 
     239             : static bool
     240           0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ScrollViewChangeEvent* self, JSJitGetterCallArgs args)
     241             : {
     242           0 :   bool result(self->IsTrusted());
     243           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     244           0 :   args.rval().setBoolean(result);
     245           0 :   return true;
     246             : }
     247             : 
     248             : static const JSJitInfo isTrusted_getterinfo = {
     249             :   { (JSJitGetterOp)get_isTrusted },
     250             :   { prototypes::id::ScrollViewChangeEvent },
     251             :   { PrototypeTraits<prototypes::id::ScrollViewChangeEvent>::Depth },
     252             :   JSJitInfo::Getter,
     253             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     254             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     255             :   true,  /* isInfallible. False in setters. */
     256             :   true,  /* isMovable.  Not relevant for setters. */
     257             :   true, /* isEliminatable.  Not relevant for setters. */
     258             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     259             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     260             :   false,  /* isTypedMethod.  Only relevant for methods. */
     261             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     262             : };
     263             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     264             : static_assert(0 < 1, "There is no slot for us");
     265             : 
     266             : static bool
     267           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     268             : {
     269           0 :   mozilla::dom::ScrollViewChangeEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScrollViewChangeEvent>(obj);
     270             :   // We don't want to preserve if we don't have a wrapper, and we
     271             :   // obviously can't preserve if we're not initialized.
     272           0 :   if (self && self->GetWrapperPreserveColor()) {
     273           0 :     PreserveWrapper(self);
     274             :   }
     275           0 :   return true;
     276             : }
     277             : 
     278             : static void
     279           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     280             : {
     281           0 :   mozilla::dom::ScrollViewChangeEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScrollViewChangeEvent>(obj);
     282           0 :   if (self) {
     283           0 :     ClearWrapper(self, self, obj);
     284           0 :     AddForDeferredFinalization<mozilla::dom::ScrollViewChangeEvent>(self);
     285             :   }
     286           0 : }
     287             : 
     288             : static void
     289           0 : _objectMoved(JSObject* obj, const JSObject* old)
     290             : {
     291           0 :   mozilla::dom::ScrollViewChangeEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ScrollViewChangeEvent>(obj);
     292           0 :   if (self) {
     293           0 :     UpdateWrapper(self, self, obj, old);
     294             :   }
     295           0 : }
     296             : 
     297             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     298             : #if defined(__clang__)
     299             : #pragma clang diagnostic push
     300             : #pragma clang diagnostic ignored "-Wmissing-braces"
     301             : #endif
     302             : static const JSPropertySpec sAttributes_specs[] = {
     303             :   { "state", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &state_getterinfo, nullptr, nullptr },
     304             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     305             : };
     306             : #if defined(__clang__)
     307             : #pragma clang diagnostic pop
     308             : #endif
     309             : 
     310             : 
     311             : // Can't be const because the pref-enabled boolean needs to be writable
     312             : static Prefable<const JSPropertySpec> sAttributes[] = {
     313             :   { nullptr, &sAttributes_specs[0] },
     314             :   { nullptr, nullptr }
     315             : };
     316             : 
     317             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     318             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     319             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     320             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     321             : 
     322             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     323             : #if defined(__clang__)
     324             : #pragma clang diagnostic push
     325             : #pragma clang diagnostic ignored "-Wmissing-braces"
     326             : #endif
     327             : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
     328             :   { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
     329             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     330             : };
     331             : #if defined(__clang__)
     332             : #pragma clang diagnostic pop
     333             : #endif
     334             : 
     335             : 
     336             : // Can't be const because the pref-enabled boolean needs to be writable
     337             : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
     338             :   { nullptr, &sUnforgeableAttributes_specs[0] },
     339             :   { nullptr, nullptr }
     340             : };
     341             : 
     342             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     343             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     344             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     345             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     346             : 
     347             : 
     348             : static uint16_t sNativeProperties_sortedPropertyIndices[2];
     349             : static PropertyInfo sNativeProperties_propertyInfos[2];
     350             : 
     351             : static const NativePropertiesN<2> sNativeProperties = {
     352             :   false, 0,
     353             :   false, 0,
     354             :   false, 0,
     355             :   true,  0 /* sAttributes */,
     356             :   false, 0,
     357             :   true,  1 /* sUnforgeableAttributes */,
     358             :   false, 0,
     359             :   -1,
     360             :   2,
     361             :   sNativeProperties_sortedPropertyIndices,
     362             :   {
     363             :     { sAttributes, &sNativeProperties_propertyInfos[0] },
     364             :     { sUnforgeableAttributes, &sNativeProperties_propertyInfos[1] }
     365             :   }
     366             : };
     367             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     368             :     "We have a property info count that is oversized");
     369             : 
     370             : static bool
     371           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     372             : {
     373           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     374           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     375           0 :   if (!args.isConstructing()) {
     376             :     // XXXbz wish I could get the name from the callee instead of
     377             :     // Adding more relocations
     378           0 :     return ThrowConstructorWithoutNew(cx, "ScrollViewChangeEvent");
     379             :   }
     380             : 
     381           0 :   GlobalObject global(cx, obj);
     382           0 :   if (global.Failed()) {
     383           0 :     return false;
     384             :   }
     385             : 
     386           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     387           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     388           0 :     return false;
     389             :   }
     390             : 
     391           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     392           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ScrollViewChangeEvent");
     393             :   }
     394           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     395           0 :   binding_detail::FakeString arg0;
     396           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     397           0 :     return false;
     398             :   }
     399           0 :   binding_detail::FastScrollViewChangeEventInit arg1;
     400           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of ScrollViewChangeEvent.constructor", false)) {
     401           0 :     return false;
     402             :   }
     403           0 :   Maybe<JSAutoCompartment> ac;
     404           0 :   if (objIsXray) {
     405           0 :     obj = js::CheckedUnwrap(obj);
     406           0 :     if (!obj) {
     407           0 :       return false;
     408             :     }
     409           0 :     ac.emplace(cx, obj);
     410           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     411           0 :       return false;
     412             :     }
     413             :   }
     414           0 :   binding_detail::FastErrorResult rv;
     415           0 :   auto result(StrongOrRawPtr<mozilla::dom::ScrollViewChangeEvent>(mozilla::dom::ScrollViewChangeEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
     416           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     417           0 :     return false;
     418             :   }
     419           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     420             :   static_assert(!IsPointer<decltype(result)>::value,
     421             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     422           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     423           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     424           0 :     return false;
     425             :   }
     426           0 :   return true;
     427             : }
     428             : 
     429             : static const js::ClassOps sInterfaceObjectClassOps = {
     430             :     nullptr,               /* addProperty */
     431             :     nullptr,               /* delProperty */
     432             :     nullptr,               /* getProperty */
     433             :     nullptr,               /* setProperty */
     434             :     nullptr,               /* enumerate */
     435             :     nullptr,               /* newEnumerate */
     436             :     nullptr,               /* resolve */
     437             :     nullptr,               /* mayResolve */
     438             :     nullptr,               /* finalize */
     439             :     _constructor, /* call */
     440             :     nullptr,               /* hasInstance */
     441             :     _constructor, /* construct */
     442             :     nullptr,               /* trace */
     443             : };
     444             : 
     445             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     446             :   {
     447             :     "Function",
     448             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     449             :     &sInterfaceObjectClassOps,
     450             :     JS_NULL_CLASS_SPEC,
     451             :     JS_NULL_CLASS_EXT,
     452             :     &sInterfaceObjectClassObjectOps
     453             :   },
     454             :   eInterface,
     455             :   true,
     456             :   prototypes::id::ScrollViewChangeEvent,
     457             :   PrototypeTraits<prototypes::id::ScrollViewChangeEvent>::Depth,
     458             :   sNativePropertyHooks,
     459             :   "function ScrollViewChangeEvent() {\n    [native code]\n}",
     460             :   EventBinding::GetConstructorObject
     461             : };
     462             : 
     463             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     464             :   {
     465             :     "ScrollViewChangeEventPrototype",
     466             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
     467             :     JS_NULL_CLASS_OPS,
     468             :     JS_NULL_CLASS_SPEC,
     469             :     JS_NULL_CLASS_EXT,
     470             :     JS_NULL_OBJECT_OPS
     471             :   },
     472             :   eInterfacePrototype,
     473             :   false,
     474             :   prototypes::id::ScrollViewChangeEvent,
     475             :   PrototypeTraits<prototypes::id::ScrollViewChangeEvent>::Depth,
     476             :   sNativePropertyHooks,
     477             :   "[object ScrollViewChangeEventPrototype]",
     478             :   EventBinding::GetProtoObject
     479             : };
     480             : 
     481             : bool
     482           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     483             : {
     484           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
     485             : }
     486             : 
     487             : JSObject*
     488           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     489             : {
     490           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     491             : }
     492             : 
     493             : static const js::ClassOps sClassOps = {
     494             :   _addProperty, /* addProperty */
     495             :   nullptr,               /* delProperty */
     496             :   nullptr,               /* getProperty */
     497             :   nullptr,               /* setProperty */
     498             :   nullptr,               /* enumerate */
     499             :   nullptr, /* newEnumerate */
     500             :   nullptr, /* resolve */
     501             :   nullptr, /* mayResolve */
     502             :   _finalize, /* finalize */
     503             :   nullptr, /* call */
     504             :   nullptr,               /* hasInstance */
     505             :   nullptr,               /* construct */
     506             :   nullptr, /* trace */
     507             : };
     508             : 
     509             : static const js::ClassExtension sClassExtension = {
     510             :   nullptr, /* weakmapKeyDelegateOp */
     511             :   _objectMoved /* objectMovedOp */
     512             : };
     513             : 
     514             : static const DOMJSClass sClass = {
     515             :   { "ScrollViewChangeEvent",
     516             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
     517             :     &sClassOps,
     518             :     JS_NULL_CLASS_SPEC,
     519             :     &sClassExtension,
     520             :     JS_NULL_OBJECT_OPS
     521             :   },
     522             :   { prototypes::id::Event, prototypes::id::ScrollViewChangeEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     523             :   IsBaseOf<nsISupports, mozilla::dom::ScrollViewChangeEvent >::value,
     524             :   sNativePropertyHooks,
     525             :   FindAssociatedGlobalForNative<mozilla::dom::ScrollViewChangeEvent>::Get,
     526             :   GetProtoObjectHandle,
     527             :   GetCCParticipant<mozilla::dom::ScrollViewChangeEvent>::Get()
     528             : };
     529             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     530             :               "Must have the right minimal number of reserved slots.");
     531             : static_assert(1 >= 1,
     532             :               "Must have enough reserved slots.");
     533             : 
     534             : const JSClass*
     535           0 : GetJSClass()
     536             : {
     537           0 :   return sClass.ToJSClass();
     538             : }
     539             : 
     540             : bool
     541           0 : Wrap(JSContext* aCx, mozilla::dom::ScrollViewChangeEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     542             : {
     543             :   MOZ_ASSERT(static_cast<mozilla::dom::ScrollViewChangeEvent*>(aObject) ==
     544             :              reinterpret_cast<mozilla::dom::ScrollViewChangeEvent*>(aObject),
     545             :              "Multiple inheritance for mozilla::dom::ScrollViewChangeEvent is broken.");
     546             :   MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
     547             :              reinterpret_cast<mozilla::dom::Event*>(aObject),
     548             :              "Multiple inheritance for mozilla::dom::Event is broken.");
     549           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     550           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     551           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     552             :              "You should probably not be using Wrap() directly; use "
     553             :              "GetOrCreateDOMReflector instead");
     554             : 
     555           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     556             :              "nsISupports must be on our primary inheritance chain");
     557             : 
     558           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     559           0 :   if (!global) {
     560           0 :     return false;
     561             :   }
     562           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     563           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     564             : 
     565             :   // That might have ended up wrapping us already, due to the wonders
     566             :   // of XBL.  Check for that, and bail out as needed.
     567           0 :   aReflector.set(aCache->GetWrapper());
     568           0 :   if (aReflector) {
     569             : #ifdef DEBUG
     570           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     571             : #endif // DEBUG
     572           0 :     return true;
     573             :   }
     574             : 
     575           0 :   JSAutoCompartment ac(aCx, global);
     576           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     577           0 :   if (!canonicalProto) {
     578           0 :     return false;
     579             :   }
     580           0 :   JS::Rooted<JSObject*> proto(aCx);
     581           0 :   if (aGivenProto) {
     582           0 :     proto = aGivenProto;
     583             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     584             :     // coming in, we changed compartments to that of "parent" so may need
     585             :     // to wrap the proto here.
     586           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     587           0 :       if (!JS_WrapObject(aCx, &proto)) {
     588           0 :         return false;
     589             :       }
     590             :     }
     591             :   } else {
     592           0 :     proto = canonicalProto;
     593             :   }
     594             : 
     595           0 :   BindingJSObjectCreator<mozilla::dom::ScrollViewChangeEvent> creator(aCx);
     596           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     597           0 :   if (!aReflector) {
     598           0 :     return false;
     599             :   }
     600             : 
     601           0 :   aCache->SetWrapper(aReflector);
     602             : 
     603             :   // Important: do unforgeable property setup after we have handed
     604             :   // over ownership of the C++ object to obj as needed, so that if
     605             :   // we fail and it ends up GCed it won't have problems in the
     606             :   // finalizer trying to drop its ownership of the C++ object.
     607             :   JS::Rooted<JSObject*> unforgeableHolder(aCx,
     608           0 :     &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
     609           0 :   if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
     610           0 :     aCache->ReleaseWrapper(aObject);
     611           0 :     aCache->ClearWrapper();
     612           0 :     return false;
     613             :   }
     614           0 :   creator.InitializationSucceeded();
     615             : 
     616           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     617             :              aCache->GetWrapperPreserveColor() == aReflector);
     618             :   // If proto != canonicalProto, we have to preserve our wrapper;
     619             :   // otherwise we won't be able to properly recreate it later, since
     620             :   // we won't know what proto to use.  Note that we don't check
     621             :   // aGivenProto here, since it's entirely possible (and even
     622             :   // somewhat common) to have a non-null aGivenProto which is the
     623             :   // same as canonicalProto.
     624           0 :   if (proto != canonicalProto) {
     625           0 :     PreserveWrapper(aObject);
     626             :   }
     627             : 
     628           0 :   return true;
     629             : }
     630             : 
     631             : const NativePropertyHooks sNativePropertyHooks[] = { {
     632             :   nullptr,
     633             :   nullptr,
     634             :   nullptr,
     635             :   { sNativeProperties.Upcast(), nullptr },
     636             :   prototypes::id::ScrollViewChangeEvent,
     637             :   constructors::id::ScrollViewChangeEvent,
     638             :   EventBinding::sNativePropertyHooks,
     639             :   &DefaultXrayExpandoObjectClass
     640             : } };
     641             : 
     642             : void
     643           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     644             : {
     645           0 :   JS::Handle<JSObject*> parentProto(EventBinding::GetProtoObjectHandle(aCx));
     646           0 :   if (!parentProto) {
     647           0 :     return;
     648             :   }
     649             : 
     650           0 :   JS::Handle<JSObject*> constructorProto(EventBinding::GetConstructorObjectHandle(aCx));
     651           0 :   if (!constructorProto) {
     652           0 :     return;
     653             :   }
     654             : 
     655             :   static bool sIdsInited = false;
     656           0 :   if (!sIdsInited && NS_IsMainThread()) {
     657           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     658           0 :       return;
     659             :     }
     660           0 :     sIdsInited = true;
     661             :   }
     662             : 
     663           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ScrollViewChangeEvent);
     664           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ScrollViewChangeEvent);
     665           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     666             :                               &sPrototypeClass.mBase, protoCache,
     667             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
     668             :                               interfaceCache,
     669             :                               sNativeProperties.Upcast(),
     670             :                               nullptr,
     671             :                               "ScrollViewChangeEvent", aDefineOnGlobal,
     672             :                               nullptr,
     673           0 :                               false);
     674             : 
     675           0 :   JS::Rooted<JSObject*> unforgeableHolder(aCx);
     676             :   {
     677           0 :     JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
     678           0 :     unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
     679           0 :     if (!unforgeableHolder) {
     680           0 :       *protoCache = nullptr;
     681           0 :       if (interfaceCache) {
     682           0 :         *interfaceCache = nullptr;
     683             :       }
     684           0 :       return;
     685             :     }
     686             :   }
     687             : 
     688           0 :   if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
     689           0 :     *protoCache = nullptr;
     690           0 :     if (interfaceCache) {
     691           0 :       *interfaceCache = nullptr;
     692             :     }
     693           0 :     return;
     694             :   }
     695             : 
     696           0 :   if (*protoCache) {
     697           0 :     js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
     698           0 :                         JS::ObjectValue(*unforgeableHolder));
     699             :   }
     700             : }
     701             : 
     702             : JS::Handle<JSObject*>
     703           0 : GetProtoObjectHandle(JSContext* aCx)
     704             : {
     705             :   /* Get the interface prototype object for this class.  This will create the
     706             :      object as needed. */
     707           0 :   bool aDefineOnGlobal = true;
     708             : 
     709             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     710           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     711           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     712           0 :     return nullptr;
     713             :   }
     714             : 
     715             :   /* Check to see whether the interface objects are already installed */
     716           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     717           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::ScrollViewChangeEvent)) {
     718           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     719           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     720             :   }
     721             : 
     722             :   /*
     723             :    * The object might _still_ be null, but that's OK.
     724             :    *
     725             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     726             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     727             :    * changed after they have been set.
     728             :    *
     729             :    * Calling address() avoids the read read barrier that does gray
     730             :    * unmarking, but it's not possible for the object to be gray here.
     731             :    */
     732             : 
     733           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::ScrollViewChangeEvent);
     734           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     735           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     736             : }
     737             : 
     738             : JS::Handle<JSObject*>
     739           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     740             : {
     741             :   /* Get the interface object for this class.  This will create the object as
     742             :      needed. */
     743             : 
     744             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     745           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     746           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     747           0 :     return nullptr;
     748             :   }
     749             : 
     750             :   /* Check to see whether the interface objects are already installed */
     751           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     752           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::ScrollViewChangeEvent)) {
     753           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     754           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     755             :   }
     756             : 
     757             :   /*
     758             :    * The object might _still_ be null, but that's OK.
     759             :    *
     760             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     761             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     762             :    * changed after they have been set.
     763             :    *
     764             :    * Calling address() avoids the read read barrier that does gray
     765             :    * unmarking, but it's not possible for the object to be gray here.
     766             :    */
     767             : 
     768           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::ScrollViewChangeEvent);
     769           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     770           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     771             : }
     772             : 
     773             : JSObject*
     774           0 : GetConstructorObject(JSContext* aCx)
     775             : {
     776           0 :   return GetConstructorObjectHandle(aCx);
     777             : }
     778             : 
     779             : } // namespace ScrollViewChangeEventBinding
     780             : 
     781             : 
     782             : 
     783             : } // namespace dom
     784             : } // namespace mozilla

Generated by: LCOV version 1.13