LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom - DocumentBinding.h (source / functions) Hit Total Coverage
Test: output.info Lines: 51 66 77.3 %
Date: 2017-07-14 16:53:18 Functions: 15 20 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Document.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #ifndef mozilla_dom_DocumentBinding_h
       4             : #define mozilla_dom_DocumentBinding_h
       5             : 
       6             : #include "js/RootingAPI.h"
       7             : #include "jspubtd.h"
       8             : #include "mozilla/ErrorResult.h"
       9             : #include "mozilla/dom/BindingDeclarations.h"
      10             : #include "mozilla/dom/FakeString.h"
      11             : #include "mozilla/dom/Nullable.h"
      12             : #include "mozilla/dom/UnionMember.h"
      13             : 
      14             : class nsIDocument;
      15             : struct nsIDocumentAtoms;
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : struct ElementCreationOptionsAtoms;
      21             : struct NativePropertyHooks;
      22             : class ProtoAndIfaceCache;
      23             : 
      24             : } // namespace dom
      25             : } // namespace mozilla
      26             : 
      27             : namespace mozilla {
      28             : namespace dom {
      29             : 
      30             : enum class VisibilityState : uint8_t {
      31             :   Hidden,
      32             :   Visible,
      33             :   Prerender,
      34             :   EndGuard_
      35             : };
      36             : 
      37             : namespace VisibilityStateValues {
      38             : extern const EnumEntry strings[4];
      39             : } // namespace VisibilityStateValues
      40             : 
      41             : bool
      42             : ToJSValue(JSContext* aCx, VisibilityState aArgument, JS::MutableHandle<JS::Value> aValue);
      43             : 
      44             : 
      45             : enum class FlashClassification : uint8_t {
      46             :   Unclassified,
      47             :   Unknown,
      48             :   Allowed,
      49             :   Denied,
      50             :   EndGuard_
      51             : };
      52             : 
      53             : namespace FlashClassificationValues {
      54             : extern const EnumEntry strings[5];
      55             : } // namespace FlashClassificationValues
      56             : 
      57             : bool
      58             : ToJSValue(JSContext* aCx, FlashClassification aArgument, JS::MutableHandle<JS::Value> aValue);
      59             : 
      60             : 
      61          56 : struct ElementCreationOptions : public DictionaryBase
      62             : {
      63             :   MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mIs;
      64             :   MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mPseudo;
      65             : 
      66             :   ElementCreationOptions();
      67             : 
      68          56 :   explicit inline ElementCreationOptions(const FastDictionaryInitializer& )
      69          56 :   {
      70             :     // Do nothing here; this is used by our "Fast" subclass
      71          56 :   }
      72             : 
      73             :   explicit inline ElementCreationOptions(const ElementCreationOptions& aOther)
      74             :   {
      75             :     *this = aOther;
      76             :   }
      77             : 
      78             :   bool
      79             :   Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
      80             : 
      81             :   bool
      82             :   Init(const nsAString& aJSON);
      83             : 
      84             :   bool
      85             :   ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
      86             : 
      87             :   bool
      88             :   ToJSON(nsAString& aJSON) const;
      89             : 
      90             :   void
      91             :   TraceDictionary(JSTracer* trc);
      92             : 
      93             :   ElementCreationOptions&
      94             :   operator=(const ElementCreationOptions& aOther);
      95             : 
      96             : private:
      97             :   static bool
      98             :   InitIds(JSContext* cx, ElementCreationOptionsAtoms* atomsCache);
      99             : };
     100             : 
     101             : namespace binding_detail {
     102          56 : struct FastElementCreationOptions : public ElementCreationOptions
     103             : {
     104          56 :   inline FastElementCreationOptions()
     105          56 :     : ElementCreationOptions(FastDictionaryInitializer())
     106             :   {
     107             :     // Doesn't matter what int we pass to the parent constructor
     108          56 :   }
     109             : };
     110             : } // namespace binding_detail
     111             : 
     112             : 
     113             : class ElementCreationOptionsOrString
     114             : {
     115             :   friend class ElementCreationOptionsOrStringArgument;
     116             :   enum Type
     117             :   {
     118             :     eUninitialized,
     119             :     eElementCreationOptions,
     120             :     eString
     121             :   };
     122             : 
     123          81 :   union Value
     124             :   {
     125             :     UnionMember<binding_detail::FastElementCreationOptions > mElementCreationOptions;
     126             :     UnionMember<binding_detail::FakeString > mString;
     127             : 
     128             :   };
     129             : 
     130             :   Type mType;
     131             :   Value mValue;
     132             : 
     133             :   ElementCreationOptionsOrString(const ElementCreationOptionsOrString&) = delete;
     134             :   ElementCreationOptionsOrString& operator=(const ElementCreationOptionsOrString&) = delete;
     135             : public:
     136          81 :   explicit inline ElementCreationOptionsOrString()
     137          81 :     : mType(eUninitialized)
     138             :   {
     139          81 :   }
     140             : 
     141          81 :   inline ~ElementCreationOptionsOrString()
     142          81 :   {
     143          81 :     Uninit();
     144          81 :   }
     145             : 
     146             :   inline binding_detail::FastElementCreationOptions&
     147          56 :   RawSetAsElementCreationOptions()
     148             :   {
     149          56 :     if (mType == eElementCreationOptions) {
     150           0 :       return mValue.mElementCreationOptions.Value();
     151             :     }
     152          56 :     MOZ_ASSERT(mType == eUninitialized);
     153          56 :     mType = eElementCreationOptions;
     154          56 :     return mValue.mElementCreationOptions.SetValue();
     155             :   }
     156             : 
     157             :   inline binding_detail::FastElementCreationOptions&
     158             :   SetAsElementCreationOptions()
     159             :   {
     160             :     if (mType == eElementCreationOptions) {
     161             :       return mValue.mElementCreationOptions.Value();
     162             :     }
     163             :     Uninit();
     164             :     mType = eElementCreationOptions;
     165             :     return mValue.mElementCreationOptions.SetValue();
     166             :   }
     167             : 
     168             :   inline bool
     169         152 :   IsElementCreationOptions() const
     170             :   {
     171         152 :     return mType == eElementCreationOptions;
     172             :   }
     173             : 
     174             :   inline binding_detail::FastElementCreationOptions&
     175             :   GetAsElementCreationOptions()
     176             :   {
     177             :     MOZ_ASSERT(IsElementCreationOptions(), "Wrong type!");
     178             :     return mValue.mElementCreationOptions.Value();
     179             :   }
     180             : 
     181             :   inline const ElementCreationOptions&
     182          48 :   GetAsElementCreationOptions() const
     183             :   {
     184          48 :     MOZ_ASSERT(IsElementCreationOptions(), "Wrong type!");
     185          48 :     return mValue.mElementCreationOptions.Value();
     186             :   }
     187             : 
     188             :   inline binding_detail::FakeString&
     189             :   RawSetAsString()
     190             :   {
     191             :     if (mType == eString) {
     192             :       return mValue.mString.Value();
     193             :     }
     194             :     MOZ_ASSERT(mType == eUninitialized);
     195             :     mType = eString;
     196             :     return mValue.mString.SetValue();
     197             :   }
     198             : 
     199             :   inline binding_detail::FakeString&
     200          25 :   SetAsString()
     201             :   {
     202          25 :     if (mType == eString) {
     203           0 :       return mValue.mString.Value();
     204             :     }
     205          25 :     Uninit();
     206          25 :     mType = eString;
     207          25 :     return mValue.mString.SetValue();
     208             :   }
     209             : 
     210             :   inline bool
     211          25 :   IsString() const
     212             :   {
     213          25 :     return mType == eString;
     214             :   }
     215             : 
     216             :   inline binding_detail::FakeString&
     217             :   GetAsString()
     218             :   {
     219             :     MOZ_ASSERT(IsString(), "Wrong type!");
     220             :     return mValue.mString.Value();
     221             :   }
     222             : 
     223             :   inline const nsAString&
     224             :   GetAsString() const
     225             :   {
     226             :     MOZ_ASSERT(IsString(), "Wrong type!");
     227             :     return mValue.mString.Value();
     228             :   }
     229             : 
     230             :   inline void
     231         106 :   Uninit()
     232             :   {
     233         106 :     switch (mType) {
     234             :       case eUninitialized: {
     235          25 :         break;
     236             :       }
     237             :       case eElementCreationOptions: {
     238          56 :         DestroyElementCreationOptions();
     239          56 :         break;
     240             :       }
     241             :       case eString: {
     242          25 :         DestroyString();
     243          25 :         break;
     244             :       }
     245             :     }
     246         106 :   }
     247             : 
     248             :   bool
     249             :   ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
     250             : 
     251             : private:
     252             :   inline void
     253          56 :   DestroyElementCreationOptions()
     254             :   {
     255          56 :     MOZ_ASSERT(IsElementCreationOptions(), "Wrong type!");
     256          56 :     mValue.mElementCreationOptions.Destroy();
     257          56 :     mType = eUninitialized;
     258          56 :   }
     259             : 
     260             :   inline void
     261          25 :   DestroyString()
     262             :   {
     263          25 :     MOZ_ASSERT(IsString(), "Wrong type!");
     264          25 :     mValue.mString.Destroy();
     265          25 :     mType = eUninitialized;
     266          25 :   }
     267             : };
     268             : 
     269             : 
     270             : class OwningElementCreationOptionsOrString : public AllOwningUnionBase
     271             : {
     272             :   friend void ImplCycleCollectionUnlink(OwningElementCreationOptionsOrString& aUnion);
     273             :   enum Type
     274             :   {
     275             :     eUninitialized,
     276             :     eElementCreationOptions,
     277             :     eString
     278             :   };
     279             : 
     280             :   union Value
     281             :   {
     282             :     UnionMember<ElementCreationOptions > mElementCreationOptions;
     283             :     UnionMember<nsString > mString;
     284             : 
     285             :   };
     286             : 
     287             :   Type mType;
     288             :   Value mValue;
     289             : 
     290             : public:
     291             :   explicit inline OwningElementCreationOptionsOrString()
     292             :     : mType(eUninitialized)
     293             :   {
     294             :   }
     295             : 
     296             :   explicit inline OwningElementCreationOptionsOrString(const OwningElementCreationOptionsOrString& aOther)
     297             :     : mType(eUninitialized)
     298             :   {
     299             :     *this = aOther;
     300             :   }
     301             : 
     302             :   inline ~OwningElementCreationOptionsOrString()
     303             :   {
     304             :     Uninit();
     305             :   }
     306             : 
     307             :   ElementCreationOptions&
     308             :   RawSetAsElementCreationOptions();
     309             : 
     310             :   ElementCreationOptions&
     311             :   SetAsElementCreationOptions();
     312             : 
     313             :   bool
     314             :   TrySetToElementCreationOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
     315             : 
     316             :   inline bool
     317           0 :   IsElementCreationOptions() const
     318             :   {
     319           0 :     return mType == eElementCreationOptions;
     320             :   }
     321             : 
     322             :   inline ElementCreationOptions&
     323             :   GetAsElementCreationOptions()
     324             :   {
     325             :     MOZ_ASSERT(IsElementCreationOptions(), "Wrong type!");
     326             :     return mValue.mElementCreationOptions.Value();
     327             :   }
     328             : 
     329             :   inline ElementCreationOptions const &
     330           0 :   GetAsElementCreationOptions() const
     331             :   {
     332           0 :     MOZ_ASSERT(IsElementCreationOptions(), "Wrong type!");
     333           0 :     return mValue.mElementCreationOptions.Value();
     334             :   }
     335             : 
     336             :   nsString&
     337             :   RawSetAsString();
     338             : 
     339             :   nsString&
     340             :   SetAsString();
     341             : 
     342             :   bool
     343             :   TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
     344             : 
     345             :   inline void
     346             :   SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
     347             :   {
     348             :     RawSetAsString().Assign(aData, aLength);
     349             :   }
     350             : 
     351             :   inline bool
     352           0 :   IsString() const
     353             :   {
     354           0 :     return mType == eString;
     355             :   }
     356             : 
     357             :   inline nsString&
     358             :   GetAsString()
     359             :   {
     360             :     MOZ_ASSERT(IsString(), "Wrong type!");
     361             :     return mValue.mString.Value();
     362             :   }
     363             : 
     364             :   inline nsString const &
     365           0 :   GetAsString() const
     366             :   {
     367           0 :     MOZ_ASSERT(IsString(), "Wrong type!");
     368           0 :     return mValue.mString.Value();
     369             :   }
     370             : 
     371             :   void
     372             :   Uninit();
     373             : 
     374             :   bool
     375             :   ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
     376             : 
     377             :   void
     378             :   TraceUnion(JSTracer* trc);
     379             : 
     380             :   OwningElementCreationOptionsOrString&
     381             :   operator=(const OwningElementCreationOptionsOrString& aOther);
     382             : 
     383             : private:
     384             :   void
     385             :   DestroyElementCreationOptions();
     386             : 
     387             :   void
     388             :   DestroyString();
     389             : };
     390             : 
     391             : 
     392             : namespace DocumentBinding {
     393             : 
     394             :   typedef nsIDocument NativeType;
     395             : 
     396             :   JSObject*
     397             :   DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
     398             : 
     399             :   const JSClass*
     400             :   GetJSClass();
     401             : 
     402             :   bool
     403             :   Wrap(JSContext* aCx, nsIDocument* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
     404             : 
     405             :   template <class T>
     406           0 :   inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
     407             :   {
     408           0 :     JS::Rooted<JSObject*> reflector(aCx);
     409           0 :     return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
     410             :   }
     411             : 
     412             :   // We declare this as an array so that retrieving a pointer to this
     413             :   // binding's property hooks only requires compile/link-time resolvable
     414             :   // address arithmetic.  Declaring it as a pointer instead would require
     415             :   // doing a run-time load to fetch a pointer to this binding's property
     416             :   // hooks.  And then structures which embedded a pointer to this structure
     417             :   // would require a run-time load for proper initialization, which would
     418             :   // then induce static constructors.  Lots of static constructors.
     419             :   extern const NativePropertyHooks sNativePropertyHooks[];
     420             : 
     421             :   void
     422             :   CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
     423             : 
     424             :   JS::Handle<JSObject*>
     425             :   GetProtoObjectHandle(JSContext* aCx);
     426             : 
     427             :   JSObject*
     428             :   GetProtoObject(JSContext* aCx);
     429             : 
     430             :   JS::Handle<JSObject*>
     431             :   GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
     432             : 
     433             :   JSObject*
     434             :   GetConstructorObject(JSContext* aCx);
     435             : 
     436             : } // namespace DocumentBinding
     437             : 
     438             : 
     439             : 
     440             : } // namespace dom
     441             : } // namespace mozilla
     442             : 
     443             : #endif // mozilla_dom_DocumentBinding_h

Generated by: LCOV version 1.13