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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM BrowserElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "BrowserElementBinding.h"
       5             : #include "jsapi.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       9             : #include "mozilla/dom/ScriptSettings.h"
      10             : #include "mozilla/dom/SimpleGlobalObject.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : namespace BrowserFindCaseSensitivityValues {
      16             : extern const EnumEntry strings[3] = {
      17             :   {"case-sensitive", 14},
      18             :   {"case-insensitive", 16},
      19             :   { nullptr, 0 }
      20             : };
      21             : } // namespace BrowserFindCaseSensitivityValues
      22             : 
      23             : bool
      24           0 : ToJSValue(JSContext* aCx, BrowserFindCaseSensitivity aArgument, JS::MutableHandle<JS::Value> aValue)
      25             : {
      26           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(BrowserFindCaseSensitivityValues::strings));
      27             :   JSString* resultStr =
      28           0 :     JS_NewStringCopyN(aCx, BrowserFindCaseSensitivityValues::strings[uint32_t(aArgument)].value,
      29           0 :                       BrowserFindCaseSensitivityValues::strings[uint32_t(aArgument)].length);
      30           0 :   if (!resultStr) {
      31           0 :     return false;
      32             :   }
      33           0 :   aValue.setString(resultStr);
      34           0 :   return true;
      35             : }
      36             : 
      37             : 
      38             : namespace BrowserFindDirectionValues {
      39             : extern const EnumEntry strings[3] = {
      40             :   {"forward", 7},
      41             :   {"backward", 8},
      42             :   { nullptr, 0 }
      43             : };
      44             : } // namespace BrowserFindDirectionValues
      45             : 
      46             : bool
      47           0 : ToJSValue(JSContext* aCx, BrowserFindDirection aArgument, JS::MutableHandle<JS::Value> aValue)
      48             : {
      49           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(BrowserFindDirectionValues::strings));
      50             :   JSString* resultStr =
      51           0 :     JS_NewStringCopyN(aCx, BrowserFindDirectionValues::strings[uint32_t(aArgument)].value,
      52           0 :                       BrowserFindDirectionValues::strings[uint32_t(aArgument)].length);
      53           0 :   if (!resultStr) {
      54           0 :     return false;
      55             :   }
      56           0 :   aValue.setString(resultStr);
      57           0 :   return true;
      58             : }
      59             : 
      60             : 
      61             : 
      62           0 : BrowserElementDownloadOptions::BrowserElementDownloadOptions()
      63             : {
      64             :   // Safe to pass a null context if we pass a null value
      65           0 :   Init(nullptr, JS::NullHandleValue);
      66           0 : }
      67             : 
      68             : 
      69             : 
      70             : bool
      71           0 : BrowserElementDownloadOptions::InitIds(JSContext* cx, BrowserElementDownloadOptionsAtoms* atomsCache)
      72             : {
      73           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      74             : 
      75             :   // Initialize these in reverse order so that any failure leaves the first one
      76             :   // uninitialized.
      77           0 :   if (!atomsCache->referrer_id.init(cx, "referrer") ||
      78           0 :       !atomsCache->filename_id.init(cx, "filename")) {
      79           0 :     return false;
      80             :   }
      81           0 :   return true;
      82             : }
      83             : 
      84             : bool
      85           0 : BrowserElementDownloadOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      86             : {
      87             :   // Passing a null JSContext is OK only if we're initing from null,
      88             :   // Since in that case we will not have to do any property gets
      89             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      90             :   // checkers by static analysis tools
      91           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      92           0 :   BrowserElementDownloadOptionsAtoms* atomsCache = nullptr;
      93           0 :   if (cx) {
      94           0 :     atomsCache = GetAtomCache<BrowserElementDownloadOptionsAtoms>(cx);
      95           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      96           0 :       return false;
      97             :     }
      98             :   }
      99             : 
     100           0 :   if (!IsConvertibleToDictionary(val)) {
     101           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     102             :   }
     103             : 
     104           0 :   bool isNull = val.isNullOrUndefined();
     105             :   // We only need these if !isNull, in which case we have |cx|.
     106           0 :   Maybe<JS::Rooted<JSObject *> > object;
     107           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     108           0 :   if (!isNull) {
     109           0 :     MOZ_ASSERT(cx);
     110           0 :     object.emplace(cx, &val.toObject());
     111           0 :     temp.emplace(cx);
     112             :   }
     113           0 :   if (!isNull) {
     114           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->filename_id, temp.ptr())) {
     115           0 :       return false;
     116             :     }
     117             :   }
     118           0 :   if (!isNull && !temp->isUndefined()) {
     119           0 :     mFilename.Construct();
     120           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mFilename.Value()))) {
     121           0 :       return false;
     122             :     }
     123           0 :     mIsAnyMemberPresent = true;
     124             :   }
     125             : 
     126           0 :   if (!isNull) {
     127           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->referrer_id, temp.ptr())) {
     128           0 :       return false;
     129             :     }
     130             :   }
     131           0 :   if (!isNull && !temp->isUndefined()) {
     132           0 :     mReferrer.Construct();
     133           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mReferrer.Value()))) {
     134           0 :       return false;
     135             :     }
     136           0 :     mIsAnyMemberPresent = true;
     137             :   }
     138           0 :   return true;
     139             : }
     140             : 
     141             : bool
     142           0 : BrowserElementDownloadOptions::Init(const nsAString& aJSON)
     143             : {
     144           0 :   AutoJSAPI jsapi;
     145           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     146           0 :   if (!cleanGlobal) {
     147           0 :     return false;
     148             :   }
     149           0 :   if (!jsapi.Init(cleanGlobal)) {
     150           0 :     return false;
     151             :   }
     152           0 :   JSContext* cx = jsapi.cx();
     153           0 :   JS::Rooted<JS::Value> json(cx);
     154           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     155           0 :   NS_ENSURE_TRUE(ok, false);
     156           0 :   return Init(cx, json);
     157             : }
     158             : 
     159             : bool
     160           0 : BrowserElementDownloadOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     161             : {
     162           0 :   BrowserElementDownloadOptionsAtoms* atomsCache = GetAtomCache<BrowserElementDownloadOptionsAtoms>(cx);
     163           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     164           0 :     return false;
     165             :   }
     166             : 
     167           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     168           0 :   if (!obj) {
     169           0 :     return false;
     170             :   }
     171           0 :   rval.set(JS::ObjectValue(*obj));
     172             : 
     173           0 :   if (mFilename.WasPassed()) {
     174             :     do {
     175             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     176           0 :       JS::Rooted<JS::Value> temp(cx);
     177           0 :       nsString const & currentValue = mFilename.InternalValue();
     178           0 :       if (!xpc::StringToJsval(cx, currentValue, &temp)) {
     179           0 :         return false;
     180             :       }
     181           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->filename_id, temp, JSPROP_ENUMERATE)) {
     182           0 :         return false;
     183             :       }
     184           0 :       break;
     185             :     } while(0);
     186             :   }
     187             : 
     188           0 :   if (mReferrer.WasPassed()) {
     189             :     do {
     190             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     191           0 :       JS::Rooted<JS::Value> temp(cx);
     192           0 :       nsString const & currentValue = mReferrer.InternalValue();
     193           0 :       if (!xpc::StringToJsval(cx, currentValue, &temp)) {
     194           0 :         return false;
     195             :       }
     196           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->referrer_id, temp, JSPROP_ENUMERATE)) {
     197           0 :         return false;
     198             :       }
     199           0 :       break;
     200             :     } while(0);
     201             :   }
     202             : 
     203           0 :   return true;
     204             : }
     205             : 
     206             : bool
     207           0 : BrowserElementDownloadOptions::ToJSON(nsAString& aJSON) const
     208             : {
     209           0 :   AutoJSAPI jsapi;
     210           0 :   jsapi.Init();
     211           0 :   JSContext *cx = jsapi.cx();
     212             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     213             :   // because we'll only be creating objects, in ways that have no
     214             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     215             :   // which likewise guarantees no side-effects for the sorts of
     216             :   // things we will pass it.
     217           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     218           0 :   JS::Rooted<JS::Value> val(cx);
     219           0 :   if (!ToObjectInternal(cx, &val)) {
     220           0 :     return false;
     221             :   }
     222           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     223           0 :   return StringifyToJSON(cx, obj, aJSON);
     224             : }
     225             : 
     226             : void
     227           0 : BrowserElementDownloadOptions::TraceDictionary(JSTracer* trc)
     228             : {
     229           0 : }
     230             : 
     231             : BrowserElementDownloadOptions&
     232           0 : BrowserElementDownloadOptions::operator=(const BrowserElementDownloadOptions& aOther)
     233             : {
     234           0 :   mFilename.Reset();
     235           0 :   if (aOther.mFilename.WasPassed()) {
     236           0 :     mFilename.Construct(aOther.mFilename.Value());
     237             :   }
     238           0 :   mReferrer.Reset();
     239           0 :   if (aOther.mReferrer.WasPassed()) {
     240           0 :     mReferrer.Construct(aOther.mReferrer.Value());
     241             :   }
     242           0 :   return *this;
     243             : }
     244             : 
     245             : namespace binding_detail {
     246             : } // namespace binding_detail
     247             : 
     248             : 
     249             : 
     250           0 : BrowserElementExecuteScriptOptions::BrowserElementExecuteScriptOptions()
     251             : {
     252             :   // Safe to pass a null context if we pass a null value
     253           0 :   Init(nullptr, JS::NullHandleValue);
     254           0 : }
     255             : 
     256             : 
     257             : 
     258             : bool
     259           0 : BrowserElementExecuteScriptOptions::InitIds(JSContext* cx, BrowserElementExecuteScriptOptionsAtoms* atomsCache)
     260             : {
     261           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     262             : 
     263             :   // Initialize these in reverse order so that any failure leaves the first one
     264             :   // uninitialized.
     265           0 :   if (!atomsCache->url_id.init(cx, "url") ||
     266           0 :       !atomsCache->origin_id.init(cx, "origin")) {
     267           0 :     return false;
     268             :   }
     269           0 :   return true;
     270             : }
     271             : 
     272             : bool
     273           0 : BrowserElementExecuteScriptOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     274             : {
     275             :   // Passing a null JSContext is OK only if we're initing from null,
     276             :   // Since in that case we will not have to do any property gets
     277             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     278             :   // checkers by static analysis tools
     279           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     280           0 :   BrowserElementExecuteScriptOptionsAtoms* atomsCache = nullptr;
     281           0 :   if (cx) {
     282           0 :     atomsCache = GetAtomCache<BrowserElementExecuteScriptOptionsAtoms>(cx);
     283           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     284           0 :       return false;
     285             :     }
     286             :   }
     287             : 
     288           0 :   if (!IsConvertibleToDictionary(val)) {
     289           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     290             :   }
     291             : 
     292           0 :   bool isNull = val.isNullOrUndefined();
     293             :   // We only need these if !isNull, in which case we have |cx|.
     294           0 :   Maybe<JS::Rooted<JSObject *> > object;
     295           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     296           0 :   if (!isNull) {
     297           0 :     MOZ_ASSERT(cx);
     298           0 :     object.emplace(cx, &val.toObject());
     299           0 :     temp.emplace(cx);
     300             :   }
     301           0 :   if (!isNull) {
     302           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->origin_id, temp.ptr())) {
     303           0 :       return false;
     304             :     }
     305             :   }
     306           0 :   if (!isNull && !temp->isUndefined()) {
     307           0 :     mOrigin.Construct();
     308           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mOrigin.Value()))) {
     309           0 :       return false;
     310             :     }
     311           0 :     mIsAnyMemberPresent = true;
     312             :   }
     313             : 
     314           0 :   if (!isNull) {
     315           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->url_id, temp.ptr())) {
     316           0 :       return false;
     317             :     }
     318             :   }
     319           0 :   if (!isNull && !temp->isUndefined()) {
     320           0 :     mUrl.Construct();
     321           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, (mUrl.Value()))) {
     322           0 :       return false;
     323             :     }
     324           0 :     mIsAnyMemberPresent = true;
     325             :   }
     326           0 :   return true;
     327             : }
     328             : 
     329             : bool
     330           0 : BrowserElementExecuteScriptOptions::Init(const nsAString& aJSON)
     331             : {
     332           0 :   AutoJSAPI jsapi;
     333           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     334           0 :   if (!cleanGlobal) {
     335           0 :     return false;
     336             :   }
     337           0 :   if (!jsapi.Init(cleanGlobal)) {
     338           0 :     return false;
     339             :   }
     340           0 :   JSContext* cx = jsapi.cx();
     341           0 :   JS::Rooted<JS::Value> json(cx);
     342           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     343           0 :   NS_ENSURE_TRUE(ok, false);
     344           0 :   return Init(cx, json);
     345             : }
     346             : 
     347             : bool
     348           0 : BrowserElementExecuteScriptOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     349             : {
     350           0 :   BrowserElementExecuteScriptOptionsAtoms* atomsCache = GetAtomCache<BrowserElementExecuteScriptOptionsAtoms>(cx);
     351           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     352           0 :     return false;
     353             :   }
     354             : 
     355           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     356           0 :   if (!obj) {
     357           0 :     return false;
     358             :   }
     359           0 :   rval.set(JS::ObjectValue(*obj));
     360             : 
     361           0 :   if (mOrigin.WasPassed()) {
     362             :     do {
     363             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     364           0 :       JS::Rooted<JS::Value> temp(cx);
     365           0 :       nsString const & currentValue = mOrigin.InternalValue();
     366           0 :       if (!xpc::StringToJsval(cx, currentValue, &temp)) {
     367           0 :         return false;
     368             :       }
     369           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->origin_id, temp, JSPROP_ENUMERATE)) {
     370           0 :         return false;
     371             :       }
     372           0 :       break;
     373             :     } while(0);
     374             :   }
     375             : 
     376           0 :   if (mUrl.WasPassed()) {
     377             :     do {
     378             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     379           0 :       JS::Rooted<JS::Value> temp(cx);
     380           0 :       nsString const & currentValue = mUrl.InternalValue();
     381           0 :       if (!xpc::StringToJsval(cx, currentValue, &temp)) {
     382           0 :         return false;
     383             :       }
     384           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->url_id, temp, JSPROP_ENUMERATE)) {
     385           0 :         return false;
     386             :       }
     387           0 :       break;
     388             :     } while(0);
     389             :   }
     390             : 
     391           0 :   return true;
     392             : }
     393             : 
     394             : bool
     395           0 : BrowserElementExecuteScriptOptions::ToJSON(nsAString& aJSON) const
     396             : {
     397           0 :   AutoJSAPI jsapi;
     398           0 :   jsapi.Init();
     399           0 :   JSContext *cx = jsapi.cx();
     400             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     401             :   // because we'll only be creating objects, in ways that have no
     402             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     403             :   // which likewise guarantees no side-effects for the sorts of
     404             :   // things we will pass it.
     405           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     406           0 :   JS::Rooted<JS::Value> val(cx);
     407           0 :   if (!ToObjectInternal(cx, &val)) {
     408           0 :     return false;
     409             :   }
     410           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     411           0 :   return StringifyToJSON(cx, obj, aJSON);
     412             : }
     413             : 
     414             : void
     415           0 : BrowserElementExecuteScriptOptions::TraceDictionary(JSTracer* trc)
     416             : {
     417           0 : }
     418             : 
     419             : BrowserElementExecuteScriptOptions&
     420           0 : BrowserElementExecuteScriptOptions::operator=(const BrowserElementExecuteScriptOptions& aOther)
     421             : {
     422           0 :   mOrigin.Reset();
     423           0 :   if (aOther.mOrigin.WasPassed()) {
     424           0 :     mOrigin.Construct(aOther.mOrigin.Value());
     425             :   }
     426           0 :   mUrl.Reset();
     427           0 :   if (aOther.mUrl.WasPassed()) {
     428           0 :     mUrl.Construct(aOther.mUrl.Value());
     429             :   }
     430           0 :   return *this;
     431             : }
     432             : 
     433             : namespace binding_detail {
     434             : } // namespace binding_detail
     435             : 
     436             : 
     437             : void
     438           0 : BrowserElementNextPaintEventCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
     439             : {
     440           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     441             : 
     442           0 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     443           0 :   if (!JS::Call(cx, aThisVal, callable,
     444           0 :                 JS::HandleValueArray::empty(), &rval)) {
     445           0 :     aRv.NoteJSContextException(cx);
     446           0 :     return;
     447             :   }
     448             : }
     449             : 
     450             : 
     451             : 
     452             : namespace binding_detail {
     453             : } // namespace binding_detail
     454             : 
     455             : 
     456             : } // namespace dom
     457             : } // namespace mozilla

Generated by: LCOV version 1.13