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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM HTMLPictureElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "HTMLElementBinding.h"
       4             : #include "HTMLPictureElementBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/HTMLPictureElement.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/XrayExpandoClass.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace dom {
      15             : 
      16             : namespace HTMLPictureElementBinding {
      17             : 
      18             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
      19             :               "Can't inherit from an interface with a different ownership model.");
      20             : 
      21             : static bool
      22           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      23             : {
      24           0 :   mozilla::dom::HTMLPictureElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLPictureElement>(obj);
      25             :   // We don't want to preserve if we don't have a wrapper, and we
      26             :   // obviously can't preserve if we're not initialized.
      27           0 :   if (self && self->GetWrapperPreserveColor()) {
      28           0 :     PreserveWrapper(self);
      29             :   }
      30           0 :   return true;
      31             : }
      32             : 
      33             : static void
      34           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      35             : {
      36           0 :   mozilla::dom::HTMLPictureElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLPictureElement>(obj);
      37           0 :   if (self) {
      38           0 :     ClearWrapper(self, self, obj);
      39           0 :     AddForDeferredFinalization<mozilla::dom::HTMLPictureElement>(self);
      40             :   }
      41           0 : }
      42             : 
      43             : static void
      44           0 : _objectMoved(JSObject* obj, const JSObject* old)
      45             : {
      46           0 :   mozilla::dom::HTMLPictureElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLPictureElement>(obj);
      47           0 :   if (self) {
      48           0 :     UpdateWrapper(self, self, obj, old);
      49             :   }
      50           0 : }
      51             : 
      52             : static bool
      53           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
      54             : {
      55           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
      56           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
      57           0 :   if (!args.isConstructing()) {
      58             :     // XXXbz wish I could get the name from the callee instead of
      59             :     // Adding more relocations
      60           0 :     return ThrowConstructorWithoutNew(cx, "HTMLPictureElement");
      61             :   }
      62             : 
      63           0 :   GlobalObject global(cx, obj);
      64           0 :   if (global.Failed()) {
      65           0 :     return false;
      66             :   }
      67             : 
      68             :   // The newTarget might be a cross-compartment wrapper. Get the underlying object
      69             :   // so we can do the spec's object-identity checks.
      70           0 :   JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
      71           0 :   if (!newTarget) {
      72           0 :     return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
      73             :   }
      74             : 
      75             :   // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
      76             :   // Enter the compartment of our underlying newTarget object, so we end
      77             :   // up comparing to the constructor object for our interface from that global.
      78             :   {
      79           0 :     JSAutoCompartment ac(cx, newTarget);
      80           0 :     JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
      81           0 :     if (!constructor) {
      82           0 :       return false;
      83             :     }
      84           0 :     if (newTarget == constructor) {
      85           0 :       return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
      86             :     }
      87             :   }
      88             : 
      89           0 :   JS::Rooted<JSObject*> desiredProto(cx);
      90           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
      91           0 :     return false;
      92             :   }
      93           0 :   if (!desiredProto) {
      94             :     // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
      95             :     // This fallback behavior is designed to match analogous behavior for the
      96             :     // JavaScript built-ins. So we enter the compartment of our underlying
      97             :     // newTarget object and fall back to the prototype object from that global.
      98             :     // XXX The spec says to use GetFunctionRealm(), which is not actually
      99             :     // the same thing as what we have here (e.g. in the case of scripted callable proxies
     100             :     // whose target is not same-compartment with the proxy, or bound functions, etc).
     101             :     // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
     102             :     {
     103           0 :       JSAutoCompartment ac(cx, newTarget);
     104           0 :       desiredProto = GetProtoObjectHandle(cx);
     105           0 :       if (!desiredProto) {
     106           0 :           return false;
     107             :       }
     108             :     }
     109             : 
     110             :     // desiredProto is in the compartment of the underlying newTarget object.
     111             :     // Wrap it into the context compartment.
     112           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     113           0 :       return false;
     114             :     }
     115             :   }
     116             : 
     117           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     118           0 :   Maybe<JSAutoCompartment> ac;
     119           0 :   if (objIsXray) {
     120           0 :     obj = js::CheckedUnwrap(obj);
     121           0 :     if (!obj) {
     122           0 :       return false;
     123             :     }
     124           0 :     ac.emplace(cx, obj);
     125           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     126           0 :       return false;
     127             :     }
     128             :   }
     129           0 :   binding_detail::FastErrorResult rv;
     130           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLPictureElement>(CreateHTMLElement(global, args, rv)));
     131           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     132           0 :     return false;
     133             :   }
     134           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     135             :   static_assert(!IsPointer<decltype(result)>::value,
     136             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     137           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     138           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     139           0 :     return false;
     140             :   }
     141           0 :   return true;
     142             : }
     143             : 
     144             : static const js::ClassOps sInterfaceObjectClassOps = {
     145             :     nullptr,               /* addProperty */
     146             :     nullptr,               /* delProperty */
     147             :     nullptr,               /* getProperty */
     148             :     nullptr,               /* setProperty */
     149             :     nullptr,               /* enumerate */
     150             :     nullptr,               /* newEnumerate */
     151             :     nullptr,               /* resolve */
     152             :     nullptr,               /* mayResolve */
     153             :     nullptr,               /* finalize */
     154             :     _constructor, /* call */
     155             :     nullptr,               /* hasInstance */
     156             :     _constructor, /* construct */
     157             :     nullptr,               /* trace */
     158             : };
     159             : 
     160             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     161             :   {
     162             :     "Function",
     163             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     164             :     &sInterfaceObjectClassOps,
     165             :     JS_NULL_CLASS_SPEC,
     166             :     JS_NULL_CLASS_EXT,
     167             :     &sInterfaceObjectClassObjectOps
     168             :   },
     169             :   eInterface,
     170             :   true,
     171             :   prototypes::id::HTMLPictureElement,
     172             :   PrototypeTraits<prototypes::id::HTMLPictureElement>::Depth,
     173             :   sNativePropertyHooks,
     174             :   "function HTMLPictureElement() {\n    [native code]\n}",
     175             :   HTMLElementBinding::GetConstructorObject
     176             : };
     177             : 
     178             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     179             :   {
     180             :     "HTMLPictureElementPrototype",
     181             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     182             :     JS_NULL_CLASS_OPS,
     183             :     JS_NULL_CLASS_SPEC,
     184             :     JS_NULL_CLASS_EXT,
     185             :     JS_NULL_OBJECT_OPS
     186             :   },
     187             :   eInterfacePrototype,
     188             :   false,
     189             :   prototypes::id::HTMLPictureElement,
     190             :   PrototypeTraits<prototypes::id::HTMLPictureElement>::Depth,
     191             :   sNativePropertyHooks,
     192             :   "[object HTMLPictureElementPrototype]",
     193             :   HTMLElementBinding::GetProtoObject
     194             : };
     195             : 
     196             : JSObject*
     197           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     198             : {
     199           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     200             : }
     201             : 
     202             : static const js::ClassOps sClassOps = {
     203             :   _addProperty, /* addProperty */
     204             :   nullptr,               /* delProperty */
     205             :   nullptr,               /* getProperty */
     206             :   nullptr,               /* setProperty */
     207             :   nullptr,               /* enumerate */
     208             :   nullptr, /* newEnumerate */
     209             :   nullptr, /* resolve */
     210             :   nullptr, /* mayResolve */
     211             :   _finalize, /* finalize */
     212             :   nullptr, /* call */
     213             :   nullptr,               /* hasInstance */
     214             :   nullptr,               /* construct */
     215             :   nullptr, /* trace */
     216             : };
     217             : 
     218             : static const js::ClassExtension sClassExtension = {
     219             :   nullptr, /* weakmapKeyDelegateOp */
     220             :   _objectMoved /* objectMovedOp */
     221             : };
     222             : 
     223             : static const DOMJSClass sClass = {
     224             :   { "HTMLPictureElement",
     225             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     226             :     &sClassOps,
     227             :     JS_NULL_CLASS_SPEC,
     228             :     &sClassExtension,
     229             :     JS_NULL_OBJECT_OPS
     230             :   },
     231             :   { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLPictureElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     232             :   IsBaseOf<nsISupports, mozilla::dom::HTMLPictureElement >::value,
     233             :   sNativePropertyHooks,
     234             :   FindAssociatedGlobalForNative<mozilla::dom::HTMLPictureElement>::Get,
     235             :   GetProtoObjectHandle,
     236             :   GetCCParticipant<mozilla::dom::HTMLPictureElement>::Get()
     237             : };
     238             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     239             :               "Must have the right minimal number of reserved slots.");
     240             : static_assert(1 >= 1,
     241             :               "Must have enough reserved slots.");
     242             : 
     243             : const JSClass*
     244           0 : GetJSClass()
     245             : {
     246           0 :   return sClass.ToJSClass();
     247             : }
     248             : 
     249             : bool
     250           0 : Wrap(JSContext* aCx, mozilla::dom::HTMLPictureElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     251             : {
     252             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLPictureElement*>(aObject) ==
     253             :              reinterpret_cast<mozilla::dom::HTMLPictureElement*>(aObject),
     254             :              "Multiple inheritance for mozilla::dom::HTMLPictureElement is broken.");
     255             :   MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
     256             :              reinterpret_cast<nsGenericHTMLElement*>(aObject),
     257             :              "Multiple inheritance for nsGenericHTMLElement is broken.");
     258             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     259             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     260             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     261             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     262             :              reinterpret_cast<nsINode*>(aObject),
     263             :              "Multiple inheritance for nsINode is broken.");
     264             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     265             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     266             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     267           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     268           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     269           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     270             :              "You should probably not be using Wrap() directly; use "
     271             :              "GetOrCreateDOMReflector instead");
     272             : 
     273           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     274             :              "nsISupports must be on our primary inheritance chain");
     275             : 
     276           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     277           0 :   if (!global) {
     278           0 :     return false;
     279             :   }
     280           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     281           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     282             : 
     283             :   // That might have ended up wrapping us already, due to the wonders
     284             :   // of XBL.  Check for that, and bail out as needed.
     285           0 :   aReflector.set(aCache->GetWrapper());
     286           0 :   if (aReflector) {
     287             : #ifdef DEBUG
     288           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     289             : #endif // DEBUG
     290           0 :     return true;
     291             :   }
     292             : 
     293           0 :   JSAutoCompartment ac(aCx, global);
     294           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     295           0 :   if (!canonicalProto) {
     296           0 :     return false;
     297             :   }
     298           0 :   JS::Rooted<JSObject*> proto(aCx);
     299           0 :   if (aGivenProto) {
     300           0 :     proto = aGivenProto;
     301             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     302             :     // coming in, we changed compartments to that of "parent" so may need
     303             :     // to wrap the proto here.
     304           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     305           0 :       if (!JS_WrapObject(aCx, &proto)) {
     306           0 :         return false;
     307             :       }
     308             :     }
     309             :   } else {
     310           0 :     proto = canonicalProto;
     311             :   }
     312             : 
     313           0 :   BindingJSObjectCreator<mozilla::dom::HTMLPictureElement> creator(aCx);
     314           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     315           0 :   if (!aReflector) {
     316           0 :     return false;
     317             :   }
     318             : 
     319           0 :   aCache->SetWrapper(aReflector);
     320           0 :   creator.InitializationSucceeded();
     321             : 
     322           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     323             :              aCache->GetWrapperPreserveColor() == aReflector);
     324             :   // If proto != canonicalProto, we have to preserve our wrapper;
     325             :   // otherwise we won't be able to properly recreate it later, since
     326             :   // we won't know what proto to use.  Note that we don't check
     327             :   // aGivenProto here, since it's entirely possible (and even
     328             :   // somewhat common) to have a non-null aGivenProto which is the
     329             :   // same as canonicalProto.
     330           0 :   if (proto != canonicalProto) {
     331           0 :     PreserveWrapper(aObject);
     332             :   }
     333             : 
     334           0 :   return true;
     335             : }
     336             : 
     337             : const NativePropertyHooks sNativePropertyHooks[] = { {
     338             :   nullptr,
     339             :   nullptr,
     340             :   nullptr,
     341             :   { nullptr, nullptr },
     342             :   prototypes::id::HTMLPictureElement,
     343             :   constructors::id::HTMLPictureElement,
     344             :   HTMLElementBinding::sNativePropertyHooks,
     345             :   &DefaultXrayExpandoObjectClass
     346             : } };
     347             : 
     348             : void
     349           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     350             : {
     351           0 :   JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
     352           0 :   if (!parentProto) {
     353           0 :     return;
     354             :   }
     355             : 
     356           0 :   JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
     357           0 :   if (!constructorProto) {
     358           0 :     return;
     359             :   }
     360             : 
     361           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLPictureElement);
     362           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLPictureElement);
     363           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     364             :                               &sPrototypeClass.mBase, protoCache,
     365             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     366             :                               interfaceCache,
     367             :                               nullptr,
     368             :                               nullptr,
     369             :                               "HTMLPictureElement", aDefineOnGlobal,
     370             :                               nullptr,
     371           0 :                               false);
     372             : }
     373             : 
     374             : JS::Handle<JSObject*>
     375           0 : GetProtoObjectHandle(JSContext* aCx)
     376             : {
     377             :   /* Get the interface prototype object for this class.  This will create the
     378             :      object as needed. */
     379           0 :   bool aDefineOnGlobal = true;
     380             : 
     381             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     382           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     383           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     384           0 :     return nullptr;
     385             :   }
     386             : 
     387             :   /* Check to see whether the interface objects are already installed */
     388           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     389           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLPictureElement)) {
     390           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     391           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     392             :   }
     393             : 
     394             :   /*
     395             :    * The object might _still_ be null, but that's OK.
     396             :    *
     397             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     398             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     399             :    * changed after they have been set.
     400             :    *
     401             :    * Calling address() avoids the read read barrier that does gray
     402             :    * unmarking, but it's not possible for the object to be gray here.
     403             :    */
     404             : 
     405           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLPictureElement);
     406           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     407           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     408             : }
     409             : 
     410             : JS::Handle<JSObject*>
     411           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     412             : {
     413             :   /* Get the interface object for this class.  This will create the object as
     414             :      needed. */
     415             : 
     416             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     417           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     418           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     419           0 :     return nullptr;
     420             :   }
     421             : 
     422             :   /* Check to see whether the interface objects are already installed */
     423           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     424           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLPictureElement)) {
     425           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     426           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     427             :   }
     428             : 
     429             :   /*
     430             :    * The object might _still_ be null, but that's OK.
     431             :    *
     432             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     433             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     434             :    * changed after they have been set.
     435             :    *
     436             :    * Calling address() avoids the read read barrier that does gray
     437             :    * unmarking, but it's not possible for the object to be gray here.
     438             :    */
     439             : 
     440           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLPictureElement);
     441           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     442           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     443             : }
     444             : 
     445             : JSObject*
     446           0 : GetConstructorObject(JSContext* aCx)
     447             : {
     448           0 :   return GetConstructorObjectHandle(aCx);
     449             : }
     450             : 
     451             : } // namespace HTMLPictureElementBinding
     452             : 
     453             : 
     454             : 
     455             : } // namespace dom
     456             : } // namespace mozilla

Generated by: LCOV version 1.13