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

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

Generated by: LCOV version 1.13